Repository navigation
Conversation
|
Important Review skippedWe couldn't safely recover the incremental review. No full review was started, and the last reviewed checkpoint was preserved. Retry later, or explicitly request a full review by commenting You can disable this status message by setting the Use the checkbox below for a quick retry:
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughCursor agent configuration now supports detected executable aliases, mapping the 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: d9e781f0-bfee-4539-944c-d7a75dcc84c5
📥 Commits
Reviewing files that changed from the base of the PR and between 7622b87d72d5e135865d1a161019d376be8c313a and 0516c37359cfd3f590506a5b4de24ca2efc11592.
📒 Files selected for processing (2)
src/shared/commit-message-agent-spec.tssrc/shared/tui-agent-config.ts
0516c37 to
7f7e839
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: fb7303d7-94f5-49b1-ab0c-47a74cd6bae0
📥 Commits
Reviewing files that changed from the base of the PR and between 0516c37359cfd3f590506a5b4de24ca2efc11592 and 7f7e83917fe12abe01b6012d7bdca6526dc05c4e.
📒 Files selected for processing (1)
node_modules
|
Maintainer review. I evaluated this against the competing #10200 for issue #10189 and this is the approach we should take. I've recommended closing #10200 in favour of it. The reasoning: aliases in this codebase only widen detection — VerificationI confirmed the underlying CLI claims against the real binaries rather than trusting the issue:
Test results in a clean worktree at Regression checks pass: alias-only → Two things to fix before merge1. Agent attribution misses the alias. const defaultLaunchCommand = getTuiAgentLaunchCommand(TUI_AGENT_CONFIG[agent], args.platform, {
isRemote: args.isRemote
})so a typed command is only ever compared against 2. Also worth noting for whoever merges: the Nice work on the write-up, particularly documenting why the inverted first attempt was wrong; that saved a good deal of review time. |
|
Follow-up to my review above, on a process point: this repo has a mandatory template at Conformant PR body## Summary
Orca hardcoded `cursor-agent` as both `detectCmd` and `launchCmd`. That binary only exists if the user ran the standalone installer (`curl https://cursor.com/install | bash`). A standard Cursor.app install puts `cursor` on PATH and reaches the agent through the `cursor agent` subcommand, so those users got `zsh: command not found: cursor-agent`.
Detection now publishes which executable actually matched on PATH, and the launch path consumes it: `cursor-agent` detected → launch `cursor-agent`; only `cursor` detected → launch `cursor agent`.
## ELI5
Cursor can be installed two different ways, and each one gives the command a different name. Orca only knew one of those names, so for everyone with the other kind of install it kept trying to run a program that wasn't there and gave up. Now Orca looks to see which version you actually have and uses the matching name.
## Proof of fix
An alias-only install (`cursor` on PATH, no `cursor-agent`) detects Cursor and then launches a command the host actually has. On `main` the same scenario detects nothing; with only a detection alias added it detects but still launches the missing binary:
```
AssertionError: expected 'cursor-agent' to be 'cursor agent'
Expected: "cursor agent"
Received: "cursor-agent"
```
With this PR, all three install layouts resolve correctly:
```
✓ alias-only install launches `cursor agent`
✓ standalone install still launches `cursor-agent`
✓ both installed prefers `cursor-agent`
Test Files 1 passed (1)
Tests 3 passed (3)
```
Verified against the real CLI, since "space-separated subcommand" is the load-bearing claim:
- Cursor.app's `bin/cursor` routes via `exec ~/.local/bin/cursor-agent "$@"` — it does **not** shift the `agent` token.
- That is safe because `cursor-agent` registers `agent` as a genuine subcommand: `cursor-agent agent --help` → `Usage: agent agent [options] [prompt...]`.
- `--model`, `--force`/`--yolo`, `--resume` all parse under the subcommand (the terse subcommand help is misleading — flags are inherited).
- `cursor agent models` and `cursor-agent models` emit identical output, so model discovery is unaffected.
## Proof of no regressions
```
vitest src/shared src/main/ipc → 5279 passed | 15 skipped (483 files)
vitest src/renderer/src/lib src/renderer/src/store src/main/text-generation
→ 5035 passed | 1 skipped (460 files)
tsc --noEmit -p config/tsconfig.node.json → clean
tsc --noEmit -p config/tsconfig.tc.web.json → clean
oxlint <all changed files> → clean
```
Existing `cursor-agent` users are unaffected: when both binaries are present, detection prefers the primary name, so the launch command is byte-identical to today's. `expectedProcess` stays `cursor-agent` and remains correct — the launcher uses `exec -a "$0"`, so argv[0] is `.../cursor-agent` regardless of entry point, leaving process recognition and title attribution untouched.
Behavior that **does** change, all of it scoped to hosts that previously could not launch Cursor at all:
- An alias-only install now shows Cursor as available (previously hidden) and launches `cursor agent`.
- On such a host, if `cursor-agent` is absent Cursor's own shim may run `curl -sS https://cursor.com/install | bash` on first launch — see Notes.
## Compatibility
- **Platforms:** macOS verified end-to-end against a real dual install (`cursor` + `cursor-agent`, agent `2026.06.02-8c11d9f`), confirming subcommand routing, flag parity and `models` output. Linux uses the same POSIX shim shape. Windows is unaffected by the string change and is handled by existing machinery: `resolveCliCommand` probes `.cmd`/`.exe`/`.bat` explicitly rather than trusting PATHEXT, and `getSpawnArgsForWindows` routes batch shims through `cmd.exe /d /c` as separate argv entries.
- **SSH / remote:** deliberately out of scope. The registry describes this process's PATH, which says nothing about a remote host, so remote and WSL launches keep the static defaults — the right answer for servers, where `cursor-agent` is the usual install. The relay protocol (`src/relay/preflight-handler.ts`) is untouched.
- **Performance:** no hot-path change. The executable map is computed once per detection pass from data preflight already gathers — no additional subprocess spawns — and launch-time lookup is a single object read.
## Screenshots
No visual change.
## Testing
- [x] `oxlint` on all changed files — clean (ran the linter directly rather than the `pnpm lint` wrapper)
- [x] `tsc --noEmit` on both `config/tsconfig.node.json` and `config/tsconfig.tc.web.json` — clean
- [ ] `pnpm test` — **not run in full.** Ran a targeted subset instead: `src/shared`, `src/main/ipc`, `src/renderer/src/lib`, `src/renderer/src/store`, `src/main/text-generation` → 10314 passed, 16 skipped, 0 failed.
- [ ] `pnpm build` — not run.
- [x] Added or updated high-quality tests that would catch regressions
## AI Review Report
Reviewed for correctness, regressions, cross-OS behavior, SSH/remote assumptions, and command-execution safety.
The main risk checked was whether widening detection without widening launch would leave the agent visibly broken — it does, which is why the alias-only approach in #10200 was rejected in favour of this one. Also verified that preferring the primary name keeps existing `cursor-agent` users on a byte-identical command, and that `expectedProcess` stays valid under `exec -a`.
Cross-platform compatibility was explicitly checked for macOS, Linux and Windows: shell resolution of `.cmd`/`.exe`/`.bat` shims, PATHEXT independence, argv construction on Windows batch paths, and the WSL/remote boundary. No shortcuts, labels, or path separators are touched by this change. One gap was flagged and should be fixed before merge — see Notes.
## Security Audit
**Command execution.** The change makes a launch command expand from one token to two, so arg-splitting was the primary concern. Traced the value into every spawn site: `planAgentBinary` splits the default into `binary` + `prefixArgs` and `commit-message-text-generation.ts` passes those to `spawn(spawnCmd, spawnArgs, …)` as an **array** — never concatenated into a shell string, so no interpolation boundary is introduced. On Windows, `getSpawnArgsForWindows` sends batch shims through `cmd.exe /d /c` as separate argv entries and throws `UnsafeWindowsBatchArgumentsError` on unsafe batch syntax.
**Terminal launches** do build a shell string, but that is the pre-existing shared path — `orca claude-teams`, `hermes --tui` and `command-code --trust` are already multi-token — so `cursor agent` adds no new class of risk. Both tokens are hardcoded constants; no user input reaches the command head.
**Input handling / IPC.** The new `preflight:detectAgentExecutables` channel returns a `Partial<Record<TuiAgent, string>>` built entirely from a fixed allowlist of config-declared names, not from user input or filesystem strings, so a hostile PATH cannot inject an arbitrary command through it. The renderer swallows failures and falls back to static defaults.
**Path handling.** No new path construction; detection reuses the existing PATH probe. No auth, secrets, or dependency surface is touched.
**Follow-up:** the `curl | bash` behavior in Notes is Cursor's own shim, not code introduced here, but it is worth documenting since this change can newly reach it.
## Notes
Two items worth resolving:
1. **Agent attribution misses the alias.** `resolveBareAgentLaunchCommand` (`src/main/runtime/orca-runtime.ts:1309`) calls `getTuiAgentLaunchCommand` without `detectedCmd`, so a typed command is only compared against `cursor-agent`. On an alias-only install, a user typing `cursor agent` into a terminal won't be recognised as a Cursor lane and loses managed hooks plus the `preflightTrust: 'cursor'` preset — the very trust-menu problem that preset exists to prevent.
2. **`cursor agent` can trigger a network install.** When `cursor-agent` is absent, Cursor.app's shim runs `curl -sS https://cursor.com/install | bash` plus a `--min-version` check on first invocation, so an alias-only launch may block on a download the user didn't request.
Fixes #10189 |
|
@nwparker Thanks for the review and for verifying the CLI claims against the real binaries — both items are now fixed on the branch (e3997c7), and the PR body has been rewritten to the template. 1. Agent attribution. Fixed, with one deliberate deviation from what you suggested. Passing the detected executable into So Covered by a test that asserts 2. Re-ran after the change:
|
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/shared/tui-agent-config.ts (1)
321-351: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winDo not apply local executable detection to remote or WSL launches.
getTuiAgentLaunchCommandresolvesdetectedCmdbefore checkingopts.isRemote, so a localcursordetection can producecursor agentfor a remote launch. Keep detected-command mappings disabled whenopts.isRemoteis true; likewise, ensure callers do not invokeapplyDetectedTuiAgentExecutablefor remote/WSL commands.Proposed fix
- const detected = opts?.detectedCmd ? config.launchCmdByDetectCmd?.[opts.detectedCmd] : undefined + const detected = opts?.isRemote + ? undefined + : opts?.detectedCmd + ? config.launchCmdByDetectCmd?.[opts.detectedCmd] + : undefinedBased on learnings, local detection must not be used for remote or WSL launch resolution.
Source: Learnings
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 4cc3b05c-c582-4ea6-bd6e-079f4d126383
📥 Commits
Reviewing files that changed from the base of the PR and between 7f7e83917fe12abe01b6012d7bdca6526dc05c4e and e3997c769cf996a7ccaa3729b892a7c0af35531c.
📒 Files selected for processing (3)
src/main/runtime/orca-runtime.test.tssrc/main/runtime/orca-runtime.tssrc/shared/tui-agent-config.ts
|
@coderabbitai Half right, and the half you were right about was the one the diff didn't show. Fixed in 2c2d46ed0. Remote — the launch path was already isolated, but you were pointing at the wrong consumer. For launches, the guard is in the caller, not Your proposed diff would also close an intentional door: But And WSL was open in both. A WSL worktree launches with Fix: detection now publishes the platform it ran on; Three tests, each confirmed failing with only the corresponding guard removed: Two structural moves came with it: |
|
Tip For best results, initiate chat on the files or code changes.
The actual issue was the ambient local registry leaking through 🐇✅ ✏️ Learnings added
If you found this review helpful, would you consider giving us a shout-out on X? Thank you for using CodeRabbit! |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/renderer/src/store/slices/detected-agents.ts (1)
61-71: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winPrevent stale executable mappings from overwriting the current context.
Lines 61-67 do not retain the detection generation or context key. If a later detection supersedes this request while
detectAgentExecutablesis in flight, its late result can republish an obsolete alias mapping and make subsequent local Cursor plans launch the wrong binary. Pass the generation/context into this helper and verify it before callingsetDetectedTuiAgentExecutables.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 9304d811-86d0-48af-9773-31dc2dbb1510
📥 Commits
Reviewing files that changed from the base of the PR and between e3997c769cf996a7ccaa3729b892a7c0af35531c and 2c2d46ed0298fb5bcffd33b717281581b7d791c6.
📒 Files selected for processing (12)
src/main/ipc/preflight.tssrc/main/text-generation/commit-message-text-generation.tssrc/renderer/src/lib/client-platform.tssrc/renderer/src/lib/new-workspace.tssrc/renderer/src/lib/tui-agent-startup.test.tssrc/renderer/src/store/slices/detected-agents.tssrc/shared/commit-message-plan.test.tssrc/shared/commit-message-plan.tssrc/shared/detected-agent-command.tssrc/shared/detected-agent-executables.tssrc/shared/tui-agent-config.tssrc/shared/tui-agent-launch-command.ts
💤 Files with no reviewable changes (1)
- src/shared/tui-agent-config.ts
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/renderer/src/store/slices/detected-agents.ts (2)
61-71: 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy liftDo not overwrite the host registry with non-host detection results.
detectAgentExecutables(context)returns an empty mapping for WSL/remote contexts, but this callback unconditionally stores{}as the client-host snapshot. After a WSL refresh, local launches can lose the detectedcursor → cursor agentmapping and fall back to unavailablecursor-agent. Keep host and non-host detection state separate, or skip publication for non-host contexts.
107-107: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winAwait executable publication before resolving detection.
Both call sites fire the publication IPC without awaiting it, so callers can immediately build a launch plan before the detected alias is stored. Return/await the publication promise while keeping publication failures non-fatal.
Suggested direction
- publishDetectedAgentExecutables(context) + await publishDetectedAgentExecutables(context)Make
publishDetectedAgentExecutablesreturn aPromise<void>and await it from these async detection callbacks.Also applies to: 154-154
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 9304d811-86d0-48af-9773-31dc2dbb1510
📥 Commits
Reviewing files that changed from the base of the PR and between e3997c769cf996a7ccaa3729b892a7c0af35531c and 2c2d46ed0298fb5bcffd33b717281581b7d791c6.
📒 Files selected for processing (12)
src/main/ipc/preflight.tssrc/main/text-generation/commit-message-text-generation.tssrc/renderer/src/lib/client-platform.tssrc/renderer/src/lib/new-workspace.tssrc/renderer/src/lib/tui-agent-startup.test.tssrc/renderer/src/store/slices/detected-agents.tssrc/shared/commit-message-plan.test.tssrc/shared/commit-message-plan.tssrc/shared/detected-agent-command.tssrc/shared/detected-agent-executables.tssrc/shared/tui-agent-config.tssrc/shared/tui-agent-launch-command.ts
💤 Files with no reviewable changes (1)
- src/shared/tui-agent-config.ts
|
@coderabbitai review |
✅ Action performedReview finished.
|
0c70966 to
cc9495c
Compare
|
I reproduced a Windows-specific gap in the Source Control AI path that this PR's current compatibility section appears to miss. Interactive Cursor launches may be fine, but non-interactive commit/branch/PR generation is still unable to use either standard Windows Cursor entry point without an override. Environment
Failure chain
In a real branch auto-name run, Cursor only worked after overriding the command to invoke So Secondary related finding: native Windows command overrides are corruptedThe workaround exposed another issue in is tokenized as: and then reported as not found on PATH. Replacing backslashes with forward slashes works around it, but Windows Settings should accept native absolute paths. This may deserve a separate fix, but it is directly relevant to the only working override for the batch-shim problem above. |
|
Thanks @iFwu — this is a great report, and I've confirmed both findings by reading the code paths you named. I want to be precise about what I'm fixing here versus what I'm deliberately deferring. Both issues are real, and both are pre-existing rather than introduced by this PR. On the batch-shim failure, your chain is exactly right. What this PR does change on Windows is visibility: an alias-only install now surfaces Cursor as available, so the failure is reported at generation time instead of being hidden behind "not detected". That is a fair thing to call out, and I've rewritten the Compatibility section — the previous claim that I've added the regression test you asked for (32197f8). It's platform-mocked, so it runs on any host, and it locks three things: both On the actual fix, I'm deferring rather than expanding this PR. Choosing between a PowerShell launch strategy and avoiding So: two follow-ups, and this PR keeps its original scope of "detect the Cursor CLI that is actually installed", with the Windows limitation now documented honestly instead of glossed over. One thing I can't do myself: I don't have a Windows environment, so the mocked test is as far as I can verify. When the launch-strategy follow-up lands, I'd be grateful if you could re-run your branch auto-name scenario against it — you're the only person who has demonstrated a working end-to-end path. |
|
Follow-ups now filed, both crediting your reproduction:
One design constraint I flagged in #11375 that's worth surfacing here: the backslash handling can't simply be deleted, because the same override string can target a WSL distro or a remote SSH host where POSIX semantics are still correct. The platform that matters is the one the command executes on, not the one running the UI. This PR's description now links both issues. |
| export function _resetPreflightCache(): void { | ||
| cached = null | ||
| detectedAgentExecutables = {} | ||
| hasDetectedAgentExecutables = false |
There was a problem hiding this comment.
Test-helper registry leak in
_resetPreflightCache
_resetPreflightCache resets the preflight.ts-local copies of detectedAgentExecutables and hasDetectedAgentExecutables, but does not call _resetDetectedTuiAgentExecutables() from detected-agent-executables.ts. Because publishDetectedAgentExecutables writes to both the local copy and the shared module-level registry, any test that triggers detectInstalledAgents will leave residual state in the shared registry for subsequent tests that rely on getDetectedTuiAgentExecutable. Current preflight.test.ts tests don't read the shared registry, so there are no failures today, but a future test that checks the registry after a preflight reset would see stale data.
Greptile SummaryThis PR fixes Cursor agent detection and launch for standard Cursor.app installations, where only
Confidence Score: 5/5Safe to merge. The change is additive for alias-only installs and byte-identical for existing cursor-agent users; all new code paths are covered by tests. The registry architecture cleanly isolates detection from launch without touching ~25 call sites. The generation + context-key staleness guard prevents stale publishes from overwriting fresh results. Platform gating blocks Windows-detected aliases from leaking into WSL or remote launches. No existing behaviour changes for standalone-binary users. Files Needing Attention: No files require special attention. The most complex new file is src/renderer/src/store/slices/detected-agents.ts, whose sequential async ordering is deliberate and well-tested.
|
| Filename | Overview |
|---|---|
| src/shared/detected-agent-executables.ts | New module: process-local registry mapping TuiAgent to matched executable. Platform-gated reads prevent Windows-detected aliases from leaking to WSL/remote launches. |
| src/shared/detected-agent-command.ts | New helper: rewrites the leading executable of a command string using the detection registry. Correctly handles exact match and prefix-with-suffix cases. |
| src/shared/tui-agent-config.ts | Adds launchCmdByDetectCmd field to TuiAgentConfig and populates it for cursor. getTuiAgentLaunchCommand gains a detectedCmd opt that overrides static defaults before launchCmdByPlatform lookup. |
| src/renderer/src/store/slices/detected-agents.ts | Detection flow now awaits publishDetectedAgentExecutables before updating Zustand store; generation + context-key tracking prevents stale results from overwriting fresh ones. |
| src/main/ipc/preflight.ts | Adds detectInstalledAgentExecutables (IPC-exposed, WSL-gated). _resetPreflightCache now also calls _resetDetectedTuiAgentExecutables(), fixing the registry-leak concern from a prior review. |
| src/shared/tui-agent-detection-commands.ts | Adds resolveDetectedTuiAgentExecutables which iterates commands in declaration order so cursor-agent wins over cursor when both are present. |
| src/shared/tui-agent-launch-command.ts | resolveAgentLaunchCommand now reads the detected executable from the registry with remote/platform gating and passes it to getTuiAgentLaunchCommand as detectedCmd. |
| src/shared/commit-message-plan.ts | planAgentBinary applies the detected executable alias and splits on space to extract binary + prefix args. planCommitMessageGeneration accepts an optional AgentExecutionRuntime parameter. |
| src/main/text-generation/commit-message-text-generation.ts | All three generation entry points now pass a runtime derived from the target, correctly scoping WSL vs local vs remote detection. |
| src/main/runtime/orca-runtime.ts | resolveBareAgentLaunchCommand now includes all launchCmdByDetectCmd values as attribution candidates so a typed 'cursor agent' is claimed by the managed Cursor lane. |
Reviews (3): Last reviewed commit: "test(win32): lock batch-shim rejection f..." | Re-trigger Greptile
32197f8 to
7ac3b3b
Compare
|
Want your agent to iterate on Greptile's feedback? Try greploops. |
7ac3b3b to
b1856b8
Compare
|
Rebased onto latest main and merged the branch's newer cursor commits. Local verification: tsc clean + 1106 tests passed (tui-agent-startup, orca-runtime, commit-message). The PR Checks workflow needs approval to run on the new head — could you approve? Thanks! |
1 similar comment
|
Rebased onto latest main and merged the branch's newer cursor commits. Local verification: tsc clean + 1106 tests passed (tui-agent-startup, orca-runtime, commit-message). The PR Checks workflow needs approval to run on the new head — could you approve? Thanks! |
772860a to
312071c
Compare
|
Rebased onto current Upstream split most of the files this touched, so each change now lives where that code is today (
|
…' and clean up aliases
Orca hardcoded `cursor-agent` for detection and launch. Cursor.app only puts `cursor` on PATH and reaches the agent via `cursor agent`, so standard IDE installs failed with `command not found: cursor-agent`. `detectCmdAliases` alone cannot fix this: aliases widen detection while launch commands stay static, so an alias-only install would be detected and then launched with a binary it does not have. Detection is the only place that knows which executable is really on PATH, so it now publishes that per agent and the launch path prefers it. - `launchCmdByDetectCmd` maps a matched alias to its launch form; Cursor keeps `cursor-agent` as primary and maps `cursor` -> `cursor agent`. - Detection resolves the matched executable and publishes it to a process-local registry read by `resolveAgentLaunchCommand` and `planAgentBinary`, so the ~25 `buildAgentStartupPlan` call sites need no new argument. - Remote and WSL launches ignore the registry and keep the static defaults — the local PATH says nothing about the host that will run the command. Existing `cursor-agent` installs, including SSH hosts, are unchanged.
resolveBareAgentLaunchCommand only compared a typed command against the single launch form the current PATH resolves to, so `cursor agent` typed into a terminal was never recognised as the Cursor lane and lost its managed hooks and the preflightTrust preset. Match every alias launch form instead — recognition is broader than launch by design, and detection can flip under us once Cursor's shim self-installs `cursor-agent`. Also document that the `cursor agent` form can trigger that install.
…ted them The detection registry describes one process's PATH, but two consumers read it without knowing where the command will actually run: - `planAgentBinary` (commit message / PR fields / branch name / model discovery) had no remote awareness at all, so an alias-only Cursor install on the client planned `cursor agent` for plans shipped to an SSH host via `runRemotePlan`. - A WSL launch is never `isRemote`, so the launch path's remote guard did not cover it: a Windows-detected `cursor` became `cursor agent` inside a distro whose standalone `cursor-agent` is the binary that exists. Detection now publishes the platform it ran on, and both consumers pass the runtime the command is bound for; a mismatch falls back to the static `launchCmd`. The explicit `detectedCmd` argument is untouched, so a future remote-side detection can still supply its own executable. Moves `applyDetectedTuiAgentExecutable` to its own leaf module (it is not config) and `CLIENT_PLATFORM` to `lib/client-platform` so the store slice can read it without importing the Zustand store.
Source Control AI delivers Cursor prompts in argv and those prompts are multiline by construction, so both standard Windows Cursor entry points hit UnsafeWindowsBatchArgumentsError before cmd.exe runs. Document that the detected-executable alias does not change this outcome, and that a non-batch launcher passes the same prompt through untouched.
…-lines The rebase onto current main landed these additions in files upstream had already grown close to the 300-line limit. Move planAgentBinary, the host executable snapshot, and the WSL-aware executable detector into their own modules; behavior is unchanged.
Discovery runs through planAgentBinary, which already maps cursor-agent to the detected alias; the catalog string is only a presence gate.
312071c to
0c5abe1
Compare
|
Rebased onto current |
|
Closing this PR. I am not going to keep iterating contribution PRs here; if a report is useful I will file an issue instead. |
Summary
Orca hardcoded
cursor-agentas bothdetectCmdandlaunchCmd. That binary only exists if the user ran the standalone installer (curl https://cursor.com/install | bash). A standard Cursor.app install putscursoron PATH and reaches the agent through thecursor agentsubcommand, so those users gotzsh: command not found: cursor-agent.Detection now publishes which executable actually matched on PATH, and the launch path consumes it:
cursor-agentdetected → launchcursor-agent; onlycursordetected → launchcursor agent.ELI5
Cursor can be installed two different ways, and each one gives the command a different name. Orca only knew one of those names, so for everyone with the other kind of install it kept trying to run a program that wasn't there and gave up. Now Orca looks to see which version you actually have and uses the matching name.
Why
detectCmdAliasesalone is not enoughAliases in this codebase only widen detection —
getTuiAgentLaunchCommandreadsconfig.launchCmdand nothing else (same shape asmistral-vibeandclaude-agent-teams). An alias-only fix would make Cursor appear installed and then fail at launch with the samecommand not found, which is worse than main's honest "not detected". Flipping the default the other way would break every existingcursor-agentuser, which on SSH hosts is the common install.Detection is the only place that knows which executable is really on PATH, so it now publishes that fact and the launch path consumes it.
Changes
launchCmdByDetectCmd(tui-agent-config.ts): maps a matched alias to the launch command it needs. Cursor keepscursor-agentasdetectCmd/launchCmdand mapscursor→cursor agent.resolveDetectedTuiAgentExecutables()returns one executable per detected agent (primary name wins when both are installed).preflightpublishes it into a process-local registry (detected-agent-executables.ts), exposed to the renderer overpreflight:detectAgentExecutables.resolveAgentLaunchCommandandplanAgentBinary(commit-message generation + native-chat model discovery) resolve through it. This keeps the change out of the ~25buildAgentStartupPlancall sites, which build commands synchronously.resolveBareAgentLaunchCommand(orca-runtime.ts) now matches a typed command against alllaunchCmdByDetectCmdforms, not just the one the current PATH resolves to — see Notes.launchCmd.Proof of fix
An alias-only install (
cursoron PATH, nocursor-agent) detects Cursor and then launches a command the host actually has. Onmainthe same scenario detects nothing; with only a detection alias added it detects but still launches the missing binary:With this PR, all three install layouts resolve correctly:
Verified against the real CLI (
cursor-agent2026.07.23-e383d2b), since "space-separated subcommand" is the load-bearing claim:bin/cursorroutes viaexec ~/.local/bin/cursor-agent "$@"— it does not shift theagenttoken.cursor-agentregistersagentas a genuine subcommand:cursor-agent agent --help→Usage: agent agent [options] [prompt...].--model,--force/--yolo,--resumeall parse under the subcommand (the terse subcommand help is misleading — flags are inherited).cursor agent modelsandcursor-agent modelsemit identical output, so model discovery is unaffected.Proof of no regressions
Existing
cursor-agentusers are unaffected: when both binaries are present, detection prefers the primary name, so the launch command is byte-identical to today's.expectedProcessstayscursor-agentand remains correct — the launcher usesexec -a "$0", so argv[0] is.../cursor-agentregardless of entry point, leaving process recognition and title attribution untouched.Behavior that does change, all of it scoped to hosts that previously could not launch Cursor at all:
cursor agent.cursor agentis now claimed by the managed Cursor lane instead of running as raw shell.cursor-agentis absent Cursor's own shim may runcurl -sS https://cursor.com/install | bashon first launch — see Notes.Compatibility
cursor+cursor-agent), confirming subcommand routing, flag parity andmodelsoutput. Linux uses the same POSIX shim shape. On Windows, interactive launches work:resolveCliCommandprobes.cmd/.exe/.batexplicitly rather than trusting PATHEXT. Windows Source Control AI remains blocked, before and after this PR — see below.promptDelivery: 'argv', and Source Control AI prompts are multiline by construction. Both standard Windows entry points (cursor-agent.cmd,cursor.cmd) resolve to batch shims, andgetSpawnArgsForWindowsdeliberately rejects — not escapes — any.cmd/.batargument containing&|<>^"%!\r\n, throwingUnsafeWindowsBatchArgumentsError. So non-interactive commit/branch/PR generation fails on Windows forcursor-agenttoday onmain, and equally for thecursoralias added here. This PR does not fix that and does not worsen it; the batch-shim limitation sits insrc/main/win32-utils.ts, which this PR does not touch. The one visible change is that an alias-only Windows install now surfaces Cursor as available, so the failure is reported at generation time rather than being hidden behind "not detected". Thanks to @iFwu for reproducing this on Orca 1.4.160. A regression test now locks the behaviour for both shims and for the working non-batch (powershell.exe -File ...ps1) launcher shape, so any future fix has to move it deliberately. Two follow-ups are tracked separately: Windows: Source Control AI cannot run argv-prompt agents through .cmd/.bat shims #11374 (a Windows-safe launch strategy for argv prompts) and Windows: command overrides with native absolute paths are corrupted by POSIX backslash tokenization #11375 (tokenizeCustomCommandTemplateconsuming backslashes in native Windows absolute-path overrides).cursor-agentis the usual install. The relay protocol (src/relay/preflight-handler.ts) is untouched.Screenshots
No visual change.
Testing
pnpm lint— ranoxlintdirectly on all changed files rather than the wrapper; clean.pnpm typecheck—tsc --noEmiton all three projects (config/tsconfig.node.json,config/tsconfig.tc.cli.json,config/tsconfig.tc.web.json); clean.pnpm test— not run in full. Ran a targeted subset instead (src/shared,src/main/ipc,src/main/runtime/orca-runtime.test.ts,src/renderer/src/lib,src/renderer/src/store,src/main/text-generation) → 12651 passed, 27 skipped, 0 failed (1057 files).pnpm build— not run.New coverage: alias-only install launches
cursor agent; standalone install still launchescursor-agent; detection preferscursor-agentwhen both exist; remote launches ignore local aliases; explicit command override still wins; commit-message planning spawnscursorwith anagentprefix arg; a typedcursor agentis claimed by the managed Cursor lane (verified failing before the fix withexpected undefined to be 'cursor').AI Review Report
Reviewed for correctness, regressions, cross-OS behavior, SSH/remote assumptions, and command-execution safety.
The main risk checked was whether widening detection without widening launch would leave the agent visibly broken — it does, which is why the alias-only approach was rejected in favour of this one. Also verified that preferring the primary name keeps existing
cursor-agentusers on a byte-identical command, and thatexpectedProcessstays valid underexec -a.Cross-platform compatibility was explicitly checked for macOS, Linux and Windows: shell resolution of
.cmd/.exe/.batshims, PATHEXT independence, argv construction on Windows batch paths, and the WSL/remote boundary. No shortcuts, labels, or path separators are touched by this change.One gap was flagged in review and is now fixed: agent attribution compared a typed command only against the launch form the current PATH resolves to, so
cursor agenttyped into a terminal lost its managed hooks andpreflightTrustpreset. Attribution now accepts every alias launch form — recognition is deliberately broader than launch, since the detected name can flip the moment Cursor's shim self-installscursor-agent.Security Audit
Command execution. The change makes a launch command expand from one token to two, so arg-splitting was the primary concern. Traced the value into every spawn site:
planAgentBinarysplits the default intobinary+prefixArgsandcommit-message-text-generation.tspasses those tospawn(spawnCmd, spawnArgs, …)as an array — never concatenated into a shell string, so no interpolation boundary is introduced. On Windows,getSpawnArgsForWindowssends batch shims throughcmd.exe /d /cas separate argv entries and throwsUnsafeWindowsBatchArgumentsErroron unsafe batch syntax.Terminal launches do build a shell string, but that is the pre-existing shared path —
orca claude-teams,hermes --tuiandcommand-code --trustare already multi-token — socursor agentadds no new class of risk. Both tokens are hardcoded constants; no user input reaches the command head.Attribution widening. The extra match candidates come from
launchCmdByDetectCmdvalues in static config, not from user input, and matching only classifies which agent lane a command belongs to — it never constructs the command that gets spawned. A claimed lane rebuilds its command from config and the detection registry as before.Input handling / IPC. The new
preflight:detectAgentExecutableschannel returns aPartial<Record<TuiAgent, string>>built entirely from a fixed allowlist of config-declared names, not from user input or filesystem strings, so a hostile PATH cannot inject an arbitrary command through it. The renderer swallows failures and falls back to static defaults.Path handling. No new path construction; detection reuses the existing PATH probe. No auth, secrets, or dependency surface is touched.
Follow-up: the
curl | bashbehavior in Notes is Cursor's own shim, not code introduced here, but it is worth documenting since this change can newly reach it.Notes
resolveBareAgentLaunchCommandmatches everylaunchCmdByDetectCmdform rather than only the currently-detected one. Matching just the detected executable would still drop the lane in the common dual-install case: Cursor.app's shim installscursor-agenton first use, after which detection prefers the primary name and a user still typingcursor agentwould fall out of the managed lane again. Recognition has no "pick exactly one" constraint that launching has, andcursor agentis unambiguously Cursor, so accepting both forms is safe.cursor agentcan trigger a network install. Whencursor-agentis absent, Cursor.app's shim runscurl -sS https://cursor.com/install | bashplus a--min-versioncheck on first invocation, so an alias-only launch may block on a download the user didn't request. This is Cursor's own behavior, not something introduced here; it is now called out in a comment next tolaunchCmdByDetectCmdso it isn't a surprise during triage.node_modulesentry CodeRabbit flagged was local worktree noise and has been removed from the branch; nothing is tracked under that path.Fixes #10189