diff --git a/CHANGELOG.md b/CHANGELOG.md index d8a3ee8..fca7a8a 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 6f3e5e5..43590cd 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. @@ -218,6 +218,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. --- @@ -725,7 +726,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 c801a72..316b6a6 100644 --- a/index.html +++ b/index.html @@ -324,7 +324,7 @@
⚙️ Settings
diff --git a/js/core.js b/js/core.js index 3923cbe..4251cde 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) { 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 ---- */