$npx -y skills add CommonstackAI/ClawBox --skill clawbox-chat-streamUse when changing or debugging ClawBox chat sending, SSE streaming, reasoning blocks, tool-call blocks, session synchronization, or title generation across the React frontend and the Bun OpenClaw bridge.
| 1 | # ClawBox Chat Stream |
| 2 | |
| 3 | Use this skill when the task involves ClawBox chat flow, assistant streaming, tool event rendering, session history hydration, or title generation. |
| 4 | |
| 5 | ## Read first |
| 6 | |
| 7 | - `src/hooks/useChat.ts` |
| 8 | - `src/services/ai.ts` |
| 9 | - `src/store/chat.ts` |
| 10 | - `src/components/chat/` |
| 11 | - `internal/routes/chat.ts` |
| 12 | - `internal/providers/openclaw-rpc.ts` |
| 13 | - `src/services/api.ts` |
| 14 | |
| 15 | ## Workflow |
| 16 | |
| 17 | 1. Map the end-to-end path: UI event -> frontend store/hook -> SSE parser -> backend route -> OpenClaw RPC event. |
| 18 | 2. If request or response payloads change, update every consumer in the same task instead of leaving cross-layer drift. |
| 19 | 3. For tool-call regressions, verify both streamed events and history rehydration. ClawBox uses live events plus follow-up history reconciliation. |
| 20 | 4. For title or unread-count issues, inspect the `finally` path in `src/hooks/useChat.ts` and the corresponding Zustand store updates. |
| 21 | |
| 22 | ## Verification |
| 23 | |
| 24 | - Run `npm run build:frontend`. |
| 25 | - Run `npm run build:backend`. |
| 26 | - If the local gateway is available, use `bun test/openclaw-stream.ts --prompt "..."` as a manual smoke test. |
| 27 | |
| 28 | ## Guardrails |
| 29 | |
| 30 | - Never guess OpenClaw protocol fields or event names. |
| 31 | - Preserve the SSE event types expected by `src/services/ai.ts`. |
| 32 | - Keep message block ordering consistent with the `text`, `reasoning`, and `tool_call` model. |