fix(app): keep Cmd+T working after switching workspaces
The new-tab menu handler registered itself as `workspace-new-tab-menu:<serverId>:<paneId>`, leaving out the workspace. Pane ids are namespaced per workspace — every workspace's default pane is called "main" — so all workspaces on a host produced the same handler id. The deck keeps several workspaces mounted at once, the dispatcher stores one live handler per id, and useKeyboardActionHandler registers once per id and never re-registers on focus change. So the second workspace to mount evicted the first, and switching back left a mounted, focused workspace with no handler at all: Cmd+T and Cmd+Shift+A/T/C/E silently did nothing until the newer entry expired from the deck. Handler ids are now built from the surface's full identity rather than assembled at the call site, so the workspace can't be dropped again. The three workspace-wide handlers move onto the same constructor; they were already correct, but the shape belongs in one place.
This commit is contained in:
@@ -104,6 +104,7 @@ import { useWorkspaceDirectory } from "@/stores/session-store-hooks";
|
||||
import { useCheckoutStatusQuery } from "@/git/use-status-query";
|
||||
import { TrailingActionScrim } from "@/components/ui/trailing-action-scrim";
|
||||
import { useKeyboardActionHandler } from "@/hooks/use-keyboard-action-handler";
|
||||
import { buildWorkspaceKeyboardHandlerId } from "@/keyboard/handler-id";
|
||||
import type { KeyboardActionDefinition } from "@/keyboard/keyboard-action-dispatcher";
|
||||
|
||||
const DROPDOWN_WIDTH = 220;
|
||||
@@ -1489,7 +1490,12 @@ function ResolvedWorkspaceDesktopTabsRow({
|
||||
);
|
||||
|
||||
useKeyboardActionHandler({
|
||||
handlerId: `workspace-new-tab-menu:${normalizedServerId}:${paneId ?? "main"}`,
|
||||
handlerId: buildWorkspaceKeyboardHandlerId({
|
||||
name: "workspace-new-tab-menu",
|
||||
serverId: normalizedServerId,
|
||||
workspaceId: normalizedWorkspaceId,
|
||||
paneId,
|
||||
}),
|
||||
actions: [
|
||||
"workspace.tab.menu.open",
|
||||
"workspace.tab.target.agent",
|
||||
|
||||
@@ -67,6 +67,7 @@ import {
|
||||
type WorkspaceTabTarget,
|
||||
} from "@/workspace-tabs/model";
|
||||
import { useKeyboardActionHandler } from "@/hooks/use-keyboard-action-handler";
|
||||
import { buildWorkspaceKeyboardHandlerId } from "@/keyboard/handler-id";
|
||||
import type { KeyboardActionDefinition } from "@/keyboard/keyboard-action-dispatcher";
|
||||
import { useCreateFlowStore } from "@/stores/create-flow-store";
|
||||
import {
|
||||
@@ -3042,7 +3043,11 @@ function WorkspaceScreenContent({
|
||||
);
|
||||
|
||||
useKeyboardActionHandler({
|
||||
handlerId: `workspace-tab-actions:${normalizedServerId}:${normalizedWorkspaceId}`,
|
||||
handlerId: buildWorkspaceKeyboardHandlerId({
|
||||
name: "workspace-tab-actions",
|
||||
serverId: normalizedServerId,
|
||||
workspaceId: normalizedWorkspaceId,
|
||||
}),
|
||||
actions: [
|
||||
"workspace.agent.new",
|
||||
"workspace.tab.close-current",
|
||||
@@ -3058,7 +3063,11 @@ function WorkspaceScreenContent({
|
||||
});
|
||||
|
||||
useKeyboardActionHandler({
|
||||
handlerId: `workspace-pane-actions:${normalizedServerId}:${normalizedWorkspaceId}`,
|
||||
handlerId: buildWorkspaceKeyboardHandlerId({
|
||||
name: "workspace-pane-actions",
|
||||
serverId: normalizedServerId,
|
||||
workspaceId: normalizedWorkspaceId,
|
||||
}),
|
||||
actions: [
|
||||
"workspace.pane.split.right",
|
||||
"workspace.pane.split.down",
|
||||
@@ -3080,7 +3089,11 @@ function WorkspaceScreenContent({
|
||||
});
|
||||
|
||||
useKeyboardActionHandler({
|
||||
handlerId: `workspace-sidebar-actions:${normalizedServerId}:${normalizedWorkspaceId}`,
|
||||
handlerId: buildWorkspaceKeyboardHandlerId({
|
||||
name: "workspace-sidebar-actions",
|
||||
serverId: normalizedServerId,
|
||||
workspaceId: normalizedWorkspaceId,
|
||||
}),
|
||||
actions: ["sidebar.toggle.right"] as const,
|
||||
enabled: Boolean(isRouteFocused && normalizedServerId && normalizedWorkspaceId),
|
||||
priority: 100,
|
||||
|
||||
Reference in New Issue
Block a user