Repository navigation
fix(terminal): activate fresh OSC links on first click - #11453
Conversation
|
Warning Review limit reached
Next review available in: 23 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
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 |
| linkifier._activeLine = -1 | ||
| } | ||
| } | ||
| linkifier._handleMouseMove(event) |
There was a problem hiding this comment.
Mousedown event passed to
_handleMouseMove may silently no-op in future xterm builds
_handleMouseMove is designed for mousemove events. If a future xterm build guards on event.type === 'mousemove' (or an equivalent internal check), the function would return early without setting _currentLink, and the try/catch would not surface it — priming would silently stop working. The existing catch block handles thrown errors, but a silent early-return from a type guard would degrade the feature invisibly. A test assertion like expect(linkifier._currentLink).toBeDefined() after calling the handler in the E2E suite would catch this regression.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Greptile SummaryThis PR fixes OSC 8 links not activating on first modifier-click when no
Confidence Score: 4/5Safe to merge. The change is renderer-local, introduces no new IPC surfaces, and degrades gracefully if xterm internals are unavailable. The core mechanism — calling xterm's private Files Needing Attention: terminal-linkifier-click-priming.ts is worth revisiting whenever xterm is upgraded, since it relies on internal fields that carry no public stability guarantee.
|
| Filename | Overview |
|---|---|
| src/renderer/src/components/terminal-pane/terminal-linkifier-click-priming.ts | New module; well-guarded access to xterm internals with try/catch. Minor fragility: _handleMouseMove is called with a mousedown event object, which may behave differently than a mousemove in future xterm builds if type-checks are added internally. |
| src/renderer/src/components/terminal-pane/terminal-url-link-hit-testing.ts | Adds isTerminalLinkifierHoverActive short-circuit in PTY suppression callback, correctly broadening suppression to cover primed OSC links. Gated by isTerminalHttpLinkActivation upstream so plain clicks are unaffected. |
| src/renderer/src/components/terminal-pane/use-terminal-pane-lifecycle.ts | Wires new linkifierClickPrimingDisposablesRef into the pane lifecycle, following the exact same install/cleanup pattern as adjacent disposables. Disposal is symmetric on per-pane close and full lifecycle teardown. |
| src/renderer/src/components/terminal-pane/terminal-linkifier-click-priming.test.ts | Comprehensive tests covering priming, hover-state preservation, non-Mac Ctrl path, missing internals (safe degradation), and dispose. Correctly verifies capture listener ordering via options.capture === true check. |
| src/renderer/src/components/terminal-pane/terminal-url-link-click.test.ts | New test verifies PTY suppression fires when _currentLink is set by priming. Uses existing mouseEventForRow fixture (metaKey+shiftKey) which correctly satisfies isTerminalHttpLinkActivation. |
Sequence Diagram
sequenceDiagram
participant User
participant DOM as DOM (capture phase)
participant Priming as LinkifierClickPriming
participant PtySup as PtyMouseSuppression
participant Linkifier as xterm Linkifier
participant XtermCore as xterm (bubble phase)
User->>DOM: modifier+mousedown
DOM->>Priming: handleMouseDown (capture, registered 1st)
Priming->>Priming: isTerminalLinkActivation?
alt fresh link (_currentLink absent)
Priming->>Linkifier: clear _lastBufferCell, _activeLine
Priming->>Linkifier: _handleMouseMove(event)
Linkifier->>Linkifier: resolve OSC 8 at position → set _currentLink
else established hover (_currentLink present)
Priming->>Linkifier: _handleMouseMove(event) [no state clear]
end
DOM->>PtySup: handleMouseDown (capture, registered 2nd)
PtySup->>Linkifier: isTerminalLinkifierHoverActive?
Linkifier-->>PtySup: true (_currentLink set)
PtySup->>XtermCore: "mouseEventsRequireAlt = true"
DOM->>XtermCore: mousedown (bubble phase)
XtermCore->>Linkifier: read _currentLink snapshot
Linkifier-->>XtermCore: link URL
XtermCore->>User: open link (in-app or system browser)
Reviews (1): Last reviewed commit: "fix(terminal): activate fresh OSC links ..." | Re-trigger Greptile
Summary
Fresh OSC 8 links printed under a stationary pointer now activate on the first modifier-click:
xterm snapshots its current link on
mousedown, but normally resolves a newly painted link only aftermousemove. A guarded capture-phase listener now primes the linkifier before xterm takes that snapshot. If xterm internals change or are unavailable, the behavior safely falls back to normal hover activation.Screenshots
Fresh Claude Code OSC 8 links before interaction:
The first trusted Cmd-click, without a preceding mousemove, opened exactly one in-app
#11323tab:The first trusted Cmd+Shift-click resolved
#11326and followed system-browser routing:Electron/Playwright reproduction used trusted mouse events. Before this change, a fresh Meta-click with no mousemove did not open the link. After this change, the first Meta-click opened one in-app tab, and the first Meta+Shift-click took the system-browser route while preserving PTY mouse handling. The run reported zero console errors.
Testing
pnpm lintpnpm typecheckpnpm testpnpm buildAlso passed:
pnpm run build:electron-viteAI Review Report
AI review found no remaining correctness or maintainability issues. It checked capture-listener ordering, PTY suppression, listener disposal on pane close and lifecycle unmount, established hover state, and safe degradation if xterm internals change.
The cross-platform audit verified Meta on macOS and Ctrl on Linux/Windows, retained macOS Ctrl-click context-menu behavior, preserved Shift routing, and found no path, shell, or Electron platform differences introduced by this renderer-local change. SSH and folder workspaces are unaffected.
Security Audit
No new IPC, authentication, secret handling, command execution, path handling, dependency, or external input surface was introduced. The new internal access is guarded by shape checks and a fail-safe catch; failure returns to normal hover behavior. No follow-up security work is needed.
Notes
The visual evidence was uploaded through GitHub user attachments and is not part of the repository diff.