The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 12:15 UTC
fix(web): honor right panel state in custom shortcuts (#34081)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
César Bahena committed
Nov 14, 2026 at 19:57 UTC
4dec8cf64169f6ba7f97b7c34887d9c021db15f7
4 files changed
+47
-3
apps/web/src/components/ChatView.browser.test.tsx
+38
@@ -2,6 +2,10 @@ import { createMemoryHistory } from "@tanstack/react-router";
2
import { scopeProjectRef, scopeThreadRef } from "@t3tools/client-runtime/environment";
3
import { EnvironmentId, RunId, ThreadId } from "@t3tools/contracts";
4
import { DEFAULT_CLIENT_SETTINGS } from "@t3tools/contracts/settings";
5
+import {
6
+ compileResolvedKeybindingsConfig,
7
+ mergeWithDefaultKeybindings,
8
+} from "@t3tools/shared/keybindings";
9
import type * as Context from "effect/Context";
10
import { expect, it, vi } from "vite-plus/test";
11
import { cdp, page, userEvent } from "vite-plus/test/browser";
@@ -476,3 +480,37 @@ it("a mounted thread view lets go of the thread structures it has replaced", asy
480
const kept = shown.slice(0, -2).flatMap((structure, round) => (structure.deref() ? [round] : []));
481
expect(kept).toEqual([]);
482
});
483
+
484
+it("a shortcut conditioned on rightPanelOpen sees the thread's open right panel", async () => {
485
+ await page.viewport(1280, 800);
486
+ const thread = threadWithHistory("thread-panel-shortcut", 1);
487
+ using _environment = installFakeEnvironment([thread], {
488
+ keybindings: mergeWithDefaultKeybindings(
489
+ compileResolvedKeybindingsConfig([
490
+ { key: "ctrl+t", command: "rightPanel.new", when: "rightPanelOpen && !terminalFocus" },
491
+ { key: "ctrl+t", command: "rightPanel.toggle", when: "!rightPanelOpen" },
492
+ ]),
493
+ ),
494
+ });
495
+ __setClientSettingsForTests({
496
+ ...DEFAULT_CLIENT_SETTINGS,
497
+ onboardingCompletedAt: "2026-01-01T00:00:00.000Z",
498
+ });
499
+ const router = getRouter(
500
+ createMemoryHistory({ initialEntries: [`/${ENVIRONMENT_ID}/${thread.id}`] }),
501
+ );
502
+ await router.load();
503
+ await using _app = await render(<AppRoot router={router} />, {
504
+ // AppRoot brings its own router.
505
+ router: false,
506
+ });
507
+ const composer = page.getByTestId("composer-editor");
508
+ const toggle = page.getByRole("button", { name: "Toggle right panel", exact: true });
509
+ await expect.element(toggle).toHaveAttribute("aria-pressed", "false");
510
+ await toggle.click();
511
+ await page.getByRole("button", { name: /^Files/ }).click();
512
+ await composer.click();
513
+ await userEvent.keyboard("{Control>}t{/Control}");
514
+ await expect.element(page.getByRole("menuitem", { name: /Files/ })).toBeVisible();
515
+ await expect.element(toggle).toHaveAttribute("aria-pressed", "true");
516
+});
apps/web/src/components/ChatView.tsx
+1
@@ -2718,6 +2718,7 @@ export default function ChatView(props: ChatViewProps) {
2718
terminalOpen: Boolean(terminalUiState.terminalOpen),
2719
previewFocus: isPreviewFocused(),
2720
previewOpen: previewPanelOpen,
2721
+ rightPanelOpen,
2722
editableFocus: isEditableFocused(eventTarget),
2723
modelPickerOpen: composerRef.current?.isModelPickerOpen() ?? false,
2724
composerFocus:
apps/web/test/fakeEnvironment.ts
+6
-1
@@ -34,6 +34,7 @@ import {
34
type OrchestrationV2ThreadStreamItem,
35
type OrchestrationV2TurnItem,
36
type TerminalMetadataStreamEvent,
37
+ type ResolvedKeybindingsConfig,
38
} from "@t3tools/contracts";
39
import type {
40
ConnectionAttemptError,
@@ -562,6 +563,7 @@ export function installFakeEnvironment(
563
fixtures: ReadonlyArray<FakeThread>,
564
options?: {
565
readonly acceptCommands?: boolean;
566
+ readonly keybindings?: ResolvedKeybindingsConfig;
567
readonly extraProjects?: ReadonlyArray<Pick<OrchestrationProjectShell, "id" | "title">>;
568
/** Commands left unanswered even when accepting, until `rejectPendingCommand`. */
569
readonly holdCommand?: (command: OrchestrationV2Command) => boolean;
@@ -569,7 +571,10 @@ export function installFakeEnvironment(
571
},
572
): Disposable {
573
threads = fixtures;
572
- baseServerConfig = makeServerConfig(options?.providers ?? [CODEX_PROVIDER]);
574
+ baseServerConfig = {
575
+ ...makeServerConfig(options?.providers ?? [CODEX_PROVIDER]),
576
+ keybindings: options?.keybindings ?? DEFAULT_RESOLVED_KEYBINDINGS,
577
+ };
578
dispatched = [];
579
acceptCommands = options?.acceptCommands === true;
580
projects = [
docs/user/keybindings.md
+2
-2
@@ -126,8 +126,8 @@ Join modifiers and a key with `+`, such as `mod+shift+d` or `ctrl+l`.
126
Available context keys are `terminalFocus`, `terminalOpen`, `previewFocus`,
127
`previewOpen`, `rightPanelOpen`, `modelPickerOpen`, `usagePageOpen`, `composerFocus`,
128
`draftThreadRoute`, `turnRunning`, `editableFocus`, `isWeb`, and `isDesktop`.
129
-`rightPanelOpen` applies only to `rightPanel.new` and is true while the right panel is
130
-open; the default `mod+t` uses it to open the panel's new-tab menu.
129
+In a thread, `rightPanelOpen` is true while its right panel is open; the default
130
+`mod+t` uses it to open the panel's new-tab menu.
131
`draftThreadRoute` is true on a draft thread, including a restored draft, until it is first sent.
132
`editableFocus` is true while a text field, the composer, or another editor has
133
the keyboard. `isWeb` is true in a browser tab. `isDesktop` is true in the