Skip to content

fix(preflight): resolve WSL/SSH agent paths past shell aliases - #7867

Merged
Jinwoo-H merged 3 commits into
stablyai:mainfrom
bbingz:fix/wsl-agent-discovery-aliases
Jul 10, 2026
Merged

Jinwoo-H merged 3 commits into
stablyai:mainfrom
bbingz:fix/wsl-agent-discovery-aliases

Conversation

@bbingz

@bbingz bbingz commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Review notes

  • Reviewer caught that type -P alone is bash-only; zsh needs lowercase type -p. Final chain is type -P || type -p || command -v.
  • Absolute-path gate still rejects residual alias text if every lookup falls through to command -v.
  • Fish remains on command -v (separate syntax path; WSL probes do not run under fish).

Test plan

  • pnpm exec vitest run --config config/vitest.config.ts src/main/ipc/preflight-wsl-agent-detection.test.ts src/relay/preflight-handler.test.ts src/main/ipc/preflight.test.ts (65 passed)
  • On Windows + WSL with LeanCTX (or manual) aliases for claude/codex, refresh agent detection and confirm both appear
  • Same check with bash and zsh as the WSL login shell
  • Confirm agents still detect when no aliases are present

AI code review summary

  • Cross-platform: WSL-focused; native Windows uses where; local POSIX uses which; relay POSIX probes updated; fish unchanged.
  • SSH/remote: relay buildShCommandLookupScript uses the same portable chain under trusted login shells.
  • Agent/integration: detection-only change; launch path unchanged once a real PATH binary is found.
  • Performance: one extra failing builtin attempt on dash/zsh before success; negligible vs WSL probe cost.
  • Security: command names still single-quote escaped; absolute-path filter retained.

bbingz added 2 commits July 9, 2026 10:19
LeanCTX and similar tools wrap claude/codex as interactive shell aliases.
command -v then returns alias text, which fails absolute-path detection and
hides installed agents (stablyai#7816).

Prefer bash type -P, then zsh type -p, then command -v for dash/sh fallback
in WSL agent discovery, WSL isCommandOnPath, and remote relay probes.
Require non-empty results between type -P, type -p, and command -v so bash
type -p empty success cannot skip later lookups.
@coderabbitai

coderabbitai Bot commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 0f2565f0-ab5b-4e84-bda9-37f76b138bba

📥 Commits

Reviewing files that changed from the base of the PR and between c49bc6a and 8fa3e52.

📒 Files selected for processing (8)
  • src/main/ipc/preflight-command-exec.test.ts
  • src/main/ipc/preflight-command-exec.ts
  • src/main/ipc/preflight-wsl-agent-detection.test.ts
  • src/main/ipc/preflight-wsl-agent-detection.ts
  • src/relay/preflight-handler.test.ts
  • src/relay/preflight-handler.ts
  • src/shared/posix-command-path-lookup.test.ts
  • src/shared/posix-command-path-lookup.ts

📝 Walkthrough

Walkthrough

A shared POSIX executable-path lookup script was added with shell-variable validation, literal quoting, explicit-path handling, and direct PATH scanning. WSL agent detection, relay preflight probes, and WSL command availability checks now use this script and emit or parse resolved absolute paths through prefixed output. Tests cover shell behavior, PATH edge cases, quoting and validation, WSL integration, probe generation, and sentinel-based parsing.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers summary, testing, and review notes, but it omits required Screenshots, Security Audit, and Notes sections. Add the missing template sections, including Screenshots, a checkbox-style Testing list, Security Audit, and Notes.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main fix: resolving WSL agent paths past shell aliases.
Linked Issues check ✅ Passed The PR implements alias-resistant PATH resolution in WSL and relay lookups, matching issue #7816’s requested behavior.
Out of Scope Changes check ✅ Passed The added helper and tests all support PATH resolution and alias handling; no unrelated changes are evident.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Jinwoo-H Jinwoo-H left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the focused fix. I tightened and validated the resolver during review:

  • WSL and SSH now scan PATH directly, so aliases, functions, and shell-specific type behavior cannot hide installed agents.
  • Added bash, zsh, dash, sh, and Windows-to-WSL coverage, including readonly functions and shell startup output.
  • Verified Claude and Codex detection in Orca's WSL flow and through a fresh Linux SSH relay.
  • Typecheck, lint, relay build, and focused tests pass.

@Jinwoo-H
Jinwoo-H merged commit 5b1b8cc into stablyai:main Jul 10, 2026
2 checks passed
Jinwoo-H added a commit that referenced this pull request Jul 10, 2026
Clean auto-merge, no conflicts (109 files, +7490 from main). Brought in:
- Codex WSL runtime status hooks (#7969); WSL/SSH agent path resolution past
  shell aliases (#7867); WSL source-control path separators (#7966); WSL
  GitLab-auth wake fix (#7967); WSL Codex usage RPC refresh (#7567/#7658)
- Improve workspace cleanup list (#7053) + background removal
- mobile: per-host connection log + Tailscale wedge recovery (#7984/#7980),
  wake slept agents on mobile worktree open (#7906)
- Harden layout validation, watcher lifecycle, connection robustness (#7924)
- Disable experimental worktree card style by default (#7977)

Perf-branch structure preserved (clean auto-merge). typecheck 0 errors; lint 0
errors. CI is the release gate (local runs skipped per env lag).

Co-authored-by: Orca <[email protected]>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…yai#7867)

* fix(preflight): resolve WSL/SSH agent paths past shell aliases

LeanCTX and similar tools wrap claude/codex as interactive shell aliases.
command -v then returns alias text, which fails absolute-path detection and
hides installed agents (stablyai#7816).

Prefer bash type -P, then zsh type -p, then command -v for dash/sh fallback
in WSL agent discovery, WSL isCommandOnPath, and remote relay probes.

* fix(preflight): harden alias-safe PATH lookup chain

Require non-empty results between type -P, type -p, and command -v so bash
type -p empty success cannot skip later lookups.

* fix(preflight): resolve agent executables directly from PATH

---------

Co-authored-by: Jinwoo Hong <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: WSL agent discovery fails when claude/codex are shell aliases; please use type -P or absolute path detection

2 participants