From 173aa4eb0dc99fe4158e6c1c1d9cf1cb0b0af7ec Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 24 Oct 2026 03:55:21 +0000 Subject: [PATCH 1/2] Rebuild transactions loaded from finlens-state.json loadStateFromFile() returned transactions straight from JSON.parse: dates were strings and the category getter was frozen. monthKey() then threw, which crashed the Income view and made buildFinancialSummary() fail before the AI request was sent. Rebuild them with reconstituteTx(), as DB.loadAll() does. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01AT1Bh6Sscb8ogzzuf8U3Jc --- js/core.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/js/core.js b/js/core.js index c431e56..117090f 100644 --- a/js/core.js +++ b/js/core.js @@ -113,6 +113,16 @@ async function loadStateFromFile() { delete loaded.apiKey; _saveStateDebounced(State); } + // JSON turns each transaction's Date into a string and freezes the `category` + // getter into a plain value. Rebuild them exactly as DB.loadAll() does, or + // monthKey()/date comparisons throw or misbehave (Income, Trends, AI summary). + if (Array.isArray(loaded.transactions)) { + const ovs = loaded.txOverrides || State.txOverrides || {}; + loaded.transactions = loaded.transactions + .map(raw => reconstituteTx({ ...raw, description: raw._originalDesc || raw.description }, ovs[raw.id] || {})) + .filter(t => !isNaN(t.date)) + .sort((a, b) => b.date - a.date); + } console.log('[FinLens] State loaded from finlens-state.json'); return loaded; } catch(e) { From ae70dac5e6b6290c24ad94bf4a309259cd2116d7 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 24 Oct 2026 03:55:21 +0000 Subject: [PATCH 2/2] =?UTF-8?q?Release=20v1.9.1:=20changelog,=20version=20?= =?UTF-8?q?strings,=20CLAUDE.md=20=C2=A74.5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01AT1Bh6Sscb8ogzzuf8U3Jc --- CHANGELOG.md | 14 ++++++++++++++ CLAUDE.md | 5 +++-- README.md | 4 ++-- index.html | 2 +- js/views-settings.js | 2 +- 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 219781a..e415f54 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,20 @@ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). --- +## [1.9.1] — 2026-10-23 + +### Fixed +- **Booting from `finlens-state.json` broke the AI tab and the Income view.** + - **Cause:** `loadStateFromFile()` returned transactions straight from `JSON.parse`, so every `date` was a string and the `category` getter was frozen into a plain value. `monthKey()` then threw `d.getFullYear is not a function`. + - **Effect:** the Income view crashed, and `buildFinancialSummary()` threw before the AI request was sent, so "Ask Claude" did nothing. + - **Who was affected:** anyone whose folder had a state file. That's the normal setup once it's been saved, because the file is loaded first at boot. + - **Fix:** `loadStateFromFile()` now rebuilds transactions with `reconstituteTx()` (real `Date` objects, the `category` getter, edits re-applied), the same way `DB.loadAll()` already did. + +### Docs +- **CLAUDE.md §4.5** notes that loaded transactions must be rebuilt, never used as raw JSON. + +--- + ## [1.9.0] — 2026-10-23 ### Settings → 🧹 Data & Reset (new tab, `views-cleanup.js`) diff --git a/CLAUDE.md b/CLAUDE.md index 41331cb..3174806 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -8,7 +8,7 @@ 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.9.0 (updated in `index.html` footer, `README.md`, and `CHANGELOG.md` on every release). +**Current version:** v1.9.1 (updated in `index.html` footer, `README.md`, and `CHANGELOG.md` on every release). **What it does:** Imports CSV exports from Ally Bank (Checking + Savings) and Chase 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. @@ -217,6 +217,7 @@ loadStateFromFile() → found? - Always use `lsSet(key, value)` and `lsGet(key, default)` — **never** call `localStorage` directly. - The `finlens_` prefix is applied automatically by `lsSet`/`lsGet`. - Don't call `saveStateToFile()` directly in hot paths — it's meant to be debounced via `_saveStateDebounced()` in `lsSet()`. +- **Never use transactions straight from JSON.** `JSON.parse` turns `date` into a string and freezes the `category` getter. `loadStateFromFile()` rebuilds them with `reconstituteTx()`, as `DB.loadAll()` does; any new code that reads transactions from JSON must do the same. - **Secrets never reach the file.** `saveStateToFile()` deliberately omits `apiKey`, and `loadStateFromFile()` strips it from files written by ≤v1.7.0 (moving it to browser storage if needed, then scheduling a re-save). Keep both behaviors when changing the serialized field list. --- @@ -722,7 +723,7 @@ Multiple Chase card files can be loaded simultaneously. Each gets a unique `acco --- -*Last updated: v1.9.0 — 2026-10-23 (§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.9.1 — 2026-10-23 (§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 db15b89..ec21541 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.9.0  ·  **Stack:** Vanilla JS, HTML, CSS  ·  **Install:** None +**Version:** v1.9.1  ·  **Stack:** Vanilla JS, HTML, CSS  ·  **Install:** None --- @@ -235,4 +235,4 @@ See [CHANGELOG.md](CHANGELOG.md) for the full release history. --- -*FinLens v1.9.0 — Built for one person's finances, designed to be useful for anyone's.* +*FinLens v1.9.1 — Built for one person's finances, designed to be useful for anyone's.* diff --git a/index.html b/index.html index 0c52e72..c87922e 100644 --- a/index.html +++ b/index.html @@ -323,7 +323,7 @@
⚙️ Settings
diff --git a/js/views-settings.js b/js/views-settings.js index 3411b8a..79d4127 100644 --- a/js/views-settings.js +++ b/js/views-settings.js @@ -49,7 +49,7 @@ function _renderGeneralSettings(root) { -
FinLens v1.9.0 ·${State.transactions.length} transactions loaded${State.lastRefresh?' · Refreshed '+dayjs(State.lastRefresh).format('MMM D, YYYY h:mm A'):''}
`; +
FinLens v1.9.1 ·${State.transactions.length} transactions loaded${State.lastRefresh?' · Refreshed '+dayjs(State.lastRefresh).format('MMM D, YYYY h:mm A'):''}
`; root.appendChild(displayCard); /* ---- Anthropic API Key ---- */