Skip to content

fix(open): detect VS Code/Cursor via .app bundle, not just PATH#171

Merged
madarco merged 1 commit into
nightlyfrom
fix/vscode-open-detection
Jul 8, 2026
Merged

fix(open): detect VS Code/Cursor via .app bundle, not just PATH#171
madarco merged 1 commit into
nightlyfrom
fix/vscode-open-detection

Conversation

@madarco

@madarco madarco commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Problem

The tray's Open In… menu was hiding VS Code on otherwise-ready Macs (e.g. a clean Mac mini), and the "some boxes show Codex, others don't" confusion.

Root causes, from apps/cli/src/commands/_open-in.ts:

  • VS Code — a real bug. detectOpenTargets() probed PATH only (pathHasBinary('code') || pathHasBinary('cursor')) with no .app-bundle fallback. A freshly dragged-in VS Code / Cursor has no code/cursor shim on PATH until the user runs "Shell Command: Install 'code' command in PATH." Worse, the tray spawns the CLI through /bin/zsh -lc (a login shell that sources ~/.zprofile but not ~/.zshrc), so PATH additions made only in .zshrc are invisible to the probe too. Net effect: a perfectly usable VS Code install is undetectable → the menu item disappears.

  • Codex — by design, not a bug. codex.providers = ['hetzner'], so the Codex row only ever appears for Hetzner boxes (Codex attaches later over its own persistent SSH identity, which only Hetzner has). It also requires the desktop app Codex.app for the codex:// deep link — the codex CLI alone isn't enough. So "shows for some boxes, not others" = a mix of providers, and "not on a clean Mac" = Codex.app not installed. Both are expected; documented here, not changed.

Fix

Add a macOS .app-bundle fallback for the VS Code family, to both detection and launch:

  • detectOpenTargets().vscode.available now also checks Visual Studio Code.app / Cursor.app in /Applications and ~/Applications.
  • New resolveVscodeCli() prefers the PATH shim, then the bundled code/cursor binary (…/Contents/Resources/app/bin/…). agentbox code / agentbox open --in vscode now launch via the real CLI even with no PATH shim — which also avoids the open <scheme>://… protocol-handler path whose %2B URL-encoding can break the Remote attach.
  • macOS-only (Linux still needs the PATH binary — no /Applications there).

Verification

  • apps/cli/test/open-in.test.ts — added cases for bundle detection (macOS-only) and resolveVscodeCli (PATH → bundle → undefined). 21 tests pass.
  • pnpm typecheck + eslint clean.
  • Live: with code/cursor stripped from PATH but Cursor.app present, agentbox open --targets --json now reports vscode.available: true (was false before this change).

No public-doc changes — the detection specifics aren't documented on the site.


Note

Low Risk
Localized CLI open-target detection and IDE spawn paths with seam-injected fs checks; behavior on Linux unchanged and coverage added in unit tests.

Overview
Fixes Open In… and agentbox code treating VS Code/Cursor as missing when only the macOS .app is installed (no code/cursor PATH shim).

Adds resolveVscodeCli: prefer the PATH binary, then the bundled CLI under Visual Studio Code.app / Cursor.app in /Applications and ~/Applications. detectOpenTargets().vscode.available now uses the same idea (PATH or bundle). agentbox code launch paths use the resolved binary so attach goes through --folder-uri instead of the open vscode://… fallback when possible. Bundle fallback is macOS-only; Linux still requires PATH.

Tests cover bundle-based availability and resolveVscodeCli resolution order.

Reviewed by Cursor Bugbot for commit 1aa5983. Configure here.

The tray's Open In... menu hides VS Code on a clean Mac because
detectOpenTargets() probed PATH only for 'code'/'cursor'. A freshly
dragged-in VS Code or Cursor has no PATH shim until the user runs
"Shell Command: Install 'code' command in PATH", and the tray spawns
the CLI via a login shell that doesn't source ~/.zshrc, so PATH-only
detection misses common installs.

Add a macOS .app-bundle fallback (Visual Studio Code.app / Cursor.app in
/Applications or ~/Applications) to both detection and the launch path:
resolveVscodeCli() prefers the PATH shim, then the bundled code/cursor
binary, so 'agentbox code' / 'open --in vscode' launch via the real CLI
(avoiding the open scheme:// %2B-encoding bug) even with no shim.

Codex stays app-only + Hetzner-only by design (needs Codex.app for the
codex:// deep link and a persistent per-box SSH identity).
@vercel

vercel Bot commented Jul 8, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
agentbox-web Skipped Skipped Jul 8, 2026 8:21am

Request Review

@madarco madarco merged commit 6880a87 into nightly Jul 8, 2026
4 checks passed
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.

1 participant