Import apps/android/src/lib/workspace-sessions.ts

This commit is contained in:
QQ 2026-11-14 14:10:56 +08:00
parent 1c4343844f
commit 9db17c350e
1 changed files with 15 additions and 0 deletions

View File

@ -0,0 +1,15 @@
import type { RemoteSession, WorkspaceView } from '../types'
/** Harness retains archived IDs in its workspace catalog for later restoration. */
export function getVisibleWorkspaceSessions(
workspace: WorkspaceView,
sessions: readonly RemoteSession[],
archivedSessionIds: readonly string[],
): RemoteSession[] {
const archived = new Set(archivedSessionIds)
const byId = new Map(sessions.map(session => [session.sessionId, session]))
return workspace.sessionIds.flatMap(id => {
const session = byId.get(id)
return session === undefined || archived.has(id) ? [] : [session]
})
}