diff --git a/apps/web/lib/ui/state-icons.test.tsx b/apps/web/lib/ui/state-icons.test.tsx index c37ef566ed..2e7a8693ed 100644 --- a/apps/web/lib/ui/state-icons.test.tsx +++ b/apps/web/lib/ui/state-icons.test.tsx @@ -31,7 +31,7 @@ describe("shouldShowTaskRunningSpinner", () => { expect(shouldShowTaskRunningSpinner("TODO")).toBe(false); }); - it("returns true when any task state has an actively running primary session", () => { + it("returns true for non-TODO task states with an actively running primary session", () => { expect(shouldShowTaskRunningSpinner("REVIEW", "RUNNING")).toBe(true); expect(shouldShowTaskRunningSpinner("COMPLETED", "RUNNING")).toBe(true); expect(shouldShowTaskRunningSpinner("FAILED", "RUNNING")).toBe(true); @@ -71,4 +71,16 @@ describe("shouldShowTaskRunningSpinner", () => { expect(shouldShowTaskRunningSpinner("IN_PROGRESS", "WAITING_FOR_INPUT")).toBe(false); expect(shouldShowTaskRunningSpinner("IN_PROGRESS", "IDLE")).toBe(false); }); + + it("suppresses the spinner for TODO regardless of primary session state", () => { + // TODO is the queued/not-started column. A stale primary session state + // (e.g. task moved back from IN_PROGRESS with the session still alive) + // must not paint the running spinner on the kanban card. + expect(shouldShowTaskRunningSpinner("TODO", "RUNNING")).toBe(false); + expect(shouldShowTaskRunningSpinner("TODO", "STARTING")).toBe(false); + expect(shouldShowTaskRunningSpinner("TODO", "CREATED")).toBe(false); + expect(shouldShowTaskRunningSpinner("TODO", "COMPLETED")).toBe(false); + expect(shouldShowTaskRunningSpinner("TODO", "WAITING_FOR_INPUT")).toBe(false); + expect(shouldShowTaskRunningSpinner("TODO", "IDLE")).toBe(false); + }); }); diff --git a/apps/web/lib/ui/state-icons.tsx b/apps/web/lib/ui/state-icons.tsx index 303f4021e9..0bc1346fe0 100644 --- a/apps/web/lib/ui/state-icons.tsx +++ b/apps/web/lib/ui/state-icons.tsx @@ -92,11 +92,16 @@ const ACTIVE_SESSION_STATES: ReadonlySet = new Set([ * When no primary session is attached yet (task just created / scheduling), * we still show the spinner so users see the imminent work; otherwise we * require an active session state. + * + * Exception: `TODO` is the queued/not-started column. Any active session + * state reported there is stale (task moved back from IN_PROGRESS, session + * still alive) or transient, and the spinner would mislead — suppress it. */ export function shouldShowTaskRunningSpinner( taskState?: TaskState, primarySessionState?: string | null, ): boolean { + if (taskState === "TODO") return false; if (primarySessionState) return ACTIVE_SESSION_STATES.has(primarySessionState); return taskState === "IN_PROGRESS" || taskState === "SCHEDULING"; }