dsh-side-chat-plus 0.3.2 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/index.ts CHANGED
@@ -472,14 +472,22 @@ function buildApi(ctx: Context, sideChats: Map<string, SidechatRecord>, getSetti
472
472
  const items: Array<{ childId: string; running: boolean; runningSince?: number }> = []
473
473
  for (const record of sideChats.values()) {
474
474
  if (record.parentSessionId !== parentSessionId) continue
475
- // "Running" is decided by an open turn in the session log — the same
476
- // signal the main conversation usesinstead of the agent status getter,
477
- // so a turn that already settled can never leave the panel stuck on
478
- // "thinking".
479
- const runningSince = openTurnStart(record.handle.agent.session.events ?? [])
475
+ const agent = record.handle.agent
476
+ // "Running" follows the agent's live lifecycle status — the dominant
477
+ // signal the main conversation uses so the composer flips to the stop
478
+ // button the moment the driver wakes for thinking/streaming, instead of
479
+ // waiting for a durable turn/start to land in the log. A settled driver
480
+ // is always 'idle' again, so a finished turn can never leave the panel
481
+ // stuck on "thinking". Hosts that do not surface the status getter fall
482
+ // back to the open-turn event scan.
483
+ const status = (agent as { status?: string }).status
484
+ const statusRunning = status === 'running'
485
+ const eventRunningSince = openTurnStart(agent.session.events ?? [])
486
+ const running = statusRunning || (status === undefined && eventRunningSince !== undefined)
487
+ const runningSince = running ? (eventRunningSince ?? Date.now()) : undefined
480
488
  items.push({
481
489
  childId: record.childId,
482
- running: runningSince !== undefined,
490
+ running,
483
491
  ...(runningSince !== undefined ? { runningSince } : {}),
484
492
  })
485
493
  }