mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Speed up /side parent restore replay (#20815)
## Why Returning from a `/side` conversation restores the parent thread by replaying its snapshot into the TUI. For very long parent threads, replaying every transcript row can take noticeable time even though most rows immediately scroll out of terminal history. ## What Changed - Buffer thread-switch replay for parent restores when terminal resize reflow is enabled. - Reuse the existing resize-reflow tail renderer so only the retained transcript tail is written back to scrollback when a row cap is configured.
This commit is contained in:
1 parent
3c2dcbef85
commit
f072119ccf
6 files changed
+77
No files matched your search
@@ -119,6 +119,23 @@ impl App {
|
||||
}
|
||||
}
|
||||
|
||||
/// Start retaining a thread-switch transcript replay without rendering each historical cell.
|
||||
///
|
||||
/// Thread switches already rebuild `transcript_cells` from source. When a row cap exists, we can
|
||||
/// defer terminal writes until the replay is complete and reuse the resize-reflow tail renderer
|
||||
/// so only the rows the terminal would retain are formatted and inserted.
|
||||
pub(super) fn begin_thread_switch_history_replay_buffer(&mut self) {
|
||||
if self.terminal_resize_reflow_enabled()
|
||||
&& self.resize_reflow_max_rows().is_some()
|
||||
&& self.overlay.is_none()
|
||||
{
|
||||
self.initial_history_replay_buffer = Some(InitialHistoryReplayBuffer {
|
||||
retained_lines: VecDeque::new(),
|
||||
render_from_transcript_tail: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// Flush retained initial resume replay rows into terminal scrollback.
|
||||
///
|
||||
/// The buffer stores display lines, not cells, because the cap is measured in terminal rows.
|
||||
@@ -130,6 +147,13 @@ impl App {
|
||||
};
|
||||
|
||||
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_lines(reflowed_lines);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -143,6 +167,14 @@ impl App {
|
||||
cell: &dyn HistoryCell,
|
||||
width: u16,
|
||||
) {
|
||||
if self
|
||||
.initial_history_replay_buffer
|
||||
.as_ref()
|
||||
.is_some_and(|buffer| buffer.render_from_transcript_tail)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
let display = self.display_lines_for_history_insert(cell, width);
|
||||
|
||||
if display.is_empty() {
|
||||
|
||||
Reference in new issue
Block a user