Repository navigation
fix(terminal): link paths typed after a prompt cwd and probe glued hard-wrap guesses before opening - #23221
fix(terminal): link paths typed after a prompt cwd and probe glued hard-wrap guesses before opening#23221MatrixA wants to merge 4 commits into
Conversation
…rd-wrap guesses before opening Two independent defects made Cmd/Ctrl+Click on terminal file paths flaky: - The broad spaced-path scan ran to line end, so a prompt whose cwd is a path (root@host:/mnt/x# echo /root/y) or a multi-argument command (cp /a/b /c/d) collapsed every later path into one nonexistent candidate that also masked the real LOCAL_PATH_REGEX matches. Split the broad match at whitespace followed by an explicit path start. - The direct-click fallback opened the first unprobed candidate. The hard-wrap joiner can glue an output row to the next prompt row and yield a bogus path that sorts first; when the hover probe had not yet answered (SSH RTT) the click opened the guess, failed silently, and stopped xterm's own activation. With several unprobed candidates, batch-probe them and open the longest that exists. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Spaced-path split —
splitSpacedPathRangeAtNextPathStartsplits a detected broad range at each whitespace followed by an explicit path start (/,~/,./,../,X:/) before the existing filters run, so a prompt cwd orcp /a/b /c/dno longer masks the real paths on the line.trimTrailingWhitespaceis renamed/moved totrimTerminalFileLinkRangeEndwith identical behavior. - Probe-before-open fallback —
openFilePathLinkAtBufferPositionnow aggregates candidates across all logical lines, prefers cached/known-worktree-root matches, still opens a lone unprobed candidate immediately, and for 2+ unprobed candidates batch-probes existence throughcreateTerminalPathExistenceBatch(same remote path as hover), writes the shared cache, and opens the longest existing one; the rejection arm opens nothing rather than guessing. - Tests — new cases for the prompt-cwd typed path,
cp /a/b /c/d, and the two-row glued-path probe. I verified these fail without their respective code paths (the prompt test with the splitter disabled, the glued-path test with the probe branch removed), so they really pin the fix.
The range-index arithmetic in the splitter is consistent with detectTerminalFileLinkRanges (lineText.slice(startIndex, endIndex) === text), the module-level g regex is safe under matchAll, and the targeted suites (93 tests) plus check:code-quality:changed are clean.
ℹ️ Two side effects worth carrying forward
The splitter surfaces a partial drive-letter match inside a longer token: root@ubuntu:/mnt/x now yields a separate u:/mnt/x candidate beside the real path. Pre-PR that line was one merged bogus link starting at u:/, so the root cause is the pre-existing [A-Za-z]:[\\/] drive alternative rather than this change; existence probing filters it from hover, and the click fallback's single-candidate blind open is unchanged. Separately, extractTerminalFileLinks also feeds comment-markdown-native-chat-file-links.ts, which has no tests; a spaced folder followed by another explicit path now splits (/repo/My Folder /repo/Other → /repo/My, /repo/Other) where pre-PR it was one merged bogus span. Neither is a regression from previously-correct behavior, but they are the blast radius I'd keep an eye on if link extraction ever grows another consumer.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
|
Important Review skippedWe couldn't safely recover the incremental review. No full review was started, and the last reviewed checkpoint was preserved. Retry later, or explicitly request a full review by commenting You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to
|
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Description check | The description covers the user impact, mechanism, rationale, testing, platform considerations, and checklist. However, the required Linked Issue field is incomplete and contains only “Fixes #”. | Add the complete linked issue number or URL. Also reconcile the checklist claim that lint, typecheck, test, and build pass with the specific commands and results reported in the Testing section. | |
| Docstring Coverage | 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 8 functions across 5 files. | Write docstrings for the functions missing them to satisfy the coverage threshold. |
✅ Passed checks (3 passed)
-
Check name Status Explanation Title check ✅ Passed The title clearly summarizes both primary fixes: terminal paths typed after prompts and glued hard-wrap candidates during click handling. 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.
Comment @coderabbitai help to get the list of available commands.
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 1f397509-84aa-4bae-8d09-492576b8206c
📒 Files selected for processing (5)
src/renderer/src/components/terminal-pane/terminal-file-link-hit-testing.tssrc/renderer/src/components/terminal-pane/terminal-link-click-fallback.test.tssrc/renderer/src/lib/terminal-file-link-detection-ranges.tssrc/renderer/src/lib/terminal-links.test.tssrc/renderer/src/lib/terminal-links.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
… superseded probes
Review follow-ups: Promise.allSettled so a single runtime {error} row does
not discard a candidate that resolved, and a gesture revision so a slow
probe from an earlier click cannot open its file after a later click.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: c98dd907-e0c2-45aa-b755-1041c5ef20db
📒 Files selected for processing (2)
src/renderer/src/components/terminal-pane/terminal-file-link-hit-testing.tssrc/renderer/src/components/terminal-pane/terminal-link-click-fallback.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
There was a problem hiding this comment.
ℹ️ No critical issues — minor suggestions inline.
Reviewed changes
Reviewed the delta since pullfrog's prior review (commit cc18a1e, on top of 332c6e7):
Promise.allSettledfor the candidate probe — a runtime{ error }row for one candidate no longer discards a sibling that resolved; a whole-batch connection failure still opens nothing rather than a guessed path.- Superseded-probe guard — a module-level
latestProbedClickGesturecounter drops an earlier click's pending probe once a later click starts its own probe. - Test coverage — a new case pins that only one file opens when a slow probe is superseded; the targeted suite passes (19 tests).
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
The gesture revision only advanced in the multi-candidate branch, so a later click that opened synchronously (cached hit, worktree root, lone candidate) left an earlier probe free to open a second file. Bump at function entry. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Reviewed the delta since pullfrog's prior review (commit cc18a1e, on top of 332c6e7):
- Gesture bump moved to function entry —
const gesture = ++latestProbedClickGesturenow runs before every early return, so any later click (cached hit, known worktree root, a lone uncached candidate, or the probe branch) invalidates an earlier click's pending probe. This resolves the stale-probe gap flagged in the prior review: at most one file opens per user action. - Test extended — the superseded-probe case now issues a second click on a lone candidate that opens synchronously and asserts only
package.jsonis opened. Without the fix the first probe'ssettings.jsonwould also open, so the assertion genuinely pins the change.
The function is only called from the modifier-mouseup fallback (terminal-link-handlers.ts:291), so bumping the counter on every call cannot be triggered by hover traffic. The module-level counter being global across panes is intentional per the author's reply — a click is one user gesture regardless of pane.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
|
Related follow-up before candidate selection/probing: #14291 (comment). We reproduced CJK-directory, CJK-filename and parenthesized-filename paths failing across TUI hard wraps on Orca 1.4.218/macOS. With no Codex process, real xterm-buffer replay through the unmodified Orca detector still fails for hard wraps, while the same existing target succeeds on one row or with xterm soft wrapping. ASCII hard-wrap controls pass. Here the complete target never enters the candidate set because the ASCII-only |
Use main's shared file-link target resolution and host-aware existence checks for ambiguous clicks, preserving remote terminal grants and the stale-click guard. Add coverage for a host-granted path alongside a failed candidate probe. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
Merged the latest The resolution uses main’s shared path resolution and host-aware existence checks while preserving this PR’s candidate probing and stale-click protection. Added a regression test for a host-granted remote file alongside a failed candidate probe. Path regression tests, renderer typecheck, and changed-code quality checks pass. The broader terminal suite had two failures in the snapshot test file during parallel execution; all tests in that file passed when rerun in isolation. |
|
Thank you @MatrixA! You traced the click fallback to the same cause we did: the hard-wrap guess was opened before anything confirmed it existed. Your idea of checking the ambiguous candidates in one batch, and dropping a slow check once the user clicks again, is the core of #32411, which fixes #32128, and we kept your stale-click test case. On top of that, #32411 makes the server answer ENOTDIR as "missing", shows a toast when a click can't open anything, and checks the full wrapped name before a shorter prefix. Your commits are credited with a Co-authored-by trailer. We left out the spaced-path splitting in |

ELI5
Cmd/Ctrl+Click on a file path in the terminal sometimes did nothing. Two separate reasons: paths you typed after a prompt that itself shows a directory (like
root@host:/mnt/x# echo /root/y) were never recognised as links, and paths in output occasionally opened nothing on the first click but worked on the next identical line. Both are now fixed.What Changed
Before
root@ubuntu:/mnt/data/project# echo /root/.claude/settings.json— the typed/root/.claude/settings.jsonis not clickable. Same forcp /a/b /c/d(neither path is clickable)./root/.claude/settings.jsonsometimes does nothing on Cmd+Click, especially over SSH. Running the same command again makes the new output line work.After
Both the typed path and the output path open on Cmd/Ctrl+Click, first time.
Mechanism
src/renderer/src/lib/terminal-links.ts— the spaced-path scanner (which exists so/Users/A/My Folder/file.tsis one link) is deliberately broad and runs to the end of the line. When the line already contains a path earlier (the prompt's cwd, or the first argument ofcp), it swallowed everything after it into one nonexistent "path", and that range then masked the real/root/.claude/settings.jsonmatch. The broad match is now split at whitespace followed by an explicit path start (/,~/,./,../,X:/) before the existing filters run.Foo Bar/fileis not an explicit start, so spaced folder names are unaffected. The splitter lives interminal-file-link-detection-ranges.tsalongside the other range helpers.src/renderer/src/components/terminal-pane/terminal-file-link-hit-testing.ts— the direct-click fallback (runs on mouseup before xterm's own activation) picked the first candidate that had not yet been probed for existence. The hard-wrap joiner can glue an output row to the prompt on the next row (/root/.claude/settings.json+root@ubuntu:/mnt/...→ bogus/root/.claude/settings.jsonroot@ubuntu), and that multi-row candidate sorts first. If the hover probe had not answered yet (one SSH round-trip), the click opened the bogus guess, failed silently, and itsstopPropagationalso suppressed xterm's correct link. On the second identical line the bogus path was already cached as missing, which is why it "worked the second time". Now, when there are several unprobed candidates at the click position, they are batch-probed through the samecreateTerminalPathExistenceBatchthe hover provider uses (SSH goes throughruntimePathsExist), results are written to the shared cache, and the longest existing path opens. A single unprobed candidate still opens immediately as before.Why
Both are root-cause fixes in the shared detection/selection code rather than special-casing shell prompts. Alternatives considered: teaching the hard-wrap joiner to recognise prompts (heuristic, would still break for other row shapes), or preferring single-row candidates in the fallback (breaks genuinely hard-wrapped long paths in TUIs). Probing instead of guessing costs one batched request only in the ambiguous case.
Linked Issue
Fixes #
Visual Proof
N/A — no visual change; the affected interaction is "Cmd+Click opens the file vs. does nothing", covered by the unit tests below.
Testing
vitest:terminal-links.test.ts,terminal-links-redos.test.ts,terminal-link-click-fallback.test.ts,terminal-link-provider-link-detection.test.tspass; fullsrc/renderer/src/components/terminal-pane+src/renderer/src/lib/terminal*suites pass (4832 tests).pnpm tc:web,pnpm run check:code-quality:changed,oxfmt --checkclean.Reproduced the reported case as unit tests: prompt-line detection,
cp /a/b /c/d, and the two-row glued-path fallback (probe called, only the real path opened, bogus path cached as missing).Platforms: logic is platform-independent (macOS Cmd / Linux+Windows Ctrl handled by existing
isTerminalLinkDirectActivation); SSH path goes through the existing remote existence batch. Not manually run in the packaged app.I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Implemented with Claude (Fable 5) via Conductor; reviewed by the author.
Review
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)🤖 Generated with Claude Code