@devries-cameron20 / t3code Mirror · read-only / commits / a31fab93a2
Fork 0

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): focus side-chat composer when selecting its tab (#31360)

Co-authored-by: maria-rcks <maria@kuuro.net> Co-authored-by: Julius Marminge <julius0216@outlook.com>

Joey van Dijk committed Nov 15, 2026 at 03:21 UTC a31fab93a2943f18460dfde12dd1be6884929bd5
3 files changed +56 -1
apps/web/src/components/ChatView.browser.test.tsx
+49
@@ -18,6 +18,7 @@ import { DraftId, useComposerDraftStore } from "~/composerDraftStore";
18 import { selectThreadDiffPanelSelection, useDiffPanelStore } from "~/diffPanelStore";
19 import { __setClientSettingsForTests } from "~/hooks/useSettings";
20 import { environmentContextRecord } from "~/lib/composerContextRecords";
21 +import { startWorkspaceFocus } from "~/lib/workspaceFocus";
22 import { usePromptStashStore } from "~/promptStashStore";
23 import { useRightPanelStore } from "~/rightPanelStore";
24 import { getRouter } from "~/router";
@@ -514,3 +515,51 @@ it("a shortcut conditioned on rightPanelOpen sees the thread's open right panel"
515 await expect.element(page.getByRole("menuitem", { name: /Files/ })).toBeVisible();
516 await expect.element(toggle).toHaveAttribute("aria-pressed", "true");
517 });
518 +
519 +it("selecting a side-chat tab focuses that side chat's composer", async () => {
520 + const parent = threadWithHistory("focus-parent", 1);
521 + // The shell loaded by the file's first test stays; a family read serves side chats added later.
522 + const sideChat = (name: string) => ({
523 + ...threadWithHistory(name, 1),
524 + sideChatOf: parent.id,
525 + olderSettled: true as const,
526 + });
527 + const side = sideChat("focus-side");
528 + const otherSide = sideChat("focus-other-side");
529 + await page.viewport(1400, 900);
530 + using _environment = installFakeEnvironment([parent, side, otherSide]);
531 + __setClientSettingsForTests({
532 + ...DEFAULT_CLIENT_SETTINGS,
533 + onboardingCompletedAt: "2026-01-01T00:00:00.000Z",
534 + });
535 + const parentRef = scopeThreadRef(ENVIRONMENT_ID, parent.id);
536 + useRightPanelStore.getState().openSideChat(parentRef, otherSide.id);
537 + useRightPanelStore.getState().openSideChat(parentRef, side.id);
538 + const router = getRouter(
539 + createMemoryHistory({ initialEntries: [`/${ENVIRONMENT_ID}/${parent.id}`] }),
540 + );
541 + await router.load();
542 + await using screen = await render(<AppRoot router={router} />, {
543 + // AppRoot brings its own router.
544 + router: false,
545 + });
546 + using _focus = { [Symbol.dispose]: startWorkspaceFocus(router) };
547 + const mainEditor = screen.getByRole("textbox", { name: `Message ${parent.title}`, exact: true });
548 + const sideEditor = screen.getByRole("textbox", { name: `Message ${side.title}`, exact: true });
549 + await expect.element(sideEditor).toBeVisible();
550 + await userEvent.click(mainEditor);
551 + await userEvent.keyboard("main draft");
552 +
553 + await userEvent.click(screen.getByRole("button", { name: otherSide.title, exact: true }));
554 + const otherEditor = screen.getByRole("textbox", {
555 + name: `Message ${otherSide.title}`,
556 + exact: true,
557 + });
558 + await expect.element(otherEditor).toHaveFocus();
559 + await userEvent.keyboard("other draft");
560 + await expect.element(otherEditor).toHaveTextContent("other draft");
561 +
562 + await userEvent.click(screen.getByRole("button", { name: side.title, exact: true }));
563 + await expect.element(sideEditor).toHaveFocus();
564 + await expect.element(mainEditor).toHaveTextContent("main draft");
565 +});
apps/web/src/components/chat/SideChatPane.tsx
+1 -1
@@ -127,7 +127,7 @@ export default function SideChatPane(props: {
127 };
128
129 return (
130 - <div data-side-chat-pane className="flex h-full min-h-0 flex-col">
130 + <div data-side-chat-pane={threadId} className="flex h-full min-h-0 flex-col">
131 <div className="flex h-9 shrink-0 items-center gap-1 border-b border-border pr-1 pl-3">
132 <span className="min-w-0 flex-1 truncate text-xs font-medium">
133 {shell?.title ?? "Side chat"}
apps/web/src/components/chat/useRightPanelActions.ts
+6
@@ -204,6 +204,12 @@ export function useRightPanelActions(input: RightPanelActionsInput) {
204 if (surface.kind === "terminal") {
205 focusTerminal(activeThreadRef, surface.activeTerminalId);
206 }
207 + if (surface.kind === "side-chat") {
208 + requestWorkspaceFocus({
209 + area: "panel",
210 + selector: `[data-side-chat-pane="${CSS.escape(surface.threadId)}"] [data-workspace-area="composer"] [contenteditable="true"]`,
211 + });
212 + }
213 if (surface.kind === "diff" && !diffOpen) {
214 onDiffPanelOpen?.();
215 }