agent-orchestrator icon indicating copy to clipboard operation
agent-orchestrator copied to clipboard

fix(desktop): Open in editor (IDE ↗) finds no editors on Windows — PATH-only detection, no %LOCALAPPDATA%/App Paths fallback

Open OrcInc opened this issue 3 months ago • 1 comments

Bug

On Windows, the "Open in editor" (IDE ↗) topbar control cannot open the session workspace in Cursor, VS Code, or any other editor — even when those editors are installed. The control reports no supported editors found, so the primary button is permanently disabled.

Source: reported in Discord #bug-triage | Reported by: @Vaibhaav-Tiwari | Analyzed against: 9997248c4 (origin/main, 2026-09-01) Confidence: Medium — mechanism traced in code and consistent with the report; the reporter's machine has not been probed (see "Open questions").

Reproduction

  1. Windows 10/11, AO desktop ≥ v0.12.10 (feature landed in d2fec68c2, Aug 23 — shipped in v0.12.10).
  2. Install Cursor and/or VS Code with default installer options (User Installer — the default on Windows — does not add bin to PATH unless "Add to PATH" is checked; the cursor/code shims live under %LOCALAPPDATA%\Programs\...).
  3. Open any local session → look at the topbar IDE ↗ control.
  4. Actual: primary button disabled; dropdown shows no editors; guidance: "No supported editor found. Use File Explorer or Command Prompt, or install Cursor." — despite Cursor/VS Code being installed.
  5. Expected: Cursor / VS Code detected and clickable.

Root Cause

Editor detection on Windows is a PATH-only scan with no fallback probing — while macOS gets an explicit app-bundle fallback and Linux gets hardcoded extra dirs.

frontend/src/main/editor-handoff.ts:

  • commandSearchDirs() (lines 92–96): for win32 it returns only env.PATH split entries. Compare: darwin appends /opt/homebrew/bin etc., linux appends /usr/local/bin, /usr/bin. There is no Windows equivalent.
  • resolveEditor() (lines 112–128): after the PATH scan misses, the .app bundle fallback (lines 122–127) is gated behind if (deps.platform !== "darwin") return undefined; — so on Windows detection ends at "not installed."
  • EDITOR_CANDIDATES (lines 27–47): each candidate has exactly one commands[] entry (cursor, code, windsurf, …). The standard Windows install locations are never probed:
    • VS Code / VS Code Insiders / Cursor / Windsurf user installs: %LOCALAPPDATA%\Programs\{Microsoft VS Code,Cursor,Windsurf}\bin\{code,cursor,windsurf}.cmd (also {version}\bin layout for VS Code)
    • System installs: %ProgramFiles%\...\bin
    • JetBrains Toolbox: %LOCALAPPDATA%\JetBrains\Toolbox\scripts\ (idea.cmd, webstorm.cmd, …)
    • Windows App Paths registry (HKCU\Software\Microsoft\Windows\CurrentVersion\App Paths\code.exe) — the OS-blessed lookup that ShellExecute/start use
  • On Windows the CLIs are .cmd shims, not .exe — executableNames() (lines 86–90) does handle PATHEXT expansion for names within a search dir, so this is not the failure; the failure is that the dirs themselves are PATH-only.
  • Additionally, createEditorHandoff() (lines 163–165) resolves the editor list once at module construction (wired at frontend/src/main.ts:699). If PATH/environment differs at launch (e.g. app auto-started, or user installs an editor later and doesn't restart AO), the list is stale for the entire app lifetime.

Renderer behavior when detection finds nothing — frontend/src/renderer/components/TopbarOpenEditorButton.tsx:

  • Line 88: const mainDisabled = busy || !workspaceAvailable || !preferred; — with editors.length === 0, preferred is undefined → primary button permanently disabled.
  • Lines 96–99: shows editor.noEditorGuidance → "No supported editor found. Use File Explorer or Command Prompt, or install Cursor." — misleading on a machine where Cursor is installed.
  • Note DEFAULT_EDITOR_ID = "cursor" (frontend/src/main/editor-settings.ts:6), so the default preference is also among the "not found" set.

Not the cause (verified): the launch path handles Windows shims correctly — frontend/src/main/launch-command.ts spawnSpec() wraps .cmd/.bat via cmd.exe /d /s /c with windowsVerbatimArguments. The gap is purely detection/resolution, and secondarily the misleading guidance.

This mirrors the class of issue the feature's own spec called out (#3118 acceptance criteria: "Failures are visible (not silent); works when app launched from Dock" — the Windows analog, "works when app launched without the editor's shims on PATH," is unmet).

Fix Direction

  1. Add Windows fallback search roots in commandSearchDirs() / resolveEditor():
    • %LOCALAPPDATA%\Programs\* per-candidate bin dirs (match on {code,cursor,windsurf,...}.cmd), {Version}\bin for VS Code family
    • %ProgramFiles%, %ProgramFiles(x86)% install roots
    • %LOCALAPPDATA%\JetBrains\Toolbox\scripts
    • Optionally App Paths registry lookup via reg query (keeps it dependency-free)
  2. Keep PATH-first ordering so an explicit PATH install wins over a probed one.
  3. Re-resolve editor targets per getState() call (or cache with TTL) instead of freezing at app start, so a mid-session install or environment change is picked up.
  4. If zero editors are detected on win32 after probing, keep the File Explorer/Terminal fallbacks but improve guidance (e.g. "Open {worktree} in File Explorer" is already there; the "install Cursor" line should not be the only hint when the editor may merely be off-PATH).
  5. Add win32 coverage to frontend/src/main/editor-handoff.test.ts (currently zero win32 cases) covering: shim in PATH, shim only in %LOCALAPPDATA%, PATHEXT expansion, and none-found.

Impact

  • All Windows users whose editor CLI shims are not on the GUI process's PATH (default User Installer path for VS Code; common for Cursor when "Add to PATH" was skipped) cannot use the IDE ↗ feature at all — the feature is effectively macOS/Linux-only for them.
  • The error guidance blames a missing install, sending users to reinstall editors that are already present.

Open questions (from the reporter's machine)

  • Exact AO version and whether the dropdown shows some editors or none (distinguishes "PATH miss for all" vs "partial detection").
  • Whether Cursor/VS Code were installed per-user (%LOCALAPPDATA%) or system-wide.
  • Terminal/File Explorer targets (which don't depend on PATH for file-manager, and use ComSpec for terminal) presumably still work — worth confirming the report is editor-specific.

Related

  • #3118 — feature spec: "Open session worktree in external IDE (IDE ↗ + target menu)"
  • #4571 — cloud-session gating for the same control (d2a134db7)
  • #4607 — Neovim target request (same surface)

OrcInc avatar Sep 01 '26 17:09 OrcInc

Assign me this issue pls.

Vansh-Singhal avatar Sep 02 '26 11:09 Vansh-Singhal