eleven / messenger Public

ios: open message links in the default browser on macOS (#92)

chat.js renders message links and link-preview cards as target="_blank"
anchors. WebKit routes those through WKUIDelegate.createWebViewWith
rather than a normal navigation, and the macOS Coordinator never
implemented that hook — so clicking a link silently did nothing.
Co-authored-by: Claude <noreply@anthropic.com>
James Adam 98831d132497bf299202687cd2c2ca7e539a63cd parent 94bfafc
1 file changed, +14 −0
  • ios/LChatMac/ChatFeedWebView.swift +14 −0
diff --git a/ios/LChatMac/ChatFeedWebView.swift b/ios/LChatMac/ChatFeedWebView.swift
index 1f91d97..1a30819 100644
--- a/ios/LChatMac/ChatFeedWebView.swift
+++ b/ios/LChatMac/ChatFeedWebView.swift
@@ -277,6 +277,20 @@ struct ChatFeedWebView: NSViewRepresentable {
if response == .OK { self?.focusComposer() }
}
}
+
+ // Message links and link-preview cards render as target="_blank" anchors
+ // (chat.js), which WebKit routes here as a new-window request rather than a
+ // normal navigation. With no WKUIDelegate handling it, the click did nothing.
+ // Hand it to the OS default browser instead of ever creating a child webview.
+ func webView(_ webView: WKWebView,
+ createWebViewWith configuration: WKWebViewConfiguration,
+ for navigationAction: WKNavigationAction,
+ windowFeatures: WKWindowFeatures) -> WKWebView? {
+ if let url = navigationAction.request.url {
+ NSWorkspace.shared.open(url)
+ }
+ return nil
+ }
}
}