From a7fdbc88ea4f4c1742d6dd255c63417544eb2cf6 Mon Sep 17 00:00:00 2001 From: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> Date: Sun, 16 Aug 2026 19:08:15 -0700 Subject: [PATCH] fix(terminal): preserve paired folder host scope --- src/main/runtime/orca-runtime.ts | 6 ++++- ...terminal-list-execution-host-scope.test.ts | 27 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/main/runtime/orca-runtime.ts b/src/main/runtime/orca-runtime.ts index 8736d2dd88c..00b707b9d5d 100644 --- a/src/main/runtime/orca-runtime.ts +++ b/src/main/runtime/orca-runtime.ts @@ -16716,9 +16716,13 @@ export class OrcaRuntimeService { queriedHostIds, targetWorktreeId !== FLOATING_TERMINAL_WORKTREE_ID ) + let resolvedTargetHostId: ExecutionHostId | null = null for (const worktree of worktrees) { if (worktree.hostId) { knownHostIds.add(worktree.hostId) + if (worktree.id === targetWorktreeId) { + resolvedTargetHostId = worktree.hostId + } } } for (const terminal of terminals) { @@ -16727,7 +16731,7 @@ export class OrcaRuntimeService { } } const scopedHostId = targetWorktreeId - ? this.tryGetWorkspaceSessionHostIdForWorktree(targetWorktreeId) + ? (resolvedTargetHostId ?? this.tryGetWorkspaceSessionHostIdForWorktree(targetWorktreeId)) : null const candidates = targetWorktreeId ? (scopedHostId ? [scopedHostId] : []) : knownHostIds // Paired runtimes own a separate control plane. Mirrored rows are evidence 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 08c87559310..0fae9976bba 100644 --- a/src/main/runtime/terminal-list-execution-host-scope.test.ts +++ b/src/main/runtime/terminal-list-execution-host-scope.test.ts @@ -70,6 +70,16 @@ function makeSshFolderWorkspace() { } } +function makeRuntimeFolderWorkspace() { + return { + ...makeSshFolderWorkspace(), + id: 'folder-runtime', + name: 'Runtime folder', + connectionId: null, + executionHostId: 'runtime:env-9' as const + } +} + type GraphLeaf = { worktreeId: string; leafId: string; ptyId: string } function makeRuntime(leaves: GraphLeaf[], store = makeStore()): OrcaRuntimeService { @@ -289,6 +299,23 @@ describe('listTerminals scope declaration', () => { expect(result.hostScope?.omittedHostIds).toEqual(['local', 'ssh:box-2']) }) + it('does not claim local coverage for a paired-runtime folder workspace', 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(`id:${folderWorkspaceKey(folderWorkspace.id)}`) + + expect(result.hostScope?.hostIds).toEqual([]) + expect(result.hostScope?.omittedHostIds).toEqual(['local', 'runtime:env-9']) + }) + it('keeps a disconnected SSH host omitted when only local inventory answered', async () => { const runtime = makeRuntime([]) runtime.setPtyController({