From 8c953aa1eba0c9d11fc018a81653e2bd2cd6fbbc Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 2 Nov 2026 13:20:51 +0000 Subject: [PATCH 1/2] v1.17.0: backup status in the sidebar; save before leaving MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Sidebar status for finlens-state.json: Saving…, Saved h:mm, Backups paused (Reconnect), Backup failed (Retry), Backups off. - beforeunload flushes a waiting save and asks the browser to confirm while a save is waiting or running and the folder is writable. - Tab hidden flushes a waiting save immediately. - Save delay 5 s -> 1.5 s; a manual save cancels a waiting one. - CLAUDE.md §4.5/§8, README, Import tab text, CHANGELOG, version v1.17.0. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013Z8iBYnr2QiFrzchNxfCti --- CHANGELOG.md | 16 ++++++++++ CLAUDE.md | 16 +++++++--- README.md | 6 ++-- index.html | 15 ++++++++- js/core.js | 73 +++++++++++++++++++++++++++++++++++++++++--- js/views-data.js | 46 +++++++++++++++++++++++++++- js/views-settings.js | 2 +- 7 files changed, 160 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a41488d..61e0b28 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,22 @@ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). --- +## [1.17.0] — 2026-11-02 + +### Sidebar +- **Backup status in the sidebar.** Above the version line, a small status shows whether `finlens-state.json` is up to date: **Saving…** while a write is waiting or running, **Saved 10:42 AM** once it's done (hover for the exact time and folder), **Backups paused · Reconnect** when folder access has lapsed, **Backup failed · Retry** when a write fails, and **Backups off** with no folder connected. Paused and failed are buttons that run Reconnect or Save Now, since only a click can ask for folder access (`updateSaveStatus()` in `views-data.js`). + +### Persistence +- **Leaving with a save still waiting now asks first.** Saves to `finlens-state.json` wait for a pause in your edits, so closing the tab right after a change could leave the backup behind. When a save is waiting or running and the folder is writable, closing or reloading starts the save at once and the browser asks "Leave site?". Browsers show their own text and ignore custom messages, and only ask after you've clicked or typed on the page. No folder, paused backups and Start over never ask. +- **Switching away saves right away.** When the tab is hidden (another tab, minimized), a waiting save runs immediately instead of waiting out the delay. +- **Saves wait 1.5 seconds instead of 5.** Each change still restarts the wait, so a burst of edits makes one write. Your data reaches the browser's own storage immediately either way; only the backup file waits. +- **Save Now covers a waiting save.** A manual save cancels the scheduled one, since it writes everything as it is at that moment. + +### Docs +- **CLAUDE.md §4.5** — 1.5 s save delay, save status, flush and leave warning; **§8** — new save helpers. README and the Import tab no longer say "every 5 seconds". + +--- + ## [1.10.5] — 2026-11-02 ### Fixed diff --git a/CLAUDE.md b/CLAUDE.md index d895c1b..1ffb231 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -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.10.5 (updated in `index.html` footer, `README.md`, and `CHANGELOG.md` on every release). +**Current version:** v1.17.0 (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. @@ -267,7 +267,12 @@ loadStateFromFile() → found? **Key principles:** - **Filesystem is the source of truth** — `finlens-state.json` contains the authoritative copy of all state. -- **Debounced writes** — Every 5 seconds (or on last mutation), `lsSet()` triggers `_saveStateDebounced()` which calls `saveStateToFile(State)`. This avoids excessive file I/O. +- **Delayed writes (v1.17.0)** — `lsSet()` calls `_saveStateDebounced()`, which writes the file `SAVE_DELAY_MS` (1.5 s) after the last change; each new change restarts the wait, so a burst of edits makes one write. Changes reach localStorage and IndexedDB at once; only the file waits. +- **Save status and leaving the page (v1.17.0)** — the scheduler tracks `State._savePending` (a write is waiting) and `saveStateToFile()` tracks `State._saving` (a write is running). Both call `updateSaveStatus()` (`views-data.js`), which drives the sidebar's `#saveStatus`: *Backups off* (no folder), *Backups paused · Reconnect* (access lapsed; a button to `reconnectFolderClick()`), *Saving…*, *Backup failed · Retry* (a button to `saveNowClick()`), *Saved h:mm A*, or *Backups on*. + - **Tab hidden:** `visibilitychange` → `flushPendingSave()` writes right away. + - **Closing or reloading:** `beforeunload` flushes too, and asks the browser to confirm when `backupWouldBeLost()`: a save is waiting or running, a folder handle exists (`hasBackupFolder()`), access hasn't lapsed and no Start over is in progress. Browsers show their own generic "Leave site?" text, ignore custom messages, and only ask after the user has clicked or typed on the page. + - **A manual save supersedes a waiting one:** `saveStateToFile()` cancels the timer, since it serializes State as it is at that moment. + - **`State._noBackupFolder`** is set whenever `loadStateFromFile()` or `saveStateToFile()` finds no stored handle (files picked with the old folder input set a folder name but no handle), and cleared by `pickDataFolder()`. - **Survives browser cache clearing** — If the browser clears IndexedDB/localStorage, the filesystem file remains on disk and will be restored on the next page load. - **Fallback chain** — If filesystem load fails, IndexedDB provides a session-local cache. If IndexedDB isn't available, localStorage defaults apply. - Always use `lsSet(key, value)` and `lsGet(key, default)` — **never** call `localStorage` directly. @@ -388,7 +393,10 @@ lsGet(key, default) // Read from localStorage (auto-prefixed) lsSet(key, value) // Write to localStorage + mirror to IndexedDB app_state + auto-save to filesystem (debounced) loadStateFromFile() // Read finlens-state.json from backup folder; returns loaded state or null if not found saveStateToFile(state) // Write state to finlens-state.json in backup folder (fire-and-forget async) -_saveStateDebounced() // Debounced wrapper (5s) — called by lsSet() +_saveStateDebounced() // Schedules a save SAVE_DELAY_MS (1.5s) after the last change — called by lsSet() +flushPendingSave() // Runs a waiting save now (tab hidden, page closing); null if none waiting +backupWouldBeLost() // True while a save is waiting/running and the folder is writable (beforeunload) +hasBackupFolder() // A folder handle is stored (access may have lapsed) // Data (core.js) filteredTx() // State.transactions filtered by active range + selected accounts @@ -798,7 +806,7 @@ Multiple Chase card files can be loaded simultaneously. Each gets a unique `acco --- -*Last updated: v1.10.5 — 2026-11-02 (no section changes: Import Logs race fix; v1.10.4: §8, §13 single `~` is literal; §21 excerpts escape `~`; v1.10.3: §13 refusals; §21 declined runs; v1.10.2: §13 summary states its dates; §21 per-month derivations; v1.10.1: §13 `AI_MAX_TOKENS`, thinking and cut-off answers; v1.10.0: §21 AI Eval added; §13 `callClaude()` raw mode; v1.9.6: §14 folder access lasts until the last tab closes, not one page load; v1.9.5: §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)* +*Last updated: v1.17.0 — 2026-11-02 (§4.5 1.5 s save delay, save status, flush and leave warning; §8 new save helpers; v1.10.5: no section changes: Import Logs race fix; v1.10.4: §8, §13 single `~` is literal; §21 excerpts escape `~`; v1.10.3: §13 refusals; §21 declined runs; v1.10.2: §13 summary states its dates; §21 per-month derivations; v1.10.1: §13 `AI_MAX_TOKENS`, thinking and cut-off answers; v1.10.0: §21 AI Eval added; §13 `callClaude()` raw mode; v1.9.6: §14 folder access lasts until the last tab closes, not one page load; v1.9.5: §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)* --- diff --git a/README.md b/README.md index 1cd3fc5..c83b34d 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.10.5  ·  **Stack:** Vanilla JS, HTML, CSS  ·  **Install:** None +**Version:** v1.17.0  ·  **Stack:** Vanilla JS, HTML, CSS  ·  **Install:** None --- @@ -87,7 +87,7 @@ FinLens stores all your data — budgets, bills, transaction edits, settings, AI **How it works:** 1. When you pick a CSV folder in the **Data** tab, FinLens begins auto-saving your complete state to `finlens-state.json` in that same folder. -2. Every 5 seconds (when you make changes), your dashboard state is written to this file. You can also click **Save Now** to force an immediate sync. +2. A moment after each change (1.5 seconds), your dashboard state is written to this file. The sidebar shows the backup status (**Saving…**, **Saved 10:42 AM**, or **Backups paused**), and if you try to close the tab while a save is still waiting, the browser asks first. You can also click **Save Now** to force an immediate sync. 3. On every page load, FinLens checks for `finlens-state.json` first — if it exists, your entire state (budgets, categories, overrides, settings, AI history) is restored instantly. If the file doesn't exist, it falls back to the browser's IndexedDB or localStorage. 4. Because the file lives on your computer (not in the browser), **it survives browser cache clearing**. Even if you clear all browser data, your `finlens-state.json` remains on your disk and will be restored on the next load. @@ -260,4 +260,4 @@ See [CHANGELOG.md](CHANGELOG.md) for the full release history. --- -*FinLens v1.10.5 — Built for one person's finances, designed to be useful for anyone's.* +*FinLens v1.17.0 — Built for one person's finances, designed to be useful for anyone's.* diff --git a/index.html b/index.html index ee48405..93bed0f 100644 --- a/index.html +++ b/index.html @@ -26,6 +26,7 @@ --sidebar-2:#16263d; --sidebar-text:#cbd5e1; --sidebar-text-active:#ffffff; + --sidebar-bad:#F87171; /* red text on --sidebar (6:1); --red is only 4.1:1 there */ --sidebar-muted:#94A3B8; /* group headers, brand subtitle, footer — 6.7:1 on --sidebar */ --bg:#F7F8FA; --surface:#FFFFFF; @@ -99,6 +100,17 @@ .nav-section{overflow:hidden;transition:max-height .25s ease,opacity .2s ease;max-height:600px;opacity:1} .nav-section.collapsed{max-height:0;opacity:0} .sidebar .footer{margin-top:auto;padding:10px;font-size:11px;color:var(--sidebar-muted);border-top:1px solid rgba(255,255,255,.06)} +/* sidebar backup status (updateSaveStatus in views-data.js) */ +.save-status{display:flex;align-items:center;gap:6px;margin-bottom:6px;font-size:11.5px;color:var(--sidebar-muted)} +.save-status .dot{width:7px;height:7px;border-radius:50%;flex:0 0 auto;background:currentColor} +.save-status.ok .dot{background:var(--teal)} +.save-status.busy .dot{background:var(--teal);animation:save-pulse 1s ease-in-out infinite} +.save-status.warn{color:var(--amber)} +.save-status.bad{color:var(--sidebar-bad)} +.save-status-btn{all:unset;display:inline-flex;align-items:center;gap:6px;cursor:pointer;text-decoration:underline;text-underline-offset:2px} +.save-status-btn:focus-visible{outline:2px solid var(--teal);outline-offset:2px;border-radius:4px} +@keyframes save-pulse{50%{opacity:.3}} +@media (prefers-reduced-motion:reduce){.save-status.busy .dot{animation:none}} .main{display:flex;flex-direction:column;min-width:0} .topbar{ @@ -326,7 +338,8 @@
⚙️ Settings
diff --git a/js/core.js b/js/core.js index f000db0..ca30d28 100644 --- a/js/core.js +++ b/js/core.js @@ -114,6 +114,7 @@ async function folderPermission(dir, mode) { async function loadStateFromFile() { try { const dirHandle = await idbGet('csvDirHandle'); + State._noBackupFolder = !dirHandle; if (!dirHandle) { console.log('[FinLens] No backup folder selected; skipping file load'); return null; @@ -162,9 +163,15 @@ async function saveStateToFile(state) { // "Start over" sets this so a pending debounced save can't re-create the file // between the reset and the page reload. if (State._resetInProgress) return false; + // This write serializes State as it is now, so it covers any save still waiting. + _cancelScheduledSave(); State._lastSaveError = ''; + State._saving = true; + _notifySaveStatus(); try { const dirHandle = await idbGet('csvDirHandle'); + // Files picked with the old folder input set a folder name but no handle. + State._noBackupFolder = !dirHandle; if (!dirHandle) { console.log('[FinLens] No backup folder selected; state not saved to file'); return false; @@ -221,13 +228,71 @@ async function saveStateToFile(state) { State._lastSaveError = e.message; console.warn('[FinLens] Failed to save state to file:', e.message); return false; + } finally { + State._saving = false; + _notifySaveStatus(); } } -// Debounced state file save (max 1 save per 5 seconds) -const _saveStateDebounced = debounce(async (state) => { - await saveStateToFile(state); -}, 5000); +/* ---------- Scheduled saves + leaving the page (v1.17.0) ---------- */ +// lsSet() schedules a write of finlens-state.json SAVE_DELAY_MS after the last change, +// so a burst of edits makes one write. Each new change restarts the wait. Changes reach +// localStorage and IndexedDB at once; only the backup file waits. +const SAVE_DELAY_MS = 1500; +let _saveTimer = null; + +function _saveStateDebounced(state) { + if (State._resetInProgress) return; + clearTimeout(_saveTimer); + State._savePending = true; + _saveTimer = setTimeout(() => { _saveTimer = null; saveStateToFile(state); }, SAVE_DELAY_MS); + _notifySaveStatus(); +} + +function _cancelScheduledSave() { + clearTimeout(_saveTimer); + _saveTimer = null; + State._savePending = false; +} + +// Start a waiting save right away (tab hidden, page closing). Returns the save's promise, +// or null when nothing was waiting. +function flushPendingSave() { + if (!_saveTimer) return null; + return saveStateToFile(State); +} + +// True when leaving now could leave finlens-state.json behind the browser copy: a save +// is waiting or still writing, and the folder can be written to. With no folder, or +// access lapsed (the banner already says backups are paused), there's nothing to wait for. +function backupWouldBeLost() { + if (State._resetInProgress) return false; + if (!State._savePending && !State._saving) return false; + return hasBackupFolder() && !State._folderNeedsAccess; +} + +// A folder FinLens can save finlens-state.json to is connected (its access may have lapsed). +function hasBackupFolder() { + return !!State.lastFolderName && !State._noBackupFolder; +} + +function _notifySaveStatus() { + if (typeof updateSaveStatus === 'function') updateSaveStatus(); +} + +// Leaving or switching away: write now instead of waiting out the delay. A hidden tab +// usually keeps running long enough to finish; a closing one may not, so beforeunload +// also asks the browser to confirm. Browsers show their own generic "Leave site?" +// text and ignore custom messages, and only ask if the page had a click or keypress. +document.addEventListener('visibilitychange', () => { + if (document.visibilityState === 'hidden') flushPendingSave(); +}); +window.addEventListener('beforeunload', (e) => { + if (!backupWouldBeLost()) return; + flushPendingSave(); + e.preventDefault(); + e.returnValue = ''; +}); /* ---------- Folder + state-file maintenance (Settings → Data & Reset) ---------- */ // Browsers only show a file-permission prompt during a user gesture, so the diff --git a/js/views-data.js b/js/views-data.js index d9947f9..11d9f2f 100644 --- a/js/views-data.js +++ b/js/views-data.js @@ -52,7 +52,7 @@ registerView('import','Import',(root)=>{ const saveMsg=_saveNowMsg; _saveNowMsg=null; // shown once, after the click that produced it backupCard.innerHTML=`

📦 Auto-Backup to Disk

-

Your dashboard state is automatically saved to finlens-state.json in your folder every 5 seconds (when you make changes). This survives browser cache clearing.

+

Your dashboard state is automatically saved to finlens-state.json in your folder a moment after each change (the sidebar shows when it was last saved). This survives browser cache clearing.

${hasBackupFolder ? `
${paused?'⚠ Backup paused — FinLens needs permission to write to this folder again':'✓ Backup enabled'}
@@ -361,6 +361,7 @@ async function pickDataFolder() { // readwrite: the same folder holds finlens-state.json, which FinLens writes to. const handle = await window.showDirectoryPicker({ mode:'readwrite', startIn:'documents' }); await idbSet('csvDirHandle', handle); + State._noBackupFolder = false; State.lastFolderName = handle.name; State._folderNeedsAccess = false; State._csvNeedsReconnect = false; @@ -503,6 +504,7 @@ async function saveNowClick() { // The banner above every view (#folderBanner in index.html). Shown while access to // the stored folder has lapsed, and briefly after a Reconnect click with its result. function updateFolderBanner() { + updateSaveStatus(); // the sidebar status reads the same folder state const el = $('#folderBanner'); if (!el) return; const msg = _folderBannerMsg; @@ -525,6 +527,48 @@ function updateFolderBanner() { if (cb) cb.onclick = () => { _folderBannerMsg = null; updateFolderBanner(); }; } +// Sidebar backup status (#saveStatus in index.html, v1.17.0): shows whether +// finlens-state.json is up to date, so it's clear when it's safe to close the tab. +// Called whenever save or folder state changes (saveStateToFile(), the save +// scheduler, updateFolderBanner()). Paused or failed backups make it a button that +// runs the same click handler as the banner or Save Now, since only a click can ask +// for folder access. +function updateSaveStatus() { + const el = $('#saveStatus'); + if (!el) return; + const folder = State.lastFolderName; + const savedAt = State.lastFsyncTime ? dayjs(State.lastFsyncTime) : null; + let kind, text, title, action = null; + if (State._resetInProgress) { + el.hidden = true; return; + } else if (!hasBackupFolder()) { + kind = 'off'; text = 'Backups off'; + title = 'No folder is connected, so nothing is saved to finlens-state.json. Your data is kept in this browser. Connect a folder in Settings → Import.'; + } else if (State._folderNeedsAccess) { + kind = 'warn'; text = 'Backups paused · Reconnect'; action = reconnectFolderClick; + title = `FinLens needs permission again to write to “${folder}”. Your data is safe in this browser. Click to reconnect.`; + } else if (State._saving || State._savePending) { + kind = 'busy'; text = 'Saving…'; + title = `Saving to finlens-state.json in “${folder}”.`; + } else if (State._lastSaveError) { + kind = 'bad'; text = 'Backup failed · Retry'; action = saveNowClick; + title = `The last save to “${folder}” failed: ${State._lastSaveError}. Your data is safe in this browser. Click to try again.`; + } else if (savedAt) { + kind = 'ok'; text = `Saved ${savedAt.format('h:mm A')}`; + title = `finlens-state.json in “${folder}” was last saved ${savedAt.format('MMM D, h:mm:ss A')}.`; + } else { + kind = 'ok'; text = 'Backups on'; + title = `Changes are saved to finlens-state.json in “${folder}”.`; + } + el.hidden = false; + el.className = 'save-status ' + kind; + el.title = title; + el.innerHTML = action + ? `` + : `${escapeHtml(text)}`; + if (action) el.querySelector('button').onclick = action; +} + function addManualAccount() { const name=$('#newAcctName').value.trim(); const kind=$('#newAcctKind').value; diff --git a/js/views-settings.js b/js/views-settings.js index 6f7d389..ab4f626 100644 --- a/js/views-settings.js +++ b/js/views-settings.js @@ -49,7 +49,7 @@ function _renderGeneralSettings(root) {
-
FinLens v1.10.5 ·${State.transactions.length} transactions loaded${State.lastRefresh?' · Refreshed '+dayjs(State.lastRefresh).format('MMM D, YYYY h:mm A'):''}
`; +
FinLens v1.17.0 ·${State.transactions.length} transactions loaded${State.lastRefresh?' · Refreshed '+dayjs(State.lastRefresh).format('MMM D, YYYY h:mm A'):''}
`; root.appendChild(displayCard); /* ---- Anthropic API Key ---- */ From 60c9c7cb295c5e810f988f77792e293d0cd29ba0 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 2 Nov 2026 15:25:23 +0000 Subject: [PATCH 2/2] v1.18.0: backup status in the sync badge; save before leaving MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rebuilds PR #23 on the Clarity app bar. #23 put a backup status line in the old sidebar, which the redesign removed; this folds it into the sync badge and keeps Luis's resting wording. - Badge: "Synced" (tooltip "Saved at 10:42 AM to finlens-state.json in ..."), "Saving..." while a save waits or runs (neutral pill, pulsing dot, same width as Synced), "Not synced" for no folder, access lapsed or a failed save. The tooltip gives the cause; the click opens Settings -> Import, reconnects, or retries the save (syncRetryClick). syncBadgeState() picks label, tooltip, accessible name and action in one place. - Accessibility: the button's name starts with the label and ends with its action; a polite status region (#syncStatus) announces only when backups stop or come back, never "Saving...". - Saves wait 1.5 s instead of 5 s (SAVE_DELAY_MS); a manual save cancels a waiting one; tab hidden flushes a waiting save. - beforeunload: attached only while a save is waiting or running and the folder is connected and writable; flushes and asks the browser to confirm. The listener stays attached until the prompt is answered, since removing it during the event cancels the prompt. - Start over (State._resetInProgress) cancels a waiting save and writes nothing. _folderNeedsAccess, the Reconnect banner, _lastSaveError and the permission checks are unchanged. #23's _noBackupFolder/hasBackupFolder() are replaced by the redesign's State._folderLinked. - Import tab: "1.5 seconds after a change". README, CLAUDE.md (§1, §4.5, §6, §8, §9, §12, §14, Last updated), CHANGELOG; version v1.18.0. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013Z8iBXzUjiQbYziDZ8CZft --- CHANGELOG.md | 30 +++++++++++ CLAUDE.md | 40 +++++++++++---- README.md | 8 +-- index.html | 16 ++++-- js/core.js | 103 +++++++++++++++++++++++++++++++++---- js/views-data.js | 117 ++++++++++++++++++++++++++++++++----------- js/views-settings.js | 2 +- 7 files changed, 262 insertions(+), 54 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b21d59e..579b8a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,36 @@ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). --- +## [1.18.0] — 2026-11-02 + +### App bar: backup status in the sync badge +The sync badge now tells you whether `finlens-state.json` is up to date, not only whether a folder is connected. This is PR #23 rebuilt on the Clarity redesign: #23 put the status in the old sidebar, which the redesign removed, and its v1.17.0 number was never released. + +- **Synced** — the last save worked and nothing is waiting. The tooltip gives the time and folder ("Saved at 10:42 AM to finlens-state.json in “FinLens Data”"). Click: opens **Settings → Import**. +- **Saving…** — new. Shows from a change until it's written: the 1.5 s wait, then the write. The pill turns neutral with a slowly pulsing dot (steady with reduced motion). It stays the same width as **Synced**, and a burst of edits keeps it on **Saving…** rather than flickering. Click: opens **Settings → Import**. +- **Not synced** — the existing label, now for three causes. The tooltip says which: + - **No folder:** changes are saved in this browser only. Click: opens **Settings → Import** to pick one. + - **Access lapsed:** the browser needs permission again. Click: **Reconnect** (asks for access), as the banner's button does. + - **The last save failed:** the tooltip gives the error. Click: **Retry**, which saves right away (`syncRetryClick()`). Before, this click only opened Settings. +- **Screen readers:** the button's name starts with the label and ends with what a click does ("Not synced, folder access lapsed. Reconnect folder"). A polite status region (`#syncStatus`) announces when backups stop or come back. It never announces **Saving…**, or **Synced** after an ordinary save. +- **How it's built:** `syncBadgeState()` (views-data.js) picks the state, label, tooltip, name and click in one place; `updateSyncBadge()` draws it and `syncBadgeClick()` runs its action, so the click always matches what the badge says. New `.sync.busy` style; colors are tokens, AA in both themes. + +### Persistence +- **Saves wait 1.5 seconds instead of 5.** Each change still restarts the wait, so a burst of edits makes one write. Your data reaches the browser's own storage at once either way; only the backup file waits (`SAVE_DELAY_MS`, `_saveStateDebounced()` in core.js). +- **Closing or reloading with a save still waiting asks first.** While a save is waiting or running and the folder is connected and writable, a `beforeunload` listener starts the save at once and asks the browser to confirm ("Leave site?"). The listener is attached only during that time (`backupWouldBeLost()`), so a page with nothing to save never has one. No folder, lapsed access and Start over never ask. Browsers show their own text and ask only after you've clicked or typed on the page. +- **Switching away saves right away.** When the tab is hidden (another tab, minimized), a waiting save runs immediately (`flushPendingSave()`). +- **Save now covers a waiting save.** Any immediate save cancels the scheduled one, since it writes everything as it is at that moment. +- **Kept as they were:** the Reconnect banner, `State._folderNeedsAccess`, `State._lastSaveError`, the folder-permission checks, and `State._resetInProgress`, which now also cancels a waiting save, so Start over can't re-create the file. + +### Settings → Import +- **Auto-save** reads "1.5 seconds after a change". + +### Docs +- **README:** the badge's states and clicks; saves 1.5 s after a change, on switching tabs, and the leave warning. +- **CLAUDE.md:** §1 version; §4.5 the save delay, save state, flush and leave warning; §6 the badge classes; §8 `flushPendingSave()`, `backupWouldBeLost()`; §9 the badge states; §12 the app bar; §14 the badge's clicks are the only new prompting code. + +--- + ## [1.17.0] — 2026-11-02 ### Settings → Database diff --git a/CLAUDE.md b/CLAUDE.md index 4fac8cd..6f92644 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -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.17.0 (updated in `index.html` footer, `README.md`, and `CHANGELOG.md` on every release). +**Current version:** v1.18.0 (updated in `index.html` footer, `README.md`, and `CHANGELOG.md` on every release). **What it does:** Imports CSV exports from a bank (checking + savings) and 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. @@ -337,7 +337,12 @@ loadStateFromFile() → found? **Key principles:** - **Filesystem is the source of truth** — `finlens-state.json` contains the authoritative copy of all state. -- **Debounced writes** — Every 5 seconds (or on last mutation), `lsSet()` triggers `_saveStateDebounced()` which calls `saveStateToFile(State)`. This avoids excessive file I/O. +- **Delayed writes (v1.18.0)** — `lsSet()` calls `_saveStateDebounced()`, which writes the file `SAVE_DELAY_MS` (1.5 s) after the last change. Each new change restarts the wait, so a burst of edits makes one write. Changes reach localStorage and IndexedDB at once; only the file waits. Up to v1.17.0 the wait was 5 s. +- **Save state (v1.18.0)** — `State._savePending` is true while a write waits, `State._saving` while one runs (a count underneath, since a manual save can overlap the scheduled one). Neither is saved anywhere. Every change to them, and every folder change through `updateFolderBanner()`, goes through `_notifySaveStatus()`: it updates the leave warning, then the sync badge (`updateSyncBadge()`, §9). + - **A manual save covers a waiting one:** `saveStateToFile()` cancels the timer, since it serializes State as it is when it gets there. + - **Tab hidden:** `visibilitychange` → `flushPendingSave()` writes a waiting save right away. + - **Closing or reloading:** a `beforeunload` listener is attached only while `backupWouldBeLost()`: a save is waiting or running, a folder is connected (`State._folderLinked`), its access hasn't lapsed (`State._folderNeedsAccess`) and no Start over is in progress (`State._resetInProgress`). It flushes the save and asks the browser to confirm. Browsers show their own "Leave site?" text, ignore custom messages, and only ask after a click or keypress on the page. Don't attach an always-on `beforeunload` listener: it can keep the page out of the back/forward cache. **Don't remove it while its event is running**, either: a fast write can finish in the event's microtasks, and removing the listener then cancels the prompt (Chromium 153). `_leaveGuardHold` keeps it attached until the prompt is answered. + - **Start over:** while `State._resetInProgress` is set, `_saveStateDebounced()` and `saveStateToFile()` cancel any waiting save and write nothing, and the leave warning never shows. - **Survives browser cache clearing** — If the browser clears IndexedDB/localStorage, the filesystem file remains on disk and will be restored on the next page load. - **Fallback chain** — If filesystem load fails, IndexedDB provides a session-local cache. If IndexedDB isn't available, localStorage defaults apply. - Always use `lsSet(key, value)` and `lsGet(key, default)` — **never** call `localStorage` directly. @@ -483,6 +488,13 @@ body[data-view="settings"], body.first-run — Settings and the Welcome are 1000 .sch-scroll .sch-hint .sch-legend .key-badge(.pk) .sch-opt — the diagram's scroll box, its phone note and legend ``` +**Sync badge (v1.18.0)** — the app bar's `#syncBadge` (§9): + +``` +.sync(.ok/.busy/.off) .sdot — Synced (good tints) / Saving… (--muted, --text-2, a pulsing --accent dot, steady under prefers-reduced-motion) / Not synced (warn tints) + min-width keeps Synced and Saving… the same width, so the pill doesn't jump on every save +``` + Prefer these over inline styles. Keep touch targets ≥ 44px where feasible (`@media (pointer:coarse)` raises pills and remove buttons). --- @@ -540,7 +552,9 @@ lsSet(key, value) // Write to localStorage + mirror to IndexedDB app_st storageKey(stateKey) // The lsSet/lsGet key for a State key: 'recurring', 'catRules', else the State name (STORAGE_KEYS, §4.5) loadStateFromFile() // Read finlens-state.json from backup folder; returns loaded state or null if not found saveStateToFile(state) // Write state to finlens-state.json in backup folder (fire-and-forget async) -_saveStateDebounced() // Debounced wrapper (5s) — called by lsSet() +_saveStateDebounced() // Schedules a save SAVE_DELAY_MS (1.5 s) after the last change — called by lsSet() (v1.18.0) +flushPendingSave() // Runs a waiting save now (tab hidden, page closing); null if none was waiting +backupWouldBeLost() // A save is waiting or running and the folder is connected and writable: the leave warning's test // Data (core.js) filteredTx() // State.transactions filtered by active range + selected accounts @@ -656,8 +670,16 @@ TX_VIEWS // transactions + its pill screens; the Tra toggleAppBarPopup(btn, panel) // Open/close the Plan menu, a filter popover or the ☰ menu (☰ shows × and "Close menu" while open) closeAppBarPopups(focusBtn?) // Close whatever is open (Escape returns focus to its button) updateRangeUI(), updateAcctUI() // Sync the date / accounts popovers, their dots and tooltips -updateSyncBadge() // (views-data.js) "Synced" / "Not synced" from State._folderLinked, - // _folderNeedsAccess and _lastSaveError; called on every render and save +updateSyncBadge() // (views-data.js) the app bar's badge from syncBadgeState(); called on every render, + // save-state change and folder change. States (v1.18.0), in this order: + // no folder (!_folderLinked) → "Not synced", click opens Settings → Import; + // access lapsed (_folderNeedsAccess) → "Not synced", click Reconnect; + // _saving / _savePending → "Saving…" (.sync.busy), click opens Settings → Import; + // _lastSaveError → "Not synced", click Retry (syncRetryClick(): save now); + // otherwise "Synced", tooltip "Saved at 10:42 AM to …", click opens Settings → Import. + // The tooltip (title) gives the reason; aria-label starts with the label and ends with + // the click's action. #syncStatus (role="status") announces only when backups stop or + // come back, never "Saving…". syncBadgeClick() runs the action syncBadgeState() names // Chart CHART_PALETTE // 12-color array, use for multi-series charts @@ -855,7 +877,7 @@ Gear → Settings, with tabs: General · Import · Accounts · Credit cards · C Database has sub-tabs: DB Inspector · DB Schema) ``` -- **Right side:** the sync badge, then the date-range and accounts icon buttons (each opens a popover), then the Settings gear. There is no theme button. +- **Right side:** the sync badge (Synced · Saving… · Not synced, §9), then the date-range and accounts icon buttons (each opens a popover), then the Settings gear. There is no theme button. - **Below 1000px** the nav moves into the **☰** menu (`#mobileMenu`), with the same grouping. **Below 720px** the gear moves into it too. - **Links** are ``; `init.js` wires every `.appbar [data-view]`, and `showView()` marks the current one (`.active` + `aria-current`). @@ -943,9 +965,9 @@ The handle lives in a separate `finlens_fs` database (distinct from `finlens_db` ### Folder permission (v1.9.3) - **It lasts until the last FinLens tab closes, not one page load** (Chromium: Edge, Chrome). A reload keeps access; closing the browser drops it, and a stored handle's permission goes back to `prompt` (confirmed in Edge, v1.9.6). Chromium can also revoke it after a tab sits in the background for a while, and since Chrome 122 the prompt can offer **Allow on every visit**, which keeps access until the user revokes it. Only a click can ask again — `requestPermission()` throws without user activation. Don't rely on any of these: check permission every time (next bullet). -- **Check before touching files.** `loadStateFromFile()` and `saveStateToFile()` call `folderPermission(dir, mode)` (wraps `queryPermission`, never prompts) and skip quietly instead of throwing `NotAllowedError`. When access is missing they set `State._folderNeedsAccess`, which shows the **Reconnect folder** banner (`#folderBanner`, `updateFolderBanner()` in `views-data.js`). A successful save clears it. +- **Check before touching files.** `loadStateFromFile()` and `saveStateToFile()` call `folderPermission(dir, mode)` (wraps `queryPermission`, never prompts) and skip quietly instead of throwing `NotAllowedError`. When access is missing they set `State._folderNeedsAccess`, which shows the **Reconnect folder** banner (`#folderBanner`, `updateFolderBanner()` in `views-data.js`) and makes the sync badge "Not synced" with Reconnect as its click. A successful save clears it. - **Always ask for `readwrite`**, not `read`: the folder picker, Reload and Reconnect all do, because the same folder holds `finlens-state.json`. -- **Prompting code runs only in click handlers:** `saveNowClick()`, `reconnectFolderClick()`, `reloadDataFiles()`, and the Data & Reset actions via `folderWithWriteAccess()` / `saveStateNow()`. +- **Prompting code runs only in click handlers:** `saveNowClick()`, `reconnectFolderClick()`, `reloadDataFiles()`, the sync badge's `syncBadgeClick()` (Reconnect, or Retry through `syncRetryClick()` → `saveStateNow()`), and the Data & Reset actions via `folderWithWriteAccess()` / `saveStateNow()`. The tab-hidden and page-closing flushes (§4.5) only call `saveStateToFile()`, which never prompts. - **After reconnecting, the browser copy wins** (Luis's decision, 2026-10-24): `reconnectDataFolder()` writes the browser's state to the file and does not load the file over it. **Exception:** a browser with no transactions (new browser, cleared site data) restores from the file instead (`_restoreStateIfBrowserEmpty()`), so an empty state never overwrites the only backup. Picking a folder follows the same rule. --- @@ -1059,7 +1081,7 @@ Multiple credit card files can be loaded simultaneously. Each gets a unique `acc --- -*Last updated: v1.17.0 — 2026-11-02 (Settings → Database tab, DB Inspector and DB Schema rebuilt on Clarity: §1 version; §3 views-db.js role; §6 Database classes; §12 seventh Settings tab, its sub-tabs, the hidden-tab guard, the tab bar scrolling to the selected tab, view registrations; §19 database views; v1.16.15: §1 desktop only; §3 `views-database.js` removed, the Changelog view reads CHANGELOG.md; §6, §18, §19 point to the current screens; v1.16.14: §9 the drawer is a modal dialog: inert page, Tab wraps, first field focused, focus returns after a re-render; v1.16.13: account order: §4.1 `accountOrder` keeps ids not loaded; §8 `orderedAccounts()`; §18 display order; v1.16.12: account names: §4.1 `accountLabels`; §4.3 an account's `name` is its default; §8 `defaultAccountName()`; §9 `acctName()`; §13 the summary lists accounts by `acctName()`; §18 names you type, and clearing them; v1.16.11: AI summary balances at the end of the selected period: §13 `summaryBalanceEnd()` and the date notes; §21 the parser reads the balance lines by how they start; v1.16.10: starting balance counted in every range: §8 `startingBalance()`, `currentBalances()`; §13 summary balances; §18 one balance rule; v1.16.9: the transaction drawer stores only the flags you change: §4.2 flags, §12 state mutations; v1.16.8: flags from transaction rules are worked out on load, never read from storage: §4.2 flags, §8 `txRuleFlag()` / `txFlags()` / `applyTxRulesToAll()`, §19 flags in the transactions store; v1.16.7: transaction links to budgets, buckets and debts by id: §1 version; §3 migrate.js role; §4.1 the `id` fields, TxOverride and its `link` shape; §8 `PLAN_LINK_TYPES`, `newPlanId()`; §9 `planItem()`, `linkedTransactions()`, `unlinkPlanItems()`, `ensurePlanIds()`; §20 clearing budgets, buckets or debts removes their links; §22 the plan-link migration; v1.16.6: JSON export carries account names and order, Read as, flag rules, transfer keywords and theme: §9 `JSON_EXPORT_KEYS`; §12 adding a persisted field; §20 what the export holds; v1.16.5: a new database copies every saved setting: §4.5 the keys that go through `storageKey()`; §12 adding a persisted field; §19 `DB.APP_STATE_KEYS`; v1.16.4: JSON import saves under the storage keys: §4.5 `STORAGE_KEYS` / `storageKey()`; §8 `storageKey()`; §12 adding a persisted field uses the State name; v1.16.3: An import keeps the loaded transactions it doesn't replace: §4.5 an import never drops loaded transactions; §8 `mergeImported()`, `undoTransferDetection()`; §10 memory follows the same re-upload rules; §11 kept transfers are detected again; v1.16.2: Imports read every file before changing anything: §8 `loadFiles()` options and result, `parseCsvFile()` reads only, `importParsedCsv()`, `importProblemText()`, `reloadFromDirHandle()`; §20 Rebuild from your folder reads before it clears, read before clearing; v1.16.1: Clear transaction edits works from memory: §4.2 `_originalCategories`, `_originalType` and what a transaction keeps of its row; §4.5 IndexedDB may not hold the loaded transactions; §10 a stored row holds the CSV's values; §20 Clear transaction edits; v1.16.0: Trends, AI Analysis, Settings and the Welcome rebuilt: §3 file roles; §4.1 `cardDetails`, `sampleData`, AI history `model`; §6 tile tokens and Insights/Settings/Welcome components; §7 rule 7 covers Trends; §8 `loadFiles()` sample option; §9 `shellHero()`, `NO_RANGE_VIEWS`, ☰ → ×, JSON export/import buttons; §12 Settings tabs renamed, the Welcome, range label hidden on Trends and Settings; §13 quick analyses, tab state, history; §20 new fields, Use my own files, Export/Import JSON; §21 quick analyses send `AI_PROMPTS`; v1.15.0: Plan screens rebuilt: §3 file roles; §4.1 `debtPlan` and the Budget / Bucket / Debt / Scenario shapes; §6 `--teal-text` and Plan components; §7 rule 7 covers the Plan charts; §8 plan helpers (`payoffPlan()`, `growthByYear()` …); §9 plan form helpers, `simulatePayoff()` kept unused; §12 Plan titles, Forecast tabs, range label hidden on Plan screens; §13 debt balances in the summary; §20 Clear forecast scenarios / investment mix, Clear debts resets `debtPlan`; v1.14.0: Finances screens rebuilt: §4.1 Bill shape and `recurringConfirmed`; §6 new tokens and Finances components; §7 rule 7 inline SVG charts; §8 new aggregation helpers; §9 drawer, `TX_VIEWS`, SVG/heatmap/format helpers, bill helpers, removed renderers; §11 keywords re-run detection, `transferPairs()`, card payments; §12 page actions and Transactions pills; §20 Clear bills also clears spotted-charge choices; v1.13.0: Clarity redesign — §6 tokens and components; §9 theme, chart colors and app bar helpers; §12 app bar navigation replaces the sidebar and the emoji rule; §17 footer; §20 Data & Reset; v1.12.0: bank-neutral account codes, names, samples and docs; §22 `migrate.js` added; §3, §4, §5, §10, §18, §21 updated; v1.10.5: no section changes: Import Logs race fix; v1.10.4: §8, §13 single `~` is literal; §21 excerpts escape `~`; v1.10.3: §13 refusals; §21 declined runs; v1.10.2: §13 summary states its dates; §21 per-month derivations; v1.10.1: §13 `AI_MAX_TOKENS`, thinking and cut-off answers; v1.10.0: §21 AI Eval added; §13 `callClaude()` raw mode; v1.9.6: §14 folder access lasts until the last tab closes, not one page load; v1.9.5: §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)* +*Last updated: v1.18.0 — 2026-11-02 (backup status in the sync badge, save before leaving: §1 version; §4.5 1.5 s save delay, save state, flush when the tab is hidden, leave warning, Start over; §6 sync badge classes; §8 `flushPendingSave()`, `backupWouldBeLost()`; §9 sync badge states, tooltip, name, announcements and clicks; §12 the badge in the app bar; §14 the badge's Reconnect and Retry are click handlers; v1.17.0: Settings → Database tab, DB Inspector and DB Schema rebuilt on Clarity: §1 version; §3 views-db.js role; §6 Database classes; §12 seventh Settings tab, its sub-tabs, the hidden-tab guard, the tab bar scrolling to the selected tab, view registrations; §19 database views; v1.16.15: §1 desktop only; §3 `views-database.js` removed, the Changelog view reads CHANGELOG.md; §6, §18, §19 point to the current screens; v1.16.14: §9 the drawer is a modal dialog: inert page, Tab wraps, first field focused, focus returns after a re-render; v1.16.13: account order: §4.1 `accountOrder` keeps ids not loaded; §8 `orderedAccounts()`; §18 display order; v1.16.12: account names: §4.1 `accountLabels`; §4.3 an account's `name` is its default; §8 `defaultAccountName()`; §9 `acctName()`; §13 the summary lists accounts by `acctName()`; §18 names you type, and clearing them; v1.16.11: AI summary balances at the end of the selected period: §13 `summaryBalanceEnd()` and the date notes; §21 the parser reads the balance lines by how they start; v1.16.10: starting balance counted in every range: §8 `startingBalance()`, `currentBalances()`; §13 summary balances; §18 one balance rule; v1.16.9: the transaction drawer stores only the flags you change: §4.2 flags, §12 state mutations; v1.16.8: flags from transaction rules are worked out on load, never read from storage: §4.2 flags, §8 `txRuleFlag()` / `txFlags()` / `applyTxRulesToAll()`, §19 flags in the transactions store; v1.16.7: transaction links to budgets, buckets and debts by id: §1 version; §3 migrate.js role; §4.1 the `id` fields, TxOverride and its `link` shape; §8 `PLAN_LINK_TYPES`, `newPlanId()`; §9 `planItem()`, `linkedTransactions()`, `unlinkPlanItems()`, `ensurePlanIds()`; §20 clearing budgets, buckets or debts removes their links; §22 the plan-link migration; v1.16.6: JSON export carries account names and order, Read as, flag rules, transfer keywords and theme: §9 `JSON_EXPORT_KEYS`; §12 adding a persisted field; §20 what the export holds; v1.16.5: a new database copies every saved setting: §4.5 the keys that go through `storageKey()`; §12 adding a persisted field; §19 `DB.APP_STATE_KEYS`; v1.16.4: JSON import saves under the storage keys: §4.5 `STORAGE_KEYS` / `storageKey()`; §8 `storageKey()`; §12 adding a persisted field uses the State name; v1.16.3: An import keeps the loaded transactions it doesn't replace: §4.5 an import never drops loaded transactions; §8 `mergeImported()`, `undoTransferDetection()`; §10 memory follows the same re-upload rules; §11 kept transfers are detected again; v1.16.2: Imports read every file before changing anything: §8 `loadFiles()` options and result, `parseCsvFile()` reads only, `importParsedCsv()`, `importProblemText()`, `reloadFromDirHandle()`; §20 Rebuild from your folder reads before it clears, read before clearing; v1.16.1: Clear transaction edits works from memory: §4.2 `_originalCategories`, `_originalType` and what a transaction keeps of its row; §4.5 IndexedDB may not hold the loaded transactions; §10 a stored row holds the CSV's values; §20 Clear transaction edits; v1.16.0: Trends, AI Analysis, Settings and the Welcome rebuilt: §3 file roles; §4.1 `cardDetails`, `sampleData`, AI history `model`; §6 tile tokens and Insights/Settings/Welcome components; §7 rule 7 covers Trends; §8 `loadFiles()` sample option; §9 `shellHero()`, `NO_RANGE_VIEWS`, ☰ → ×, JSON export/import buttons; §12 Settings tabs renamed, the Welcome, range label hidden on Trends and Settings; §13 quick analyses, tab state, history; §20 new fields, Use my own files, Export/Import JSON; §21 quick analyses send `AI_PROMPTS`; v1.15.0: Plan screens rebuilt: §3 file roles; §4.1 `debtPlan` and the Budget / Bucket / Debt / Scenario shapes; §6 `--teal-text` and Plan components; §7 rule 7 covers the Plan charts; §8 plan helpers (`payoffPlan()`, `growthByYear()` …); §9 plan form helpers, `simulatePayoff()` kept unused; §12 Plan titles, Forecast tabs, range label hidden on Plan screens; §13 debt balances in the summary; §20 Clear forecast scenarios / investment mix, Clear debts resets `debtPlan`; v1.14.0: Finances screens rebuilt: §4.1 Bill shape and `recurringConfirmed`; §6 new tokens and Finances components; §7 rule 7 inline SVG charts; §8 new aggregation helpers; §9 drawer, `TX_VIEWS`, SVG/heatmap/format helpers, bill helpers, removed renderers; §11 keywords re-run detection, `transferPairs()`, card payments; §12 page actions and Transactions pills; §20 Clear bills also clears spotted-charge choices; v1.13.0: Clarity redesign — §6 tokens and components; §9 theme, chart colors and app bar helpers; §12 app bar navigation replaces the sidebar and the emoji rule; §17 footer; §20 Data & Reset; v1.12.0: bank-neutral account codes, names, samples and docs; §22 `migrate.js` added; §3, §4, §5, §10, §18, §21 updated; v1.10.5: no section changes: Import Logs race fix; v1.10.4: §8, §13 single `~` is literal; §21 excerpts escape `~`; v1.10.3: §13 refusals; §21 declined runs; v1.10.2: §13 summary states its dates; §21 per-month derivations; v1.10.1: §13 `AI_MAX_TOKENS`, thinking and cut-off answers; v1.10.0: §21 AI Eval added; §13 `callClaude()` raw mode; v1.9.6: §14 folder access lasts until the last tab closes, not one page load; v1.9.5: §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)* --- diff --git a/README.md b/README.md index 20f769e..5dbd901 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.17.0  ·  **Stack:** Vanilla JS, HTML, CSS  ·  **Install:** None +**Version:** v1.18.0  ·  **Stack:** Vanilla JS, HTML, CSS  ·  **Install:** None --- @@ -53,7 +53,7 @@ FinLens auto-detects which file is which based on filename and column headers. C **3. Explore** -Use the top bar to move between views: Overview, Transactions, **Plan** (a menu with Budget, Buckets, Debt, Investments and Forecast), Trends and AI Analysis. Transactions has filter pills for Income, Spending, Bills, Payments and Transfers. On a phone or a narrow window they're in the **☰** menu. The calendar icon sets the date range for most views, and the bank icon picks which accounts to include. The **Synced** badge shows whether your changes are being saved to your folder. +Use the top bar to move between views: Overview, Transactions, **Plan** (a menu with Budget, Buckets, Debt, Investments and Forecast), Trends and AI Analysis. Transactions has filter pills for Income, Spending, Bills, Payments and Transfers. On a phone or a narrow window they're in the **☰** menu. The calendar icon sets the date range for most views, and the bank icon picks which accounts to include. The **Synced** badge shows whether your changes are being saved to your folder: **Saving…** right after a change, **Not synced** when there's no folder, its access has lapsed or a save failed. Hover it for the reason; clicking it reconnects, retries the save or opens **Settings → Import**. --- @@ -88,7 +88,7 @@ FinLens stores all your data — budgets, bills, transaction edits, settings, AI **How it works:** 1. When you pick a CSV folder (on the Welcome screen or in **Settings → Import**), FinLens begins auto-saving your complete state to `finlens-state.json` in that same folder. -2. Every 5 seconds (when you make changes), your dashboard state is written to this file. You can also click **Save now** in **Settings → Import** to force an immediate sync. +2. A moment after each change (1.5 seconds), your dashboard state is written to this file. The badge in the top bar says **Saving…** until it's written, then **Synced**. Switching to another tab saves right away, and if you close the tab while a save is still waiting, the browser asks first. You can also click **Save now** in **Settings → Import** to force an immediate sync. 3. On every page load, FinLens checks for `finlens-state.json` first — if it exists, your entire state (budgets, categories, overrides, settings, AI history) is restored instantly. If the file doesn't exist, it falls back to the browser's IndexedDB or localStorage. 4. Because the file lives on your computer (not in the browser), **it survives browser cache clearing**. Even if you clear all browser data, your `finlens-state.json` remains on your disk and will be restored on the next load. @@ -265,4 +265,4 @@ See [CHANGELOG.md](CHANGELOG.md) for the full release history. --- -*FinLens v1.17.0 — Built for one person's finances, designed to be useful for anyone's.* +*FinLens v1.18.0 — Built for one person's finances, designed to be useful for anyone's.* diff --git a/index.html b/index.html index c13e6d2..1ce2b09 100644 --- a/index.html +++ b/index.html @@ -167,12 +167,18 @@ .menu a.active .t{color:var(--accent-strong-text)} .menu a.active .d{color:var(--text-2)} .appbar-tools{margin-left:auto;display:flex;align-items:center;gap:8px} -.sync{height:36px;display:inline-flex;align-items:center;gap:8px;padding:0 14px;margin-right:4px;border:0;border-radius:999px;font-size:13px;font-weight:600;white-space:nowrap} +/* min-width: "Synced" and "Saving…" are the same width, so the pill doesn't jump on every save */ +.sync{height:36px;min-width:7.75em;display:inline-flex;align-items:center;justify-content:center;gap:8px;padding:0 14px;margin-right:4px;border:0;border-radius:999px;font-size:13px;font-weight:600;white-space:nowrap} .sync .sdot{width:8px;height:8px;border-radius:50%;flex-shrink:0} .sync.ok{background:var(--good-soft);color:var(--good-strong-text)} .sync.ok .sdot{background:var(--good-dot)} .sync.off{background:var(--warn-soft);color:var(--warn-strong-text)} .sync.off .sdot{background:var(--warn)} +/* "Saving…" while a save waits or runs (v1.18.0): neutral, with a slow pulse on the dot */ +.sync.busy{background:var(--muted);color:var(--text-2)} +.sync.busy .sdot{background:var(--accent)} +@media (prefers-reduced-motion:no-preference){.sync.busy .sdot{animation:sync-pulse 1.4s ease-in-out infinite}} +@keyframes sync-pulse{50%{opacity:.3}} .pop-wrap{position:relative;display:flex} .icon-btn{position:relative;width:40px;height:40px;display:grid;place-items:center;flex-shrink:0;border:1px solid var(--border);background:var(--surface);color:var(--text-2);border-radius:10px;cursor:pointer;text-decoration:none} .icon-btn:hover{background:var(--surface-2);color:var(--text)} @@ -1174,7 +1180,7 @@
- +
+ + +