diff --git a/CHANGELOG.md b/CHANGELOG.md index 83bb784..86d6785 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 contrast. + +### 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 9c22731..5071cb8 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. @@ -356,7 +356,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. @@ -504,6 +509,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). --- @@ -561,7 +573,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 @@ -688,8 +702,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 @@ -919,7 +941,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 or theme setting (light only for now). +- **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 or theme setting (light only for now). - **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`). @@ -1013,9 +1035,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. --- @@ -1133,7 +1155,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.27: §9 and §12 the developer views are in `NO_RANGE_VIEWS`; §14 the tab's name is Data & reset; §20 a render partway through an action keeps its button's done label (`DataCleanup.running`); v1.16.26: the type decides whether a transaction is a transfer: §4.1 the drawers note, a type changed away from Transfer; §8 the sums go by type, `ownCategories()`, `withoutDirection()`, `redetectTransfers()`; §11 the type decides, Transfer out / in only on transfers, a type change re-runs detection; §11.1 a retyped autopay's card payment; §13 the summary's totals go by type; v1.16.25: Re-categorize all is saved: §1 version; §4.1 `ruleCategories`; §4.2 categories; §8 `categoryFromRules()`; §9 `recategorizeAll()`; §20 where `ruleCategories` is kept, what clears it, left out of the JSON export; v1.16.24: a transfer that stops being one gets its own type and category back: §8 `undoTransferDetection()`, §11 un-transferring; v1.16.23: transfer detection respects the user's type and categories: §1 version, §4.1 the drawers note, §11 the user's edit wins; v1.16.22: §13 the AI summary's trend stops at a past period's end, subscriptions labelled current; §21 the parser finds sections by their heading's start; v1.16.21: §8 `overrideBalanceAt()`, `balanceAt()`; §18 a card's amount owed is taken back plus the later transactions, a bank balance minus them; the sign of a card's balance; v1.16.20: §18 a balance override at the end of every range is the override less the later transactions, no 7-day exception; v1.16.19: overlapping exports of one account count each shared row once: §4.5 one transaction per id; §8 `mergeImported()`, `importParsedCsv()`; §10 overlapping exports of one account; §19 the leftover-copy check keeps the import's ids; v1.16.18: a JSON import's transaction edits show at once: §9 `applyImportedEdits()`; §20 what takes effect without a reload; v1.16.17: a file read into another account takes its rows with it: §4.3 the account's `files`, `accountFiles()`; §4.5 the exception to an import never dropping rows; §8 `accountFiles()`, `earlierCopies()`, `moveEarlierCopies()`; §10 Read as changes the ids; §19 `DB.removeTransactions()`, `DB.patchAccount()`; §22 `_rekey()` is also used by imports; v1.16.16: the transaction and transfer drawers store only the fields you change: §4.1 TxOverride, §11 transfer keywords, §12 state mutations; 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.27: §9 and §12 the developer views are in `NO_RANGE_VIEWS`; §14 the tab's name is Data & reset; §20 a render partway through an action keeps its button's done label (`DataCleanup.running`); v1.16.26: the type decides whether a transaction is a transfer: §4.1 the drawers note, a type changed away from Transfer; §8 the sums go by type, `ownCategories()`, `withoutDirection()`, `redetectTransfers()`; §11 the type decides, Transfer out / in only on transfers, a type change re-runs detection; §11.1 a retyped autopay's card payment; §13 the summary's totals go by type; v1.16.25: Re-categorize all is saved: §1 version; §4.1 `ruleCategories`; §4.2 categories; §8 `categoryFromRules()`; §9 `recategorizeAll()`; §20 where `ruleCategories` is kept, what clears it, left out of the JSON export; v1.16.24: a transfer that stops being one gets its own type and category back: §8 `undoTransferDetection()`, §11 un-transferring; v1.16.23: transfer detection respects the user's type and categories: §1 version, §4.1 the drawers note, §11 the user's edit wins; v1.16.22: §13 the AI summary's trend stops at a past period's end, subscriptions labelled current; §21 the parser finds sections by their heading's start; v1.16.21: §8 `overrideBalanceAt()`, `balanceAt()`; §18 a card's amount owed is taken back plus the later transactions, a bank balance minus them; the sign of a card's balance; v1.16.20: §18 a balance override at the end of every range is the override less the later transactions, no 7-day exception; v1.16.19: overlapping exports of one account count each shared row once: §4.5 one transaction per id; §8 `mergeImported()`, `importParsedCsv()`; §10 overlapping exports of one account; §19 the leftover-copy check keeps the import's ids; v1.16.18: a JSON import's transaction edits show at once: §9 `applyImportedEdits()`; §20 what takes effect without a reload; v1.16.17: a file read into another account takes its rows with it: §4.3 the account's `files`, `accountFiles()`; §4.5 the exception to an import never dropping rows; §8 `accountFiles()`, `earlierCopies()`, `moveEarlierCopies()`; §10 Read as changes the ids; §19 `DB.removeTransactions()`, `DB.patchAccount()`; §22 `_rekey()` is also used by imports; v1.16.16: the transaction and transfer drawers store only the fields you change: §4.1 TxOverride, §11 transfer keywords, §12 state mutations; 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 6708afa..3cfaf24 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. @@ -263,4 +263,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 c59bc09..7dba235 100644 --- a/index.html +++ b/index.html @@ -129,12 +129,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)} @@ -1136,7 +1142,7 @@
- +
+ + +