Repository navigation
v1.16.6: Fix JSON export leaving out account names, order, flag rules, transfer keywords, Read as choices and theme - #29
Open
gitluis wants to merge 3 commits into
Conversation
….16.6) exportAllData() and importJsonFile() each had a hand-written key list that stopped at format 1.1, so a round trip lost custom account names, the account order, the transaction (flag) rules, the transfer keywords, the "Read as" choices and the theme. All six were already in State and finlens-state.json. - ui.js: JSON_EXPORT_KEYS (State key -> kind of value), used by both. Adds accountLabels, accountOrder, fileAssignments, txRules, transferKeywords and theme. The export's version is 1.2. - Import accepts 1.0, 1.1 and 1.2. A key that's missing, null or of the wrong kind keeps its current value; a file that isn't a JSON object is refused. - _applyImportedSettings(): names and order show, flag rules re-apply, transfer detection re-runs, the theme switches, without a reload. - Not exported: transactions, accounts, the API key, sampleData, csvAutoImportPaused, lastFolderName, session state, customSchemas. - Data & reset says what the file holds. CHANGELOG, version in the four places, README, CLAUDE.md §1, §9, §12, §20. 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
…json-export-fields 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.6. renderImportLog() keeps #18's guards. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013Z8iBXzUjiQbYziDZ8CZft
21 tasks
… into fix-json-export-fields Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013Z8iBUZo6LRYpLthSp2PRi # Conflicts: # js/views-settings.js
Owner
Author
|
Dark theme taken out of the stack (Luis, 2026-11-04). #17 is light only for now: no ◐ toggle, no Light / Dark / Match system setting, no dark tokens. It comes back later in its own PR. #17's change was merged forward into this branch (no force push).
🤖 Generated with Claude Code https://claude.ai/code/session_013Z8iBUZo6LRYpLthSp2PRi Generated by Claude Code |
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
Export JSON left out six settings you make in the app, so Export → Start over → Import lost them: custom account names, the account order, the transaction (flag) rules, the transfer keywords, the "Read as" choices and the theme. The export and the import now share one list of keys that includes them. The export's
versionis1.2. Imported settings take effect without a reload.Cause
exportAllData()andimportJsonFile()each had a hand-written list of 14 keys. Neither list had these six, although all six were already in State and infinlens-state.jsonwhen the export was first written (commit02c9891).What changed
JSON_EXPORT_KEYSinui.jsmaps each exported State key to the kind of value it holds (list,map,theme). The export writes them all and the import reads the same list. Each key is saved throughstorageKey(), from v1.16.4 (v1.16.4: Fix JSON import losing spotted-charge choices and category rules #27).accountLabels,accountOrder,fileAssignments,txRules,transferKeywords,theme.version. A key that's missing, null or holds the wrong kind of value (a list where a map belongs, an unknown theme) keeps its current value. A JSON file that isn't an object is refused: "Import failed: this file is not a FinLens export."_applyImportedSettings(), for keys whose value changed):acctName()shows the imported names fromState.accountLabels.)applyTxRulesToAll().reapplyTransferKeywords(), the helper the Transfers screen uses, re-runs detection.applyTheme().CHANGELOG.md, theindex.htmlfooter,README.md(badge and footer) andviews-settings.js. CLAUDE.md: §1 version; §9JSON_EXPORT_KEYS; §12 adding a persisted field; §20 what the export holds and what the import does; Last updated.Key by key
budgets,buckets,debts,bills,scenarios,investAlloc,debtPlantxOverrides,categories,categoryRules,recurringConfirmedmanualBalances,cardDetailsaiHistoryaccountLabelsaccountOrdertxRulestransferKeywordsfileAssignmentscard_<file>).themefinlens-state.jsontoo. Onlylight,darkorsystemis imported.apiKeytransactions,accountssampleDatacsvAutoImportPaused,lastFolderNamerange,selectedAccounts,currentView,pendingFiles,fileMeta,lastRefresh,_folder*customSchemasBANK_SCHEMAS, which only happens at boot.Not verified
FileSystemDirectoryHandle.theme: 'system'wasn't imported in the test, onlydark.IdMigration.migrateState()already rewritesaccountLabels,accountOrderandfileAssignments, but no export from before v1.16.6 has these keys, so no import test covers it.Older bugs found while testing, not fixed here. Each now has its own PR in this stack:
DB.loadAll()keeps the stored flags and never re-appliestxRules. Same on v1.16.0: 6 flagged → 0 after a reload. The round-trip test prints this as a NOTE and leaves it out of its after-reload comparisons.DataCleanup.clearEdits()rebuilds the transactions from IndexedDB. In a browser restored fromfinlens-state.json, IndexedDB has none, so all transactions disappear from memory (257 → 0 on v1.16.0)._finish()then saves that to the file when a folder is connected; I read that part in the code but didn't run it.setAccountName(id, '')deletes the label, buta.namekeeps the old custom name (read in the code, not run).loadFiles()keeps only accounts present). A folder import loads them all at once, so the order holds (read in the code; the JSON-first test loads all three at once).Automated checks: earlier run, not re-run · a06b536
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 commita06b536, chained on #28. 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).a06b536test-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(from #28)test-json-export.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-export.js's round trip sets budgets and debts directly in State. Their fixture now carries ids (bud_jsonexp001,dbt_jsonexp001), because from v1.16.7: Fix transaction links to budgets, buckets and debts pointing at the wrong item after a delete #30 every budget and debt has one and the import's link migration gives an id-less item abud_m0-style id. That's a fixture change only; this branch passes with or without it.Measured before the chain
By the agent that wrote the fix, on
f5c1665(built ond47dd8d, the JSON import commit before it was split into #27 and #28; then numbered v1.16.2).Headless Chromium (Playwright) against
samples/, on commitf5c1665. 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. Its existing Export / Import JSON checks pass unchanged. Its "General: version line" check reads the version from the footer (the edit described in v1.16.4: Fix JSON import losing spotted-charge choices and category rules #27).boot.js: 257 transactions, 24 views, 0 errors.race.js: 6 errors, allrenderImportLog/importLogsBody, which v1.10.5: fix Import Logs throwing when the view is left before it loads #18 fixes. None come from this change.test-json-import.js(from v1.16.4: Fix JSON import losing spotted-charge choices and category rules #27, before its new-database section moved to v1.16.5: Fix a new browser database dropping the card details, the sample-data flag and the import pause #28): 31/31.test-json-export.js(new): 31/31. On the JSON import fix's commit before the chain (d47dd8d) it fails 20 of 31. It covers:samples/, import, reload. The test first checks that Start over really reset every one of the 20 fields, so the round trip proves something.versionis1.2; it holds exactly the 20 expected keys, each equal to State; it has no API key (neither the key name nor its value) and none of the left-out keys.app_state). Names show inacctName()and the accounts filter. The order applies. RENT PAYMENT rows became transfers and ZELLE rows stopped being transfers. The rule flags apply. The theme is dark.How to reproduce the bug
Run this on the base branch,
fix-new-browser-settings-copy.fix-new-browser-settings-copyinstead offix-json-export-fields."version": "1.1"and has noaccountLabels,accountOrder,fileAssignments,txRules,transferKeywordsorthemekey.RESETand click Erase and start over. Click OK.samples/CSVs and click Import 3 files. Set All time.What goes wrong: all six settings are lost. The theme is light, the checking account has its default name instead of My Checking, the account order is the default,
savings_sample.csvis back to its guessed Read as, there is no LIBERTY INTERNET → Bill rule, and walmart is not a transfer keyword.Manual QA steps
Setup
git checkout fix-json-export-fields.index.html. On the Welcome, click choose the files (in "In Safari or Firefox you'll choose the files…"). Select the three CSVs insamples/. In Choose how to read these files, keep the guesses and click Import 3 files.Make the six settings this PR adds to the export:
My Checkingand press Tab. Saved the name "My Checking". appears.savings_sample.csvto Other CSV. The message says it applies from the next reload; that's fine, nothing is re-read here.LIBERTY INTERNET, Flag as Bill, click Add rule.walmartin Add keyword and click Add.sk-ant-test-123and click Save key.finlens-export-YYYYMMDD.jsonsomewhere likeC:\temp.1. The export file holds the six new settings, and no API key
Expected:
"version": "1.2"."accountLabels"has"bank_checking": "My Checking"."accountOrder"starts with"bank_savings"."fileAssignments"has"savings_sample.csv": "other"."txRules"hasLIBERTY INTERNETwith"flag": "bill"."transferKeywords"includes"walmart"."theme": "dark".sk-ant-test-123and forapiKeyfinds nothing. There is notransactions,accounts,sampleDataorlastFolderNamekey.Before this fix:
"version": "1.1"and none of the six keys.2. Export → Start over → Import brings them back (main fix)
RESETin Type RESET to confirm. Click Erase and start over.samples/CSVs and click Import 3 files. Set All time.Expected (right away, no reload):
savings_sample.csvshows Read as Other CSV.LIBERTY INTERNETshows the Bill flag on each row.WALMARTshows the rows as Transfer out.Before this fix: all six were lost: light theme, default account names and order, no rule, no
walmartkeyword, Read as back to the guess.3. Still there after a reload (persistence)
Expected:
4. Older settings still import (regression)
1000, press Tab.UBER TRIP, CategoryPersonal, click Add rule.5, press Tab.Expected:
5. A bad value is skipped, a bad file is refused
export-bad.json. In Notepad, change"theme": "dark"to"theme": "purple", and change"accountOrder": [ … ]to"accountOrder": {}. Save.export-bad.json, click OK.not-export.jsonin Notepad with the text[1, 2, 3]. Save.not-export.json.Expected:
6. The Export and import description is updated
Expected:
Please check before merging
themeandfileAssignments, and leaving outcustomSchemasandsampleData.https://claude.ai/code/session_013Z8iBXzUjiQbYziDZ8CZft
Generated by Claude Code