webchat: surface bootstrap errors in UI

main
Peter Steinberger 2025-12-08 12:17:39 +01:00
parent dc22661744
commit be87cdddeb
1 changed files with 10 additions and 1 deletions

View File

@ -124,7 +124,9 @@ final class WebChatWindowController: NSWindowController, WKScriptMessageHandler,
self.loadPage(baseURL: endpoint.appendingPathComponent("webchat/")) self.loadPage(baseURL: endpoint.appendingPathComponent("webchat/"))
} }
} catch { } 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 = """
<html><body style='font-family:-apple-system;padding:24px;color:#c00'>Web chat failed to connect.<br><br>\(text)</body></html>
"""
self.webView.loadHTMLString(html, baseURL: nil)
}
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) { func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
webChatLogger.debug("didFinish navigation url=\(webView.url?.absoluteString ?? "nil", privacy: .public)") webChatLogger.debug("didFinish navigation url=\(webView.url?.absoluteString ?? "nil", privacy: .public)")
} }