Tighten Escape agent interrupt shortcut

This commit is contained in:
Mohamed Boudra
2026-04-22 12:52:47 +07:00
parent 6edf19c7c6
commit fc86ce2a5f
9 changed files with 175 additions and 30 deletions
+1
View File
@@ -16,6 +16,7 @@ export type MessageInputKeyboardActionKind =
| "voice-mute-toggle";
export type KeyboardActionId =
| "agent.interrupt"
| "agent.new"
| "workspace.tab.new"
| "workspace.tab.close.current"
@@ -1,6 +1,7 @@
export type KeyboardActionScope = "global" | "message-input" | "sidebar" | "workspace";
export type KeyboardActionId =
| "agent.interrupt"
| "message-input.focus"
| "message-input.send"
| "message-input.dictation-toggle"
@@ -29,6 +30,7 @@ export type KeyboardActionId =
| "worktree.archive";
export type KeyboardActionDefinition =
| { id: "agent.interrupt"; scope: KeyboardActionScope }
| { id: "message-input.focus"; scope: KeyboardActionScope }
| { id: "message-input.send"; scope: KeyboardActionScope }
| { id: "message-input.dictation-toggle"; scope: KeyboardActionScope }
@@ -280,11 +280,10 @@ describe("keyboard-shortcuts", () => {
payload: { kind: "voice-mute-toggle" },
},
{
name: "lets Escape continue to local handlers while routing dictation cancel",
name: "routes Escape to agent interrupt outside terminal focus",
event: { key: "Escape", code: "Escape" },
context: { focusScope: "message-input" },
action: "message-input.action",
payload: { kind: "dictation-cancel" },
action: "agent.interrupt",
preventDefault: false,
stopPropagation: false,
},
@@ -353,6 +352,16 @@ describe("keyboard-shortcuts", () => {
event: { key: "d", code: "KeyD", metaKey: true },
context: { isMac: true, focusScope: "terminal" },
},
{
name: "does not interrupt agent when terminal is focused",
event: { key: "Escape", code: "Escape" },
context: { focusScope: "terminal" },
},
{
name: "does not interrupt agent when command center is open",
event: { key: "Escape", code: "Escape" },
context: { commandCenterOpen: true },
},
{
name: "does not bind pane shortcuts on non-mac platforms",
event: { key: "\\", code: "Backslash", ctrlKey: true },
@@ -869,17 +869,16 @@ const SHORTCUT_BINDINGS: readonly ShortcutBinding[] = [
},
},
{
id: "message-input-dictation-cancel",
action: "message-input.action",
id: "agent-interrupt",
action: "agent.interrupt",
combo: "Escape",
when: { commandCenter: false, terminal: false },
payload: { type: "message-input", kind: "dictation-cancel" },
preventDefault: false,
stopPropagation: false,
help: {
id: "dictation-cancel",
id: "agent-interrupt",
section: "agent-input",
label: "Cancel dictation",
label: "Interrupt agent",
keys: ["Esc"],
},
},