Repository navigation
feat(web): restore the thread workspace across restarts and save named ones - #27
Merged
Merged
Conversation
…d ones The workspace threw away everything but its geometry on reload. Open tabs were rebuilt from whichever thread the URL happened to name, so stopping work meant reopening every pane by hand. That was a deliberate trade at the time: nothing could tell a deleted thread apart from one that had simply not synced yet, so persisting tabs risked restoring dead ones. Persists the whole workspace — layout, the tabs in each pane, and the selected thread — and resolves the staleness problem with a prune pass instead of by discarding state. A tab is only dropped once the environment that owns it has actually delivered a snapshot and did not report the thread; an environment that is offline, still syncing, or not yet in the catalog keeps its tabs, and the routed tab is never dropped because the router needs one to represent. Everything read out of storage goes through a repair pass, so a truncated or hand-edited entry degrades to a usable workspace rather than crashing one. On top of the automatic restore, the layout menu can now save the current workspace under a name and restore it later. Snapshots store panes by position and mint fresh pane ids on restore, so restoring one twice cannot alias a live pane. The prune pass is gated on a signature of what actually decides its outcome. Its two inputs churn on ordinary thread traffic, and pruning on each of those would write the persisted workspace to storage on every incoming message. Model: Claude Opus 5 via Claude Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The thread workspace threw away everything but its geometry on reload. Open tabs were rebuilt from whichever thread the URL happened to name, so stopping work meant reopening every pane by hand.
That was a deliberate trade, not an oversight — the old
partializecomment says so. Nothing on the client could tell a deleted thread apart from one that simply had not synced yet, so persisting tabs risked restoring dead ones. Discarding the state was the safe answer available at the time.Fix
Persists the whole workspace — layout, the tabs in each pane, and the selected thread — and solves the staleness problem with a prune pass instead of by discarding state.
Pruning. A new atom separates "environments this device is configured for" from "environments that have actually delivered a snapshot". Only the latter can be trusted to say a thread is gone. The rules, in
threadWorkspacePrune.ts:The default is always to keep. Dropping a tab because the network was slow would quietly erase a workspace, which is a far worse failure than briefly showing a tab for a deleted thread.
Repair on read. Everything coming out of storage goes through
normalizeThreadWorkspaceModel, which fixes pane count versus layout, duplicate pane ids, the same tab appearing in two panes, and anactiveTabKeypointing at nothing. A truncated or hand-edited entry degrades into a usable workspace instead of crashing one. Storage version 1 → 2 with a migration, since v1 only ever wrote the layout.Named workspaces. The layout menu gains a Save current workspace action plus a list of what is saved. Restoring one also navigates to the thread it had active — without that, the still-current URL would be bound straight back into the workspace the user just restored. Snapshots store panes by position and mint fresh pane ids on restore, so restoring the same one twice cannot alias a live pane. Saving under an existing name replaces it; the list is capped at 20 so storage does not grow without bound.
Performance
The prune pass is gated on a signature of what actually decides its outcome. Both of its inputs (
useThreadRefsand the prune scope) recompute on ordinary thread traffic while their membership is unchanged, and everypruneTargetscall writes the persisted workspace to storage — ungated, that would be one storage write per incoming message.Notes
docs/user/thread-workspace.mdalso still said "two or three columns" — a gap from feat(web): add 4-column layout and drop-target hints to the thread workspace #25 — and described the old discard-on-reload behaviour. Both corrected.Verification
vp test run apps/web/src/threadWorkspaceStore.test.ts apps/web/src/threadWorkspacePrune.test.ts— 24 passedvp run --filter @t3tools/web typecheck— cleanmain(5356de110) and re-verified; no overlap with the upstream syncNo screenshots attached: the maintainer asked to ship this directly without a browser pass.
Model: Claude Opus 5 via Claude Code