Repository navigation
fix(terminal): Cmd/Ctrl+click opens the clicked path on a paired server when more paths follow - #32411
Conversation
…hs follow Cmd/Ctrl+click on a terminal file path opened the hard-wrap guess that joins it to the rows below (`a.txt/b.txt/...`) whenever that guess had no cached existence answer. Paired hosts rejected the guess's probe with ENOTDIR instead of answering "missing", so it was never cached, the open failed silently, and the fallback had already swallowed xterm's own activation. - The click fallback now probes ambiguous candidates in one batch and opens the longest one that exists; a later click supersedes a slow probe. - A click that opens nothing now says why (not found vs. could not check). - Host existence probes treat ENOTDIR as missing. Co-authored-by: fernando_jacob <f.jacob1996@gmail.com>
Co-authored-by: fernando_jacob <f.jacob1996@gmail.com>
…r file open Co-authored-by: fernando_jacob <f.jacob1996@gmail.com>
…ng unanswerable guesses Co-authored-by: fernando_jacob <f.jacob1996@gmail.com>
…oizing it Co-authored-by: fernando_jacob <f.jacob1996@gmail.com>
…unprompted Co-authored-by: fernando_jacob <f.jacob1996@gmail.com>
…to the clicked pairing Co-authored-by: fernando_jacob <f.jacob1996@gmail.com>
…IR by its errno text Co-authored-by: fernando_jacob <f.jacob1996@gmail.com>
Co-authored-by: fernando_jacob <f.jacob1996@gmail.com>
📝 Walkthrough
Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: 🔵 Low · up to
|
…missing path Co-authored-by: fernando_jacob <f.jacob1996@gmail.com>
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
888ab056-84f7-4397-8449-4528a3d70b86
📒 Files selected for processing: 2
src/renderer/src/components/terminal-pane/terminal-file-link-hit-testing.tssrc/renderer/src/components/terminal-pane/terminal-link-paired-click-fallback.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
| // Why the visible path last: a click on a path already known missing still says so. | ||
| // An OSC 8 hyperlink there is xterm's to open. | ||
| const knownMissing = | ||
| shown && !shown.hasOscLink && /[\\/]/.test(shown.pathText) ? shown : undefined |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Preserve OSC 8 handling when a joined guess is present.
If an OSC 8 label is cached as missing, hasOscLink blocks only knownMissing. A longer unchecked candidate can still enter toProbe and make this function return true. With a following .map line, the click can open a guessed file instead of reaching xterm’s hyperlink handler. Give the cached-missing OSC 8 label priority over unchecked guesses.
ELI5
In a workspace on a paired Orca server, Cmd+click on a file path in the terminal did nothing if more file paths were printed on the lines below it. Orca guessed that the lines might be one long path that had wrapped, tried to open that guess, failed, and said nothing. Now it checks its guesses with the server first and opens the path you actually clicked. If a click can't open anything, a toast says why.
What Changed
Before: a terminal in a paired-server workspace prints three paths on consecutive lines. Cmd+click (Ctrl+click on Windows and Linux) on the first path does nothing, with no toast. Plain click, then Open file, works.
After: Cmd/Ctrl+click opens the clicked file. When a click can't open anything, a toast says either "File not found" or "Couldn't check ... : reason". It never claims a file is missing when the server just couldn't answer.
Mechanism
terminal-file-link-hit-testing.ts: the direct-click fallback runs on mouseup, before xterm's own link handler.…/a.txt/…/b.txt).ENOTDIRerror. The renderer's missing-path check (isMissingRuntimePathError) now reads that error as "missing". So the hover probe and the click both cache the guess as absent, and later clicks don't ask again. Transient errors are not cached.reserveDetectedFilePathOpenTurninterminal-file-open-routing.ts. Its result is dropped if a newer click or file open starts meanwhile, or if the workspace's host or pairing changes while the check runs.onOpenFailure. It goes toshowFileLinkOpenFailureToast(newsrc/renderer/src/lib/file-link-open-failure-toast.ts), which native chat now also uses. Bare dotted words such asconsole.logdon't toast unless they were verified as files.ENOENTas "missing", soENOTDIR(a path under a file, likea.txt/b.txt) came back as an error. This covers the runtimefiles.pathsExistfallback infile-path-existence.ts, andfs:pathsExist/fs:pathExists.ENOTDIRnow counts as missing, throughisPathAbsentError, which reuses the sharedisDefinitiveAbsenceallowlist.The modifier check is unchanged:
isTerminalLinkDirectActivationuses metaKey on Mac and ctrlKey elsewhere.Why
The renderer change is the fix that matters. It works against hosts of any version, because an unanswerable guess no longer blocks the real path. The host change only makes newer hosts answer cleanly, and it adds no new wire fields or opcodes.
Alternatives considered:
Contributor PR #23221 (@MatrixA)
#23221 found the same click-fallback cause and proposed batch-probing ambiguous candidates and dropping stale probes. This PR builds on that idea and its test scenario, rebased onto current
main, which has #31713, #30399, #27364 and #32056 since. Commits carryCo-authored-by: fernando_jacob.Compared with #23221, this PR adds:
foo.tsvsfoo.ts.map)#23221 also changed spaced-path detection in
terminal-links.ts. That is a separate behaviour (paths typed after a prompt), so it is left out here to keep this fix small.Design check
There were several review rounds, so I compared this with how other terminals resolve clicked paths. The common approach is the same: check that a candidate exists on the machine that printed it before treating it as a file link, and never open an unchecked guess. The design did not change. One per-pane memo, added mid-review, was replaced by classifying ENOTDIR at the single missing-path check.
Linked Issue
Fixes #32128
Thanks to @mmarabel for the report, which included the full root-cause trace.
Visual Proof
N/A: no layout change. The behaviour (the click opens the file, or a toast appears) is covered by the tests below.
Testing
New
terminal-link-paired-click-fallback.test.ts, for a paired workspace with three consecutive paths. Each test fails onmainor without the matching part of the fix:Names the visible path in the toast, not a joined guess.
Opens a wrapped share path whole, even when its prefix is a known file.
Drops the click when the server is re-paired, or the workspace moves to another host, while candidates are checked.
Still reports when every candidate is already known missing, and leaves an OSC 8 hyperlink to xterm.
runtime-path-existence-error-parity.test.ts: ENOTDIR text is missing; a file merely namedenotdir…is not.filesystem-path-containment-remote-enoent.test.ts: ENOTDIR is absent, EACCES is not.src/renderer/src/components/terminal-pane,native-chatand the related main IPC/runtime suites pass. Three real-watcher/registry timing tests fail locally onmaintoo.pnpm tcand the static-analysis job steps pass locally. The orcad smoke needs a built mobile-web bundle, and the Node 18 smoke needs a Node 18 binary; CI covers both.Not run: a live paired-server session or the Docker managed-orcad lane. The change doesn't touch PTY routing, ownership or SSH transport.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Review
Agent skill upstream boundary
Notes
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)