Repository navigation
Conversation
…16.4) Browser storage keeps State.recurringConfirmed as 'recurring' and State.categoryRules as 'catRules'. importJsonFile() saved every key under its State name, so these two went to keys nothing reads and the old values came back on the next reload. - core.js: STORAGE_KEYS / storageKey(stateKey), the one State key -> storage key mapping. The storage names don't change. - Import saves through storageKey(). A null value counts as missing and keeps the current value (a null categoryRules broke categorization). - Data & reset plan clears and migrate.js go through storageKey(); no change in behavior. - CHANGELOG, version in the four places, CLAUDE.md §1, §4.5, §8, §12. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013Z8iBXzUjiQbYziDZ8CZft
This was referenced Nov 2, 2026
Open
…mport-keys Carries master's v1.10.3-v1.10.5 up the stack: declined answers (#14), literal single "~" (#15) and the Import Logs race fix (#18), with clarity-insights' port of #14 to the rebuilt AI tab. One conflict: CLAUDE.md's "Last updated" line. Kept this branch's line and added the v1.10.3-v1.10.5 history. The CHANGELOG merged cleanly. Versions stay 1.16.4. renderImportLog() keeps #18's guards. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013Z8iBXzUjiQbYziDZ8CZft
…fix-json-import-keys Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013Z8iBUZo6LRYpLthSp2PRi # Conflicts: # js/views-settings.js
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.
Summary
After Settings → Data & reset → Import JSON, the spotted-charge choices (Bills → Spotted recurring charges: Confirm / Dismiss) and the category rules (Spending → Category rules) showed at first, then were gone after a reload. This fixes the import, and moves the places that save keys by State name in a loop onto one shared mapping. It also fixes a smaller problem found during the audit: a null value in the file broke categorization. A third finding, a new database dropping three keys, was part of this commit before the chain; it is now its own PR, #28, stacked on this one.
Cause
app_state) keepsState.recurringConfirmedasrecurringandState.categoryRulesascatRules. Every other key is stored under its State name.importJsonFile()calledlsSet(k, d[k])with the State name, so these two went tofinlens_recurringConfirmed/finlens_categoryRulesandapp_staterecurringConfirmed/categoryRules. Nothing reads those keys. At boot,lsGet('recurring'),lsGet('catRules')andDB.loadAll()loaded the old values.saveStateToFile()andloadStateFromFile()use State names, and the debounced save writes from memory. So with a connected folder, a reload more than 5 seconds after the import loaded the file and kept the import. Without a folder, or once folder access had lapsed (the browser was closed), the import was lost.What changed
The mapping
core.js:STORAGE_KEYS = { recurringConfirmed: 'recurring', categoryRules: 'catRules' }andstorageKey(stateKey). The storage names don't change, so existing data loads as before. State's initializer reads both keys through it.Every key, State name → storage key
recurringConfirmedrecurringcategoryRulescatRulesbudgets,buckets,debts,bills,txOverrides,manualBalances,categories,apiKey,aiHistory,scenarios,investAlloc,debtPlan,cardDetails,sampleData,theme,lastFolderName,csvAutoImportPaused,fileAssignments,accountOrder,accountLabels,txRules,transferKeywords,customSchemasPlaces audited
importJsonFile()(ui.js): the bug. It now saves throughstorageKey(). A key set tonullin the file now counts as missing and keeps the current value; before, a nullcategoryRulesmadeautoCategory()throw.DB.loadAll()(db.js): was right (its own list of storage names). Not changed here; v1.16.5: Fix a new browser database dropping the card details, the sample-data flag and the import pause #28 moves it ontostorageKey()and a shared list.DB._migrateSync()(db.js, a new database copies localStorage intoapp_state): names were right, but its hand-written list missedcardDetails,sampleDataandcsvAutoImportPaused, whichDB.loadAll()then reset to their defaults. Real data loss, fixed separately in v1.16.5: Fix a new browser database dropping the card details, the sample-data flag and the import pause #28.views-cleanup.js): was right (PLAN_ALSOlisted'recurring'by hand). The plan clears now save throughstorageKey(), andPLAN_ALSOno longer carries a storage key of its own. No change in behavior.migrate.js: all five of itsKEYSare stored under their State names, so it was right.migrateStores()now reads and writes browser storage throughstorageKey(). No change in behavior.views-eval.js): swaps State keys in memory only and never writes storage. No change.saveStateToFile(),loadStateFromFile(), boot,_restoreStateIfBrowserEmpty(): use State names in the file and don't write browser storage. No change.lsSet('recurring', …),lsSet('catRules', …)inui.jsandviews-data.js) were right. Unchanged.Version and docs
CHANGELOG.md, theindex.htmlfooter,README.md(badge and footer) andviews-settings.js.storageKey(); §12 adding a persisted field (use the State name as the storage key); Last updated. The rest of the §12 checklist and §19DB.APP_STATE_KEYSmoved to v1.16.5: Fix a new browser database dropping the card details, the sample-data flag and the import pause #28 with the code they describe.Not verified
FileSystemDirectoryHandle. Real Chrome or Edge with a real folder wasn't run.1.1since the first commit. The test uses a hand-made 1.0-shaped file with fewer keys.recurringConfirmedandcategoryRulesin browser storage. Nothing reads them and Start over removes them, but this PR doesn't clean them up. Anyone who imported before the fix should import the file again.Automated checks: earlier run, not re-run · 3a21a04
Moved unchanged from this PR's "Test results" comment on 2026-11-04; not re-run, so not in the new table format. Originally a description section titled "How it was tested".
Headless Chromium (Playwright) at 1280×900 against
samples/(257 transactions), with the pinned CDN libraries served from npm, on this branch's final commit3a21a04, chained on #26. Each script ran asNODE_PATH=$(npm root -g) node <script> <repo> <outdir>, from one harness shared by every branch in the stack: the base suites, plus every test added by this PR or by a PR below it (cumulative regression).3a21a04test-clarity.jstest-insights.jstest-finances.jstest-plan.jsboot.jsrace.jsrenderImportLog(the race #18 fixes on master; not in this stack)test-clear-edits.js(from #24)test-rebuild-folder.js(from #25)test-partial-import.js(from #26)test-json-import.js(new in this PR)test-insights.js's "General: version line" check reads the version from theindex.htmlfooter, andtest-plan.js's "Budget: Save adds it" accepts a new budget with or without anid, requiring thebud_+ 10 base-36 format once it has one (v1.16.7: Fix transaction links to budgets, buckets and debts pointing at the wrong item after a delete #30 adds ids). Nothing else in the base suites changed.test-json-import.jshas 28 checks on this branch: its new-database section (3 checks) moved to v1.16.5: Fix a new browser database dropping the card details, the sample-data flag and the import pause #28'stest-new-browser-copy.js, with the fix it covers. The other 28 are unchanged.Measured before the chain
By the agent that wrote the fix, on
d47dd8d(built onddc8a5f, then numbered v1.16.1), which also held the #28 fix. Version numbers below are as the agent wrote them, except the PR's own version.Headless Chromium (Playwright) against
samples/, on commitd47dd8d. The CDN libraries are served from npm (same versions; the SRI hashes inindex.htmlverify).test-clarity.js: 55/55.test-finances.js: 126/126.test-plan.js: 127/127.test-insights.js: 137/137. One check edited: "General: version line" matchedv1.16.0literally. It now reads the version from theindex.htmlfooter, so it follows a version bump and also checks that the two places agree.boot.js: 257 transactions, 24 views, 0 errors.race.js: 7 errors, allrenderImportLog/importLogsBody, which v1.10.5: fix Import Logs throwing when the view is left before it loads #18 fixes. v1.16.0 shows 7 too. None come from this change.test-json-import.js(new): 31/31. On v1.16.0 (ddc8a5f) it fails 11 of 31, all from this bug and the two side issues. It covers:samples/, import the file, reload. After the reload, Bills shows the charge as Dismissed and Spending lists both rules.recurringandcatRuleshold the imported values in localStorage andapp_state. Nothing is written underrecurringConfirmedorcategoryRules.debtPlan/cardDetails), a file with noversion, and a file with null values. Each leaves the keys it lacks unchanged in State and storage, also after a reload.recurringin storage.cardDetailsincluded. On v1.16.0cardDetailswas lost. (This section moved to v1.16.5: Fix a new browser database dropping the card details, the sample-data flag and the import pause #28'stest-new-browser-copy.jswith the fix it covers; the 3 checks it held are not in this branch's 28.)app_stateare still renamed at boot. Passes on v1.16.0 too, as a check that behavior didn't change.How to reproduce the bug
Run this on the base branch,
fix-partial-file-import.fix-partial-file-importinstead offix-json-import-keys. You end with a fresh sample-data session and the export file from setup step 8.file://entry.What goes wrong:
finlens_categoryRulesandfinlens_recurringConfirmedkeys holding the imported values, which nothing reads.Manual QA steps
Setup
git checkout fix-json-import-keys.index.html.samples/. The yellow banner says You're trying FinLens with sample data. The date range is set to All time for you.Make the backup file:
UBER TRIP, set Category toPersonal, click Add rule. The rule row UBER TRIP → Personal appears.finlens-export-YYYYMMDD.json) somewhere likeC:\temp.index.html, and load the sample data again (steps 3–4). The Category rules list says No rules yet., and SPOTIFY and NETFLIX show Dismiss / Confirm as bill.1. Imported spotted-charge choices and category rules survive a reload (main fix)
Expected:
file://entry hasfinlens_catRulesandfinlens_recurringholding the imported values. There is nofinlens_categoryRulesorfinlens_recurringConfirmedkey.Before this fix: after F5 the rules list said No rules yet. and SPOTIFY went back to Dismiss / Confirm as bill. NETFLIX still showed ✓ Added to bills (that comes from the bill itself, which was saved). Local storage had the stray
finlens_categoryRulesandfinlens_recurringConfirmedkeys.2. A null value in the file keeps the current value
export-null.json. Open it in Notepad."categoryRules": [ … ]value to"categoryRules": null(replace the whole array, brackets included). Save.export-null.json. Click OK.Expected:
State.categoryRules is not iterable.Before this fix:
categoryRulesbecame null, and categorizing threw a red error in the Console (for example on Re-categorize all or the next import).3. Rules and choices made in the app still save (regression)
TARGET→Housing. Click Add rule.Expected:
4. Clear bills still forgets the spotted-charge choices
Expected:
5. Import with a folder connected still works (regression)
C:\temp\finlens-27, and copy the threesamples/CSVs into it.index.html, click Pick your CSV folder, choose the scratch folder and allow access.Expected:
finlens-state.jsonin the scratch folder has"categoryRules"with the UBER TRIP rule and"recurringConfirmed"with SPOTIFY.Please check before merging
DB._migrateSync()fix (it also copiescardDetails,sampleDataandcsvAutoImportPaused) is split out into v1.16.5: Fix a new browser database dropping the card details, the sample-data flag and the import pause #28, with its CHANGELOG entry, docs and test.migrate.jsandviews-cleanup.jschanges are refactors with no change in behavior.https://claude.ai/code/session_013Z8iBXzUjiQbYziDZ8CZft
Generated by Claude Code