MCPcopy Create free account
hub / github.com/Noumena-Network/code / updateStatusDisplay

Function updateStatusDisplay

src/bridge/bridgeMain.ts:384–432  ·  view source on GitHub ↗

Refresh the inline status display. Shows idle or active depending on state.

()

Source from the content-addressed store, hash-verified

382
383 /** Refresh the inline status display. Shows idle or active depending on state. */
384 function updateStatusDisplay(): void {
385 // Push the session count (no-op when maxSessions === 1) so the
386 // next renderStatusLine tick shows the current count.
387 logger.updateSessionCount(
388 activeSessions.size,
389 config.maxSessions,
390 config.spawnMode,
391 )
392
393 // Push per-session activity into the multi-session display.
394 for (const [sid, handle] of activeSessions) {
395 const act = handle.currentActivity
396 if (act) {
397 logger.updateSessionActivity(sessionCompatIds.get(sid) ?? sid, act)
398 }
399 }
400
401 if (activeSessions.size === 0) {
402 logger.updateIdleStatus()
403 return
404 }
405
406 // Show the most recently started session that is still actively working.
407 // Sessions whose current activity is 'result' or 'error' are between
408 // turns — the CLI emitted its result but the process stays alive waiting
409 // for the next user message. Skip updating so the status line keeps
410 // whatever state it had (Attached / session title).
411 const [sessionId, handle] = [...activeSessions.entries()].pop()!
412 const startTime = sessionStartTimes.get(sessionId)
413 if (!startTime) return
414
415 const activity = handle.currentActivity
416 if (!activity || activity.type === 'result' || activity.type === 'error') {
417 // Session is between turns — keep current status (Attached/titled).
418 // In multi-session mode, still refresh so bullet-list activities stay current.
419 if (config.maxSessions > 1) logger.refreshDisplay()
420 return
421 }
422
423 const elapsed = formatDuration(Date.now() - startTime)
424
425 // Build trail from recent tool activities (last 5)
426 const trail = handle.activities
427 .filter(a => a.type === 'tool_start')
428 .slice(-5)
429 .map(a => a.summary)
430
431 logger.updateSessionStatus(sessionId, elapsed, activity, trail)
432 }
433
434 /** Start the status display update ticker. */
435 function startStatusUpdates(): void {

Callers 1

startStatusUpdatesFunction · 0.85

Calls 3

entriesMethod · 0.80
formatDurationFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected