@devries-cameron20 / t3code-1 / commits / 71dfe27e45
Fork 0

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

fix(web): an untouched sidebar thread rename keeps a title that arrived while it was open (#35174)

Julius Marminge committed Nov 12, 2026 at 03:17 UTC 71dfe27e45b37391eceaa3256ac46028d9179d44
3 files changed +63 -3
apps/web/src/components/Sidebar.browser.test.tsx
+57
@@ -17,6 +17,8 @@ import { useHandleNewThread } from "../hooks/useHandleNewThread";
17 import { __setClientSettingsForTests, getClientSettings } from "../hooks/useSettings";
18 import { useThreadRouteTarget } from "../hooks/useThreadRouteTarget";
19 import { useProjects, useQuietThreadShells } from "../state/entities";
20 +import { readEnvironmentScope, useEnvironmentScope } from "../state/session";
21 +import { useOrchestrationCommand } from "../state/use-orchestration-command";
22 import { useTerminalUiStateStore } from "../terminalUiStateStore";
23 import type { Project } from "../types";
24 import Sidebar from "./Sidebar";
@@ -28,6 +30,8 @@ vi.mock("../state/entities", { spy: true });
30 vi.mock("../hooks/useHandleNewThread", { spy: true });
31 vi.mock("../hooks/useThreadRouteTarget", { spy: true });
32 vi.mock("./sidebar/SidebarThreadRow", { spy: true });
33 +vi.mock("../state/session", { spy: true });
34 +vi.mock("../state/use-orchestration-command", { spy: true });
35 vi.mock(import("../state/server"), async (original) => {
36 const { Atom } = await import("effect/reactivity");
37 const { compileResolvedKeybindingsConfig } = await import("@t3tools/shared/keybindings");
@@ -190,3 +194,56 @@ describe("sidebar render isolation", () => {
194 expect(jumpLabelsSince(beforeRelease)).toEqual([]);
195 });
196 });
197 +
198 +describe("sidebar thread rename", () => {
199 + // regression: #35151 an untouched rename wrote back the title it opened with over a newer one
200 + it.each(["{Enter}", "{Tab}"])(
201 + "ending an untouched rename with %s keeps a title that arrived while it was open",
202 + async (finish) => {
203 + const activeProject = project("active");
204 + const routeThreadRef: ScopedThreadRef = {
205 + environmentId: activeProject.environmentId,
206 + threadId: ThreadId.make("thread-0"),
207 + };
208 + const shellTitled = (title: string) => ({ ...threadShell(activeProject.id, 0), title });
209 + const updateMetadata = vi.fn().mockResolvedValue({ _tag: "Success" });
210 + vi.mocked(useOrchestrationCommand).mockReturnValue(updateMetadata);
211 + vi.mocked(readEnvironmentScope).mockReturnValue(true);
212 + vi.mocked(useEnvironmentScope).mockReturnValue(true);
213 + vi.mocked(useProjects).mockReturnValue([activeProject]);
214 + vi.mocked(useQuietThreadShells).mockReturnValue([shellTitled("Fix the login redirect")]);
215 + vi.mocked(useThreadRouteTarget).mockReturnValue({
216 + kind: "server",
217 + threadRef: routeThreadRef,
218 + });
219 + vi.mocked(useHandleNewThread).mockReturnValue({
220 + activeDraftThread: null,
221 + activeThread: null,
222 + defaultProjectRef: {
223 + environmentId: activeProject.environmentId,
224 + projectId: activeProject.id,
225 + },
226 + defaultProjectFallbackReady: true,
227 + handleNewThread: vi.fn().mockResolvedValue(null),
228 + routeDraftId: null,
229 + routeThreadRef,
230 + });
231 + const tree = () => (
232 + <SidebarProvider>
233 + <Sidebar routeReveal={{ observedKey: null, pendingKey: null }} />
234 + </SidebarProvider>
235 + );
236 + await using screen = await render(tree());
237 + await userEvent.dblClick(screen.getByText("Fix the login redirect").first());
238 + const input = screen.getByRole("textbox", { name: "Thread title" });
239 + await expect.element(input).toHaveValue("Fix the login redirect");
240 +
241 + vi.mocked(useQuietThreadShells).mockReturnValue([shellTitled("Generated title")]);
242 + await screen.rerender(tree());
243 + await userEvent.keyboard(finish);
244 +
245 + await expect.element(input).not.toBeInTheDocument();
246 + expect(updateMetadata).not.toHaveBeenCalled();
247 + },
248 + );
249 +});
apps/web/src/components/Sidebar.tsx
+4 -1
@@ -1040,6 +1040,7 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
1040 ? scopedThreadKey(renamingThreadRef)
1041 : null;
1042 const [renamingTitle, setRenamingTitle] = useState("");
1043 + const renamingOriginalTitleRef = useRef("");
1044 const settlingThreadKeysRef = useRef(new Set<string>());
1045 const threadListRef = useRef<HTMLUListElement | null>(null);
1046 const searchResultsListRef = useRef<HTMLUListElement | null>(null);
@@ -1533,9 +1534,11 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
1534 if (!readEnvironmentScope(threadRef.environmentId, AuthOrchestrationOperateScope)) return;
1535 setRenamingThreadRef(threadRef);
1536 setRenamingTitle(title);
1537 + renamingOriginalTitleRef.current = title;
1538 };
1539 const cancelThreadRename = () => setRenamingThreadRef(null);
1538 - const commitThreadRename = (threadRef: ScopedThreadRef, title: string, originalTitle: string) => {
1540 + const commitThreadRename = (threadRef: ScopedThreadRef, title: string) => {
1541 + const originalTitle = renamingOriginalTitleRef.current;
1542 void (async () => {
1543 if (!readEnvironmentScope(threadRef.environmentId, AuthOrchestrationOperateScope)) return;
1544 const trimmed = title.trim();
apps/web/src/components/sidebar/SidebarThreadRow.tsx
+2 -2
@@ -579,7 +579,7 @@ type SidebarThreadRowProps = {
579 onThreadActivate: (threadRef: ScopedThreadRef) => void;
580 onStartRename: (threadRef: ScopedThreadRef, title: string) => void;
581 onRenameTitleChange: (title: string) => void;
582 - onCommitRename: (threadRef: ScopedThreadRef, title: string, originalTitle: string) => void;
582 + onCommitRename: (threadRef: ScopedThreadRef, title: string) => void;
583 onCancelRename: () => void;
584 isRenaming: boolean;
585 renamingTitle: string;
@@ -1034,7 +1034,7 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThreadRowP
1034 <ThreadRenameInput
1035 title={renamingTitle}
1036 onTitleChange={onRenameTitleChange}
1037 - onCommit={() => onCommitRename(threadRef, renamingTitle, thread.title)}
1037 + onCommit={() => onCommitRename(threadRef, renamingTitle)}
1038 onCancel={onCancelRename}
1039 />
1040 ) : (