Repository navigation
refactor(app): session-route decomposition — 6 hook extractions, -551 lines - #2200
Merged
Merged
Conversation
session-route.tsx and settings-route.tsx each carried a private copy of the route-workspace helper family (RouteWorkspace, mapDesktopWorkspace, workspaceLabel, mergeRouteWorkspaces, toSessionGroups, getSessionStatus, isActiveSessionStatus, describe*Error, export/download helpers, folderNameFromPath) — and the copies had drifted: - settings-route was MISSING the mergeRouteWorkspaces fix that stops stale local-server registrations from clobbering desktop remote workspaces' routing fields (a latent settings-route bug, now fixed by unification) - settings-route used older getSessionStatus (no normalizeSessionStatus) and isActiveSessionStatus (no 'streaming') One canonical copy now lives in shell/route-workspaces.ts (the newer session-route behavior). settings' toSessionGroups call passes an empty loading set, preserving its previous output exactly. session-route: 3,328 -> 3,161 lines; settings-route: 2,595 -> 2,472. Tested: - pnpm typecheck clean; bun test tests/ 58 pass - pnpm build clean - live: vite serves both routes' new module graph (200) - pnpm test:e2e — 23/23 assertions ok (real app + opencode binary)
Permissions/questions/todos cluster (~170 lines: busy state, query-cache subscriptions, snapshot seed effects, reply handlers) moves verbatim to domains/session/sync/use-session-interactions.ts. Nothing in the component read this cluster's internals except the JSX, so the seam is a single hook call with four stable inputs (client, workspaceId, sessionId, workspaceRoot). The generic useQueryCacheState helper moves to infra/query-cache-state.ts next to the query-client singleton. session-route.tsx: 3,161 -> 3,020 lines (3,328 at phase start). Tested: - pnpm typecheck clean; bun test tests/ 58 pass - pnpm build clean - pnpm test:e2e — 23/23 assertions ok (boots real app, exercises sessions, permissions among them)
The OpenWork Models startup promo (one-shot latch, promo-hidden listener, schedule effect, subscribe/continue handlers) moves verbatim to domains/cloud/use-openwork-models-startup-promo.ts. The hook self-acquires denAuth/platform/navigate/shellConfig (same pattern as use-den-session) and takes clientReady/workspaceId/providerConnectedIds as inputs. session-route.tsx: 3,020 -> 2,973 lines. Tested: pnpm typecheck clean; bun test 58 pass; pnpm build clean; pnpm test:e2e 23/23 assertions ok.
Provider-catalog prefetch + reasoning/thinking variant computation move to domains/session/surface/use-model-behavior.ts. The catalog is now properly typed as Record<providerID, Record<modelID, ProviderModel>> instead of Record<string, Record<string, any>> (ProviderModel is exactly ProviderListItem['models'][string], so the SDK shape flows through to getModelBehaviorSummary with no casts). The hook also returns the catalog for the model picker's lazy loader until that extraction lands. session-route.tsx: 2,973 -> 2,934 lines. Tested: pnpm typecheck clean; bun test 58 pass; pnpm build clean; pnpm test:e2e 23/23 assertions ok.
Model picker modal state (open/compact/query/options), the new-providers toast event + pending-localStorage triggers, the lazy option loader with 'Recently added' flagging, and the org-restriction filter move verbatim to domains/session/modals/use-model-picker.ts. The hook self-acquires the desktop-restriction context and exposes raw setters so call sites stay one-line renames. The render watchdog moved below the hook to keep its modelPickerOpen attribution field. session-route.tsx: 2,934 -> 2,815 lines (3,328 at phase start). settings-route still carries its sibling copy of the option loader; adopting this hook there is queued as its own commit. Tested: pnpm typecheck clean; bun test 58 pass; pnpm build clean; pnpm test:e2e 23/23 assertions ok.
Command palette / session search / terminal open-state plus the global Cmd-N/K/J/Shift-F keydown handler (useEffectEvent) move verbatim to shell/use-shell-shortcuts.ts. The hook reads canCreateTask/onCreateTask at event time exactly as before; the call sits after handleCreateTaskInWorkspace so nothing is referenced before declaration, with the render watchdog relocated alongside to keep its panel-state attribution fields. session-route.tsx: 2,815 -> 2,777 lines. Tested: pnpm typecheck clean; bun test 58 pass; pnpm build clean; pnpm test:e2e 23/23 assertions ok.
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This was referenced Jun 12, 2026
Merged
This branch was successfully deployed
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.
What
Phase 2 of the architecture refactor (follow-up to #2199): decomposing the
session-route.tsxgod-component (3,328 lines, 32 effects, one component) into domain hooks. Six extractions, one commit each, every commit independently gated and revertable.c66c4014cshell/route-workspaces.ts— the helper family both routes duplicated (RouteWorkspace, mapDesktopWorkspace, mergeRouteWorkspaces, toSessionGroups, getSessionStatus, describe*Error, export/download helpers)28157d200domains/session/sync/use-session-interactions.ts— permissions/questions/todos (busy state, cache subscriptions, seed effects, reply handlers) + genericinfra/query-cache-state.ts86de215d1domains/cloud/use-openwork-models-startup-promo.ts— startup promo latch539efdf50domains/session/surface/use-model-behavior.ts— provider catalog prefetch + variant pill computationRecord<providerID, Record<modelID, ProviderModel>>instead ofRecord<string, Record<string, any>>2a3339230domains/session/modals/use-model-picker.ts— picker state, lazy option loader, new-provider toast triggers, org-restriction filtering3468f9787shell/use-shell-shortcuts.ts— palette/search/terminal state + global Cmd-N/K/J/Shift-F keydown (useEffectEvent)session-route.tsx: 3,328 → 2,777 lines (-551). All moves are verbatim (behavior-preserving); the only intentional behavior change is settings-route inheriting the newer merge/status helpers (the drift fix called out above).Tests (ran locally after EVERY commit, not just at the end)
Live checks: vite dev server serves the new module graph (200s) per step.
No video: behavior-preserving refactor with no UI change — the per-commit e2e runs are the end-to-end evidence. Reviewer repro: commands above on any commit in the stack.
Follow-ups queued (tracker)
useEngineReload · useWorkspaceSessions (types the session lists, kills ~21
anys) · useWorkspaceModals · useSessionProviderAuth · core useWorkspaceRouteState · settings-route adopts useModelPicker