Make transcript list spacing uniform after streaming (#46899)

## Why

Adding blank lines only after multiline items gives lists uneven spacing. Completed lists in redrawable transcript views can use consistent spacing based on their rendered width.

## What changed

- Keep assistant and plan lists compact while streaming in the fullscreen transcript, without holding back completed list rows.
- On completion or interruption, separate all sibling items if any item spans multiple rows; keep single-line lists compact and recompute spacing on resize.
- Preserve the reader's displayed content when consolidating streamed cells, and include spacing policy in the Markdown render cache key.
- Retain existing list spacing for native terminal scrollback.

## Testing

Add regression and snapshot coverage for streaming completion and interruption, width-dependent reflow, reader position, nested and quoted lists, item paragraphs, and preservation of links and source metadata.

GitOrigin-RevId: b2230aaf76ae798ebb6bf15563f8b8dcb6f3d19d
This commit is contained in:
Felipe Coury
2026-09-20 22:55:19 +00:00
committed by copyberry
parent d99213289f
commit 4ca8e7afff
25 changed files with 789 additions and 68 deletions
@@ -3,6 +3,7 @@
use super::*;
use crate::app::tests::make_test_app_with_channels;
use crate::app_command::AppCommand;
use crate::app_event::ConsolidationScrollbackReflow;
use crate::chatwidget::tests::helpers::normalize_snapshot_paths;
use crate::history_cell::HistoryCell;
use crate::history_cell::UserHistoryCell;
@@ -72,6 +73,52 @@ fn buffer_text(buffer: &Buffer) -> String {
.join("\n")
}
#[tokio::test]
async fn list_spacing_completion_preserves_the_scrolled_reader() -> Result<()> {
let mut app = crate::app::test_support::make_test_app().await;
app.transcript_cells = vec![Arc::new(history_cell::AgentMessageCell::new(
vec![
"- First item wraps onto".into(),
" a second row".into(),
"- b".into(),
"- c".into(),
],
/*is_first_line*/ true,
))];
let mut tui = crate::tui::test_support::make_test_tui()?;
tui.set_owned_screen(/*owned*/ true)?;
let area = Rect::new(
/*x*/ 0, /*y*/ 0, /*width*/ 26, /*height*/ 1,
);
let mut before = Buffer::empty(area);
app.transcript_view
.jump_to_entry(&app.transcript_cells, /*index*/ 0);
app.transcript_view
.render(area, &mut before, &app.transcript_cells);
app.transcript_view
.scroll(&app.transcript_cells, /*rows*/ 3);
app.transcript_view
.render(area, &mut before, &app.transcript_cells);
assert!(buffer_text(&before).contains("- c"));
app.handle_consolidate_agent_message(
&mut tui,
"- First item wraps onto a second row\n- b\n- c".into(),
app.config.cwd.to_path_buf(),
/*inline_visualization_context*/ None,
ConsolidationScrollbackReflow::Required,
/*deferred_history_cell*/ None,
)?;
let mut after = Buffer::empty(area);
app.transcript_view
.render(area, &mut after, &app.transcript_cells);
assert_eq!(after, before);
app.transcript_view.jump_to_latest();
app.transcript_view
.render(area, &mut after, &app.transcript_cells);
assert_eq!(after, before);
Ok(())
}
#[tokio::test]
async fn older_page_loading_uses_the_status_row_without_moving_content_or_cursor() -> Result<()> {
let mut app = crate::app::test_support::make_test_app().await;