@@ -37,7 +37,6 @@ import {
3737 type OrchestratorMcpListScheduledTasksInput ,
3838 type ProjectId ,
3939 type OrchestratorMcpThreadDetail ,
40- type OrchestratorMcpThreadPullRequest ,
4140 type OrchestratorMcpThreadInterruptInput ,
4241 type OrchestratorMcpThreadInterruptResult ,
4342 type OrchestratorMcpThreadListInput ,
@@ -804,15 +803,25 @@ function threadSnooze(
804803
805804function threadPullRequests (
806805 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+ } ;
816825}
817826
818827// 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(
842851 runtimeMode : shell . runtimeMode ,
843852 interactionMode : shell . interactionMode ,
844853 linkedPullRequest : shell . linkedPullRequest ?? null ,
845- pullRequests : threadPullRequests ( shell . pullRequests ) ,
854+ ... threadPullRequests ( shell . pullRequests ) ,
846855 ...threadSettlement ( shell ) ,
847856 ...threadSnooze ( shell , nowMs ) ,
848857 parentThreadId : shell . lineage . parentThreadId ,
@@ -859,6 +868,7 @@ function threadDetail(
859868 itemCount : number ,
860869 shell : OrchestrationV2ThreadShell ,
861870 nowMs : number ,
871+ firstPage : boolean ,
862872) : OrchestratorMcpThreadDetail {
863873 const latest = ThreadManagementService . latestRun ( projection ) ;
864874 const active = ThreadManagementService . latestActiveRun ( projection ) ;
@@ -877,7 +887,7 @@ function threadDetail(
877887 runtimeMode : projection . thread . runtimeMode ,
878888 interactionMode : projection . thread . interactionMode ,
879889 linkedPullRequest : projection . thread . linkedPullRequest ?? null ,
880- pullRequests : threadPullRequests ( projection . thread . pullRequests ) ,
890+ ... threadPullRequests ( projection . thread . pullRequests , firstPage ) ,
881891 titleRegeneration :
882892 projection . thread . titleRegeneration === undefined ||
883893 projection . thread . titleRegeneration === null
@@ -3107,6 +3117,7 @@ const make = Effect.gen(function* () {
31073117 timeline . totalItems ,
31083118 shell ,
31093119 yield * Clock . currentTimeMillis ,
3120+ input . afterPosition === undefined && input . itemId === undefined ,
31103121 ) ,
31113122 recentRuns : target . runs
31123123 . toSorted ( ( left , right ) => right . ordinal - left . ordinal )
0 commit comments