Files
zed/crates/language_model
Ben Brandt 33156f0d81 language_model: Stream background events through async-channel (#66290)
`stream_in_background` forwards a model's events from a background task
through a bounded `futures::channel::mpsc`. When the 32-event buffer
fills, that channel parks the sender behind a `std` mutex that the
receiver also locks to wake it.

On the web the receiver polls on the browser's main thread, and the
producer runs on a Web Worker. Waiting on a contended `std` mutex on the
main thread traps with `Atomics.wait cannot be called in this context`,
which can happen whenever rendering falls behind a model stream.

`async_channel::bounded` keeps the same backpressure without that mutex.
`gpui_web`'s HTTP response body already uses it for the same reason.

Release Notes:

- N/A
2026-10-29 13:16:06 +00:00
..