diff --git a/apps/macos/Sources/Clawdis/WebChatWindow.swift b/apps/macos/Sources/Clawdis/WebChatWindow.swift index b9dbadad9..2347184cd 100644 --- a/apps/macos/Sources/Clawdis/WebChatWindow.swift +++ b/apps/macos/Sources/Clawdis/WebChatWindow.swift @@ -80,11 +80,16 @@ final class WebChatWindowController: NSWindowController, WKScriptMessageHandler let importMap = [ "imports": [ "@mariozechner/pi-web-ui": "file://\(distPath)/index.js", + "@mariozechner/pi-web-ui/": "file://\(distPath)/", "@mariozechner/pi-ai": "file://\(piAi)", + "@mariozechner/pi-ai/": "file://\(vendor.appendingPathComponent("pi-ai/").path(percentEncoded: false))", "@mariozechner/mini-lit": "file://\(miniLit)", + "@mariozechner/mini-lit/": "file://\(vendor.appendingPathComponent("mini-lit/").path(percentEncoded: false))", "lit": "file://\(lit)", + "lit/": "file://\(vendor.appendingPathComponent("lit/").path(percentEncoded: false))", "lucide": "file://\(lucide)", "pdfjs-dist": "file://\(pdfjs)", + "pdfjs-dist/": "file://\(vendor.appendingPathComponent("pdfjs-dist/").path(percentEncoded: false))", "pdfjs-dist/build/pdf.worker.min.mjs": "file://\(pdfWorker)", ], ] @@ -114,73 +119,92 @@ final class WebChatWindowController: NSWindowController, WKScriptMessageHandler
@@ -191,8 +215,15 @@ final class WebChatWindowController: NSWindowController, WKScriptMessageHandler func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) { guard let body = message.body as? [String: Any], let id = body["id"] as? String, - let type = body["type"] as? String, - type == "chat", + let type = body["type"] as? String + else { return } + + if id == "log", let log = body["log"] as? String { + NSLog("WebChat JS: %@", log) + return + } + + guard type == "chat", let payload = body["payload"] as? [String: Any], let text = payload["text"] as? String else { return } diff --git a/docs/webchat.md b/docs/webchat.md index ae3ee2754..3a4bf17d1 100644 --- a/docs/webchat.md +++ b/docs/webchat.md @@ -23,5 +23,5 @@ The macOS Clawdis app ships a built-in web chat window that reuses your primary ## Usage -- Launch the macOS Clawdis menu bar app, click the lobster icon → “Open Web Chat”. +- Launch the macOS Clawdis menu bar app, click the lobster icon → “Open Chat”. - Type and send; replies continue the primary Clawd session.