Open cmd+clicked terminal links in cmux browser panel (#53)

* Open cmd+clicked terminal links in cmux browser panel instead of system browser

Handle GHOSTTY_ACTION_OPEN_URL in the Ghostty action callback to intercept
link opens. Uses preferredBrowserTargetPane to reuse an existing right-side
pane, falling back to a new horizontal split.

* Use tab-specific manager for OPEN_URL action

Use tabManagerFor(tabId:) instead of the active-window tabManager so the
lookup succeeds when the surface belongs to a different window context.
This commit is contained in:
Lawrence Chen 2026-02-17 18:24:36 -08:00 committed by GitHub
parent 14ce05db5f
commit 7f8b639ae3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 23 additions and 0 deletions

View file

@ -888,6 +888,25 @@ class GhosttyApp {
surfaceView.updateKeyTable(action.action.key_table)
return true
}
case GHOSTTY_ACTION_OPEN_URL:
let openUrl = action.action.open_url
guard let cstr = openUrl.url else { return false }
let urlString = String(cString: cstr)
guard let url = URL(string: urlString) else { return false }
guard let tabId = surfaceView.tabId,
let surfaceId = surfaceView.terminalSurface?.id else { return false }
return performOnMain {
guard let app = AppDelegate.shared,
let tabManager = app.tabManagerFor(tabId: tabId) ?? app.tabManager,
let workspace = tabManager.tabs.first(where: { $0.id == tabId }) else {
return false
}
if let targetPane = workspace.preferredBrowserTargetPane(fromPanelId: surfaceId) {
return workspace.newBrowserSurface(inPane: targetPane, url: url, focus: true) != nil
} else {
return workspace.newBrowserSplit(from: surfaceId, orientation: .horizontal, url: url) != nil
}
}
default:
return false
}

View file

@ -47,6 +47,10 @@
- [ ] Add question mark icon to learn shortcuts
- [ ] Notification popover: each button item should show outline outside when focused/hovered
- [ ] Notification popover: add right-click context menu to mark as read/unread
- [ ] Cmd+click should open links in cmux (browser panel) instead of external browser
- [ ] "Waiting for input" notification should include custom terminal title if set
- [ ] Close button for current/active tab should always be visible (not just on hover)
- [ ] Add browser icon to the left of the plus button in the tab bar
## Analytics
- [x] Add PostHog tracking (set `PostHogAnalytics.apiKey` in `Sources/PostHogAnalytics.swift`)