Introduce workspace-aware System side panel with remote process/tmux/Docker management, terminal popup for interactive attach, capability warmup, review-hardened IPC, performance optimizations, toast action errors, and SSH channel recovery on reconnect.
22 lines
922 B
TypeScript
22 lines
922 B
TypeScript
import { collectSessionIds } from '../workspace';
|
|
import type { TerminalSession, Workspace } from '../../types';
|
|
|
|
/** Resolve which terminal session the system sidebar should target (workspace focus-aware). */
|
|
export function resolveSystemSidebarSession(
|
|
sessions: TerminalSession[],
|
|
activeWorkspace: Workspace | undefined,
|
|
focusedSessionId: string | undefined,
|
|
activeSession: TerminalSession | undefined,
|
|
): TerminalSession | null {
|
|
if (activeWorkspace) {
|
|
const workspaceSessionIds = collectSessionIds(activeWorkspace.root);
|
|
const idSet = new Set(workspaceSessionIds);
|
|
const preferredId = focusedSessionId && idSet.has(focusedSessionId)
|
|
? focusedSessionId
|
|
: workspaceSessionIds.find((id) => sessions.some((session) => session.id === id));
|
|
if (!preferredId) return null;
|
|
return sessions.find((session) => session.id === preferredId) ?? null;
|
|
}
|
|
return activeSession ?? null;
|
|
}
|