Offline read cache for recent entries/motifs #122
Labels
No labels
bug
duplicate
enhancement
future
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
rbrooks/TeaLeaves#122
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Feature idea (audit Phase 5, rank #5) · Effort: medium
Why
The PWA offline story is capture-only (IndexedDB queue); reading is online-only (the service worker deliberately doesn't cache
/api/*). A mobile researcher on the go can't review recent work offline.Proposal
Add a narrow, auth-aware cache of recently-viewed entries/motifs for offline reading - explicitly NOT a blanket
/apicache (must respect the security invariant that authenticated API responses aren't cached by the service worker). Store in IndexedDB, keyed to the logged-in user, cleared on logout.Why it was likely missed
"Offline" was scoped narrowly to capture, to avoid caching authenticated data.
Acceptance criteria
/api/*; the cache is app-managed and cleared on logout.Filed from the 2026-07-15 codebase audit. Full report:
docs/.internal/report-2026-07-15.md(gitignored).Done — shipped in v9.3.0 (PR #142, merge
c69897c).app/src/lib/offlineCache.ts— a separate, app-managed IndexedDB database (tealeaves-read-cache), records keyed bytype:idand stamped with the current user id. Entry/Motif detail pagescacheItemon successful view and fall back togetCachedRecordwhen a fetch fails offline, rendering the cached copy with an "Offline — cached copy from …" banner.clearReadCache()runs on logout (Shell.handleLogout). Pruned to ~100 records/type. Cache failures are swallowed so they can never break a page.Acceptance: ✅ recently-viewed entries/motifs readable offline · ✅ the service worker still does not cache
/api/*(this is app-managed, not a SW cache) and the cache is cleared on logout. Unit tests cover cross-user isolation, the prune cap, clear-on-logout, and graceful behavior when IndexedDB is unavailable.