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 23, 04:15 UTC
fix(web): a failed run shows Failed, not Completed (#20996)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Yannic Charlon committed
Oct 19, 2026 at 03:19 UTC
25dff68e0122979c26c82c69c49d5c5ba942ad5c
2 files changed
+96
apps/web/src/components/Sidebar.logic.test.ts
+71
@@ -1367,9 +1367,80 @@ describe("resolveThreadStatusPill", () => {
1367
}),
1368
).toMatchObject({ label: "Completed", pulse: false });
1369
});
1370
+
1371
+ it("shows failed, not completed, when the unseen run failed", () => {
1372
+ expect(
1373
+ resolveThreadStatusPill({
1374
+ thread: {
1375
+ ...baseThread,
1376
+ interactionMode: "default",
1377
+ latestRun: { ...makeLatestRun(), status: "failed" },
1378
+ lastVisitedAt: "2026-03-09T10:04:00.000Z",
1379
+ runtime: {
1380
+ ...baseThread.runtime,
1381
+ status: "failed",
1382
+ activeRunId: null,
1383
+ lastError: "Provider turn failed.",
1384
+ },
1385
+ },
1386
+ }),
1387
+ ).toMatchObject({ label: "Failed", pulse: false });
1388
+ });
1389
+
1390
+ it("shows failed for a thread nobody has opened yet", () => {
1391
+ expect(
1392
+ resolveThreadStatusPill({
1393
+ thread: {
1394
+ ...baseThread,
1395
+ interactionMode: "default",
1396
+ latestRun: { ...makeLatestRun(), status: "failed" },
1397
+ lastVisitedAt: null,
1398
+ runtime: { ...baseThread.runtime, status: "failed", activeRunId: null },
1399
+ },
1400
+ }),
1401
+ ).toMatchObject({ label: "Failed" });
1402
+ });
1403
+
1404
+ it("shows failed, not plan ready, when a plan run proposed a plan and then failed", () => {
1405
+ expect(
1406
+ resolveThreadStatusPill({
1407
+ thread: {
1408
+ ...baseThread,
1409
+ hasActionableProposedPlan: true,
1410
+ latestRun: { ...makeLatestRun(), status: "failed" },
1411
+ lastVisitedAt: "2026-03-09T10:04:00.000Z",
1412
+ runtime: { ...baseThread.runtime, status: "failed", activeRunId: null },
1413
+ },
1414
+ }),
1415
+ ).toMatchObject({ label: "Failed" });
1416
+ });
1417
+
1418
+ it("drops the failed pill once the failure has been seen", () => {
1419
+ expect(
1420
+ resolveThreadStatusPill({
1421
+ thread: {
1422
+ ...baseThread,
1423
+ interactionMode: "default",
1424
+ latestRun: { ...makeLatestRun(), status: "failed" },
1425
+ lastVisitedAt: "2026-03-09T10:06:00.000Z",
1426
+ runtime: { ...baseThread.runtime, status: "failed", activeRunId: null },
1427
+ },
1428
+ }),
1429
+ ).toBeNull();
1430
+ });
1431
});
1432
1433
describe("resolveProjectStatusIndicator", () => {
1434
+ it("ranks a failure above work in progress and completions", () => {
1435
+ expect(
1436
+ resolveProjectStatusIndicator([
1437
+ { label: "Completed", colorClass: "", dotClass: "", pulse: false },
1438
+ { label: "Working", colorClass: "", dotClass: "", pulse: true },
1439
+ { label: "Failed", colorClass: "", dotClass: "", pulse: false },
1440
+ ]),
1441
+ ).toMatchObject({ label: "Failed" });
1442
+ });
1443
+
1444
it("returns null when no threads have a notable status", () => {
1445
expect(resolveProjectStatusIndicator([null, null])).toBeNull();
1446
});
apps/web/src/components/Sidebar.logic.ts
+25
@@ -573,6 +573,7 @@ export interface ThreadStatusPill {
573
| "Working"
574
| "Connecting"
575
| "Completed"
576
+ | "Failed"
577
| "Pending Approval"
578
| "Awaiting Input"
579
| "Waiting"
@@ -585,6 +586,7 @@ export interface ThreadStatusPill {
586
const THREAD_STATUS_PRIORITY: Record<ThreadStatusPill["label"], number> = {
587
"Pending Approval": 5,
588
"Awaiting Input": 4,
589
+ Failed: 3.5,
590
Working: 3,
591
Connecting: 3,
592
Waiting: 2.5,
@@ -720,6 +722,20 @@ export function hasUnseenCompletion(thread: ThreadStatusInput): boolean {
722
return completedAt > lastVisitedAt;
723
}
724
725
+/**
726
+ * A failed latest run the person hasn't looked at since it ended. Unlike a
727
+ * completion, a thread nobody has opened yet (an automation's, say) counts:
728
+ * its failure still needs someone.
729
+ */
730
+function hasUnseenFailure(thread: ThreadStatusInput): boolean {
731
+ if (thread.latestRun?.status !== "failed") return false;
732
+ if (!thread.lastVisitedAt) return true;
733
+ const completedAt = Date.parse(thread.latestRun.completedAt ?? "");
734
+ const lastVisitedAt = Date.parse(thread.lastVisitedAt);
735
+ if (Number.isNaN(completedAt) || Number.isNaN(lastVisitedAt)) return true;
736
+ return completedAt > lastVisitedAt;
737
+}
738
+
739
export function shouldClearThreadSelectionOnMouseDown(target: HTMLElement | null): boolean {
740
if (target === null) return true;
741
return !target.closest(THREAD_SELECTION_SAFE_SELECTOR);
@@ -1133,6 +1149,15 @@ export function resolveThreadStatusPill(input: {
1149
};
1150
}
1151
1152
+ if (hasUnseenFailure(thread)) {
1153
+ return {
1154
+ label: "Failed",
1155
+ colorClass: "text-red-600 dark:text-red-300/90",
1156
+ dotClass: "bg-red-500 dark:bg-red-300/90",
1157
+ pulse: false,
1158
+ };
1159
+ }
1160
+
1161
const hasPlanReadyPrompt =
1162
!thread.hasPendingUserInput &&
1163
thread.interactionMode === "plan" &&