fix(web): stop marking mixed tool runs as failed (#7893)

This commit is contained in:
Theo Browne authored and GitHub committed 2026-08-22 04:18:27 -07:00
1 parent 11f051373e
commit ce91284f83
7 files changed
+230 -6

No files matched your search

@@ -1374,6 +1374,91 @@ describe("deriveMessagesTimelineRows", () => {
expanded: true,
});
});
it.each([
["recovered", ["failed", "completed"], false],
["ending in failure", ["completed", "failed"], true],
["failed", ["failed", "failed"], true],
] as const)("uses the final call for %s tool groups", (_, statuses, hasFailure) => {
const timelineEntries = statuses.map((status, index) => ({
id: `work-entry-${index}`,
kind: "work" as const,
createdAt: `2026-01-01T00:00:0${index}Z`,
entry: {
id: `work-${index}`,
createdAt: `2026-01-01T00:00:0${index}Z`,
label: "Ran command",
tone: "tool" as const,
itemType: "command_execution" as const,
toolLifecycleStatus: status,
},
}));
const rows = deriveMessagesTimelineRows({
timelineEntries,
isWorking: false,
activeTurnStartedAt: null,
turnDiffSummaryByAssistantMessageId: new Map(),
revertTurnCountByUserMessageId: new Map(),
});
expect(rows.find((row) => row.kind === "work-toggle")).toMatchObject({
hiddenCount: 2,
hasFailure,
});
});
it("keeps a failure visible when other hidden entries succeeded", () => {
const rows = deriveMessagesTimelineRows({
timelineEntries: [
{
id: "failed-work-entry",
kind: "work",
createdAt: "2026-01-01T00:00:01Z",
entry: {
id: "failed-work",
createdAt: "2026-01-01T00:00:01Z",
label: "Ran command",
tone: "tool",
toolLifecycleStatus: "failed",
},
},
{
id: "completed-work-entry",
kind: "work",
createdAt: "2026-01-01T00:00:02Z",
entry: {
id: "completed-work",
createdAt: "2026-01-01T00:00:02Z",
label: "Ran command",
tone: "tool",
toolLifecycleStatus: "completed",
},
},
{
id: "visible-info-entry",
kind: "work",
createdAt: "2026-01-01T00:00:03Z",
entry: {
id: "visible-info",
createdAt: "2026-01-01T00:00:03Z",
label: "Status updated",
tone: "info",
},
},
],
isWorking: false,
activeTurnStartedAt: null,
turnDiffSummaryByAssistantMessageId: new Map(),
revertTurnCountByUserMessageId: new Map(),
});
expect(rows.find((row) => row.kind === "work-toggle")).toMatchObject({
hiddenCount: 2,
summary: null,
hasFailure: true,
});
});
});
describe("computeStableMessagesTimelineRows", () => {
@@ -894,9 +894,7 @@ export function deriveMessagesTimelineRows(input: {
onlyToolEntries: true,
summary: summarizeToolGroup(visibleGroupedEntries),
summaryKind,
hasFailure: visibleGroupedEntries.some((entry) =>
workEntryDisplayIndicatesToolFailure(entry),
),
hasFailure: workEntryDisplayIndicatesToolFailure(visibleGroupedEntries.at(-1)!),
});
if (expanded) {
for (const [entryIndex, workEntry] of visibleGroupedEntries.entries()) {
@@ -813,6 +813,45 @@ describe("MessagesTimeline", () => {
expect(markup).not.toContain("C:/Users/mike/dev-stuff/t3code/apps/web/src/session-logic.ts");
});
it("keeps mixed-success tool groups neutral", () => {
const markup = renderToStaticMarkup(
<MessagesTimeline
{...buildProps()}
timelineEntries={[
{
id: "entry-failed",
kind: "work",
createdAt: "2026-03-17T19:12:28.000Z",
entry: {
id: "work-failed",
createdAt: "2026-03-17T19:12:28.000Z",
label: "Run search",
tone: "tool",
itemType: "command_execution",
toolLifecycleStatus: "failed",
},
},
{
id: "entry-completed",
kind: "work",
createdAt: "2026-03-17T19:12:29.000Z",
entry: {
id: "work-completed",
createdAt: "2026-03-17T19:12:29.000Z",
label: "Run tests",
tone: "tool",
itemType: "command_execution",
toolLifecycleStatus: "completed",
},
},
]}
/>,
);
expect(markup).toContain("Ran 2 commands");
expect(markup).not.toContain('aria-label="Tool call failed"');
});
it("shows the animated one-line label for a live tool group", () => {
const turnId = TurnId.make("turn-live");
const markup = renderToStaticMarkup(