Repository navigation
v1.16.1: Fix "Clear transaction edits" wiping every transaction when the browser database is empty - #24
Open
gitluis wants to merge 3 commits into
Open
v1.16.1: Fix "Clear transaction edits" wiping every transaction when the browser database is empty#24gitluis wants to merge 3 commits into
gitluis wants to merge 3 commits into
Conversation
…er database is empty (v1.16.1) DataCleanup.clearEdits() replaced the loaded transactions with IndexedDB's rows. After a restore from finlens-state.json (a new browser, cleared site data) that store is empty or partial, so every transaction vanished from memory, and with a folder connected _finish() then wrote the empty list to finlens-state.json. master has the same code. - clearEdits() now rebuilds each loaded transaction without its edit, from the transaction itself (DataCleanup._unedited()): original description, category and type, no notes or plan link, flags from the rules, then detectTransfers(). No transaction is dropped or added; the transactions store isn't written. - Transactions keep their CSV category and type: mkTx() records _originalCategories and _originalType, reconstituteTx() carries them, DB.loadAll() takes them from the row, and finlens-state.json saves them. - A transaction from a <=v1.16.0 file with no row has neither: an edited category/type, or a transfer, is worked out again from the description and amount (exact for checking and savings; a card's own columns can't be). - DB.importTransactions() stores the CSV's category, type and rule flags, not the edits mkTx() applied, so an import while edits exist (Rebuild from your folder) no longer saves the edits into the row. - Version bumped to v1.16.1 (CHANGELOG, footer, README, Settings, CLAUDE.md); CLAUDE.md §4.2, §4.5, §10 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
v1.16.2: Fix Rebuild from your folder clearing everything when the folder has no CSV it can read
#25
Open
Open
gitluis
pushed a commit
that referenced
this pull request
Nov 2, 2026
…e-tab Merges cleanup-stale-docs-and-dead-code (#38), the top of the fix chain stacked on #21, so #10 can merge last. No rebase. Conflicts: - Versions: 1.17.0 kept in the footer, README, Settings -> General and CLAUDE.md §1. CHANGELOG: 1.17.0, then 1.16.15 ... 1.16.1, then 1.16.0. - CLAUDE.md: "Last updated" is #10's note followed by the chain's history; §3's views-db.js line names both the Database tab and the Changelog view that reads CHANGELOG.md. - views-db.js: #10's rebuilt DB Schema code, with #30's plan link note ({type,id}); the Changelog banner keeps "4. CHANGELOG" with #38's text and code (loadChangelog(), no embedded copy). - views-settings.js: #10's tab-bar comment and version line. - #10's wording about the embedded changelog, which #38 removed, is updated in CLAUDE.md §19 and the 1.17.0 entry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013Z8iBXzUjiQbYziDZ8CZft
Open
33 tasks
…ipes-transactions 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.1. renderImportLog() keeps #18's guards. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013Z8iBXzUjiQbYziDZ8CZft
44 tasks
gitluis
pushed a commit
that referenced
this pull request
Nov 2, 2026
…e-status-indicator Brings the Clarity redesign and fix stack (#16-#21, #24-#38, #10) into #23, so its backup status can be rebuilt on the app bar. All seven files #23 touched conflicted (CHANGELOG.md, CLAUDE.md, README.md, index.html, js/core.js, js/views-data.js, js/views-settings.js). Each was resolved by taking the redesign's version: the sidebar #23 built on is gone. The tree now equals settings-database-tab at 477f357. The next commit rebuilds #23's changes on the app bar's sync badge. 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
Open
This was referenced Nov 2, 2026
gitluis
pushed a commit
that referenced
this pull request
Nov 2, 2026
…database-tab Brings in the second fix chain (#24-#38 already merged here; now the twelve fixes v1.16.16-v1.16.27). Version stays v1.17.0; CHANGELOG runs 1.17.0, 1.16.27 ... 1.16.0, 1.10.5 ... Conflicts: - CHANGELOG.md: 1.17.0 entry on top of the chain's changelog. - README.md, index.html, js/views-settings.js, CLAUDE.md section 1: v1.17.0. - CLAUDE.md Last updated: #10's note, then the chain's history from v1.16.27. - js/views-db.js: #10's rewritten DB Schema kept; the chain's one change there (ruleCategories in the app_state note, v1.16.25) applied to #10's note. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013Z8iBXzUjiQbYziDZ8CZft
…ar-edits-wipes-transactions Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013Z8iBUZo6LRYpLthSp2PRi # Conflicts: # js/views-settings.js
4 tasks
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 → Clear transaction edits could delete every loaded transaction. This happened when the browser's IndexedDB didn't hold them, which is the case after FinLens restores from
finlens-state.jsonin a new browser or after site data was cleared. With a folder connected, the empty list was then written tofinlens-state.json.The action now rebuilds the loaded transactions from memory, so it removes only the edits. To make that possible, each transaction now keeps its CSV category and type, and IndexedDB rows store the CSV's values instead of the edited ones.
Cause
DataCleanup.clearEdits()replacedState.transactionswith the store's rows:(await DB._getAllTransactions()).map(r => reconstituteTx(r, {})).finlens-state.jsonfirst (loadStateFromFile()), and picking or reconnecting a folder in an empty browser restores from it (_restoreStateIfBrowserEmpty()). Neither writes the transactions to IndexedDB, so in a new browser or after cleared site data the store is empty._finish()→saveStateNow()then wrote"transactions": []tofinlens-state.json.DB._dbunset): the rebuild was skipped, so the edits stayed on screen until a reload._originalDesc).mkTx()applies the edit when it builds the transaction, anddetectTransfers()overwrites the category and type. The CSV's category and type were lost.DB.importTransactions()stored the category, type and flags thatmkTx()showed, edits included.DB.loadAll()now takes a transaction's original category and type from its row, so the row must hold the CSV's values.masterhas both.origin/master(9ba3e79, v1.10.4) has the sameclearEdits()body and the sameimportTransactions()row. A probe on master's code: 257 transactions → 0 in memory, andfinlens-state.jsonwritten with 0.What changed
DataCleanup.clearEdits()(views-cleanup.js) rebuilds each loaded transaction without its edit, in the same order, with the newDataCleanup._unedited(t, ov, row). Then it runsdetectTransfers()and_finish()as before. IndexedDB rows are read only to fill in the category and type of a transaction that doesn't record them. They never decide which transactions exist._unedited()rebuilds one transaction withreconstituteTx(…, {}):_originalDesc.txRuleFlag()), asmkTx()sets them without an edit._originalCategories/_originalType, else the row's.finlens-state.jsonwritten by v1.16.0 or earlier with no row has neither. If its category or type was edited, or it was marked as a transfer, they are worked out again from the description and amount (autoCategory(), debit or credit by sign), as an import of a file without Category and Type columns does. That is exact for checking and savings. A card's own Category and Type (Sale/Payment/Return) can't be recovered; Rebuild from your folder gets them back. These worked-out values aren't recorded as originals.accountOverride(no screen sets it, but older data can hold one): the row's account, as before.mkTx()(core.js) records_originalCategories: [o.category]and_originalType: o.type.reconstituteTx()(db.js) carries both when the record has them.loadStateFromFile()andloadFiles()keep them that way, andfinlens-state.jsonsaves them, because it serializes transactions whole.DB.loadAll()passes the row'scategoriesandtypeas the originals.DB.importTransactions()stores_originalCategories,_originalTypeand the flags from the rules, instead of whatmkTx()showed.transactionsstore is not filled. Reasons:accountscoverage, theimport_logentry and theschemaIdthat an import records.finlens-state.json, the source of truth (CLAUDE.md §4.5), is rewritten with every transaction, and boot loads it first.CHANGELOG.md, theindex.htmlfooter,README.md(badge and footer), Settings → General, and CLAUDE.md §1.Other paths checked
DB._getAllTransactions()callers:DB.loadAll()is fine: it replacesState.transactionsonly when the store has rows, and runs at boot only when the state file wasn't loaded.clearEdits()is fixed here.DB.queryTransactions()also reads rows, but nothing calls it.views-database.jsisn't loaded.clearPlan()doesn't touch transactions.clearImported()andclearSampleData()empty the transactions on purpose.rebuildFromFolder()): doesn't read IndexedDB. Found, not fixed: it clears memory and the stores before it knows the folder has any CSV. With onlyfinlens-state.jsonin the folder, it alerts "No CSV files found in the selected folder.", leaves 0 transactions, and rewritesfinlens-state.jsonwith 0 (probe-rebuild-empty.js). This is a separate bug for its own PR: it should look for CSV files before clearing.loadFiles()): doesn't read IndexedDB. Found, not fixed: "Choose CSV files" replaces memory with only the chosen files' transactions. Importing just the card CSV after all three samples took memory from 257 to 165 while IndexedDB kept 257, and the next autosave wrote 165 tofinlens-state.json(probe-partial-import.js). This is a separate bug for its own PR.importJsonFile()) doesn't rebuild transactions. It replacestxOverrideswithout re-applying them to the loaded transactions, so the edits on screen are stale until a reload. That isn't data loss, and it isn't touched here.init.js),_restoreStateIfBrowserEmpty(),reconnectDataFolder(),IdMigration.atBoot(),adoptOverrides(),reapplyTransferKeywords(),recategorizeAll()anddeleteCategory(). They work on memory, or they load only into an empty browser.Not verified
idbGet('csvDirHandle')is stubbed, and the state file lives inlocalStorage). Not tried in Edge or Chrome with a real directory, or in Safari or Firefox.credit, which counts as income. In the samples every card payment pairs with the checking autopay and becomes a transfer again, so the tests can't show this.accountOverride: tested only with an injected edit, since no screen sets it. With no row, the moved account stays.Automated checks: earlier run, not re-run · 93a373a
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 commit93a373a, chained on #21. 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).93a373atest-clarity.jstest-insights.jstest-finances.jstest-plan.jsboot.jsrace.jsrenderImportLog(the race #18 fixes on master; not in this stack)test-clear-edits.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
On the original commit
93a373a, which is also this branch's commit: it was already built on70c7125, so it didn't change when the stack was built.Headless Chromium (Playwright) against
samples/(257 transactions), with the pinned CDN libraries served from npm. Each script ran asNODE_PATH=$(npm root -g) node <script> <repo> <outdir>.70c7125(v1.16.0)test-clarity.jstest-finances.jstest-plan.jstest-insights.jsboot.jsrace.jsrenderImportLog(#18)renderImportLog(#18)test-clear-edits.js(new)No existing suite was changed. Their phone checks still pass, and no phone checks were added (desktop only).
test-clear-edits.jsmakes five edits through the transaction drawer:Each case then clicks Clear transaction edits twice in Data & reset. Every case checks that no transaction is lost or added, and that no edit is left in State, localStorage or IndexedDB.
finlens-state.json, IndexedDB empty: a new browser context boots from a file with the edits and has 0 rows. After the clear: 257 in memory, all at their CSV values, including the card's own category (Travel) and Payment type. The file written by the fake folder holds 257 transactions and no edits, and each one records_originalCategoriesand_originalType. The store stays empty. After a reload (from the file): 257, no edits. Base: 0 in memory, 0 in the file.accountOverride: the clear puts the transaction back in the account it was imported into. Passes on the base too; it guards against a regression.Probes (one-off scripts):
probe-clear-edits-file.js(a fake folder, an empty store, thenclearEdits()): master9ba3e79: 257 → 0, file written with 0. Base70c7125: the same. This branch: 257 → 257, file written with 257.probe-rebuild-empty.jsandprobe-partial-import.js: the two bugs found and not fixed, above.How to reproduce the bug
Run this on the base branch,
clarity-insights.masterhas the same bug.clarity-insightsinstead offix-clear-edits-wipes-transactions. Use a scratch folder with the three sample CSVs, never your real data folder.index.htmlin it. (real browser)finlens-state.json.UBER TRIP, and open the Oct 20 row (−$10.62). Change Category toGroceriesand click Save changes.finlens-state.jsonfrom the scratch folder.What goes wrong:
finlens-state.jsonnow holds"transactions": []. Press F5 and it still shows 0.Manual QA steps
Setup
git checkout fix-clear-edits-wipes-transactions.C:\temp\finlens-24. Copy the three CSVs fromsamples/into it. Never use your real data folder for this PR.index.htmlin Edge.finlens-state.json.Every Clear button in Data & reset needs two clicks: Clear, then Click again to confirm.
1. Clear edits in a "new browser" keeps every transaction (the main fix)
index.htmlin it. You should see the Welcome. (A separate Edge profile also works.)finlens-state.json.UBER TRIP. Click the first row's description (Oct 20, −$10.62).TEST RENAME, Category toGroceries, Type toIncome / refund. Tick Bill. Typehelloin Notes. Click Save changes.TEST RENAME. Confirm the row shows Groceries, a Bill flag and the note.Expected:
UBER TRIPshows the Oct 20 −$10.62 row again with category Travel, no Bill flag and no note. SearchingTEST RENAMEfinds nothing.Before this fix: after step 9 the Transactions tile reads 0, and every screen is empty.
2. The state file still holds every transaction (persistence)
finlens-state.jsonfrom the scratch folder in Notepad or VS Code. Search for_originalCategories.Expected:
UBER TRIProw is still at its CSV values.finlens-state.jsonhas"txOverrides": {}and each transaction has_originalCategoriesand_originalTypefields (for example"_originalCategories": ["Travel"],"_originalType": "debit"on an UBER TRIP).Before this fix: the file holds
"transactions": []and the reload shows 0.3. Clearing edits when IndexedDB holds the transactions (normal browser)
index.htmlin a normal Edge window. Set All time.SPOTIFY USA, open the Oct 9 row (−$11.99), change Category toHousing, click Save changes.Payment Thank You, open the Oct 6 row (+$836.91). Change Category toShoppingand Type toExpense. Click Save changes.Expected:
4. IndexedDB rows store the CSV values, not the edits (Rebuild)
TARGET 00021, open the Oct 17 row (−$75.63).Housingand tick Subscription. Click Save changes.TARGET 00021again.Expected:
categories: ["Shopping"],type: "debit"andisSubscription: false.Before this fix: the IndexedDB row holds
["Housing"]andisSubscription: true, and in a browser that boots from IndexedDB the clear brings the edit back.5. Transaction rules still flag after clearing (regression)
LIBERTY INTERNET. Set Flag as to Bill. Click Add rule.LIBERTY INTERNET. Confirm the rows show a Bill flag.Expected:
6. A savings transfer leg goes back to being a transfer
ONLINE TRANSFER TO SAVINGS, open the Oct 3 row (−$525.00).Expenseand Category toShopping. Addmovedin Notes. Click Save changes.Expected:
Please check before merging
finlens-state.jsonstill lists every transaction.DB.importTransactions()change belongs in this PR rather than its own:DB.loadAll()'s originals are only right if the rows hold the CSV's values.finlens-state.jsongrows by two fields per transaction (_originalCategories,_originalType). That's acceptable.https://claude.ai/code/session_013Z8iBXzUjiQbYziDZ8CZft
Generated by Claude Code