Expand description
Per-channel coalescing buffer for outputChannel.append notifications.
Cocoon’s Git extension emits 30+ append notifications per git status
(one per [trace] [OperationManager][...] line, one per executed
sub-command). Each one previously:
- Crossed the Cocoon → Mountain gRPC notification boundary.
- Fired its own
Tauri::Emitter::emit("sky://output/append")round-trip. - Wrote its own dev_log entry.
For a workspace with the Git extension actively probing repo state on
file changes, the volume of [OperationManager] traces alone accounted
for ~1.9k lines of one 28k-line session log.
This atom buffers appends per-channel for a short window
(COALESCE_WINDOW) and flushes the concatenated payload as a single
Sky emit + a single dev_log line. The downstream Output panel still
sees identical text - just delivered in larger chunks - which matches
the user-perceived UX of an output channel (it scrolls in chunks, not
character-by-character).
§Why this is safe
- Per-channel buffer means ordering is preserved within a channel.
- Append-only semantics mean partial-payload visibility cannot expose torn writes - the buffered text is always a prefix of the eventual full payload.
Tauri::Emitterserialises emits per channel; the flush task running on the tokio runtime keeps the same back-pressure shape the per-call path had.
§Disable hook
OutputCoalesce=0 reverts to per-append emit (debugging
synchronisation issues where a single append must be flushed
immediately to disk).
Structs§
Constants§
- COALESCE_
WINDOW 🔒 - Maximum delay between an append arriving and its flush to Sky. Tuned
against the FSEvents / Git-extension 16ms tick - one frame is enough
for a
git statusburst to fully accumulate without introducing a human-perceptible scroll lag. - MAX_
BUFFERED_ 🔒BYTES - Maximum buffered bytes per channel before a forced flush. Caps memory
for any channel emitting unbounded text (a build extension piping
cargo buildstdout) before the timer fires.
Statics§
Functions§
- Flush
One 🔒 - GetOr
Init 🔒Channel - IsDisabled 🔒
- TryEnqueue
- Submit a pending append for coalescing. Returns
truewhen the item was enqueued (the coalescer will flush withinCOALESCE_WINDOW),falsewhen coalescing is disabled and the caller must flush inline.