Skip to content

Commit 933e152

Browse files
fix(server): thread reads send linked PRs on the first page only
Later t3_thread_read pages keep pullRequestCount and leave the list out. AI-assisted; verified with the tests and tools listed above.
1 parent 259536d commit 933e152

3 files changed

Lines changed: 12 additions & 2 deletions

File tree

‎apps/server/src/mcp/OrchestratorMcpService.activity.test.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,12 @@ it("readThread preserves caller access errors and prefers activity-run status ov
232232
watching: true,
233233
watchStartedAt: "2026-08-04T11:30:00.000Z",
234234
});
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);
235241

236242
callerUnavailable = true;
237243
const denied = yield* service

‎apps/server/src/mcp/OrchestratorMcpService.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -803,8 +803,10 @@ function threadSnooze(
803803

804804
function threadPullRequests(
805805
links: OrchestrationV2ThreadShell["pullRequests"],
806+
includeLinks = true,
806807
): Pick<OrchestratorMcpThreadListItem, "pullRequests" | "pullRequestCount"> {
807808
const visible = visibleThreadPullRequests(links ?? []);
809+
if (!includeLinks) return { pullRequestCount: visible.length };
808810
return {
809811
pullRequests: visible
810812
.filter((link) => link.snapshot?.state !== "merged" && link.snapshot?.state !== "closed")
@@ -866,6 +868,7 @@ function threadDetail(
866868
itemCount: number,
867869
shell: OrchestrationV2ThreadShell,
868870
nowMs: number,
871+
firstPage: boolean,
869872
): OrchestratorMcpThreadDetail {
870873
const latest = ThreadManagementService.latestRun(projection);
871874
const active = ThreadManagementService.latestActiveRun(projection);
@@ -884,7 +887,7 @@ function threadDetail(
884887
runtimeMode: projection.thread.runtimeMode,
885888
interactionMode: projection.thread.interactionMode,
886889
linkedPullRequest: projection.thread.linkedPullRequest ?? null,
887-
...threadPullRequests(projection.thread.pullRequests),
890+
...threadPullRequests(projection.thread.pullRequests, firstPage),
888891
titleRegeneration:
889892
projection.thread.titleRegeneration === undefined ||
890893
projection.thread.titleRegeneration === null
@@ -3114,6 +3117,7 @@ const make = Effect.gen(function* () {
31143117
timeline.totalItems,
31153118
shell,
31163119
yield* Clock.currentTimeMillis,
3120+
input.afterPosition === undefined && input.itemId === undefined,
31173121
),
31183122
recentRuns: target.runs
31193123
.toSorted((left, right) => right.ordinal - left.ordinal)

‎packages/contracts/src/orchestratorMcp.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ export const OrchestratorMcpThreadDetail = Schema.Struct({
449449
runtimeMode: RuntimeMode,
450450
interactionMode: ProviderInteractionMode,
451451
linkedPullRequest: Schema.NullOr(ThreadLinkedPullRequest),
452-
/** Linked pull requests not yet merged or closed; list_thread_pull_requests has all of them. */
452+
/** Open linked pull requests, on the first page only; list_thread_pull_requests has all of them. */
453453
pullRequests: Schema.optional(Schema.Array(OrchestratorMcpThreadPullRequest)),
454454
pullRequestCount: Schema.optional(NonNegativeInt),
455455
titleRegeneration: Schema.NullOr(ThreadTitleRegeneration),

0 commit comments

Comments
 (0)