Repository navigation
Description
Problem
The app routes each project to its own named window (ui-packages/web/src/features/projects/project-link.tsx:16-28), but nothing stops the same project from being open twice: a browser's Duplicate Tab, a bookmark to /p/<id>, or a pasted address all land a second tab on the same library. The deletion path already plans for this state — it shows "Waiting for other tabs that have X open to close." (ui-packages/web/src/shell/project-root.tsx:153-159; ui-packages/web/src/data/workspace-database.ts:142-150). Every other path ignores it:
- The Files tree is listed once at mount (
ui-packages/web/src/features/resources/use-file-library.ts:96-111) and only this tab's own writes reload it; noBroadcastChannelorstorage-event listener exists anywhere in the source. A file imported, moved or removed in one tab never appears in the other's Files, Starred or Recent views until reload — and the assistant in the stale tab answers from the same behind list. - File navigation (view, Recent, starred) is read once at mount (
ui-packages/web/src/features/resources/use-file-navigation.ts:20) and rewritten as one whole record on every change (use-file-navigation.ts:52;file-navigation.ts:58-67). Two tabs hold two copies, and whichever writes last drops the other's entries: a star set in tab B is erased from the record when tab A merely opens its next document, and after reload it is gone everywhere. - The saved workspace (open tabs, last active, positions) follows the same whole-value rule (
ui-packages/web/src/features/workspace/use-workspace.ts:48,100-105,109-131;workspace-storage.ts:56-65). Tab B's position save — armed one second after a scroll pauses — writes the tab list it read at its mount, so a tab closed in A reopens at next launch and tabs A opened since B mounted vanish from the saved bar.
The reader's model is one library per project ("Included files and files added by the user should share one clear interaction model", ui-packages/web/PRODUCT.md); two windows on it disagree about what it holds, and the stale one silently destroys the reader's own marks with its next write.
Proposal
- Pick one notification channel between tabs of a project — a
BroadcastChannelnamed by the database, or thestorageevent that already fires only in the other tab — and post a change signal from the library's writes (import, move, remove, save, replace). - On that signal, re-list the library and re-read file navigation and the saved workspace, so both tabs show one library.
- Stop letting a whole-value write drop entries its writer has never seen: stars, Recent entries and the saved tab list either merge on write, or move out of single whole-value records, so one tab can no longer erase another's.
Goal
After this, two tabs of one project behave as one library: a file added, moved or removed in either appears in both Files trees and in both assistants' reach, and no tab's write can erase a star, a Recent entry or an open-tab record another tab added — a star set in one tab still stands after the other opens a document.
Verification
if ! grep -rq "BroadcastChannel\|addEventListener('storage'" ui-packages/web/src; then echo 'no cross-tab channel yet'; exit 1; fi
pnpm --filter @gamma-reader/web test src/features/resources src/features/workspace
pnpm checkRefs
- ui-packages/web/src/features/resources/use-file-library.ts:96-111 — library listed once; only this tab's writes reload it
- ui-packages/web/src/features/resources/use-file-navigation.ts:20,52 and file-navigation.ts:58-67 — navigation read once, rewritten whole
- ui-packages/web/src/features/workspace/use-workspace.ts:48,100-105,109-131 and workspace-storage.ts:56-65 — saved workspace read once, written whole
- ui-packages/web/src/shell/project-root.tsx:153-159 and data/workspace-database.ts:142-150 — deletion already treats same-project tabs as expected
- ui-packages/web/src/features/projects/project-link.tsx:16-28 — named-window routing, which a duplicate or bookmark bypasses
- Keep a background reply's hands off the reader's tabs — today its open call switches what the reader is reading, and the reader switching back breaks the call #226 — another reader-vs-writer contention over the same workspace-tab state, from the assistant side
- Keep the reader's place when its tab closes — today Close and Close all drop the reading position, and the document reopens at page 1 #247 — positions live in the same whole-value record this issue's workspace half widens
Activity
bencode commentedon Oct 27, 2026
Independent review — posted by the scheduled issue-reviewer loop, independent of the authoring session.
Evidence audit: all citations confirmed on main (
dbf9cb6).project-link.tsx:16-28guards only plain left-clicks (duplicate tab / bookmark to/p/<id>bypasses the named window);project-root.tsx:155-158carries the exact "Waiting for other tabs that have X open to close." string;workspace-database.ts:142-150plans deletion around same-project tabs.use-file-library.ts:96-111lists once at mount (useEffect → reload), only this tab's writes reload it;use-file-navigation.ts:20reads at mount,:52rewrites on every state change viafile-navigation.ts:58-67(whole-recordJSON.stringify);use-workspace.ts:48reads once,:100-105writes whole on tab/active change,:109-131defers position saves 1 s and ships the whole record from this tab's in-memory store (workspace-storage.ts:56-65). ✓ NoBroadcastChannelorstorage-event listener exists anywhere insrc.PRODUCT.md:31✓.Duplicate check: clean — #226 (assistant open-call contention) and #247 (positions on close) touch adjacent state; nothing covers cross-tab library sharing.
Sensor: lint ✓. Verify was ungated as filed — repaired. The block was existing tests +
pnpm checkonly, so verify passed on unfixed main — it could never fail, and a later beat would have closed this as implemented on a false signal (same defect as #269's block last beat). Per the anchor-repair rule I edited only the Verification block, prependingif ! grep -rq "BroadcastChannel\|addEventListener('storage'" ui-packages/web/src; then …; exit 1; fi— mechanism-neutral between the proposal's two channel options. Re-lint ✓; verify now fails on main (no cross-tab channel yet) → not implemented. Body edit logged: one line prepended to the Verification block, nothing else touched.Verdict: valid, stays open. Sharpening: bullet 3 is the substantive half — a channel alone does not stop the erasure, because the losing write happens in-memory before storage; the fix needs merge-on-write (or split records), and a unit test simulating two mount-time snapshots would anchor exactly the regression the title names.
bencode commentedon Oct 30, 2026
Posted by the scheduled issue-reviewer loop, independent of the authoring session.
Re-audit @ d05b6b6 — the review ran against
dbf9cb6; the four plugins commits since touch conversation/plugins/shell surfaces, none of the cited files. Still valid; stays open.project-link.tsx:17-28still guards only plain left-clicks;project-root.tsx:157carries the "Waiting for other tabs…" string;workspace-database.ts:142-150still plans deletion around same-project tabs. Read-once/write-whole holds end to end:resources/use-file-library.ts:95-112(list once at mount),resources/use-file-navigation.ts:20,52+resources/file-navigation.ts:58-68(whole-recordJSON.stringifyon every state change),use-workspace.ts:49,100-106,109-131(read once, whole-write on tab/active change, 1 s deferred whole-record position saves),workspace-storage.ts:56-66.PRODUCT.md:31✓.no cross-tab channel yet(noBroadcastChannel, nostoragelistener anywhere in src). Correct not-implemented verdict.--
bencode commentedon Nov 5, 2026
Posted by the scheduled issue-reviewer loop, independent of the authoring session.
Re-audit @ d05b6b6 — no commits since the 10-30 review's base; still valid, stays open.
BroadcastChanneland nostoragelistener anywhere insrc, so every read-once/write-whole citation (use-file-library.ts,use-file-navigation.ts:20,52+file-navigation.ts,use-workspace.ts,workspace-storage.ts) remains as verified 10-30.no cross-tab channel yet. Correct not-implemented verdict.bencode commentedon Nov 7, 2026
Posted by the scheduled issue-reviewer loop, independent of the authoring session.
Re-audit at
d05b6b6(fourth pass; HEAD unchanged since 2026-10-28) — valid, stays open; no edits.project-link.tsx:17-28still guards only plain left-clicks (button 0, no modifiers), so duplicate tab / bookmark to/p/<id>still lands a second window; the exact "Waiting for other tabs that have X open to close." still atshell/project-root.tsx:157. Read-once/write-whole holds end to end: library listed once at mount (use-file-library.ts:96-111), navigation read once and rewritten whole on every state change (use-file-navigation.ts:20,52→file-navigation.ts:58-67), workspace read once, whole-written on tab/active change and on deferred position saves (use-workspace.ts:49,100-105,109-131→workspace-storage.ts:56-65). The erasure mechanism is intact: a position save still ships the mount-time tab list.no cross-tab channel yet(grep re-run: noBroadcastChannel, nostoragelistener anywhere insrc). Correct not-implemented verdict.Verdict unchanged; the standing sharpening remains the substantive one: a channel alone does not stop the erasure (the losing write is in-memory before storage) — the fix needs merge-on-write or split records, and a two-snapshot unit test would anchor the star-erasure regression the title names.
bencode commentedon Nov 11, 2026
Posted by the scheduled issue-reviewer loop, independent of the authoring session.
Re-audit (fifth pass) @
d05b6b6— HEAD unchanged since 2026-10-28; valid, stays open.features/projects/project-link.tsx:16-28), the "Waiting for other tabs…" string still atshell/project-root.tsx:157, library still listed once at mount (use-file-library.ts:109), and noBroadcastChannel/storagelistener anywhere insrc(grep re-run: 0 matches).no cross-tab channel yet. Correct not-implemented verdict.