# Zo StreamBrowse — Agent Notes

**Fork of Zo Co-browse (v0.0.1-alpha) with SSE streaming support.**

## Key differences from upstream

- Background uses port-based streaming (`port.name === 'stream-browse'`) instead of message-based `ASK_ZO`
- SSE events parsed in `_askZoStreamImpl()`: `FrontendModelResponse` (chunks), `End` (done), `Error`
- Sidepanel has streaming state (`streamSession`), port connection with auto-reconnect
- `sendQuery()` sends via port, `handleStreamMessage()` renders tokens incrementally

## Port protocol

| Message Type | Direction | Description |
|---|---|---|
| `ASK_ZO` | Panel → BG | Start streaming query (with `sessionId`) |
| `NEW_CONVERSATION` | Panel → BG | Reset conversation ID |
| `STREAM_CHUNK` | BG → Panel | Token chunk (`{text: string}`) |
| `STREAM_DONE` | BG → Panel | Complete response + actions |
| `STREAM_ERROR` | BG → Panel | Error message |
| `STREAM_RECONNECT` | BG → Panel | Reconnect attempt status |
| `STREAM_RECONNECT_DONE` | BG → Panel | Reconnect successful |

## Non-streaming fallback

`sendQuery()` in sidepanel falls back to `chrome.runtime.sendMessage({type: 'ASK_ZO'})` if no streaming port is available.
