fix(field): keep every value in the FIELD suggestion cache - #2113
Conversation
FieldSuggestionCache stored only the first 1,000 values of a field. The first prompt after a note change listed every value, and every prompt after it only those 1,000, so in a large vault most values could not be found by typing. Fixes #2108
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review. 📝 WalkthroughWalkthrough
ChangesField suggestion cache
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to The change fixes missing suggestions on later prompt openings. No merge-blocking issue remains; larger fields retain the acknowledged processing overhead. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The fix preserves complete suggestions and existing invalidation controls. Large fields can now consume more retained memory and processing time on repeated prompts. No new privilege or data-access boundary was identified, but exposure to malicious vault data is not established. Retained concerns
Security review detailsSecurity Blast Radius
Security Findings and Attack Paths
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. A rabbit gathers fields in a row Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
A
{{FIELD}}prompt now offers the same values every time it opens. Before, the second and later prompts offered only the first 1,000 values the scan found.Cause
FieldSuggestionCache.setcopied at mostMAX_VALUES_PER_ENTRY(1,000) values into the cache entry.collectFieldValuesCachedreturns the full scan on a miss and the cut-down copy on every hit, so the list shrank from the second prompt on, until a note changed and cleared the cache. The cap came with the cache in #826.The cache already holds at most 100 entries, one per field and filter set, and drops them on any note change, after 5 minutes, or with
fieldSuggestions.clearCache(). This removes only the per-entry cap.Measured
Obsidian 1.13.7, isolated vault with 20,151 notes;
aliaseshas 26,668 distinct values. A Capture with format{{FIELD:aliases}}, run twice after a note change, typingalias 1999:Ada alias 19996,Alan alias 19992,Vint alias 19999, ...alias 1999(the typed text)Ada alias 19996,Alan alias 19992,Vint alias 19999, ...The prompt opens in 61-87 ms either way.
In the one-page form's FIELD input, which asks the cache on every keystroke, master was fast (about 18 ms a keystroke) because from the second keystroke it searched 1,000 values. Typing
ada alias 19there now takes 51-114 ms a keystroke (median 70-88 ms) for this 26,668-value field, and shows 200 matches instead of 10. Almost all of it is sorting and de-duplicating the values again on each keystroke (FieldValueProcessor.processValues), which the cache doesn't keep. A field with 400 values (owner) stays at about 18 ms. Caching the processed list instead of the raw set would remove that cost; I left it out to keep this to the bug.Tests
FieldValueCollector.issue2108.test.ts: 1,500 notes with distinctauthorvalues; the secondcollectFieldValuesProcessedcall returns all 1,500, the same as the first. Onmasterit returns 1,000.pnpm run build-with-lint,pnpm run test(6600 passed),.agents/run-e2e(395 passed, 24 Templater-only skipped).Release / migration
None. Pre-existing since #826, not a 2.30.0 regression.
Fixes #2108
Note
Fix
FieldSuggestionCache.setto store all values, not just the first 1,000Removes the per-entry 1,000-value cap in FieldSuggestionCache.ts. Cache-key creation, entry-count eviction, and timestamps are unchanged. Adds a regression test in FieldValueCollector.issue2108.test.ts that collects 1,500 distinct values twice and checks both results are complete and equal. Risk: cached sets for fields with many values now grow without a bound; check memory usage for large vaults.
📊 Macroscope summarized a1cda57. 1 file reviewed, 1 issue evaluated, 0 issues filtered, 1 comment posted
🗂️ Filtered Issues
Summary by CodeRabbit