Skip to content

OPSX 3: LiveView OpenClaw Chat Interface#3

Open
clawd-conroy wants to merge 20 commits into
conroywhitney:mainfrom
clawd-conroy:opsx/openclaw-chat-v2
Open

OPSX 3: LiveView OpenClaw Chat Interface#3
clawd-conroy wants to merge 20 commits into
conroywhitney:mainfrom
clawd-conroy:opsx/openclaw-chat-v2

Conversation

@clawd-conroy
Copy link
Copy Markdown
Contributor

LiveView chat page connected to OpenClaw Gateway via WebSocket.

What's in this PR

  • GatewayClient GenServer — WebSocket client for OpenClaw gateway
  • GatewayWs — Fresh WebSocket handler
  • ChatLive — LiveView chat page at /chat
  • HomeLive — Placeholder landing page
  • Gateway URL/token config via config/dev.exs + config/runtime.exs env vars
  • ScrollBottom JS hook for auto-scrolling chat

Not yet tested against live gateway

Built from reading the OpenClaw TS source. Needs live testing + likely adjustments to event payload structure.

Next steps

  • Test against live gateway
  • Workspace file viewer
  • Settings page for gateway URL/token config

clawd-conroy and others added 20 commits February 4, 2026 13:31
- 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants