PR #9641 review: keep recent workspaces mounted
Summary
The PR makes desktop workspace switches instant. It removes the per-id remount of the $workspaceId route and keeps up to 8 recent workspace trees mounted (hidden with opacity-0 + inert). Hovering a sidebar row prewarms a tree, and the 4 most recent are prewarmed at startup. A mouse-down on a row swaps the visible tree before the click navigates. Most of the remaining diff gates global side effects in hidden trees (hotkeys, title bar slots, menu events, polls, webviews), and holds back terminal/chat/browser panes in trees that were never opened. It also includes smaller trace fixes: shared host-project fan-out providers, a data-overlay-open attribute instead of a body:has() selector, and a deferred diff viewer mount.
Verdict
minor issues The approach is sound and carefully gated, and CI is green. But hidden opened workspaces keep their terminals attached and rendering, which bypasses the existing parked-terminal cap. This should be addressed or at least decided on purpose before merge.
Findings
apps/desktop/src/renderer/routes/_authenticated/_dashboard/stores/keptWorkspacesStore/keptWorkspacesStore.ts:9 (HIDDEN_CLASS) with v2-workspace/$workspaceId/hooks/usePaneRegistry/components/TerminalPane/TerminalPane.tsx:255
What is wrong: Before this PR, a workspace switch unmounted TerminalPane, which calls terminalRuntimeRegistry.detach. That parked the xterm runtime, and the user-configurable parked-runtime LRU cap (terminal-runtime-registry.ts:79, SUPER-1545) bounded how many stayed alive. Now terminals in hidden but opened workspaces stay attached, so they never count as parked and the cap never evicts them. The wrapper is opacity-0 and still on screen, so xterm's IntersectionObserver does not pause rendering. Every hidden terminal keeps drawing agent output, keeps its WebGL context (Chromium keeps only about 16; the oldest is lost and that terminal falls back to the slower DOM renderer), and is laid out again on every window resize. 8 workspaces with a few agent terminals each can be more than the cap allowed before.
Fix: Park terminals when useIsScreenActive() is false, the same way usePersistentWebview now detaches webviews: detach on hide, then mount again on show (the registry already reparents warm runtimes). Another option is to hide wrappers with content-visibility: hidden / visibility: hidden so observers and paint stop. At minimum, mention the interaction with the parked cap under Known Limitations.
apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/page.tsx:162, imported at layout.tsx:50
What is wrong: V2WorkspacePage is now exported from a route file and imported by the layout. With autoCodeSplitting: true, the router plugin warns on every dev build: “These exports from …/$workspaceId/page.tsx will not be code-split and will increase your bundle size: V2WorkspacePage” (seen in the desktop dev log at this head). The index route's component also never renders now, because the layout has no <Outlet>. So page.tsx is a route only for validateSearch.
Fix: Move the page body to $workspaceId/components/V2WorkspacePage/ (per AGENTS.md's folder-per-component rule) and import it from there. Keep page.tsx as the route that owns validateSearch, with no exported component.
PR description, “Manual QA Checklist”
What is wrong: The PR says command-palette “Toggle right sidebar”, “/” to focus the composer, the right-sidebar focus hotkey and a malformed /v2-workspace/<id>/<extra> URL were not exercised. isSidebarInteractive() in useRightSidebarHotkeys.ts:21 was also changed to scan all right areas. These paths are now gated only by ScreenActiveContext, and no tests cover them.
Fix: Exercise them once in the app before merge, or add a small test that renders two trees with ScreenActiveContext true/false and asserts that only one handler fires.
Evidence
Surface: Electron desktop, driven over CDP (port 9333). Dev build of this checkout at 71d224d8, renderer http://localhost:3005, local API localhost:3001, signed in (session 200).
Not verified: the workspace swap itself. Every workspace in the signed-in account is a cloud workspace. Opening one through the route wakes its real sandbox, and the run rules forbid creating a local workspace. So I did not open any workspace, and the main claim (8–15 ms paint, kept trees, terminals held back in prewarmed trees, webview hoisting) is not verified here. The tree only renders under the $workspaceId route.

#/new-workspace.
usePressPreview → pressedWorkspaceStore). Hover first added the id to keptWorkspacesStore as {shown:false, usedAt:0} (prewarm).
#/new-workspace, so no navigation happened. No console.error during the gesture.
watchOpenOverlays: data-overlay-open is absent at idle, present while the workspace hover card (role=dialog) is open, and cleared when the hover card closes. The same happens with the model dropdown (opened by click, closed by Escape), where .drag flips between no-drag and drag. The @layer order <style> is the first in <head>.
Questions for the author
- Was keeping hidden terminals attached (instead of parked) a deliberate trade-off for faster return paint? If it was, how does it behave with the user's parked-runtime cap and the WebGL context limit when a heavy user has 8 workspaces with several agent terminals?
- Why
opacity-0rather thanvisibility:hidden/content-visibility:hiddenfor hidden wrappers? Was it measured to make the swap slower? - Do you want
v2-recent-workspacesscoped per organization? It is shared across org switches today.prewarmRecentfilters by known ids, so that only costs some misses.
Test / CI notes
All at 71d224d8:
bunx tsc --noEmit (apps/desktop) exit 0
bun test src/renderer (apps/desktop) 7733 pass, 0 fail (692 files, 40.5s)
bun test (new suites: keptWorkspacesStore, resolveHotkeyEnabled, watchOpenOverlays, persisted-keys)
34 pass, 0 fail
GitHub CI: Lint, Typecheck, Test, Sherif, Vale, Version Sync, Build CLI, deploy previews: all pass
(CodeRabbit pending, cubic skipped)