mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-29 03:24:54 +00:00
Add packages/cli-rs, an OpenCode client written in Rust on OpenTUI's Rust crates. It is a client only.
13 lines
834 B
Markdown
13 lines
834 B
Markdown
# A09: bounded event batch queue
|
|
|
|
TypeScript: `createClientConnection` (`packages/client/src/solid/connection.ts:65-74`) appends every
|
|
event to an unbounded `pending` array and flushes it to `onEvent` every 10 ms on the UI thread.
|
|
|
|
Rust: the connection loop (`crates/api/src/events.rs`, `connect`) runs on a tokio task and sends each
|
|
10 ms batch over a bounded channel (`Options::queue`, 256 batches by default). When the consumer
|
|
falls that far behind, the loop drops the stream, records "Event queue full", and reconnects. The
|
|
consumer gets `server.connected` again and resynchronizes from the server, as it does after any
|
|
reconnect.
|
|
|
|
Reason: the Rust UI thread is separate from the network task, and `AGENTS.md` requires every queue
|
|
between tasks and the UI to be bounded. A UI that stops reading cannot grow memory without bound.
|