pub struct TextDeltaRenderer;Expand description
Default implementation of DeltaRenderer for text content.
Supports true append-only streaming pattern that works correctly under line wrapping and in ANSI-stripping environments.
- First delta: prefix + content (no newline, stays on current line)
- Subsequent deltas: Parser computes and emits only new suffix
- Completion: single newline via
DeltaRenderer::render_completion - Sanitizes newlines to spaces (to prevent artificial line breaks)
- Applies consistent color formatting
§Output Pattern
§Full Mode (TTY with capable terminal) - Append-Only Pattern
[ccs-glm] Hello <- First delta: prefix + content, NO newline
World <- Parser emits suffix: " World" (no prefix, no \r)
\n <- Completion: single newlineResult: Single logical line that may wrap to multiple terminal rows. Terminal handles wrapping naturally. No cursor movement means wrapping is not an issue.
§Full Mode (Legacy Pattern - Deprecated)
Some parsers not yet implementing append-only may still use render_subsequent_delta
which rewrites the line with \r. This pattern has known issues with wrapping:
[ccs-glm] Hello <- First delta
\r[ccs-glm] Hello World <- Subsequent: carriage return + full rewriteIssue: When content wraps, \r only returns to column 0 of current row, not
start of logical line. This causes display corruption.
§Basic/None Mode (non-TTY logs)
In non-TTY modes, per-delta output is suppressed to avoid repeated prefixed
lines for partial updates. The parser is responsible for flushing the final
accumulated content once at a completion boundary (e.g. message_stop).
[ccs-glm] Hello World\n§CCS Spam Prevention (Bug Fix)
This implementation prevents repeated prefixed lines for CCS agents (ccs/codex, ccs/glm) in non-TTY modes. The spam fix is validated with comprehensive regression tests that simulate real-world streaming scenarios:
- Ultra-extreme delta counts: Tests verify no spam with 1000+ deltas per content block
- Multi-turn sessions: Validates 3+ turns with 200+ deltas each (600+ total)
- All delta types: Covers text deltas, thinking deltas, and tool input deltas
- Real-world logs: Tests with production logs containing 12,596 total deltas
The multi-line pattern (in-place updates) is the industry standard used by Rich, Ink, Bubble Tea, and other production CLI libraries for clean streaming output.
See regression tests:
tests/integration_tests/ccs_delta_spam_systematic_reproduction.rs(systematic reproduction & verification)tests/integration_tests/ccs_all_delta_types_spam_reproduction.rs(1000+ deltas, edge case coverage)tests/integration_tests/ccs_extreme_streaming_regression.rs(500+ deltas per block)tests/integration_tests/ccs_streaming_spam_all_deltas.rs(all delta types)tests/integration_tests/ccs_real_world_log_regression.rs(production log regression)tests/integration_tests/ccs_nuclear_full_log_regression.rs(large captured logs)tests/integration_tests/codex_reasoning_spam_regression.rs(Codex reasoning regression)tests/integration_tests/ccs_wrapping_waterfall_reproduction.rs(wrapping waterfall reproduction)tests/integration_tests/ccs_wrapping_comprehensive.rs(wrapping + append-only behavior)tests/integration_tests/ccs_ansi_stripping_console.rs(ANSI-stripping console behavior)
Trait Implementations§
Source§impl DeltaRenderer for TextDeltaRenderer
impl DeltaRenderer for TextDeltaRenderer
Source§fn render_first_delta(
accumulated: &str,
prefix: &str,
colors: Colors,
terminal_mode: TerminalMode,
) -> String
fn render_first_delta( accumulated: &str, prefix: &str, colors: Colors, terminal_mode: TerminalMode, ) -> String
Source§fn render_subsequent_delta(
_accumulated: &str,
_prefix: &str,
_colors: Colors,
terminal_mode: TerminalMode,
) -> String
fn render_subsequent_delta( _accumulated: &str, _prefix: &str, _colors: Colors, terminal_mode: TerminalMode, ) -> String
Source§fn render_completion(terminal_mode: TerminalMode) -> String
fn render_completion(terminal_mode: TerminalMode) -> String
Auto Trait Implementations§
impl Freeze for TextDeltaRenderer
impl RefUnwindSafe for TextDeltaRenderer
impl Send for TextDeltaRenderer
impl Sync for TextDeltaRenderer
impl Unpin for TextDeltaRenderer
impl UnsafeUnpin for TextDeltaRenderer
impl UnwindSafe for TextDeltaRenderer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more