Files
orca/src/main/runtime/runtime-repository-issue-command.ts
T
Neil 62b00c98bd fix(wsl): Settings' issue-command and path checks never start a stopped distro (#35829)
* fix(wsl): Settings' issue-command and path checks never start a stopped distro

Opening the repository and MCP settings sections read .orca/issue-command,
orca.yaml and stat'ed the repo root over \\wsl.localhost, which starts a
stopped distro (E9). The issue-command read (IPC and runtime) now returns
the unreachable result for a stopped distro unless a launch passes
wakeWslDistro, and shell:pathExists is gated like shell:pathsExist, with the
two link-click callers passing wakeWslDistro.

* fix(wsl): never save over an issue command a stopped distro kept unread

A refused read showed an empty, editable field, and typing then saved over
the hidden local override and started the distro. The editor now stays
read-only with a stopped-distro note, skips both saves, and re-reads when
main signals the distro running. Writes are gated too unless the user is
saving their own edit (wakeWslDistro). The MCP section's stopped message no
longer offers a Retry that cannot start the distro.

* fix(wsl): translate the stopped-distro issue command note; listen before reading

Adds the note in every shipped locale, and attaches the editor's running
listener before its read so a distro that starts while the refused read is
in flight still triggers a re-read.

* fix(wsl): keep the issue-command editor and writer tests on their seams

The editor reads window.api optionally, as hosts without a preload do, and
the writer tests spy on the gated write that the handlers now call.
2026-10-29 02:22:36 -07:00

71 lines
2.5 KiB
TypeScript

import { getRepoDialableSshTargetId } from '../../shared/execution-host'
import type { GitRuntimeOptions } from '../git/git-runtime-options'
import type { Repo } from '../../shared/repo-types'
import {
readIssueCommandUnlessWslStopped,
writeIssueCommandUnlessWslStopped
} from '../issue-command-file'
import { isFolderRepo } from '../../shared/repo-kind'
import { joinWorktreeRelativePath } from './runtime-relative-paths'
import type { RuntimeStore } from './runtime-store-contract'
import { assertWslMoveRepoWritable } from '../persistence/moving-wsl-projects/wsl-move-scope-guard'
type RuntimeRepositoryIssueCommandDeps = {
resolveRepo: (selector: string) => Promise<Repo>
getLocalGitArgs: (repo: Repo) => [] | [GitRuntimeOptions]
getStore?: () => RuntimeStore | null
}
export class RuntimeRepositoryIssueCommand {
constructor(private readonly deps: RuntimeRepositoryIssueCommandDeps) {}
async read(repoSelector: string, options: { wakeWslDistro?: boolean } = {}) {
const repo = await this.deps.resolveRepo(repoSelector)
if (isFolderRepo(repo)) {
return {
localContent: null,
sharedContent: null,
effectiveContent: null,
localFilePath: '',
source: 'none' as const
}
}
const connectionId = getRepoDialableSshTargetId(repo)
if (!connectionId) {
// A paired client's Settings render must not start this host's stopped distro (E9).
return readIssueCommandUnlessWslStopped(repo.path, options)
}
// Why: an `ssh:` repo is not served here; it reads as having no command.
return {
localContent: null,
sharedContent: null,
effectiveContent: null,
localFilePath: joinWorktreeRelativePath(repo.path, '.orca/issue-command'),
source: 'none' as const
}
}
/** Save a private override on its execution host; blank content restores the shared command. */
async write(
repoSelector: string,
content: string,
options: { wakeWslDistro?: boolean } = {}
): Promise<{ ok: true }> {
const repo = await this.deps.resolveRepo(repoSelector)
assertWslMoveRepoWritable(this.deps.getStore?.() ?? undefined, repo)
if (isFolderRepo(repo)) {
return { ok: true }
}
// Why: an `ssh:` repo is not served here; the write is dropped, as when it was unreachable.
if (!getRepoDialableSshTargetId(repo)) {
await writeIssueCommandUnlessWslStopped(
repo.path,
content,
() => this.deps.getLocalGitArgs(repo)[0] ?? {},
options
)
}
return { ok: true }
}
}