diff --git a/src/shared/execution-host.ts b/src/shared/execution-host.ts index 2533327dada..2032bd9a511 100644 --- a/src/shared/execution-host.ts +++ b/src/shared/execution-host.ts @@ -170,11 +170,18 @@ export function getRepoExecutionHostId( // field and the unified `executionHostId`. Routing that reads the raw field answers // "local" for a row that only carries `ssh:`, which runs a remote operation // on the client. Resolve the host first, then read the connection off it. +// +// Why the fallback: a row whose execution host is a *runtime* can still reach a nested +// SSH target, and that target only ever appears in `connectionId`. Returning null for +// those rows answers "local" for a nested-SSH worktree — the same defect in reverse. export function getRepoSshConnectionId( repo: Pick ): string | null { const parsed = parseExecutionHostId(getRepoExecutionHostId(repo)) - return parsed?.kind === 'ssh' ? parsed.targetId : null + if (parsed?.kind === 'ssh') { + return parsed.targetId + } + return normalizeHostPart(repo.connectionId) ?? null } export function getSshTargetIdForExecutionHost(