@devries-cameron20 / t3code Mirror · read-only / commits / c15735dd88
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 24, 12:45 UTC

fix(chat): replace failed tools with thinking (#9165)

Co-authored-by: maria-rcks <254055478+maria-rcks@users.noreply.github.com>

maria committed Sep 2, 2026 at 01:19 UTC c15735dd8894f829ce396c922ce4b5a48073f05a
2 files changed +16 -4
apps/web/src/components/chat/MessagesTimeline.logic.test.ts
+8 -1
@@ -1411,7 +1411,9 @@ describe("deriveMessagesTimelineRows", () => {
1411 );
1412
1413 it("reuses one activity row for initial thinking and the latest tool", () => {
1414 - const deriveRows = (toolLifecycleStatus: "inProgress" | "completed" | "declined" | null) =>
1414 + const deriveRows = (
1415 + toolLifecycleStatus: "inProgress" | "completed" | "failed" | "declined" | null,
1416 + ) =>
1417 deriveMessagesTimelineRows({
1418 timelineEntries:
1419 toolLifecycleStatus === null
@@ -1430,6 +1432,7 @@ describe("deriveMessagesTimelineRows", () => {
1432 requestKind: "command",
1433 tone: "tool" as const,
1434 toolLifecycleStatus,
1435 + ...(toolLifecycleStatus === "inProgress" ? { detail: "exit code 1" } : {}),
1436 },
1437 },
1438 ],
@@ -1448,6 +1451,7 @@ describe("deriveMessagesTimelineRows", () => {
1451 const initialRows = deriveRows(null);
1452 const runningRows = deriveRows("inProgress");
1453 const completedRows = deriveRows("completed");
1454 + const failedRows = deriveRows("failed");
1455 const declinedRows = deriveRows("declined");
1456 const initialActivityRow = initialRows.find((row) => row.id === "live-activity-row");
1457 const runningActivityRow = runningRows.find((row) => row.id === "live-activity-row");
@@ -1456,11 +1460,14 @@ describe("deriveMessagesTimelineRows", () => {
1460 expect(initialActivityRow).toMatchObject({ kind: "thinking" });
1461 expect(runningActivityRow).toMatchObject({ kind: "work-live", active: true });
1462 expect(completedActivityRow).toMatchObject({ kind: "work-live", active: true });
1463 + expect(failedRows.some((row) => row.kind === "work-live")).toBe(false);
1464 + expect(failedRows.at(-1)).toMatchObject({ kind: "thinking", id: "live-activity-row" });
1465 expect(declinedRows.find((row) => row.kind === "work-live")).toMatchObject({ active: false });
1466 expect(declinedRows.at(-1)).toMatchObject({ kind: "thinking", id: "live-activity-row" });
1467 expect(initialRows.filter((row) => row.id === "live-activity-row")).toHaveLength(1);
1468 expect(runningRows.filter((row) => row.id === "live-activity-row")).toHaveLength(1);
1469 expect(completedRows.filter((row) => row.id === "live-activity-row")).toHaveLength(1);
1470 + expect(failedRows.filter((row) => row.id === "live-activity-row")).toHaveLength(1);
1471 expect(declinedRows.filter((row) => row.id === "live-activity-row")).toHaveLength(1);
1472 });
1473
apps/web/src/components/chat/MessagesTimeline.logic.ts
+8 -3
@@ -691,13 +691,18 @@ export function deriveMessagesTimelineRows(input: {
691 const latestRunningToolEntry = visibleActiveToolEntries.findLast((entry) =>
692 workEntryIsActiveTurnActivity(entry.entry),
693 );
694 + const latestToolFailed =
695 + latestRunningToolEntry === undefined &&
696 + latestVisibleToolEntry !== undefined &&
697 + latestVisibleToolEntry.entry.toolLifecycleStatus !== "declined" &&
698 + workEntryDisplayIndicatesToolFailure(latestVisibleToolEntry.entry);
699 const latestToolKeepsActivityLive =
700 latestRunningToolEntry !== undefined ||
701 (latestVisibleToolEntry !== undefined &&
702 workEntryIndicatesToolSuccess(latestVisibleToolEntry.entry));
703 const activeWorkPlacementEntryId = latestVisibleToolEntry?.id;
704 const activeWorkRow =
700 - activeWorkAnchor && latestVisibleToolEntry
705 + activeWorkAnchor && latestVisibleToolEntry && !latestToolFailed
706 ? (() => {
707 const groupId = workGroupId(activeWorkAnchor.id, activeWorkAnchor.entry);
708 return {
@@ -715,7 +720,7 @@ export function deriveMessagesTimelineRows(input: {
720 })()
721 : null;
722 const activeWorkEntryIds = new Set(
718 - activeWorkRow === null ? [] : activeToolEntries.map((entry) => entry.id),
723 + activeWorkRow !== null || latestToolFailed ? activeToolEntries.map((entry) => entry.id) : [],
724 );
725 const appendWorkingRow = () => {
726 nextRows.push({
@@ -912,7 +917,7 @@ export function deriveMessagesTimelineRows(input: {
917 if (input.isWorking && activeTurnHeaderIndex === input.timelineEntries.length) {
918 appendWorkingRow();
919 }
915 - if (input.isWorking && !hasActivityRow) {
920 + if (input.isWorking && (!hasActivityRow || latestToolFailed)) {
921 nextRows.push({
922 kind: "thinking",
923 id: LIVE_ACTIVITY_ROW_ID,