2.4 KiB
2.4 KiB
summary, read_when
| summary | read_when | |
|---|---|---|
| How the mac app embeds the gateway WebChat and how to debug it |
|
Web Chat (macOS app)
The macOS menu bar app opens the gateway’s loopback web chat server in a WKWebView. It reuses the primary Clawd session (main by default, configurable via inbound.reply.session.mainKey). The server is started by the Node gateway (default port 18788, see webchat.port).
Launch & debugging
- Manual: Lobster menu → “Open Chat”.
- Auto-open for testing: run
dist/Clawdis.app/Contents/MacOS/Clawdis --webchat(or pass--webchatto the binary launched by launchd). The window opens on startup. - Inspect: right-click the web view → “Inspect Element” (developerExtras enabled). Console logs go to the Swift logger (subsystem
com.steipete.clawdis, categoryWebChat). The HTML boot script also writes status text into the#appdiv until the panel mounts. - WK logs: navigation lifecycle, readyState, js location, and JS errors/unhandled rejections are mirrored to OSLog for easier diagnosis.
How it’s wired
- Assets:
apps/macos/Sources/Clawdis/Resources/WebChat/contains thepi-web-uidist plus a local import map pointing at bundled vendor modules and a tinypi-aistub. Everything is served from the gateway at/webchat/*. - Bridge: none. The web UI calls
/webchat/rpcdirectly; Swift no longer proxies messages. RPC is handled in-process inside the gateway (no CLI spawn/PATH dependency). - Session: always primary; multiple transports (WhatsApp/Telegram/Desktop) share the same session key so context is unified.
Security / surface area
- Loopback server only; remote mode uses SSH port-forwarding from the gateway host to the Mac. CSP is set to
default-src 'self' 'unsafe-inline' data: blob:. - Web Inspector is opt-in via right-click; otherwise WKWebView stays in the app sandbox.
Known limitations
- Text-only, single-turn (no streaming); tools/attachments not yet plumbed.
- Uses a stubbed pi-ai for model metadata; model selection is fixed to the primary Clawd backend.
Updating the bundle
- Ensure
../pi-monois present and built (pnpm install+pnpm buildinsidepackages/web-ui). - Copy vendor deps into
Resources/WebChat/vendor(currently synced from../pi-mono/node_modules). - Rebuild/restart the mac app with
./scripts/restart-mac.shso the new assets land in the bundle.