Repository navigation
feat(terminal): open a bare file name on Cmd+click (Ctrl+click off a Mac) (#1168) - #2348
Conversation
…Mac) (#1168) A bare file name in a terminal pane (`design.md`, no folder) is a link only while Cmd (Ctrl off a Mac) is held, as in VS Code's terminal: underlined with the pointer cursor while the key is down, opened in the file viewer by a click with the key. The server's existing lookup answers it (the pane's folder, then a bounded walk under it; several files of that name come back as choices). A plain click or a tap on one still lands on the terminal, a path with a folder still opens on a plain click, and dotted code names (process.env, Math.random) stay text. Based on the reporter's fork branch (bricks-8/herdr-web-ui feat/bare-file-name-links). Co-authored-by: jaemoo lee <[email protected]>
…overed again on its row (#1168) xterm reads a link hovered again on the same row from the decorations it swapped in on the first hover, which still hold how the link was drawn when the pointer left: a bare name left under the key and come back to without it kept its pointer cursor, so a plain click was not handed to a program that reads the mouse (and the other way round). The hover now writes the key's state. The unit test's stand-in for xterm reads and writes decorations as xterm 5.5 does.
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
| Layer / File(s) | Summary |
|---|---|
Bare filename recognition and activation src/lib/filePaths.ts, src/lib/terminalFileLinks.ts, src/lib/terminalFileLinks.test.ts |
The link provider now supports modifier-gated bare filenames and excludes names classified as code. Tests cover activation, decorations, hover changes, and folder-path links. |
Modifier tracking and interaction checks src/lib/useTerminalMount.ts, scripts/terminal-file-links-regression.ts, src/components/FileViewer.css, changelog.d/terminal-bare-file-name-links.md |
Terminal mount tracks Cmd or Ctrl state and resets it on blur. Regression checks cover taps, modifier-clicks, and multiple matches. File-choice paths can wrap, and the changelog describes the behavior. |
Priority:
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Feature · Severity of issue fixed: Low
Suggested reviewers: beomq
Merge Risk: 
Minimal · previous review 350a9
-
Bare filenames gain modifier-click support. No merge-blocking issue is established.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed-
Full details: Linked Issues check
-
Explanation
Objectives from
#1168, mapped to the reviewed head:- Bare names open only with Cmd+click (Ctrl+click off Mac); plain click and tap do nothing.
terminalFileLinks(src/lib/terminalFileLinks.ts) creates a bare-name link withkeyedset. Itsactivatereturns early unlesskeyed.pressed(event)is true.pressedreadsmetaKeyon Mac andctrlKeyelsewhere. In useTerminalMount.ts, the tap path passesbareLinksonly whenbareLinks.pressed(event)holds, so a plain tap finds no bare-name link. - Underline and pointer cursor only while the key is held.
bareNameLinkssetsdecorations.underlineanddecorations.pointerCursorfromheld.updateruns on window keydown, keyup and mousemove (capture).resetruns on window blur. The xterm decoration object (decorations(),hover,leave) redraws only the hovered bare name. The unit test covers re-hover with the key changed. - Folder paths keep the plain-click behavior.
folder ? undefined : bareleaves paths with a/unkeyed. - Code names stay text.
!folder && isCodeName(path)skips them.isCodeNameis exported from src/lib/filePaths.ts. - Cmd/Ctrl+click opens the file viewer through the existing
openFileRefpath. Multiple matches appear as a choice list (regression script:access.tslistsserver/access.tsandshared/access.ts). The lookup (GET /api/fs/stat, thenlocateFile) is existing viewer behavior. The open handler itself is not in the changed files, so this rests on the existing viewer plus the reported browser regression. Both the diff and the regression summary support it. - A Cmd/Ctrl+click on a drawn link sets the pointer cursor, so the existing
onMouseDownlink check keeps it from reaching mouse-reading programs.
Tests:
src/lib/terminalFileLinks.test.tscovers key-gated activation, decoration updates across key changes and re-hover, folder paths, code names and versions. The browser regression covers cursor,README.md, multi-match choice and plain click/390px tap. The PR reports both as passing.No unmet coding requirement found. Known LOW limits (dotted non-file names drawn while the key is held; Ctrl+C visual underline off Mac) are stated by the author and do not contradict
#1168. - Bare names open only with Cmd+click (Ctrl+click off Mac); plain click and tap do nothing.
Full details: Out of Scope Changes check
-
Explanation
Changed files at the reviewed head, compared with the merge base:
- src/lib/terminalFileLinks.ts and src/lib/useTerminalMount.ts: implement the bare-name link, key tracking and tap/click gating for
#1168. - src/lib/filePaths.ts: exports the existing
isCodeName, which the issue asks to reuse for code names. - src/lib/terminalFileLinks.test.ts: unit tests for the new behavior.
- scripts/terminal-file-links-regression.ts: browser regression for the new behavior.
- src/components/FileViewer.css: adds
white-space: normalto the file-choice buttons. These choices are the multi-match list that#1168requires for bare names. The change lets long paths wrap on a phone, so the folder part that separates the choices stays visible. This supports the feature and is justified in the PR description. - changelog.d/terminal-bare-file-name-links.md: changelog entry for the feature.
No change is unrelated to
#1168. The PR makes no server, HTTP or WebSocket contract change, which matches the issue's client-side scope. - src/lib/terminalFileLinks.ts and src/lib/useTerminalMount.ts: implement the bare-name link, key tracking and tap/click gating for
Full details: Description check
-
Explanation
The description follows the repository template. It has a Change section that explains the problem, the resulting behavior, and the linked issue (
#1168). It also has a Validation section with unit tests, a browser regression script, and a full check run (bun run check fast, 8593 unit tests passing). It includes extra sections on implementation, review, known limits, and screenshots, which go beyond the template but add useful context. The Validation section names the checks and results, and no HTTP or WS contract test is needed because the change is client-only, which the description states. No required section is missing.
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 2 functions across 5 files. (2 skipped: 2 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches: 💡 1
-
📝 Generate docstrings: 💡
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- 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.
Comment @coderabbitai help to get the list of available commands.
…that reads the mouse (#1168) herdr's attach reports the mouse for every pane, a shell's too, so nothing tells a program that wants Cmd/Ctrl+click (vim's tag jump) from one that does not. A bare name follows the rule a web or folder link already follows, for its own click only: a plain click on it is the program's, as on any text, and Cmd+click (Ctrl+click off a Mac) opens it and sends the program no button. The case fails when a bare name becomes a plain-click link.
|
Re the merge pass's MEDIUM (a Cmd/Ctrl+click on a bare file name in a program that reads the mouse, such as vim, tmux or htop, opens the file and the program never gets that click): Option 1 (no bare-name links while the program has mouse reporting on) cannot tell vim from a shell. herdr's attach turns mouse reporting on for every pane, a plain shell's too. It says so in So this follows option 2, the rule web and folder links already follow, and pins it with a regression test (03d45ec):
The remaining cost is the one in the report: in vim with |
Deploying ovis with
|
| Latest commit: |
287c5e4
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://3686ad5e.ovis.pages.dev |
| Branch Preview URL: | https://feat-terminal-open-bare-file.ovis.pages.dev |
|
Merging 287c5e4 (closes #1168; the maintainer delegated the per-PR look check and judges the final build on main before the release). A bare file name in the terminal opens on Cmd+click (Ctrl+click off a Mac), resolved against the pane's folder through the existing file-open route; a plain click still reaches the program. Review by the merge pass: tests, typecheck, build and desktop/mobile browser regressions pass. Known limit (accepted, same as URL links today): Cmd/Ctrl+click on a bare name opens the file and sends no button to a program that reads the mouse, so Ctrl+click inside such an app (vim, tmux) over a file name opens it instead; gating on mouse reporting is not possible because herdr's attach turns mouse reporting on for every pane. A regression in terminal-arrows-clicks-regression.ts pins that a plain click is never taken. LOW: the decoration test stand-in mirrors xterm internals; keep real-browser coverage when xterm changes. |
Change
A bare file name in a terminal pane (
11_two-version-design.md, no folder in it) can now be opened from the terminal, the way VS Code's integrated terminal does it (the design follows VS Code; iTerm2 also opens a name on Cmd+click):GET /api/fs/statlookup in the pane's folder, then a bounded walk under it (locateFile, at most 10 matches). If several files have that name, the viewer lists them to choose from. It never picks one on its own.lsandgit statusprint bare names everywhere, so a plain click must not open the viewer.process.env,Math.random) stay text: the chat'sCODE_NAMElist is reused (isCodeNameis now exported fromsrc/lib/filePaths.ts)..btn'swhite-space: nowrapcut both ends of each path, including the folder that tells the choices apart.The change is client-only: no server, HTTP or WS contract change, and nothing in the remote bundle moves.
Based on @bricks-8's fork branch (
feat/bare-file-name-links), rebuilt on the currentuseTerminalMount.ts. Thank you for the report and the design.Closes #1168
How it works
bareNameLinks(src/lib/terminalFileLinks.ts) tracks the key through windowkeydown/keyup/mousemovelisteners (capture phase, with nopreventDefault) and resets on windowblur. xterm 5.5's Linkifier replaces a hovered link'sdecorationswith its own object, whose setters redraw the link hovered at that moment. So only the hovered bare name's decorations are written, and only from its ownhover. That keeps a folder link the pointer moved on to drawn. It also covers a bare name hovered again on the same row, which xterm reads back from that object.A Cmd/Ctrl+click on a drawn link sets the pointer cursor, so the existing
onMouseDowncheck keeps it from being forwarded to a program that reads the mouse. The phone and narrow-screen fold tap path treats bare names as links only when the key is pressed.Tests
src/lib/terminalFileLinks.test.ts, which failed before the change:scripts/terminal-file-links-regression.ts(browser, isolated test session):README.mdopens it.access.tslistsserver/access.tsandshared/access.ts, and a choice opens one.bun run check fastgreen on the branch merged with main after 0.4.20 (xterm 6.0.0): unit 8593 pass, 0 fail; the browser regression above passes on that tree too.Review
Two reviewers, omo-native-code-reviewer and Codex Sol 6.1 Fast xhigh, reviewed the change adversarially.
Known limits (LOW, not fixed)
github.com,node.js) are drawn as links too. A click on one ends in "No readable file at this path". The chat's code-span reading has the same limit.mouse=auses Ctrl+click to jump to a tag). herdr's attach reports the mouse for every pane, so nothing tells such a program from a shell. This is the rule web and folder links already follow for a plain click; a bare name takes only the key-click. A plain click on a bare name, and a Ctrl+click anywhere else, still reach the program (scripts/terminal-arrows-clicks-regression.ts)._handleNewLink/_linkHovercode, so the fix and the stand-in still match. The two PRs share no files. Re-check the stand-in on later xterm upgrades.Screenshots
These were taken on the isolated test session, Codex theme, at 1280 and 390 in dark and light, and sent to the maintainer through Dori.