From 90503f6a7050ebd31004d1f61b65f05439c74c25 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 2 Nov 2026 11:30:13 +0000 Subject: [PATCH] Accounts: the display order survives importing files one at a time (v1.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 Claude-Session: https://claude.ai/code/session_013Z8iBXzUjiQbYziDZ8CZft --- CHANGELOG.md | 10 ++++++++++ CLAUDE.md | 10 ++++++---- README.md | 4 ++-- index.html | 2 +- js/core.js | 7 +++++-- js/views-data.js | 13 ++++++++----- js/views-settings.js | 2 +- 7 files changed, 33 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3bf14ae..1fb239d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,16 @@ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). --- +## [1.16.13] — 2026-11-02 + +### Accounts — the display order survives importing files one at a time +- **The bug:** importing CSV files dropped every id in the saved display order (`State.accountOrder`) whose account wasn't loaded yet. When the accounts came back one file at a time, each was added at the end, so the order you set was lost. This happened after **Clear transactions & accounts**, which keeps the order (§20), and whenever the order was restored before the accounts, for example from a backup. `loadFiles()` rebuilt the order from the loaded accounts only. +- **`loadFiles()` keeps every id in the order,** loaded or not, and adds newly loaded accounts at the end. An account takes its saved place when its file is imported. `orderedAccounts()` already skips ids with no account, so nothing extra shows. +- **The ▲▼ arrows in Settings → Accounts (`moveAccount()`)** had the same problem: they saved only the accounts on screen. Now the loaded accounts swap among the places they hold, and ids of accounts not loaded keep theirs. +- **Unchanged:** with no saved order, accounts are listed in the order they were first imported. + +--- + ## [1.16.12] — 2026-11-02 ### Accounts — clearing a name brings the default back diff --git a/CLAUDE.md b/CLAUDE.md index cf59c44..45b2e73 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -59,7 +59,7 @@ Until then, this section is the rule. FinLens is a **single-origin, zero-build, vanilla JavaScript personal finance dashboard** that runs entirely in the browser. There is no server, no npm, no bundler, no framework, and no TypeScript. The entry point is `index.html`; everything else is a plain `.js` file in the `js/` folder. -**Current version:** v1.16.12 (updated in `index.html` footer, `README.md`, and `CHANGELOG.md` on every release). +**Current version:** v1.16.13 (updated in `index.html` footer, `README.md`, and `CHANGELOG.md` on every release). **What it does:** Imports CSV exports from a bank (checking + savings) and credit cards, parses and normalizes them into a unified transaction model, and renders a multi-tab financial dashboard with budgeting, debt tracking, savings forecasting, investment planning, and Claude-powered AI analysis. @@ -175,7 +175,7 @@ const State = { lastFolderName: '', csvAutoImportPaused: false, // true after "Clear transactions & accounts" with a folder connected (§20) fileAssignments: {}, // { [filename]: kind } - accountOrder: [], // [accountId, ...] — user-defined display order + accountOrder: [], // [accountId, ...] — user-defined display order; keeps ids of accounts not loaded (§18) accountLabels: {}, // { [accountId]: name you typed } — acctName() shows it first; an empty name removes it (§18) currentView: 'overview', }; @@ -534,7 +534,7 @@ _saveStateDebounced() // Debounced wrapper (5s) — called by lsSet() // Data (core.js) filteredTx() // State.transactions filtered by active range + selected accounts -orderedAccounts() // Object.values(State.accounts) in user-defined display order +orderedAccounts() // Object.values(State.accounts) in user-defined display order (ids with no account are skipped) autoCategory(description) // Returns category string based on rules + DEFAULT_RULES txRuleFlag(desc, flag, rules?) // true if a transaction rule for that flag matches; rules default to State.txRules txFlags(desc, ov, rules?) // { isRecurring, isBill, isSubscription }: the edit in ov, else the rules (§4.2) @@ -1035,9 +1035,11 @@ Multiple credit card files can be loaded simultaneously. Each gets a unique `acc **Names you type** (Settings → Accounts, or double-click a name on the Overview) are saved in `State.accountLabels` by `setAccountName()` (views-data.js). The account's own `name` stays the default (`defaultAccountName()`). An empty name, or the default name itself, removes the label, and the default shows again. Show a name with `acctName(id)`, never `account.name`: data saved by older versions can still hold a cleared name there. +**Display order** (`State.accountOrder`, the ▲▼ arrows in Settings → Accounts) keeps the ids of accounts that aren't loaded. **Clear transactions & accounts** keeps the order (§20), and a backup can restore it before the accounts, so the files may come back one at a time. `loadFiles()` keeps every id already in the order and adds new accounts at the end; `moveAccount()` swaps the loaded accounts among the places they hold. Don't rebuild the order from `State.accounts` alone: it drops the places of accounts not loaded yet. + --- -*Last updated: v1.16.12 — 2026-11-02 (account names: §4.1 `accountLabels`; §4.3 an account's `name` is its default; §8 `defaultAccountName()`; §9 `acctName()`; §13 the summary lists accounts by `acctName()`; §18 names you type, and clearing them; v1.16.11: AI summary balances at the end of the selected period: §13 `summaryBalanceEnd()` and the date notes; §21 the parser reads the balance lines by how they start; v1.16.10: starting balance counted in every range: §8 `startingBalance()`, `currentBalances()`; §13 summary balances; §18 one balance rule; v1.16.9: the transaction drawer stores only the flags you change: §4.2 flags, §12 state mutations; v1.16.8: flags from transaction rules are worked out on load, never read from storage: §4.2 flags, §8 `txRuleFlag()` / `txFlags()` / `applyTxRulesToAll()`, §19 flags in the transactions store; v1.16.7: transaction links to budgets, buckets and debts by id: §1 version; §3 migrate.js role; §4.1 the `id` fields, TxOverride and its `link` shape; §8 `PLAN_LINK_TYPES`, `newPlanId()`; §9 `planItem()`, `linkedTransactions()`, `unlinkPlanItems()`, `ensurePlanIds()`; §20 clearing budgets, buckets or debts removes their links; §22 the plan-link migration; v1.16.6: JSON export carries account names and order, Read as, flag rules, transfer keywords and theme: §9 `JSON_EXPORT_KEYS`; §12 adding a persisted field; §20 what the export holds; v1.16.5: a new database copies every saved setting: §4.5 the keys that go through `storageKey()`; §12 adding a persisted field; §19 `DB.APP_STATE_KEYS`; v1.16.4: JSON import saves under the storage keys: §4.5 `STORAGE_KEYS` / `storageKey()`; §8 `storageKey()`; §12 adding a persisted field uses the State name; v1.16.3: An import keeps the loaded transactions it doesn't replace: §4.5 an import never drops loaded transactions; §8 `mergeImported()`, `undoTransferDetection()`; §10 memory follows the same re-upload rules; §11 kept transfers are detected again; v1.16.2: Imports read every file before changing anything: §8 `loadFiles()` options and result, `parseCsvFile()` reads only, `importParsedCsv()`, `importProblemText()`, `reloadFromDirHandle()`; §20 Rebuild from your folder reads before it clears, read before clearing; v1.16.1: Clear transaction edits works from memory: §4.2 `_originalCategories`, `_originalType` and what a transaction keeps of its row; §4.5 IndexedDB may not hold the loaded transactions; §10 a stored row holds the CSV's values; §20 Clear transaction edits; v1.16.0: Trends, AI Analysis, Settings and the Welcome rebuilt: §3 file roles; §4.1 `cardDetails`, `sampleData`, AI history `model`; §6 tile tokens and Insights/Settings/Welcome components; §7 rule 7 covers Trends; §8 `loadFiles()` sample option; §9 `shellHero()`, `NO_RANGE_VIEWS`, ☰ → ×, JSON export/import buttons; §12 Settings tabs renamed, the Welcome, range label hidden on Trends and Settings; §13 quick analyses, tab state, history; §20 new fields, Use my own files, Export/Import JSON; §21 quick analyses send `AI_PROMPTS`; v1.15.0: Plan screens rebuilt: §3 file roles; §4.1 `debtPlan` and the Budget / Bucket / Debt / Scenario shapes; §6 `--teal-text` and Plan components; §7 rule 7 covers the Plan charts; §8 plan helpers (`payoffPlan()`, `growthByYear()` …); §9 plan form helpers, `simulatePayoff()` kept unused; §12 Plan titles, Forecast tabs, range label hidden on Plan screens; §13 debt balances in the summary; §20 Clear forecast scenarios / investment mix, Clear debts resets `debtPlan`; v1.14.0: Finances screens rebuilt: §4.1 Bill shape and `recurringConfirmed`; §6 new tokens and Finances components; §7 rule 7 inline SVG charts; §8 new aggregation helpers; §9 drawer, `TX_VIEWS`, SVG/heatmap/format helpers, bill helpers, removed renderers; §11 keywords re-run detection, `transferPairs()`, card payments; §12 page actions and Transactions pills; §20 Clear bills also clears spotted-charge choices; v1.13.0: Clarity redesign — §6 tokens and components; §9 theme, chart colors and app bar helpers; §12 app bar navigation replaces the sidebar and the emoji rule; §17 footer; §20 Data & Reset; v1.12.0: bank-neutral account codes, names, samples and docs; §22 `migrate.js` added; §3, §4, §5, §10, §18, §21 updated; v1.10.2: §13 summary states its dates; §21 per-month derivations; v1.10.1: §13 `AI_MAX_TOKENS`, thinking and cut-off answers; v1.10.0: §21 AI Eval added; §13 `callClaude()` raw mode; v1.9.6: §14 folder access lasts until the last tab closes, not one page load; v1.9.5: §7 chart guard; v1.9.4: views-db.js changelog reads CRLF checkouts; v1.9.3: §14 folder permission: re-request on click, Reconnect banner, browser copy wins; v1.9.2: §0 branch, PR and approval workflow added; v1.9.1: §4.5 rehydrate transactions loaded from JSON; v1.9.0: §20 Data & Reset added; v1.8.1: §10 re-upload dedup rewritten for the occurrence-suffix fix; v1.8.0: AI Analysis restored with API-key and output hardening; `renderMarkdown()` added; `samples/` added; §1–3, §13, §14, §17 corrected to match the code)* +*Last updated: v1.16.13 — 2026-11-02 (account order: §4.1 `accountOrder` keeps ids not loaded; §8 `orderedAccounts()`; §18 display order; v1.16.12: account names: §4.1 `accountLabels`; §4.3 an account's `name` is its default; §8 `defaultAccountName()`; §9 `acctName()`; §13 the summary lists accounts by `acctName()`; §18 names you type, and clearing them; v1.16.11: AI summary balances at the end of the selected period: §13 `summaryBalanceEnd()` and the date notes; §21 the parser reads the balance lines by how they start; v1.16.10: starting balance counted in every range: §8 `startingBalance()`, `currentBalances()`; §13 summary balances; §18 one balance rule; v1.16.9: the transaction drawer stores only the flags you change: §4.2 flags, §12 state mutations; v1.16.8: flags from transaction rules are worked out on load, never read from storage: §4.2 flags, §8 `txRuleFlag()` / `txFlags()` / `applyTxRulesToAll()`, §19 flags in the transactions store; v1.16.7: transaction links to budgets, buckets and debts by id: §1 version; §3 migrate.js role; §4.1 the `id` fields, TxOverride and its `link` shape; §8 `PLAN_LINK_TYPES`, `newPlanId()`; §9 `planItem()`, `linkedTransactions()`, `unlinkPlanItems()`, `ensurePlanIds()`; §20 clearing budgets, buckets or debts removes their links; §22 the plan-link migration; v1.16.6: JSON export carries account names and order, Read as, flag rules, transfer keywords and theme: §9 `JSON_EXPORT_KEYS`; §12 adding a persisted field; §20 what the export holds; v1.16.5: a new database copies every saved setting: §4.5 the keys that go through `storageKey()`; §12 adding a persisted field; §19 `DB.APP_STATE_KEYS`; v1.16.4: JSON import saves under the storage keys: §4.5 `STORAGE_KEYS` / `storageKey()`; §8 `storageKey()`; §12 adding a persisted field uses the State name; v1.16.3: An import keeps the loaded transactions it doesn't replace: §4.5 an import never drops loaded transactions; §8 `mergeImported()`, `undoTransferDetection()`; §10 memory follows the same re-upload rules; §11 kept transfers are detected again; v1.16.2: Imports read every file before changing anything: §8 `loadFiles()` options and result, `parseCsvFile()` reads only, `importParsedCsv()`, `importProblemText()`, `reloadFromDirHandle()`; §20 Rebuild from your folder reads before it clears, read before clearing; v1.16.1: Clear transaction edits works from memory: §4.2 `_originalCategories`, `_originalType` and what a transaction keeps of its row; §4.5 IndexedDB may not hold the loaded transactions; §10 a stored row holds the CSV's values; §20 Clear transaction edits; v1.16.0: Trends, AI Analysis, Settings and the Welcome rebuilt: §3 file roles; §4.1 `cardDetails`, `sampleData`, AI history `model`; §6 tile tokens and Insights/Settings/Welcome components; §7 rule 7 covers Trends; §8 `loadFiles()` sample option; §9 `shellHero()`, `NO_RANGE_VIEWS`, ☰ → ×, JSON export/import buttons; §12 Settings tabs renamed, the Welcome, range label hidden on Trends and Settings; §13 quick analyses, tab state, history; §20 new fields, Use my own files, Export/Import JSON; §21 quick analyses send `AI_PROMPTS`; v1.15.0: Plan screens rebuilt: §3 file roles; §4.1 `debtPlan` and the Budget / Bucket / Debt / Scenario shapes; §6 `--teal-text` and Plan components; §7 rule 7 covers the Plan charts; §8 plan helpers (`payoffPlan()`, `growthByYear()` …); §9 plan form helpers, `simulatePayoff()` kept unused; §12 Plan titles, Forecast tabs, range label hidden on Plan screens; §13 debt balances in the summary; §20 Clear forecast scenarios / investment mix, Clear debts resets `debtPlan`; v1.14.0: Finances screens rebuilt: §4.1 Bill shape and `recurringConfirmed`; §6 new tokens and Finances components; §7 rule 7 inline SVG charts; §8 new aggregation helpers; §9 drawer, `TX_VIEWS`, SVG/heatmap/format helpers, bill helpers, removed renderers; §11 keywords re-run detection, `transferPairs()`, card payments; §12 page actions and Transactions pills; §20 Clear bills also clears spotted-charge choices; v1.13.0: Clarity redesign — §6 tokens and components; §9 theme, chart colors and app bar helpers; §12 app bar navigation replaces the sidebar and the emoji rule; §17 footer; §20 Data & Reset; v1.12.0: bank-neutral account codes, names, samples and docs; §22 `migrate.js` added; §3, §4, §5, §10, §18, §21 updated; v1.10.2: §13 summary states its dates; §21 per-month derivations; v1.10.1: §13 `AI_MAX_TOKENS`, thinking and cut-off answers; v1.10.0: §21 AI Eval added; §13 `callClaude()` raw mode; v1.9.6: §14 folder access lasts until the last tab closes, not one page load; v1.9.5: §7 chart guard; v1.9.4: views-db.js changelog reads CRLF checkouts; v1.9.3: §14 folder permission: re-request on click, Reconnect banner, browser copy wins; v1.9.2: §0 branch, PR and approval workflow added; v1.9.1: §4.5 rehydrate transactions loaded from JSON; v1.9.0: §20 Data & Reset added; v1.8.1: §10 re-upload dedup rewritten for the occurrence-suffix fix; v1.8.0: AI Analysis restored with API-key and output hardening; `renderMarkdown()` added; `samples/` added; §1–3, §13, §14, §17 corrected to match the code)* --- diff --git a/README.md b/README.md index f97bade..db3eb70 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ > A zero-install, browser-native finance dashboard. Drop in your bank CSVs, get instant clarity on your money. -**Version:** v1.16.12  ·  **Stack:** Vanilla JS, HTML, CSS  ·  **Install:** None +**Version:** v1.16.13  ·  **Stack:** Vanilla JS, HTML, CSS  ·  **Install:** None --- @@ -263,4 +263,4 @@ See [CHANGELOG.md](CHANGELOG.md) for the full release history. --- -*FinLens v1.16.12 — Built for one person's finances, designed to be useful for anyone's.* +*FinLens v1.16.13 — Built for one person's finances, designed to be useful for anyone's.* diff --git a/index.html b/index.html index 6b06f47..edcfb2d 100644 --- a/index.html +++ b/index.html @@ -1202,7 +1202,7 @@
-
v1.16.12 · FinLens
+
v1.16.13 · FinLens
diff --git a/js/core.js b/js/core.js index c913597..83f11fd 100644 --- a/js/core.js +++ b/js/core.js @@ -915,10 +915,13 @@ async function loadFiles(fileList, assignments, opts = {}) { } State.transactions.sort((a,b)=>b.date-a.date); detectTransfers(); - // Keep accountOrder in sync: preserve existing order, append any newly loaded accounts + // Keep accountOrder in sync: keep every id already in it, loaded or not, and append newly + // loaded accounts. An order restored from a backup, or kept while the accounts were + // cleared (§20), lists accounts whose files may come back one at a time; dropping the ones + // not loaded yet would lose their places. orderedAccounts() skips ids with no account. const knownIds=new Set(State.accountOrder); const newIds=Object.keys(State.accounts).filter(id=>!knownIds.has(id)); - State.accountOrder=[...State.accountOrder.filter(id=>State.accounts[id]),...newIds]; + State.accountOrder=[...knownIds,...newIds]; lsSet('accountOrder',State.accountOrder); State.lastRefresh = new Date(); updateRefreshLabel(); diff --git a/js/views-data.js b/js/views-data.js index d94a4fa..30cc1a2 100644 --- a/js/views-data.js +++ b/js/views-data.js @@ -269,15 +269,18 @@ function renderImportLog(container) { /* ---- Move an account up (-1) or down (+1) in the display order ---- */ // Works from the order as shown, so accounts missing from State.accountOrder (loaded from -// the browser database) move too. +// the browser database) move too. Ids in the saved order whose account isn't loaded keep +// their places: the loaded accounts are rearranged among the places they hold. function moveAccount(accountId, direction) { if (!accountId) return; - const order=orderedAccounts().map(a=>a.id); - const idx=order.indexOf(accountId); + const shown=orderedAccounts().map(a=>a.id); + const idx=shown.indexOf(accountId); if (idx===-1) return; const newIdx=idx+direction; - if (newIdx<0||newIdx>=order.length) return; - [order[idx],order[newIdx]]=[order[newIdx],order[idx]]; + if (newIdx<0||newIdx>=shown.length) return; + [shown[idx],shown[newIdx]]=[shown[newIdx],shown[idx]]; + let k=0; + const order=[...new Set([...(State.accountOrder||[]),...shown])].map(id=>State.accounts[id]?shown[k++]:id); State.accountOrder=order; lsSet('accountOrder',order); buildAccountFilter(); diff --git a/js/views-settings.js b/js/views-settings.js index 3201fdf..a6d6b9b 100644 --- a/js/views-settings.js +++ b/js/views-settings.js @@ -67,7 +67,7 @@ function _renderGeneralSettings(root) { ``).join('')} -
VersionFinLens v1.16.12
+
VersionFinLens v1.16.13
`); const opts=$$('[data-theme-opt]',root); opts.forEach((b,i)=>{