[codex] Fix v2 terminal OSC links#3736
Conversation
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughA new test suite validates Changes
Sequence Diagram(s)sequenceDiagram
participant App as Application
participant Manager as TerminalLinkManager
participant Terminal as xterm Terminal
participant Provider as LinkProvider
App->>Manager: setHandlers(onUrlClick, onHover, onLeave)
Manager->>Manager: Create OSC 8 linkHandler
Manager->>Terminal: Install linkHandler in options
Terminal->>Manager: Handler registered
User->>Terminal: Click OSC 8 hyperlink
Terminal->>Manager: Invoke linkHandler with URL
Manager->>App: Call onUrlClick(URL)
User->>Terminal: Hover over hyperlink
Terminal->>Manager: Invoke linkHandler (hover event)
Manager->>App: Call onHover(URL)
User->>Terminal: Leave hyperlink
Terminal->>Manager: Invoke linkHandler (leave event)
Manager->>App: Call onLeave()
App->>Manager: dispose()
Manager->>Terminal: Clear linkHandler from options
Manager->>Manager: Clean up _oscLinkHandler
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
Greptile SummaryThis PR fixes OSC 8 hyperlinks in the Electron terminal by setting xterm's Confidence Score: 5/5Safe to merge — the change is well-scoped, all edge cases are covered by tests, and the lifecycle management is correct. No P0 or P1 issues found. The OSC handler installation and cleanup logic are correct, the identity-check guard prevents clobbering external handlers, and No files require special attention.
|
| Filename | Overview |
|---|---|
| apps/desktop/src/renderer/lib/terminal/terminal-link-manager.ts | Adds OSC 8 link handler via xterm's linkHandler option, routing activation/hover/leave to existing URL callbacks. Lifecycle is clean: handler is only cleared if it was the one installed by this manager, preventing clobbering external owners. |
| apps/desktop/src/renderer/lib/terminal/terminal-link-manager.test.ts | New test file covering three scenarios: OSC 8 callback routing, handler cleanup on dispose, and non-clobbering of externally-installed handlers. Coverage is focused and correct. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[OSC 8 hyperlink in terminal] -->|xterm intercepts| B{options.linkHandler set?}
B -->|No - old behavior| C[xterm default confirm + window.open blocked in Electron]
B -->|Yes - new behavior| D[TerminalLinkManager oscLinkHandler]
D -->|activate| E[onUrlClick callback]
D -->|hover| F[onLinkHover kind url]
D -->|leave| G[onLinkLeave callback]
H[Plain or wrapped URL in terminal] -->|xterm link provider| I[UrlLinkProvider]
I -->|activate| E
I -->|hover| F
I -->|leave| G
J[dispose or re-register] --> K{linkHandler === oscLinkHandler?}
K -->|Yes own handler| L[Set to null]
K -->|No external handler| M[Leave untouched]
Reviews (1): Last reviewed commit: "fix v2 terminal osc links" | Re-trigger Greptile
🧹 Preview Cleanup CompleteThe following preview resources have been cleaned up:
Thank you for your contribution! 🎉 |
PR1〜PR5 (#435 #436 #437 #438 #440) で 13 commits 全件 cherry-pick + 手動 conflict 解消で取り込み済み。 本コミットは git 履歴上 behind=0 とするための ours マージ記録。 取り込み済み 13 commits: - 1f55c62 Fix host service restart adoption (superset-sh#3732) - 0fe65d2 test(desktop): remove host-service-coordinator test (superset-sh#3734) - 3012b5a Add optimistic Electric collection updates (superset-sh#3722) - c272a51 fix(desktop): drop branch row from v2 sidebar workspace item (superset-sh#3733) - c2f3fdc feat(desktop): add fade-edge mask utilities (superset-sh#3735) - 682d07c fix v2 terminal osc links (superset-sh#3736) - 7c0d22b feat(ports): surface remote host-service ports in the sidebar (superset-sh#3676) - 6a3be2d [codex] Stabilize v2 terminal resize (superset-sh#3739) - 8928ac6 [codex] Improve v2 pane header responsiveness (superset-sh#3737) - 5fe3d22 refactor(desktop): tidy v2 terminal session dropdown (superset-sh#3743) - 66c23d6 Fix automation timezone scheduling (superset-sh#3738) - 16e270c [codex] Add terminal session titles (superset-sh#3740) - 583fa5d fix(desktop): refit v2 terminal after font settle (superset-sh#3742)
Summary
Fixes OSC 8 hyperlinks in the desktop terminal by wiring xterm's built-in
linkHandlerinto Superset's existing URL link action path.Root Cause
xterm 6 always registers its own
OscLinkProviderbefore custom providers. Whenoptions.linkHandleris unset, OSC 8 links fall back to xterm's defaultconfirm(...)+window.open()behavior. In Electron this shows the warning dialog, but allowing it does not open the link reliably and bypasses Superset's terminal link preferences.What Changed
linkHandlerinTerminalLinkManagerthat delegates activation and hover events to the same URL callbacks.TerminalLinkManager, so another owner is not clobbered if it replacesterminal.options.linkHandler.Design Notes
I checked the vendored/upstream behavior again:
xterm.options.linkHandlerand routing to its terminal URL opener.xterm.options.linkHandlerfor OSC links and uses web-link detection separately for printed URLs.This PR follows that split: use our detector for printed URLs, use xterm's handler hook for OSC 8 links.
Validation
bun test apps/desktop/src/renderer/lib/terminal/terminal-link-manager.test.ts apps/desktop/src/renderer/lib/terminal/links/link-detector-adapter.test.ts apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/link-providers/url-link-provider.test.tsbunx biome check apps/desktop/src/renderer/lib/terminal/terminal-link-manager.ts apps/desktop/src/renderer/lib/terminal/terminal-link-manager.test.tsbun run --cwd apps/desktop typecheckSummary by cubic
Fixes OSC 8 hyperlinks in the desktop terminal by handling them via
@xterm/xterm’slinkHandlerand routing to our URL opener. Links now open reliably in Electron and respect modifier keys and internal/external link preferences.terminal.options.linkHandlerfor OSC 8 and keep existing detector for printed URLs.TerminalLinkManageron dispose to avoid clobbering others.Written for commit 7609a7d. Summary will update on new commits.
Summary by CodeRabbit
Bug Fixes
Tests