Skip to content

Commit 929d2f4

Browse files
committed
Show finished sub-agent durations only and fix related tests
Drop live Date.now() duration from running strip labels so formatSessionLabel stays deterministic. Update chrome-zone StatusBar props and agents-strip expectations for finishedAt durations.
1 parent 245147f commit 929d2f4

3 files changed

Lines changed: 15 additions & 5 deletions

File tree

src/tui/components/agents-strip.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -314,12 +314,12 @@ function currentToolArguments(session: SubAgentSession): string {
314314
}
315315

316316
export function formatSessionLabel(session: SubAgentSession): string {
317+
// Only finished workers get a duration suffix — matches status-bar policy
318+
// (completed sub-agent times, not a live tick for in-flight sessions).
317319
const duration =
318320
session.finishedAt !== undefined && session.finishedAt >= session.startedAt
319321
? formatStripDuration(session.finishedAt - session.startedAt)
320-
: session.status === "running"
321-
? formatStripDuration(Date.now() - session.startedAt)
322-
: undefined;
322+
: undefined;
323323
const durationSuffix = duration !== undefined ? ` · ${duration}` : "";
324324
if (session.status === "running" && session.currentToolName !== null) {
325325
const args = currentToolArguments(session);

tests/unit/tui/agents-strip.test.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,9 @@ describe("formatSessionLabel", () => {
258258
status: "done",
259259
currentToolName: null,
260260
toolNames: ["grep", "read_file"],
261+
finishedAt: 5_000,
261262
});
262-
expect(formatSessionLabel(session)).toBe("researcher: researching things · 2 tools");
263+
expect(formatSessionLabel(session)).toBe("researcher: researching things · 2 tools · 5s");
263264
});
264265

265266
test("shell tool preview leads with the command, not a redundant tool name", () => {
@@ -269,6 +270,15 @@ describe("formatSessionLabel", () => {
269270
const session = baseSession({ currentToolName: "run_shell", entries });
270271
expect(formatSessionLabel(session)).toBe("researcher: researching things — bun test");
271272
});
273+
274+
test("appends finished duration when finishedAt is set", () => {
275+
const session = baseSession({
276+
status: "done",
277+
currentToolName: null,
278+
finishedAt: 65_000,
279+
});
280+
expect(formatSessionLabel(session)).toBe("researcher: researching things · 1m 5s");
281+
});
272282
});
273283

274284
describe("agentsStripRowColor", () => {

tests/unit/tui/chrome-zone-budgets.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ test("status budget matches the rows StatusBar paints inside App's marginTop wra
3535
// App wraps StatusBar in <Box marginTop={1}>; mirror that wrapper here.
3636
const { lastFrame } = render(
3737
<Box marginTop={1}>
38-
<StatusBar sessionElapsedMs={0} mcpCount={0} />
38+
<StatusBar mcpCount={0} />
3939
</Box>,
4040
);
4141
expect(frameRows(lastFrame())).toBe(CHROME_ZONE_ROWS.status);

0 commit comments

Comments
 (0)