Skip to content

Commit 13889f0

Browse files
fix(web): renaming a thread no longer brings back a failure you already saw
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent e65f5a3 commit 13889f0

2 files changed

Lines changed: 14 additions & 11 deletions

File tree

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -381,20 +381,18 @@ describe("resolveSidebarRowStatus", () => {
381381
expect(resolveSidebarRowStatus(failedAgain)).toBe("failed");
382382
});
383383

384-
it("dates a failure without a completed run by the runtime update", () => {
384+
it("keeps an undated failure unseen, so later thread updates cannot revive or hide it", () => {
385385
const visitedAfter = "2026-03-09T10:06:00.000Z";
386-
const visitedBefore = "2026-03-09T10:00:00.000Z";
387386
const noCompletedAt = {
388387
...failed,
389388
latestRun: { ...failed.latestRun, completedAt: null },
390389
};
391390
expect(resolveSidebarRowStatus({ ...noCompletedAt, lastVisitedAt: visitedAfter })).toBe(
392-
"ready",
391+
"failed",
393392
);
394393

395394
const noRun = { ...failed, latestRun: null };
396-
expect(resolveSidebarRowStatus({ ...noRun, lastVisitedAt: visitedBefore })).toBe("failed");
397-
expect(resolveSidebarRowStatus({ ...noRun, lastVisitedAt: visitedAfter })).toBe("ready");
395+
expect(resolveSidebarRowStatus({ ...noRun, lastVisitedAt: visitedAfter })).toBe("failed");
398396
});
399397
});
400398

@@ -1783,7 +1781,11 @@ describe("resolveSidebarFolderDot", () => {
17831781
expect(resolveSidebarFolderDot([working, unread])).toBe("unread");
17841782
expect(resolveSidebarFolderDot([unread, limited])).toBe("attention");
17851783
// A failure the user already opened clears, like its row.
1786-
const failed = { ...idle, runtime: { ...runtime, status: "failed" as const } };
1784+
const failed = {
1785+
...idle,
1786+
latestRun: { ...idle.latestRun, status: "failed" as const },
1787+
runtime: { ...runtime, status: "failed" as const },
1788+
};
17871789
expect(resolveSidebarFolderDot([failed])).toBeNull();
17881790
expect(
17891791
resolveSidebarFolderDot([{ ...failed, lastVisitedAt: "2026-03-09T09:00:00.000Z" }]),

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -778,16 +778,17 @@ export function hasUnseenCompletion(thread: ThreadStatusInput): boolean {
778778
function hasUnseenFailure(
779779
thread: Pick<ThreadStatusInput, "latestRun" | "runtime" | "lastVisitedAt">,
780780
): boolean {
781-
// Failed runs can lack completedAt, and a session can fail before any run.
781+
// Only a run's completion dates a failure: runtime.updatedAt also moves on renames and
782+
// branch changes. An undated failure, such as a session failing before any run, stays unseen.
782783
const failedAt =
783784
thread.latestRun?.status === "failed"
784-
? (thread.latestRun.completedAt ?? thread.runtime?.updatedAt)
785+
? thread.latestRun.completedAt
785786
: thread.runtime?.status === "failed"
786-
? thread.runtime.updatedAt
787+
? null
787788
: undefined;
788789
if (failedAt === undefined) return false;
789-
if (!thread.lastVisitedAt) return true;
790-
const failedAtMs = Date.parse(failedAt ?? "");
790+
if (failedAt === null || !thread.lastVisitedAt) return true;
791+
const failedAtMs = Date.parse(failedAt);
791792
const lastVisitedAtMs = Date.parse(thread.lastVisitedAt);
792793
if (Number.isNaN(failedAtMs) || Number.isNaN(lastVisitedAtMs)) return true;
793794
return failedAtMs > lastVisitedAtMs;

0 commit comments

Comments
 (0)