diff --git a/apps/macos/Sources/Clawdis/WebChatWindow.swift b/apps/macos/Sources/Clawdis/WebChatWindow.swift index 076223353..770635207 100644 --- a/apps/macos/Sources/Clawdis/WebChatWindow.swift +++ b/apps/macos/Sources/Clawdis/WebChatWindow.swift @@ -124,7 +124,9 @@ final class WebChatWindowController: NSWindowController, WKScriptMessageHandler, self.loadPage(baseURL: endpoint.appendingPathComponent("webchat/")) } } catch { - webChatLogger.error("webchat bootstrap failed: \(error.localizedDescription, privacy: .public)") + let message = error.localizedDescription + webChatLogger.error("webchat bootstrap failed: \(message, privacy: .public)") + await MainActor.run { self.showError(message) } } } @@ -153,6 +155,13 @@ final class WebChatWindowController: NSWindowController, WKScriptMessageHandler, } } + private func showError(_ text: String) { + let html = """ + Web chat failed to connect.

\(text) + """ + self.webView.loadHTMLString(html, baseURL: nil) + } + func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) { webChatLogger.debug("didFinish navigation url=\(webView.url?.absoluteString ?? "nil", privacy: .public)") }