From be95460ad2a389f4fcfab9ba79591eaa8e915072 Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Fri, 4 Sep 2026 04:54:00 -0700 Subject: [PATCH] test(runtime): pin the scoped host derivation for local and executionHostId repos Review flagged that the host-scope cases only covered a connectionId repo. getRepoExecutionHostId reads two spellings, and a scoped listing naming the wrong host would be worse than naming none, so both are pinned. Both fail with the fix reverted. --- .../runtime-managed-worktree-queries.test.ts | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/main/runtime/runtime-managed-worktree-queries.test.ts b/src/main/runtime/runtime-managed-worktree-queries.test.ts index aa28c73c1f4..3fb792fcc7c 100644 --- a/src/main/runtime/runtime-managed-worktree-queries.test.ts +++ b/src/main/runtime/runtime-managed-worktree-queries.test.ts @@ -171,6 +171,48 @@ describe('RuntimeManagedWorktreeQueries.list host scope', () => { expect(scoped.hostScope?.omittedHostIds).toEqual(['ssh:conn-1']) }) + // `getRepoExecutionHostId` derives the host from two spellings, and a scoped listing that named + // the wrong one would be worse than naming none. These pin both. + it('names the local host for a scoped local repo', async () => { + const repo = folderRepo({ id: 'repo-local', kind: 'git', path: '/workspace/local' }) + const store = { + getRepos: () => [repo], + getRepo: () => repo, + getAllWorktreeMeta: () => ({}), + getWorktreeMeta: () => undefined, + setWorktreeMeta: vi.fn(), + getAllWorktreeLineage: () => ({}), + getSettings: () => settings + } as unknown as RuntimeStore + + const result = await queries(store).list('repo-local', 50) + + expect(result.hostScope?.omittedHostIds).toEqual(['local']) + }) + + it('prefers executionHostId over connectionId for the scoped host', async () => { + const repo = folderRepo({ + id: 'repo-runtime', + kind: 'git', + connectionId: 'conn-legacy', + executionHostId: 'runtime:env-1', + path: '/workspace/runtime' + }) + const store = { + getRepos: () => [repo], + getRepo: () => repo, + getAllWorktreeMeta: () => ({}), + getWorktreeMeta: () => undefined, + setWorktreeMeta: vi.fn(), + getAllWorktreeLineage: () => ({}), + getSettings: () => settings + } as unknown as RuntimeStore + + const result = await queries(store).list('repo-runtime', 50) + + expect(result.hostScope?.omittedHostIds).toEqual(['runtime:env-1']) + }) + it('still reports every configured host when the listing is unscoped', async () => { const unscoped = await queries(sshStore(), { listKnownHostIds: () => ['local', 'ssh:conn-1'] as never