fix: include active root sessions in Recent sidebar

Recent now shows active root sessions immediately, even if they are older than 48 hours
Archived sessions and subtasks still stay out of Recent
Added coverage and documentation for the new recency rules
This commit is contained in:
Bohdan Triapitsyn
2026-07-23 16:46:20 +03:00
parent 89f7c37d60
commit 38222d07c8
4 changed files with 57 additions and 15 deletions
@@ -22,20 +22,19 @@ const getSessionUpdatedAt = (session: Session): number => {
return 0;
};
// Recent sessions are simply every non-archived, top-level session updated
// within the last RECENT_SESSION_MAX_AGE_MS. No persisted history or live-busy
// tracking: membership is timestamp-derived, while the caller applies shared
// lifecycle ordering.
// Recent contains non-archived root sessions that are active now or were
// updated within the retention window. The caller applies shared lifecycle
// ordering after this membership filter.
export const deriveRecentSessions = (
sessions: Session[],
activeSessionIds: ReadonlySet<string>,
now = Date.now(),
): Session[] => {
const minUpdatedAt = now - RECENT_SESSION_MAX_AGE_MS;
const recent = sessions.filter((session) => {
return sessions.filter((session) => {
if (isArchivedSession(session) || isSubtaskSession(session)) {
return false;
}
return getSessionUpdatedAt(session) >= minUpdatedAt;
return activeSessionIds.has(session.id) || getSessionUpdatedAt(session) >= minUpdatedAt;
});
return recent;
};