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 22, 14:30 UTC
feat(web,mobile): the @ picker lists threads on linked machines (#26201)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 27, 2026 at 18:39 UTC
4ab7084aa7fb77b803ddc90a3d7f1baf7ff5fe01
24 files changed
+335
-30
apps/mobile/src/components/ComposerEditor.tsx
+3
@@ -27,6 +27,7 @@ import { startComposerDraftOperation } from "../state/composerDraftOperations";
27
import { appAtomRegistry } from "../state/atom-registry";
28
import { mobilePreferencesAtom } from "../state/preferences";
29
import { useOpenLinkedThread } from "../features/threads/useOpenLinkedThread";
30
+import { useLinkedEnvironments } from "../state/peerLinks";
31
import { ComposerContextSheet } from "./ComposerContextSheet";
32
import { AppText as Text } from "./ui/AppText";
33
import {
@@ -77,6 +78,7 @@ export function ComposerEditor({
78
const [selected, setSelected] = useState<{ source: string; start: number; end: number } | null>(
79
null,
80
);
81
+ const linkedEnvironments = useLinkedEnvironments(environmentId ?? null);
82
const contextImports = useAtomValue(composerContextImportsAtom);
83
const importing = draftKey ? contextImports[draftKey] === true : false;
84
const pasteContext = async (
@@ -101,6 +103,7 @@ export function ComposerEditor({
103
signal,
104
retained.context?.records.length ?? 0,
105
environmentId,
106
+ linkedEnvironments,
107
);
108
if (signal.aborted) return;
109
if (!result) {
apps/mobile/src/features/threads/NewTaskDraftScreen.tsx
+1
@@ -625,6 +625,7 @@ export function NewTaskDraftScreen(props: {
625
text: draft.text,
626
records: draft.context?.records ?? [],
627
environmentId: selectedProject.environmentId,
628
+ linkedEnvironments: flow.linkedEnvironments,
629
})[0];
630
if (strandedThread) {
631
const owner =
apps/mobile/src/features/threads/ThreadComposer.tsx
+2
@@ -67,6 +67,7 @@ import { appAtomRegistry } from "../../state/atom-registry";
67
import type { ComposerDocumentAttachment } from "../../lib/composerContext";
68
import { useProject, useThreadShells } from "../../state/entities";
69
import { useMentionableEnvironments } from "../../state/environments";
70
+import { useLinkedEnvironments } from "../../state/peerLinks";
71
import { scopeProjectRef } from "@t3tools/client-runtime/environment";
72
73
import { AppText as Text } from "../../components/ui/AppText";
@@ -536,6 +537,7 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps
537
environments: offersLinkedEnvironments(props.serverConfig)
538
? mentionableEnvironments
539
: NO_MACHINES,
540
+ linkedEnvironments: useLinkedEnvironments(props.environmentId),
541
currentThreadId: props.selectedThread.id,
542
projectCwd: props.projectCwd,
543
pullRequestProjectId: props.serverConfig?.environment.capabilities.pullRequests
apps/mobile/src/features/threads/new-task-flow-provider.tsx
+6
@@ -36,6 +36,7 @@ import { scopedProjectKey } from "../../lib/scopedEntities";
36
import { useAtomValue } from "@effect/atom-react";
37
import { appAtomRegistry } from "../../state/atom-registry";
38
import { projectEnvironment } from "../../state/projects";
39
+import { useLinkedEnvironments } from "../../state/peerLinks";
40
import { useEnvironmentQuery } from "../../state/query";
41
import { useAtomCommand } from "../../state/use-atom-command";
42
import {
@@ -160,6 +161,8 @@ type NewTaskFlowContextValue = {
161
readonly environmentLabel: string;
162
}>;
163
readonly selectedProject: EnvironmentProject | null;
164
+ /** The machines the selected project's environment links to, whose threads it can read. */
165
+ readonly linkedEnvironments: ReadonlyMap<EnvironmentId, string>;
166
readonly isScratchDraft: boolean;
167
readonly modelOptions: ReadonlyArray<ModelOption>;
168
readonly selectedModel: ModelSelection | null;
@@ -321,6 +324,7 @@ export function NewTaskFlowProvider(
324
projectsForEnvironment[0] ??
325
null);
326
327
+ const linkedEnvironments = useLinkedEnvironments(selectedProject?.environmentId ?? null);
328
const projectDefaults = useNewTaskProjectDefaults(selectedProject);
329
const selectedEnvironmentServerConfig = projectDefaults.serverConfig;
330
const isScratchDraft = projectDefaults.isScratch;
@@ -779,6 +783,7 @@ export function NewTaskFlowProvider(
783
text: draft.text,
784
records: draft.context?.records ?? [],
785
environmentId: selectedProject.environmentId,
786
+ linkedEnvironments,
787
}).length > 0
788
) {
789
return null;
@@ -853,6 +858,7 @@ export function NewTaskFlowProvider(
858
expandedProvider,
859
environments,
860
selectedProject,
861
+ linkedEnvironments,
862
isScratchDraft,
863
modelOptions,
864
selectedModel,
apps/mobile/src/features/threads/use-composer-command-menu.ts
+5
@@ -16,6 +16,7 @@ import type { EnvironmentThreadShell } from "@t3tools/client-runtime/state/model
16
17
const EMPTY_THREAD_SHELLS: ReadonlyArray<EnvironmentThreadShell> = [];
18
const EMPTY_ENVIRONMENTS: ReadonlyArray<ComposerEnvironmentCandidate> = [];
19
+const NO_LINKED_ENVIRONMENTS: ReadonlyMap<EnvironmentId, string> = new Map();
20
import { COMPOSER_CONTEXT_MAX_RECORDS } from "@t3tools/contracts";
21
import { formatComposerContextReference } from "@t3tools/shared/composerContextReferences";
22
import {
@@ -211,6 +212,7 @@ export function useComposerCommandMenu({
212
environmentId,
213
threadShells = EMPTY_THREAD_SHELLS,
214
environments = EMPTY_ENVIRONMENTS,
215
+ linkedEnvironments = NO_LINKED_ENVIRONMENTS,
216
currentThreadId = null,
217
projectCwd,
218
pullRequestProjectId = null,
@@ -230,6 +232,8 @@ export function useComposerCommandMenu({
232
readonly environmentId: EnvironmentId | null;
233
readonly threadShells?: ReadonlyArray<EnvironmentThreadShell>;
234
readonly environments?: ReadonlyArray<ComposerEnvironmentCandidate>;
235
+ /** The machines `environmentId` links to, by name, whose threads the picker also offers. */
236
+ readonly linkedEnvironments?: ReadonlyMap<EnvironmentId, string>;
237
readonly currentThreadId?: ThreadId | null;
238
readonly projectCwd: string | null;
239
readonly pullRequestProjectId?: ProjectId | null;
@@ -459,6 +463,7 @@ export function useComposerCommandMenu({
463
? matchComposerThreadItems({
464
shells: threadShells,
465
environmentId,
466
+ linkedEnvironments,
467
excludeThreadId: currentThreadId,
468
query: trigger.query,
469
now,
apps/mobile/src/lib/composerContextClipboard.test.ts
+16
@@ -295,6 +295,22 @@ describe("mobile context clipboard imports", () => {
295
expect(result!.text).toMatch(/^Compare these findings: .* before changing anything\.$/);
296
});
297
298
+ it("keeps a thread from a machine the destination links to", async () => {
299
+ const result = await importComposerContextClipboard(
300
+ mixedClipboard,
301
+ 0,
302
+ new AbortController().signal,
303
+ 0,
304
+ EnvironmentId.make("destination"),
305
+ new Map([[foreignThread.environmentId, "Source"]]),
306
+ );
307
+ expect(result!.skippedThreads).toEqual([]);
308
+ expect(result!.context.records.filter((record) => record.kind === "thread")).toEqual([
309
+ { ...foreignThread, contextId: expect.any(String) },
310
+ { ...localThread, contextId: expect.any(String) },
311
+ ]);
312
+ });
313
+
314
it("preserves both machines' thread references when pasting without a destination", async () => {
315
const result = await importComposerContextClipboard(
316
mixedClipboard,
apps/mobile/src/lib/composerContextClipboard.ts
+3
@@ -67,6 +67,8 @@ export async function importComposerContextClipboard(
67
signal: AbortSignal,
68
existingContextCount = 0,
69
destinationEnvironmentId?: EnvironmentId,
70
+ /** The machines the destination links to, whose threads its agent can read too. */
71
+ linkedEnvironments: ReadonlyMap<EnvironmentId, string> = new Map(),
72
) {
73
const fragment =
74
decodeComposerContextFragment(input.fragment) ?? decodeComposerContextClipboardHtml(input.html);
@@ -80,6 +82,7 @@ export async function importComposerContextClipboard(
82
text: imported.text,
83
records: imported.context.records,
84
environmentId: destinationEnvironmentId,
85
+ linkedEnvironments,
86
});
87
const skippedIds = new Set(skippedThreads.map((record) => record.contextId));
88
const retained = imported.context.records.filter((record) => !skippedIds.has(record.contextId));
apps/mobile/src/state/peerLinks.ts
+28
-1
@@ -1,5 +1,9 @@
1
import { useAtomValue } from "@effect/atom-react";
2
-import { linkableMachines } from "@t3tools/client-runtime/link-request";
2
+import {
3
+ linkableMachines,
4
+ linkedEnvironmentNames,
5
+ offersLinkedEnvironments,
6
+} from "@t3tools/client-runtime/link-request";
7
import { createPeerLinkEnvironmentAtoms } from "@t3tools/client-runtime/state/peerLinks";
8
import type { EnvironmentId } from "@t3tools/contracts";
9
import { useEffect, useEffectEvent, useMemo } from "react";
@@ -12,6 +16,29 @@ import { useAtomCommand } from "./use-atom-command";
16
17
export const peerLinkEnvironment = createPeerLinkEnvironmentAtoms(connectionAtomRuntime);
18
19
+/**
20
+ * The machines `environmentId` links to, by name, while it offers links, and none otherwise.
21
+ * Its agents can read threads there. Listing asks each linked machine whether it answers, so
22
+ * every caller shares one briefly cached list.
23
+ */
24
+export function useLinkedEnvironments(
25
+ environmentId: EnvironmentId | null,
26
+): ReadonlyMap<EnvironmentId, string> {
27
+ const { environments } = useEnvironments();
28
+ const offered = offersLinkedEnvironments(
29
+ environments.find((environment) => environment.environmentId === environmentId)?.serverConfig,
30
+ );
31
+ const links = useEnvironmentQuery(
32
+ offered && environmentId !== null
33
+ ? peerLinkEnvironment.list({ environmentId, input: {} })
34
+ : null,
35
+ );
36
+ return useMemo(
37
+ () => linkedEnvironmentNames({ links: offered ? (links.data?.links ?? []) : [], environments }),
38
+ [environments, links.data, offered],
39
+ );
40
+}
41
+
42
/**
43
* The user's other machines, for picking one to link `environmentId` to,
44
* including those only on their T3 Connect account. Reads that environment's
apps/web/src/components/chat/ChatComposer.tsx
+7
-1
@@ -176,6 +176,7 @@ import {
176
import { rememberCopiedComposerAttachments } from "~/lib/copiedComposerAttachments";
177
import { useThreadContextDrop, threadContextDropTargetProps } from "./threadContextDrag";
178
import { readThreadShell } from "~/state/entities";
179
+import { useLinkedEnvironments } from "~/state/peerLinks";
180
import { encodeComposerContextFragment } from "@t3tools/shared/composerContextClipboard";
181
import type { ComposerContextRecord, ThreadPullRequestLink } from "@t3tools/contracts";
182
import { threadContextAttachment } from "~/lib/threadContextAttachment";
@@ -1147,6 +1148,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
1148
composerTerminalContexts.length === 0 &&
1149
composerPreviewAnnotations.length === 0 &&
1150
composerReviewComments.length === 0;
1151
+ const linkedEnvironments = useLinkedEnvironments(environmentId);
1152
const {
1153
items: composerMenuItems,
1154
isLoading: isComposerMenuLoading,
@@ -1154,6 +1156,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
1156
} = useComposerMenuItems({
1157
composerTrigger,
1158
environmentId,
1159
+ linkedEnvironments,
1160
gitCwd,
1161
activeThreadId,
1162
pullRequestProjectId,
@@ -1387,6 +1390,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
1390
importContextFragmentStable,
1391
} = useComposerContextImport({
1392
environmentId,
1393
+ linkedEnvironments,
1394
activeThread,
1395
activeThreadId,
1396
composerDraftTarget,
@@ -2879,7 +2883,9 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
2883
2884
useThreadContextDrop(composerFormRef, environmentId, attachmentTargetKey, (refs, isActive) => {
2885
const records = refs.flatMap((ref) => {
2882
- if (ref.environmentId !== environmentId) {
2886
+ // The agent reads a linked machine's thread itself, like the `@` picker's; any other
2887
+ // machine's comes in as its transcript.
2888
+ if (ref.environmentId !== environmentId && !linkedEnvironments.has(ref.environmentId)) {
2889
void importDroppedThread(
2890
ref,
2891
() => isActive() && attachmentTargetKeyRef.current === attachmentTargetKey,
apps/web/src/components/chat/useComposerContextImport.ts
+9
-2
@@ -75,6 +75,7 @@ async function downloadAttachmentBlob(url: string): Promise<Blob | null> {
75
*/
76
export function useComposerContextImport(input: {
77
readonly environmentId: EnvironmentId;
78
+ readonly linkedEnvironments: ReadonlyMap<EnvironmentId, string>;
79
readonly activeThread: ChatComposerProps["activeThread"];
80
readonly activeThreadId: ChatComposerProps["activeThreadId"];
81
readonly composerDraftTarget: ChatComposerProps["composerDraftTarget"];
@@ -91,6 +92,7 @@ export function useComposerContextImport(input: {
92
}) {
93
const {
94
environmentId,
95
+ linkedEnvironments,
96
activeThread,
97
activeThreadId,
98
composerDraftTarget,
@@ -372,8 +374,13 @@ export function useComposerContextImport(input: {
374
break;
375
}
376
case "thread": {
375
- // The agent can only read threads on its own server; a pasted foreign one is dropped.
376
- if (record.environmentId !== environmentId) break;
377
+ // The agent reads threads on its own server and the machines it links to; a pasted
378
+ // thread from any other machine is dropped.
379
+ if (
380
+ record.environmentId !== environmentId &&
381
+ !linkedEnvironments.has(record.environmentId)
382
+ )
383
+ break;
384
addComposerDraftThreadContexts(threadDraftTarget, [record], {
385
appendReference: false,
386
});
apps/web/src/components/chat/useComposerMenuItems.ts
+3
@@ -56,6 +56,7 @@ const EMPTY_PULL_REQUEST_LIST_TARGETS: ReadonlyArray<EnvironmentQueryTarget<Pull
56
export function useComposerMenuItems({
57
composerTrigger,
58
environmentId,
59
+ linkedEnvironments,
60
gitCwd,
61
activeThreadId,
62
pullRequestProjectId,
@@ -71,6 +72,7 @@ export function useComposerMenuItems({
72
}: {
73
readonly composerTrigger: ComposerTrigger | null;
74
readonly environmentId: EnvironmentId;
75
+ readonly linkedEnvironments: ReadonlyMap<EnvironmentId, string>;
76
readonly gitCwd: string | null;
77
readonly activeThreadId: ThreadId | null;
78
readonly pullRequestProjectId: ProjectId | null;
@@ -182,6 +184,7 @@ export function useComposerMenuItems({
184
...matchComposerThreadItems({
185
shells: environmentThreadShells,
186
environmentId,
187
+ linkedEnvironments,
188
excludeThreadId: activeThreadId,
189
query: composerTrigger.query,
190
now,
apps/web/src/components/chat/useComposerSend.ts
+3
@@ -105,6 +105,7 @@ import {
105
} from "../../lib/attachmentUploadQueue";
106
import { appAtomRegistry } from "../../rpc/atomRegistry";
107
import { fileAttachmentCapabilityBlockReason } from "./composerAttachmentFiles";
108
+import { useLinkedEnvironments } from "../../state/peerLinks";
109
import { readEnvironmentScope } from "../../state/session";
110
import { useOrchestrationCommand } from "../../state/use-orchestration-command";
111
import {
@@ -325,6 +326,7 @@ export function useComposerSend(input: ComposerSendInput) {
326
handleNewThreadInActiveProject,
327
persistThreadSettingsForNextTurn,
328
} = input;
329
+ const linkedEnvironments = useLinkedEnvironments(environmentId);
330
const handleNewThread = useNewThreadHandler();
331
const navigate = useNavigate();
332
const clientSettingsHydrated = useClientSettingsHydrated();
@@ -552,6 +554,7 @@ export function useComposerSend(input: ComposerSendInput) {
554
text: promptForSend,
555
records: composerThreadContexts,
556
environmentId,
557
+ linkedEnvironments,
558
})[0];
559
if (strandedThread) {
560
const owner =
apps/web/src/components/composerContextPresentation.tsx
+7
-1
@@ -38,6 +38,7 @@ import type { ReviewCommentContext } from "~/reviewCommentContext";
38
import { ComposerPendingTerminalContextChip } from "./chat/ComposerPendingTerminalContexts";
39
import { EnvironmentContextChip } from "./EnvironmentContextChip";
40
import { ThreadContextChip } from "./ThreadContextChip";
41
+import { useLinkedEnvironments } from "~/state/peerLinks";
42
import {
43
createContextPresentationRegistry,
44
type ContextPresentationCapability,
@@ -345,10 +346,15 @@ function ComposerPreviewAnnotationDetails({
346
347
function ComposerThreadContextChip(props: { record: ThreadContextRecord }) {
348
const { environmentId } = use(ComposerContextActionsContext);
349
+ const linkedEnvironments = useLinkedEnvironments(environmentId);
350
return (
351
<ThreadContextChip
352
record={props.record}
351
- unreadable={environmentId !== null && props.record.environmentId !== environmentId}
353
+ unreadable={
354
+ environmentId !== null &&
355
+ props.record.environmentId !== environmentId &&
356
+ !linkedEnvironments.has(props.record.environmentId)
357
+ }
358
/>
359
);
360
}
apps/web/src/state/peerLinks.ts
+31
-2
@@ -1,12 +1,16 @@
1
import { useAtomValue } from "@effect/atom-react";
2
-import { linkableMachines, offersLinkedEnvironments } from "@t3tools/client-runtime/link-request";
2
+import {
3
+ linkableMachines,
4
+ linkedEnvironmentNames,
5
+ offersLinkedEnvironments,
6
+} from "@t3tools/client-runtime/link-request";
7
import { createPeerLinkEnvironmentAtoms } from "@t3tools/client-runtime/state/peerLinks";
8
import { AuthAccessReadScope, type EnvironmentId } from "@t3tools/contracts";
9
import { Atom } from "effect/reactivity";
10
import { useEffect, useEffectEvent } from "react";
11
12
import { connectionAtomRuntime } from "../connection/runtime";
9
-import { useEnvironments } from "./environments";
13
+import { useEnvironmentIdentities, useEnvironments } from "./environments";
14
import { environmentPresentations } from "./presentation";
15
import { relayEnvironmentDiscovery } from "./relay";
16
import { useEnvironmentQuery } from "./query";
@@ -22,6 +26,31 @@ export const offersLinkedEnvironmentsAtom = Atom.family((environmentId: Environm
26
).pipe(Atom.withLabel(`peer-links:offered:${environmentId}`)),
27
);
28
29
+const offersNoLinksAtom = Atom.make(false).pipe(Atom.withLabel("peer-links:offered:none"));
30
+
31
+/**
32
+ * The machines `environmentId` links to, by name, while it offers links, and none otherwise.
33
+ * Its agents can read threads there. Listing asks each linked machine whether it answers, so
34
+ * every caller shares one briefly cached list.
35
+ */
36
+export function useLinkedEnvironments(
37
+ environmentId: EnvironmentId | null,
38
+): ReadonlyMap<EnvironmentId, string> {
39
+ const offered = useAtomValue(
40
+ environmentId === null ? offersNoLinksAtom : offersLinkedEnvironmentsAtom(environmentId),
41
+ );
42
+ const identities = useEnvironmentIdentities();
43
+ const links = useEnvironmentQuery(
44
+ offered && environmentId !== null
45
+ ? peerLinkEnvironment.list({ environmentId, input: {} })
46
+ : null,
47
+ );
48
+ return linkedEnvironmentNames({
49
+ links: offered ? (links.data?.links ?? []) : [],
50
+ environments: identities,
51
+ });
52
+}
53
+
54
export function usePeerLinkHosts() {
55
const { environments } = useEnvironments();
56
const supported = environments.filter(
docs/user/composer.md
+5
-3
@@ -281,13 +281,15 @@ pull request is older than the recent list. Type a single word after `#` to sear
281
the repository by text. Choose a result to insert it as a chip.
282
283
Another thread can be context too. Type `@` followed by part of its title to pick one from
284
-the same server, or on web and desktop drag a thread out of the sidebar and drop it on the
285
-composer; a multi-selection drops together. The chip shows the thread's current title and
284
+the same server, or from a machine it links to while the Linked environments beta is on; those
285
+show the machine's name. On web and desktop you can also drag a thread out of the sidebar and
286
+drop it on the composer; a multi-selection drops together. The chip shows the thread's current title and
287
opens it when selected. Your prompt only carries a reference: the agent reads the thread's
288
history on demand, so attaching a long thread costs nothing until the agent looks. Attaching a
289
thread does not change it, and the agent cannot send messages to it unless you ask.
290
290
-Dropping a thread from another environment attaches a saved transcript file. The source
291
+A thread from a linked machine, picked, pasted or dropped, stays a reference that the agent reads
292
+on that machine. Dropping a thread from any other environment attaches a saved transcript file. The source
293
environment must be connected and up to date. The transcript includes the visible history and
294
saved text context at the time of the drop; later messages and the contents of attached files
295
are not copied. The agent can read the saved transcript after the source disconnects. Normal
evals/mcp-tool-use/cases/orchestration.ndjson
+1
@@ -32,3 +32,4 @@
32
{"id": "codex-same-model-subagents-stay-native", "area": "orchestration", "kind": "guard", "pattern": "same-provider subagents stay native", "experience": "A Sol thread at its own reasoning level asked for subagents. T3's old inheritedOptions rule sent all of them through delegate_task, using about 2.8x the allowance (issue 23525). Same-model children should use spawn_agent.", "rule": "Use your native tool when the child uses your provider, a model it offers, and no settings beyond yours, and you need it only in this turn.", "privacy": "commit-safe", "setup": {"role": "top", "harness": "codex", "world": {"commits": [{"sha": "a17c3e2", "subject": "feat(web): new empty state for projects (#147)"}, {"sha": "a16c3e2", "subject": "feat(server): faster thread list query (#146)"}, {"sha": "a15c3e2", "subject": "fix(web): toast spacing (#145)"}, {"sha": "a14c3e2", "subject": "feat(web): move model picker into the composer (#144)"}, {"sha": "a13c3e2", "subject": "chore: update dependencies (#143)"}, {"sha": "a12c3e2", "subject": "feat(web): compact thread header (#142)"}, {"sha": "a11c3e2", "subject": "fix(server): close idle sockets (#141)"}, {"sha": "a10c3e2", "subject": "feat(web): pin icon on sidebar rows (#140)"}], "prs": [{"number": 140, "title": "feat(web): pin icon on sidebar rows", "state": "MERGED", "mergedAt": "2026-10-17T18:00:00Z", "diff": "diff --git a/apps/web/src/Sidebar.tsx b/apps/web/src/Sidebar.tsx\n--- a/apps/web/src/Sidebar.tsx\n+++ b/apps/web/src/Sidebar.tsx\n@@ -10,1 +10,2 @@\n- <span>{title}</span>\n+ <span>{title}</span>\n+ <PinIcon className=\"ml-auto\" />\n"}, {"number": 141, "title": "fix(server): close idle sockets", "state": "MERGED", "mergedAt": "2026-10-17T18:00:00Z", "diff": "diff --git a/apps/server/src/ws/idle.ts b/apps/server/src/ws/idle.ts\n--- a/apps/server/src/ws/idle.ts\n+++ b/apps/server/src/ws/idle.ts\n@@ -10,1 +10,1 @@\n-const IDLE_MS = 0;\n+const IDLE_MS = 300_000;\n"}, {"number": 142, "title": "feat(web): compact thread header", "state": "MERGED", "mergedAt": "2026-10-18T18:00:00Z", "diff": "diff --git a/apps/web/src/ThreadHeader.tsx b/apps/web/src/ThreadHeader.tsx\n--- a/apps/web/src/ThreadHeader.tsx\n+++ b/apps/web/src/ThreadHeader.tsx\n@@ -10,1 +10,1 @@\n- <header className=\"h-14 px-4\">\n+ <header className=\"h-9 px-2 text-xs\">\n"}, {"number": 143, "title": "chore: update dependencies", "state": "MERGED", "mergedAt": "2026-10-18T18:00:00Z", "diff": "diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml\n--- a/pnpm-lock.yaml\n+++ b/pnpm-lock.yaml\n@@ -40,1 +40,1 @@\n- react: 19.1.0\n+ react: 19.2.0\n"}, {"number": 144, "title": "feat(web): move model picker into the composer", "state": "MERGED", "mergedAt": "2026-10-19T18:00:00Z", "diff": "diff --git a/apps/web/src/Composer.tsx b/apps/web/src/Composer.tsx\n--- a/apps/web/src/Composer.tsx\n+++ b/apps/web/src/Composer.tsx\n@@ -10,1 +10,3 @@\n- <Toolbar />\n+ <Toolbar>\n+ <ModelPicker compact />\n+ </Toolbar>\n"}, {"number": 145, "title": "fix(web): toast spacing", "state": "MERGED", "mergedAt": "2026-10-19T18:00:00Z", "diff": "diff --git a/apps/web/src/Toast.tsx b/apps/web/src/Toast.tsx\n--- a/apps/web/src/Toast.tsx\n+++ b/apps/web/src/Toast.tsx\n@@ -10,1 +10,1 @@\n- <div className=\"gap-2 p-3\">\n+ <div className=\"gap-1 p-2\">\n"}, {"number": 146, "title": "feat(server): faster thread list query", "state": "MERGED", "mergedAt": "2026-10-20T18:00:00Z", "diff": "diff --git a/apps/server/src/threads/list.ts b/apps/server/src/threads/list.ts\n--- a/apps/server/src/threads/list.ts\n+++ b/apps/server/src/threads/list.ts\n@@ -10,1 +10,1 @@\n- return db.all(SELECT_ALL);\n+ return db.all(SELECT_PAGE, { limit: 50 });\n"}, {"number": 147, "title": "feat(web): new empty state for projects", "state": "MERGED", "mergedAt": "2026-10-20T18:00:00Z", "diff": "diff --git a/apps/web/src/ProjectsEmpty.tsx b/apps/web/src/ProjectsEmpty.tsx\n--- a/apps/web/src/ProjectsEmpty.tsx\n+++ b/apps/web/src/ProjectsEmpty.tsx\n@@ -10,1 +10,1 @@\n- return <p>No projects</p>;\n+ return <EmptyState icon={FolderIcon} title=\"No projects yet\" />;\n"}]}, "mocks": {"Agent": "The agent finished. Final report: old logger imports remain in apps/server/src/legacy/http.ts and packages/cli/src/run.ts; skipped tests are apps/web/src/Toast.test.tsx (it.skip) and apps/server/src/ws/idle.test.ts (describe.skip); env vars read but not in docs/env.md: T3_DEBUG_WS and T3_TRACE_SQL."}}, "prompt": "Use subagents to check these three things in parallel, then summarize: 1) which packages still import the old logger, 2) which tests are skipped, 3) which env vars are read but never documented.", "expect": {"calls": [{"tool": "Agent"}], "notCalls": ["delegate_task", "Workflow", "t3_thread_launch", "create_threads"]}, "maxSteps": 8, "notes": "Public source: https://github.com/pingdotgg/t3code/issues/23525"}
33
{"id": "two-children-same-model", "area": "orchestration", "kind": "bad", "pattern": "named-model rule read as a cap", "experience": "Asked for two Sol xhigh subagents, an Astra parent started one and refused the second, citing 'One child per named model' (#24967).", "rule": "Before delegate_task ... One child per named model. (intended: every named model gets a child; read as a cap of one child per model)", "privacy": "commit-safe", "setup": {"role": "top", "mocks": {"orchestrator_capabilities": {"parentThreadId": "33333333-3333-4333-8333-333333333333", "inheritedProviderInstanceId": "claudeAgent", "inheritedModel": "claude-sonnet-5-5", "inheritedOptions": [{"id": "effort", "value": "high"}], "runtimeMode": "full-access", "interactionMode": "default", "features": {"appOwnedSubagents": true, "asyncPolling": true, "cancellation": true, "batchThreadCreation": true, "threadManagement": true, "incrementalThreadRead": true, "scheduledTasks": true}, "providers": [{"providerInstanceId": "claudeAgent", "driverKind": "claudeAgent", "displayName": "Claude", "models": [{"id": "claude-opus-5-5", "label": "Claude Opus 5.5", "options": [{"id": "effort", "values": ["low", "medium", "high", "xhigh", "max"], "default": "high"}, {"id": "fastMode", "type": "boolean", "default": false}]}, {"id": "claude-sonnet-5-5", "label": "Claude Sonnet 5.5", "options": [{"id": "effort", "values": ["low", "medium", "high", "xhigh", "max"], "default": "high"}]}, {"id": "claude-haiku-5-5", "label": "Claude Haiku 5.5", "options": [{"id": "effort", "values": ["low", "medium", "high", "xhigh", "max"], "default": "high"}]}]}, {"providerInstanceId": "codex", "driverKind": "codex", "displayName": "Codex", "models": [{"id": "gpt-6.1-sol", "label": "GPT-6.1 Sol", "options": [{"id": "reasoningEffort", "values": ["low", "medium", "high", "xhigh", "max"], "default": "high"}, {"id": "serviceTier", "values": ["default", "priority"], "default": "default"}]}]}, {"providerInstanceId": "muse", "driverKind": "muse", "displayName": "Muse Code", "runtimeModes": ["approval-required", "full-access"], "models": [{"id": "muse-wonder-full", "label": "Muse Wonder Full", "options": [{"id": "reasoningEffort", "values": ["minimal", "low", "medium", "high", "xhigh", "max"], "default": "high"}]}]}, {"providerInstanceId": "grok", "driverKind": "grok", "displayName": "Grok", "models": [{"id": "grok-4.7", "label": "Grok 4.7", "options": []}]}]}, "delegate_task": "default"}}, "prompt": "Launch two Sol xhigh subagents. Give each a trivial task that only replies OK.", "expect": {"calls": [{"tool": "delegate_task", "args": {"target.model": "gpt-6.1-sol", "target.options.reasoningEffort": "xhigh"}}], "minCalls": {"delegate_task": 2}, "callsMustNot": [{"tool": "delegate_task", "args": {"target.model": "~muse"}}, {"tool": "delegate_task", "args": {"target.model": "~claude"}}]}, "notes": "From #24967. One child plus the parent doing the work fails, and so does a second model in place of Sol."}
34
{"id": "worker-counts-per-model", "area": "orchestration", "kind": "bad", "pattern": "named-model rule read as a cap", "experience": "Asked for 20 Sol workers and 20 Luna workers, the agent started one worker per model (#25359).", "rule": "Before delegate_task ... One child per named model. (intended: every named model gets a child; read as a cap of one child per model)", "privacy": "commit-safe", "setup": {"role": "top", "mocks": {"orchestrator_capabilities": {"parentThreadId": "33333333-3333-4333-8333-333333333333", "inheritedProviderInstanceId": "claudeAgent", "inheritedModel": "claude-sonnet-5-5", "inheritedOptions": [{"id": "effort", "value": "high"}], "runtimeMode": "full-access", "interactionMode": "default", "features": {"appOwnedSubagents": true, "asyncPolling": true, "cancellation": true, "batchThreadCreation": true, "threadManagement": true, "incrementalThreadRead": true, "scheduledTasks": true}, "providers": [{"providerInstanceId": "claudeAgent", "driverKind": "claudeAgent", "displayName": "Claude", "models": [{"id": "claude-opus-5-5", "label": "Claude Opus 5.5", "options": [{"id": "effort", "values": ["low", "medium", "high", "xhigh", "max"], "default": "high"}, {"id": "fastMode", "type": "boolean", "default": false}]}, {"id": "claude-sonnet-5-5", "label": "Claude Sonnet 5.5", "options": [{"id": "effort", "values": ["low", "medium", "high", "xhigh", "max"], "default": "high"}]}, {"id": "claude-haiku-5-5", "label": "Claude Haiku 5.5", "options": [{"id": "effort", "values": ["low", "medium", "high", "xhigh", "max"], "default": "high"}]}]}, {"providerInstanceId": "codex", "driverKind": "codex", "displayName": "Codex", "models": [{"id": "gpt-6.1-sol", "label": "GPT-6.1 Sol", "options": [{"id": "reasoningEffort", "values": ["low", "medium", "high", "xhigh", "max"], "default": "high"}, {"id": "serviceTier", "values": ["default", "priority"], "default": "default"}]}]}, {"providerInstanceId": "muse", "driverKind": "muse", "displayName": "Muse Code", "runtimeModes": ["approval-required", "full-access"], "models": [{"id": "muse-wonder-full", "label": "Muse Wonder Full", "options": [{"id": "reasoningEffort", "values": ["minimal", "low", "medium", "high", "xhigh", "max"], "default": "high"}]}]}, {"providerInstanceId": "grok", "driverKind": "grok", "displayName": "Grok", "models": [{"id": "grok-4.7", "label": "Grok 4.7", "options": []}]}]}, "delegate_task": "default"}, "world": {"files": {"tests/flaky/retry.test.ts": "it('retry is flaky', async () => { /* fails 1 in 5 runs */ });\n", "tests/flaky/upload.test.ts": "it('upload is flaky', async () => { /* fails 1 in 5 runs */ });\n", "tests/flaky/session.test.ts": "it('session is flaky', async () => { /* fails 1 in 5 runs */ });\n", "tests/flaky/search.test.ts": "it('search is flaky', async () => { /* fails 1 in 5 runs */ });\n", "tests/flaky/billing.test.ts": "it('billing is flaky', async () => { /* fails 1 in 5 runs */ });\n", "tests/flaky/webhook.test.ts": "it('webhook is flaky', async () => { /* fails 1 in 5 runs */ });\n"}}}, "prompt": "Six tests in tests/flaky/ fail now and then. Start 3 Muse Wonder Full workers and 3 Grok workers, one test file each, to find and fix the flake.", "expect": {"calls": [{"tool": "delegate_task", "args": {"target.model": "muse-wonder-full"}}, {"tool": "delegate_task", "args": {"target.model": "grok-4.7"}}], "minCalls": {"delegate_task": 6}}, "notes": "Scaled down from the real 20 Sol + 20 Luna ask. Muse and Grok need delegate_task from every parent, so a native Sol helper cannot pass or fail it."}
35
+{"id": "linked-thread-chip-reads-there", "area": "orchestration", "kind": "guard", "pattern": "thread chip from a linked machine read on this one", "experience": "A thread chip from a linked machine names its environmentId; an agent that reads it without passing that id reads this machine, where the thread does not exist.", "rule": "The thread chip names its environmentId; t3_thread_read takes it.", "privacy": "commit-safe", "setup": {"role": "top", "linkedEnvironments": true, "mocks": {"t3_environment_links": {"environmentId": "environment-laptop", "links": [{"environmentId": "environment-vps", "label": "Hetzner VPS", "status": "reachable", "access": "auto-accept-edits", "expiresAt": "2026-12-01T00:00:00.000Z", "lastError": null}], "notListed": "Not listed: not linked yet. Call t3_environment_link with a hint from the user's words."}, "t3_thread_read": {"thread": {"threadId": "thread-deploy-api", "title": "Deploy the API", "status": "idle"}, "items": [{"position": 1, "createdBy": "user", "text": "Deploy the API to the VPS and check the health endpoint."}, {"position": 2, "createdBy": "assistant", "text": "Deployed. /health returns 200, but /health/db times out after 5s: the API can't reach Postgres on 10.0.0.5:5432."}], "nextPosition": 3, "hasMore": false}}}, "prompt": "Pick up where [Deploy the API](t3-context://v1/thread/thread_deploy-api) left off. What is still failing?", "promptContext": {"records": [{"version": 1, "kind": "thread", "contextId": "thread_deploy-api", "label": "Deploy the API", "environmentId": "environment-vps", "threadId": "thread-deploy-api", "title": "Deploy the API"}]}, "expect": {"calls": [{"tool": "t3_thread_read", "args": {"threadId": "thread-deploy-api", "environmentId": "environment-vps"}}], "notCalls": ["t3_environment_link"]}, "source": {"request": "akj on #17130: attach a linked machine's thread without dragging"}}
evals/mcp-tool-use/run.test.ts
+44
@@ -1,4 +1,6 @@
1
import { assert, expect, it } from "@effect/vitest";
2
+import { ComposerContextId, EnvironmentId, ThreadId } from "@t3tools/contracts";
3
+import { projectComposerContextForProvider } from "@t3tools/shared/composerContextReferences";
4
5
import {
6
buildBase,
@@ -264,6 +266,48 @@ it("rebuilds the template from this checkout and sends a child T3's task prompt"
266
assert.notEqual(prompt?.text, childCase.prompt);
267
});
268
269
+it("lists link tools only while a case turns the beta on, and sends chips as T3 projects them", () => {
270
+ const off = buildBase(template, { model: "claude-sonnet-5-5", keepUserInstructions: false });
271
+ const on = buildBase(template, {
272
+ model: "claude-sonnet-5-5",
273
+ keepUserInstructions: false,
274
+ links: true,
275
+ });
276
+ assert.notInclude(
277
+ off.t3.map((tool) => tool.name),
278
+ "mcp__t3-code__t3_environment_link",
279
+ );
280
+ assert.include(
281
+ on.t3.map((tool) => tool.name),
282
+ "mcp__t3-code__t3_environment_link",
283
+ );
284
+
285
+ const testCase: McpToolUseCase = {
286
+ ...childCase,
287
+ setup: { role: "top", linkedEnvironments: true },
288
+ prompt: "Continue [Deploy](t3-context://v1/thread/thread_deploy)",
289
+ promptContext: {
290
+ records: [
291
+ {
292
+ version: 1,
293
+ kind: "thread",
294
+ contextId: ComposerContextId.make("thread_deploy"),
295
+ label: "Deploy",
296
+ environmentId: EnvironmentId.make("environment-vps"),
297
+ threadId: ThreadId.make("thread-deploy"),
298
+ title: "Deploy",
299
+ },
300
+ ],
301
+ },
302
+ };
303
+ const prompt = buildMessages(makeSample(testCase, on)).at(-1)?.content.at(-1);
304
+ assert.equal(
305
+ prompt?.text,
306
+ projectComposerContextForProvider({ text: testCase.prompt, ...testCase.promptContext! }),
307
+ );
308
+ assert.include(prompt?.text, "environmentId: environment-vps");
309
+});
310
+
311
it("replays earlier capability results with the model under test as the caller", () => {
312
const base = buildBase(template, { model: "claude-opus-5-5", keepUserInstructions: false });
313
const capabilities = {
evals/mcp-tool-use/run.ts
+30
-8
@@ -11,7 +11,11 @@ import * as NodeVM from "node:vm";
11
import * as NodeZlib from "node:zlib";
12
import * as NodeRuntime from "@effect/platform-node/NodeRuntime";
13
import * as NodeServices from "@effect/platform-node/NodeServices";
14
-import { OrchestratorMcpTaskRole, ProviderInstanceId } from "@t3tools/contracts";
14
+import {
15
+ ComposerContextRecord,
16
+ OrchestratorMcpTaskRole,
17
+ ProviderInstanceId,
18
+} from "@t3tools/contracts";
19
import * as Cause from "effect/Cause";
20
import * as Context from "effect/Context";
21
import * as Effect from "effect/Effect";
@@ -30,6 +34,7 @@ import { taskPrompt } from "../../apps/server/src/mcp/delegatedTaskModes.ts";
34
import * as McpInvocationContext from "../../apps/server/src/mcp/McpInvocationContext.ts";
35
import { advertisedJsonSchema } from "../../apps/server/src/mcp/advertisedJsonSchema.ts";
36
import { ORCHESTRATOR_MCP_RUNNING_TASK_NEXT } from "@t3tools/contracts";
37
+import { projectComposerContextForProvider } from "@t3tools/shared/composerContextReferences";
38
import { formatThreadLink } from "@t3tools/shared/threadLinks";
39
import { buildCodexAdditionalContext } from "../../apps/server/src/provider/CodexDeveloperInstructions.ts";
40
import { AttachmentToolkit } from "../../apps/server/src/mcp/toolkits/attachment/tools.ts";
@@ -170,6 +175,8 @@ export const McpToolUseCase = Schema.Struct({
175
role: Schema.Literals(["top", "delegated-child", "native-subagent"]),
176
/** Runs only on this harness, for cases whose right answer depends on it. */
177
harness: Schema.optional(Schema.Literals(["claude", "codex"])),
178
+ /** The Linked environments beta is on, so T3 lists its link tools. */
179
+ linkedEnvironments: Schema.optional(Schema.Boolean),
180
/** delegate_task `role` for a delegated child. T3 builds the child's first message from it. */
181
delegateRole: Schema.optional(OrchestratorMcpTaskRole),
182
context: Schema.optional(Schema.String),
@@ -191,6 +198,8 @@ export const McpToolUseCase = Schema.Struct({
198
),
199
}),
200
prompt: Schema.String,
201
+ /** Records for the context chips `prompt` links, projected as T3 sends them. */
202
+ promptContext: Schema.optional(Schema.Struct({ records: Schema.Array(ComposerContextRecord) })),
203
expect: McpToolUseExpect,
204
/** Model calls this case may need. Overrides `--max-steps`. */
205
maxSteps: Schema.optional(Schema.Number),
@@ -320,10 +329,11 @@ const enabledWhen = (predicate: () => boolean) =>
329
const hiddenFromSubagents = enabledWhen(McpInvocationContext.hiddenFromSubagents);
330
// The Linked environments beta starts off, and T3 lists its tools only while it is on.
331
const hiddenWhileLinksOff = enabledWhen(McpInvocationContext.hiddenWhileLinksOff);
323
-const visibleT3Tools = (subagent: boolean) =>
332
+const visibleT3Tools = (options: { readonly subagent?: boolean; readonly links?: boolean }) =>
333
t3Tools.filter(
334
(tool) =>
326
- !hiddenWhileLinksOff.has(tool.name) && !(subagent && hiddenFromSubagents.has(tool.name)),
335
+ (options.links === true || !hiddenWhileLinksOff.has(tool.name)) &&
336
+ !(options.subagent === true && hiddenFromSubagents.has(tool.name)),
337
);
338
339
/** Text T3 appends to Claude Code's system prompt. Delegated children get the same text. */
@@ -387,9 +397,10 @@ export const buildBase = (
397
readonly model: Model;
398
readonly keepUserInstructions: boolean;
399
readonly subagent?: boolean;
400
+ readonly links?: boolean;
401
},
402
) => {
392
- const t3 = visibleT3Tools(options.subagent === true);
403
+ const t3 = visibleT3Tools(options);
404
const firstAssistant = template.messages.findIndex((message) => message.role === "assistant");
405
const head = template.messages.slice(0, firstAssistant === -1 ? undefined : firstAssistant);
406
const systemTexts = [
@@ -462,9 +473,10 @@ const buildCodexBase = (
473
readonly keepUserInstructions: boolean;
474
readonly effort?: string | undefined;
475
readonly subagent?: boolean;
476
+ readonly links?: boolean;
477
},
478
): Base => {
467
- const t3 = visibleT3Tools(options.subagent === true);
479
+ const t3 = visibleT3Tools(options);
480
const contentText = (item: Block) =>
481
Array.isArray(item.content)
482
? item.content.map((block: Block) => valueText(block.text)).join("\n")
@@ -725,7 +737,10 @@ export const buildMessages = (sample: Sample) => {
737
}
738
if (turn.text) push(turn.role, text(turn.text));
739
}
728
- const { prompt } = testCase;
740
+ const prompt =
741
+ testCase.promptContext === undefined
742
+ ? testCase.prompt
743
+ : projectComposerContextForProvider({ text: testCase.prompt, ...testCase.promptContext });
744
const childPrompt = () => taskPrompt({ task: prompt, role: delegateRole });
745
push("user", text(role === "delegated-child" ? childPrompt() : prompt));
746
return messages;
@@ -1688,7 +1703,7 @@ const main = Effect.gen(function* () {
1703
templatePath.endsWith(".gz") ? NodeZlib.gunzipSync(templateBytes) : templateBytes,
1704
);
1705
const keepUserInstructions = flags["user-instructions"] === "keep";
1691
- const buildFor = (subagent: boolean): Effect.Effect<Base, Schema.SchemaError> =>
1706
+ const buildFor = (subagent: boolean, links = false): Effect.Effect<Base, Schema.SchemaError> =>
1707
codex
1708
? decodeCodexCapture(template).pipe(
1709
Effect.map((capture) =>
@@ -1697,6 +1712,7 @@ const main = Effect.gen(function* () {
1712
keepUserInstructions,
1713
effort: flags.effort,
1714
subagent,
1715
+ links,
1716
}),
1717
),
1718
)
@@ -1706,13 +1722,19 @@ const main = Effect.gen(function* () {
1722
model: flags.model,
1723
keepUserInstructions,
1724
subagent,
1725
+ links,
1726
}),
1727
),
1728
);
1729
const base = yield* buildFor(false);
1730
const childBase = yield* buildFor(true);
1731
+ const linkedBase = yield* buildFor(false, true);
1732
const baseFor = (testCase: McpToolUseCase) =>
1715
- testCase.setup.role === "delegated-child" ? childBase : base;
1733
+ testCase.setup.role === "delegated-child"
1734
+ ? childBase
1735
+ : testCase.setup.linkedEnvironments === true
1736
+ ? linkedBase
1737
+ : base;
1738
const effort = flags.effort ?? base.codex?.reasoning.effort ?? "high";
1739
if (flags["dry-run"]) {
1740
// One JSON line per case. Without --case this also checks that every case builds.
packages/client-runtime/src/composerThreadItems.test.ts
+25
@@ -46,6 +46,7 @@ it("ranks thread mentions like the palette and leaves out subagent threads", ()
46
shell("other-environment", "Model docs", { environmentId: EnvironmentId.make("env-other") }),
47
],
48
environmentId,
49
+ linkedEnvironments: new Map(),
50
excludeThreadId: null,
51
query: "model",
52
now: Date.parse("2026-10-23T00:00:00.000Z"),
@@ -53,6 +54,30 @@ it("ranks thread mentions like the palette and leaves out subagent threads", ()
54
expect(items.map((item) => item.thread.threadId)).toEqual(["word", "newer-mid-word"]);
55
});
56
57
+it("also offers threads on linked machines, naming the machine, but no other machine's", () => {
58
+ const vps = EnvironmentId.make("env-vps");
59
+ const items = matchComposerThreadItems({
60
+ shells: [
61
+ shell("here", "Deploy script"),
62
+ shell("there", "Deploy script", { environmentId: vps }),
63
+ shell("unlinked", "Deploy notes", { environmentId: EnvironmentId.make("env-unlinked") }),
64
+ ],
65
+ environmentId,
66
+ linkedEnvironments: new Map([[vps, "Hetzner VPS"]]),
67
+ excludeThreadId: null,
68
+ query: "deploy",
69
+ now: Date.parse("2026-10-23T00:00:00.000Z"),
70
+ });
71
+ expect(items.map(({ thread, label, description }) => ({ thread, label, description }))).toEqual([
72
+ { thread: { environmentId, threadId: "here" }, label: "Deploy script", description: "Thread" },
73
+ {
74
+ thread: { environmentId: vps, threadId: "there" },
75
+ label: "Deploy script",
76
+ description: "Thread on Hetzner VPS",
77
+ },
78
+ ]);
79
+});
80
+
81
describe("matchComposerEnvironmentItems", () => {
82
const environments = [
83
{ environmentId: EnvironmentId.make("env-here"), label: "Laptop", machine: "laptop" },
packages/client-runtime/src/composerThreadItems.ts
+20
-10
@@ -24,12 +24,15 @@ export interface ComposerThreadItem {
24
25
/**
26
* Threads to reference from the composer, matched and ranked like the command
27
- * palette, without subagent threads. The agent can only read threads on its
28
- * own server, so candidates stay within the composer's environment.
27
+ * palette, without subagent threads. The agent reads threads on its own server
28
+ * and on the machines it links to, so candidates stay within those, and a linked
29
+ * machine's threads say which machine they are on.
30
*/
31
export function matchComposerThreadItems(input: {
32
shells: ReadonlyArray<ComposerThreadCandidate>;
33
environmentId: EnvironmentId;
34
+ /** The machines the composer's environment links to, by name. */
35
+ linkedEnvironments: ReadonlyMap<EnvironmentId, string>;
36
excludeThreadId: ThreadId | null;
37
query: string;
38
/** Recency is measured against this time. */
@@ -39,7 +42,8 @@ export function matchComposerThreadItems(input: {
42
if (query.length === 0) return [];
43
const candidates = input.shells.filter(
44
(shell) =>
42
- shell.environmentId === input.environmentId &&
45
+ (shell.environmentId === input.environmentId ||
46
+ input.linkedEnvironments.has(shell.environmentId)) &&
47
shell.id !== input.excludeThreadId &&
48
shell.archivedAt === null &&
49
shell.lineage.relationshipToParent !== "subagent",
@@ -51,13 +55,19 @@ export function matchComposerThreadItems(input: {
55
}),
56
)
57
.slice(0, COMPOSER_THREAD_RESULT_LIMIT)
54
- .map(({ item: shell }) => ({
55
- id: `thread:${shell.environmentId}:${shell.id}`,
56
- type: "thread",
57
- thread: { environmentId: shell.environmentId, threadId: shell.id },
58
- label: shell.title,
59
- description: "Thread",
60
- }));
58
+ .map(({ item: shell }) => {
59
+ const machine =
60
+ shell.environmentId === input.environmentId
61
+ ? undefined
62
+ : input.linkedEnvironments.get(shell.environmentId);
63
+ return {
64
+ id: `thread:${shell.environmentId}:${shell.id}`,
65
+ type: "thread",
66
+ thread: { environmentId: shell.environmentId, threadId: shell.id },
67
+ label: shell.title,
68
+ description: machine === undefined ? "Thread" : `Thread on ${machine}`,
69
+ };
70
+ });
71
}
72
73
export interface ComposerEnvironmentCandidate {
packages/client-runtime/src/linkRequest.test.ts
+27
@@ -9,6 +9,7 @@ import type { EnvironmentPresentation } from "./connection/presentation.ts";
9
import type { RelayDiscoveredEnvironment } from "./relay/discovery.ts";
10
import {
11
linkableMachines,
12
+ linkedEnvironmentNames,
13
linkRequestAnswerInput,
14
linkRequestDisplay,
15
linkRequestFailureMessage,
@@ -314,6 +315,32 @@ describe("linkableMachines", () => {
315
});
316
});
317
318
+describe("linkedEnvironmentNames", () => {
319
+ it("names the unexpired links as this client does, else as the link does", () => {
320
+ const vps = EnvironmentId.make("environment-vps");
321
+ const mini = EnvironmentId.make("environment-mini");
322
+ const unsaved = EnvironmentId.make("environment-unsaved");
323
+ expect(
324
+ linkedEnvironmentNames({
325
+ links: [
326
+ { environmentId: vps, label: "vps-01", status: "unreachable" },
327
+ { environmentId: mini, label: "mini", status: "expired" },
328
+ { environmentId: unsaved, label: "Office box", status: "reachable" },
329
+ ],
330
+ environments: [
331
+ { environmentId: vps, label: "Hetzner VPS" },
332
+ { environmentId: mini, label: "Mac mini" },
333
+ ],
334
+ }),
335
+ ).toEqual(
336
+ new Map([
337
+ [vps, "Hetzner VPS"],
338
+ [unsaved, "Office box"],
339
+ ]),
340
+ );
341
+ });
342
+});
343
+
344
describe("rankMachinesByHint", () => {
345
const machines = [
346
{ label: "Old vps box" },
packages/client-runtime/src/linkRequest.ts
+23
@@ -22,6 +22,29 @@ export const offersLinkedEnvironments = (
22
): boolean =>
23
config?.environment.capabilities.peerLinks === true && config.settings.linkedEnvironmentsEnabled;
24
25
+/**
26
+ * The machines an environment's agents can work on, by name: its links that have not
27
+ * expired, named as this client names them, else as the link does.
28
+ */
29
+export function linkedEnvironmentNames(input: {
30
+ readonly links: ReadonlyArray<Pick<PeerLinkSummary, "environmentId" | "label" | "status">>;
31
+ readonly environments: ReadonlyArray<{
32
+ readonly environmentId: EnvironmentId;
33
+ readonly label: string;
34
+ }>;
35
+}): ReadonlyMap<EnvironmentId, string> {
36
+ const names = new Map(
37
+ input.environments.map((environment) => [environment.environmentId, environment.label]),
38
+ );
39
+ return new Map(
40
+ input.links.flatMap((link) =>
41
+ link.status === "expired"
42
+ ? []
43
+ : [[link.environmentId, names.get(link.environmentId) ?? link.label] as const],
44
+ ),
45
+ );
46
+}
47
+
48
/** The access a request opens with: the agent's suggestion, else supervised. */
49
export const linkRequestDefaultAccess = (
50
item: Pick<LinkRequestItem, "requestedAccess">,
packages/shared/src/composerContextReferences.test.ts
+31
@@ -317,6 +317,7 @@ describe("threadContextsOutsideEnvironment", () => {
317
text: `${localReference} [Foreign](t3-context://v1/thread/thread_foreign)`,
318
records,
319
environmentId: local.environmentId,
320
+ linkedEnvironments: new Map(),
321
}),
322
).toEqual([foreign]);
323
expect(
@@ -324,9 +325,39 @@ describe("threadContextsOutsideEnvironment", () => {
325
text: localReference,
326
records,
327
environmentId: local.environmentId,
328
+ linkedEnvironments: new Map(),
329
}),
330
).toEqual([]);
331
});
332
+
333
+ it("lets a thread on a linked machine through, since the agent reads it there", () => {
334
+ const thread = {
335
+ version: 1 as const,
336
+ kind: "thread" as const,
337
+ label: "Thread",
338
+ threadId: ThreadId.make("thread"),
339
+ title: "Thread",
340
+ };
341
+ const linked = {
342
+ ...thread,
343
+ contextId: ctx("thread_linked"),
344
+ environmentId: EnvironmentId.make("env-linked"),
345
+ };
346
+ const unlinked = {
347
+ ...thread,
348
+ contextId: ctx("thread_unlinked"),
349
+ environmentId: EnvironmentId.make("env-unlinked"),
350
+ };
351
+
352
+ expect(
353
+ threadContextsOutsideEnvironment({
354
+ text: "[A](t3-context://v1/thread/thread_linked) [B](t3-context://v1/thread/thread_unlinked)",
355
+ records: [linked, unlinked],
356
+ environmentId: EnvironmentId.make("env-local"),
357
+ linkedEnvironments: new Map([[linked.environmentId, "VPS"]]),
358
+ }),
359
+ ).toEqual([unlinked]);
360
+ });
361
});
362
363
describe("toComposerContextId", () => {
packages/shared/src/composerContextReferences.ts
+5
-2
@@ -322,11 +322,13 @@ export function projectComposerContextForProvider(input: {
322
return `${body}\n\n<${CONTEXT_ENVELOPE_TAG} version="1">\n${entries.join("\n")}\n</${CONTEXT_ENVELOPE_TAG}>`;
323
}
324
325
-// Thread reads are environment-local even when a draft moves between machines.
325
+// An agent reads threads on its own machine and on those it links to, even when a draft
326
+// moves between machines.
327
export function threadContextsOutsideEnvironment(input: {
328
text: string;
329
records: ReadonlyArray<ComposerContextRecord>;
330
environmentId: EnvironmentId;
331
+ linkedEnvironments: ReadonlyMap<EnvironmentId, string>;
332
}): ThreadContextRecord[] {
333
const referenced = new Set(
334
collectComposerContextReferences(input.text).map((occurrence) => occurrence.contextId),
@@ -336,7 +338,8 @@ export function threadContextsOutsideEnvironment(input: {
338
record.kind === "thread" &&
339
"threadId" in record &&
340
referenced.has(record.contextId) &&
339
- record.environmentId !== input.environmentId,
341
+ record.environmentId !== input.environmentId &&
342
+ !input.linkedEnvironments.has(record.environmentId),
343
);
344
}
345