Repository navigation
Conversation
… as" (v1.16.17) Changing a file's Read as in Settings -> Import, then Reload CSVs, left the file's rows under both the old account and the new one: 268 transactions instead of 257 on the samples (savings read as checking), in memory, IndexedDB and finlens-state.json, until Rebuild from your folder. The account id is part of every transaction id, so the re-read rows had new ids, and since v1.16.3 an import keeps every loaded transaction a file doesn't replace. master has it in IndexedDB: its import replaces the loaded transactions, but the store keeps both copies and a boot from IndexedDB shows them, with the old account left empty. - earlierCopies() finds each file's earlier rows before the import writes anything: only in accounts the file went into before (the account's new `files` list; for older accounts its sourceFile or the import log), and each row by its exact old id, worked out from the new one with IdMigration._rekey(). - moveEarlierCopies() removes them from memory and IndexedDB, moves their edits and plan links to the new ids, and removes an account left empty (its name, balances, card details and order stay, by id). The autosave writes the state file. Last import says how many rows moved, and from where. - A kind that can't read the file (a card export read as checking) moves nothing. - Accounts record every CSV imported into them (`files`, accountFiles()). Settings -> Import lists every file, so a moved file can be moved back, and Rebuild's check counts them all as imported before. - db.js: DB.removeTransactions(), DB.patchAccount(). - The Read as message says the rows move with their edits on the next reload, and stay if the file can't be read that way. - Version bumped to v1.16.17 (CHANGELOG, footer, README, Settings, CLAUDE.md); CLAUDE.md §4.3, §4.5, §8, §10, §19, §22 updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013Z8iBXzUjiQbYziDZ8CZft
This was referenced Nov 2, 2026
…3.0) into fix-read-as-reload-duplicates 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
In Settings → Import → Files in the folder, changing a file's Read as and then clicking Reload CSVs left that file's rows under both the old account and the new one. On the samples, savings read as checking gave 268 transactions instead of 257 (checking read as savings gave 338). The copies were in memory, IndexedDB and
finlens-state.json, and stayed until Rebuild from your folder.Now the reload moves the file's rows: they leave the old account, their edits and plan links go with them, and an account left empty is removed. The files list shows every file, so a moved file can always be moved back.
Cause
mkTx(), CLAUDE.md §10). A file read into another account gives the same rows with new ids.mergeImported(), v1.16.3, v1.16.3: Fix importing some CSV files losing the other loaded transactions #26). Nothing replaced the old-id rows, so they stayed.importedFiles()usedsourceFile, the last file imported). After the move, savings_sample.csv was listed twice and checking_sample.csv not at all.DB.importTransactions()only adds rows, so the store holds both copies (268), and a boot from IndexedDB (no folder, or access lapsed) shows 268. Master also keeps the old account, empty. Checked with a probe onorigin/master(e8e18e7).What changed
earlierCopies(read)(core.js, new). Runs before the import writes anything. For each file that gave transactions, it finds the loaded rows that file gave under another account.fileslist. An account saved before v1.16.17 has no list, so itssourceFileor an import-log entry counts.IdMigration._rekey(), the v1.12.0 migration's tested step. The id includes the bank's time (or the card's post date), so the match is exact.moveEarlierCopies(moves, read, fresh)(core.js, new). Runs after the import:files. If no transaction is left and no file of this import went into it, the account is removed from memory and IndexedDB. Its label, balances, card details and place inaccountOrderstay, keyed by id, so they come back with the file.account.files, kept byimportParsedCsv();accountFiles(a)falls back to[sourceFile]). It lives inside the account record, so it needs no new storage.importedFiles()). An account's Rows and Dates cells span its files' rows._rebuildBlockers()) counts every file infilesas imported before, not only each account's last one. Before this change, a stale empty account still named the moved file; now the account is gone, so without this the check would get weaker.from the next reloadwording thattest-insights.jschecks is unchanged.DB.removeTransactions(rows)andDB.patchAccount(id, patch | null)(db.js, new).removeTransactionslowers the account'stxCountand leaves its date range as it is.patchAccountnever creates a record.Decision: edits are carried over. The moved row is the same bank transaction; only its account changed. The match uses
_rekey()rather than date, description and amount, because two same-day rows with the same amount and description differ only by time. Test case 4 edits two such rows differently and checks that each edit follows its own row.Not verified
entries()on a real disk may differ. The fix doesn't depend on it, except for accounts saved before v1.16.17: there only the last file is known (sourceFile), and the import log covers the others when the browser has one. Case 5 covers both._rekey()can't trace those rows, so they would stay in the old account. Same limit as the v1.12.0 migration.Automated checks: earlier run, not re-run · 2a4f53b
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".
Light checks, by Luis's call to save usage: on this branch's final commit
2a4f53b(chained on #39) onlyboot.js,race.jsand this PR's own tests ran. Headless Chromium at 1280×900 againstsamples/, with the pinned CDN libraries served from npm; each script ran asNODE_PATH=$(npm root -g) node <script> <repo> <outdir>.2a4f53bboot.jsrace.jstest-read-as.js(new in this PR)Full set, once, on the top of the stack (#23,
819e809: every PR below it merged in): every base suite and every fix test from #24 to #50, plus #10's and #23's, each in its final variant. All pass:test-clarity.js55/55,test-insights.js137/137,test-finances.js126/126,test-plan.js127/127,boot.js257 transactions and 0 errors,race.js0 errors; #24–#38's tests (clear-edits 48/48, rebuild-folder 57/57, partial-import 47/47, json-import 28/28, new-browser-copy 10/10, json-export 31/31, plan-links 60/60, rule-flags 67/67, drawer-flags 36/36, start-balance 193/193, ai-summary-period 78/78, account-names 40/40, account-order 32/32, drawer-focus 167/167, cleanup 21/21); #39–#50's tests (drawer-fields 45/45, read-as 52/52, json-import-edits 29/29, overlapping-exports 46/46, override-balance 160/160, card-override 277/277, ai-summary-trend 91/91, transfer-user-type 39/39, untransfer-category 27/27, recategorize 55/55, retype-transfer 135/135, minor-fixes 34/34);test-dbtab.js73/73,test-save-status.js64/64,test-master-port.js16/16. Three scripts needed a test-only change on that run, listed in #23 and in the PRs they belong to; the app code wasn't changed.Measured before the chain
The numbers below are the PR author's, on the commit before it was chained (built on the old #38 tip
ecfcab2, v1.16.15, or on the fix below it there; version numbers renumbered to the chain's).Headless Chromium, desktop 1280×900, with the harness's fake folder. Suites ran one at a time.
test-read-as.js(new):ecfcab2: 23/52 passed. Failures: 268 / 338 / 272 rows; edits and links left on the old copies; the files table showing savings_sample.csv twice; the old Rebuild message. The 23 passes are the cases where nothing should move (card ↔ checking, the identical fee row) plus setup and no-console-error checks.17cc713): 52/52 passed.sourceFile, and in a new browser restored from the state file.run-tip.sh 15on17cc713: every suite passed (one at a time, on a checkout of the commit):renderImportLog(expected on this base until v1.10.5: fix Import Logs throwing when the view is left before it loads #18's fix is in the stack; none from this change).test-insights.jschecks the Read as message forfrom the next reload, and the new wording keeps it.How to reproduce the bug
Run this on the base branch,
fix-drawer-saves-unchanged-fields(#39). Master has a narrower form of it: only its IndexedDB keeps both copies (268), so it shows after a boot from the browser database.fix-drawer-saves-unchanged-fieldsinstead offix-read-as-reload-duplicates. Check the starting count: Transactions says 257.savings_sample.csvto Checking.What goes wrong:
savings_sample.csvtwice andchecking_sample.csvnot at all.Manual QA steps
Setup
git checkout fix-read-as-reload-duplicates.samples/to a new scratch folder. Don't use your real folder: this PR moves rows between accounts and rewritesfinlens-state.json.index.html.500in Bank Savings' Starting balance field and press Tab. Rename Bank Savings toMy Savingsin Display name and press Tab. Use the arrows to move it to the top.Interest Paid. Open the newest one, type the noteinterest A, click Save changes.interest B, save.For a quick count in DevTools, F12 → Console:
State.transactions.length, andnew Set(State.transactions.map(t=>t.id)).size(the two should always match).1. Savings read as checking moves the rows (main fix)
savings_sample.csvto Checking.Expected:
Before this fix: 268 transactions, the 11 savings rows under both accounts, and an empty savings account left behind.
2. The files table lists both files
Expected:
checking_sample.csvandsavings_sample.csv(both read as Checking) andcredit_card_sample.csv.Before this fix:
savings_sample.csvwas listed twice andchecking_sample.csvnot at all.3. The notes moved with their rows
interest.Expected:
4. Moving back restores the account with its name, balance and order
savings_sample.csvback to Savings. Click Reload CSVs.intereston Transactions and check the notes.Expected:
5. Checking read as savings, then back
checking_sample.csvto Savings and click Reload CSVs.Expected:
Before this fix: step 1 gave 338 transactions.
6. A kind that can't read the file moves nothing
credit_card_sample.csvto Checking. Click Reload CSVs.Expected:
7. It survives a reload and a fresh browser
savings_sample.csvto Checking and click Reload CSVs again.index.html, pick the same scratch folder.finlens_db→transactions: check the entry count at the bottom.savings_sample.csvback to Savings and click Reload CSVs.Expected:
transactionsholds 257 entries, andaccountshas no savings entry.8. Regression: a normal reload changes nothing
Expected:
9. Regression: Rebuild still works
Expected:
Please check before merging
https://claude.ai/code/session_013Z8iBXzUjiQbYziDZ8CZft
Generated by Claude Code