Registry Mirror
Skip to content

File tree

‎apps/web/src/components/chat/useChatShortcuts.browser.test.tsx‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@ function ChatWithSideChatPane(props: { ran: string[] }) {
426426
keybindings: [
427427
ctrlAlt("b", "rightPanel.toggle"),
428428
ctrlAlt("k", "rightPanel.close"),
429+
ctrl("j", "terminal.toggle"),
429430
ctrl("x", "thread.stop", true),
430431
],
431432
scriptKeybindings: [],
@@ -444,6 +445,7 @@ function ChatWithSideChatPane(props: { ran: string[] }) {
444445
commands: {
445446
"rightPanel.toggle": () => void props.ran.push("toggle"),
446447
"rightPanel.close": () => void props.ran.push("close"),
448+
"terminal.toggle": () => void props.ran.push("terminal"),
447449
"thread.stop": () => void props.ran.push("stop"),
448450
},
449451
fallback: () => undefined,
@@ -487,7 +489,7 @@ it("leaves the right panel alone while a context menu has focus", async () => {
487489
}
488490
});
489491

490-
it("leaves the right panel alone while a dialog is open", async () => {
492+
it("leaves the right panel and terminal alone while a dialog is open", async () => {
491493
const ran: string[] = [];
492494
const view = (dialogOpen: boolean) => (
493495
<>
@@ -507,6 +509,7 @@ it("leaves the right panel alone while a dialog is open", async () => {
507509
await using screen = await render(view(true), options);
508510
await expect.element(page.getByLabelText("Commit message")).toHaveFocus();
509511
await userEvent.keyboard("{Control>}{Alt>}BK{/Alt}{/Control}");
512+
await userEvent.keyboard("{Control>}j{/Control}");
510513
await userEvent.keyboard("{Control>}{Shift>}X{/Shift}{/Control}");
511514
await vi.waitFor(() => expect(ran).toEqual(["stop"]));
512515

@@ -516,7 +519,8 @@ it("leaves the right panel alone while a dialog is open", async () => {
516519
.not.toBeInTheDocument();
517520
await expect.element(page.getByRole("dialog", { name: "Workspace panel" })).toBeVisible();
518521
await userEvent.keyboard("{Control>}{Alt>}BK{/Alt}{/Control}");
519-
await vi.waitFor(() => expect(ran).toEqual(["stop", "toggle", "close"]));
522+
await userEvent.keyboard("{Control>}j{/Control}");
523+
await vi.waitFor(() => expect(ran).toEqual(["stop", "toggle", "close", "terminal"]));
520524
});
521525

522526
it.each(["video", "audio"] as const)(

‎apps/web/src/components/chat/useChatShortcuts.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,11 @@ export function useChatShortcuts(input: ChatShortcutsInput) {
138138
});
139139
if (!command || (inSideChatPane && !SIDE_CHAT_PANE_COMMANDS.has(command))) return;
140140
if (isRightPanelShortcutBlockedByContextMenu(command)) return;
141-
const isCloseOrToggle = command === "rightPanel.close" || command === "rightPanel.toggle";
142-
if (isCloseOrToggle && document.querySelector(OPEN_LAYER) !== null) return;
141+
const isBlockedByOpenLayer =
142+
command === "rightPanel.close" ||
143+
command === "rightPanel.toggle" ||
144+
command === "terminal.toggle";
145+
if (isBlockedByOpenLayer && document.querySelector(OPEN_LAYER) !== null) return;
143146
const run =
144147
input.commands[command] ??
145148
composerShortcutCommands(input.composerRef, input.branchToolbarRef)[command] ??

0 commit comments

Comments
 (0)