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 21, 21:00 UTC
fix(server): thread reads list only open linked PRs and show their watch state (#34895)
Julius Marminge committed
Nov 11, 2026 at 23:52 UTC
1df9c91230c3c9e3ada0a91659b1333e0014f4f0
3 files changed
+76
-18
apps/server/src/mcp/OrchestratorMcpService.activity.test.ts
+47
-6
@@ -124,13 +124,41 @@ function makeRun(input: {
124
125
it("readThread preserves caller access errors and prefers activity-run status over a newer cancelled queued run", async () => {
126
let callerUnavailable = false;
127
+ const pullRequestLink = (number: number, state: "open" | "merged", watched: boolean) => ({
128
+ host: "github.com",
129
+ repository: "acme/web",
130
+ number,
131
+ url: `https://github.com/acme/web/pull/${number}`,
132
+ source: "agent",
133
+ linkedAt: "2026-08-04T11:00:00.000Z",
134
+ snapshot: { state },
135
+ stack: null,
136
+ ...(watched
137
+ ? {
138
+ watch: {
139
+ startedAt: "2026-08-04T11:30:00.000Z",
140
+ headSha: null,
141
+ failedChecks: [],
142
+ passed: false,
143
+ passedChecks: [],
144
+ remarksThrough: "2026-08-04T11:30:00.000Z",
145
+ remarkIds: [],
146
+ conflicting: false,
147
+ wakes: 0,
148
+ },
149
+ }
150
+ : {}),
151
+ });
152
const projection = {
128
- thread: baseThread({
129
- threadId: parentThreadId,
130
- title: "Parent",
131
- instanceId: parentInstanceId,
132
- model: "gpt-5.4",
133
- }),
153
+ thread: {
154
+ ...baseThread({
155
+ threadId: parentThreadId,
156
+ title: "Parent",
157
+ instanceId: parentInstanceId,
158
+ model: "gpt-5.4",
159
+ }),
160
+ pullRequests: [pullRequestLink(1, "merged", false), pullRequestLink(2, "open", true)],
161
+ },
162
runs: [
163
makeRun({ id: activeRunId, ordinal: 1, status: "running" }),
164
makeRun({ id: cancelledRunId, ordinal: 2, status: "cancelled" }),
@@ -197,6 +225,19 @@ it("readThread preserves caller access errors and prefers activity-run status ov
225
expect(result.thread.status).toBe("running");
226
expect(result.thread.latestRunId).toBe(cancelledRunId);
227
expect(result.thread.activeRunId).toBe(activeRunId);
228
+ // Every page read must not repeat each linked PR, and an open PR shows whether it is watched.
229
+ const listed = result.thread.pullRequests ?? [];
230
+ expect(listed.map((link) => link.number)).not.toContain(1);
231
+ expect(listed.find((link) => link.number === 2)).toMatchObject({
232
+ watching: true,
233
+ watchStartedAt: "2026-08-04T11:30:00.000Z",
234
+ });
235
+ const laterPage = yield* service.readThread(makeScope(), {
236
+ threadId: parentThreadId,
237
+ afterPosition: 0,
238
+ });
239
+ expect(laterPage.thread.pullRequests).toBeUndefined();
240
+ expect(laterPage.thread.pullRequestCount).toBe(2);
241
242
callerUnavailable = true;
243
const denied = yield* service
apps/server/src/mcp/OrchestratorMcpService.ts
+23
-12
@@ -37,7 +37,6 @@ import {
37
type OrchestratorMcpListScheduledTasksInput,
38
type ProjectId,
39
type OrchestratorMcpThreadDetail,
40
- type OrchestratorMcpThreadPullRequest,
40
type OrchestratorMcpThreadInterruptInput,
41
type OrchestratorMcpThreadInterruptResult,
42
type OrchestratorMcpThreadListInput,
@@ -804,15 +803,25 @@ function threadSnooze(
803
804
function threadPullRequests(
805
links: OrchestrationV2ThreadShell["pullRequests"],
807
-): OrchestratorMcpThreadPullRequest[] {
808
- return visibleThreadPullRequests(links ?? []).map((link) => ({
809
- host: normalizeThreadPullRequestKey(link).host,
810
- repository: link.repository,
811
- number: link.number,
812
- url: link.url,
813
- source: link.source,
814
- state: link.snapshot?.state ?? null,
815
- }));
806
+ includeLinks = true,
807
+): Pick<OrchestratorMcpThreadListItem, "pullRequests" | "pullRequestCount"> {
808
+ const visible = visibleThreadPullRequests(links ?? []);
809
+ if (!includeLinks) return { pullRequestCount: visible.length };
810
+ return {
811
+ pullRequests: visible
812
+ .filter((link) => link.snapshot?.state !== "merged" && link.snapshot?.state !== "closed")
813
+ .map((link) => ({
814
+ host: normalizeThreadPullRequestKey(link).host,
815
+ repository: link.repository,
816
+ number: link.number,
817
+ url: link.url,
818
+ source: link.source,
819
+ state: link.snapshot?.state ?? null,
820
+ watching: link.watch !== undefined,
821
+ watchStartedAt: link.watch?.startedAt ?? null,
822
+ })),
823
+ pullRequestCount: visible.length,
824
+ };
825
}
826
827
// Awaited background work keeps a thread live after its turn ends, as auto-settle and the sidebar treat it.
@@ -842,7 +851,7 @@ function listItemFromShell(
851
runtimeMode: shell.runtimeMode,
852
interactionMode: shell.interactionMode,
853
linkedPullRequest: shell.linkedPullRequest ?? null,
845
- pullRequests: threadPullRequests(shell.pullRequests),
854
+ ...threadPullRequests(shell.pullRequests),
855
...threadSettlement(shell),
856
...threadSnooze(shell, nowMs),
857
parentThreadId: shell.lineage.parentThreadId,
@@ -859,6 +868,7 @@ function threadDetail(
868
itemCount: number,
869
shell: OrchestrationV2ThreadShell,
870
nowMs: number,
871
+ firstPage: boolean,
872
): OrchestratorMcpThreadDetail {
873
const latest = ThreadManagementService.latestRun(projection);
874
const active = ThreadManagementService.latestActiveRun(projection);
@@ -877,7 +887,7 @@ function threadDetail(
887
runtimeMode: projection.thread.runtimeMode,
888
interactionMode: projection.thread.interactionMode,
889
linkedPullRequest: projection.thread.linkedPullRequest ?? null,
880
- pullRequests: threadPullRequests(projection.thread.pullRequests),
890
+ ...threadPullRequests(projection.thread.pullRequests, firstPage),
891
titleRegeneration:
892
projection.thread.titleRegeneration === undefined ||
893
projection.thread.titleRegeneration === null
@@ -3107,6 +3117,7 @@ const make = Effect.gen(function* () {
3117
timeline.totalItems,
3118
shell,
3119
yield* Clock.currentTimeMillis,
3120
+ input.afterPosition === undefined && input.itemId === undefined,
3121
),
3122
recentRuns: target.runs
3123
.toSorted((left, right) => right.ordinal - left.ordinal)
packages/contracts/src/orchestratorMcp.ts
+6
@@ -357,6 +357,8 @@ export const OrchestratorMcpThreadPullRequest = Schema.Struct({
357
url: TrimmedNonEmptyString,
358
source: ThreadPullRequestLinkSource,
359
state: Schema.NullOr(PullRequestState),
360
+ watching: Schema.Boolean,
361
+ watchStartedAt: Schema.NullOr(IsoDateTime),
362
});
363
export type OrchestratorMcpThreadPullRequest = typeof OrchestratorMcpThreadPullRequest.Type;
364
@@ -374,7 +376,9 @@ export const OrchestratorMcpThreadListItem = Schema.Struct({
376
runtimeMode: RuntimeMode,
377
interactionMode: ProviderInteractionMode,
378
linkedPullRequest: Schema.NullOr(ThreadLinkedPullRequest),
379
+ /** Linked pull requests not yet merged or closed; list_thread_pull_requests has all of them. */
380
pullRequests: Schema.optional(Schema.Array(OrchestratorMcpThreadPullRequest)),
381
+ pullRequestCount: Schema.optional(NonNegativeInt),
382
settled: Schema.Boolean,
383
settledAt: Schema.NullOr(IsoDateTime),
384
snoozed: Schema.Boolean,
@@ -445,7 +449,9 @@ export const OrchestratorMcpThreadDetail = Schema.Struct({
449
runtimeMode: RuntimeMode,
450
interactionMode: ProviderInteractionMode,
451
linkedPullRequest: Schema.NullOr(ThreadLinkedPullRequest),
452
+ /** Open linked pull requests, on the first page only; list_thread_pull_requests has all of them. */
453
pullRequests: Schema.optional(Schema.Array(OrchestratorMcpThreadPullRequest)),
454
+ pullRequestCount: Schema.optional(NonNegativeInt),
455
titleRegeneration: Schema.NullOr(ThreadTitleRegeneration),
456
branch: Schema.NullOr(Schema.String),
457
worktreePath: Schema.NullOr(Schema.String),