From a84c66bf5ce32533070d4451fa7c4b50380c9574 Mon Sep 17 00:00:00 2001 From: Badcuban <108198679+badcuban@users.noreply.github.com> Date: Tue, 17 Nov 2026 16:38:24 -0500 Subject: [PATCH] fix(web): a wrapped thread shows when it last wrapped, not an old Wrap up A thread wrapped by hand, then used again, then wrapped again on its own (its pull request merging, or sitting idle) showed the date of the old Wrap up in the Wrapped list and was grouped under that day. The row's time now uses the user's Wrap up only while nothing newer has happened in the thread, the same rule the filing already used. Otherwise it uses the thread's last activity. The label and the list order both read this, so they still agree. --- apps/web/src/components/Sidebar.logic.test.ts | 21 +++++++++++++++++++ apps/web/src/components/Sidebar.logic.ts | 19 +++++++++-------- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/apps/web/src/components/Sidebar.logic.test.ts b/apps/web/src/components/Sidebar.logic.test.ts index 15cd46e0a..6904b1b8b 100644 --- a/apps/web/src/components/Sidebar.logic.test.ts +++ b/apps/web/src/components/Sidebar.logic.test.ts @@ -7,6 +7,7 @@ import { getSidebarIdlePrewarmThreadIds, getSidebarThreadIdsToPrewarm, resolveAdjacentThreadId, + resolveDoneTimestamp, getFallbackThreadIdAfterDelete, getProjectSortTimestamp, hasUnseenCompletion, @@ -1330,6 +1331,26 @@ describe("inbox done lifecycle", () => { ).toBe(true); }); + it("dates a thread that wrapped again by its new work, not an old Wrap up", () => { + // Wrapped by hand days ago, used again today, then filed by its pull + // request landing: the row says today, not the day of the old mark. + const oldMark = { state: "done", at: "2026-07-24T12:00:00.000Z" } as const; + const usedAgain = { + ...base, + latestUserMessageAt: "2026-07-28T11:00:00.000Z", + lastVisitedAt: "2026-07-28T11:10:00.000Z", + }; + expect( + isThreadDone(usedAgain, oldMark, { + now: NOW, + pullRequestSettledAt: "2026-07-28T11:30:00.000Z", + }), + ).toBe(true); + expect(resolveDoneTimestamp(usedAgain, oldMark)).toBe("2026-07-28T11:00:00.000Z"); + // A Wrap up given after the last work still dates the row. + expect(resolveDoneTimestamp(usedAgain, doneMark)).toBe(NOW); + }); + it("lets a thread an agent will come back to wrap up, and brings it back when the agent does", () => { // Like a snoozed email: the check-back doesn't hold the thread in the // list, and its turn returns the thread there by itself. diff --git a/apps/web/src/components/Sidebar.logic.ts b/apps/web/src/components/Sidebar.logic.ts index ad8f3c5a3..7c5f62033 100644 --- a/apps/web/src/components/Sidebar.logic.ts +++ b/apps/web/src/components/Sidebar.logic.ts @@ -814,10 +814,7 @@ export function freshThreadDoneOverride( override: ThreadDoneOverride | null | undefined, ): ThreadDoneOverride | null { if (override == null) return null; - const lastActivityAt = resolveDoneTimestamp(thread, null); - return lastActivityAt !== null && Date.parse(lastActivityAt) > Date.parse(override.at) - ? null - : override; + return Date.parse(threadLastActivityAt(thread)) > Date.parse(override.at) ? null : override; } const DAY_MS = 24 * 60 * 60 * 1_000; @@ -1359,16 +1356,20 @@ type DoneSortInput = Pick< >; /** - * Done rows are history, so they order by when the work ended: the explicit - * mark when there is one, else the thread's last activity. Label and order - * both come from here so they can never disagree. + * Done rows are history, so they order by when the work ended: the user's + * Wrap up while it still stands, else the thread's last activity. A mark that + * newer work outran no longer dates anything: the thread that comes back and + * wraps again (its pull request landing, or sitting idle) wrapped after that + * work, not on the old day. Label and order both come from here so they can + * never disagree. */ export function resolveDoneTimestamp( thread: DoneSortInput, override: ThreadDoneOverride | null | undefined, ): string | null { - if (override?.state === "done" && !Number.isNaN(Date.parse(override.at))) { - return override.at; + const standing = freshThreadDoneOverride(thread, override); + if (standing?.state === "done" && !Number.isNaN(Date.parse(standing.at))) { + return standing.at; } return threadLastActivityAt(thread); }