Fix WebSocket connection in dev mode (`bun run dev`)
Problem
When running the project with bun run dev, agent terminals never connect — you can't type into them and no output appears. This affects anyone developing against the repo (as opposed to the published single-server openui command, which works fine).
Root cause
In dev, the frontend runs on Vite (6969) and proxies to the Bun backend (6968). The HTTP /api proxy works, but the /ws proxy does not: Vite forwards the upgrade and Bun accepts it (the backend logs [ws] Connected), but Vite's underlying http-proxy cannot relay Bun.serve's 101 Switching Protocols response back to the browser. The socket never opens and the connection silently times out.
This is a known incompatibility between Vite's http-proxy and Bun.serve WebSockets — not specific to any agent.
Fix
client/src/components/Terminal.tsx— in dev, connect the terminal WebSocket directly to the backend (window.location.hostname+ backend port) instead of through the Vite proxy. The backend port is configurable viaVITE_BACKEND_PORT(defaults to6968). Production/single-server mode is unchanged: there the backend serves the built client itself, sowindow.location.hostalready points at the backend.client/vite.config.ts— remove the non-functional/wsproxy entry (with a comment explaining why). The/apiproxy is untouched.
The backend performs no Origin check on upgrade, so the cross-port WebSocket from the dev page is accepted.
Verification
With the fix and bun run dev running:
- Created a session via the (proxied)
/api. - Opened the terminal WebSocket directly to the backend with a browser
Origin: http://localhost:6969header. - Result:
ws OPENand command output received ✓.
Terminals now work in dev mode without falling back to single-server/production mode.
Notes
- Two files changed,
+10 / −5. No behavior change in production. - Independent of #6 (the Copilot agent PR); this is a pre-existing bug affecting all agents.
Summary by cubic
Fixes terminal WebSocket connections in dev by bypassing Vite’s proxy and connecting directly to the Bun backend. In dev, mirror the page protocol (ws/wss) to satisfy browser mixed-content rules; production/single-server is unchanged.
- Bug Fixes
- In
client/src/components/Terminal.tsx, in dev connect directly to${protocol}//${window.location.hostname}:${<VITE_BACKEND_PORT|6968>}/wswhereprotocolmirrors the page; production reuses the current host and protocol. - In
client/vite.config.ts, remove the non-functional/wsproxy (keep/api), since Vite’shttp-proxycan’t relayBun.serve’s upgrade response.
- In