Skip to content

Commit 57a90d8

Browse files
refactor(tui): deepen comment compression in the agent progress module
1 parent a0a4223 commit 57a90d8

2 files changed

Lines changed: 21 additions & 27 deletions

File tree

‎src/tui/agent-progress.test.ts‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ describe("agentProgress", () => {
152152
});
153153
});
154154

155-
// A worker inside one long tool call emits nothing, so a fleet running a
155+
// A worker in one long tool call emits nothing, so a fleet running a
156156
// test suite must not flip every lane to "stalled".
157157
test("silence inside an outstanding tool call is not a stall", () => {
158158
const progress = agentProgress(
@@ -181,8 +181,8 @@ describe("agentProgress", () => {
181181
});
182182

183183
test("default stall window tolerates a multi-minute Grok think gap", () => {
184-
// 300s window: 180s of quiet with no tool outstanding must still read
185-
// working, or worker rows false-stall on healthy Responses thinks.
184+
// 180s of quiet with no tool outstanding must still read working, or
185+
// healthy Responses thinks false-stall the row.
186186
const progress = agentProgress(
187187
{ ...base, currentToolName: null, lastActivityAt: 0 },
188188
180_000,
@@ -330,7 +330,6 @@ describe("fleetLabel", () => {
330330

331331
test("never names stalled count to the operator", () => {
332332
const label = fleetLabel({ running: 6, working: 4, inTool: 0, stalled: 2 });
333-
// the running count is the only number the operator sees
334333
expect(label).toContain("6");
335334
expect(label).not.toContain("2");
336335
expect(label).not.toMatch(/stall/i);
@@ -353,8 +352,6 @@ describe("the in-tool bound", () => {
353352
lastActivityAt: 0,
354353
};
355354

356-
// in_tool must not be terminal, or a wedged build reads as busy forever and
357-
// never reaches the fleet stall count.
358355
test("a call outstanding past the bound escalates to stalled", () => {
359356
expect(laneState(wedged, IN_TOOL_STALL_MS - 1_000)).toBe("in_tool");
360357
expect(laneState(wedged, IN_TOOL_STALL_MS + 1_000)).toBe("stalled");

‎src/tui/agent-progress.ts‎

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/**
22
* Live progress for a dispatched sub-agent's pending transcript row, plus the
3-
* fleet-level roll-up of those lanes.
3+
* fleet roll-up.
44
*
5-
* The pending row lives for the worker's lifetime, not just the tool call in
6-
* flight — the immediate `{status:running}` result must not drop live clocks.
7-
* Lane and fleet share one stalled definition (`laneState` below).
5+
* The pending row lives for the worker's lifetime, not just the tool call —
6+
* the immediate `{status:running}` result must not drop live clocks. Lane and
7+
* fleet share one stalled definition (`laneState`).
88
*/
99

1010
/** Minimal session shape this module reads — avoids a hard dep on the store. */
@@ -37,7 +37,7 @@ export interface AgentProgressSession {
3737
/**
3838
* What a lane is doing, not how long it has been alive.
3939
*
40-
* A worker inside one long tool call emits nothing, so silence alone cannot
40+
* A worker in one long tool call emits nothing, so silence alone cannot
4141
* tell a wedged reactor from a long test run. `stalled` is quiet with no
4242
* outstanding tool to explain it — the only case an operator can act on.
4343
*/
@@ -57,21 +57,20 @@ export interface AgentProgress {
5757
/**
5858
* Silence after which a running worker reads as hung rather than thinking.
5959
*
60-
* Grok routinely sits 60–120s between tool cycles, so a 2-minute bar painted
61-
* healthy gaps as stalled rows and drove dig/cascade thrash. Matches the
60+
* Grok sits 60–120s between tool cycles, so a 2-minute bar painted healthy
61+
* gaps as stalled rows and drove dig/cascade thrash. Matches the
6262
* 5-minute sub-agent stall nudge so UI and salvage agree on "quiet too long".
6363
*/
6464
export const DEFAULT_STALL_MS = 300_000;
6565

6666
/**
67-
* How long one tool call may stay outstanding before the lane reads as
68-
* stalled anyway.
67+
* How long one tool call may stay outstanding before the lane reads stalled.
6968
*
7069
* Without it `in_tool` would be terminal: a wedged build or a shell blocked
71-
* on stdin would read as busy forever. Generous on purpose — real test
72-
* suites and builds run for minutes. Also backstops calls that never report
73-
* a result: the approval-suspend path emits no completion, so it would
74-
* otherwise leave a call outstanding forever.
70+
* on stdin reads busy forever. Generous on purpose — real test suites and
71+
* builds run for minutes. Also backstops calls that never report a result:
72+
* the approval-suspend path emits no completion, so a call stays outstanding
73+
* forever.
7574
*/
7675
export const IN_TOOL_STALL_MS = 600_000;
7776

@@ -130,8 +129,8 @@ export function agentLaneIsLive(session: {
130129
* Progress for a running session's pending row, or null once it has finished
131130
* (a terminal session resolves its row through the tool-result path instead).
132131
*
133-
* The number always explains the state: lifetime for a healthy lane, tool
134-
* runtime for one in a tool, silence length for a quiet one.
132+
* The number explains the state: lifetime for a healthy lane, tool runtime
133+
* for one in a tool, silence length for a quiet one.
135134
*/
136135
export function agentProgress(
137136
session: AgentProgressSession,
@@ -151,8 +150,6 @@ export function agentProgress(
151150
};
152151
}
153152
const elapsed = clockLabel(nowMs - session.startedAt);
154-
// Prefer the argument subject over the bare tool name so shell commands
155-
// stay distinguishable.
156153
const preview = session.currentToolPreview;
157154
const tool = session.currentToolName;
158155
const subject =
@@ -197,11 +194,11 @@ export function agentProgress(
197194
}
198195

199196
/**
200-
* What the whole fleet is doing, rolled up from the per-lane states.
197+
* Fleet roll-up of the per-lane states.
201198
*
202-
* Without the roll-up the top-level indicator reports the parent's own
203-
* activity — mostly awaiting children at fleet scale — so it would read
204-
* "working" while every lane is stuck.
199+
* Without it the top-level indicator reports the parent's own activity —
200+
* mostly awaiting children — so it reads "working" while every lane is
201+
* stuck.
205202
*/
206203
export interface FleetProgress {
207204
readonly running: number;

0 commit comments

Comments
 (0)