diff --git a/apps/macos/Sources/Clawdis/CanvasWindow.swift b/apps/macos/Sources/Clawdis/CanvasWindow.swift index 16ab0eda8..05630aa5c 100644 --- a/apps/macos/Sources/Clawdis/CanvasWindow.swift +++ b/apps/macos/Sources/Clawdis/CanvasWindow.swift @@ -311,11 +311,32 @@ final class CanvasWindowController: NSWindowController, WKNavigationDelegate, NS return } let scheme = url.scheme?.lowercased() - if scheme == CanvasScheme.scheme || scheme == "https" || scheme == "http" { + + // Keep web content inside the panel when reasonable. + // `about:blank` and friends are common internal navigations for WKWebView; never send them to NSWorkspace. + if scheme == CanvasScheme.scheme + || scheme == "https" + || scheme == "http" + || scheme == "about" + || scheme == "blob" + || scheme == "data" + || scheme == "javascript" + { decisionHandler(.allow) return } - NSWorkspace.shared.open(url) + + // Only open external URLs when there is a registered handler, otherwise macOS will show a confusing + // "There is no application set to open the URL ..." alert (e.g. for about:blank). + if let appURL = NSWorkspace.shared.urlForApplication(toOpen: url) { + NSWorkspace.shared.open( + [url], + withApplicationAt: appURL, + configuration: NSWorkspace.OpenConfiguration(), + completionHandler: nil) + } else { + canvasWindowLogger.debug("no application to open url \(url.absoluteString, privacy: .public)") + } decisionHandler(.cancel) }