Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

---

## [1.9.5] — 2026-10-25

### Fixed
- **"Canvas is already in use" console errors.** Views draw their charts in `setTimeout(…, 0)`. When a view rendered twice before those timers ran, both batches targeted the same canvas IDs and Chart.js threw for the second. This happened at startup when the folder's CSVs re-imported (`loadFiles()` renders, then `init.js` calls `showView()`), and after Reconnect. The bug was already on `master`.
- **Charts leaked on every render.** Views rebuild their DOM on each render, but the old charts were never destroyed. Chart.js kept every one alive, along with its canvas and data.
- **Fix:** a guard in `ui.js` replaces the global `Chart` with a subclass. Before drawing, it destroys any chart already on that canvas and any chart whose canvas has left the page. No view code changed. Statics such as `Chart.defaults` and `Chart.getChart` still work.

### Docs
- **CLAUDE.md §7** says rule 4 is now enforced by the guard.

---

## [1.9.4] — 2026-10-25

### Fixed
Expand Down
6 changes: 3 additions & 3 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.9.4 (updated in `index.html` footer, `README.md`, and `CHANGELOG.md` on every release).
**Current version:** v1.9.5 (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.

Expand Down Expand Up @@ -341,7 +341,7 @@ These rules exist because Chart.js will cause infinite layout loops if violated.
1. **Always** set `responsive: true, maintainAspectRatio: false`.
2. **Always** wrap `<canvas>` in a `.chart-wrap` div (or `.spark-wrap` for sparklines).
3. **Always** initialize charts inside `setTimeout(() => { new Chart(...) }, 0)` — the canvas must be in the DOM first.
4. **Always** destroy a chart before recreating it on the same canvas — or use a unique canvas ID per render.
4. **Always** destroy a chart before recreating it on the same canvas — or use a unique canvas ID per render. `ui.js` enforces this: `Chart` is a guard subclass that destroys any chart already on the canvas, and any chart whose canvas has left the page, before drawing. Keep it. Without it, two renders in a row throw "Canvas is already in use" and every render leaks its charts.
5. **Never** let a chart container have `height: auto` — always an explicit pixel height.

```js
Expand Down Expand Up @@ -785,7 +785,7 @@ Multiple Chase card files can be loaded simultaneously. Each gets a unique `acco

---

*Last updated: v1.9.4 — 2026-10-25 (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.9.5 — 2026-10-25 (§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)*

---

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.4 &nbsp;·&nbsp; **Stack:** Vanilla JS, HTML, CSS &nbsp;·&nbsp; **Install:** None
**Version:** v1.9.5 &nbsp;·&nbsp; **Stack:** Vanilla JS, HTML, CSS &nbsp;·&nbsp; **Install:** None

---

Expand Down Expand Up @@ -235,4 +235,4 @@ See [CHANGELOG.md](CHANGELOG.md) for the full release history.

---

*FinLens v1.9.4 — Built for one person's finances, designed to be useful for anyone's.*
*FinLens v1.9.5 — Built for one person's finances, designed to be useful for anyone's.*
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@
<div style="margin-top:auto">
<a class="nav" data-view="settings">⚙️ Settings</a>
<div class="footer">
<div style="color:var(--text-3);font-size:11px">v1.9.4 · FinLens</div>
<div style="color:var(--text-3);font-size:11px">v1.9.5 · FinLens</div>
</div>
</div>
</aside>
Expand Down
21 changes: 21 additions & 0 deletions js/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,27 @@ function applyTheme() {
}
}

/* ---------- CHART GUARD (CLAUDE.md §7, rule 4) ---------- */
// Views draw charts in setTimeout(…, 0). When a view renders twice before those timers
// run (loadFiles() then showView() at boot, or Reconnect re-rendering after an import),
// both timers target the same canvas IDs and Chart.js throws "Canvas is already in use"
// for the second. Every `new Chart(...)` goes through this subclass, which destroys a
// chart already on the canvas first. It also destroys charts whose canvas has left the
// page: views rebuild their DOM on every render (§12) and never destroyed the old charts,
// so each render leaked them. Statics (defaults, getChart, register) are inherited.
if (typeof Chart !== 'undefined' && !Chart._finlensGuard) {
const ChartJS = Chart;
Chart = class extends ChartJS {
constructor(item, config) {
for (const c of Object.values(ChartJS.instances)) if (!c.canvas || !c.canvas.isConnected) c.destroy();
const existing = ChartJS.getChart(item);
if (existing) existing.destroy();
super(item, config);
}
};
Chart._finlensGuard = true;
}

/* ---------- CHART PALETTE ---------- */
const CHART_PALETTE = ['#00C49A','#3B82F6','#8B5CF6','#F59E0B','#EF4444','#94A3B8','#F472B6','#FCD34D','#34D399','#7DD3FC','#FB923C','#A78BFA'];
const CHART_DEFAULTS = {
Expand Down
2 changes: 1 addition & 1 deletion js/views-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function _renderGeneralSettings(root) {
</select>
</div>
</div>
<div class="muted" style="font-size:11.5px;margin-top:14px">FinLens v1.9.4 ·${State.transactions.length} transactions loaded${State.lastRefresh?' · Refreshed '+dayjs(State.lastRefresh).format('MMM D, YYYY h:mm A'):''}</div>`;
<div class="muted" style="font-size:11.5px;margin-top:14px">FinLens v1.9.5 ·${State.transactions.length} transactions loaded${State.lastRefresh?' · Refreshed '+dayjs(State.lastRefresh).format('MMM D, YYYY h:mm A'):''}</div>`;
root.appendChild(displayCard);

/* ---- Anthropic API Key ---- */
Expand Down