The best way to control Claude Code, Codex and more from any computer or phone
fix(web,mobile): @ picker finds older settled threads on linked machines (#37243)
Co-authored-by: Grok 4.7 <noreply@x.ai> Co-authored-by: Julius Marminge <julius0216@outlook.com>
Wout Stiens committed
Nov 15, 2026 at 16:10 UTC
256dce7f1f6c6e051c0b5b432376b196e70385d8
3 files changed
+149
-4
apps/mobile/src/features/threads/use-composer-command-menu.ts
+3
-2
@@ -343,9 +343,10 @@ export function useComposerCommandMenu({
343
cwd: trigger?.kind === "path" ? projectCwd : null,
344
query: trigger?.kind === "path" ? trigger.query : null,
345
});
346
- // Mounts older settled threads matching the mention, which shells may leave out.
346
+ // Mounts older settled threads matching the mention, here and on linked machines, which shells
347
+ // may leave out.
348
useThreadSearch(
348
- trigger?.kind === "path" && environmentId ? [environmentId] : [],
349
+ trigger?.kind === "path" && environmentId ? [environmentId, ...linkedEnvironments.keys()] : [],
350
trigger?.kind === "path" ? trigger.query : "",
351
{ titlesOnly: true },
352
);
apps/web/src/components/chat/useComposerMenuItems.ts
+7
-2
@@ -123,8 +123,13 @@ export function useComposerMenuItems({
123
pullRequestTextQuery === debouncedPullRequestTextQuery ? pullRequestTextQuery : null;
124
const isPathTrigger = composerTriggerKind === "path";
125
const environmentThreadShells = useVisibleThreadShells(isPathTrigger);
126
- // Mounts older settled threads matching the mention, which shells may leave out.
127
- useThreadSearch(isPathTrigger ? [environmentId] : [], pathTriggerQuery, { titlesOnly: true });
126
+ // Mounts older settled threads matching the mention, here and on linked machines, which shells
127
+ // may leave out.
128
+ useThreadSearch(
129
+ isPathTrigger ? [environmentId, ...linkedEnvironments.keys()] : [],
130
+ pathTriggerQuery,
131
+ { titlesOnly: true },
132
+ );
133
// The user's machines feed `@` machine matches; the catalog summary is cheap and stable.
134
const environmentIdentities = useEnvironmentIdentities();
135
const environmentMachines = useEnvironmentMachines();
scripts/scenarios/mention-finds-older-linked-thread.e2e.ts
new
+139
@@ -0,0 +1,139 @@
1
+import * as NodeCrypto from "@effect/platform-node/NodeCrypto";
2
+import * as NodeWS from "@effect/platform-node/NodeWS";
3
+import {
4
+ CommandId,
5
+ ORCHESTRATION_PROTOCOL_VERSION,
6
+ ThreadId,
7
+ WsRpcGroup,
8
+} from "@t3tools/contracts";
9
+import { expect } from "e2e";
10
+import * as SecureRandom from "effect/crypto/SecureRandom";
11
+import * as Effect from "effect/Effect";
12
+import * as Layer from "effect/Layer";
13
+import * as Schema from "effect/Schema";
14
+import { FetchHttpClient, HttpClient, HttpClientRequest, HttpClientResponse } from "effect/http";
15
+import { RpcClient, RpcSerialization } from "effect/rpc";
16
+import { Socket } from "effect/socket";
17
+
18
+import { T3_HOME } from "../e2e.config.ts";
19
+import { SECOND_HOME, startSecondServer } from "./second-server.ts";
20
+import { makeState, runPromise, test, WEB } from "./t3.ts";
21
+
22
+// A shell keeps an environment's 25 newest settled threads; older ones come from search.
23
+const NEWER_SETTLED = 25;
24
+
25
+/** The typed RPC client of the server on `home` at `origin`, signed in through its own CLI. */
26
+const rpcClient = Effect.fn("scenario.rpcClient")(function* (home: string, origin: string) {
27
+ const issued = yield* makeState(home).cli(["auth", "session", "issue", "--token-only"]);
28
+ const { ticket } = yield* HttpClient.execute(
29
+ HttpClientRequest.post(`${origin}/api/auth/websocket-ticket`).pipe(
30
+ HttpClientRequest.bearerToken(issued.stdout.trim()),
31
+ ),
32
+ ).pipe(
33
+ Effect.flatMap(HttpClientResponse.filterStatusOk),
34
+ Effect.flatMap(HttpClientResponse.schemaBodyJson(Schema.Struct({ ticket: Schema.String }))),
35
+ Effect.provide(FetchHttpClient.layer),
36
+ );
37
+ // Built into the caller's scope: `Effect.provide` would close the socket once `make` returns.
38
+ const protocol = yield* Layer.build(
39
+ RpcClient.layerProtocolSocket().pipe(
40
+ Layer.provide(
41
+ Socket.layerWebSocket(
42
+ `${origin.replace(/^http/, "ws")}/ws?orchestrationProtocol=${ORCHESTRATION_PROTOCOL_VERSION}&wsTicket=${encodeURIComponent(ticket)}`,
43
+ ),
44
+ ),
45
+ Layer.provide(RpcSerialization.layerJson),
46
+ Layer.provide(NodeWS.layerWebSocketConstructor),
47
+ ),
48
+ );
49
+ return yield* RpcClient.make(WsRpcGroup).pipe(Effect.provideContext(protocol));
50
+});
51
+
52
+const uuid = Effect.flatMap(SecureRandom.SecureRandom, (random) => random.uuidV4());
53
+const decodePairing = Schema.decodeEffect(
54
+ Schema.fromJsonString(Schema.Struct({ credential: Schema.String })),
55
+);
56
+
57
+const settle = Effect.fn("scenario.settle")(
58
+ function* (home: string, origin: string, threadIds: ReadonlyArray<string>) {
59
+ const client = yield* rpcClient(home, origin);
60
+ for (const threadId of threadIds) {
61
+ yield* client["orchestration.dispatchCommand"]({
62
+ type: "thread.settle",
63
+ commandId: CommandId.make(yield* uuid),
64
+ threadId: ThreadId.make(threadId),
65
+ });
66
+ }
67
+ },
68
+ Effect.scoped,
69
+ Effect.provide(NodeCrypto.layer),
70
+);
71
+
72
+/** Turns the Linked environments beta on for both servers and links the first to the second. */
73
+const linkEnvironments = Effect.fn("scenario.linkEnvironments")(function* (
74
+ primaryOrigin: string,
75
+ secondOrigin: string,
76
+) {
77
+ const primary = yield* rpcClient(T3_HOME, primaryOrigin);
78
+ const second = yield* rpcClient(SECOND_HOME, secondOrigin);
79
+ for (const client of [primary, second]) {
80
+ yield* client["server.updateSettings"]({ patch: { linkedEnvironmentsEnabled: true } });
81
+ }
82
+ const pairing = yield* makeState(SECOND_HOME).cli(["auth", "pairing", "create", "--json"]);
83
+ const { credential } = yield* decodePairing(pairing.stdout);
84
+ yield* primary["peerLinks.link"]({
85
+ url: secondOrigin,
86
+ pairingCode: credential,
87
+ access: "approval-required",
88
+ });
89
+}, Effect.scoped);
90
+
91
+test(
92
+ "The @ picker finds an older settled thread on a linked machine",
93
+ WEB,
94
+ async ({ t3, app, screen }) => {
95
+ const project = await t3.project("primary");
96
+ const current = await t3.thread({ project, title: "Current work", messages: ["first"] });
97
+ const server = startSecondServer(app.baseUrl ?? "");
98
+ try {
99
+ const { host, token } = await server.ready;
100
+ await runPromise(linkEnvironments(app.baseUrl ?? "", host));
101
+ const second = makeState(SECOND_HOME).state;
102
+ const linkedProject = await second.project("linked");
103
+ // Settled first, so the newer ones push it out of the linked machine's shell.
104
+ const titles = [
105
+ "Ancient design notes",
106
+ ...Array.from({ length: NEWER_SETTLED }, (_, index) => `Newer ${index + 1}`),
107
+ ];
108
+ const threadIds: Array<string> = [];
109
+ for (const title of titles) {
110
+ threadIds.push(
111
+ (await second.thread({ project: linkedProject, title, messages: ["first"] })).threadId,
112
+ );
113
+ }
114
+ await runPromise(settle(SECOND_HOME, host, threadIds));
115
+
116
+ await t3.open("/settings/connections");
117
+ await screen.getByRole("button", "Add environment").tap();
118
+ const dialog = screen.getByRole("dialog");
119
+ await dialog.getByPlaceholder("backend.example.com").fill(host);
120
+ await dialog.getByPlaceholder("PAIRCODE").fill(token);
121
+ await dialog.getByRole("button", "Add environment").tap();
122
+ await expect(screen.getByRole("button", "More actions for Scenario")).toBeVisible({
123
+ timeout: 60_000,
124
+ });
125
+
126
+ await t3.open(current);
127
+ await screen.getByRole("textbox").fill("@Ancient");
128
+ try {
129
+ await expect(
130
+ screen.getByRole("option", "Ancient design notes Thread on Scenario", { exact: false }),
131
+ ).toBeVisible();
132
+ } finally {
133
+ await app.screenshot("ancient-mention");
134
+ }
135
+ } finally {
136
+ await server.stop();
137
+ }
138
+ },
139
+);