perf + cleanup pass: debounce, dedup, dead-code removal, builder tests#708
Merged
Conversation
TreeView, Matrix, and TrailView saved settings to disk on every local $state change. Swap to the existing saveSettingsDebounced() (600ms) to coalesce rapid disk writes. No behavior change. Item 1a of the perf-cleanup pass; see notes/perf-cleanup-log.md.
add_period_edges resolved daily->period and finer->coarser targets with Array.find() inside nested loops (O(n*m) string scans per rebuild). Build a basename->PeriodNote Map per period kind once and look up via .get(). First-occurrence semantics match the prior find(); edges unchanged. Item 1b of the perf-cleanup pass.
When the layout_change rebuild trigger is enabled, the handler called rebuildGraph() directly on every CM6 cursor/scroll event. Route through the existing rebuildGraphDebounced() (1500ms) like the else branch. Trigger defaults to false, so only opt-in users were affected. Item 1c of the perf-cleanup pass.
- delete unused src/utils/markmap.ts (never imported; the Markmap in CodeblockMarkmap comes from the markmap-view package) - drop commented-out Traverse import in src/api/index.ts - drop commented-out EdgeToAdd type in src/interfaces/graph.ts Item 2a of the perf-cleanup pass.
- dataview get_api/is_enabled: cast app via a PluginRegistry interface instead of 'as any'; use dot notation. (External Dataview integration is still live via dataview_note builder + dataview-from codeblocks.) - getMetdataPropertyType: cast metadataTypeManager to a one-method shape for the untyped getAssignedWidget, guarded by the existing 'in' check. Drops 4 eslint-disable comments. Item 2b of the perf-cleanup pass.
The same 3-branch edge-field validation (falsy -> skip, non-string -> invalid_field_value, unregistered -> invalid_edge_field) was copy-pasted across the explicit builders. Extract it to validate_field.ts and call it from folder, dendron, johnny_decimal, tag (field + sibling), list (field + neighbour), regex, and traverse builders. - Error message wording unified to '<field> is not a valid field'; codes unchanged (tests assert on code only). - traverse_note: drop dead 'raw || default_field' fallback (raw is always a truthy string there). Item 3 of the perf-cleanup pass. 68 builder tests green.
Covers add_period_edges (the basename-index refactor): sequential next edges, finer->coarser up edges (week->month, month->quarter), absent target, and the daily->period week_start edge case (Sunday maps to the current ISO week under 'monday', next week under 'sunday'). Plus the invalid default_field error path. 9 tests; full suite 221 green. Item 4 of the perf-cleanup pass (date_note portion).
Extend the shared test helpers: make_plugin gains an app_extra arg (getAbstractFileByPath, resolvedLinks, cachedRead, dataview_pages) and mock_file gains listItems/links cache options. Add tests for the four previously-untested explicit builders (+21 tests): - traverse_note: DFS over resolvedLinks, cycle protection, field errors - folder_note: folder->sibling edges, recurse on/off, invalid field - dataview_note: query->page edges, DataArray normalization, missing plugin + invalid query errors - list_note: list-item child edges, field validation errors Full suite 242 green. Item 4b of the perf-cleanup pass.
get_all_files has hardcoded dataview: null since the Dataview-page file source was retired, so every all_files.dataview?.forEach/map branch in the builders was unreachable. Remove the dataview field from AllFiles and get_all_files, delete the 10 dead branches across 6 builders (date_note, regex_note, tag_note, dendron_note, johnny_decimal_note, folder_note), and drop the now-unused IDataview import in files.ts. Does not touch the dataview-from codeblock feature or the live Dataview API used by dataview_note. Internal only; 242 tests green. Item 2c of the perf-cleanup pass.
All pre-existing, surfaced by the obsidianmd branch review: - drop unnecessary non-null assertions (dataview_from, typed_link) - unused catch bindings catch (_) -> catch (codeblocks/index, regex_note) - move DateNoteSetupModal inline styles to a .bc-date-note-setup-warning CSS class (no-static-styles-assignment) - scope MDRC's blanket eslint-disable to no-duplicate-type-constituents 242 tests green.
The obsidian community scorecard flags the blanket /* eslint-disable */ that wasm-pack emits atop wasm/pkg/*.d.ts. The project eslint config already ignores **/*.d.ts, but the scorecard runs its own pass. Since these files are generated, fix it in the build: factor the duplicated post-wasm .gitignore step into a shared wasm:postbuild script that also strips the eslint-disable line via perl -i, and apply it to the committed files. Leaves the (unflagged) tslint:disable line. Item 5b of the perf-cleanup pass.
wasm/pkg/ is generated by wasm-pack but committed so builds don't need a Rust toolchain. Note that it's regenerated by wasm:build (with the wasm:postbuild step) and shouldn't be hand-edited.
Removing the disable (prev commit) exposed the wasm-bindgen .d.ts to the scorecard's full ruleset, which flagged no-explicit-any, no-unsafe-function-type, and no-misused-new on generated code. Scope the suppression instead: move the post-wasm step into scripts/wasm-postbuild.mjs, which writes wasm/pkg/.gitignore and normalizes the generated .d.ts header to a disable naming exactly those three rules. Satisfies the 'specify rule names' meta-rule while keeping generated bindings unlinted. Idempotent across wasm-pack regenerations. Item 5c of the perf-cleanup pass.
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.
Incremental performance + code-cleanup pass, one item per commit. Build/typecheck clean throughout; test suite 212 → 242.
Resumable log at
notes/perf-cleanup-log.md.Performance
saveSettingsDebounced, 600ms) — coalesce rapid disk writes.basename → PeriodNoteMap (O(n·m) → O(n)).layout_changegraph rebuild (was a full rebuild on every CM6 cursor/scroll for opt-in users).Cleanup
utils/markmap.ts, commentedTraverseimport,EdgeToAddtype).anycasts on plugin internals (Dataview registry access,metadataTypeManager.getAssignedWidget) with typed shapes; drop 4 eslint-disable comments.all_files.dataviewfile-source: drop the field fromAllFiles/get_all_filesand the 10 unreachable?.forEach/mapbranches across 6 builders. Does not touch thedataview-fromcodeblock feature or the live Dataview API indataview_note.validate_edge_fieldhelper, replacing the copy-pasted 3-branch field validation at 9 sites across 7 builders. Error codes unchanged (tests assert on code only); message wording unified.Tests
week_startmonday/sunday edge case). Extended the shared test helpers with anapp_extraarg andmock_filelistItems/linksoptions.Verification
bun run build(tsc + svelte-check) andbun run test(242 passing) green at every commit. No vault-visible behavior changes.Note: a few pre-existing
src/lint warnings remain untouched (folder_note./filesimport order, list_noteArray<T>, typed_link:97) — not introduced here.