Skip to content

fix(server): discover editors on the hydrated PATH - #12501

Open
Christos-Ioannou wants to merge 1 commit into
pingdotgg:mainfrom
Christos-Ioannou:fix/editor-discovery-hydrated-path
Open

Christos-Ioannou wants to merge 1 commit into
pingdotgg:mainfrom
Christos-Ioannou:fix/editor-discovery-hydrated-path

Conversation

@Christos-Ioannou

@Christos-Ioannou Christos-Ioannou commented Sep 18, 2026 •

Copy link
Copy Markdown

What Changed

externalLauncher now reads its env (PATH/PATHEXT and the browser-launch vars) from HostProcessEnvironment instead of Effect Config. Tests provide the env through HostProcessEnvironment accordingly, plus one regression test.

Two files, server only: apps/server/src/process/externalLauncher.ts and its test.

Why

On macOS, when the desktop app is launched from the Dock/Finder, the Open in picker only offers Finder. Cursor, VS Code, Antigravity, IntelliJ etc. are all missing even though their CLIs are installed.

Root cause:

  1. A Dock/Finder launch gives the server the bare launchd PATH: /usr/bin:/bin:/usr/sbin:/sbin.
  2. fixPath() correctly hydrates process.env.PATH from the login shell (provider child processes do get the full PATH).
  3. Editor discovery did not read process.env though - it read Config.String("PATH"). The default ConfigProvider is fromEnv(), which copies { ...process.env } the first time it is used. That happens while ServerConfig resolves, which is before fixPath() runs in makeServerLayer. So discovery kept seeing the pre-hydration PATH forever.
  4. On that PATH only open (in /usr/bin) resolves, so file-manager is the single available editor.

The snapshot behaviour is easy to confirm in isolation:

process.env.PROBE = "before";
const first = yield* Config.String("PROBE");   // "before"
process.env.PROBE = "after";
const second = yield* Config.String("PROBE");  // still "before"

Launching the same build from a terminal ("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/Applications/T3 Code (Alpha).app/Contents/MacOS/T3 Code (Alpha)") makes every editor show up, because the inherited PATH is already complete and the stale snapshot happens to be right. That is also why this is easy to miss in dev.

HostProcessEnvironment is the object fixPath() mutates, so reading it at call time is the smallest change that makes discovery and hydration agree. Empty values are still treated as absent, matching the previous Config behaviour.

The new test fails on main and passes here. It asserts an exact editor list on purpose: on main the lookup falls through to the ambient process PATH and reports whatever editors the host machine has installed.

Verified locally: vp test run src/process/externalLauncher.test.ts (25 passed, 1 skipped), tsc --noEmit clean for the touched files, vp fmt and vp lint clean.

Not in this PR, to keep it focused: apps/server/src/provider/providerMaintenance.ts has the same Config.String("PATH") reader and is likely affected the same way. Happy to follow up if wanted.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes (no UI code changed; before = picker shows only Finder, after = Cursor / VS Code / Antigravity / IntelliJ IDEA / Finder)
  • I included a video for animation/interaction changes (n/a)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved editor and command discovery when environment variables, including PATH, become available after application startup.
    • Browser launches and command lookups now more reliably use the current host environment.
    • Empty or unavailable environment variables are handled more consistently.

Editor discovery read PATH through Effect Config. The default
ConfigProvider copies process.env the first time it is used, which
happens while ServerConfig resolves - before fixPath() hydrates PATH
from the login shell. Discovery therefore kept looking at the bare
launchd PATH (/usr/bin:/bin:/usr/sbin:/sbin) of a Dock/Finder launch,
where only `open` resolves, so the Open-in picker offered Finder and
nothing else. Launching the app from a terminal hid the bug because the
inherited PATH was already complete.

Read the launcher's env from HostProcessEnvironment instead, which is
the object fixPath() mutates.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Sep 18, 2026
@macroscopeapp

macroscopeapp Bot commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 5948f68

Macroscope's review found this PR approvable — This is a small, focused server bug fix that makes existing editor discovery use the hydrated PATH without changing APIs, schemas, deployment, or product defaults. The accompanying regression test covers the startup-versus-hydration timing issue.

You can add or adjust custom eligibility rules. Learn more.

@coderabbitai

coderabbitai Bot commented Sep 18, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 1ffc6c0d-d144-4275-a11d-f1734b9740d1

📥 Commits

Reviewing files that changed from the base of the PR and between 93e0416 and 5948f68.

📒 Files selected for processing (2)
  • apps/server/src/process/externalLauncher.test.ts
  • apps/server/src/process/externalLauncher.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The external launcher now reads environment variables through HostProcessEnvironment instead of Config. Tests provide environment values through the service and verify editor discovery after PATH changes after layer construction.

Changes

External launcher environment

Layer / File(s) Summary
Host environment reads
apps/server/src/process/externalLauncher.ts
Browser and command lookup environment variables now come from HostProcessEnvironment. Empty values are omitted, and command lookup checks PATH, Path, path, and PATHEXT.
Environment test coverage
apps/server/src/process/externalLauncher.test.ts
Tests provide HostProcessEnvironment directly. A new test verifies editor discovery after PATH is hydrated after layer construction. Existing cache and interrupted-discovery tests use the new environment service.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: juliusmarminge

Merge Risk: ⚪ Minimal · up to 5948f

The launcher now observes the hydrated host PATH, preserving editor discovery for desktop launches. No actionable current-head risk remains.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the primary fix: editor discovery now uses the hydrated PATH on the server.
Description check ✅ Passed The description explains what changed, why the change is required, the affected files, testing performed, and checklist status. It is focused and substantially matches the repository template. The UI …
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

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

sheehanmunim added a commit to munimtechnologies/mtcode that referenced this pull request Sep 19, 2026
From pingdotgg#12501 by @Christos-Ioannou. Environment reads go
through HostProcessEnvironment (hydrated by fixPath) for the fork's macOS
bundle lookup and pingdotgg#12439's install-root lookup too.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant