Open terminal file links in editor
Summary
- route terminal file references through the preferred editor instead of browser routing
- preserve file:line and file:line:column metadata for editor commands
- add regression coverage for relative and absolute terminal file link resolution
Closes #1544
Testing
- Not run locally per repository testing policy.
[!NOTE]
Medium Risk
Touches terminal link classification, async open-url handling, and editor invocation paths where misclassification could open wrong targets or skip in-app routing; scope is large but covered by new tests.
Overview
Terminal file links (including path:line[:column], relative paths, extensionless names like Makefile, and file: URLs with #L… fragments) are resolved against the terminal CWD and opened through the preferred editor, with line/column passed via URL fragments and editor-specific flags (-g / path:line:col for VS Code–family commands). HTTP(S) and odd scheme:port tokens stay on the browser/external path; unverified absolute paths are not opened on remote terminals.
In-app routing gains an explicit CommandClickFileRouteKind, off-main route checks in deferred opens, and a markdown → file-preview fallback when a markdown split cannot be created. Ghostty open_url handling is refactored to resolve off the main thread and apply opens on the main actor, using PreferredEditorSettings (and cmux splits only for fragment-free local files when routing applies).
Shared CmuxShellWords replaces ad-hoc shell splitting for agent resume and editor command parsing.
Reviewed by Cursor Bugbot for commit a80502ddd45b01ced0d5f5668e9217f19640b994. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by cubic
Open terminal file links in the preferred editor with correct line/column jumps, while keeping web URLs in the browser and routing Markdown/supported files in‑app. Resolution runs off‑main with a clear action context, preserves file: fragments, and resolves relative paths against the terminal CWD (closes #1544).
-
New Features
- Prefer local file refs (
path:line[:col],file:) over browser URLs; resolve against terminal CWD; support extensionless files (e.g.,Makefile); emitfile://…#L…. - Open via
PreferredEditorSettings; parse#L…fragments; add--goto/-gforcode/cursor/windsurf; sharedCmuxShellWords; explicitCommandClickFileRouteKindwith markdown→preview fallback.
- Prefer local file refs (
-
Bug Fixes
- More accurate classification: keep
http/httpsandscheme:porttokens (e.g.,config:8080) external; avoid host:port false positives. - Safer opening: preserve
file:line fragments; don't routefile#L…into in‑app preview; resolve off‑main and defer UI on main; preserve source workspace/panel; skip absolute‑path fallbacks for remote terminals; fallback toNSWorkspacewhen editor routing fails.
- More accurate classification: keep
Summary by CodeRabbit
-
New Features
- Smarter editor launches: preserves line/column, adapts invocation flags, and supports shell-aware tokenization.
- Enhanced terminal link handling with richer local-file parsing, cwd support, and host/fragment normalization.
-
Bug Fixes
- More reliable terminal link routing and safer deferred opening with validated fallbacks.
- Improved handling for command-click file routing with proper fallback to existing previews.
-
Tests
- Added unit and integration tests covering editor invocation, shell tokenization, and terminal URL/file resolution.