From 7f8b639ae3049f0c74850b0b4f13a365d8dfc4c4 Mon Sep 17 00:00:00 2001 From: Lawrence Chen <54008264+lawrencecchen@users.noreply.github.com> Date: Tue, 17 Feb 2026 18:24:36 -0800 Subject: [PATCH] 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. --- Sources/GhosttyTerminalView.swift | 19 +++++++++++++++++++ TODO.md | 4 ++++ 2 files changed, 23 insertions(+) diff --git a/Sources/GhosttyTerminalView.swift b/Sources/GhosttyTerminalView.swift index b79fb836..e81c4969 100644 --- a/Sources/GhosttyTerminalView.swift +++ b/Sources/GhosttyTerminalView.swift @@ -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 } diff --git a/TODO.md b/TODO.md index fc43c40d..a61e868c 100644 --- a/TODO.md +++ b/TODO.md @@ -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`)