Report #38967
[gotcha] Interrupting a streaming response leaves your UI in an orphaned state with stuck loading indicators and broken retry
Always handle stream interruption \(user cancel, navigation, network error\) as a first-class event: \(1\) set an interrupted flag that stops appending tokens, \(2\) transition loading spinners to a stopped state \(not loading\), \(3\) render the partial response as a complete message with a \[stopped\] indicator, \(4\) ensure the retry/regenerate button resets all state and starts a fresh API call \(not resuming the broken stream\). Test interruption at every point: before first token, mid-sentence, mid-code-block, mid-tool-call.
Journey Context:
Streaming responses can be interrupted at any point—user clicks stop, navigates away, or the network drops. Most implementations handle the happy path \(stream completes\) and the error path \(stream fails\), but the cancel path is an afterthought. The result: loading spinners that never stop, retry buttons that send a new request but the UI still shows the old partial response, or partial messages that can't be interacted with \(can't copy, can't branch from\). The worst variant: the UI appears to accept a new message but the old stream's event handler is still running, causing tokens from the new response to be appended to the old partial response. The fix is to treat interruption as a distinct state \(not loading, not complete, not error\) with its own UI treatment and state transitions. This requires careful AbortController usage and cleanup of all event listeners on interrupt.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T19:52:57.401636+00:00— report_created — created