| name | add-ws-event |
| description | Wire a new WebSocket event end-to-end (daemon → types → hook → component). |
| disable-model-invocation | true |
Add WebSocket Event
Wire a new real-time event through all layers of the FXFlow stack.
Arguments
$ARGUMENTS[0] — Event name (e.g., "trade_alert_triggered")
$ARGUMENTS[1] — Data type description (e.g., "{ tradeId: string, alertType: string }")
Steps
-
packages/types/src/index.ts — Add to DaemonMessageType union and create typed message interface.
-
apps/daemons/src/server.ts — Add broadcast call in the appropriate listener or endpoint:
broadcast({ type: "event_name", timestamp: new Date().toISOString(), data })
-
apps/web/src/hooks/use-daemon-connection.ts — Handle the new message type:
- Add state variable:
const [lastEvent, setLastEvent] = useState<T | null>(null)
- Add case in message handler switch
- Expose in return value
-
apps/web/src/state/daemon-status-context.tsx — Expose through context if needed by multiple consumers.
-
Consuming component — Use the hook/context to react to the event.
-
Run /verify to confirm types and lint pass.
Checklist