@devries-cameron20 / t3code-1 / commits / 77f08e6b01
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(web): app shortcuts wait while a confirmation dialog is open (#27157)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Seryözha Dmitriev committed Oct 31, 2026 at 01:24 UTC 77f08e6b01e279e79e423375f0eb90677d62b945
2 files changed +29 -1
apps/web/src/shortcuts/dispatcher.browser.test.ts
+19
@@ -111,6 +111,25 @@ describe("command dispatcher", () => {
111 expect(calls).toEqual(["command", "observe:true", "observe:false"]);
112 });
113
114 + it("consumes a command chord pressed inside a confirmation without running its handler", () => {
115 + const command = vi.fn();
116 + const dialog = document.createElement("div");
117 + dialog.setAttribute("role", "alertdialog");
118 + const cancel = document.createElement("button");
119 + dialog.append(cancel);
120 + document.body.append(dialog);
121 + using stack = new DisposableStack();
122 + stack.defer(() => dialog.remove());
123 + stack.defer(registerCommands({ "chat.new": command }, { keybindings }));
124 + cancel.focus();
125 +
126 + const event = new KeyboardEvent("keydown", { key: "k", cancelable: true, bubbles: true });
127 + cancel.dispatchEvent(event);
128 +
129 + expect(command).not.toHaveBeenCalled();
130 + expect(event.defaultPrevented).toBe(true);
131 + });
132 +
133 it("routes a menu action to its newest handler", () => {
134 const older = vi.fn();
135 const newer = vi.fn();
apps/web/src/shortcuts/dispatcher.ts
+10 -1
@@ -53,6 +53,10 @@ function readFocusContext(event: KeyboardEvent): Partial<ShortcutMatchContext> {
53 };
54 }
55
56 +function isInsideConfirmation(target: EventTarget | null): boolean {
57 + return target instanceof Element && target.closest('[role="alertdialog"]') !== null;
58 +}
59 +
60 function runScope(scope: CommandScope, event: KeyboardEvent): boolean {
61 const { commands, options } = scope;
62 if (options.when && !options.when(event)) return false;
@@ -63,7 +67,12 @@ function runScope(scope: CommandScope, event: KeyboardEvent): boolean {
67 { context: { ...readFocusContext(event), ...options.context?.() } },
68 );
69 const handler = command === null ? undefined : commands[command];
66 - return handler !== undefined && handler(event) !== false;
70 + if (handler === undefined) return false;
71 + if (isInsideConfirmation(event.target)) {
72 + event.preventDefault();
73 + return true;
74 + }
75 + return handler(event) !== false;
76 }
77
78 function runScopes(scopes: readonly CommandScope[], event: KeyboardEvent): boolean {