Repository navigation
Conversation
…s no CSV it can read (v1.16.2)
DataCleanup.rebuildFromFolder() cleared the transactions, accounts and import log
(memory and IndexedDB) before reading the folder. With only finlens-state.json in it,
or only CSVs FinLens can't parse, 0 transactions were left, and _finish() wrote that
to finlens-state.json, which boot loads first. Reload CSVs, picking or reconnecting a
folder and Choose CSV files had the same problem one level down: loadFiles() emptied
State.transactions before parsing, and the autosave then wrote 0 to the file.
master has the same code.
- loadFiles() reads every file first and changes nothing (memory, storage, IndexedDB,
sample data, the import pause) unless at least one transaction was read. An alert
names each file and why; chosen files stay listed so Read as can be changed.
- parseCsvFile() now only reads a file: { accountId, rows, txs, problem, ... }, no
writes. importParsedCsv() does the import; a failing IndexedDB write is logged and
the import carries on (before, that file's import never finished).
- rebuildFromFolder() clears inside loadFiles()'s new beforeImport hook, after the
read, and only when _rebuildBlockers() finds no file it would import but couldn't
read (unopenable, no readable row, or imported before with columns it no longer
knows). Otherwise nothing is cleared and the tab says why. CSVs in other formats
that were never imported are skipped and named.
- reloadFromDirHandle() reports a CSV it can't open instead of stopping, returns
loadFiles()'s result, and renders after filling Last import, which lists files that
weren't imported.
- A file with no readable row no longer creates an empty account.
- Version bumped to v1.16.2 (CHANGELOG, footer, README, Settings, CLAUDE.md);
CLAUDE.md §8 and §20 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
Open
… fix-rebuild-empty-folder 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.2. renderImportLog() keeps #18's guards. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013Z8iBXzUjiQbYziDZ8CZft
…13.0) into fix-rebuild-empty-folder 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
Settings → Data & reset → Rebuild from your folder cleared the transactions, accounts and import log before it read the folder. Two kinds of folder ended with 0 transactions, and that was saved to
finlens-state.json:finlens-state.json;Now the rebuild reads and checks every CSV first. It clears only when the files can be read. Otherwise nothing changes, and the tab says why.
The other imports had the same problem one level down: Reload CSVs, picking or reconnecting a folder, and Choose CSV files.
loadFiles()emptied the loaded transactions before parsing. Now an import that reads no transaction changes nothing.Cause
DataCleanup.rebuildFromFolder()called_dropImported()andDB.clearStores(['transactions', 'accounts', 'import_log']), thenreloadFromDirHandle(). With no CSV,reloadFromDirHandle()showed an alert and returned. With unreadable CSVs,loadFiles()imported nothing. Either way_finish()then wrote 0 transactions tofinlens-state.json, which boot loads first. On the samples, a reload afterwards shows 0.entry.getFile()threw after the clear. The tab said "Something went wrong", and memory and IndexedDB were left empty.parseCsvFile()'scomplete: asynccallback never resolved, so the rebuild hung on "Working…".loadFiles()setState.transactions = []before parsing. When no file gave a transaction, none were left in memory. The autosave then wrote 0 to the state file. IndexedDB still held 257, but the state file wins at boot, so a reload showed 0.origin/master(v1.10.4) has the samerebuildFromFolder()and the sameState.transactions = []inloadFiles().What changed
loadFiles()reads every file before changing anything (js/core.js).quiet.{ imported, reason, transactions, files }.quiet,unopened(files the caller couldn't open), andbeforeImport(result).beforeImportruns after the read; returning false stops the import.parseCsvFile()now only reads. It returns{ accountId, rows, txs, problem, … }and writes nothing.problemis one of'unknown-format','no-rows'or'unreadable'.importParsedCsv()(new) does whatparseCsvFile()used to do after parsing: the account in State and IndexedDB,DB.importTransactions(), the import log,State.fileMeta.rebuildFromFolder()(js/views-cleanup.js) clears insidebeforeImport, after the read, and only when_rebuildBlockers()finds nothing. A blocker is a file FinLens would import but couldn't read:With a blocker, nothing is cleared and the tab says why, in the callout the Data & reset actions use (
_done('bad', …)). The tab has no per-row status line.reloadFromDirHandle()(js/views-data.js):optsand returnsloadFiles()'s result;importAssignedFiles(): when nothing was imported, the chosen files stay listed, so Read as can be changed and tried again.Last import lists files that weren't imported, with the reason (
captureImportResults(), shared by both import paths).New helpers:
importProblemText()andimportFileProblem()put a file's problem in words.Version v1.16.2: CHANGELOG, footer, README (two places), Settings → General, CLAUDE.md §1 and Last updated.
CLAUDE.md: §8 (the new functions and options) and §20 (the Rebuild row, plus a "Read before clearing" rule).
Review tip: most of the
core.jsdiff isparseCsvFile()'s body re-indented inside atry. View it with whitespace hidden.Not verified
FileSystemDirectoryHandle. Nothing was run in Chrome or Edge against a real folder.NotReadableErroris simulated. A real file locked by another program wasn't tried.showDirectoryPicker. It usesreloadFromDirHandle(), which the Reload cases cover.reloadDataFiles()'s catch). That is from reading the code, not run.Automated checks: earlier run, not re-run · 277ebe2
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 commit277ebe2, chained on #24. 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).277ebe2test-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(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.Measured before the chain
By the agent that wrote the fix, on
277ebe2(this branch's commit too: it was already built on #24's93a373a, so it didn't change when the stack was built).Headless Chromium against
samples/, with CDNs served from npm. Each script ran asNODE_PATH=$(npm root -g) node <script> <repo> <outdir>.New:
test-rebuild-folder.js(57 checks). Every case starts in a fresh browser whose connected folder holds the three samples: boot imports 257, then Save now. The folder is a fake handle, as intest-clear-edits.js; it survives reloads and can be changed per case. Each case checks:Cases:
93a373a)277ebe2)test-rebuild-folder.js(new)test-clarity.jstest-finances.jstest-plan.jstest-insights.jstest-clear-edits.jsboot.jsrace.jsrenderImportLogerrorsrenderImportLogerrorsrace.js: these are the known errors PR v1.10.5: fix Import Logs throwing when the view is left before it loads #18 fixes. The count varies by run; none come from this change. The line number moved by one because of the Last import change.How to reproduce the bug
Run this on the base branch,
fix-clear-edits-wipes-transactions.masterhas the same bug.fix-clear-edits-wipes-transactionsinstead offix-rebuild-empty-folder. Use the scratch folder with the three sample CSVs, never your real data folder. (real browser: the tests used a fake folder)finlens-state.json.finlens-state.jsonfrom the scratch folder.What goes wrong:
finlens-state.jsonhas"transactions": [].Manual QA steps
Setup
git checkout fix-rebuild-empty-folder.C:\temp\finlens-25. Copy the three CSVs fromsamples/into it. Never use your real data folder for this PR. Keepsamples/itself untouched so you can copy fresh files back.C:\temp\finlens-25-parked, to move files into and out of.notes.csvin Notepad with these two lines, and save it:notes.csvinto the parked folder for now.index.htmlin Edge. Click Pick your CSV folder and choose the scratch folder. Allow access.Every button in Data & reset → Clean up needs two clicks: the button, then Click again to confirm.
1. Rebuild with no CSV in the folder changes nothing (main fix)
finlens-state.json.Expected:
Before this fix: an alert "No CSV files found in the selected folder.", then the success message with 0 transactions re-imported, and 0 everywhere.
2. Nothing is lost after a reload (persistence)
finlens-state.jsonin the scratch folder in Notepad and search for"transactions".Expected:
transactionslist is not empty (it still lists the sample rows, e.g.UBER TRIP).Before this fix: the reload shows 0, and the file has
"transactions": [].3. Rebuild with only an unreadable CSV changes nothing
notes.csvfrom the parked folder into the scratch folder (the samples stay parked).Expected:
4. Reload CSVs with only an unreadable CSV changes nothing
notes.csvandfinlens-state.json, go to Settings → Import.Expected:
Before this fix: memory and
finlens-state.jsonwent to 0 (IndexedDB kept 257), and the reload showed 0.5. One broken sample blocks the rebuild
samples/into the scratch folder (so it holds the three samples,notes.csvandfinlens-state.json).checking_sample.csvin Notepad. Use Replace (Ctrl+H): find2026-, replace withbad-, Replace all. Save and close.Expected:
notes.csvis not named as a blocker.PAYROLLstill finds the checking deposits.Before this fix: the rebuild went ahead without checking: 176 transactions, and every checking row gone.
6. Choose CSV files with a broken file keeps the file listed
checking_sample.csvfrom the scratch folder.Expected:
checking_sample.csv: none of its 81 rows has a date and an amount FinLens can read.7. A normal rebuild still works, and names a skipped CSV (regression)
checking_sample.csvfromsamples/over the broken one in the scratch folder. Leavenotes.csvthere.Expected:
notes.csvrow: Not imported: its columns don't match a format FinLens reads.parseCsvFile: no schema matched for notes.csvwarning is fine; no red errors.8. Reload CSVs with a good folder updates Last import right away
notes.csvfrom the scratch folder.Expected:
notes.csvrow. Before this fix, Last import kept showing the previous import until you left and came back to the tab.Please check before merging
checklist.csvorcredit_score.csvthat isn't an export. Is blocking right, or should those be skipped?alert(), as the existing "No CSV files found" alert does, at boot too. Is that fine, or should it be a status line?loadFiles()renders mid-rebuild and uses upDataCleanup.lastDone. The parent commit does the same.fix-account-name-reset(v1.16.12: Fix clearing an account name not bringing the default name back #35) andfix-account-order-after-import(v1.16.13: Fix account display order lost when importing files one at a time #36) change the account set-up that was inparseCsvFile()and the account order inloadFiles(). The set-up block now lives inimportParsedCsv(); those PRs re-apply their changes there, on top of this one.https://claude.ai/code/session_013Z8iBXzUjiQbYziDZ8CZft
Generated by Claude Code