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
SPEC-TTUI-05~draft— Slice 4 deliverable (§5, Slice 4).
Functions§
- elide_
middle - Shorten
texttowidthcolumns, preferring/boundaries (#8164). - 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.