From 2da6c3a7645f5a2033837fb830902f1759d1c143 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 24 Oct 2026 02:32:55 +0000 Subject: [PATCH 1/5] Fix two pre-existing crashes: Investments view parse error, detectRecurring ReferenceError - views-invest.js: _renderForecastInvest() closed with '});' instead of '}', so the whole file failed to parse and the Investments tab never registered. - aggregation.js: detectRecurring() pushed {key} but the loop variable is k, throwing whenever a recurring charge was found (Trends insights, AI summary). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01AT1Bh6Sscb8ogzzuf8U3Jc --- js/aggregation.js | 2 +- js/views-invest.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/js/aggregation.js b/js/aggregation.js index ad8f714..8972dde 100644 --- a/js/aggregation.js +++ b/js/aggregation.js @@ -119,7 +119,7 @@ function detectRecurring() { else if (freq==='Quarterly') next.setMonth(next.getMonth()+3); else if (freq==='Annual') next.setFullYear(next.getFullYear()+1); const isSubscription=SUBS_KEYWORDS.some(s=>k.includes(s))||items.some(t=>t.isSubscription); - out.push({key,merchant:items[0].description,avg,freq,confidence,lastSeen:last,nextDue:next,count:items.length,category:items[0].category,isSubscription,account:items[0].account}); + out.push({key:k,merchant:items[0].description,avg,freq,confidence,lastSeen:last,nextDue:next,count:items.length,category:items[0].category,isSubscription,account:items[0].account}); } return out.sort((a,b)=>b.confidence-a.confidence||b.avg-a.avg); } diff --git a/js/views-invest.js b/js/views-invest.js index 566130f..1ba48f3 100644 --- a/js/views-invest.js +++ b/js/views-invest.js @@ -251,7 +251,7 @@ function _renderForecastInvest(root){ root.appendChild(tableCard); setTimeout(runInvestForecast,0); -}); +} const RETURN_PRESETS={conservative:5,moderate:8,aggressive:11}; From 53b16254bafee589613981f59c12e2ae66f3e0ff Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 24 Oct 2026 02:32:56 +0000 Subject: [PATCH 2/5] Restore AI Analysis with API-key and output hardening - Re-add the AI Analysis nav item and views-ai.js script tag (removed in 1.7.0). - Model: claude-sonnet-4-20250514 was retired 2026-06-15; use claude-sonnet-5-5 via a single AI_MODEL constant. - API key: new Settings > General card (password field, value never rendered). saveStateToFile() no longer writes apiKey to finlens-state.json; loadStateFromFile() strips it from older files, moves it to browser storage if needed, and schedules a re-save to scrub the file. - Output: new renderMarkdown() (marked -> DOMPurify, no img/style/forms, escaped-text fallback) replaces every direct marked.parse() call. - Prompt injection: summary sent inside tags with a data-only instruction in the system prompt; responses join all text blocks. - Pin marked@15.0.12 (what the unpinned URL already served) and add DOMPurify@3.4.17, both with SRI. - .gitignore: finlens-state.json, settings exports, saved AI analyses. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01AT1Bh6Sscb8ogzzuf8U3Jc --- .gitignore | 5 +++++ index.html | 8 +++++++- js/core.js | 31 +++++++++++++++++++++++++++++-- js/views-ai.js | 22 ++++++++++++++-------- js/views-db.js | 2 +- js/views-settings.js | 33 ++++++++++++++++++++++++++++++++- 6 files changed, 88 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index 16b0cf0..4f39355 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,11 @@ # Financial data β€” never commit real transaction exports or backups data/ finlens-data.json +# State backup (all transactions + settings) β€” ignored wherever the CSV folder lives +finlens-state.json +# Settings exports and saved AI analyses +finlens-export-*.json +finlens-analysis-*.md # macOS .DS_Store diff --git a/index.html b/index.html index 0f56f5b..f8945d1 100644 --- a/index.html +++ b/index.html @@ -12,7 +12,11 @@ - + + +