How ngmaloney/clawchat works
ClawChat is an Electron desktop chat client for OpenClaw gateways and Claude Code channel servers. The main workflow is to load or enter backend credentials, optionally establish an SSH tunnel, connect over WebSocket, select a session, then send messages and attachments while rendering streamed replies. The graph includes the documented session, markdown, slash-command, reconnect, and credential-persistence capabilities. Some subsystem links are documented rather than visible in sampled implementation; those links use the README as evidence.
Main entry points: gateway-client.ts WebSocket client · App.tsx App coordinator · Dashboard.tsx Chat dashboard · ConnectScreen.tsx Connect screen
Components 25
Connection and backends
- App coordinator
src/App.tsx - Connect screen
src/components/ConnectScreen.tsx - Gateway lifecycle
src/hooks/useGateway.ts - WebSocket client
src/lib/gateway-client.ts - OpenClaw gateway
- Claude channel server
- SSH tunnel
electron/main.ts - Device identity signing
src/lib/device-crypto-ed25519.ts
Chat experience
- Chat dashboard
src/components/Dashboard.tsx - Chat view
src/components/ChatView.tsx - Chat state and streaming
src/hooks/useChat.ts - Message composer
src/components/MessageInput.tsx - Slash commands
src/components/SlashCommandMenu.tsx - Attachment encoding
src/lib/file-utils.ts - Attachment preview
src/components/AttachmentPreview.tsx - Markdown message display
src/components/MessageBubble.tsx - Message attachments
src/components/MessageAttachment.tsx
Sessions and protocol
- Session management
src/hooks/useSessions.ts - Session sidebar
src/components/Sidebar.tsx - Connection status
src/components/StatusBar.tsx - Gateway protocol types
src/types/protocol.ts
Desktop integration
- Desktop main process
electron/main.ts - Desktop API bridge
electron/preload.ts - Local credential storage
electron/main.ts
Other components
- Desktop user
Connections 31
- Desktop user → Connect screen: configures connection
README.md - Connect screen → App coordinator: submits credentials
src/App.tsx - App coordinator → Gateway lifecycle: creates connection
src/App.tsx - Gateway lifecycle → WebSocket client: manages lifecycle
src/hooks/useGateway.ts - WebSocket client → OpenClaw gateway: connects WebSocket
README.md - WebSocket client → Claude channel server: connects WebSocket
README.md - Connect screen → SSH tunnel: starts tunnel
README.md - App coordinator → Chat dashboard: renders connected view
src/App.tsx - Chat dashboard → Chat view: renders chat
src/components/Dashboard.tsx - Chat view → Chat state and streaming: uses chat state
src/components/ChatView.tsx - Chat view → Message composer: renders composer
src/components/ChatView.tsx - Chat view → Markdown message display: renders messages
src/components/ChatView.tsx - Message composer → Slash commands: shows commands
src/components/MessageInput.tsx - Message composer → Attachment preview: renders previews
src/components/MessageInput.tsx - Message composer → Attachment encoding: encodes files
src/components/MessageInput.tsx - Attachment preview → Attachment encoding: formats attachments
src/components/AttachmentPreview.tsx - Markdown message display → Message attachments: renders attachments
src/components/MessageBubble.tsx - Chat state and streaming → WebSocket client: calls chat methods
src/hooks/useChat.ts - Chat state and streaming → Gateway protocol types: uses message types
src/hooks/useChat.ts - WebSocket client → Device identity signing: signs handshake
src/lib/gateway-client.ts - Chat dashboard → Session management: manages sessions
src/components/Dashboard.tsx - Session management → WebSocket client: lists sessions
src/hooks/useSessions.ts - Session management → Gateway protocol types: uses session types
src/hooks/useSessions.ts - Chat dashboard → Session sidebar: renders navigation
src/components/Dashboard.tsx - Chat dashboard → Connection status: renders status
src/components/Dashboard.tsx - Connection status → Gateway protocol types: uses connection types
src/components/StatusBar.tsx - App coordinator → Local credential storage: loads and saves credentials
src/App.tsx - Connect screen → Local credential storage: loads connection settings
src/components/ConnectScreen.tsx - Desktop API bridge → Local credential storage: exposes store API
electron/preload.ts - App coordinator → Desktop API bridge: uses desktop API
src/App.tsx - Desktop main process → Desktop API bridge: provides renderer bridge