* perf: eliminate page-reload UX on mutations and navigation
Phase 1 — Background refresh (no content-destroying spinner):
- Transactions, Dashboard, Goals, Accounts, Portfolio, Loans, Bills,
Housing, Retirement, Counterparties: replace setLoading(true)/false
with initialLoad signal — existing data stays visible during re-fetch
- Render spinner only on first-ever load (no data yet), not on every
mutation or navigation return
Phase 2 — Keep-alive page mounting (no destroy on nav):
- App.tsx: replace <Show when={activePage === name}> with CSS visibility
toggle — pages stay mounted after first visit
- Track visited pages via mountedPages signal, mount on first access
- Navigation is instant: no remount, no re-fetch, preserved scroll
11 files, typecheck + lint + build all pass.
* docs: update plan status, gitignore CLAUDE.md
* fix: falsy-empty-array checks in Counterparties and Retirement
!array is always false for empty arrays (arrays are truthy in JS).
Changed to .length === 0 so the loading spinner actually renders
during initial fetch instead of showing empty-state prematurely.
* fix: remove unused eslint-disable directive in idb.ts
5.4 KiB
Plan: Eliminate Page-Reload UX on Mutations & Navigation
Status: Phase 1 + 2 implemented (2026-07-13)
Problem
Users perceive "page reloads" in two scenarios:
-
After a mutation (add transaction, allocate budget, etc.): the entire content area vanishes, a spinner appears, then content reappears. This is
setLoading(true)→ full re-render with spinner → refetch →setLoading(false). -
When navigating between pages: clicking a sidebar item destroys the old page component and creates a new one from scratch. All data is re-fetched, spinner shows, then content appears.
Root Causes
| # | Cause | Location | Impact |
|---|---|---|---|
| 1 | <Show when={activePage() === name}> unmounts pages on navigation |
App.tsx:987-1009 |
Every nav = full page recreation + refetch |
| 2 | setLoading(true) before every data fetch replaces content with spinner |
17 features (Transactions, Dashboard, Goals, etc.) | Every mutation = content disappears |
| 3 | No distinction between "initial load" (needs spinner) and "background refresh" (should be silent) | All feature refresh* functions |
Same spinner for both cases |
| 4 | bumpProfileVersion() triggers all mounted features to refetch on any mutation |
App.tsx:1041,1071 |
One mutation = cascade of refetches |
Plan
Phase 1: Eliminate mutation-triggered loading spinners (HIGH IMPACT, LOW RISK)
Pattern change — every feature's refresh function:
Current (destructive):
const refreshData = async () => {
setLoading(true); // ← removes all content
const data = await api.getX();
setData(data);
setLoading(false); // ← content reappears
};
Target (background refresh):
const [initialLoad, setInitialLoad] = createSignal(true);
const refreshData = async () => {
try {
const data = await api.getX();
setData(data);
} catch {
/* toast */
} finally {
setInitialLoad(false);
}
};
// Render: only show spinner on first ever load
{
initialLoad() && !data() ? <Spinner /> : <Content />;
}
Features to convert (priority order):
- Transactions.tsx — most-used, most noticeable
- Dashboard.tsx — landing page, highly visible
- Goals.tsx
- Accounts.tsx
- Portfolio.tsx
- Loans.tsx
- Bills.tsx + BillCalendar.tsx
- Housing.tsx
- Retirement.tsx
- Counterparties.tsx
- Import.tsx (already has partial pattern)
Features already using createResource (skip or minimal change):
- Budgets.tsx —
createResourcekeeps old data during refetch; only needsinitialLoadguard - Analytics.tsx — same pattern
- Categories.tsx — same pattern
Phase 2: Keep-alive page mounting (MEDIUM IMPACT, MEDIUM RISK)
Replace <Show> with CSS visibility:
// Current — destroys page on nav away
<Show when={activePage() === name && !_isLoading()}>
<Dynamic component={page} />
</Show>
// Target — hides page, preserves state
<div style={{ display: activePage() === name ? 'block' : 'none' }}>
<Dynamic component={page} />
</div>
Considerations:
- All 18 pages stay mounted; memory impact is low (SolidJS DOM is lightweight, data signals are just references)
- Each page fetches on first mount only; re-visit = instant
- Need to handle
_isLoading()differently — only show during initial app boot, not per-page - The
lazy()imports still work — pages load on first access, then stay in memory
Phase 3: Optimistic local state updates (LOWER PRIORITY)
After Phase 1 & 2, the remaining "lag" is waiting for the API response. Optimistic updates would make mutations feel instant:
const handleCreate = async (payload) => {
const optimistic = { id: -Date.now(), ...payload }; // temp ID
setData((prev) => [...prev, optimistic]); // instant UI
const created = await api.create(payload);
setData((prev) => prev.map((x) => (x.id === optimistic.id ? created : x))); // reconcile
};
Scope & Sequencing
| Phase | Description | Files | Risk | Effort |
|---|---|---|---|---|
| 1a | Transactions background refresh | 1 file | Low | 30 min |
| 1b | Dashboard background refresh | 1 file | Low | 20 min |
| 1c | Remaining features (Goals, Accounts, etc.) | 8 files | Low | 45 min |
| 2 | Keep-alive page mounting | 1 file (App.tsx) | Medium | 30 min |
| 3 | Optimistic updates (optional) | TBD | Medium | TBD |
Total Phase 1+2: ~2 hours, 12 files changed.
Verification
After each phase:
cd frontend && npm run lint && npx tsc --noEmit— must pass- Manual test: add a transaction → content should NOT disappear
- Manual test: navigate Transactions → Budgets → back → data should be instant, no spinner
npm run build— must produce valid build