2025-12-09 17:51:05 +00:00
---
2025-12-09 23:16:57 +01:00
summary: "Loopback WebChat static host and Gateway WS usage for chat UI"
2025-12-09 17:51:05 +00:00
read_when:
- Debugging or configuring WebChat access
---
2025-12-17 23:05:28 +01:00
# WebChat (SwiftUI + Gateway WS)
2025-12-08 12:50:37 +01:00
2025-12-17 23:05:28 +01:00
Updated: 2025-12-17
2025-12-08 12:50:37 +01:00
2025-12-09 14:41:55 +01:00
## What it is
2025-12-17 23:05:28 +01:00
- A native SwiftUI chat UI (macOS app / iOS) that talks directly to the Gateway WebSocket.
- No embedded browser/WKWebView and no bundled static WebChat HTTP server.
- Data plane is entirely Gateway WS: methods `chat.history` , `chat.send` , `chat.abort` ; events `chat` , `agent` , `presence` , `tick` , `health` .
2025-12-09 14:41:55 +01:00
## How it connects
2025-12-17 23:05:28 +01:00
- The UI performs Gateway WS `connect` , then calls `chat.history` for bootstrap and `chat.send` for sends; it listens to `chat/agent/presence/tick/health` events.
- History comes from the Gateway via `chat.history` (no local session file watching).
2025-12-09 23:16:57 +01:00
- If Gateway WS is unavailable, the UI surfaces the error and blocks send.
2025-12-09 14:41:55 +01:00
## Remote use
2025-12-17 23:05:28 +01:00
- In remote mode, the macOS app forwards the Gateway WebSocket control port via SSH and uses that for the SwiftUI chat UI.
- You generally should not need to manage tunnels manually; see `RemoteTunnelManager` in the app.
2025-12-09 14:41:55 +01:00
## Config
2025-12-17 23:05:28 +01:00
- WebChat does not have a separate HTTP port/config anymore.
2026-01-04 14:32:47 +00:00
- Gateway WS is configured via the app’ s gateway endpoint settings (`GatewayEndpointStore` ) or `clawdbot gateway --port` when running locally.
2025-12-08 12:50:37 +01:00
## Failure handling
2025-12-17 23:05:28 +01:00
- UI errors when the Gateway handshake fails or the WS drops.
- No fallback transport; the Gateway WS is required.
2025-12-08 12:50:37 +01:00
## Dev notes
2026-01-04 14:32:47 +00:00
- macOS glue: `apps/macos/Sources/Clawdbot/WebChatSwiftUI.swift` + `apps/macos/Sources/Clawdbot/WebChatManager.swift` .
- Remote tunnel helper: `apps/macos/Sources/Clawdbot/RemotePortTunnel.swift` .