---
name: "Web UI SSE socket stops updating after a while"
---

# Bug 114: Web UI SSE socket stops updating after a while

## Description

After the first several pipeline updates, the UI stops reflecting changes. Lozenges stop flying, stories stop moving between stages, but the server is still advancing the pipeline fine. A page refresh fixes it.

The root cause is likely not the SSE transport itself but rather the large combined pipeline state push that the frontend subscribes to. Investigate the SSE event handler in the frontend client — it receives a single big `pipeline_state` event that everything listens to. Something may be going wrong in the processing/diffing of that state after several rapid updates.

## Investigation hints

- Start with the SSE client in `frontend/src/api/client.ts` — look at `onPipelineState` handling
- Check if the SSE connection is actually dropping (add a log on close/error) or if events arrive but stop being processed
- The `LozengeFlyContext` diffing logic in `useLayoutEffect` compares prev vs current pipeline — could a stale ref or missed update break the chain?
- Server-side: the `broadcast::channel` has a 1024 buffer — if a slow consumer lags, tokio drops it silently

## How to Reproduce

1. Open the web UI
2. Start several agents working on stories
3. Wait a few minutes while agents complete and pipeline advances
4. Observe that the UI stops reflecting pipeline changes
5. Refresh the page — state is correct again

## Actual Result

UI freezes showing stale pipeline state after several updates.

## Expected Result

UI should always reflect current pipeline state in real time without needing a manual refresh.

## Acceptance Criteria

- [ ] Root cause identified (SSE transport vs frontend state processing)
- [ ] Fix implemented with auto-recovery if connection drops
- [ ] UI stays live through sustained agent activity (10+ minutes)
