1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//! CLI sink — forwards EngineEvents to the TUI event loop.
//!
//! The TUI uses `CliSink::channel()` to forward all events to the
//! main event loop via `UiEvent`. The headless path uses
//! `HeadlessSink` (see `headless_sink.rs`).
use ;
// ── UiEvent ───────────────────────────────────────────────
/// Events forwarded from `CliSink` to the main event loop.
pub
// ── CliSink ───────────────────────────────────────────────
/// Channel-forwarding sink for the TUI event loop.
///
/// Uses an **unbounded** channel so engine events are never dropped.
///
/// Memory safety: the engine produces events sequentially (single
/// turn loop, I/O-bound on LLM streaming at ~50–100 tokens/sec).
/// The TUI drains events every frame (~16 ms). Even in the worst
/// case (large `ToolCallResult` output), only a handful of events
/// queue up — each a few KB — which is negligible. A bounded
/// channel with `try_send` silently dropped `TextDelta` events
/// when the TUI couldn’t keep up, truncating model output.