Skip to content

fix(terminal): Cmd/Ctrl+click opens the clicked path on a paired server when more paths follow - #32411

Merged
nwparker merged 10 commits into
mainfrom
nwparker/fix-32128-paired-file-link
Oct 23, 2026
Merged

nwparker merged 10 commits into
mainfrom
nwparker/fix-32128-paired-file-link

Conversation

@nwparker

@nwparker nwparker commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​477 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​475
Prod 9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​185 $\color{#cf222e}{\Huge{\mathbf{−}}}$​52 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​133

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

  1. terminal-file-link-hit-testing.ts: the direct-click fallback runs on mouseup, before xterm's own link handler.
    • Before: it opened the first candidate that had no cached existence answer. That is usually the hard-wrap guess that joins the clicked row to the rows below (…/a.txt/…/b.txt).
    • Now: it gathers candidates from every joined line and takes the longest one already known to exist. It checks every unchecked longer candidate in one batched existence request, then opens the longest one that exists. If none exists, it opens the plain clicked path, so the open itself reports the real reason.
    • Single unambiguous clicks still open with no extra round trip.
    • An older server answers a joined guess with an ENOTDIR error. 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.
    • An ambiguous click immediately supersedes any open still in flight, through the new reserveDetectedFilePathOpenTurn in terminal-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.
    • Network-share paths outside the workspace are still never checked without a prompt. Their hard-wrapped form opens whole, as before, and the host resolves it.
    • A click on a path that is already known to be missing now shows "File not found" instead of doing nothing. The exception is when the text is an OSC 8 hyperlink: xterm still opens that link.
  2. Failure toasts: the click fallback and the underlined-link activation now pass onOpenFailure. It goes to showFileLinkOpenFailureToast (new src/renderer/src/lib/file-link-open-failure-toast.ts), which native chat now also uses. Bare dotted words such as console.log don't toast unless they were verified as files.
  3. Host: existence probes treated only ENOENT as "missing", so ENOTDIR (a path under a file, like a.txt/b.txt) came back as an error. This covers the runtime files.pathsExist fallback in file-path-existence.ts, and fs:pathsExist/fs:pathExists. ENOTDIR now counts as missing, through isPathAbsentError, which reuses the shared isDefinitiveAbsence allowlist.

The modifier check is unchanged: isTerminalLinkDirectActivation uses 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:

  • Prefer single-row candidates: breaks genuinely hard-wrapped long paths.
  • Fix only the host: leaves every older host broken.
  • Wait for the hover probe: a click often lands before the probe has answered.

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 carry Co-authored-by: fernando_jacob.

Compared with #23221, this PR adds:

  • the host ENOTDIR fix
  • failure toasts instead of silent no-ops
  • opening the clicked path, rather than nothing, when every probe fails
  • checking longer wrapped names before a cached prefix (foo.ts vs foo.ts.map)
  • cancellation against every other file-open entry point

#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 on main or without the matching part of the fix:

    • Opens the clicked path when an older host answers ENOTDIR for the joined guess.
    • Reports "missing" only when the host says missing, and "unverifiable" when it can't answer.
    • Stays quiet for bare dotted words.
    • Checks a longer wrapped name before a cached prefix.
    • Drops a stale probe when any other open starts.
    • Supersedes an in-flight open at click time.
    • Caches an older host's ENOTDIR answer as missing, so a second click does not re-ask.
  • 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 named enotdir… is not.

  • filesystem-path-containment-remote-enoent.test.ts: ENOTDIR is absent, EACCES is not.

  • src/renderer/src/components/terminal-pane, native-chat and the related main IPC/runtime suites pass. Three real-watcher/registry timing tests fail locally on main too.

  • pnpm tc and 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

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Security: no new host reads. The click probes the same candidates the hover provider already probes.
  • Cross-platform: modifier handling is unchanged.
  • SSH / WSL / folder workspaces: they use the same existence batch and cache keys, keyed per connection or runtime.
  • Mixed versions: no wire change; works against older hosts.
  • Mobile: the mobile terminal has its own link path and is unaffected.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

nwparker and others added 9 commits October 23, 2026 02:01
…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>
@coderabbitai

coderabbitai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Walkthrough

The change recognizes definitive filesystem absence errors, including ENOTDIR, in path-existence checks. Terminal file-link hit testing now considers and probes multiple candidate paths, and discards results when a later open or host change makes them stale. Terminal link handlers report eligible open failures through a shared toast helper. New tests cover error classification and terminal path-link behavior.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: 🔵 Low · up to e8fa1

An OSC 8 hyperlink beside another path line can respond to a click incorrectly. This is a bounded issue to fix or explicitly accept before merging.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 26.09% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 23 functions across 12 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly identifies the primary fix: Cmd/Ctrl+click now opens the clicked terminal path on a paired server when additional paths follow.
Description check Passed The description is complete and matches the template. It explains the user impact, implementation, rationale, linked issue, testing, visual proof, compatibility considerations, and known test limitati…
Linked Issues check Passed Issue #32128 requires Cmd/Ctrl+click to open the clicked file when later paths appear on consecutive terminal lines in a paired-server workspace. terminal-file-link-hit-testing.ts now collects candi…
Out of Scope Changes check Passed The changes remain connected to issue #32128. ENOTDIR handling fixes the host response that caused the reported failure. Failure toasts expose errors that the original fallback reported silently. Op…
Full details: Description check

Explanation

The description is complete and matches the template. It explains the user impact, implementation, rationale, linked issue, testing, visual proof, compatibility considerations, and known test limitations.

Full details: Linked Issues check

Explanation

Issue #32128 requires Cmd/Ctrl+click to open the clicked file when later paths appear on consecutive terminal lines in a paired-server workspace. terminal-file-link-hit-testing.ts now collects candidates across joined lines, probes unchecked candidates, selects the longest existing candidate, and opens the clicked path when no candidate exists. file-path-existence.ts now treats ENOTDIR as absence, which covers older-host responses. The added paired-click test suite covers the reported case, failure reporting, stale probes, and host or pairing changes.

Full details: Out of Scope Changes check

Explanation

The changes remain connected to issue #32128. ENOTDIR handling fixes the host response that caused the reported failure. Failure toasts expose errors that the original fallback reported silently. Open-turn reservation prevents a delayed probe from overriding a newer file open. Native chat reuses the shared failure-toast behavior. The added tests validate these paths and no unrelated wire or protocol change is shown.

✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

…missing path

Co-authored-by: fernando_jacob <f.jacob1996@gmail.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
📥 Commits

Reviewing files that changed from the base of the PR and between dd3442f and e8fa153.

📒 Files selected for processing: 2
  • src/renderer/src/components/terminal-pane/terminal-file-link-hit-testing.ts
  • src/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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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.

@nwparker
nwparker merged commit fce37d3 into main Oct 23, 2026
51 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.

[Bug]: Cmd+click on a terminal file path does nothing in a paired-server workspace when more paths follow it

1 participant