Skip to content

fix editor launch fallback when saved editor is unavailable - #681

Closed
baggiiiie wants to merge 1 commit into
pingdotgg:mainfrom
baggiiiie:yc/fix/keybinding
Closed

fix editor launch fallback when saved editor is unavailable#681
baggiiiie wants to merge 1 commit into
pingdotgg:mainfrom
baggiiiie:yc/fix/keybinding

Conversation

@baggiiiie

@baggiiiie baggiiiie commented Mar 9, 2026

Copy link
Copy Markdown

What Changed

  • apps/server/src/open.ts

    • now checks the requested editor against the editors actually available in the current process environment
    • it keeps the requested editor when it is available, otherwise falls back to another supported command editor in the existing editor order, or file-manager when no command editor is available
    • for file-manager: strips :line[:column], so it opens the base file path instead of failing.
  • apps/server/src/open.test.ts

    • adds deterministic environment-based coverage for editor launch resolution.
    • adds focused regression tests for:
      • falling back to file-manager when the requested editor is unavailable for a plain file path
      • stripping line/column suffixes when falling back to file-manager for line- targeted paths

Why

Issue #209:

  • Opening a file could fail when the requested editor command was no longer installed, even if another supported launcher was available in the current environment.

Cause:

  • The server launch path resolved the requested editor id directly and only discovered command availability later, so it never reconciled the request against the editors actually available on PATH.

Fix:

  • Resolve the requested editor against the current environment before building the launch command.
  • Keep the requested editor when it is available, otherwise fall back to another supported command editor, then to the file manager.
  • When the file manager is the only option for a line-targeted path, strip the line and column suffix and open the base file instead.
  • Add focused server tests for the fallback behavior.

before

  • attempting to open cursor when cursor is not installed
before.mp4

after

  • open default file-manager
after.mp4

UI Changes

No UI changes

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Note

Fix editor launch fallback when saved editor is unavailable on PATH

  • resolveEditorLaunch in open.ts now checks PATH at runtime to determine which editors are available, falling back to another command-based editor or the file manager when the requested editor is not found.
  • Adds resolveLaunchEditor to encapsulate editor selection logic, and stripLineColumnSuffix to strip :line:column from paths passed to the file manager on fallback.
  • Returns an OpenError with a clear message when no supported editor command is available at all.
  • New tests in open.test.ts use a withTempDirEnv helper to simulate editor binaries on PATH and cover the fallback and suffix-stripping behavior.
  • Behavioral Change: previously unresolved editors may now silently fall back to the file manager instead of using the saved editor preference.

Macroscope summarized 46dad54.

@coderabbitai

coderabbitai Bot commented Mar 9, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 6252879d-9eea-467c-9182-99f8cf7af2e9

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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 and usage tips.

@github-actions github-actions Bot added the vouch:unvouched PR author is not yet trusted in the VOUCHED list. label Mar 9, 2026
Issue: Opening a file could fail when the requested editor command was no longer installed, even if another supported launcher was available in the current environment.

Cause: The server launch path resolved the requested editor id directly and only discovered command availability later, so it never reconciled the request against the editors actually available on PATH.

Fix: Resolve the requested editor against the current environment before building the launch command. Keep the requested editor when it is available, otherwise fall back to another supported command editor, then to the file manager. When the file manager is the only option for a line-targeted path, strip the line and column suffix and open the base file instead. Add focused server tests for the fallback behavior.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

2 participants