Fix inbox ordering: self-touched issues no longer sink to bottom

issueLastActivityTimestamp() returned 0 for issues where the user was
the last to touch them (myLastTouchAt >= updatedAt) and no external
comment existed. This pushed those items to the bottom of the inbox
list regardless of how recently they were updated.

Now falls back to updatedAt instead, so recently updated items sort
to the top of the Recent tab as expected.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
Devin FoleyandPaperclip committed 2026-03-29 23:18:10 -07:00
1 parent 6a72faf83b
commit 9b5a404379
2 files changed
+21 -5

No files matched your search

+20
View File
@@ -342,6 +342,26 @@ describe("inbox helpers", () => {
]);
});
it("sorts self-touched issues without external comments by updatedAt", () => {
const recentSelfTouched = makeIssue("recent", false);
recentSelfTouched.lastExternalCommentAt = null as unknown as Date;
recentSelfTouched.updatedAt = new Date("2026-03-11T05:00:00.000Z");
recentSelfTouched.myLastTouchAt = new Date("2026-03-11T05:00:00.000Z");
const olderCommented = makeIssue("older", false);
olderCommented.lastExternalCommentAt = new Date("2026-03-11T03:00:00.000Z");
const items = getInboxWorkItems({
issues: [olderCommented, recentSelfTouched],
approvals: [],
});
expect(items.map((i) => (i.kind === "issue" ? i.issue.id : ""))).toEqual([
"recent",
"older",
]);
});
it("can include sections on recent without forcing them to be unread", () => {
expect(
shouldShowInboxSection({
+1 -5
View File
@@ -123,11 +123,7 @@ export function issueLastActivityTimestamp(issue: Issue): number {
const lastExternalCommentAt = normalizeTimestamp(issue.lastExternalCommentAt);
if (lastExternalCommentAt > 0) return lastExternalCommentAt;
const updatedAt = normalizeTimestamp(issue.updatedAt);
const myLastTouchAt = normalizeTimestamp(issue.myLastTouchAt);
if (myLastTouchAt > 0 && updatedAt <= myLastTouchAt) return 0;
return updatedAt;
return normalizeTimestamp(issue.updatedAt);
}
export function sortIssuesByMostRecentActivity(a: Issue, b: Issue): number {