web: a running chat reads Thinking… until a tool starts

The indicator called a silent turn "Waiting…" after 2.5s without a delta, so a
model reasoning for a minute looked idle. A running turn is now thinking for as
long as it is silent; Waiting… is reserved for a prompt queued behind the turn in
flight.
This commit is contained in:
2026-10-19 23:22:33 +01:00
parent 053bbe68a1
commit ccb97e424b
2 changed files with 22 additions and 27 deletions
+10 -22
View File
@@ -1137,14 +1137,6 @@ export const EVENT_SHELL = "shell";
/** ChatStep.Status values. `ended` is the one status that settles a turn. */
export const STEP_ENDED = "ended";
/**
* How recently a text or reasoning delta must have arrived for a turn to read as
* still thinking. Long enough that the indicator's tick cannot flicker between
* thinking and waiting on a steady stream, short enough that a stalled turn
* starts reading as waiting while the operator still wonders.
*/
export const TURN_THINKING_WINDOW_MILLIS = 2500;
/** The three things an in-flight turn can be doing (ChatFormat.kt TurnPhase). */
export const TURN_PHASE_THINKING = "thinking";
export const TURN_PHASE_TOOL = "tool";
@@ -1466,18 +1458,15 @@ export function runningToolStamps(current, messages, now) {
}
/**
* The [TURN_PHASE_*] of a turn in flight. [tools] are the calls the stream still
* reports running; [silentMillis] is how long ago the last text or reasoning
* delta arrived, or null when none has. No percentage, ETA or progress is
* invented — the only inputs are the calls the stream reported and the time since
* the last delta.
* The [TURN_PHASE_*] of a running turn. [tools] are the calls the stream still
* reports running. A running turn with no running call is thinking: the model may
* be reasoning silently for a minute before its first delta, and calling that
* "Waiting…" made the chat look idle while it was working. "Waiting…" belongs to a
* prompt that is queued behind the turn already in flight, never to a live turn.
* No percentage, ETA or progress is invented.
*/
export function turnPhase(tools, silentMillis) {
if ((tools ?? []).length > 0) return TURN_PHASE_TOOL;
if (silentMillis != null && silentMillis >= 0 && silentMillis < TURN_THINKING_WINDOW_MILLIS) {
return TURN_PHASE_THINKING;
}
return TURN_PHASE_WAITING;
export function turnPhase(tools) {
return (tools ?? []).length > 0 ? TURN_PHASE_TOOL : TURN_PHASE_THINKING;
}
/** The running indicator's headline for [phase], naming what is happening. */
@@ -1494,9 +1483,8 @@ export function turnPhaseLabel(phase) {
*/
export function threadPhase(thread, nowMillis) {
if (!thread?.running) return null;
const last = Number(thread.lastDeltaAt) || 0;
const silent = last >= 1 && last < nowMillis ? nowMillis - last : null;
return turnPhase(threadRunningTools(thread.messages), silent);
if (thread.queued) return TURN_PHASE_WAITING;
return turnPhase(threadRunningTools(thread.messages));
}
/**
+12 -5
View File
@@ -67,7 +67,6 @@ import {
TURN_PHASE_THINKING,
TURN_PHASE_TOOL,
TURN_PHASE_WAITING,
TURN_THINKING_WINDOW_MILLIS,
appendChatNotice,
applyChatEvent,
applyChatOverrides,
@@ -1296,15 +1295,23 @@ test("the chat stream badge uses the live / reconnecting / not live words", () =
});
test("the turn phase names what is happening", () => {
assert.equal(turnPhase([], 1000), TURN_PHASE_THINKING);
assert.equal(turnPhase([]), TURN_PHASE_THINKING);
assert.equal(turnPhaseLabel(TURN_PHASE_THINKING), "Thinking…");
assert.equal(turnPhase([{ type: "tool", id: "t", state: { status: "running" } }], 100000), TURN_PHASE_TOOL);
assert.equal(turnPhase([{ type: "tool", id: "t", state: { status: "running" } }]), TURN_PHASE_TOOL);
assert.equal(turnPhaseLabel(TURN_PHASE_TOOL), "Running a tool…");
assert.equal(turnPhase([], null), TURN_PHASE_WAITING);
assert.equal(turnPhase([], TURN_THINKING_WINDOW_MILLIS), TURN_PHASE_WAITING);
assert.equal(turnPhaseLabel(TURN_PHASE_WAITING), "Waiting…");
});
test("a running turn reads as thinking at any silence; a queued prompt waits", () => {
let thread = newChatThread("s1");
thread = applyChatEvent(thread, evt("step", { step: { status: "started" } }), 1000);
// Two minutes without a delta: still the model's own work, not idle.
assert.equal(threadPhase(thread, 121000), TURN_PHASE_THINKING);
const queued = { ...thread, queued: true };
assert.equal(threadPhase(queued, 121000), TURN_PHASE_WAITING);
assert.equal(threadPhase({ ...thread, running: false }, 121000), null);
});
test("only a call at or past 60s reads as long", () => {
assert.equal(toolLongRunning(TOOL_LONG_RUNNING_MILLIS - 1), false);
assert.equal(toolLongRunning(TOOL_LONG_RUNNING_MILLIS), true);