Skip to main content

Module text

Module text 

Source
Expand description

Pure text-shaping helpers shared by crate::app’s chat mutators and crate::widgets::scrollback’s renderer.

Why: LLM/agent responses routinely arrive with extra leading/trailing blank lines (a model’s closing paragraph break) and interior \n\n paragraph gaps that read as wasted vertical space once rendered into a fixed-height terminal pane. Both problems are pure string transforms with no dependency on ReplApp or ratatui, so they live in their own module rather than being duplicated between the state mutator that trims stored text (crate::app::ReplApp::push_assistant) and any future consumer that needs the same shaping. Extracted verbatim (behavior-preserving) from crates/trusty-agents/src/repl/tui/helpers.rs’s trim_surrounding_blank_lines/ strip_interior_blank_lines (DOC-50 §3.1/§5 Slice 4 migration).

§Spec References

Functions§

strip_interior_blank_lines
Drop every whitespace-only line from within a response.
trim_surrounding_blank_lines
Strip leading and trailing whitespace-only lines from a multi-line string.