The best way to control Claude Code, Codex and more from any computer or phone
fix(web): the thread menu works for an older settled thread the sidebar hasn't loaded (#32507)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Nov 10, 2026 at 08:31 UTC
30c11a3c74072077e4b65c856f3815e7f30990a9
4 files changed
+79
-12
apps/web/src/components/ChatView.browser.test.tsx
+26
@@ -17,6 +17,7 @@ import {
17
ENVIRONMENT_ID,
18
PROJECT_ID,
19
installFakeEnvironment,
20
+ threadWithHistory,
21
type FakeDriver,
22
} from "../../test/fakeEnvironment";
23
import { render } from "../../test/render";
@@ -65,3 +66,28 @@ it("a new draft does not load its reserved thread before the server lists it", a
66
// A 404 here marks the thread deleted, and the view never loads it once the send creates it.
67
expect(threadRequests).toEqual([]);
68
});
69
+
70
+it("opens the thread actions menu for an older settled thread the shell leaves out", async () => {
71
+ const thread = { ...threadWithHistory("older-settled", 1), olderSettled: true as const };
72
+ using _environment = installFakeEnvironment([thread]);
73
+ __setClientSettingsForTests({
74
+ ...DEFAULT_CLIENT_SETTINGS,
75
+ onboardingCompletedAt: "2026-01-01T00:00:00.000Z",
76
+ });
77
+
78
+ const router = getRouter(
79
+ createMemoryHistory({ initialEntries: [`/${ENVIRONMENT_ID}/${thread.id}`] }),
80
+ );
81
+ await router.load();
82
+ await using _app = await render(<AppRoot router={router} />, {
83
+ // AppRoot brings its own router.
84
+ router: false,
85
+ });
86
+ await expect.element(page.getByText("older-settled: question 0")).toBeVisible();
87
+
88
+ await page.getByRole("button", { name: `Thread actions for ${thread.title}` }).click();
89
+ // Without a bound the poll runs to the test deadline and reports a bare timeout.
90
+ await expect
91
+ .element(page.getByRole("menuitem", { name: "Rename thread" }), { timeout: 5_000 })
92
+ .toBeVisible();
93
+});
apps/web/src/components/ThreadRouteView.tsx
+23
-2
@@ -1,7 +1,8 @@
1
import { useAtomValue } from "@effect/atom-react";
2
-import { scopedThreadKey } from "@t3tools/client-runtime/environment";
2
+import { parseScopedThreadKey, scopedThreadKey } from "@t3tools/client-runtime/environment";
3
import { parseThreadKey, threadKey } from "@t3tools/client-runtime/state/entities";
4
import { visibilityParentKey } from "@t3tools/client-runtime/state/threads";
5
+import type { ScopedThreadRef } from "@t3tools/contracts";
6
import * as Option from "effect/Option";
7
import { Navigate, useNavigate } from "@tanstack/react-router";
8
import { useEffect, useState } from "react";
@@ -16,8 +17,9 @@ import {
17
useAnyEnvironmentHiding,
18
useQuietThreadShell,
19
} from "../state/entities";
20
+import { appAtomRegistry } from "../rpc/atomRegistry";
21
import { useEnvironmentShellStatus } from "../state/shell";
20
-import { environmentThreadShells, useEnvironmentThread } from "../state/threads";
22
+import { environmentThreadShells, threadFamilies, useEnvironmentThread } from "../state/threads";
23
import {
24
buildThreadRouteParams,
25
isThreadRouteSnapshotAuthoritative,
@@ -25,6 +27,24 @@ import {
27
type ThreadRouteTarget,
28
} from "../threadRoutes";
29
30
+/**
31
+ * Keeps the family of an open thread the shell leaves out (an older settled thread) in the shell
32
+ * rows until the route leaves it, so every reader of its shell row finds it.
33
+ */
34
+function useOpenThreadFamily(threadRef: ScopedThreadRef | null, missing: boolean) {
35
+ const key = threadRef === null ? null : scopedThreadKey(threadRef);
36
+ // Sticks to the route thread, so the row the family brings in does not release it.
37
+ const [mountedKey, setMountedKey] = useState<string | null>(null);
38
+ const nextKey = missing || mountedKey === key ? key : null;
39
+ if (nextKey !== mountedKey) setMountedKey(nextKey);
40
+ // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- holds the open thread's family in the thread family registry until the route leaves it
41
+ useEffect(() => {
42
+ const ref = mountedKey === null ? null : parseScopedThreadKey(mountedKey);
43
+ if (ref === null) return;
44
+ return threadFamilies.mount(appAtomRegistry, ref.environmentId, ref.threadId);
45
+ }, [mountedKey]);
46
+}
47
+
48
/**
49
* Unkeyed so navigating between server threads reuses one ChatView. Rendered by the `_chat`
50
* layout, since an element only survives a route swap when the same parent renders it. Draft
@@ -88,6 +108,7 @@ export function ThreadRouteView({
108
unlistedThreadRef?.environmentId ?? null,
109
unlistedThreadRef?.threadId ?? null,
110
);
111
+ useOpenThreadFamily(serverThreadRef, bootstrapComplete && unlistedThreadRef !== null);
112
const hiddenKeys = useAtomValue(environmentThreadShells.hiddenThreadKeysAtom);
113
const unlistedThread = Option.getOrNull(Option.map(unlistedThreadDetail.data, (p) => p.thread));
114
const unlistedParentKey =
apps/web/src/hooks/useThreadActionMenu.ts
+4
-1
@@ -121,7 +121,10 @@ export function useThreadActionMenu(input: {
121
const api = readLocalApi();
122
if (!api) return;
123
const thread = readThreadShell(threadRef);
124
- if (!thread) return;
124
+ if (!thread) {
125
+ failureToast("Thread actions unavailable", new Error("This thread has not loaded yet."));
126
+ return;
127
+ }
128
const now = new Date();
129
const configLoaded = readEnvironmentServerConfigLoaded(threadRef.environmentId);
130
const supports = {
apps/web/test/fakeEnvironment.ts
+26
-9
@@ -68,7 +68,7 @@ const auth = {
68
sessionCookieName: "t3_session",
69
};
70
71
-const serverConfig: ServerConfig = {
71
+const baseServerConfig: ServerConfig = {
72
...Schema.decodeUnknownSync(ServerConfig)({
73
environment: descriptor,
74
auth,
@@ -106,6 +106,11 @@ const serverConfig: ServerConfig = {
106
}),
107
keybindings: DEFAULT_RESOLVED_KEYBINDINGS,
108
};
109
+// A server only leaves threads out of the shell when it serves their families.
110
+const serverConfig = (): ServerConfig =>
111
+ threads.some((thread) => thread.olderSettled)
112
+ ? { ...baseServerConfig, shellThreadFamilies: true }
113
+ : baseServerConfig;
114
115
const project: OrchestrationProjectShell = {
116
id: PROJECT_ID,
@@ -189,6 +194,8 @@ function run(threadId: ThreadId, id: RunId, ordinal: number, userMessageId: stri
194
export interface FakeThread {
195
/** Makes this a side chat of that thread. */
196
readonly sideChatOf?: ThreadId;
197
+ /** Makes this an older settled thread the shell leaves out; only its family read returns it. */
198
+ readonly olderSettled?: true;
199
readonly id: ThreadId;
200
readonly title: string;
201
readonly runs: ReadonlyArray<OrchestrationV2Run>;
@@ -253,8 +260,8 @@ function shellOf(thread: FakeThread): OrchestrationV2ThreadShell {
260
createdAt: AT,
261
updatedAt: AT,
262
archivedAt: null,
256
- settledOverride: null,
257
- settledAt: null,
263
+ settledOverride: thread.olderSettled ? "settled" : null,
264
+ settledAt: thread.olderSettled ? AT : null,
265
lastVisitedAt: AT,
266
deletedAt: null,
267
};
@@ -290,8 +297,8 @@ function projectionOf(thread: FakeThread): OrchestrationV2ThreadProjection {
297
createdAt: AT,
298
updatedAt: AT,
299
archivedAt: null,
293
- settledOverride: null,
294
- settledAt: null,
300
+ settledOverride: shell.settledOverride,
301
+ settledAt: shell.settledAt,
302
lastVisitedAt: AT,
303
deletedAt: null,
304
},
@@ -363,7 +370,7 @@ const handlers: Record<string, (input: never) => unknown> = {
370
schemaVersion: 1,
371
snapshotSequence: sequence,
372
projects: [project],
366
- threads: threads.map(shellOf),
373
+ threads: threads.filter((thread) => !thread.olderSettled).map(shellOf),
374
archivedThreads: [],
375
},
376
},
@@ -387,6 +394,16 @@ const handlers: Record<string, (input: never) => unknown> = {
394
},
395
);
396
},
397
+ [ORCHESTRATION_V2_WS_METHODS.getThreadFamily]: (input: { readonly threadId: ThreadId }) => {
398
+ const rootOf = (thread: FakeThread) => thread.sideChatOf ?? thread.id;
399
+ const requested = threads.find((candidate) => candidate.id === input.threadId);
400
+ return Effect.succeed({
401
+ snapshotSequence: sequence,
402
+ threads: requested
403
+ ? threads.filter((thread) => rootOf(thread) === rootOf(requested)).map(shellOf)
404
+ : [],
405
+ });
406
+ },
407
[WS_METHODS.subscribeVcsStatus]: () =>
408
subscribe<VcsStatusStreamEvent>([], (queue) => {
409
vcsStatusSubscriber = queue;
@@ -395,7 +412,7 @@ const handlers: Record<string, (input: never) => unknown> = {
412
};
413
}),
414
[WS_METHODS.subscribeServerConfig]: () =>
398
- subscribe([{ version: 1 as const, type: "snapshot" as const, config: serverConfig }]),
415
+ subscribe([{ version: 1 as const, type: "snapshot" as const, config: serverConfig() }]),
416
};
417
418
// Unanswered calls stay pending, like a server that has not replied yet.
@@ -410,9 +427,9 @@ const client = new Proxy(handlers, {
427
428
const session: EnvironmentConnectionLease["session"] = {
429
client: client as unknown as WsRpcProtocolClient,
413
- initialConfig: Effect.succeed(serverConfig),
430
+ initialConfig: Effect.sync(serverConfig),
431
subscribeServerConfig: () =>
415
- subscribe([{ version: 1 as const, type: "snapshot" as const, config: serverConfig }]),
432
+ subscribe([{ version: 1 as const, type: "snapshot" as const, config: serverConfig() }]),
433
ready: Effect.void,
434
probe: Effect.void,
435
inboundFrames: Effect.succeed(0),