Skip to content

Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.

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

Theo Brownece91284f832f
diff --git a/apps/server/src/orchestration/ActivityPayloadProjection.ts b/apps/server/src/orchestration/ActivityPayloadProjection.ts
index 103b267d2..32f249c25 100644
--- a/apps/server/src/orchestration/ActivityPayloadProjection.ts
+++ b/apps/server/src/orchestration/ActivityPayloadProjection.ts
@@ -342,11 +342,17 @@ export function projectActivityPayload(
return activity;
}
+ const itemStatus = asRecord(data.item)?.status;
+ const projectedPayload =
+ payload.status === "completed" && (itemStatus === "failed" || itemStatus === "declined")
+ ? { ...payload, status: itemStatus }
+ : payload;
+
if (payload.itemType === "mcp_tool_call") {
return {
...activity,
payload: {
- ...payload,
+ ...projectedPayload,
data: projectMcpToolCallData(data),
},
};
@@ -384,7 +390,7 @@ export function projectActivityPayload(
return {
...activity,
payload: {
- ...payload,
+ ...projectedPayload,
data: projectedData,
},
};
diff --git a/apps/server/src/provider/Layers/CodexAdapter.test.ts b/apps/server/src/provider/Layers/CodexAdapter.test.ts
index 5358716aa..da7f6fb15 100644
--- a/apps/server/src/provider/Layers/CodexAdapter.test.ts
+++ b/apps/server/src/provider/Layers/CodexAdapter.test.ts
@@ -614,6 +614,66 @@ lifecycleLayer("CodexAdapterLive lifecycle", (it) => {
}),
);
+ it.effect("preserves failed and declined outcomes on completed tool items", () =>
+ Effect.gen(function* () {
+ const { adapter, runtime } = yield* startLifecycleRuntime();
+ const items = [
+ {
+ type: "commandExecution",
+ id: "failed-command",
+ command: "vp test run",
+ commandActions: [],
+ cwd: "/tmp",
+ exitCode: 1,
+ status: "failed",
+ },
+ {
+ type: "mcpToolCall",
+ id: "failed-mcp",
+ server: "simulator",
+ tool: "build",
+ arguments: {},
+ error: { message: "Build failed" },
+ status: "failed",
+ },
+ {
+ type: "fileChange",
+ id: "declined-change",
+ changes: [],
+ status: "declined",
+ },
+ ] as const;
+
+ for (const item of items) {
+ const firstEventFiber = yield* Stream.runHead(adapter.streamEvents).pipe(Effect.forkChild);
+
+ yield* runtime.emit({
+ id: asEventId(`evt-${item.id}`),
+ kind: "notification",
+ provider: ProviderDriverKind.make("codex"),
+ createdAt: "2026-01-01T00:00:00.000Z",
+ method: "item/completed",
+ threadId: asThreadId("thread-1"),
+ turnId: asTurnId("turn-1"),
+ itemId: asItemId(item.id),
+ payload: {
+ completedAtMs: 1_778_000_000_000,
+ threadId: "thread-1",
+ turnId: "turn-1",
+ item,
+ },
+ });
+
+ const firstEvent = yield* Fiber.join(firstEventFiber);
+ NodeAssert.equal(firstEvent._tag, "Some");
+ if (firstEvent._tag !== "Some" || firstEvent.value.type !== "item.completed") {
+ return;
+ }
+ NodeAssert.equal(firstEvent.value.payload.status, item.status);
+ }
+ }),
+ );
+
it.effect("maps completed plan items to canonical proposed-plan completion events", () =>
Effect.gen(function* () {
const { adapter, runtime } = yield* startLifecycleRuntime();
diff --git a/apps/server/src/provider/Layers/CodexAdapter.ts b/apps/server/src/provider/Layers/CodexAdapter.ts
index 065156d36..cf82ffd40 100644
--- a/apps/server/src/provider/Layers/CodexAdapter.ts
+++ b/apps/server/src/provider/Layers/CodexAdapter.ts
@@ -480,7 +480,9 @@ function mapItemLifecycle(
lifecycle === "item.started"
? "inProgress"
: lifecycle === "item.completed"
- ? "completed"
+ ? "status" in item && (item.status === "failed" || item.status === "declined")
+ ? item.status
+ : "completed"
: undefined;
return {
diff --git a/apps/server/test/ActivityPayloadProjection.test.ts b/apps/server/test/ActivityPayloadProjection.test.ts
index 49f1b532a..72e2cd9e9 100644
--- a/apps/server/test/ActivityPayloadProjection.test.ts
+++ b/apps/server/test/ActivityPayloadProjection.test.ts
@@ -220,6 +220,40 @@ describe("projectActivityPayload", () => {
}
});
+ it("preserves failed stored tool outcomes for web and mobile clients", () => {
+ const activities = [
+ makeActivity("failed-command", "command_execution", {
+ item: {
+ command: "vp test run",
+ exitCode: 1,
+ status: "failed",
+ },
+ }),
+ makeActivity("failed-mcp", "mcp_tool_call", {
+ item: {
+ server: "simulator",
+ tool: "build",
+ arguments: {},
+ status: "failed",
+ },
+ }),
+ ];
+
+ for (const activity of activities) {
+ const projected = projectActivityPayload(activity);
+ expect(projected.payload).toMatchObject({ status: "failed" });
+
+ const [webEntry] = deriveWorkLogEntries([projected]);
+ expect(webEntry?.toolLifecycleStatus).toBe("failed");
+
+ const [mobileGroup] = buildThreadFeed(makeThread([projected]));
+ expect(mobileGroup).toMatchObject({ type: "activity-group" });
+ if (mobileGroup?.type === "activity-group") {
+ expect(mobileGroup.activities[0]?.status).toBe("failure");
+ }
+ }
+ });
+
it("projects snapshot and event transports without mutating their sources", () => {
const activity = fixtures[0]!;
const thread = makeThread([activity]);
diff --git a/apps/web/src/components/chat/MessagesTimeline.logic.test.ts b/apps/web/src/components/chat/MessagesTimeline.logic.test.ts
index 6d9a9c37e..fae5df1e4 100644
--- a/apps/web/src/components/chat/MessagesTimeline.logic.test.ts
+++ b/apps/web/src/components/chat/MessagesTimeline.logic.test.ts
@@ -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", () => {
diff --git a/apps/web/src/components/chat/MessagesTimeline.logic.ts b/apps/web/src/components/chat/MessagesTimeline.logic.ts
index 716a72ea8..fbe0f5b91 100644
--- a/apps/web/src/components/chat/MessagesTimeline.logic.ts
+++ b/apps/web/src/components/chat/MessagesTimeline.logic.ts
@@ -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()) {
diff --git a/apps/web/src/components/chat/MessagesTimeline.test.tsx b/apps/web/src/components/chat/MessagesTimeline.test.tsx
index ea6cda9b6..c7f1f8feb 100644
--- a/apps/web/src/components/chat/MessagesTimeline.test.tsx
+++ b/apps/web/src/components/chat/MessagesTimeline.test.tsx
@@ -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(