Skip to content

feat: add Claude Code channels as alternative backend#26

Merged
ngmaloney merged 1 commit intomainfrom
feature/channel-backend
Apr 5, 2026
Merged

feat: add Claude Code channels as alternative backend#26
ngmaloney merged 1 commit intomainfrom
feature/channel-backend

Conversation

@ngmaloney
Copy link
Copy Markdown
Owner

Summary

Adds Claude Code channels as a second backend option alongside OpenClaw. ClawChat can now connect to a Claude Code instance running with a custom MCP channel server, using the Max subscription instead of requiring an OpenClaw gateway.

What changed

src/lib/gateway-client.ts

  • Added BackendType ('openclaw' | 'channel') and backend field to GatewayClientOptions
  • New handler for connect.welcome event — channel servers use this simplified handshake instead of OpenClaw's connect.challenge → Ed25519 → hello-ok flow
  • OpenClaw flow is completely untouched — the channel path is additive

src/components/ConnectScreen.tsx

  • Replaced single connect form with tabbed interface: OpenClaw | Claude Channels
  • Each backend maintains its own URL and token state (switching tabs doesn't clobber values)
  • SSH tunnel toggle only shows for OpenClaw (channels connect directly)
  • Token is optional for channel backend (server may not require auth)
  • Defaults: OpenClaw → ws://localhost:18789, Channels → ws://tc1.home.wrox.us:9700

src/App.tsx

  • Credentials now include backend type
  • Channel credentials persisted separately (channelUrl/channelToken vs gatewayUrl/token)
  • Auto-connect on launch loads the correct credentials based on last-used backend

src/hooks/useGateway.ts

  • Passes backend through to GatewayClient
  • Allows empty token for channel backend (doesn't block client creation)

README.md

  • Updated tagline and intro to mention both backends
  • Added full Claude Channels setup guide: Docker compose, channel server, MCP config, first-time container setup, launching Claude with channels, and optional personality via CLAUDE.md
  • Restructured "Connecting" section with separate instructions per backend

How it works

The channel server is an MCP server that runs as a subprocess of Claude Code. It has two interfaces:

  • stdio → talks to Claude Code (MCP channel notifications)
  • WebSocket → talks to ClawChat (same req/res/event protocol)
ClawChat ──WebSocket──→ Channel Server (MCP + WS)
                            │ stdio
                            ▼
                        Claude Code (interactive, with --dangerously-load-development-channels)

When ClawChat sends a chat.send request:

  1. Channel server acks immediately with a runId
  2. Sends notifications/claude/channel to Claude via MCP
  3. Claude processes the message and calls the send_reply tool
  4. Channel server broadcasts the reply as a chat event (state: final) with the matching runId
  5. ClawChat displays the response

What's NOT changed

  • OpenClaw gateway flow — zero changes to handshake, crypto, protocol, or behavior
  • useChat.ts — no changes needed, both backends emit the same event format
  • useSessions.ts — channel server implements sessions.list compatibly
  • All existing tests pass unchanged
  • MessageBubble, MessageInput, ChatView, Dashboard — all unchanged

Known limitations

  • No streaming deltas from channels — Claude's response arrives as a single final event (not incremental deltas). The response appears all at once rather than streaming word-by-word.
  • Channel server requires Claude Code running interactively (in tmux) with --dangerously-load-development-channels — this is a research preview feature
  • The dev channels warning prompt must be accepted manually after each container restart
  • Single conversation per Claude Code instance (no multi-session support yet)

Test plan

  • Select OpenClaw tab → enter gateway URL + token → Connect → verify full chat flow with streaming deltas
  • Select Claude Channels tab → enter channel server URL → Connect → verify chat flow with final responses
  • Switch between tabs → verify URL/token fields are independent and don't clobber each other
  • Connect to channels → disconnect → reconnect → verify auto-reconnect works
  • Verify saved credentials load correctly on app restart for both backends
  • Run npm test — all 12 tests pass
  • Run npx tsc --noEmit — clean build

🤖 Generated with Claude Code

Add support for connecting to Claude Code channel servers alongside
existing OpenClaw gateway support. Users select between backends via
tabs on the connect screen. Each backend maintains its own saved
credentials.

- gateway-client.ts: handle `connect.welcome` event for channel backend,
  add BackendType, skip Ed25519 handshake for channels
- ConnectScreen: backend tabs (OpenClaw / Claude Channels), separate
  URL/token state per backend, SSH toggle only for OpenClaw
- App.tsx: persist backend type and channel credentials separately
- useGateway: pass backend type through to client
- README: document channel server setup with full instructions

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ngmaloney ngmaloney merged commit 3780b2a into main Apr 5, 2026
1 check passed
@ngmaloney ngmaloney deleted the feature/channel-backend branch April 5, 2026 04:34
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.

1 participant