@devries-cameron20 / t3code-1 / commits / d23f479a87
Fork 0

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

fix(web): right panel shortcuts work while a side chat has focus (#32117)

Julius Marminge committed Nov 14, 2026 at 18:46 UTC d23f479a87f15cab393d68532841bb891cc2f7d7
2 files changed +69 -2
apps/web/src/components/chat/useChatShortcuts.browser.test.tsx
+58
@@ -187,3 +187,61 @@ it("runs a side chat's composer chords only from its composer, and never thread
187 expect(toggles).toEqual(["model"]);
188 expect(stops).toEqual([]);
189 });
190 +
191 +const ctrlAlt = (key: string, command: KeybindingCommand) => ({
192 + command,
193 + shortcut: { key, metaKey: false, ctrlKey: true, shiftKey: false, altKey: true, modKey: false },
194 +});
195 +
196 +// The main chat's window listener while focus sits in a side chat pane in its right panel.
197 +function ChatWithSideChatPane(props: { ran: string[] }) {
198 + useChatShortcuts({
199 + enabled: true,
200 + keybindings: [
201 + ctrlAlt("b", "rightPanel.toggle"),
202 + ctrlAlt("k", "rightPanel.close"),
203 + ctrlShift("x", "thread.stop"),
204 + ],
205 + scriptKeybindings: [],
206 + getShortcutContext: () => shortcutContext,
207 + threadFindActive: false,
208 + composerRef: {
209 + current: {
210 + insertTextAtEnd: (key: string) => {
211 + props.ran.push(`typed ${key}`);
212 + return true;
213 + },
214 + } as Partial<ChatComposerHandle> as ChatComposerHandle,
215 + },
216 + branchToolbarRef: { current: null },
217 + closeThreadFind: () => {},
218 + commands: {
219 + "rightPanel.toggle": () => void props.ran.push("toggle"),
220 + "rightPanel.close": () => void props.ran.push("close"),
221 + "thread.stop": () => void props.ran.push("stop"),
222 + },
223 + fallback: () => undefined,
224 + });
225 + return (
226 + <div data-side-chat-pane>
227 + <div role="region" aria-label="Conversation" tabIndex={0}>
228 + A side chat message
229 + </div>
230 + <textarea aria-label="Message Side chat" />
231 + </div>
232 + );
233 +}
234 +
235 +it("runs right panel commands from inside a side chat pane, but not thread commands", async () => {
236 + const ran: string[] = [];
237 + await using screen = await render(<ChatWithSideChatPane ran={ran} />, options);
238 +
239 + await userEvent.click(screen.getByLabelText("Message Side chat"));
240 + await userEvent.keyboard("{Control>}{Alt>}BK{/Alt}{/Control}");
241 + await userEvent.keyboard("{Control>}{Shift>}X{/Shift}{/Control}");
242 + await userEvent.click(screen.getByRole("region", { name: "Conversation" }));
243 + await userEvent.keyboard("{Control>}{Alt>}B{/Alt}{/Control}");
244 + await userEvent.keyboard("q");
245 +
246 + expect(ran).toEqual(["toggle", "close", "toggle"]);
247 +});
apps/web/src/components/chat/useChatShortcuts.ts
+11 -2
@@ -22,6 +22,13 @@ type ChatShortcutHandler = (context: {
22
23 export type ChatShortcutCommands = Partial<Record<KeybindingCommand, ChatShortcutHandler>>;
24
25 +/** Window-level commands the main chat still runs while focus is in its side chat pane. */
26 +const SIDE_CHAT_PANE_COMMANDS: ReadonlySet<KeybindingCommand> = new Set([
27 + "rightPanel.toggle",
28 + "rightPanel.close",
29 + "rightPanel.toggleMaximized",
30 +]);
31 +
32 interface ChatShortcutsInput {
33 readonly enabled: boolean;
34 /**
@@ -64,12 +71,14 @@ export function useChatShortcuts(input: ChatShortcutsInput) {
71 event.stopPropagation();
72 return;
73 }
67 - if (!input.enabled || isCommandPaletteOpen() || isInSideChatPane(event.target)) return;
74 + if (!input.enabled || isCommandPaletteOpen()) return;
75 + const inSideChatPane = isInSideChatPane(event.target);
76 const terminalFocusOwner = getTerminalFocusOwner();
77 if (event.defaultPrevented && terminalFocusOwner === null) return;
78 const shortcutContext = input.getShortcutContext(event.target);
79
80 if (
81 + !inSideChatPane &&
82 !shortcutContext.terminalFocus &&
83 !shortcutContext.modelPickerOpen &&
84 shouldTypeToFocusComposer(event) &&
@@ -83,7 +92,7 @@ export function useChatShortcuts(input: ChatShortcutsInput) {
92 const command = resolveChatShortcutCommand(event, keybindings, input.scriptKeybindings, {
93 context: shortcutContext,
94 });
86 - if (!command) return;
95 + if (!command || (inSideChatPane && !SIDE_CHAT_PANE_COMMANDS.has(command))) return;
96 const run =
97 input.commands[command] ??
98 composerShortcutCommands(input.composerRef, input.branchToolbarRef)[command] ??