fix(sync): unify live session truth across chat and sidebar
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import type { Session } from '@opencode-ai/sdk/v2';
|
||||
import type { SessionStatus } from '@opencode-ai/sdk/v2/client';
|
||||
|
||||
export const ACTIVE_NOW_STORAGE_KEY = 'oc.sessions.activeNow';
|
||||
export const ACTIVE_NOW_MAX_AGE_MS = 36 * 60 * 60 * 1000;
|
||||
@@ -104,4 +105,20 @@ export const deriveActiveNowSessions = (
|
||||
return sortSessionsByUpdated(sessions);
|
||||
};
|
||||
|
||||
export const deriveLiveActiveNowSessions = (
|
||||
sessions: Session[],
|
||||
statuses: Record<string, SessionStatus>,
|
||||
): Session[] => {
|
||||
const activeSessions = sessions.filter((session) => {
|
||||
if (isArchivedSession(session) || isSubtaskSession(session)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const status = statuses[session.id];
|
||||
return status?.type === 'busy' || status?.type === 'retry';
|
||||
});
|
||||
|
||||
return sortSessionsByUpdated(activeSessions);
|
||||
};
|
||||
|
||||
export const getSessionUpdatedAtMs = getSessionUpdatedAt;
|
||||
|
||||
Reference in New Issue
Block a user