Skip to content

v1.16.13: Fix account display order lost when importing files one at a time - #36

Open
gitluis wants to merge 3 commits into
fix-account-name-resetfrom
fix-account-order-after-import
Open

gitluis wants to merge 3 commits into
fix-account-name-resetfrom
fix-account-order-after-import

Conversation

@gitluis

@gitluis gitluis commented Nov 2, 2026 •

Copy link
Copy Markdown
Owner

Stacked on #35 (fix-account-name-reset), in a chain of fixes on top of the Clarity redesign (#16 → #17 → #19 → #20 → #21). Merge in order: #16, #17, #19, #20, #21, then the fixes #24–#38 and #39–#50 in order, then #10, then #23. #18 is a separate patch on master (already merged).
Written on top of #35, but its code doesn't need #35's: it is stacked so versions and the CHANGELOG merge cleanly.

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 ran State.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.
  • When it happens:
  • 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.
  • Master has the loadFiles() part. origin/master (9ba3e79, v1.10.4) has the same filter in loadFiles(). 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's moveAccount() works from State.accountOrder directly, so the arrow part only exists on the Clarity stack (v1.16.0).

What changed

Not verified

  • A real backup restore followed by single-file imports. test-account-order.js still 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's test-json-export.js checks 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 from finlens-state.json or a real data folder.
  • Real browsers. Only headless Chromium. Not checked in Edge, Chrome, Safari or Firefox by hand.
  • Phone layout. Not checked. FinLens targets desktop browsers for now.
  • Ids that never come back. Ids of accounts that are never imported again (for example a card file you deleted) now stay in 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 commit 90503f6, chained on #35. Each script ran as NODE_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).

Script Result on 90503f6
test-clarity.js 55/55
test-insights.js 137/137
test-finances.js 126/126
test-plan.js 127/127
boot.js 257 transactions, 24 views, 0 errors
race.js 7 errors, all renderImportLog (the race #18 fixes on master; not in this stack)
test-clear-edits.js (from #24) 47/47
test-rebuild-folder.js (from #25) 57/57
test-partial-import.js (from #26) 47/47
test-json-import.js (from #27) 28/28
test-new-browser-copy.js (from #28) 10/10
test-json-export.js (from #29) 31/31
test-plan-links.js (from #30) 60/60
test-rule-flags.js (from #31, as updated by #32) 67/67
test-drawer-flags.js (from #32) 36/36
test-start-balance.js (from #33, as updated by #34) 193/193
test-ai-summary-period.js (from #34) 78/78
test-account-names.js (from #35) 40/40
test-account-order.js (new in this PR) 32/32

Measured before the chain

By the agent that wrote the fix, on 7f2fa9b (built on be87cd8, #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):

  • Setup: the order is set the way a backup restore would set it (State.accountOrder + lsSet), because the JSON import doesn't carry it on this base.
  • What it covers:
    • a restored order, then the files one at a time, with a reload in between and after;
    • a new account (a copy of the card file under another name);
    • the arrows with an account not loaded, and with every account loaded;
    • Clear transactions & accounts, then the files one at a time with a reload in between, then another reload;
    • a first import with no saved order.
  • What it reads: the order in State, localStorage and IndexedDB app_state, and as shown on the Overview, in Settings → Accounts (including which arrows are disabled) and in the accounts filter.
  • On 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:
    • a new account is appended when every account is loaded;
    • the arrows swap neighbours when every account is loaded;
    • Clear keeps the order;
    • a first import keeps the import order;
    • no horizontal scroll;
    • no errors.
  • On this branch: 32/32.

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:

Suite Base 70c7125 This branch
test-clarity.js 55/55 55/55
test-finances.js 126/126 126/126
test-plan.js 127/127 127/127
test-insights.js 137/137 137/137
boot.js 0 errors 0 errors
race.js 7 errors 7 errors
How to reproduce the bug

Run this on the base branch, fix-account-name-reset (#35). Master has the same bug in loadFiles().

  1. Do the Setup from the testing steps below, but check out fix-account-name-reset instead of fix-account-order-after-import. Use an InPrivate window and Choose CSV files only, no folder.
  2. Follow tests 1 and 2 below, so all three accounts are loaded and Settings → Accounts shows Bank Credit Card, Bank Savings, Bank Checking.
  3. Click the Data & reset tab. On Clear transactions and accounts, click Clear, then Click again to confirm.
  4. Click the Import tab. Under Using Safari or Firefox?, click Choose CSV files, pick checking_sample.csv and click Import 1 file.
  5. Do the same for savings_sample.csv.
  6. Press F5.
  7. Import credit_card_sample.csv the same way.
  8. Look at Settings → Accounts, then Overview, then the Accounts popover.

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_accountOrder no longer lists the card's id first.

Manual QA steps

Setup

  1. git checkout fix-account-order-after-import.
  2. Copy checking_sample.csv, savings_sample.csv and credit_card_sample.csv from samples/ to a scratch folder. In that folder, make one more copy of credit_card_sample.csv named credit_card_copy.csv (used in test 5).
  3. Open an Edge InPrivate window (Ctrl+Shift+N), so FinLens starts with nothing saved. Drag index.html into it.
  4. Import with Choose CSV files only. Don't pick a folder in these tests, so nothing re-imports on its own when you reload.

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

  1. On the Welcome screen, click choose the files (in the line under the two big buttons).
  2. Pick only checking_sample.csv.
  3. Under Choose how to read this file, leave Read as on Checking. Click Import 1 file.
  4. Still in Settings → Import, scroll to Using Safari or Firefox? and click Choose CSV files. Pick savings_sample.csv, then click Import 1 file.
  5. Do the same for credit_card_sample.csv.
  6. Click the Accounts tab in Settings.

Expected:

  • The order is Bank Checking, Bank Savings, Bank Credit Card (credit_card_sample).
  • The top row's up arrow and the bottom row's down arrow are disabled.

2. The arrows still swap neighbours with every account loaded

  1. In Settings → Accounts, click the up arrow (tooltip Move up) on Bank Credit Card. The order is Checking, Card, Savings.
  2. Click Move up on Bank Credit Card again. The order is Card, Checking, Savings.
  3. Click the down arrow (Move down) on Bank Checking. The order is Card, Savings, Checking.

Expected:

  • Settings → Accounts shows Bank Credit Card, Bank Savings, Bank Checking.
  • The Overview cards and the Accounts popover show the same order.
  • Only the card's up arrow and Checking's down arrow are disabled.

3. The order survives Clear and a one-file-at-a-time import (main fix)

Start from the order Card, Savings, Checking (test 2).

  1. Click the Data & reset tab in Settings.
  2. On Clear transactions and accounts, click Clear, then Click again to confirm.
  3. Click the Import tab. Under Using Safari or Firefox?, click Choose CSV files, pick checking_sample.csv and click Import 1 file.
  4. Do the same for savings_sample.csv.
  5. Click the Accounts tab.
  6. Press F5.
  7. In Settings → Import, import credit_card_sample.csv the same way.
  8. Look at Settings → Accounts, then Overview, then the Accounts popover.

Expected:

  • At step 5, Bank Savings is listed above Bank Checking (the card isn't back yet).
  • At step 8, all three places show Bank Credit Card, Bank Savings, Bank Checking.
  • finlens_accountOrder lists 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.

  1. Settings → Data & reset → Clear transactions and accounts → Clear → Click again to confirm.
  2. In Settings → Import, import checking_sample.csv, then savings_sample.csv, with Choose CSV files.
  3. In Settings → Accounts (only Savings and Checking show), click Move up on Bank Checking. Checking is now above Savings.
  4. In Settings → Import, import credit_card_sample.csv.
  5. Open Settings → Accounts.

Expected:

  • The order is Bank Credit Card, Bank Checking, Bank Savings: the card is back in first place, and your move is kept.

Before this fix: the card ends up last (Checking, Savings, Card).

5. A brand-new account is added at the end

  1. With all three accounts loaded, import credit_card_copy.csv with Choose CSV files. Leave Read as on Credit card.
  2. Open Settings → Accounts.

Expected:

  • A fourth account, Bank Credit Card (credit_card_copy), is last. The other three keep their order.
  • Its down arrow is disabled, and the row above it now has an enabled down arrow.

6. The order survives a reload

  1. Press F5.
  2. Check Settings → Accounts, Overview and the Accounts popover.

Expected:

  • The same order as before the reload, in all three places.
  • F12 → Console shows no red errors.

7. A JSON backup, then the files one at a time

  1. Set an order you'll recognise with the arrows, e.g. Savings first.
  2. Settings → Data & reset → Export JSON. Keep the downloaded finlens-export-YYYYMMDD.json.
  3. Close the InPrivate window. Open a new one and open index.html.
  4. Open Settings from the gear icon if it shows; on a true first run the app bar is empty, so first import one file from the Welcome screen (choose the files → checking_sample.csv → Import 1 file), which opens Settings.
  5. Settings → Data & reset → Import JSON… → pick the export. Click OK on Imported successfully.
  6. In Settings → Import, import the other CSVs one at a time with Choose CSV files.
  7. Open Settings → Accounts.

Expected:

  • The order from step 1, not the order you imported in.

Please check before merging

  • Set an order with the arrows in Settings → Accounts, then use Clear transactions and accounts in Settings → Data & reset. Import the CSV files one at a time with Choose CSV files (Settings → Import): the accounts come back in your order.
  • The arrows still swap neighbours with every account loaded, and the first and last arrows are disabled.
  • A first import with no saved order still lists accounts in import order.
  • You're happy that ids of accounts not loaded stay in State.accountOrder, unseen, until Start over.
  • With v1.16.6: Fix JSON export leaving out account names, order, flag rules, transfer keywords, Read as choices and theme #29 in the stack: restore a JSON backup that holds an order, then import the files one at a time.
  • Manual QA passed in Edge/Chrome with a real folder

https://claude.ai/code/session_013Z8iBXzUjiQbYziDZ8CZft


Generated by Claude Code

…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
…-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
@gitluis gitluis added the bug Something isn't working label Nov 3, 2026 — with Claude
@gitluis gitluis added this to the Clarity stack (v1.12.0 → v1.18.1) milestone Nov 3, 2026 — with Claude
…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
@gitluis gitluis changed the title v1.16.13: fix account display order lost when importing files one at a time v1.16.13: Fix account display order lost when importing files one at a time Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants