Repository navigation
Conversation
…1.16.13) Importing CSV files dropped every id in the saved display order (State.accountOrder) whose account wasn't loaded yet, so when the accounts came back one file at a time each was added at the end and the order was lost. It happened after "Clear transactions & accounts", which keeps the order, and whenever the order was restored before the accounts, for example from a backup. - loadFiles() keeps every id already in the order, loaded or not, and appends newly loaded accounts. orderedAccounts() already skips ids with no account. - moveAccount() (the Settings -> Accounts arrows) saved only the accounts on screen. Now the loaded accounts swap among the places they hold, and ids of accounts not loaded keep theirs. - With no saved order, accounts are still listed in the order they were first imported. 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
…-order-after-import 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.13. renderImportLog() keeps #18's guards. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013Z8iBXzUjiQbYziDZ8CZft
…ix-account-order-after-import 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
The account display order you set in Settings → Accounts now survives importing your CSV files one at a time. When an account's file is imported, the account takes its saved place. New accounts are added at the end.
Cause
loadFiles()rebuilt the order from the loaded accounts only. It ranState.accountOrder.filter(id => State.accounts[id]), so it dropped the id of every account not loaded yet. When those accounts came back later, each was added at the end, and the order was lost.accountOrderto the JSON export, so a JSON restore is one such case.moveAccount()(the ▲▼ arrows) had the same problem. It saved only the accounts on screen, so moving an account dropped the places of accounts not loaded.loadFiles()part.origin/master(9ba3e79, v1.10.4) has the same filter inloadFiles(). A probe on master confirmed it: saved order card, savings, checking; Clear transactions & accounts; import checking, savings, card one at a time. The result is checking, savings, card. Master'smoveAccount()works fromState.accountOrderdirectly, so the arrow part only exists on the Clarity stack (v1.16.0).What changed
loadFiles()(core.js) keeps every id already inState.accountOrder, loaded or not, and adds newly loaded accounts at the end.orderedAccounts()already skips ids with no account, so nothing extra shows on screen.moveAccount()(views-data.js) swaps the loaded accounts among the places they hold. Ids of accounts not loaded keep their places.accountOrder), §8 (orderedAccounts()), §18 (display order) and the Last updated line.parseCsvFile()intoimportParsedCsv()and rewroteloadFiles()around it, and v1.16.3: Fix importing some CSV files losing the other loaded transactions #26 merges the files' transactions into the loaded ones. This fix doesn't touch the set-up block (v1.16.12: Fix clearing an account name not bringing the default name back #35 does, and resolves that conflict). Its two changes re-applied as follows:loadFiles(): the account-order block still sits afterdetectTransfers()at the end of the import in v1.16.3: Fix importing some CSV files losing the other loaded transactions #26's version, so the change applied there as written: every saved id is kept and newly loaded accounts are appended.importParsedCsv()still recordsdisplayOrderfromState.accountOrder, which now also holds ids of accounts not loaded.moveAccount(): unchanged by v1.16.2: Fix Rebuild from your folder clearing everything when the folder has no CSV it can read #25/v1.16.3: Fix importing some CSV files losing the other loaded transactions #26; applied as written.test-account-order.jspasses on it (above).Not verified
test-account-order.jsstill sets the order directly, as a restore would. v1.16.6: Fix JSON export leaving out account names, order, flag rules, transfer keywords, Read as choices and theme #29'stest-json-export.jschecks that the order survives an export and import with all files loaded at once; the two weren't combined.finlens-state.json. The order was checked after reloads from browser storage only, not fromfinlens-state.jsonor a real data folder.State.accountOrder. They don't show anywhere, and Start over removes them. Nothing else cleans them up.Automated checks: earlier run, not re-run · 90503f6
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 commit90503f6, chained on #35. 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).90503f6test-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(from #30)test-rule-flags.js(from #31, as updated by #32)test-drawer-flags.js(from #32)test-start-balance.js(from #33, as updated by #34)test-ai-summary-period.js(from #34)test-account-names.js(from #35)test-account-order.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
7f2fa9b(built onbe87cd8, #35's commit before the chain, then v1.16.8; this one was v1.16.9). "The previous PR" below is #35.Headless Chromium (Playwright) at 1280px, against
samples/, in light and dark. CDNs are blocked in the sandbox, so the harness serves the pinned libraries from npm.New test,
test-account-order.js(32 checks, 16 per theme):State.accountOrder+lsSet), because the JSON import doesn't carry it on this base.State, localStorage and IndexedDBapp_state, and as shown on the Overview, in Settings → Accounts (including which arrows are disabled) and in the accounts filter.70c7125(base): 12/32. On the previous PR's commit it's also 12/32. All 20 failures are the bug: ids of accounts not loaded are dropped, and the accounts come back in import order. The 12 checks that pass are the controls:Also on this branch:
test-account-names.js(from the previous PR) 40/40.Existing suites on this branch (
run-all.sh), the same counts as on base:70c7125test-clarity.jstest-finances.jstest-plan.jstest-insights.jsboot.jsrace.jsrace.jserrors: all of them arerenderImportLog/importLogsBody(Cannot set properties of null), which PR v1.10.5: fix Import Logs throwing when the view is left before it loads #18 fixes. None come from this change.How to reproduce the bug
Run this on the base branch,
fix-account-name-reset(#35). Master has the same bug inloadFiles().fix-account-name-resetinstead offix-account-order-after-import. Use an InPrivate window and Choose CSV files only, no folder.checking_sample.csvand click Import 1 file.savings_sample.csv.credit_card_sample.csvthe same way.What goes wrong: the accounts come back in import order, Bank Checking, Bank Savings, Bank Credit Card, not your saved order Card, Savings, Checking.
finlens_accountOrderno longer lists the card's id first.Manual QA steps
Setup
git checkout fix-account-order-after-import.checking_sample.csv,savings_sample.csvandcredit_card_sample.csvfromsamples/to a scratch folder. In that folder, make one more copy ofcredit_card_sample.csvnamedcredit_card_copy.csv(used in test 5).index.htmlinto it.The default account names are Bank Checking, Bank Savings and Bank Credit Card (credit_card_sample). The order shows in three places: the account cards on Overview, the rows in Settings → Accounts, and the list under the Accounts icon in the app bar. The saved order is in F12 → Application → Local Storage → the
file://entry →finlens_accountOrder.1. A first import with no saved order keeps the import order
checking_sample.csv.savings_sample.csv, then click Import 1 file.credit_card_sample.csv.Expected:
2. The arrows still swap neighbours with every account loaded
Expected:
3. The order survives Clear and a one-file-at-a-time import (main fix)
Start from the order Card, Savings, Checking (test 2).
checking_sample.csvand click Import 1 file.savings_sample.csv.credit_card_sample.csvthe same way.Expected:
finlens_accountOrderlists the card's id first.Before this fix: the accounts come back in import order: Checking, Savings, Card.
4. Moving an account while another isn't loaded keeps the missing one's place
Start from the order Card, Savings, Checking.
checking_sample.csv, thensavings_sample.csv, with Choose CSV files.credit_card_sample.csv.Expected:
Before this fix: the card ends up last (Checking, Savings, Card).
5. A brand-new account is added at the end
credit_card_copy.csvwith Choose CSV files. Leave Read as on Credit card.Expected:
6. The order survives a reload
Expected:
7. A JSON backup, then the files one at a time
finlens-export-YYYYMMDD.json.index.html.checking_sample.csv→ Import 1 file), which opens Settings.Expected:
Please check before merging
State.accountOrder, unseen, until Start over.https://claude.ai/code/session_013Z8iBXzUjiQbYziDZ8CZft
Generated by Claude Code