Repository navigation
Description
Problem
Every tab a reader has ever looked at stays fully mounted. DocumentTabs maps over all open tabs and renders a pane for each (ui-packages/web/src/features/reader/document-tabs.tsx:283-305); once a tab has been active, its pane is forceMounted inside <Activity mode="hidden"> and never unmounted (ui-packages/web/src/features/reader/document-pane.tsx:17-31). For PDFs that means the loaded pdf.js document, its bytes, and the blob ObjectURL all stay alive until the tab is closed — pdfSources revokes a URL only when its id leaves workspace.tabs (document-tabs.tsx:164-173). Nothing caps how many tabs stay open (workspace-store.ts:95-101 is an unbounded string[]), and the product's own verb is comparing files (ui-packages/web/PRODUCT.md:19). A reader comparing a shelf of reports in a browser — on iOS Safari, where a few hundred MB gets the page killed, the platform #167 already worries about — pays for every document they opened, not the ones they are reading.
Proposal
- Keep only the most recently used hidden panes mounted (a small fixed number, e.g. 3); unmount the rest's content while keeping their tab, title and place in the tab bar.
- Restore an evicted pane on revisit from the position the workspace already records —
defaultPosition={workspace.store.getState().positions[id]}(document-tabs.tsx:296-300) is read at mount and already carries the scroll state. - Release an evicted PDF's
ObjectURLby reusing the existingpdfSourcescleanup instead of waiting for tab close. - Never evict a pane whose lab is running: the lab runner lives inside the mounted reader (
features/assistant/lab-tools.ts:21-22), so evicting it would kill a run.
Goal
After this, memory grows with the documents a reader is actually reading, not with how many they opened today: opening and revisiting many documents keeps a bounded number of loaded readers alive, and closing a tab is no longer the only thing that frees its document.
Verification
grep -rwiE "evict|unload|unmount|suspend|keepMounted|mountedPanes" ui-packages/web/src/features/reader ui-packages/web/src/features/workspace --include='*.ts' --include='*.tsx' --exclude='*test*'
pnpm --filter @gamma-reader/web test --silent
pnpm checkRefs
- ui-packages/web/src/features/reader/document-tabs.tsx:283-305 — every open tab renders a pane
- ui-packages/web/src/features/reader/document-pane.tsx:17-31 — visited panes
forceMountinsideActivityand never unmount - ui-packages/web/src/features/reader/document-tabs.tsx:164-173 — a PDF's blob URL is freed only when its tab closes
- ui-packages/web/src/features/workspace/workspace-store.ts:95-101 — open tabs are unbounded
- ui-packages/web/src/features/reader/document-tabs.tsx:296-300 — mount-time position restore, already enough to rehydrate an evicted pane
- ui-packages/web/src/features/assistant/lab-tools.ts:21-22 — the lab runner lives in the mounted reader, so it must be exempt
- ui-packages/web/PRODUCT.md:19 — "importing, previewing, comparing, and discussing files feel immediate"
- Remember where the reader stopped — reopen documents at their page or scroll position #40 — the position memory this builds on
- Keep the Files panel fluent at the 5000-file import cap — every row renders today, unwindowed #166 — sibling scale issue (Files panel renders every row); this one is the document panes
Activity
bencode commentedon Oct 22, 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. Audited againstmain@ebb0ee0.Evidence audit: all load-bearing citations confirmed; one one-line drift.
document-tabs.tsx:283-305— every id inworkspace.tabsrenders a pane;document-pane.tsx:17-31— panes sit in<Activity mode="hidden">with unconditionalforceMount, so a visited tab stays fully mounted until closed, exactly as claimed.document-tabs.tsx:164-173—pdfSourcesrevokes theObjectURLonly when an id leavesworkspace.tabs;workspace-store.ts:95-101—setTabshas no cap anywhere.document-tabs.tsx:296-300—defaultPosition={workspace.store.getState().positions[id]}is read at mount, with the design comment confirming panes aren't re-rendered on scroll — the restore path for an evicted pane already exists.LabAccess(lab-tools.ts:21-23) exposes per-file runners, andworkspace-context.tsx:47registerLab: (runner) => () => void— runners are registered by mounted readers and unregister on unmount, so eviction would kill a run, as the Proposal requires exempting.PRODUCT.md:19→ the "importing, previewing, comparing, and discussing files feel immediate" quote lives at :18 — verbatim, one line up. Non-fatal.Sensor + Verification block repaired (logged here per policy): lint ✓, but
verifyfalsely passed on unmodified main —grep -rqiE "evict|unload|suspend"case-insensitively matchesbeforeunloadinworkspace-context.tsx:101-103(the very guard #167 is about). Same disease as #157/#158's blocks. Edited only the Verification block:Word boundaries kill the
beforeunloadfalse match; the broadened list covers the natural implementation names. Re-linted ✓; verify now ✗ on main ✓ (not implemented).Verdict: valid, keep open. Two sharpenings for implementation: (1) the lab exemption has a free mechanism —
registerLab's unregister-on-unmount means the eviction policy can simply ask the context which runners exist; the test should pin that a running lab's pane is never evicted. (2) Evicting a PDF releases itsObjectURL, so a revisit must re-read bytes from the store — the position restore is already mount-time, but the test should assert a revisit after eviction restores position, not just the document.bencode commentedon Oct 24, 2026
Re-audit — posted by the scheduled issue-reviewer loop, independent of the authoring session. Prior review (above) audited
main@ebb0ee0; this beat re-checks it againstmain@90b046f, the stalest-reviewed issue relative to commits landed since.Drift since ebb0ee0: the drag-tabs work (
614abd0/101c45f) touched the tab bar (features/reader/document-tabs.tsx,document-tab-bar/) — not this issue's subject, pane lifecycle. Of the cited anchors, only one moved:workspace-store.tsgainedmoveTab(+7 lines,:55-61), shifting thesetTabscitation from:95-101to:103-108;setTabsstill has no cap.features/workspace/document-tabs.tsxanddocument-pane.tsxare byte-identical — the load-bearing citations (per-id panes underforceMount,ObjectURLrevoke only on tab close, mount-time position read) all stand.Sensor: lint ✓; verify ✗ on main ✓ — the anchor repaired in the prior review is still red (no evict/unload/unmount/suspend/keepMounted/mountedPanes in reader or workspace, tests excluded).
Verdict: unchanged — valid, keep open. The original sharpenings stand, and reordering strengthens the second one: with tabs now draggable, a revisit after eviction must restore the pane's position and land it in the current (possibly re-dragged) order — the order comes from
workspace.tabs, but the test should pin both together.bencode commentedon Oct 27, 2026
Re-audit — posted by the scheduled issue-reviewer loop, independent of the authoring session. Prior review audited
main@90b046f; this beat re-checks the stalest-reviewed issue againstmain@0439ecf(11 commits since).Drift since 90b046f: none. The sheet/reader fixes since then (chart sheet, cell bar, open-at-page, pdf worker order, notices) never touch this issue's anchors —
git diff --stat 90b046f..HEADoverworkspace-store.ts,workspace-context.tsx,document-tabs.tsx,document-pane.tsx,lab-tools.ts,PRODUCT.mdis empty.setTabsstill atworkspace-store.ts:103-108with no cap; panes still render per-id under unconditionalforceMount.Sensor: lint ✓; verify ✗ on main ✓ (no evict/unload/unmount/suspend/keepMounted/mountedPanes in reader or workspace).
Verdict: unchanged — valid, keep open. Both sharpenings from the prior review stand (running-lab pane never evicted via
registerLab; revisit after eviction restores position and current tab order).bencode commentedon Nov 2, 2026
Posted by the scheduled issue-reviewer loop, independent of the authoring session.
Re-audit at
d05b6b6— the stalest remaining review (8 commits since the last @0439ecf, the whole plugins series;git diff --stat 0439ecf..HEADover all six cited files is empty). Valid, stays open; no edits.forceMountunderActivity mode='hidden'(document-pane.tsx:8-16); a pane per open tab (document-tabs.tsx:284-306);pdfSourcesrevoking only when an id leavesworkspace.tabs(:164-173);setTabswith no cap (workspace-store.ts:103-108, body's:95-101drifted to this in the last review); mount-timedefaultPosition(:300);LabAccessin the mounted reader (lab-tools.ts:20-24); "comparing" atPRODUCT.md:18-19.features/reader/— the eviction design's one exemption (never evict a running lab) still covers everything that lives inside a pane.evict|unload|unmount|suspend|keepMounted|mountedPanesred in reader + workspace — red for the right reason). Gate healthy as written, one command per line.bencode commentedon Nov 13, 2026
Posted by the scheduled issue-reviewer loop, independent of the authoring session.
Re-audit at
d05b6b6— second-stalest review this beat (12 days). HEAD still unchanged since 2026-10-28; valid, stays open; no edits.forceMount(document-pane.tsx:8-16,document-tabs.tsx:284-306);pdfSourcesrevoking only on tab close;setTabswith no cap (workspace-store.ts:103-108); mount-timedefaultPosition;LabAccessexemption surface untouched.evict|unload|unmount|suspend|keepMounted|mountedPanesred in reader + workspace,beforeunloadexcluded — red for the right reason). Gate healthy, one command per line.Verdict unchanged: valid, keep open. Both sharpenings from the earlier reviews stand (never evict a running lab's pane via
registerLab; revisit after eviction restores position and current tab order).