Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -735,16 +735,11 @@ export function groupAgentSessionsByActive(sessions: IAgentSession[]): Map<Agent
const startOfToday = new Date(now).setHours(0, 0, 0, 0);
const startOfYesterday = startOfToday - DAY_THRESHOLD;

let mostRecentSession: { session: IAgentSession; time: number } | undefined;
for (const session of sessions) {
const sessionTime = session.timing.lastRequestEnded ?? session.timing.lastRequestStarted ?? session.timing.created;
if (!mostRecentSession || sessionTime > mostRecentSession.time) {
mostRecentSession = { session, time: sessionTime }; // always keep track of the most recent session
}

if (session.isArchived()) {
historySessions.add(session);
} else {
const sessionTime = session.timing.lastRequestEnded ?? session.timing.lastRequestStarted ?? session.timing.created;
if (
isSessionInProgressStatus(session.status) || // in-progress
!session.isRead() || // unread
Expand All @@ -758,17 +753,6 @@ export function groupAgentSessionsByActive(sessions: IAgentSession[]): Map<Agent
}
}

// Consider most recent from today or yesterday. This helps
// restore the session after restart when chat is cleared.
if (
mostRecentSession && !mostRecentSession.session.isArchived() &&
mostRecentSession.time >= startOfYesterday &&
!activeSessions.has(mostRecentSession.session)
) {
historySessions.delete(mostRecentSession.session);
activeSessions.add(mostRecentSession.session);
}

return new Map<AgentSessionSection, IAgentSessionSection>([
[AgentSessionSection.Active, { section: AgentSessionSection.Active, label: AgentSessionSectionLabels[AgentSessionSection.Active], sessions: [...activeSessions] }],
[AgentSessionSection.History, { section: AgentSessionSection.History, label: localize('agentSessions.historySectionWithCount', "History ({0})", historySessions.size), sessions: [...historySessions] }],
Expand Down
Loading