Repository navigation
Conversation
…d import pause (v1.16.5) When IndexedDB is created while localStorage still holds data, DB._migrateSync() copied a hand-written list of keys into app_state, and DB.loadAll() read a second list. cardDetails and sampleData (v1.16.0) and csvAutoImportPaused (v1.9.0) were only on the second, so they weren't copied and loadAll() reset them to their defaults. - db.js: DB.APP_STATE_KEYS, every app_state key with the default loadAll() uses. _migrateSync() copies those keys and loadAll() reads them, both under storageKey(). loadAll() loads the same keys with the same defaults as before. - CHANGELOG, version in the four places, CLAUDE.md §1, §4.5, §12, §19. 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
…er-settings-copy 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.5. renderImportLog() keeps #18's guards. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013Z8iBXzUjiQbYziDZ8CZft
…-new-browser-settings-copy 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
When FinLens creates its IndexedDB database while localStorage still holds your settings, it copies them across. That copy had its own hand-written list of keys, and it missed three:
cardDetails(the APR and due day under Settings → Credit cards),sampleDataandcsvAutoImportPaused.DB.loadAll()then set them to their defaults on that boot and on every boot after it that read IndexedDB, though localStorage still held them.Now the copy and
DB.loadAll()read one list,DB.APP_STATE_KEYS.This was found by the audit in #27 (the JSON import storage keys) and was part of that commit before the chain. It is split out here because it is a separate bug with its own trigger.
Cause
finlens_dbis created while localStorage has data. In practice that'sfinlens_dbalone being deleted (for example from the browser's developer tools) with localStorage kept.DB.open()then runsonupgradeneededwitholdVersion0 and callsDB._migrateSync()._migrateSync()copied the keys in its ownLS_KEYSlist intoapp_state.DB.loadAll()read a second list (appStateMap, State key → storage key → default). WhencardDetailsandsampleData(v1.16.0) were added to the second list, they weren't added to the first, and neither wascsvAutoImportPaused(v1.9.0).lsGet(), so it briefly has the right value.DB.loadAll()runs at boot whenfinlens-state.jsonwasn't loaded, finds noapp_staterow for the key, and sets the default. That repeats on every such boot, because the database now exists and is never filled again.finlens-state.json(no folder access yet) can import the folder's CSVs again.masterhas it forcsvAutoImportPaused.origin/master(e8e18e7, v1.10.5) has the same two lists; its_migrateSync()missescsvAutoImportPaused, which itsloadAll()reads.cardDetailsandsampleDatadon't exist there. A probe on master (localStoragecsvAutoImportPaused: true,DB.destroy(), reload) givesState.csvAutoImportPaused === falsewhile a budget in the same localStorage is copied.What changed
DB.APP_STATE_KEYS(db.js): every State key kept inapp_state, with the defaultDB.loadAll()uses when it's missing (null: keep what State has). The 25 keys and defaults areloadAll()'s old list, unchanged.DB._migrateSync()copiesAPP_STATE_KEYS, each understorageKey()(v1.16.4: Fix JSON import losing spotted-charge choices and category rules #27), sorecurringConfirmedandcategoryRulesare still copied fromrecurringandcatRules.DB.loadAll()readsAPP_STATE_KEYSthroughstorageKey(). Same keys, same storage names, same defaults, so a normal boot is unchanged._migrateSync()runs only when the database is created, so values lost before this fix stay lost: enter the card details again.DB.loadAll()and the new-database copy go throughstorageKey()), §12 (adding a persisted field: it saidlsGetwas all you needed; it also takesDB.APP_STATE_KEYS,saveStateToFile()'s list and §20), §19 (DB.APP_STATE_KEYS).Not verified
finlens_dbwithDB.destroy()in the page. Deleting it from the developer tools in Chrome or Edge wasn't tried, nor Safari or Firefox.finlens_dbdidn't exist) also runs the copy. Those versions had none of the three keys, so nothing is lost on that path; not run.Automated checks: earlier run, not re-run · dc1eeb4
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 commitdc1eeb4, chained on #27. 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).dc1eeb4test-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(from #27)test-new-browser-copy.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-new-browser-copy.json v1.16.4: Fix JSON import losing spotted-charge choices and category rules #27's chained commit gives 5/10 (the three missed keys, the second reload and the Credit cards check).test-new-browser-copy.js(new, 10 checks). It is section 4 of #27'stest-json-import.jsbefore the split ("a new database copies every saved key from localStorage"), moved here and extended from 5 keys to all 25:app_statekey, written out in the test rather than read from the app, is set in localStorage to a value that isn't its default; budgets, buckets and debts carry ids, as every item has from v1.16.7;DB.destroy()deletesfinlens_dband keeps localStorage; the page reloads;cardDetails,sampleDataandcsvAutoImportPaused: copied toapp_stateand kept in State;Fails without the fix: on #27's commit it gives 5/10. The three missed keys fail, so do the second-reload check and the Credit cards check; the other 22 keys pass.
How to reproduce the bug
Run this on the base branch,
fix-json-import-keys.masterhas the bug only for the import pause (csvAutoImportPaused); the card details below don't exist there.git checkout fix-json-import-keys. Open an InPrivate window (Ctrl+Shift+N) and openindex.html. No folder connected.samples/, keep the guesses and click Import 3 files. Do not use Try it with sample data.24.99in APR (%) and press Tab. Type15in Payment due day and press Tab.cardDetailsrow.samples/credit_card_sample.csv, and click Import 1 file.What goes wrong:
app_statehas nocardDetailsrow.finlens_cardDetailsstill holds 24.99 and 15. They stay empty after every further F5.Manual QA steps
Setup
git checkout fix-new-browser-settings-copy.finlens-state.jsonand finds a newly created IndexedDB database. Tests 1–3 do this with no folder connected, in an InPrivate window (Ctrl+Shift+N), so your normal browser data is untouched. InPrivate keeps its data across F5 until you close every InPrivate window.C:\temp\finlens-28, and copy the threesamples/CSVs into it. Never use your real folder.To delete only the database: F12 → Application → Storage → IndexedDB → right-click finlens_db → Delete database. Leave Local storage alone.
1. Card APR and due day survive a new database (main fix)
index.html.samples/. Do not use Try it with sample data here.24.99in APR (%) and press Tab. Type15in Payment due day and press Tab. Each shows Saved the APR. / Saved the due day.UBER TRIP→Personalwith Add rule.cardDetails,catRulesandsampleDatarows.samples/credit_card_sample.csv, and click Import 1 file.Expected:
app_statehas acardDetailsrow withapr: 24.99anddueDay: 15, acatRulesrow with the UBER TRIP rule, and asampleDatarow (false).Before this fix:
app_statehad nocardDetailsrow, and after the re-import the APR and due day fields were empty.2. They stay after more reloads (persistence)
Expected:
[FinLens] Boot: Loaded state from IndexedDB — 165 transactions.Before this fix: the values stayed empty on every boot from IndexedDB, though
finlens_cardDetailsin Local storage still held them.3. The sample-data flag survives a new database
index.html.samples/. The yellow banner You're trying FinLens with sample data. appears.sampleDatarow.State.sampleDataand press Enter.Expected:
app_statehassampleData: true.true.Before this fix: no
sampleDatarow, and the Console printedfalse, though Local storage →finlens_sampleDatawas stilltrue.4. The import pause survives a new database (folder connected)
index.html, click Pick your CSV folder, choose the scratch folder and allow access. Set Date range to All time: Transactions reads 257.index.htmlagain. Folder access lapses, so FinLens can't readfinlens-state.jsonand boots from the new database.Expected:
Before this fix: the callout was missing, and Reconnect folder re-imported all 257 transactions you had cleared.
5. A normal boot is unchanged (regression)
19.5, press Tab.finlens-state.json).Expected:
Please check before merging
DB.loadAll()is unchanged in behaviour: the same 25 keys and defaults, now read fromDB.APP_STATE_KEYS.https://claude.ai/code/session_013Z8iBXzUjiQbYziDZ8CZft
Generated by Claude Code