mirror of
https://github.com/openai/codex.git
synced 2026-11-24 07:20:27 +00:00
Improve paginated TUI history loading (#36949)
## Why Paginated sessions can have visible messages beyond the first item page, so bounded hydration could leave resumed history or transcript previews empty and the transcript viewer incomplete. ## What changed - Scan paginated history until the configured rendered-row budget is filled, while retaining the configured scrollback beyond the visible viewport. - Fully hydrate transcripts opened from the resume picker and build previews from bounded item pages, including when non-visible items precede messages. - Stop pagination on repeated cursors and let `Esc` cancel an in-flight transcript load. - Replay restored token usage for cold metadata-only resumes when its stored turn can be identified. ## Testing - Add coverage for paginated and legacy transcript loading, bounded resume hydration, repeated cursors, transcript cancellation, and resize reflow. GitOrigin-RevId: 2ce69f7d5eae88e2b09a27c333b00b1830ff17bf
This commit is contained in:
1 parent
8bfa49e350
commit
3b8d22ec2c
13 files changed
+721
-125
No files matched your search
@@ -29,6 +29,7 @@ pub(crate) struct TranscriptReflowState {
|
||||
last_reflow_width: Option<u16>,
|
||||
pending_reflow_width: Option<u16>,
|
||||
pending_until: Option<Instant>,
|
||||
visible_history_rows: Option<u16>,
|
||||
ran_during_stream: bool,
|
||||
resize_requested_during_stream: bool,
|
||||
}
|
||||
@@ -43,6 +44,16 @@ impl TranscriptReflowState {
|
||||
*self = Self::default();
|
||||
}
|
||||
|
||||
/// Cache the history rows left above the composer for the current terminal size.
|
||||
pub(crate) fn set_visible_history_rows(&mut self, rows: u16) {
|
||||
self.visible_history_rows = Some(rows.max(/*other*/ 1));
|
||||
}
|
||||
|
||||
/// Return the last viewport budget without querying the terminal during cell replay.
|
||||
pub(crate) fn visible_history_rows(&self) -> Option<u16> {
|
||||
self.visible_history_rows
|
||||
}
|
||||
|
||||
/// Record the width observed during a draw and report whether it is new or changed.
|
||||
///
|
||||
/// The first observed width initializes the state without scheduling a rebuild because no
|
||||
@@ -178,6 +189,24 @@ pub(crate) struct TranscriptWidthChange {
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn visible_history_rows_are_cached_for_resize_replay() {
|
||||
let mut state = TranscriptReflowState::default();
|
||||
|
||||
state.set_visible_history_rows(/*rows*/ 19);
|
||||
|
||||
assert_eq!(state.visible_history_rows(), Some(19));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn visible_history_rows_keep_one_row_for_a_full_height_composer() {
|
||||
let mut state = TranscriptReflowState::default();
|
||||
|
||||
state.set_visible_history_rows(/*rows*/ 0);
|
||||
|
||||
assert_eq!(state.visible_history_rows(), Some(1));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn schedule_debounced_postpones_existing_reflow() {
|
||||
let mut state = TranscriptReflowState::default();
|
||||
|
||||
Reference in new issue
Block a user