Files
orca/src
Kevin BravoandBrennan Benson 0d4baf2a63 fix(settings): guide Windows skill setup when npx is missing (#10453)
* fix(settings): guide Windows skill setup when npx is missing

* fix(settings): resolve npx by PATHEXT and keep the preflight off POSIX shells

Review fixes on the Windows npx preflight:

- Probe and run bare `npx` instead of pinning `npx.cmd`. cmd.exe resolves both
  through PATHEXT, so shims that ship `npx.exe` (Volta) no longer get told
  "npx was not found" on a machine where npx works.
- Force the skill terminal to PowerShell when the configured Windows shell is
  POSIX-family. Git Bash rewrites the leading `/d /s /c` arguments as MSYS
  paths, which would break a command that runs fine there today.
- Drop the "restart Orca" advice. Every new PTY merges the persisted Windows
  PATH, so a new setup terminal already picks up a fresh Node install.
- Fall back to the plain command on the two newly routed call sites when the
  project runtime is repair-required, matching the eight existing callers.
  Those sites otherwise emitted a wsl.exe command for a missing distro.

Adds coverage for the Git Bash override and for cmd.exe block safety.

* fix(settings): apply the skill-terminal shell override on every wrapped path

The Windows npx wrapper is emitted whenever buildSkillCommandForRuntime falls
back to the local host, but three paths never consulted the shell override, so
a Git Bash user still got the cmd.exe string pasted into MSYS:

- useActiveProjectSkillRuntime returned an empty result whenever no local
  project runtime resolved (no repo yet, or an SSH/remote repo) while the
  command builder kept wrapping. It now resolves the override for that same
  host fallback, so the wrap gate and the shell gate agree.
- The Linear setup prompt carried a third copy of the override that was still
  on the old wsl.exe-only check. It now delegates, as does the settings copy,
  leaving one implementation.
- MobileEmulatorAgentControlRow built wrapped commands but passed no override.

Also drops the unreachable WSL guard inside the wrapper; the only caller is
already on the non-WSL branch.

* fix(settings): keep the npx preflight off remote runtimes and finish the emulator row

- Skill setup terminals spawn on the focused runtime environment, so a Windows
  client was handing a cmd.exe command to a remote Linux host where the plain
  npx command used to run. Skip the wrapper whenever a runtime environment is
  focused.
- MobileEmulatorAgentControlRow was left half routed: it took the project
  runtime's shell override while still building a Windows host command, so a
  WSL project got the cmd.exe wrapper inside a WSL shell. Build its commands
  from the same runtime, matching MobileEmulatorAgentSetupGuideSteps.

* fix(settings): match the terminal router when skipping the npx preflight

- The remote check used settings.activeRuntimeEnvironmentId, but the setup
  terminal routes through getSingleFocusedRuntimeEnvironmentId, which keeps the
  terminal local unless exactly one saved environment is focused. Users with
  two or more environments lost the preflight while still running locally.
- LinearAgentSkillPane memoized its commands on the project runtime alone. The
  built command now also depends on the focused runtime environment, and
  Settings panes stay mounted, so the memo could serve a stale Windows command
  after a runtime switch. Compute it inline like every sibling pane.

* fix(settings): keep emulator skill setup installing where detection looks

The mobile emulator surfaces detect the Orca CLI skill with a local-host scan
that takes no discovery target, so building their commands from the project
runtime made a WSL project install into the distro while detection kept
scanning Windows: the panel stayed "Not installed" with no way out. Build host
commands there again, as the surrounding comment already documented, and keep
only the terminal shell override those surfaces actually needed.

Also narrow the remote check back to the focused environment id. Matching the
terminal router exactly meant reading runtimeEnvironments, which nothing on
these surfaces subscribes to, so adding or removing an environment mid-session
could leave a stale decision. The focused id alone over-skips instead, which
degrades to the previous behavior rather than sending cmd.exe to a remote host.

* fix(feature-tips): keep the npx preflight on the repair-required fallback

installDisabledReason is only ever set on Windows, so dropping the whole
command builder on that branch stripped the npx preflight exactly where it is
needed. This terminal auto-pastes with no install gate, so that fallback put
the bare npx command straight back in front of the user #10438 describes. Drop
to the host runtime instead, which still avoids the missing WSL distro.

Pins the two call-site invariants that were unguarded: the emulator surfaces
must build host commands because their detection scans the host only, and the
Linear prompt's shell override must cover POSIX-family Windows shells.

* fix(settings): reach the npx preflight from the ephemeral VMs pane too

This pane was the only one of eight requiring a resolved project runtime
before building its command, so a Windows user with no repo added yet — the
state issue #10438 was reported from — got the bare npx command and the same
dead end. An absent runtime already resolves to the local host, which is what
the sibling panes rely on.

Also pins the repair-required host fallback added in the previous commit; the
existing assertions all passed against the old form.

* test(settings): pin the ephemeral VMs pane to the host-resolving command

Reverting the previous commit left the whole suite green, and this is a PR
where several regressions came from an earlier fix, so guard it the same way
the emulator call sites are guarded.

---------

Co-authored-by: Brennan Benson <79079362+brennanb2025@users.noreply.github.com>
2026-07-29 16:27:47 -07:00
..