Files
coder/coderd/x/chatd/messagepartbuffer
Mathias Fredriksson 1d565409e4 fix(coderd/x/chatd): keep slow part subscribers attached while the episode is open (#31196)
The message part buffer dropped a subscriber of an open episode whose
send waited 10 seconds. The parts endpoint read the closed channel as
the end of the episode and kept the connection open, so live output
stopped for the rest of the model call. Only on the cross-replica
WebSocket could a longer stall end it: the endpoint's heartbeat closes
the socket 15 to 30 s after the relay stops reading, and the relay
reconnects and replays once it reads again. That path is unchanged. The
stream loop stops reading when its writes to the browser block.

The timeout keeps an unresponsive subscriber from holding an episode in
memory, but only closed episodes wait for subscribers. It now starts at
the close, also for a send already waiting then.

A drop after the close only cuts short the live preview, which the saved
message or the error event replaces. The buffer has no logger, so it is
not logged.

Cost: a subscriber that stops reading an open episode holds its
goroutine and batch until it reads, is cancelled, its context ends, the
buffer closes, or `SubscriberSendTimeout` passes after the episode
closes.

> 🤖 This PR was created with the help of Coder Agents.
2026-11-25 16:26:23 +02:00
..