Repository navigation
Conversation
A transaction's link to a budget, bucket or debt stored the item's list
position ({ type, idx }). Deleting an item moved the ones after it up a
place, so their links pointed at the wrong item.
- Budgets, buckets and debts get a stable id when they're created
(newPlanId() in core.js) and keep it when edited. Links are { type, id }.
- Deleting an item, or clearing its list in Data & reset, removes the
links to it (unlinkPlanItems() in ui.js).
- migrate.js: migratePlanLinks() gives older items <prefix>_m<n> ids and
rewrites each { type, idx } link to the item it pointed at; links past
the end of the list are dropped. It runs inside migrateState(): at boot
(with a write-back to localStorage and IndexedDB app_state), when
finlens-state.json loads, and on JSON import.
- buildFinancialSummary() output is unchanged.
- CLAUDE.md §1, §3, §4.1, §8, §9, §20, §22; CHANGELOG; version 1.16.7.
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
v1.16.2: Fix Rebuild from your folder clearing everything when the folder has no CSV it can read
#25
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
…nk-ids 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.7. renderImportLog() keeps #18's guards. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013Z8iBXzUjiQbYziDZ8CZft
31 tasks
…ix-plan-link-ids 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
You can link a transaction to a budget, bucket or debt in its edit drawer ("Link to a budget, bucket or debt"). The link stored the item's position in its list. Deleting an item moved every item after it up one place, so their links then pointed at the wrong item. Links now point at a stable id instead. Deleting an item, or clearing its list in Data & reset, removes the links to it. Data saved by older versions is migrated when it loads.
Cause
showTxDrawer()savedtxOverrides[txId].link = { type, idx }, whereidxwas the item's index inState.budgets,State.bucketsorState.debts.deleteBudget(),deleteBucket()anddeleteDebt()spliced the array and left links alone.l.idx === i, so it was wrong in the same way.buildFinancialSummary().What changed
id:bud_,bkt_ordbt_plus 10 random base-36 characters (newPlanId()andPLAN_LINK_TYPESincore.js).saveBudget(),seedBudgets()(Use starter budget),addBucket()(+ New bucket),saveBucket()andsaveDebt(), including a debt started from a card.prev.id.setBudgetLimit()andsetCardDetail()change fields in place.{ type, id }.showTxDrawer()) lists items by id and saves{ type, id }. A link to an item that no longer exists shows as None, and saving drops it.ensurePlanIds()first gives an id to any item that has none (an item added by hand, or by an older version in another tab).ui.js:planItem(),linkedTransactions()(the bucket drawer uses it),unlinkPlanItems()andensurePlanIds().deleteBudget(),deleteBucket()anddeleteDebt()remove the links to the deleted item, saved astxOverrides. Links to other items stay. A transaction's other edits stay; an edit left with nothing in it is removed.clearPlan()inviews-cleanup.js). The button text is unchanged.IdMigration.migratePlanLinks()inmigrate.js).<prefix>_m<n>, where n is its position when the migration runs. If that id is already taken, it gets_2,_3and so on. A duplicate id is replaced the same way. The ids depend only on position, so the same old data gets the same ids wherever it's migrated.{ type, idx }becomes{ type, id }of the item it already pointed at, so no link changes target. A link past the end of its list, or with an idx that isn't a whole number, is dropped.migrateState(), so in the same three places as the v1.12.0 account-code migration:atBoot()). Afterwards,storePlanLinks()writes State'sbudgets,buckets,debtsandtxOverridesthroughlsSet(): localStorage, IndexedDBapp_state, and the normal debounced save offinlens-state.json. It writes when the migration changed State, or when a browser copy still has old data because State came from the state file. The four keys are written together, so a copy's links always match its lists.loadStateFromFile()). This also covers_restoreStateIfBrowserEmpty(). The loaded copy is migrated and a save is scheduled.importJsonFile()already callsmigrateState(); neither it norexportAllData()was edited.[FinLens] Plan links: …, in browser storageor… in finlens-state.json) reports what changed.migrateState()also returnscodes(the account-code changes), so the old "Renamed old account codes" line still appears only for account codes.buildFinancialSummary()doesn't read links or ids, and it is byte-identical to v1.16.0's (see testing).docs/EVAL.mdstays valid, and the eval doesn't need a re-run.idfields, the TxOverride shape andlink), §8, §9, §20, §22 and the "Last updated" line. A CHANGELOG entry. v1.16.7 in theindex.htmlfooter,README.md(twice) and Settings → General.views-db.js: the schema note now says{type,id}.Not verified
loadStateFromFile()andsaveStateToFile(). Permission prompts and the Reconnect flow weren't exercised.{ type, idx }links and items without ids. The next boot migrates them by position at that moment. This wasn't tested.tx_overridesIndexedDB store isn't migrated. No current code writes that store, and links are only read fromState.txOverrides. Any oldlinkthere stays as it is and is never read.views-db.js(CHANGELOG_MD) still ends at v1.4.1. No release since has updated it, and this one doesn't either. (v1.16.15: Cleanup — remove unused views-database.js, fix the in-app changelog, update stale wording #38, further up the stack, replaces it with a read ofCHANGELOG.md.)Automated checks: earlier run, not re-run · 19b6c32
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 commit19b6c32, chained on #29. 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).19b6c32test-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(from #29)test-plan-links.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.bud_m0-style ids at boot and on JSON import, so their round-trip comparisons differed (27/31 and 6/10 on the first run of this commit). The fixtures now carry ids, as every item has from this version; the app code is unchanged. Results above are with the updated fixtures.Measured before the chain
By the agent that wrote the fix, on
ae9b0a0(built onddc8a5f, v1.16.0; then numbered v1.16.4). The AI summary baseline it compares with was captured onddc8a5f, and the same comparison passes on this branch's commit (test-plan-links.jsabove).Headless Chromium (Playwright) against
samples/, on commitae9b0a0. The harness serves the pinned CDN libraries from npm. Every suite passed with the same counts on the base commitddc8a5fbefore the change.test-clarity.jstest-finances.jstest-plan.jstest-insights.jstest-plan-links.js(new)boot.jsrace.jsrenderImportLog/importLogsBody(fixed by #18). The base commit gave 7. None come from this change.Existing checks edited, and why:
test-plan.js"Budget: Save adds it" compared the whole new budget as JSON. The record now also has anid. The check now compares the record withoutid(the same string as before) and requires the id to match^bud_[0-9a-z]{10}$.test-insights.js"General: version line" expectedFinLens v1.16.0. It now expectsv1.16.7.test-plan-links.jscovers:app_state. Other edits stay.{ type, idx }data is migrated on reload. Ids becomebud_m0…, links point at the items their idx meant, and two past-the-end links are dropped (one emptied edit is removed). localStorage andapp_stateare rewritten to match, and one log line appears.finlens-state.json: a fake folder handle, injected beforeinit.js, makes boot go through the realloadStateFromFile(). State is migrated, an older, different browser copy is replaced by State's, and the normal save rewrites the file. Reloading from the rewritten file keeps the links and changes nothing.migrateState()on migrated State, on the rewritten file and on the export changes nothing, and a second boot logs nothing.newPlanId()ids with no repeats.ddc8a5f(capture-links-base.js, run on an export of that commit).buildFinancialSummary()is byte-identical for All time, This month and Last 3 months, both with no plan items and with three of each plus links. The AI request body for the debt-payoff prompt is byte-identical, and so is the AI Eval's sample summary (AIEval.loadSamples()).Control:
control-delete.jsruns the bug's steps through the UI. Onddc8a5f, after deleting B1, the transaction linked to B2 shows B3 and the one linked to B3 shows B2. On this branch they show B2 and B3.How to reproduce the bug
Run this on the base branch,
fix-json-export-fields.fix-json-export-fieldsinstead offix-plan-link-ids. Use the scratch folder with the three sample CSVs, never your real folder.B1, tick one category, and click Save budget. Repeat forB2andB3, each with a different category.What goes wrong:
Manual QA steps
Setup
checking_sample.csv,credit_card_sample.csvandsavings_sample.csvfromsamples/into a new scratch folder (for exampleFinLens-test-30). Do not use your real folder: this PR rewrites saved state.git checkout fix-plan-link-ids, then openindex.htmlin Edge.RESETin Type RESET to confirm and click Erase and start over, so you start clean.1. Deleting the first budget keeps the other links (the main fix)
B1, tick one category (any), click Save budget.B2andB3, each with a different category.Expected:
Before this fix: T2 showed B3, and T3 showed B2 (its link pointed past the end of the list, so the drawer fell back to the first option).
2. Deleting a linked item removes only its links
keep mein Notes, leave the link on B2, click Save changes.Expected:
keep meis still there, and the note line still shows under its description in the table.3. Buckets: delete the first, check the bucket drawer's list
K1, click Create bucket.K2andK3.Expected:
Before this fix: after deleting K1, each bucket's list showed the other bucket's transaction (K2 showed nothing or K3's).
4. Debts, including one started from a card
D2andD3, a balance (e.g.500) and Save debt each time.Expected:
5. Editing an item keeps its links
B3 renamed, click Save budget.Expected:
6. Data & reset → Clear budgets removes only budget links
Expected:
7. Links survive a reload
Expected:
file://entry →finlens_txOverrides: eachlinkreads{"type":"…","id":"bud_…"}(orbkt_/dbt_), neveridx.8. Old data is migrated on first load
RESETand click Erase and start over.git checkout fix-json-export-fields(the base branch) and reloadindex.html.B1,B2,B3. Link one transaction to B2 and one to B3. Wait about 5 seconds so the state file is saved.git checkout fix-plan-link-idsand press F5.Expected:
[FinLens] Plan links: 3 budget, bucket or debt ids added, 2 links rewritten, 0 dropped, endingin browser storageorin finlens-state.json.finlens-state.jsonin the folder contains"id":"bud_m0",bud_m1,bud_m2.Plan linksline appears the second time.9. Old-style JSON backup import
fix-json-export-fields), with budgets and links set up as in test 8, go to Settings → Data & reset and click Export JSON. Save the file.git checkout fix-plan-link-ids, F5. In Settings → Data & reset → Start over, choose Delete finlens-state.json, typeRESET, click Erase and start over. Pick the scratch folder again and set All time.Expected:
Please check before merging
[FinLens] Plan links: …in the console. Existing links show the same items as before, andfinlens-state.jsongets ids within about 5 seconds.bud_/bkt_/dbt_+ 10 characters for new items,bud_m0-style for migrated ones.https://claude.ai/code/session_013Z8iBXzUjiQbYziDZ8CZft
Generated by Claude Code