Skip to content

Commit 25dff68

Browse files
JustYanniccclaude
andauthored
fix(web): a failed run shows Failed, not Completed (pingdotgg#20996)
Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent a31f1f2 commit 25dff68

2 files changed

Lines changed: 96 additions & 0 deletions

File tree

‎apps/web/src/components/Sidebar.logic.test.ts‎

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1367,9 +1367,80 @@ describe("resolveThreadStatusPill", () => {
13671367
}),
13681368
).toMatchObject({ label: "Completed", pulse: false });
13691369
});
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+
});
13701431
});
13711432

13721433
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+
13731444
it("returns null when no threads have a notable status", () => {
13741445
expect(resolveProjectStatusIndicator([null, null])).toBeNull();
13751446
});

‎apps/web/src/components/Sidebar.logic.ts‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,7 @@ export interface ThreadStatusPill {
573573
| "Working"
574574
| "Connecting"
575575
| "Completed"
576+
| "Failed"
576577
| "Pending Approval"
577578
| "Awaiting Input"
578579
| "Waiting"
@@ -585,6 +586,7 @@ export interface ThreadStatusPill {
585586
const THREAD_STATUS_PRIORITY: Record<ThreadStatusPill["label"], number> = {
586587
"Pending Approval": 5,
587588
"Awaiting Input": 4,
589+
Failed: 3.5,
588590
Working: 3,
589591
Connecting: 3,
590592
Waiting: 2.5,
@@ -720,6 +722,20 @@ export function hasUnseenCompletion(thread: ThreadStatusInput): boolean {
720722
return completedAt > lastVisitedAt;
721723
}
722724

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+
723739
export function shouldClearThreadSelectionOnMouseDown(target: HTMLElement | null): boolean {
724740
if (target === null) return true;
725741
return !target.closest(THREAD_SELECTION_SAFE_SELECTOR);
@@ -1133,6 +1149,15 @@ export function resolveThreadStatusPill(input: {
11331149
};
11341150
}
11351151

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+
11361161
const hasPlanReadyPrompt =
11371162
!thread.hasPendingUserInput &&
11381163
thread.interactionMode === "plan" &&

0 commit comments

Comments
 (0)