Skip to main content

Module scrollback

Module scrollback 

Source
Expand description

The chat scrollback pane — generalized port of tagent’s repl/tui/chat.rs (build_chat_lines/chat_line_count/draw_chat).

Why: DOC-50 §5 Slice 4 migrates this file’s markdown-aware chat rendering (fenced code blocks, tables, the banner-as-scrollback-prefix trick) since it’s the single largest, most product-agnostic piece of tagent’s TUI. Generalization removed exactly one thing: tagent’s AgentScope-driven cyan/yellow leader color became crate::app::ReplApp::accent_color, a plain engine-set field (see that field’s doc comment) — everything else (fence/table detection via crate::render::markdown, blank-line collapsing) is a direct, behavior-preserving port.

What: build_chat_lines walks app.chat and returns the rendered Vec<Line> (banner prepended when app.show_banner); chat_line_count is the pre-layout height query crate::layout::draw uses to size the chat Constraint; draw_chat renders into a Frame with bottom-pinned padding and publishes the scroll cap to app.last_max_scroll.

§Spec References

Functions§

build_chat_lines
Build the rendered Vec<Line> for the chat pane.
chat_line_count
Count chat content lines for layout sizing.
collapse_blank_lines
Drop runs of 2+ consecutive whitespace-only Lines, keeping at most one.
draw_chat
Render the chat pane into area, bottom-pinned when content fits.