Files
Netcatty/domain/systemManager/resolveSystemSession.ts
陈大猫 36267717ac feat(terminal): add system manager side panel for processes, tmux, and Docker
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.
2026-06-11 04:19:21 +08:00

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;
}