Refactor NotePanel: cache derived tags/links/backlinks and avoid hot-path IO#820
Merged
multiplex55 merged 2 commits intomasterfrom Feb 11, 2026
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Description
NoteDerivedViewstruct and newNotePanelfields (derived: NoteDerivedView,derived_dirty: bool, and a test-onlyderived_recompute_count) to cache derived metadata such astags,wiki_links,external_links, backlink rows by category, and atodo_label_mapfor markdown preprocessing insrc/gui/note_panel.rs.NotePanel::refresh_derived(), called on panel init and after successful saves (also used for overwrite/save-as-new paths), and introducedbacklink_rows_for_active_tab()to page over precomputed backlink rows instead of recomputing each render.preprocess_note_linksto accept an injected todo label map (todo_labels: &HashMap<String, String>) to remove directload_todos()IO from markdown preprocessing and wired all callers to useself.derived.todo_label_map.pub fn note_cache_snapshot() -> Vec<Note>insrc/plugins/note.rsso UI code can read cached notes without callingload_notes()(disk) during repaint.derived_dirty = trueon edit-mode changes and when rendering segments mutate the note, and avoid per-keystroke recomputation;refresh_derived()runs after a successfulsave()(and related save flows) to updateself.note.linksand backlink rows.src/gui/note_panel.rstests for derived reuse across renders, recomputation aftersave()andnote.linksupdate, backlink invalidation when slug/targets change, andpreprocess_note_linksusing an injected todo map; insrc/plugins/note.rstests fornote_cache_snapshotread-only copy semantics and that it reflectsrefresh_cache()updates.Testing
cargo fmt --allsuccessfully to format changes.note_paneltests withcargo test, but the environment Rust toolchain is older than required by a transitive dependency (error:rustc 1.87.0vstimerequiring>=1.88.0), so the test suite could not be executed here.src/gui/note_panel.rsandsrc/plugins/note.rs(see PR diffs) and should pass on a compatible toolchain when run (cargo test).Codex Task