99 isOrchestrationV2WorkActive ,
1010 isProviderNativeSubagentThread ,
1111 latestProviderTurnForAttempt ,
12+ PROVIDER_DISPLAY_NAMES ,
1213 type ModelSelection ,
1314 type OrchestrationV2NotificationSource ,
1415 type OrchestrationV2PendingBackgroundTask ,
@@ -50,6 +51,8 @@ import { formatSubagentDisplayTitle } from "./subagentDisplay.ts";
5051
5152const ACTIVITY_RUN_STATUSES = new Set ( [ "preparing" , "starting" , "running" , "waiting" ] ) ;
5253const INTERRUPTIBLE_RUN_STATUSES = new Set ( [ "preparing" , "starting" , "running" ] ) ;
54+ // Preparing runs show their workspace setup instead.
55+ const PROVIDER_STARTING_RUN_STATUSES = new Set ( [ "starting" , "running" ] ) ;
5356
5457const EMPTY_EXTENSION_STATUSES : NonNullable < OrchestrationV2ProviderSession [ "extensionStatuses" ] > =
5558 [ ] ;
@@ -103,6 +106,17 @@ function latestMatchingRun(
103106 ) ;
104107}
105108
109+ function providerStartingLabel (
110+ projection : ThreadStructure ,
111+ run : OrchestrationV2ThreadProjection [ "runs" ] [ number ] ,
112+ ) : string {
113+ const driver = projection . providerSessions . findLast (
114+ ( session ) => session . providerInstanceId === run . providerInstanceId ,
115+ ) ?. driver ;
116+ const name = driver === undefined ? undefined : PROVIDER_DISPLAY_NAMES [ driver ] ;
117+ return name === undefined ? "Starting" : `Starting ${ name } ` ;
118+ }
119+
106120function summarizeThreadRun (
107121 projection : ThreadStructure ,
108122 run : OrchestrationV2ThreadProjection [ "runs" ] [ number ] ,
@@ -120,9 +134,15 @@ function summarizeThreadRun(
120134 projection . messages . findLast (
121135 ( message ) => message . runId === run . id && message . role === "assistant" ,
122136 ) ?. id ?? null ,
123- ...( turnStatus === undefined || turnStatus === "pending" || turnStatus === "running"
124- ? { }
125- : { turnEnded : true } ) ,
137+ // A run counts as running before its provider opens; until a turn appears,
138+ // the provider can still be launching for minutes.
139+ ...( turnStatus === undefined
140+ ? PROVIDER_STARTING_RUN_STATUSES . has ( run . status )
141+ ? { providerStartingLabel : providerStartingLabel ( projection , run ) }
142+ : { }
143+ : turnStatus === "pending" || turnStatus === "running"
144+ ? { }
145+ : { turnEnded : true } ) ,
126146 ...( run . sourcePlanRef === undefined ? { } : { sourcePlanRef : run . sourcePlanRef } ) ,
127147 } ;
128148}
0 commit comments