Preserve streamed output during capped history replay (#33093)

## Why

Stream consolidation can replace transcript cells while initial history replay is buffering capped display rows, leaving those rows stale and omitting the finalized output.

## What changed

- Discard buffered rows when required stream reflow occurs during capped initial replay and rebuild the capped tail from the canonical transcript after replay finishes.
- Schedule the rebuild through the resize reflow path so it waits for an active transcript overlay to close.

## Testing

Added coverage for consolidated Markdown output during capped initial replay, both with and without an active transcript overlay.

GitOrigin-RevId: 1c184ff561a50362daf11c1c629be59882f27a4a
This commit is contained in:
rakan-oai authored and copyberry committed 2026-07-14 15:27:45 +00:00
1 parent 6629e08702
commit effd58d750
4 files changed
+156 -10

No files matched your search

+20 -10
View File
@@ -144,17 +144,14 @@ impl App {
return;
};
if buffer.render_from_transcript_tail || self.overlay.is_some() {
// Reflow clears any pre-replay or partially emitted history and applies the reserved
// history width. It also waits for an active overlay to close before rebuilding.
self.schedule_immediate_resize_reflow(tui);
return;
}
if buffer.retained_lines.is_empty() {
if buffer.render_from_transcript_tail {
let width = tui.terminal.last_known_screen_size.width;
let reflowed_lines = self.render_transcript_lines_for_reflow(width).lines;
if !reflowed_lines.is_empty() {
tui.insert_history_hyperlink_lines_with_wrap_policy(
reflowed_lines,
self.history_line_wrap_policy(),
);
}
}
return;
}
@@ -274,6 +271,19 @@ impl App {
/// replaced as one styled source-backed cell. If this reflow is skipped after a stream-time
/// resize, the visible scrollback can keep the pre-consolidation wrapping.
pub(super) fn finish_required_stream_reflow(&mut self, tui: &mut tui::Tui) -> Result<()> {
// Capped initial replay normally buffers per-cell display rows. A live stream tail is
// consolidated directly into `transcript_cells`, so any retained rows no longer describe
// the canonical transcript. Let the replay-end event render the capped transcript tail
// once all consolidation events have been processed.
if self.resize_reflow_max_rows().is_some()
&& let Some(buffer) = self.initial_history_replay_buffer.as_mut()
{
buffer.retained_lines.clear();
buffer.render_from_transcript_tail = true;
self.transcript_reflow.clear_stream_flags();
return Ok(());
}
self.schedule_immediate_resize_reflow(tui);
self.maybe_run_resize_reflow(tui)?;
if !self.transcript_reflow.has_pending_reflow() {