@devries-cameron20 / t3code-1 / commits / 382312aba8
Fork 0

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

fix(web): the sidebar shortcut honors terminal and preview focus conditions (#29612)

Co-authored-by: maria-rcks <maria@kuuro.net> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Julius Marminge <julius0216@outlook.com>

Alex Southwell committed Nov 15, 2026 at 02:10 UTC 382312aba8fd4b2197d2f902495e5ab765aee3ec
2 files changed +52 -6
apps/web/src/components/AppSidebarLayout.browser.test.tsx new
+42
@@ -0,0 +1,42 @@
1 +import { page, userEvent } from "vite-plus/test/browser";
2 +import { describe, expect, it, vi } from "vite-plus/test";
3 +
4 +import { render } from "../../test/render";
5 +
6 +vi.mock(import("../state/server"), async (original) => {
7 + const actual = await original();
8 + const { Atom } = await import("effect/reactivity");
9 + const { compileResolvedKeybindingsConfig } = await import("@t3tools/shared/keybindings");
10 + const keybindings = compileResolvedKeybindingsConfig([
11 + { key: "mod+b", command: "sidebar.toggle", when: "!terminalFocus" },
12 + ]);
13 + return { ...actual, primaryServerKeybindingsAtom: Atom.make(keybindings) };
14 +});
15 +// The thread list needs live environments; the shortcut lives in the shell around it.
16 +vi.mock(import("./Sidebar"), () => ({ default: (() => null) as never }));
17 +
18 +import { AppSidebarLayout } from "./AppSidebarLayout";
19 +
20 +describe("sidebar toggle shortcut", () => {
21 + it("leaves the key to a focused terminal when its rule excludes terminalFocus", async () => {
22 + await page.viewport(1280, 800);
23 + using _platform = vi.spyOn(navigator, "platform", "get").mockReturnValue("Linux x86_64");
24 + await using screen = await render(
25 + <AppSidebarLayout>
26 + <div data-terminal-owner="drawer">
27 + <textarea aria-label="Terminal input" />
28 + </div>
29 + <button type="button">Outside</button>
30 + </AppSidebarLayout>,
31 + );
32 + const wrapper = screen.container.querySelector('[data-slot="sidebar-wrapper"]')!;
33 +
34 + await userEvent.click(screen.getByRole("textbox", { name: "Terminal input" }));
35 + await userEvent.keyboard("{Control>}b{/Control}");
36 + expect(wrapper.getAttribute("data-sidebar-state")).toBe("expanded");
37 +
38 + await userEvent.click(screen.getByRole("button", { name: "Outside" }));
39 + await userEvent.keyboard("{Control>}b{/Control}");
40 + await vi.waitFor(() => expect(wrapper.getAttribute("data-sidebar-state")).toBe("collapsed"));
41 + });
42 +});
apps/web/src/components/AppSidebarLayout.tsx
+10 -6
@@ -347,11 +347,15 @@ function SidebarControl({ showSidebar }: { readonly showSidebar: boolean }) {
347 // the toggle stays available everywhere else.
348 return;
349 }
350 - if (
351 - resolveShortcutCommand(event, keybindings, { context: { usagePageOpen } }) !==
352 - "sidebar.toggle"
353 - )
354 - return;
350 + const command = resolveShortcutCommand(event, keybindings, {
351 + context: {
352 + terminalFocus: isTerminalFocused(),
353 + previewFocus: isPreviewFocused(),
354 + ...readRoutePanelsOpen(router),
355 + usagePageOpen,
356 + },
357 + });
358 + if (command !== "sidebar.toggle") return;
359
360 event.preventDefault();
361 event.stopPropagation();
@@ -366,7 +370,7 @@ function SidebarControl({ showSidebar }: { readonly showSidebar: boolean }) {
370 window.removeEventListener("keydown", onKeyDown, true);
371 unsubscribe?.();
372 };
369 - }, [keybindings, showSidebar, toggleSidebar, usagePageOpen]);
373 + }, [keybindings, router, showSidebar, toggleSidebar, usagePageOpen]);
374
375 // The control lives as long as the shell, so it carries the shell's commands. Created
376 // once so re-renders never re-register them.