Skip to content

feat(terminal): open a bare file name on Cmd+click (Ctrl+click off a Mac) (#1168) - #2348

Merged
devswha merged 5 commits into
mainfrom
feat/terminal-open-bare-filename
Oct 30, 2026
Merged

devswha merged 5 commits into
mainfrom
feat/terminal-open-bare-filename

Conversation

@devswha

@devswha devswha commented Oct 29, 2026 •

Copy link
Copy Markdown
Owner

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):

  • While Cmd is held (Ctrl off a Mac), a bare name under the pointer is underlined and gets the pointer cursor. A Cmd+click (Ctrl+click) opens it in the file viewer.
  • The name is looked up the way the chat's bare names already are: the existing GET /api/fs/stat lookup 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.
  • Without the key, a bare name stays plain text: a plain click or a tap still lands on the terminal (and on a program that reads the mouse), as before. ls and git status print bare names everywhere, so a plain click must not open the viewer.
  • A path with a folder in it still opens on a plain click.
  • Dotted code names (process.env, Math.random) stay text: the chat's CODE_NAME list is reused (isCodeName is now exported from src/lib/filePaths.ts).
  • On a phone, the viewer's list of choices now wraps long paths. Before, .btn's white-space: nowrap cut 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 current useTerminalMount.ts. Thank you for the report and the design.

Closes #1168

How it works

bareNameLinks (src/lib/terminalFileLinks.ts) tracks the key through window keydown/keyup/mousemove listeners (capture phase, with no preventDefault) and resets on window blur. xterm 5.5's Linkifier replaces a hovered link's decorations with 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 own hover. 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 onMouseDown check 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:
    • A bare name opens only on Cmd+click on a Mac and Ctrl+click elsewhere. It is drawn only while the key is held. A folder path still opens on a plain click. Code names and versions stay text.
    • An xterm stand-in reads, swaps and re-reads decorations as Linkifier does. It re-hovers the same link with the key changed while the pointer was away, in both directions. This test failed on the first version of the fix.
  • scripts/terminal-file-links-regression.ts (browser, isolated test session):
    • With the key held the pointer appears, and it goes when the key is released.
    • Ctrl+click on README.md opens it.
    • access.ts lists server/access.ts and shared/access.ts, and a choice opens one.
    • A plain click and a 390px tap open nothing.
  • bun run check fast green 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.

  • Both found the same HIGH on the first head. When the pointer left a bare name and came back on the same row after the key changed, the name kept its old drawing. A plain click on it was then not forwarded to a mouse-reading program, or a Cmd/Ctrl+click was forwarded. Fixed in the second commit with a test that fails on the old code.
  • Both approved the fix with no CRITICAL, HIGH or MEDIUM findings.

Known limits (LOW, not fixed)

  • With the key held, dotted names that are not files but have a letter-only "extension" (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.
  • Off a Mac, holding Ctrl for a shortcut (Ctrl+C) briefly underlines a bare name under the pointer. This is only visual: shortcuts are untouched.
  • In a program that reads the mouse, a Cmd/Ctrl+click on a bare name opens the file, and the program does not get that click (vim with mouse=a uses 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).
  • The unit test's xterm stand-in mirrors xterm 5.5's Linkifier. xterm 6.0.0, which open PR feat(terminal): upgrade xterm.js to 6.0.0 for synchronized output (#1617) #2335 moves to, has the same _handleNewLink/_linkHover code, 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.

devswha and others added 3 commits October 29, 2026 15:44
…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.
@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 3da46d3 and 350a95c.

Files selected for processing: 7
  • changelog.d/terminal-bare-file-name-links.md
  • scripts/terminal-file-links-regression.ts
  • src/components/FileViewer.css
  • src/lib/filePaths.ts
  • src/lib/terminalFileLinks.test.ts
  • src/lib/terminalFileLinks.ts
  • src/lib/useTerminalMount.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

📝 Summary

Summary by CodeRabbit

  • New Features
    • Cmd-click on macOS or Ctrl-click elsewhere to open bare filenames shown in the terminal. Matching files are searched for under the pane’s folder; when multiple matches are found, choose which one to open.
    • Plain clicks and taps continue to interact with the terminal. Bare filenames are indicated as links only while the modifier key is held.
  • Improvements
    • Long file paths in the file-selection list can wrap on narrow screens.

Terminal bare filenames can now open in the file viewer with Cmd+click on macOS or Ctrl+click elsewhere. Plain clicks and taps remain non-activating. The change also tracks modifier state, supports selection when multiple files match, and adds unit and regression coverage.

Changes: Terminal bare filename links

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: Low

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: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning 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. Documenta… 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 and concisely describes the primary change: opening bare terminal file names with the platform-specific modifier key.
Linked Issues check Passed Objectives from #1168, mapped to the reviewed head:

1. Bare names open only with Cmd+click (Ctrl+click off Mac); plain click and tap do nothing. terminalFileLinks (src/lib/terminalFileLinks.ts) cre…
Out of Scope Changes check Passed 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 #…
Description check Passed 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 tes…
Full details: Linked Issues check

Explanation

Objectives from #1168, mapped to the reviewed head:

  1. 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 with keyed set. Its activate returns early unless keyed.pressed(event) is true. pressed reads metaKey on Mac and ctrlKey elsewhere. In useTerminalMount.ts, the tap path passes bareLinks only when bareLinks.pressed(event) holds, so a plain tap finds no bare-name link.
  2. Underline and pointer cursor only while the key is held. bareNameLinks sets decorations.underline and decorations.pointerCursor from held. update runs on window keydown, keyup and mousemove (capture). reset runs 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.
  3. Folder paths keep the plain-click behavior. folder ? undefined : bare leaves paths with a / unkeyed.
  4. Code names stay text. !folder &amp;&amp; isCodeName(path) skips them. isCodeName is exported from src/lib/filePaths.ts.
  5. Cmd/Ctrl+click opens the file viewer through the existing openFileRef path. Multiple matches appear as a choice list (regression script: access.ts lists server/access.ts and shared/access.ts). The lookup (GET /api/fs/stat, then locateFile) 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.
  6. A Cmd/Ctrl+click on a drawn link sets the pointer cursor, so the existing onMouseDown link check keeps it from reaching mouse-reading programs.

Tests: src/lib/terminalFileLinks.test.ts covers 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.

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: normal to the file-choice buttons. These choices are the multi-match list that #1168 requires 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.

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.

❤️ Share

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.
@devswha

devswha commented Oct 29, 2026

Copy link
Copy Markdown
Owner Author

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 src/lib/useTerminalMount.ts ("herdr's attach stream turns mouse reporting on…") and in scripts/mirror-fold-demo-regression.ts. So term.modes.mouseTrackingMode is never "none" in an attached pane, and this option would switch the feature off in every attached pane. The alternate screen is no signal either, because the attach stream always lives in it.

So this follows option 2, the rule web and folder links already follow, and pins it with a regression test (03d45ec):

  • In a program that reads the mouse, a plain click on a web or folder link already opens the link and sends the program no button (terminal-arrows-clicks-regression.ts, "a click on a link sends the program no button").
  • A bare name takes even less. A plain click on it is the program's, as on any text. Only the deliberate Cmd+click (Ctrl+click off a Mac), the key that draws the name as a link, opens it and sends no button.
  • The new case in scripts/terminal-arrows-clicks-regression.ts (mouse-reporting pane, attached) checks both:
    • a plain click on notes.md reaches the program as a press and release, and opens nothing;
    • Cmd/Ctrl+click opens the viewer and sends the program no button.
  • It fails when a bare name becomes a plain-click link: "timed out: a bare name is no link without the key".

The remaining cost is the one in the report: in vim with mouse=a, a Ctrl+click on a word that looks like a file name opens it instead of jumping to the tag. Ctrl+click anywhere else in vim still reaches it. The PR body lists this as a known limit, the same trade a web link already makes for a plain click.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Deploying ovis with  Cloudflare Pages  Cloudflare Pages

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

View logs

@devswha

devswha commented Oct 30, 2026

Copy link
Copy Markdown
Owner Author

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.

@devswha
devswha merged commit 64396ed into main Oct 30, 2026
13 checks passed
@devswha
devswha deleted the feat/terminal-open-bare-filename branch October 30, 2026 01:01
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.

Terminal: open a bare file name with Cmd+click (Ctrl+click), as VS Code's terminal does

1 participant