Skip to content

v1.9.1: fix AI 'does nothing' + Income crash after booting from finlens-state.json - #4

Merged
gitluis merged 4 commits into
masterfrom
fix-state-file-boot-dates
Oct 25, 2026
Merged

gitluis merged 4 commits into
masterfrom
fix-state-file-boot-dates

Conversation

@gitluis

@gitluis gitluis commented Oct 24, 2026

Copy link
Copy Markdown
Owner

Stacked on #3 (← #2 ← #1). Merge in order. Released as v1.9.1.

Summary

Fixes the reported bug: asking Claude a question did nothing. The same root cause also crashed the Income view. It affects anyone whose CSV folder holds a finlens-state.json, which is the normal setup once the file has been saved, because it's the first thing loaded at boot.

Cause

  • Where: loadStateFromFile() returned the file's transactions straight from JSON.parse.
  • What JSON does:
    • Every date becomes a string.
    • The category getter is frozen into a plain value.
  • What breaks: monthKey() then throws d.getFullYear is not a function. That crashes:
    • byMonth(), and with it the Income view.
    • buildFinancialSummary(). It ran before the request and outside the error handling, so the click made no API call and showed nothing.

The bug predates these PRs. On master, booting from the state file has always worked this way. It surfaced once "Save Now" wrote the file.

Fix (173aa4e)

How it was tested

A real finlens-state.json written by the app is loaded in a fresh browser context the way init.js boots: loadStateFromFile() → Object.assign(State, …).

Check Before After
Transactions restored 257, string dates 257, Date objects
category getter frozen value restored
Transaction edits n/a re-applied
buildFinancialSummary() throws works
All 14 views render Income crashes ✅
AI question sent and answered (mocked API) 0 requests ✅

7/7 new checks pass, and all earlier suites still pass: 33, 27, 18 and 5.

After merging

Open FinLens with your real folder and ask Claude a question with your key. Any remaining problem now appears as a message on the page instead of nothing.


Generated by Claude Code

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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AT1Bh6Sscb8ogzzuf8U3Jc
@gitluis gitluis removed their assignment Oct 25, 2026
…te-file-boot-dates

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QoR1wxcaDjVVk3xmd5rRCt
Base automatically changed from data-cleanup-and-reset to master October 25, 2026 03:41
@gitluis

gitluis commented Oct 25, 2026

Copy link
Copy Markdown
Owner Author

Manual test: Edge (InPrivate), sample data only

Branch: fix-state-file-boot-dates (v1.9.1) · Data: sample finlens-state.json built from the 3 CSVs in samples/ (257 transactions, no API key)

Edge drops folder access on every reload (the bug #7 fixes), so a reload never boots from the file. To test the fix, I ran the two startup steps from init.js in the console, right after picking the folder:
const fsState = await loadStateFromFile(); Object.assign(State, fsState);

# Test Expected Result
1 Load finlens-state.json State loaded from finlens-state.json ✅ Pass
2 State.transactions[0].date instanceof Date true (false on master) ✅ Pass
3 Transactions → Income and Spending pills Render, no crash ✅ Pass
4 Trends, Investments, Forecast Render, no crash ✅ Pass
5 buildFinancialSummary() (the step before Ask Claude sends) Returns the summary, no error ✅ Pass

Headless comparison (same file):

  • master: Income, Spending, Trends, Investments, Forecast and the AI summary all throw d.getFullYear is not a function.
  • This branch: all 23 views render and the AI summary builds.

Notes

@gitluis
gitluis merged commit 7d2589b into master Oct 25, 2026
@gitluis
gitluis deleted the fix-state-file-boot-dates branch October 25, 2026 05:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants