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 gRPC boundary, fired its
own renderer event, and wrote its own dev_log entry. For a workspace
with the Git extension actively probing on file changes, this 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
renderer emit + a single dev_log line. The downstream Output panel
still sees identical text - just delivered in larger chunks.
Β§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.
- The flusher 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Β§
- Coalesce
Channel π - Pending
Append π
ConstantsΒ§
- COALESCE_
WINDOW π - Maximum delay between an append arriving and its flush to the
renderer. 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Β§
- COALESCE_
CHANNEL π
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.