Repository navigation
Description
Problem
Gamma Reader persists which tabs are open and which is active, but not where in any document the reader stopped:
- The persisted workspace shape is
{ tabs: string[]; lastActiveId: string | null }(workspace-storage.ts:3) — no position travels with a tab. - A PDF's page number is component state initialized to one —
useState(1)inpdf-reader.tsx:18— so a reload reopens a 40-page essay at page 1, and any tab whose reader unmounts starts over. - Markdown, HTML, and text scroll positions live only in an in-memory ref map (
markdown-reader/index.tsx:82,103,170, passed down throughfile-preview.tsx), which survives tab switches within a session and dies on reload.
For a product whose identity is reading — and whose competitor in every reader's muscle memory (browser PDF viewers, e-readers) resumes where you left off — returning tomorrow means finding your place again by hand. The plumbing to fix this half-exists: ReaderState.viewport already computes stable text anchors (startText/endText, reader-viewport.ts) for the assistant's context; the same anchors could locate a scroll position across sessions.
Issue #1's flow said "read… while drafts save automatically," and tab persistence shipped (c6ff2e2); position persistence never did.
Proposal
- Extend the persisted workspace with a per-document position: the PDF's page number, and for text-flow formats a scroll anchor (the existing viewport text anchors are natural — robust across width/theme changes, unlike raw pixel offsets).
- Restore the position when a tab reopens, including after reload; positions for files removed from the library age out with the tab list.
- Keep it silent: no settings, no toggle, no status message — resuming is simply what reopening does. Reversible by scrolling, like any reader.
Goal
After this, reloading the app (or reopening a saved tab) puts every document back where the reader left it — PDFs on their page, text formats at their scroll anchor — with no reader action required.
Verification
grep -q "position" ui-packages/web/src/shell/workspace-storage.ts
pnpm --filter @gamma-reader/web test --silent
pnpm checkRefs
- ui-packages/web/src/shell/workspace-storage.ts:3-6 — persisted shape carries no position
- ui-packages/web/src/features/reader/pdf-reader.tsx:18 —
useState(1)page state - ui-packages/web/src/features/reader/markdown-reader/index.tsx:82,103,170 — session-only scroll map
- ui-packages/web/src/core/reader-state.ts —
viewporttext anchors already computed for agent context - ui-packages/web/src/features/reader/file-preview.tsx:42-43 — content loads per active tab
- README.md — "Local-first by design" (tabs and last active file use localStorage); ui-packages/web/PRODUCT.md — "Keep reading as the largest and quietest part of the workspace"
- Start with sample documents, add local resources progressively, and save explicitly #1 — automatic persistence of reading progress was in its intent; only tabs shipped
Activity
bencode commentedon Sep 30, 2026
Independent review — posted by the scheduled issue-reviewer loop (a session separate from the one that files these issues), under the maintainer's standing instruction to evaluate, sharpen, or retire
source:scheduledproposals.Evidence audit (against
main@d28fe0b): all citations confirmed, two of them to the exact line.{ tabs: string[]; lastActiveId: string | null }(workspace-storage.ts:3) — no position travels with a tab.useState(1)(pdf-reader.tsx:18); markdown scroll lives only in the in-memoryscrollPositionsmap (markdown-reader/index.tsx:82-103), so it dies on reload exactly as described.ReaderState.viewportalready producesstartText/endTextanchors (reader-state.ts:8).lintpassed;verifyfails today as it should → stays open.Verdict: valid, keep open — the strongest of the proposals so far. "Resume where you left off" is table stakes for a reading product, the plumbing half-exists, and the no-toggle/no-setting framing matches PRODUCT.md.
One sharpening note (non-blocking): the anchor
grep -q "position" workspace-storage.tspasses on any substring occurrence — a comment or unrelated identifier would satisfy it. Tying it to the type would make the gate meaningful, e.g.grep -Eq "position.*(number|anchor)|SavedWorkspace" ...-style is overwrought; simplest robust form is asserting the persisted shape itself:bencode commentedon Oct 1, 2026
Close audit — posted by the scheduled issue-reviewer loop (independent of the authoring session), under the maintainer's standing instruction to maintain
source:scheduledproposals.This issue was auto-closed by the merge of #48 (
c4f831c), which bypasses the relay close gate — this comment records the audit that gate would have run, atmain@725b383:SavedWorkspacenow carriespositions: ReadingPositions(workspace-storage.ts:1-8), with newcore/reading-position.ts+use-flow-position.ts, PDF and text-flow wiring, and its own integration coverage (workspace-navigation.integration.test.tsx, passing).pnpm checkfails ~2 of 3 runs onprojects.integration.test.tsx > projects > deletes only what this tab asked for, once other tabs let go of it("Unable to find role=list and name Files"). Verified pre-existing: the same test also flakes at pre-merged28fe0b(temp worktree, 3 runs). Not caused by PR feat: reopen every document where the reader left it #48 — possibly aggravated by its timing changes. Until it stabilizes, the verify gate is unreliable for every issue's Verification block, so closes cannot go throughitem.mjs closereliably.Action: added
state:needs-verificationto normalize the lifecycle (auto-close left the issue with no lifecycle label). Maintainer: swap tostate:verifiedafter checking resume-in-person, or reopen if it doesn't hold. The flaky test deserves its own issue — filed outside this loop's charter, flagging here for the maintainer.bencode commentedon Oct 1, 2026
Follow-up on the flaky-test caveat recorded in this issue's close audit (and #46's):
projects.integration.test.tsx > deletes only what this tab asked forhas stopped reproducing — 5 consecutive green runs atmain@9080aec, afterea52b1e(PR #62) reworked how folder removal reads library files.pnpm checkis reliable again, so future closes can go through theitem.mjs closeverify gate instead of human-equivalent audits. No action needed on this issue; recording the resolution where the alarm was raised.