- WebSocket broadcasts: Next.js tRPC router now routes broadcasts via
POST /internal/broadcast on the Bun ws-server process, which holds
the actual client connections. Broadcasts were previously silently
dropped due to the split singleton across processes.
- ws-server stubs: request_trial_status and request_trial_events now
use the real async DB methods instead of the stub getTrialStatusSync/
getTrialEventsSync that always returned null/[].
- Duplicate branch case: removed the unreachable second case "branch"
block in executeAction switch; server-side branching is a pass-through
since routing is client-orchestrated.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Create standalone WebSocket server (ws-server.ts) on port 3001 using Bun
- Add ws_connections table to track active connections in database
- Create global WebSocket manager that persists across component unmounts
- Fix useWebSocket hook to prevent infinite re-renders and use refs
- Fix TrialForm Select components with proper default values
- Add trialId to WebSocket URL for server-side tracking
- Update package.json with dev:ws script for separate WS server