From de1f7cf39feb39f8e4fbd282aca55e9253f5faf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20B=C3=B6hm?= <47267007+LukasFB@users.noreply.github.com> Date: Sun, 1 Nov 2026 11:13:33 +0100 Subject: [PATCH 01/11] feat(web): add shortcuts to rename the active thread --- apps/web/src/components/ChatView.tsx | 26 ++++++++++++++++++- apps/web/src/components/chat/ChatHeader.tsx | 9 +++++++ .../settings/KeybindingsSettings.logic.ts | 2 ++ packages/contracts/src/keybindings.ts | 2 ++ 4 files changed, 38 insertions(+), 1 deletion(-) diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx index 1a50e7fdfa6b3..9025e33680719 100644 --- a/apps/web/src/components/ChatView.tsx +++ b/apps/web/src/components/ChatView.tsx @@ -300,7 +300,7 @@ import { NativeChildWorkDialog } from "./chat/NativeChildWorkDialog"; import { ProviderSubagentBar } from "./chat/ProviderSubagentBar"; import { getTriggerDisplayModelName } from "./chat/providerIconUtils"; import { resolveScrollToEndClearance } from "./composerFooterLayout"; -import { ChatHeader } from "./chat/ChatHeader"; +import { ChatHeader, type ChatHeaderHandle } from "./chat/ChatHeader"; import { useSideChat } from "./chat/useSideChat"; import { useRemoteOpenState } from "~/remoteOpen"; import { shouldShowOpenInPicker } from "./chat/OpenInPicker.logic"; @@ -441,6 +441,7 @@ const DismissedFallbackWindowSchema = Schema.NullOr(Schema.String); const ignoreComposerFocus = () => {}; export default function ChatView(props: ChatViewProps) { + const chatHeaderRef = useRef(null); const { environmentId, threadId, @@ -2762,6 +2763,28 @@ export default function ChatView(props: ChatViewProps) { ...terminalShortcuts, ...rightPanelShortcuts, ...threadLifecycleShortcuts, + "thread.rename": ({ event }) => { + if (!isServerThread || !canOperateThread || document.querySelector('[role="dialog"]')) + return false; + if (!event.repeat) chatHeaderRef.current?.startRename(); + }, + "thread.regenerateTitle": ({ event }) => { + if (!isServerThread || !canOperateThread || document.querySelector('[role="dialog"]')) + return false; + if (event.repeat) return; + void updateThreadMetadata({ + environmentId, + input: { threadId: activeThreadId, regenerateTitle: true }, + }).then((result) => { + if (result._tag !== "Failure" || isAtomCommandInterrupted(result)) return; + const error = squashAtomCommandFailure(result); + toastManager.add({ + type: "error", + title: "Failed to regenerate thread title", + description: error instanceof Error ? error.message : "An error occurred.", + }); + }); + }, "thread.copyReference": ({ event }) => { if (!event.repeat) copyActiveThreadReference(); }, @@ -3373,6 +3396,7 @@ export default function ChatView(props: ChatViewProps) { {!rightPanelControlsAtRoot && !rightPanelControlsInPanel ? panelLayoutControls : null} {inlineRightPanelOwnsTitleBar ? threadPanelHeaderControl : null} void; +} + interface ChatHeaderProps { + ref?: Ref; activeThreadEnvironmentId: EnvironmentId; activeThreadId: ThreadId; activeThreadTitle: string; @@ -70,6 +77,7 @@ function resolveRenameCommit(input: { } export const ChatHeader = memo(function ChatHeader({ + ref, activeThreadEnvironmentId, activeThreadId, activeThreadTitle, @@ -171,6 +179,7 @@ export const ChatHeader = memo(function ChatHeader({ title: activeThreadTitle, }); }; + useImperativeHandle(ref, () => ({ startRename })); const commitRename = (title: string) => { setRenaming(null); if (!readEnvironmentScope(activeThreadEnvironmentId, AuthOrchestrationOperateScope)) return; diff --git a/apps/web/src/components/settings/KeybindingsSettings.logic.ts b/apps/web/src/components/settings/KeybindingsSettings.logic.ts index e5db82230a6f0..1b7a47b358494 100644 --- a/apps/web/src/components/settings/KeybindingsSettings.logic.ts +++ b/apps/web/src/components/settings/KeybindingsSettings.logic.ts @@ -382,6 +382,8 @@ export function buildKeybindingCommandOptions( } export function commandLabel(command: KeybindingCommand): string { + if (command === "thread.rename") return "Thread: Rename Active Thread"; + if (command === "thread.regenerateTitle") return "Thread: Regenerate Active Thread Name"; if (command === "workspace.focusNext") return "Focus Next Workspace Area"; if (command === "workspace.focusPrevious") return "Focus Previous Workspace Area"; if (command === "composer.sendAlternate") return "Composer: Opposite Queue or Steer Action"; diff --git a/packages/contracts/src/keybindings.ts b/packages/contracts/src/keybindings.ts index eda5138b760b9..5f0082cd6258a 100644 --- a/packages/contracts/src/keybindings.ts +++ b/packages/contracts/src/keybindings.ts @@ -36,6 +36,8 @@ export type ModelPickerJumpKeybindingCommand = const THREAD_KEYBINDING_COMMANDS = [ "thread.stop", + "thread.rename", + "thread.regenerateTitle", "thread.steerQueuedMessage", "thread.editQueuedMessage", "thread.previous", From 5c31b65f74e998424da5962da3a09421eb9ff8ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20B=C3=B6hm?= <47267007+LukasFB@users.noreply.github.com> Date: Sun, 1 Nov 2026 11:15:54 +0100 Subject: [PATCH 02/11] fix(web): guard title shortcuts without an active thread --- apps/web/src/components/ChatView.tsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx index 9025e33680719..88371492502b8 100644 --- a/apps/web/src/components/ChatView.tsx +++ b/apps/web/src/components/ChatView.tsx @@ -2764,12 +2764,22 @@ export default function ChatView(props: ChatViewProps) { ...rightPanelShortcuts, ...threadLifecycleShortcuts, "thread.rename": ({ event }) => { - if (!isServerThread || !canOperateThread || document.querySelector('[role="dialog"]')) + if ( + !isServerThread || + !activeThreadId || + !canOperateThread || + document.querySelector('[role="dialog"]') + ) return false; if (!event.repeat) chatHeaderRef.current?.startRename(); }, "thread.regenerateTitle": ({ event }) => { - if (!isServerThread || !canOperateThread || document.querySelector('[role="dialog"]')) + if ( + !isServerThread || + !activeThreadId || + !canOperateThread || + document.querySelector('[role="dialog"]') + ) return false; if (event.repeat) return; void updateThreadMetadata({ From d0390a02032bfd62a41f07b23168179abb344205 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20B=C3=B6hm?= <47267007+LukasFB@users.noreply.github.com> Date: Sun, 1 Nov 2026 12:00:15 +0100 Subject: [PATCH 03/11] feat(web): add a shortcut to mark the active thread unread --- apps/web/src/components/chat/useThreadLifecycle.tsx | 7 ++++++- .../src/components/settings/KeybindingsSettings.logic.ts | 1 + packages/contracts/src/keybindings.ts | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/web/src/components/chat/useThreadLifecycle.tsx b/apps/web/src/components/chat/useThreadLifecycle.tsx index 4f27c18b75c7d..3f15df38d5946 100644 --- a/apps/web/src/components/chat/useThreadLifecycle.tsx +++ b/apps/web/src/components/chat/useThreadLifecycle.tsx @@ -181,7 +181,7 @@ export function useThreadLifecycle(input: ThreadLifecycleInput) { } = input; const navigate = useNavigate(); const router = useRouter(); - const { settleThread, pinThread, confirmAndUnpinThread } = useThreadActions(); + const { settleThread, pinThread, confirmAndUnpinThread, markThreadUnread } = useThreadActions(); const canWriteSourceControl = useEnvironmentScope(environmentId, AuthSourceControlWriteScope); const switchGitRef = useAtomCommand(vcsEnvironment.switchRef, { reportFailure: false }); const updateThreadMetadata = useOrchestrationCommand(threadEnvironment.updateMetadata, { @@ -661,6 +661,11 @@ export function useThreadLifecycle(input: ThreadLifecycleInput) { ); }; const shortcuts = { + "thread.markUnread": ({ event }) => { + if (!activeThreadShell || !activeThreadRef || document.querySelector('[role="dialog"]')) + return false; + if (!event.repeat) markThreadUnread(activeThreadRef); + }, "thread.settle": () => { if (!readEnvironmentScope(environmentId, AuthOrchestrationOperateScope)) return false; if (!activeThreadShell || !activeThreadRef || !serverConfigLoaded) return; diff --git a/apps/web/src/components/settings/KeybindingsSettings.logic.ts b/apps/web/src/components/settings/KeybindingsSettings.logic.ts index 1b7a47b358494..7e426fb5f4ab1 100644 --- a/apps/web/src/components/settings/KeybindingsSettings.logic.ts +++ b/apps/web/src/components/settings/KeybindingsSettings.logic.ts @@ -382,6 +382,7 @@ export function buildKeybindingCommandOptions( } export function commandLabel(command: KeybindingCommand): string { + if (command === "thread.markUnread") return "Thread: Mark Active Thread Unread"; if (command === "thread.rename") return "Thread: Rename Active Thread"; if (command === "thread.regenerateTitle") return "Thread: Regenerate Active Thread Name"; if (command === "workspace.focusNext") return "Focus Next Workspace Area"; diff --git a/packages/contracts/src/keybindings.ts b/packages/contracts/src/keybindings.ts index 5f0082cd6258a..50c85c1683f31 100644 --- a/packages/contracts/src/keybindings.ts +++ b/packages/contracts/src/keybindings.ts @@ -38,6 +38,7 @@ const THREAD_KEYBINDING_COMMANDS = [ "thread.stop", "thread.rename", "thread.regenerateTitle", + "thread.markUnread", "thread.steerQueuedMessage", "thread.editQueuedMessage", "thread.previous", From 3d38247007f6dda8a0a3d16f2e1972bd07295223 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20B=C3=B6hm?= <47267007+LukasFB@users.noreply.github.com> Date: Sun, 1 Nov 2026 12:38:32 +0100 Subject: [PATCH 04/11] fix(web): shorten thread keybinding labels --- .../src/components/settings/KeybindingsSettings.logic.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/web/src/components/settings/KeybindingsSettings.logic.ts b/apps/web/src/components/settings/KeybindingsSettings.logic.ts index 7e426fb5f4ab1..0af02b339d365 100644 --- a/apps/web/src/components/settings/KeybindingsSettings.logic.ts +++ b/apps/web/src/components/settings/KeybindingsSettings.logic.ts @@ -382,9 +382,9 @@ export function buildKeybindingCommandOptions( } export function commandLabel(command: KeybindingCommand): string { - if (command === "thread.markUnread") return "Thread: Mark Active Thread Unread"; - if (command === "thread.rename") return "Thread: Rename Active Thread"; - if (command === "thread.regenerateTitle") return "Thread: Regenerate Active Thread Name"; + if (command === "thread.markUnread") return "Thread: Mark Unread"; + if (command === "thread.rename") return "Thread: Rename"; + if (command === "thread.regenerateTitle") return "Thread: Regenerate Name"; if (command === "workspace.focusNext") return "Focus Next Workspace Area"; if (command === "workspace.focusPrevious") return "Focus Previous Workspace Area"; if (command === "composer.sendAlternate") return "Composer: Opposite Queue or Steer Action"; From 8b799fd04881ddc2ed93a13bc7b7e214dc38c24a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20B=C3=B6hm?= <47267007+LukasFB@users.noreply.github.com> Date: Sun, 1 Nov 2026 13:12:37 +0100 Subject: [PATCH 05/11] fix(web): guard thread title shortcuts --- apps/web/src/components/ChatView.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx index 88371492502b8..8e20048f8d130 100644 --- a/apps/web/src/components/ChatView.tsx +++ b/apps/web/src/components/ChatView.tsx @@ -132,6 +132,7 @@ import { useRef, useState, } from "react"; +import { flushSync } from "react-dom"; import { BackgroundThreadContext } from "./chat/backgroundThread"; import { WorkspaceMutationIdContext } from "./chat/ChatMarkdownMedia"; import { useLocation, useNavigate } from "@tanstack/react-router"; @@ -2771,7 +2772,13 @@ export default function ChatView(props: ChatViewProps) { document.querySelector('[role="dialog"]') ) return false; - if (!event.repeat) chatHeaderRef.current?.startRename(); + if (event.repeat) return; + if (activeThreadRef && rightPanelMaximized) { + flushSync(() => { + useRightPanelStore.getState().setMaximized(activeThreadRef, false); + }); + } + chatHeaderRef.current?.startRename(); }, "thread.regenerateTitle": ({ event }) => { if ( @@ -2781,7 +2788,7 @@ export default function ChatView(props: ChatViewProps) { document.querySelector('[role="dialog"]') ) return false; - if (event.repeat) return; + if (event.repeat || activeThreadShell?.titleRegeneration != null) return; void updateThreadMetadata({ environmentId, input: { threadId: activeThreadId, regenerateTitle: true }, From 575ccd4cdf7cdfca8a06fc53da137af063c5320c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20B=C3=B6hm?= <47267007+LukasFB@users.noreply.github.com> Date: Mon, 2 Nov 2026 17:30:47 +0100 Subject: [PATCH 06/11] fix(web): ignore closed dialogs in thread shortcuts Apply the patch provided by @williamconnolly in PR #28630. --- apps/web/src/components/ChatView.tsx | 4 ++-- apps/web/src/components/chat/useThreadLifecycle.tsx | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx index 8e20048f8d130..eee746e39d7a2 100644 --- a/apps/web/src/components/ChatView.tsx +++ b/apps/web/src/components/ChatView.tsx @@ -2769,7 +2769,7 @@ export default function ChatView(props: ChatViewProps) { !isServerThread || !activeThreadId || !canOperateThread || - document.querySelector('[role="dialog"]') + document.querySelector('[role="dialog"]:not([data-closed])') ) return false; if (event.repeat) return; @@ -2785,7 +2785,7 @@ export default function ChatView(props: ChatViewProps) { !isServerThread || !activeThreadId || !canOperateThread || - document.querySelector('[role="dialog"]') + document.querySelector('[role="dialog"]:not([data-closed])') ) return false; if (event.repeat || activeThreadShell?.titleRegeneration != null) return; diff --git a/apps/web/src/components/chat/useThreadLifecycle.tsx b/apps/web/src/components/chat/useThreadLifecycle.tsx index 3f15df38d5946..819729dbf8fea 100644 --- a/apps/web/src/components/chat/useThreadLifecycle.tsx +++ b/apps/web/src/components/chat/useThreadLifecycle.tsx @@ -662,7 +662,11 @@ export function useThreadLifecycle(input: ThreadLifecycleInput) { }; const shortcuts = { "thread.markUnread": ({ event }) => { - if (!activeThreadShell || !activeThreadRef || document.querySelector('[role="dialog"]')) + if ( + !activeThreadShell || + !activeThreadRef || + document.querySelector('[role="dialog"]:not([data-closed])') + ) return false; if (!event.repeat) markThreadUnread(activeThreadRef); }, From 5c46f6d57ebd5ee19a12a28654e9c95fa38c7600 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20B=C3=B6hm?= <47267007+LukasFB@users.noreply.github.com> Date: Tue, 17 Nov 2026 09:39:28 +0100 Subject: [PATCH 07/11] fix(web): block thread shortcuts behind confirmation dialogs --- .../src/components/ChatView.browser.test.tsx | 41 +++++++++++++++++++ apps/web/src/components/ChatView.tsx | 8 +++- .../components/chat/useThreadLifecycle.tsx | 4 +- 3 files changed, 50 insertions(+), 3 deletions(-) diff --git a/apps/web/src/components/ChatView.browser.test.tsx b/apps/web/src/components/ChatView.browser.test.tsx index a0458f9e80280..373d55298b628 100644 --- a/apps/web/src/components/ChatView.browser.test.tsx +++ b/apps/web/src/components/ChatView.browser.test.tsx @@ -581,6 +581,47 @@ it("a mounted thread view lets go of the thread structures it has replaced", asy expect(kept).toEqual([]); }); +it("thread title shortcuts ignore closed dialogs but stop for open dialogs and confirmations", async () => { + const thread = threadWithHistory("thread-title-dialog-guard", 1); + using _environment = installFakeEnvironment([thread], { + keybindings: mergeWithDefaultKeybindings( + compileResolvedKeybindingsConfig([{ key: "ctrl+shift+r", command: "thread.rename" }]), + ), + }); + __setClientSettingsForTests({ + ...DEFAULT_CLIENT_SETTINGS, + onboardingCompletedAt: "2026-01-01T00:00:00.000Z", + }); + const router = getRouter( + createMemoryHistory({ initialEntries: [`/${ENVIRONMENT_ID}/${thread.id}`] }), + ); + await router.load(); + await using screen = await render(, { + // AppRoot brings its own router. + router: false, + }); + using overlays = new DisposableStack(); + const dialog = document.createElement("div"); + document.body.append(dialog); + overlays.defer(() => dialog.remove()); + const composer = screen.getByTestId("composer-editor"); + const title = screen.getByRole("textbox", { name: "Thread title", exact: true }); + for (const role of ["alertdialog", "dialog"]) { + dialog.setAttribute("role", role); + dialog.removeAttribute("data-closed"); + await composer.click(); + await userEvent.keyboard("{Control>}{Shift>}r{/Shift}{/Control}"); + expect(document.querySelector('input[aria-label="Thread title"]')).toBeNull(); + + dialog.setAttribute("data-closed", ""); + await userEvent.keyboard("{Control>}{Shift>}r{/Shift}{/Control}"); + await expect.element(title).toBeVisible(); + await title.click(); + await userEvent.keyboard("{Escape}"); + await expect.element(title).not.toBeInTheDocument(); + } +}); + it("a shortcut conditioned on rightPanelOpen sees the thread's open right panel", async () => { await page.viewport(1280, 800); const thread = threadWithHistory("thread-panel-shortcut", 1); diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx index eee746e39d7a2..67e81e4a0e425 100644 --- a/apps/web/src/components/ChatView.tsx +++ b/apps/web/src/components/ChatView.tsx @@ -2769,7 +2769,9 @@ export default function ChatView(props: ChatViewProps) { !isServerThread || !activeThreadId || !canOperateThread || - document.querySelector('[role="dialog"]:not([data-closed])') + document.querySelector( + '[role="dialog"]:not([data-closed]), [role="alertdialog"]:not([data-closed])', + ) ) return false; if (event.repeat) return; @@ -2785,7 +2787,9 @@ export default function ChatView(props: ChatViewProps) { !isServerThread || !activeThreadId || !canOperateThread || - document.querySelector('[role="dialog"]:not([data-closed])') + document.querySelector( + '[role="dialog"]:not([data-closed]), [role="alertdialog"]:not([data-closed])', + ) ) return false; if (event.repeat || activeThreadShell?.titleRegeneration != null) return; diff --git a/apps/web/src/components/chat/useThreadLifecycle.tsx b/apps/web/src/components/chat/useThreadLifecycle.tsx index 819729dbf8fea..68cb4024af17b 100644 --- a/apps/web/src/components/chat/useThreadLifecycle.tsx +++ b/apps/web/src/components/chat/useThreadLifecycle.tsx @@ -665,7 +665,9 @@ export function useThreadLifecycle(input: ThreadLifecycleInput) { if ( !activeThreadShell || !activeThreadRef || - document.querySelector('[role="dialog"]:not([data-closed])') + document.querySelector( + '[role="dialog"]:not([data-closed]), [role="alertdialog"]:not([data-closed])', + ) ) return false; if (!event.repeat) markThreadUnread(activeThreadRef); From 8aa6160b368de4826c19d85c6f6c3cf179a7f3b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20B=C3=B6hm?= <47267007+LukasFB@users.noreply.github.com> Date: Tue, 17 Nov 2026 09:45:00 +0100 Subject: [PATCH 08/11] test(web): isolate dialog guard from shared shortcut configuration --- .../web/src/components/ChatView.browser.test.tsx | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/apps/web/src/components/ChatView.browser.test.tsx b/apps/web/src/components/ChatView.browser.test.tsx index 373d55298b628..a769ff64e9ea4 100644 --- a/apps/web/src/components/ChatView.browser.test.tsx +++ b/apps/web/src/components/ChatView.browser.test.tsx @@ -26,6 +26,7 @@ import { selectThreadDiffPanelSelection, useDiffPanelStore } from "~/diffPanelSt import { __setClientSettingsForTests } from "~/hooks/useSettings"; import { environmentContextRecord } from "~/lib/composerContextRecords"; import { startWorkspaceFocus } from "~/lib/workspaceFocus"; +import * as keybindingCommands from "~/keybindings"; import { usePromptStashStore } from "~/promptStashStore"; import { useRightPanelStore } from "~/rightPanelStore"; import { getRouter } from "~/router"; @@ -48,6 +49,8 @@ import { } from "../../test/fakeEnvironment"; import { act, fakeTimers, render } from "../../test/render"; +vi.mock(import("~/keybindings"), { spy: true }); + const PNG = Uint8Array.from( atob( "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=", @@ -583,11 +586,7 @@ it("a mounted thread view lets go of the thread structures it has replaced", asy it("thread title shortcuts ignore closed dialogs but stop for open dialogs and confirmations", async () => { const thread = threadWithHistory("thread-title-dialog-guard", 1); - using _environment = installFakeEnvironment([thread], { - keybindings: mergeWithDefaultKeybindings( - compileResolvedKeybindingsConfig([{ key: "ctrl+shift+r", command: "thread.rename" }]), - ), - }); + using _environment = installFakeEnvironment([thread]); __setClientSettingsForTests({ ...DEFAULT_CLIENT_SETTINGS, onboardingCompletedAt: "2026-01-01T00:00:00.000Z", @@ -600,6 +599,13 @@ it("thread title shortcuts ignore closed dialogs but stop for open dialogs and c // AppRoot brings its own router. router: false, }); + using _command = vi + .spyOn(keybindingCommands, "resolveChatShortcutCommand") + .mockImplementation((...args) => + args[0].ctrlKey && args[0].shiftKey && args[0].key.toLowerCase() === "r" + ? "thread.rename" + : null, + ); using overlays = new DisposableStack(); const dialog = document.createElement("div"); document.body.append(dialog); From 84f71e2e503f0a972cd607bdd839bdf1b36065bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20B=C3=B6hm?= <47267007+LukasFB@users.noreply.github.com> Date: Tue, 17 Nov 2026 09:52:48 +0100 Subject: [PATCH 09/11] fix(contracts): remove duplicate thread title shortcut --- packages/contracts/src/keybindings.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/contracts/src/keybindings.ts b/packages/contracts/src/keybindings.ts index 50c85c1683f31..727dc86ff413f 100644 --- a/packages/contracts/src/keybindings.ts +++ b/packages/contracts/src/keybindings.ts @@ -37,7 +37,6 @@ export type ModelPickerJumpKeybindingCommand = const THREAD_KEYBINDING_COMMANDS = [ "thread.stop", "thread.rename", - "thread.regenerateTitle", "thread.markUnread", "thread.steerQueuedMessage", "thread.editQueuedMessage", From 40b288c5059901bb2774ec7a5d1318d73ffcbdfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20B=C3=B6hm?= <47267007+LukasFB@users.noreply.github.com> Date: Tue, 17 Nov 2026 10:10:36 +0100 Subject: [PATCH 10/11] test(web): use browser assertion for thread title guard --- apps/web/src/components/ChatView.browser.test.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/web/src/components/ChatView.browser.test.tsx b/apps/web/src/components/ChatView.browser.test.tsx index a769ff64e9ea4..7ff525626345c 100644 --- a/apps/web/src/components/ChatView.browser.test.tsx +++ b/apps/web/src/components/ChatView.browser.test.tsx @@ -617,7 +617,7 @@ it("thread title shortcuts ignore closed dialogs but stop for open dialogs and c dialog.removeAttribute("data-closed"); await composer.click(); await userEvent.keyboard("{Control>}{Shift>}r{/Shift}{/Control}"); - expect(document.querySelector('input[aria-label="Thread title"]')).toBeNull(); + await expect.element(title).not.toBeInTheDocument(); dialog.setAttribute("data-closed", ""); await userEvent.keyboard("{Control>}{Shift>}r{/Shift}{/Control}"); From a5265a3fd959c6c4655724c078ba1addd36d992c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20B=C3=B6hm?= <47267007+LukasFB@users.noreply.github.com> Date: Tue, 17 Nov 2026 10:51:12 +0100 Subject: [PATCH 11/11] fix(web): preserve narrow panel while renaming a thread --- .../src/components/ChatView.browser.test.tsx | 49 ++++++ apps/web/src/components/ChatView.tsx | 153 +++++++++++------- .../chat/ChatHeader.browser.test.tsx | 10 +- apps/web/src/components/chat/ChatHeader.tsx | 29 +--- 4 files changed, 154 insertions(+), 87 deletions(-) diff --git a/apps/web/src/components/ChatView.browser.test.tsx b/apps/web/src/components/ChatView.browser.test.tsx index 7ff525626345c..9db99ab6a8da2 100644 --- a/apps/web/src/components/ChatView.browser.test.tsx +++ b/apps/web/src/components/ChatView.browser.test.tsx @@ -628,6 +628,55 @@ it("thread title shortcuts ignore closed dialogs but stop for open dialogs and c } }); +it("renaming temporarily hides a maximized narrow panel and restores it on completion", async () => { + await page.viewport(900, 800); + const thread = threadWithHistory("thread-title-panel-focus", 1); + using _environment = installFakeEnvironment([thread]); + const threadRef = scopeThreadRef(ENVIRONMENT_ID, thread.id); + useRightPanelStore.getState().open(threadRef, "diff"); + useRightPanelStore.getState().setMaximized(threadRef, true); + const panelState = useRightPanelStore.getState().byThreadKey; + __setClientSettingsForTests({ + ...DEFAULT_CLIENT_SETTINGS, + onboardingCompletedAt: "2026-01-01T00:00:00.000Z", + }); + const router = getRouter( + createMemoryHistory({ initialEntries: [`/${ENVIRONMENT_ID}/${thread.id}`] }), + ); + await router.load(); + await using screen = await render(, { + // AppRoot brings its own router. + router: false, + }); + using _command = vi + .spyOn(keybindingCommands, "resolveChatShortcutCommand") + .mockImplementation((...args) => + args[0].ctrlKey && args[0].shiftKey && args[0].key.toLowerCase() === "r" + ? "thread.rename" + : null, + ); + await expect + .element(screen.getByRole("button", { name: "Toggle right panel", exact: true })) + .toBeVisible(); + const title = screen.getByRole("textbox", { name: "Thread title", exact: true }); + for (const finish of ["{Escape}", "{Enter}", "blur"]) { + await userEvent.keyboard("{Control>}{Shift>}r{/Shift}{/Control}"); + await expect.element(title).toBeVisible(); + await expect.element(title).toHaveFocus(); + await expect + .element(screen.getByRole("dialog", { name: "Workspace panel" })) + .not.toBeInTheDocument(); + expect(useRightPanelStore.getState().byThreadKey).toEqual(panelState); + if (finish === "blur") await screen.getByTestId("composer-editor").click(); + else await userEvent.keyboard(finish); + await expect.element(title).not.toBeInTheDocument(); + await expect + .element(screen.getByRole("button", { name: "Restore panel size", exact: true })) + .toBeVisible(); + expect(useRightPanelStore.getState().byThreadKey).toEqual(panelState); + } +}); + it("a shortcut conditioned on rightPanelOpen sees the thread's open right panel", async () => { await page.viewport(1280, 800); const thread = threadWithHistory("thread-panel-shortcut", 1); diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx index 67e81e4a0e425..286956d71952c 100644 --- a/apps/web/src/components/ChatView.tsx +++ b/apps/web/src/components/ChatView.tsx @@ -1025,6 +1025,25 @@ export default function ChatView(props: ChatViewProps) { })(); const activeThreadRef = useActiveThreadRef(activeThread); const activeThreadKey = activeThreadRef ? scopedThreadKey(activeThreadRef) : null; + const [renamingTitleState, setRenamingTitleState] = useState<{ + threadKey: string | null; + title: string; + } | null>(null); + if ( + renamingTitleState && + (renamingTitleState.threadKey !== activeThreadKey || !canOperateThread) + ) { + setRenamingTitleState(null); + } + const renamingTitle = + canOperateThread && renamingTitleState && renamingTitleState.threadKey === activeThreadKey + ? renamingTitleState.title + : null; + const handleRenamingTitleChange = (title: string | null) => { + setRenamingTitleState(title === null ? null : { threadKey: activeThreadKey, title }); + }; + const hidePanelForTitleRename = prefersPlanSidebarSheet && renamingTitle !== null; + const activeEnvironmentServerBrowser = useEnvironmentSupportsServerBrowser( activeThreadRef?.environmentId ?? null, ); @@ -1125,7 +1144,10 @@ export default function ChatView(props: ChatViewProps) { const canMaximizeRightPanel = rightPanelOpen; // An embedded side chat has no panel; a stale maximized flag would hide its own column. const rightPanelMaximized = - !embedded && canMaximizeRightPanel && rightPanelState.maximized === true; + !embedded && + !hidePanelForTitleRename && + canMaximizeRightPanel && + rightPanelState.maximized === true; const inlineRightPanelOwnsTitleBar = rightPanelOpen && !shouldUsePlanSidebarSheet; const [threadPanelPopoverHandle] = useState(PopoverCreateHandle); const [chatCanvasStore] = useState(createChatCanvasStore); @@ -2775,7 +2797,7 @@ export default function ChatView(props: ChatViewProps) { ) return false; if (event.repeat) return; - if (activeThreadRef && rightPanelMaximized) { + if (activeThreadRef && rightPanelMaximized && !prefersPlanSidebarSheet) { flushSync(() => { useRightPanelStore.getState().setMaximized(activeThreadRef, false); }); @@ -3422,6 +3444,8 @@ export default function ChatView(props: ChatViewProps) { activeThreadId={activeThread.id} isServerThread={isServerThread} activeThreadTitle={activeThread.title} + renamingTitle={renamingTitle} + onRenamingTitleChange={handleRenamingTitleChange} activeThreadLinkOrigin={activeThreadShell?.linkOrigin?.label ?? null} activeProject={activeProject ?? null} parentThreadLink={headerParentThreadLink} @@ -4035,67 +4059,72 @@ export default function ChatView(props: ChatViewProps) { {rightPanelPresent && activeThreadRef && !embedded ? ( - - - {panelToggleControls} - - ) : null - } - surfaces={renderedRightPanelSurfaces} - environmentId={activeThreadRef.environmentId} - activeSurfaceId={renderedRightPanelSurface?.id ?? null} - pendingSurfaceIds={pendingFileSurfaceIds} - previewSessions={activePreviewState.sessions} - desktopByTabId={activePreviewState.desktopByTabId} - previewRuntimeTabId={resolvePreviewRuntimeTabId} - terminalLabelsById={activeTerminalLabelsById} - onActivate={activateRightPanelSurfaceStable} - onCloseSurface={closeRightPanelSurfaceStable} - onRenameDevice={(surfaceId, title) => { - if (activeThreadRef) - useRightPanelStore.getState().renameDevice(activeThreadRef, surfaceId, title); - }} - onCloseOtherSurfaces={closeOtherRightPanelSurfacesStable} - onCloseSurfacesToRight={closeRightPanelSurfacesToRightStable} - onCloseAllSurfaces={closeAllRightPanelSurfacesStable} - onMoveSurface={moveRightPanelSurfaceStable} - onCopyFilePath={copyRightPanelFilePathStable} - onAddBrowser={() => createBrowserSurface()} - onAddBrowserInProfile={createBrowserSurfaceStable} - onAddTerminal={addTerminalSurfaceStable} - onAddDiff={addDiffSurfaceStable} - onAddFiles={addFilesSurfaceStable} - onAddPullRequest={addPullRequestSurfaceStable} - onAddPullRequests={addPullRequestsSurfaceStable} - onAddDevice={addDeviceSurfaceStable} - onAddSideChat={sideChatsOffered ? openSideChatStable : undefined} - browserAvailable={canOperatePreview && browserAvailable} - terminalAvailable={activeProject !== null && canOperateTerminal} - diffAvailable={isServerThread && isGitRepo} - filesAvailable={activeProject !== null} - pullRequestAvailable={pullRequestSurfaceAvailable} - pullRequestsAvailable={pullRequestsSurfaceAvailable} - deviceAvailable={activeThreadRef !== null} - sideChatAvailable={sideChat.available} - sideChatDisabledReason={sideChatDisabledReason} +
- {rightPanelContent} - + + + {panelToggleControls} +
+ ) : null + } + surfaces={renderedRightPanelSurfaces} + environmentId={activeThreadRef.environmentId} + activeSurfaceId={renderedRightPanelSurface?.id ?? null} + pendingSurfaceIds={pendingFileSurfaceIds} + previewSessions={activePreviewState.sessions} + desktopByTabId={activePreviewState.desktopByTabId} + previewRuntimeTabId={resolvePreviewRuntimeTabId} + terminalLabelsById={activeTerminalLabelsById} + onActivate={activateRightPanelSurfaceStable} + onCloseSurface={closeRightPanelSurfaceStable} + onRenameDevice={(surfaceId, title) => { + if (activeThreadRef) + useRightPanelStore.getState().renameDevice(activeThreadRef, surfaceId, title); + }} + onCloseOtherSurfaces={closeOtherRightPanelSurfacesStable} + onCloseSurfacesToRight={closeRightPanelSurfacesToRightStable} + onCloseAllSurfaces={closeAllRightPanelSurfacesStable} + onMoveSurface={moveRightPanelSurfaceStable} + onCopyFilePath={copyRightPanelFilePathStable} + onAddBrowser={() => createBrowserSurface()} + onAddBrowserInProfile={createBrowserSurfaceStable} + onAddTerminal={addTerminalSurfaceStable} + onAddDiff={addDiffSurfaceStable} + onAddFiles={addFilesSurfaceStable} + onAddPullRequest={addPullRequestSurfaceStable} + onAddPullRequests={addPullRequestsSurfaceStable} + onAddDevice={addDeviceSurfaceStable} + onAddSideChat={sideChatsOffered ? openSideChatStable : undefined} + browserAvailable={canOperatePreview && browserAvailable} + terminalAvailable={activeProject !== null && canOperateTerminal} + diffAvailable={isServerThread && isGitRepo} + filesAvailable={activeProject !== null} + pullRequestAvailable={pullRequestSurfaceAvailable} + pullRequestsAvailable={pullRequestsSurfaceAvailable} + deviceAvailable={activeThreadRef !== null} + sideChatAvailable={sideChat.available} + sideChatDisabledReason={sideChatDisabledReason} + > + {rightPanelContent} +
+ ) : null} ({ import { render, stubGlobal } from "../../../test/render"; import { ChatHeader } from "./ChatHeader"; -function header(title: string) { +function Header({ title }: { title: string }) { + const [renamingTitle, setRenamingTitle] = useState(null); return ( <> ; +} + it.each(["blur", "Enter"] as const)( "preserves a concurrent title update when an untouched rename ends with %s", async (finish) => { diff --git a/apps/web/src/components/chat/ChatHeader.tsx b/apps/web/src/components/chat/ChatHeader.tsx index 8af9bccfeba0f..e5a136491ab9b 100644 --- a/apps/web/src/components/chat/ChatHeader.tsx +++ b/apps/web/src/components/chat/ChatHeader.tsx @@ -55,6 +55,8 @@ interface ChatHeaderProps { activeThreadEnvironmentId: EnvironmentId; activeThreadId: ThreadId; activeThreadTitle: string; + renamingTitle: string | null; + onRenamingTitleChange: (title: string | null) => void; activeThreadLinkOrigin?: string | null | undefined; isServerThread: boolean; activeProject: EnvironmentProject | null; @@ -81,6 +83,8 @@ export const ChatHeader = memo(function ChatHeader({ activeThreadEnvironmentId, activeThreadId, activeThreadTitle, + renamingTitle, + onRenamingTitleChange: setRenaming, activeThreadLinkOrigin, isServerThread, activeProject, @@ -105,25 +109,6 @@ export const ChatHeader = memo(function ChatHeader({ const updateThreadMetadata = useOrchestrationCommand(threadEnvironment.updateMetadata, { reportFailure: false, }); - const [renaming, setRenaming] = useState<{ - threadId: ThreadId; - environmentId: EnvironmentId; - title: string; - } | null>(null); - if ( - renaming !== null && - (renaming.threadId !== activeThreadId || - renaming.environmentId !== activeThreadEnvironmentId || - !canOperateThread) - ) { - setRenaming(null); - } - const renamingTitle = - canOperateThread && - renaming?.threadId === activeThreadId && - renaming.environmentId === activeThreadEnvironmentId - ? renaming.title - : null; const isRenamingTitle = renamingTitle !== null; // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- measures the breadcrumb list DOM via ResizeObserver, a frame and font loads to collapse the parent title useEffect(() => { @@ -173,11 +158,7 @@ export const ChatHeader = memo(function ChatHeader({ ) return; renameCommittedRef.current = false; - setRenaming({ - environmentId: activeThreadEnvironmentId, - threadId: activeThreadId, - title: activeThreadTitle, - }); + setRenaming(activeThreadTitle); }; useImperativeHandle(ref, () => ({ startRename })); const commitRename = (title: string) => {