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:
+10
-22
@@ -1137,14 +1137,6 @@ export const EVENT_SHELL = "shell";
|
|||||||
/** ChatStep.Status values. `ended` is the one status that settles a turn. */
|
/** ChatStep.Status values. `ended` is the one status that settles a turn. */
|
||||||
export const STEP_ENDED = "ended";
|
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). */
|
/** The three things an in-flight turn can be doing (ChatFormat.kt TurnPhase). */
|
||||||
export const TURN_PHASE_THINKING = "thinking";
|
export const TURN_PHASE_THINKING = "thinking";
|
||||||
export const TURN_PHASE_TOOL = "tool";
|
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
|
* The [TURN_PHASE_*] of a running turn. [tools] are the calls the stream still
|
||||||
* reports running; [silentMillis] is how long ago the last text or reasoning
|
* reports running. A running turn with no running call is thinking: the model may
|
||||||
* delta arrived, or null when none has. No percentage, ETA or progress is
|
* be reasoning silently for a minute before its first delta, and calling that
|
||||||
* invented — the only inputs are the calls the stream reported and the time since
|
* "Waiting…" made the chat look idle while it was working. "Waiting…" belongs to a
|
||||||
* the last delta.
|
* 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) {
|
export function turnPhase(tools) {
|
||||||
if ((tools ?? []).length > 0) return TURN_PHASE_TOOL;
|
return (tools ?? []).length > 0 ? TURN_PHASE_TOOL : TURN_PHASE_THINKING;
|
||||||
if (silentMillis != null && silentMillis >= 0 && silentMillis < TURN_THINKING_WINDOW_MILLIS) {
|
|
||||||
return TURN_PHASE_THINKING;
|
|
||||||
}
|
|
||||||
return TURN_PHASE_WAITING;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The running indicator's headline for [phase], naming what is happening. */
|
/** The running indicator's headline for [phase], naming what is happening. */
|
||||||
@@ -1494,9 +1483,8 @@ export function turnPhaseLabel(phase) {
|
|||||||
*/
|
*/
|
||||||
export function threadPhase(thread, nowMillis) {
|
export function threadPhase(thread, nowMillis) {
|
||||||
if (!thread?.running) return null;
|
if (!thread?.running) return null;
|
||||||
const last = Number(thread.lastDeltaAt) || 0;
|
if (thread.queued) return TURN_PHASE_WAITING;
|
||||||
const silent = last >= 1 && last < nowMillis ? nowMillis - last : null;
|
return turnPhase(threadRunningTools(thread.messages));
|
||||||
return turnPhase(threadRunningTools(thread.messages), silent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+12
-5
@@ -67,7 +67,6 @@ import {
|
|||||||
TURN_PHASE_THINKING,
|
TURN_PHASE_THINKING,
|
||||||
TURN_PHASE_TOOL,
|
TURN_PHASE_TOOL,
|
||||||
TURN_PHASE_WAITING,
|
TURN_PHASE_WAITING,
|
||||||
TURN_THINKING_WINDOW_MILLIS,
|
|
||||||
appendChatNotice,
|
appendChatNotice,
|
||||||
applyChatEvent,
|
applyChatEvent,
|
||||||
applyChatOverrides,
|
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", () => {
|
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(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(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…");
|
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", () => {
|
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 - 1), false);
|
||||||
assert.equal(toolLongRunning(TOOL_LONG_RUNNING_MILLIS), true);
|
assert.equal(toolLongRunning(TOOL_LONG_RUNNING_MILLIS), true);
|
||||||
|
|||||||
Reference in New Issue
Block a user