diff --git a/src/main/runtime/orca-runtime.ts b/src/main/runtime/orca-runtime.ts index 8dc377053f3..52e831602b4 100644 --- a/src/main/runtime/orca-runtime.ts +++ b/src/main/runtime/orca-runtime.ts @@ -5776,6 +5776,9 @@ export class OrcaRuntimeService { if (!workspace) { return null } + if (workspace.executionHostId != null) { + return parseExecutionHostId(workspace.executionHostId)?.id ?? null + } const connectionId = this.resolveFolderWorkspaceConnectionId(workspace) return connectionId ? toSshExecutionHostId(connectionId) : LOCAL_EXECUTION_HOST_ID } @@ -5844,6 +5847,13 @@ export class OrcaRuntimeService { } const projectGroups = this.store?.getProjectGroups?.() ?? [] for (const workspace of this.store?.getFolderWorkspaces?.() ?? []) { + if (workspace.executionHostId != null) { + const explicitHostId = parseExecutionHostId(workspace.executionHostId)?.id + if (explicitHostId) { + hostIds.add(explicitHostId) + } + continue + } const connection = inferFolderWorkspacePathConnection({ folderPath: workspace.folderPath, projectGroupId: workspace.projectGroupId, @@ -16733,6 +16743,9 @@ export class OrcaRuntimeService { const scopedHostId = targetWorktreeId ? (resolvedTargetHostId ?? this.tryGetWorkspaceSessionHostIdForWorktree(targetWorktreeId)) : null + if (scopedHostId) { + knownHostIds.add(scopedHostId) + } const candidates = targetWorktreeId ? (scopedHostId ? [scopedHostId] : []) : knownHostIds // Paired runtimes own a separate control plane. Mirrored rows are evidence // for those rows only; this runtime cannot claim their complete inventory. diff --git a/src/main/runtime/terminal-list-execution-host-scope.test.ts b/src/main/runtime/terminal-list-execution-host-scope.test.ts index edf8b64370e..c0460e0bd08 100644 --- a/src/main/runtime/terminal-list-execution-host-scope.test.ts +++ b/src/main/runtime/terminal-list-execution-host-scope.test.ts @@ -76,7 +76,7 @@ function makeRuntimeFolderWorkspace() { ...makeSshFolderWorkspace(), id: 'folder-runtime', name: 'Runtime folder', - connectionId: null, + connectionId: 'stale-box', executionHostId: 'runtime:env-9' as const } } @@ -317,6 +317,23 @@ describe('listTerminals scope declaration', () => { expect(result.hostScope?.omittedHostIds).toEqual(['local', 'runtime:env-9']) }) + it('keeps a paired-runtime folder owner omitted in an unscoped listing', async () => { + const baseStore = makeStore() + const folderWorkspace = makeRuntimeFolderWorkspace() + const runtime = makeRuntime([], { + ...baseStore, + getRepos: vi.fn(() => [REPOS[0]!]), + getRepo: vi.fn((id: string) => (id === REPOS[0]!.id ? REPOS[0] : undefined)), + getWorkspaceSessionHostIds: vi.fn(() => ['local']), + getFolderWorkspaces: vi.fn(() => [folderWorkspace]) + }) + + const result = await runtime.listTerminals() + + expect(result.hostScope?.hostIds).toEqual(['local']) + expect(result.hostScope?.omittedHostIds).toEqual(['runtime:env-9']) + }) + it('keeps a disconnected SSH host omitted when only local inventory answered', async () => { const runtime = makeRuntime([]) runtime.setPtyController({