Skip to content

Commit 210b364

Browse files
improve(ui): stop showing failed counts on grouped agent work
Co-authored-by: steipete <[email protected]>
1 parent cd566f3 commit 210b364

19 files changed

Lines changed: 112 additions & 180 deletions

‎scripts/lib/control-ui-i18n-catalog.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ export function loadControlUiSourceCatalog(): TranslationMap {
261261
? ["viewMode", "diff", "raw"]
262262
: key === "openFile"
263263
? ["openDetails"]
264-
: key === "failureCount"
264+
: key === "exitCode"
265265
? ["noOutputFailed"]
266266
: [];
267267
for (const contentKey of contentKeys) {

‎ui/src/e2e/chat-nested-tool-presentation.e2e.test.ts‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ async function expectCollapsed(work: Locator) {
4242
expect(await summary.locator(".chat-activity-group__label").textContent()).toBe(
4343
"1 command · 1 read",
4444
);
45-
expect((await summary.textContent())?.match(/1 failed/g)).toHaveLength(1);
45+
// The step completed and the agent replied, so its recovered child failure stays on its row.
46+
expect(await summary.textContent()).not.toContain("failed");
4647
expect(await summary.textContent()).not.toContain("/workspace/README.md");
47-
expect(await summary.getByText("1 failed", { exact: true }).isVisible()).toBe(true);
4848
expect(await work.textContent()).not.toContain("gh: command not found");
4949
}
5050

@@ -76,7 +76,7 @@ function nestedHistory() {
7676
}
7777

7878
suite.define(() => {
79-
it("keeps failed child diagnostics behind disclosure, including after reload", async () => {
79+
it("keeps a recovered child failure on its own row, including after reload", async () => {
8080
await suite.withPage(contextOptions, async ({ page }) => {
8181
const gateway = await installMockGateway(page, {
8282
methodResponses: {
@@ -112,7 +112,6 @@ suite.define(() => {
112112
const summary = work.locator(":scope > .chat-activity-group__summary");
113113
await summary.waitFor();
114114
await expectCollapsed(work);
115-
const failure = summary.getByText("1 failed", { exact: true });
116115
expect(await work.textContent()).not.toContain("Sign in to GitHub");
117116
await summary.click();
118117
const activityBody = work.locator(".chat-activity-group__body");
@@ -121,11 +120,12 @@ suite.define(() => {
121120
hasText: "Start GitHub authentication",
122121
});
123122
await wrapper.waitFor();
124-
expect(await wrapper.textContent()).toContain("1 failed");
123+
expect(await wrapper.textContent()).not.toContain("failed");
125124
await wrapper.click();
126125
const children = activityBody.locator(".chat-tool-children");
127126
const login = children.locator(".chat-tool-msg-summary", { hasText: "GitHub sign-in" });
128127
await login.waitFor();
128+
await login.locator(".chat-tool-failure").waitFor();
129129
expect(await activityBody.getByText("gh: command not found").count()).toBe(0);
130130
await login.click();
131131
await activityBody.getByText(command, { exact: true }).first().waitFor();
@@ -145,8 +145,7 @@ suite.define(() => {
145145
await page.emulateMedia({ reducedMotion: "reduce" });
146146
await page.setViewportSize({ width: 390, height: 844 });
147147
await page.locator('.shell-nav[aria-hidden="true"]').waitFor({ state: "attached" });
148-
await failure.waitFor();
149-
expect(await failure.isVisible()).toBe(true);
148+
await expectCollapsed(work);
150149
expect(await work.textContent()).not.toContain("gh: command not found");
151150
});
152151
});

‎ui/src/e2e/chat-tool-item-outcomes.test-support.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ export function registerItemOnlyOutcomeTest(
201201
const summary = page.locator(".chat-activity-group__summary").first();
202202
await summary.waitFor();
203203
await captureToolActivityProof(page, `item-outcomes-${stage}-collapsed`);
204-
expect.soft(await summary.textContent()).toContain("1 failed");
204+
expect.soft(await summary.textContent()).not.toContain("failed");
205205
await summary.click();
206206
const rows = page.locator(".chat-activity-group__body .chat-tool-msg-summary");
207207
await expect.poll(() => rows.count()).toBe(3);

‎ui/src/e2e/chat-tool-steering-skip.e2e.test.ts‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,8 @@ suite.define(() => {
9595
await historyPage.goto(`${suite.server.baseUrl}chat`);
9696
await historyPage.locator(".chat-text").getByText(completed, { exact: true }).waitFor();
9797
const group = historyPage.locator(".chat-activity-group__summary").first();
98-
expect(await group.textContent()).toContain("1 failed");
99-
expect((await group.textContent())?.match(/1 skipped/gu)).toHaveLength(1);
100-
expect(await group.textContent()).not.toContain("blocked");
98+
// Completed work leaves failed and skipped steps to their rows.
99+
expect(await group.textContent()).not.toMatch(/failed|skipped|blocked/u);
101100
expect(await group.locator(".chat-activity-group__label").textContent()).not.toContain(
102101
"Write (failed)",
103102
);
@@ -108,8 +107,7 @@ suite.define(() => {
108107
expect(await historyRow.textContent()).toContain("Skipped");
109108
await historyRow.click({ position: { x: 4, y: 4 } });
110109
expect(await historyPage.locator(".chat-tool-card__outcome").textContent()).toBe("Skipped");
111-
expect((await group.textContent())?.match(/1 skipped/gu)).toHaveLength(1);
112-
expect(await group.textContent()).not.toContain("blocked");
110+
expect(await group.textContent()).not.toMatch(/failed|skipped|blocked/u);
113111
} finally {
114112
await context.close();
115113
}

‎ui/src/e2e/chat-tool-turn-outcome.e2e.test.ts‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ suite.define(() => {
234234
},
235235
);
236236

237-
it("keeps an earlier autonomous failure visible after a later turn recovers", async () => {
237+
it("keeps an earlier autonomous failure on its row after a later turn recovers", async () => {
238238
const sessionKey = "agent:main:dashboard:tool-turn-outcome";
239239
const { context, page } = await openChat(
240240
[
@@ -255,9 +255,8 @@ suite.define(() => {
255255
await page.getByText("Recovered on the next autonomous turn.", { exact: true }).waitFor();
256256
const workSummaries = page.locator(".chat-work-group > .chat-activity-group__summary");
257257
await workSummaries.first().waitFor();
258-
expect(await workSummaries.first().getByText("1 failed", { exact: true }).isVisible()).toBe(
259-
true,
260-
);
258+
// The recovery reply owns the outcome; the failed call keeps its status on its own row.
259+
expect(await workSummaries.first().textContent()).not.toContain("failed");
261260
expect(await page.getByText("Command could not finish", { exact: false }).count()).toBe(0);
262261
for (let index = 0; index < (await workSummaries.count()); index += 1) {
263262
const summary = workSummaries.nth(index);

‎ui/src/i18n/locales/en-chat-tool-labels.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ const enChatToolLabels = {
6161
blocked: "Blocked",
6262
outcomeUnknown: "Outcome unknown",
6363
exitCode: "Exit code {code}",
64-
failureCount: "{count} failed",
6564
noOutputSucceeded: "No output — tool completed successfully.",
6665
noResult: "No result available.",
6766
review: {

‎ui/src/lib/chat/tool-call-grouping.test.ts‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ describe("summarizeToolGroup", () => {
3535
toolCallId: "refused",
3636
status: "failed",
3737
});
38-
expect(summarizeToolGroup([...launches, refused])).toBe(
39-
"1 other operation · 3 subagents · 1 failed",
40-
);
38+
expect(summarizeToolGroup([...launches, refused])).toBe("1 other operation · 3 subagents");
4139
});
4240

4341
it("replaces running state with the same operation's outcome without counting suppressed siblings", () => {
@@ -47,10 +45,10 @@ describe("summarizeToolGroup", () => {
4745
prepared("tool:call", "Inspect", { toolCallId: "call", status: "failed" }),
4846
prepared("command:call", "Command", { toolCallId: "call", suppressChannelProgress: true }),
4947
]),
50-
).toBe("1 other operation · 1 failed");
48+
).toBe("1 other operation");
5149
});
5250

53-
it("keeps failure, approval, skipped, and unknown outcomes while quiet work stays out", () => {
51+
it("keeps approval and unknown outcomes but leaves failed and skipped steps to their rows", () => {
5452
expect(
5553
summarizeToolGroup([
5654
prepared("quiet", "Wait", { hideFromChannelProgress: true }),
@@ -60,7 +58,7 @@ describe("summarizeToolGroup", () => {
6058
prepared("unknown", "Outcome unknown", { status: undefined }),
6159
prepared("unpaired", "Run build", { status: undefined, unpairedCall: true }),
6260
]),
63-
).toBe("5 other operations · 1 failed · 1 blocked · 1 skipped · 1 unknown");
61+
).toBe("5 other operations · 1 blocked · 1 unknown");
6462
});
6563

6664
it("keeps the diagnostic disclosure label when all prepared work is quiet", () => {

‎ui/src/lib/chat/tool-call-grouping.ts‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,20 @@ export function describeToolGroup(
4848
return { total: summary.total, label, outcomes };
4949
}
5050

51+
/**
52+
* Failed and skipped steps stay on their own rows: agents recover from routine
53+
* failures, and a run that ends in one reports it through its own error message.
54+
*/
5155
export function summarizeToolGroup(
5256
items: readonly AgentActivityItem[],
53-
options: ToolGroupOptions & { includeInlineOutcomes?: boolean } = {},
57+
options: ToolGroupOptions = {},
5458
): string {
5559
const summary = describeToolGroup(items, options);
5660
return (
5761
[
5862
summary.label,
5963
...summary.outcomes
60-
.filter(
61-
({ kind }) =>
62-
options.includeInlineOutcomes !== false || (kind !== "failed" && kind !== "skipped"),
63-
)
64+
.filter(({ kind }) => kind !== "failed" && kind !== "skipped")
6465
.map(({ label }) => label),
6566
]
6667
.filter(Boolean)

‎ui/src/pages/chat/components/chat-activity-disclosure.test.ts‎

Lines changed: 54 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ it("commits a cached activity summary with its transcript row", () => {
5050
const row = summaryContainer.querySelector('[data-chat-row-key="cached"]');
5151
expect(row).not.toBeNull();
5252
expect(row?.querySelector(".chat-activity-group__summary")?.textContent).toContain("1 read");
53-
expect(row?.querySelector(".chat-tool-failure")?.textContent).toBe("1 failed");
53+
expect(row?.querySelector(".chat-tool-failure")).toBeNull();
5454
});
5555

5656
function read(id: string, overrides: Record<string, unknown> = {}) {
@@ -178,35 +178,32 @@ it.each([
178178
["work", "anonymous"],
179179
["work", "missing-card"],
180180
["work", "matched"],
181-
] as const)(
182-
"retains prepared failures exactly once in %s summaries (%s)",
183-
async (kind, pairing) => {
184-
const message = createAssistantMessage(
185-
pairing === "missing-card"
186-
? [{ type: "text", text: "Operation details unavailable" }]
187-
: [
188-
read("call-failed"),
189-
createToolResultBlock("call-failed", "read", "Permission denied", { isError: true }),
190-
],
191-
{
192-
activity: [
193-
preparedOutcome("failed", pairing === "matched" ? "call-failed" : null, {
194-
itemId: "prepared-failure",
195-
title: "Read file",
196-
}),
181+
] as const)("leaves a prepared failure to its row in %s summaries (%s)", async (kind, pairing) => {
182+
const message = createAssistantMessage(
183+
pairing === "missing-card"
184+
? [{ type: "text", text: "Operation details unavailable" }]
185+
: [
186+
read("call-failed"),
187+
createToolResultBlock("call-failed", "read", "Permission denied", { isError: true }),
197188
],
198-
},
199-
);
200-
for (const expanded of [false, true]) {
201-
const summary = await renderSummary([message], kind, { expanded });
202-
expect(summary?.textContent).toContain(kind === "work" ? "Worked for 1 second" : "1 read");
203-
expect(summary?.textContent?.match(/1 failed/gu)).toHaveLength(1);
204-
if (kind === "work") {
205-
expect(summary?.textContent?.includes("1 tool call")).toBe(expanded);
206-
}
189+
{
190+
activity: [
191+
preparedOutcome("failed", pairing === "matched" ? "call-failed" : null, {
192+
itemId: "prepared-failure",
193+
title: "Read file",
194+
}),
195+
],
196+
},
197+
);
198+
for (const expanded of [false, true]) {
199+
const summary = await renderSummary([message], kind, { expanded });
200+
expect(summary?.textContent).toContain(kind === "work" ? "Worked for 1 second" : "1 read");
201+
expect(summary?.textContent).not.toContain("failed");
202+
if (kind === "work") {
203+
expect(summary?.textContent?.includes("1 tool call")).toBe(expanded);
207204
}
208-
},
209-
);
205+
}
206+
});
210207

211208
it.each(["activity", "work"] as const)(
212209
"uses current prepared outcomes in %s summaries",
@@ -237,14 +234,13 @@ it.each(["activity", "work"] as const)(
237234
expect(summary?.textContent).not.toContain("failed");
238235
if (kind === "work") {
239236
expect(summary?.textContent).not.toContain("tool call");
240-
expect(summary?.querySelector(".chat-work-group__outcomes")).toBeNull();
241237
}
242238
expect(summary?.querySelector(".chat-tool-failure")).toBeNull();
243239
},
244240
);
245241

246242
it.each(["blocked", "skipped", undefined] as const)(
247-
"retains %s outcomes when completed work is expanded",
243+
"keeps blocked and unknown but not skipped outcomes in completed work (%s)",
248244
async (status) => {
249245
const message = createAssistantMessage([], {
250246
activity: [preparedOutcome("completed", null, { itemId: "outcome", status })],
@@ -253,31 +249,34 @@ it.each(["blocked", "skipped", undefined] as const)(
253249
const summary = await renderSummary([message], "work", { expanded });
254250
expect(summary?.textContent).toContain("Worked for 1 second");
255251
expect(summary?.textContent?.includes("1 tool call")).toBe(expanded);
256-
expect(summary?.textContent).toContain(`1 ${status ?? "unknown"}`);
257252
if (status === "skipped") {
258-
expect(summary?.textContent?.match(/1 skipped/g)).toHaveLength(1);
259-
expect(summary?.textContent).not.toMatch(/blocked|failed/);
253+
expect(summary?.textContent).not.toMatch(/skipped|blocked|failed/);
254+
} else {
255+
expect(summary?.textContent).toContain(`1 ${status ?? "unknown"}`);
260256
}
261257
}
262258
},
263259
);
264260

265-
it.each([0, 10])("keeps failures visible without a duration (%i calls)", async (total) => {
266-
const message = createAssistantMessage(
267-
Array.from({ length: total }).flatMap((_, index) => [
268-
read(`call-${index}`),
269-
createToolResultBlock(`call-${index}`, "read", index < 2 ? "Unavailable" : "Loaded", {
270-
isError: index < 2,
271-
}),
272-
]),
273-
);
274-
const summary = await renderSummary(total ? [message] : [], "work", {
275-
durationMs: null,
276-
prepareHistory: true,
277-
});
278-
const text = summary?.textContent?.replace(/\s+/gu, " ").trim();
279-
expect(text).toBe(total ? "Worked · 2 failed" : "Worked");
280-
});
261+
it.each([0, 10])(
262+
"does not tally recovered failures in completed work (%i calls)",
263+
async (total) => {
264+
const message = createAssistantMessage(
265+
Array.from({ length: total }).flatMap((_, index) => [
266+
read(`call-${index}`),
267+
createToolResultBlock(`call-${index}`, "read", index < 2 ? "Unavailable" : "Loaded", {
268+
isError: index < 2,
269+
}),
270+
]),
271+
);
272+
const summary = await renderSummary(total ? [message] : [], "work", {
273+
durationMs: null,
274+
prepareHistory: true,
275+
});
276+
const text = summary?.textContent?.replace(/\s+/gu, " ").trim();
277+
expect(text).toBe("Worked");
278+
},
279+
);
281280

282281
async function workSummaryText(messages: Record<string, unknown>[]) {
283282
return (await renderSummary(messages, "work", { durationMs: null, expanded: true }))?.textContent
@@ -311,7 +310,7 @@ it.each([
311310
content: isError ? "Command failed" : "Command completed",
312311
isError,
313312
})),
314-
expected: "Worked · 2 tool calls · 1 failed",
313+
expected: "Worked · 2 tool calls",
315314
},
316315
...[false, true].map((reverse) => {
317316
const prepared = readResult("prepared", true, { activity: [preparedOutcome()] });
@@ -327,7 +326,7 @@ it.each([
327326
return {
328327
name: `mixed history, reverse=${reverse}`,
329328
messages,
330-
expected: "Worked · 2 tool calls · 1 failed",
329+
expected: "Worked · 2 tool calls",
331330
};
332331
}),
333332
...["empty", "hidden", "suppressed"].map((kind) => ({
@@ -346,7 +345,7 @@ it.each([
346345
}),
347346
readResult("visible"),
348347
],
349-
expected: "Worked · 1 tool call · 1 failed",
348+
expected: "Worked · 1 tool call",
350349
})),
351350
...["raw", "blocked", "skipped"].map((kind) => ({
352351
name: `${kind} steering skip`,
@@ -365,7 +364,7 @@ it.each([
365364
}),
366365
}),
367366
],
368-
expected: `Worked · 1 tool call · 1 ${kind === "blocked" ? "blocked" : "skipped"}`,
367+
expected: kind === "blocked" ? "Worked · 1 tool call · 1 blocked" : "Worked · 1 tool call",
369368
})),
370369
{
371370
name: "unpaired anonymous raw call does not claim an unknown outcome",
@@ -424,15 +423,10 @@ it.each([
424423
);
425424
const { container, draw } = mountGroup(history.messages);
426425
await draw(false);
427-
if (isError) {
428-
const summary = container.querySelector(".chat-activity-group__summary");
429-
expect(summary?.textContent).toContain("1 command");
430-
expect(summary?.textContent).toContain("1 failed");
431-
expect(container.querySelector(".chat-tool-row__title")).toBeNull();
432-
return;
433-
}
434426
expect(container.querySelector(".chat-activity-group__summary")).toBeNull();
435427
expect(container.querySelector(".chat-tool-row__title")?.textContent).toBe(title);
428+
// The step's own row carries its outcome now that groups no longer count it.
429+
expect(container.querySelector(".chat-tool-failure") !== null).toBe(isError);
436430
expect(container.querySelector(".chat-progress-card-receipt")).toBeNull();
437431
await draw(true);
438432
expect(

‎ui/src/pages/chat/components/chat-activity-headline.test.tsx‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -390,9 +390,7 @@ it("uses the newest group's live card label without inheriting an earlier failur
390390
expect(label()).toBe("in /repo/src/a.ts…");
391391

392392
await renderActivityFixture(groups, { ...opts, runActive: false });
393-
expect(activitySummary.textContent?.replace(/\s+/gu, " ").trim()).toBe(
394-
"1 read · 1 edit 1 failed",
395-
);
393+
expect(activitySummary.textContent?.replace(/\s+/gu, " ").trim()).toBe("1 read · 1 edit");
396394
});
397395

398396
it.each(["failed", "blocked"] as const)(
@@ -404,7 +402,13 @@ it.each(["failed", "blocked"] as const)(
404402
await renderActivityFixture([nested], liveOptions);
405403
expect(label()).toBe("Build the snake game");
406404
expect(vi.getTimerCount()).toBe(0);
407-
expect(query("summary")?.textContent).toContain("1 " + status);
405+
// A reviewer's block is a decision worth surfacing; a failed attempt mid-run is not.
406+
const summary = query("summary")?.textContent;
407+
if (status === "blocked") {
408+
expect(summary).toContain("1 blocked");
409+
} else {
410+
expect(summary).not.toContain("failed");
411+
}
408412
},
409413
);
410414

0 commit comments

Comments
 (0)