diff --git a/apps/web/src/pages/workspace/index.tsx b/apps/web/src/pages/workspace/index.tsx index 87f9c593..be363108 100644 --- a/apps/web/src/pages/workspace/index.tsx +++ b/apps/web/src/pages/workspace/index.tsx @@ -742,16 +742,14 @@ function ReadyRoom({ lastShown?.role === "assistant" && !streaming && !sending ? suggestedReplies(lastShown.text) : []; - // Mid-turn by native state, whoever sent the message: this stream saw the message run start and - // not end, or the hub's activity read saw one start after the last end this stream saw. const agents = activity.data?.agents; - const coordinatorTurnSince = agents?.find( - (agent) => agent.role === "coordinator", - )?.since; + const coordinator = agents?.find((agent) => agent.role === "coordinator"); + // Mid-turn by the hub's read: the coordinator's run began after the last end this stream saw. + // The stream's own flag is not used; a frame missed while the tab is hidden leaves it set. const working = - liveRun.running || - (coordinatorTurnSince !== undefined && - Date.parse(coordinatorTurnSince) > (liveRun.endedAt ?? 0)); + coordinator !== undefined && + (liveRun.endedAt === null || + Date.parse(coordinator.since) > liveRun.endedAt); // The engine treats the first id as history and every later change as a // send: it pins that turn and reserves space under it. A turn loaded from // the mirror is not a send. Passing it pins the old message and the reserve @@ -1244,11 +1242,8 @@ function ReadyRoom({ for (const dispatch of dispatches) noteDispatch(dispatchRoom, dispatch); // The document a writer or reviewer run works on, from the coordinator's own hand-off call as // the hub's activity read saw it start: the latest such call made before the run started. - const coordinatorTools = agents?.find( - (agent) => agent.role === "coordinator", - )?.tools; - if (coordinatorTools !== undefined) - for (const tool of coordinatorTools) { + if (coordinator !== undefined) + for (const tool of coordinator.tools) { const role = HANDOFF_ROLE[tool.name]; if (role !== undefined && tool.subject !== undefined) handoffCalls.current.set(`${tool.at}:${tool.name}`, {