diff --git a/apps/web/src/components/Sidebar.logic.test.ts b/apps/web/src/components/Sidebar.logic.test.ts index 2fa0d608b1f1d..76f8c8c30c2d5 100644 --- a/apps/web/src/components/Sidebar.logic.test.ts +++ b/apps/web/src/components/Sidebar.logic.test.ts @@ -526,22 +526,44 @@ describe("resolveThreadStatusPill", () => { }); it("shows failed, not completed, when the unseen run failed", () => { - expect( - resolveThreadStatusPill({ - thread: { - ...baseThread, - interactionMode: "default", - latestRun: { ...makeLatestRun(), status: "failed" }, - lastVisitedAt: "2026-03-09T10:04:00.000Z", - runtime: { - ...baseThread.runtime, - status: "failed", - activeRunId: null, - lastError: "Provider turn failed.", - }, + const failed = { + ...baseThread, + interactionMode: "default" as const, + latestRun: { ...makeLatestRun(), status: "failed" as const }, + lastVisitedAt: "2026-03-09T10:04:00.000Z", + runtime: { + ...baseThread.runtime, + status: "failed" as const, + activeRunId: null, + lastError: "Provider turn failed.", + }, + }; + expect(resolveThreadStatusPill({ thread: failed })).toMatchObject({ + label: "Failed", + pulse: false, + }); + // The failure sends the thread to the inbox, so its pill must not say it is still waiting. + const watching = { + ...failed, + pendingBackgroundTasks: [ + { + taskId: "pr-watch", + description: "Watching pull request #7", + kind: "monitor" as const, + awaited: true as const, }, - }), - ).toMatchObject({ label: "Failed", pulse: false }); + ], + }; + expect(isSidebarThreadWorking(watching)).toBe(false); + expect(resolveThreadStatusPill({ thread: watching })).toMatchObject({ label: "Failed" }); + // A run blocked on another thread is still waiting, as its sidebar row says. + const blocked = { + ...watching, + runtime: { ...failed.runtime, status: "running" as const }, + blockedOnThreadWait: true, + }; + expect(resolveSidebarThreadStatus(blocked)).toBe("waiting"); + expect(resolveThreadStatusPill({ thread: blocked })).toMatchObject({ label: "Waiting" }); }); it("shows failed, not plan ready, when a plan run proposed a plan and then failed", () => { diff --git a/apps/web/src/components/Sidebar.logic.ts b/apps/web/src/components/Sidebar.logic.ts index 5cb2a044093a0..f97a6e33fb864 100644 --- a/apps/web/src/components/Sidebar.logic.ts +++ b/apps/web/src/components/Sidebar.logic.ts @@ -1244,18 +1244,15 @@ export function resolveThreadStatusPill(input: { }; } - if ( - (thread.runtime?.status === "running" && thread.blockedOnThreadWait === true) || - backgroundWorkHoldsCompletion(thread.pendingBackgroundTasks ?? []) - ) { - return { - label: msg("Waiting"), - colorClass: "text-sidebar-muted-foreground", - dotClass: "bg-sidebar-muted-foreground", - pulse: false, - }; - } + const waiting = { + label: msg("Waiting"), + colorClass: "text-sidebar-muted-foreground", + dotClass: "bg-sidebar-muted-foreground", + pulse: false, + }; + if (thread.runtime?.status === "running" && thread.blockedOnThreadWait === true) return waiting; + // A failed run goes to the inbox even while background work holds the thread. if (hasUnseenRunFailure(thread)) { return { label: msg("Failed"), @@ -1265,6 +1262,8 @@ export function resolveThreadStatusPill(input: { }; } + if (backgroundWorkHoldsCompletion(thread.pendingBackgroundTasks ?? [])) return waiting; + const hasPlanReadyPrompt = !thread.hasPendingUserInput && thread.interactionMode === "plan" &&