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 23, 03:00 UTC
fix(server): MCP thread list and read report every linked pull request (#17454)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Scott Norteman committed
Oct 18, 2026 at 16:11 UTC
d6841e9098a2a289937733d5dd141b02f65a8f0b
4 files changed
+94
-3
apps/server/src/mcp/OrchestratorMcpService.ts
+21
@@ -36,6 +36,7 @@ import {
36
type OrchestratorMcpListScheduledTasksInput,
37
type ProjectId,
38
type OrchestratorMcpThreadDetail,
39
+ type OrchestratorMcpThreadPullRequest,
40
type OrchestratorMcpThreadInterruptInput,
41
type OrchestratorMcpThreadInterruptResult,
42
type OrchestratorMcpThreadListInput,
@@ -60,6 +61,10 @@ import {
61
ThreadId,
62
} from "@t3tools/contracts";
63
import { runRanAfter } from "@t3tools/shared/orchestrationV2ThreadError";
64
+import {
65
+ normalizeThreadPullRequestKey,
66
+ visibleThreadPullRequests,
67
+} from "@t3tools/shared/threadPullRequests";
68
import * as Clock from "effect/Clock";
69
import * as Context from "effect/Context";
70
import * as Crypto from "effect/Crypto";
@@ -709,6 +714,20 @@ function threadSnooze(
714
};
715
}
716
717
+/** The same links `list_thread_pull_requests` reports, without the snapshot details. */
718
+function threadPullRequests(
719
+ links: OrchestrationV2ThreadShell["pullRequests"],
720
+): OrchestratorMcpThreadPullRequest[] {
721
+ return visibleThreadPullRequests(links ?? []).map((link) => ({
722
+ host: normalizeThreadPullRequestKey(link).host,
723
+ repository: link.repository,
724
+ number: link.number,
725
+ url: link.url,
726
+ source: link.source,
727
+ state: link.snapshot?.state ?? null,
728
+ }));
729
+}
730
+
731
function listItemFromShell(
732
shell: OrchestrationV2ThreadShell,
733
nowMs: number,
@@ -725,6 +744,7 @@ function listItemFromShell(
744
runtimeMode: shell.runtimeMode,
745
interactionMode: shell.interactionMode,
746
linkedPullRequest: shell.linkedPullRequest ?? null,
747
+ pullRequests: threadPullRequests(shell.pullRequests),
748
...threadSettlement(shell),
749
...threadSnooze(shell, nowMs),
750
parentThreadId: shell.lineage.parentThreadId,
@@ -757,6 +777,7 @@ function threadDetail(
777
runtimeMode: projection.thread.runtimeMode,
778
interactionMode: projection.thread.interactionMode,
779
linkedPullRequest: projection.thread.linkedPullRequest ?? null,
780
+ pullRequests: threadPullRequests(projection.thread.pullRequests),
781
titleRegeneration:
782
projection.thread.titleRegeneration === undefined ||
783
projection.thread.titleRegeneration === null
apps/server/src/mcp/OrchestratorMcpToolkit.integration.test.ts
+52
@@ -2388,6 +2388,58 @@ describe("orchestrator MCP toolkit", () => {
2388
);
2389
expect(unlinked.linkedPullRequest).toBeNull();
2390
2391
+ // Links added through thread.pull-request.link leave linkedPullRequest unchanged.
2392
+ yield* orchestrator.dispatch({
2393
+ type: "thread.pull-request.link",
2394
+ commandId: CommandId.make("command:mcp-empty:link-other-repository"),
2395
+ threadId: emptyThread.threadId,
2396
+ host: "github.com",
2397
+ repository: "octo/other-repo",
2398
+ number: 42,
2399
+ url: "https://github.com/octo/other-repo/pull/42",
2400
+ source: "agent",
2401
+ });
2402
+ yield* orchestrator.dispatch({
2403
+ type: "thread.pull-request.link",
2404
+ commandId: CommandId.make("command:mcp-empty:link-dismissed"),
2405
+ threadId: emptyThread.threadId,
2406
+ host: "github.com",
2407
+ repository: "octo/other-repo",
2408
+ number: 43,
2409
+ url: "https://github.com/octo/other-repo/pull/43",
2410
+ source: "stack-dismissed",
2411
+ });
2412
+ const otherRepositoryLink = {
2413
+ host: "github.com",
2414
+ repository: "octo/other-repo",
2415
+ number: 42,
2416
+ url: "https://github.com/octo/other-repo/pull/42",
2417
+ source: "agent",
2418
+ state: null,
2419
+ };
2420
+ const otherRepositoryReadCall = yield* invoke("t3_thread_read", {
2421
+ threadId: emptyThread.threadId,
2422
+ });
2423
+ const otherRepositoryRead = yield* decodeThreadReadResult(
2424
+ otherRepositoryReadCall.structuredContent,
2425
+ ).pipe(Effect.orDie);
2426
+ expect(otherRepositoryRead.thread).toMatchObject({
2427
+ linkedPullRequest: null,
2428
+ pullRequests: [otherRepositoryLink],
2429
+ });
2430
+ const otherRepositoryListCall = yield* invoke("t3_thread_list", { limit: 100 });
2431
+ const otherRepositoryList = yield* decodeThreadListResult(
2432
+ otherRepositoryListCall.structuredContent,
2433
+ ).pipe(Effect.orDie);
2434
+ expect(
2435
+ otherRepositoryList.threads.find(
2436
+ (thread) => thread.threadId === emptyThread.threadId,
2437
+ ),
2438
+ ).toMatchObject({ linkedPullRequest: null, pullRequests: [otherRepositoryLink] });
2439
+ expect(
2440
+ otherRepositoryList.threads.find((thread) => thread.threadId === parentThreadId),
2441
+ ).toMatchObject({ pullRequests: [] });
2442
+
2443
const regenerateCall = yield* invoke("t3_thread_update", {
2444
threadId: emptyThread.threadId,
2445
action: "regenerate_title",
apps/server/src/mcp/toolkits/orchestrator/tools.ts
+2
-2
@@ -192,7 +192,7 @@ export const CreateThreadsTool = Tool.make("create_threads", {
192
193
const ThreadListTool = Tool.make("t3_thread_list", {
194
description:
195
- "List T3 threads in a project, newest first. Omit projectId for the calling thread's project. Filter by durable run status, title, or settled state (settled=true lists threads the user or auto-settlement moved out of the active list), or snoozed state, and paginate with the returned cursor. A snoozed thread wakes early when it asks for something, fails, or completes. To link a thread for the user, write `[title](t3-thread://v1/<threadId>)` with the threadId exactly as returned, not URL-encoded; T3 Code shows the thread's current title.",
195
+ "List T3 threads in a project, newest first. Omit projectId for the calling thread's project. Filter by durable run status, title, or settled state (settled=true lists threads the user or auto-settlement moved out of the active list), or snoozed state, and paginate with the returned cursor. A snoozed thread wakes early when it asks for something, fails, or completes. pullRequests lists every pull request linked to each thread; linkedPullRequest is a legacy single link and can be null while pullRequests still has entries. To link a thread for the user, write `[title](t3-thread://v1/<threadId>)` with the threadId exactly as returned, not URL-encoded; T3 Code shows the thread's current title.",
196
parameters: OrchestratorMcpThreadListInput,
197
success: OrchestratorMcpThreadListResult,
198
failure: OrchestratorMcpFailure,
@@ -206,7 +206,7 @@ const ThreadListTool = Tool.make("t3_thread_list", {
206
207
const ThreadReadTool = Tool.make("t3_thread_read", {
208
description:
209
- "Read durable state and a paginated timeline from any T3 thread in this environment. The default messages view returns user messages, assistant messages, and proposed plans; activity returns all summarized timeline items. Reading an untruncated terminal assistant result from this parent thread's direct app-owned child acknowledges that child's automatic completion delivery. Continue with afterPosition=nextPosition. Recover long item text with itemId and textOffset=nextTextOffset until nextTextOffset is null; offsets count UTF-16 code units. The thread also reports its snooze state. To link a thread for the user, write `[title](t3-thread://v1/<threadId>)` with the threadId exactly as returned, not URL-encoded; T3 Code shows the thread's current title.",
209
+ "Read durable state and a paginated timeline from any T3 thread in this environment. The default messages view returns user messages, assistant messages, and proposed plans; activity returns all summarized timeline items. Reading an untruncated terminal assistant result from this parent thread's direct app-owned child acknowledges that child's automatic completion delivery. Continue with afterPosition=nextPosition. Recover long item text with itemId and textOffset=nextTextOffset until nextTextOffset is null; offsets count UTF-16 code units. The thread also reports its snooze state and, in pullRequests, every linked pull request; linkedPullRequest is a legacy single link and can be null while pullRequests still has entries. To link a thread for the user, write `[title](t3-thread://v1/<threadId>)` with the threadId exactly as returned, not URL-encoded; T3 Code shows the thread's current title.",
210
parameters: OrchestratorMcpThreadReadInput,
211
success: OrchestratorMcpThreadReadResult,
212
failure: OrchestratorMcpFailure,
packages/contracts/src/orchestratorMcp.ts
+19
-1
@@ -23,7 +23,12 @@ import {
23
ScheduledTaskUpsertSchedule,
24
} from "./scheduledTask.ts";
25
import { ProviderInteractionMode, RuntimeMode } from "./providerPolicy.ts";
26
-import { ThreadLinkedPullRequest } from "./threadPullRequest.ts";
26
+import { PullRequestState } from "./pullRequest.ts";
27
+import {
28
+ ThreadLinkedPullRequest,
29
+ ThreadPullRequestKey,
30
+ ThreadPullRequestLinkSource,
31
+} from "./threadPullRequest.ts";
32
import { ThreadTitleRegeneration } from "./threadTitle.ts";
33
import {
34
OrchestrationV2Actor,
@@ -304,6 +309,15 @@ export const OrchestratorMcpThreadListInput = Schema.Struct({
309
});
310
export type OrchestratorMcpThreadListInput = typeof OrchestratorMcpThreadListInput.Type;
311
312
+/** A pull request linked to a thread; `state` is null until the host has been read. */
313
+export const OrchestratorMcpThreadPullRequest = Schema.Struct({
314
+ ...ThreadPullRequestKey.fields,
315
+ url: TrimmedNonEmptyString,
316
+ source: ThreadPullRequestLinkSource,
317
+ state: Schema.NullOr(PullRequestState),
318
+});
319
+export type OrchestratorMcpThreadPullRequest = typeof OrchestratorMcpThreadPullRequest.Type;
320
+
321
export const OrchestratorMcpThreadListItem = Schema.Struct({
322
threadId: ThreadId,
323
title: Schema.String,
@@ -316,6 +330,8 @@ export const OrchestratorMcpThreadListItem = Schema.Struct({
330
runtimeMode: RuntimeMode,
331
interactionMode: ProviderInteractionMode,
332
linkedPullRequest: Schema.NullOr(ThreadLinkedPullRequest),
333
+ /** Missing on older servers. */
334
+ pullRequests: Schema.optional(Schema.Array(OrchestratorMcpThreadPullRequest)),
335
settled: Schema.Boolean,
336
settledAt: Schema.NullOr(IsoDateTime),
337
snoozed: Schema.Boolean,
@@ -363,6 +379,8 @@ export const OrchestratorMcpThreadDetail = Schema.Struct({
379
runtimeMode: RuntimeMode,
380
interactionMode: ProviderInteractionMode,
381
linkedPullRequest: Schema.NullOr(ThreadLinkedPullRequest),
382
+ /** Missing on older servers. */
383
+ pullRequests: Schema.optional(Schema.Array(OrchestratorMcpThreadPullRequest)),
384
titleRegeneration: Schema.NullOr(ThreadTitleRegeneration),
385
branch: Schema.NullOr(Schema.String),
386
worktreePath: Schema.NullOr(Schema.String),