@@ -177,7 +177,8 @@ async function recoverStuckSession(
177177 } ) ;
178178}
179179
180- function formatDiagnosticWorkLabel (
180+ function pushLimitedDiagnosticLabel (
181+ labels : string [ ] ,
181182 state : {
182183 sessionId ?: string ;
183184 sessionKey ?: string ;
@@ -187,22 +188,22 @@ function formatDiagnosticWorkLabel(
187188 lastActivity : number ;
188189 } ,
189190 now : number ,
190- ) : string {
191+ ) : void {
191192 const label = state . sessionKey ?? state . sessionId ?? "unknown" ;
192193 const ageSeconds = Math . round ( Math . max ( 0 , now - state . lastActivity ) / 1000 ) ;
193194 const activity = getDiagnosticSessionActivitySnapshot (
194195 { sessionId : state . sessionId , sessionKey : state . sessionKey } ,
195196 now ,
196197 ) ;
198+ // Activity lookup reconciles aliases even when the bounded label list is full.
199+ if ( labels . length >= 5 ) {
200+ return ;
201+ }
197202 const workKind = activity . activeWorkKind ? `/${ activity . activeWorkKind } ` : "" ;
198203 const lastProgress = activity . lastProgressReason ? ` last=${ activity . lastProgressReason } ` : "" ;
199- return `${ label } (${ state . state } ${ workKind } ,q=${ state . queueDepth } ,age=${ ageSeconds } s${ lastProgress } )` ;
200- }
201-
202- function pushLimitedDiagnosticLabel ( labels : string [ ] , label : string , limit = 5 ) : void {
203- if ( labels . length < limit ) {
204- labels . push ( label ) ;
205- }
204+ labels . push (
205+ `${ label } (${ state . state } ${ workKind } ,q=${ state . queueDepth } ,age=${ ageSeconds } s${ lastProgress } )` ,
206+ ) ;
206207}
207208
208209function resolveDiagnosticQueuedBacklog ( state : {
@@ -227,14 +228,14 @@ function getDiagnosticWorkSnapshot(now = Date.now()): DiagnosticWorkSnapshot {
227228 for ( const state of diagnosticSessionStates . values ( ) ) {
228229 if ( state . state === "processing" ) {
229230 activeCount += 1 ;
230- pushLimitedDiagnosticLabel ( activeLabels , formatDiagnosticWorkLabel ( state , now ) ) ;
231+ pushLimitedDiagnosticLabel ( activeLabels , state , now ) ;
231232 } else if ( state . state === "waiting" ) {
232233 waitingCount += 1 ;
233- pushLimitedDiagnosticLabel ( waitingLabels , formatDiagnosticWorkLabel ( state , now ) ) ;
234+ pushLimitedDiagnosticLabel ( waitingLabels , state , now ) ;
234235 }
235236 const queuedBacklog = resolveDiagnosticQueuedBacklog ( state ) ;
236237 if ( queuedBacklog > 0 ) {
237- pushLimitedDiagnosticLabel ( queuedLabels , formatDiagnosticWorkLabel ( state , now ) ) ;
238+ pushLimitedDiagnosticLabel ( queuedLabels , state , now ) ;
238239 }
239240 queuedCount += queuedBacklog ;
240241 }
0 commit comments