fix(desktop): workspace shortcuts follow the current route under React Compiler
What & why
⌘⇧Delete (Close Workspace) and ⌘⌥↑/↓ (Previous/Next Workspace) stopped working after React Compiler was enabled for the renderer in #9582.
The router's useMatchRoute() returns one stable function and re-renders the caller through a separate subscription. The compiler caches matchRoute({ to: "/v2-workspace/$workspaceId" }) on the function's identity, so the result from the first render is reused forever:
if ($[4] !== matchRoute) { t2 = matchRoute({ to: "/v2-workspace/$workspaceId", fuzzy: true }); ... } else { t2 = $[5]; }
The dashboard layout and the sidebar shortcut hook therefore kept the route the app booted on. Booted on a non-workspace screen: Close Workspace is disabled and Previous/Next return early.
How it works
- New
renderer/hooks/useMatchRoute: wraps the router hook, is marked"use no memo", and returns a new function whenever the route changes, which invalidates the compiler's cache. - All 23 files that called the router's
useMatchRoutenow import this one. Each is a one-line import change. They share the same cached-result pattern (sidebar active states, command palette context, new-workspace project preselection). - One line added to a test fixture's router mock.
How I tested it
Dev app from this branch, driven over CDP with real key input. Same journey before and after: boot on New Workspace, click a workspace in the sidebar, press the chords.
| Chord | Before (main) | After |
|---|---|---|
| ⌘⌥↓ | Handler ran, route did not change | Route moved to the next workspace |
| ⌘⌥↑ | Not pressed | Route moved back |
| ⌘⇧Delete | No dialog, key event not consumed | Delete workspace dialog for the current workspace |
Only the two reported shortcut paths were reproduced and verified live. The other call sites are changed by inference from the compiled output, not checked one by one.
bun run typecheck(desktop): passbiome check src/renderer: passbun teston hotkeys, DashboardSidebar, commandPalette: 393 pass
No new unit test: bun test runs uncompiled source, so it cannot fail on this bug.
Follow-up (not in this PR)
The same compiler pattern affects other stable handles: router.history.canGoBack() in NavigationControls (confirmed live), table.getRowModel() in the tasks table, the useSharedFileDocument handle in the file pane, and tiptap editor.isActive(). A full scan runs separately.
Checklist
- PR title follows conventional commits (
type(scope): subject) -
bun run lintandbun run typecheckpass (CI fails on lint warnings too)
Summary by cubic
Fixes the workspace shortcuts — ⌘⇧Delete (Close Workspace) and ⌘⌥↑/↓ (Previous/Next Workspace) — that stopped working after React Compiler was enabled. They were stuck matching the route from first render.
Root cause and fix
- React Compiler cached
matchRoute()results on the router's stableuseMatchRoutefunction identity, so route-aware code never re-ran after navigation. - Adds
renderer/hooks/useMatchRoute, opted out of the compiler, which returns a new function on every route change; all 23 call sites now use it.
Summary by CodeRabbit
- Refactor
- Standardized route matching across the desktop app with a shared hook. No user-visible behavior changes are noted.