From be87cdddebe497656e0109ecbeca8378ee8e6d77 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Mon, 8 Dec 2025 12:17:39 +0100 Subject: [PATCH] webchat: surface bootstrap errors in UI --- apps/macos/Sources/Clawdis/WebChatWindow.swift | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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)") }