OPSX 3: LiveView OpenClaw Chat Interface#3
Open
clawd-conroy wants to merge 20 commits into
Open
Conversation
- Add Fresh WebSocket client for OpenClaw Gateway - GatewayClient GenServer: manages connection, auth, RPC, events - GatewayWs: Fresh handler for raw WebSocket framing - ChatLive: LiveView page with real-time chat UI - DaisyUI chat bubbles (user right, assistant left) - Streaming support with live buffer display - Auto-scroll via JS hook - Connection status badge - History loading on mount - Gateway config via env vars (OPENCLAW_GATEWAY_URL/TOKEN) - Dev default: ws://host.docker.internal:18789 - Route: /chat - Protocol: JSON-RPC over WebSocket (chat.send, chat.history, chat.abort) - Events: PubSub broadcast of agent stream events - All tests passing, credo clean
- Add $time to dev logger format (was stripped by default Phoenix config) - Add :context metadata key to logger config - Tag GatewayClient logs with context=openclaw.gateway - Tag GatewayWs logs with context=openclaw.ws - Ignore priv/plts/ (dialyzer PLT binaries)
Only start GatewayClient when :openclaw config is present. Test env doesn't set it, so no more econnrefused noise in tests.
Loads .env and .env.{dev,test} in non-prod environments via runtime.exs.
Set OPENCLAW_GATEWAY_URL and OPENCLAW_GATEWAY_TOKEN in .env.
dev.exs sets static defaults, runtime.exs merges ENV overrides after dotenvy loads .env. Fixes .env not being picked up.
Dotenvy.source doesn't call System.put_env, so later System.get_env calls didn't see the values. Replaced with a simple inline loader that does System.put_env directly. Removed dotenvy dep.
- import Dotenvy in runtime.exs
- source! loads .env and .env.{env} files
- env! with defaults for gateway URL/token
- Remove redundant openclaw config from dev.exs
- Cleaner than inline parser, proper variable interpolation support
Use fetch! so missing config fails loud instead of silently falling back to localhost.
LiveView was falling back to longpoll after 2.5s. Remove the fallback to see the actual WS connection error.
The :connected PubSub event fires before ChatLive subscribes, so poll GatewayClient.connected?() on mount.
The OpenClaw gateway protocol requires a connect request frame
as the first message. Previously we only put params in the URL
query string, but the server needs the actual frame:
{type: 'req', method: 'connect', params: ConnectParams}
Gateway sends {type:'res', ok:true, payload:hello} for the connect
request. Track the connect request ID and handle the response to
transition to connected state.
Gateway broadcasts 'chat' events (not 'agent') with states:
- 'final': complete response with message.content[{type,text}]
- 'delta': streaming chunks (ignored for now)
- 'error': error with errorMessage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
LiveView chat page connected to OpenClaw Gateway via WebSocket.
What's in this PR
GatewayClientGenServer — WebSocket client for OpenClaw gatewayGatewayWs— Fresh WebSocket handlerChatLive— LiveView chat page at/chatHomeLive— Placeholder landing pageconfig/dev.exs+config/runtime.exsenv varsNot yet tested against live gateway
Built from reading the OpenClaw TS source. Needs live testing + likely adjustments to event payload structure.
Next steps