Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions apps/web/src/components/Sidebar.logic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
getSidebarIdlePrewarmThreadIds,
getSidebarThreadIdsToPrewarm,
resolveAdjacentThreadId,
resolveDoneTimestamp,
getFallbackThreadIdAfterDelete,
getProjectSortTimestamp,
hasUnseenCompletion,
Expand Down Expand Up @@ -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.
Expand Down
19 changes: 10 additions & 9 deletions apps/web/src/components/Sidebar.logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
Loading