Skip to content

Split note derived recompute into fast (local) and heavy (global) paths#892

Merged
multiplex55 merged 2 commits intonoteoptfrom
codex/refactor-note_panel.rs-refresh_derived-method
Feb 17, 2026
Merged

Split note derived recompute into fast (local) and heavy (global) paths#892
multiplex55 merged 2 commits intonoteoptfrom
codex/refactor-note_panel.rs-refresh_derived-method

Conversation

@multiplex55
Copy link
Copy Markdown
Owner

Motivation

  • Reduce per-frame work when editing a note by only doing cheap local recomputes immediately and deferring expensive global work (todo-label loading and backlink row construction).
  • Avoid rebuilding unchanged global caches during rapid edits while still ensuring backlinks and todo labels update after saves or when the underlying note/todo datasets change.

Description

  • Introduce refresh_fast_derived for immediate local recompute of tags, wiki_links, and external_links, and refresh_heavy_derived for expensive global recompute of todo_label_map and backlink rows using note_version() and todo_version() to short-circuit unchanged work.
  • Add fast_derived_dirty, heavy_recompute_requested, last_edit_at_secs, last_notes_version, and last_todo_revision fields to NotePanel, and replace the old recompute counter with heavy_recompute_count under #[cfg(test)].
  • Trigger fast recompute immediately on content mutations and schedule/debounce heavy recompute with maybe_refresh_heavy_derived using a HEAVY_RECOMPUTE_IDLE_DEBOUNCE constant, while forcing heavy recompute after successful saves and after overwrite/save-as-new flows.
  • Update call sites to use mark_content_changed on edits/preview mutations and to call refresh_fast_derived/refresh_heavy_derived(true) where a full refresh is required, and add the unit test edits_do_not_trigger_heavy_recompute_every_frame while adjusting existing derived-recompute tests to track heavy recomputes.

Testing

  • Formatted the code with cargo fmt --all which completed successfully.
  • Attempted to run the targeted unit test with cargo test edits_do_not_trigger_heavy_recompute_every_frame -- --nocapture, but the build failed in this environment due to a missing system dependency (alsa.pc) required by the alsa-sys crate, preventing the test run from completing.
  • Existing derived-recompute unit tests were updated in-source to assert against the new heavy_recompute_count behavior, and the new test was added to prevent heavy recompute increments on every frame during active edits.

Codex Task

@multiplex55 multiplex55 changed the base branch from master to noteopt February 17, 2026 21:14
@multiplex55 multiplex55 merged commit cc0d29b into noteopt Feb 17, 2026
1 check passed
@multiplex55 multiplex55 deleted the codex/refactor-note_panel.rs-refresh_derived-method branch February 20, 2026 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant