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:
Felipe Coury authored and copyberry committed 2026-08-04 19:05:45 +00:00
1 parent 8bfa49e350
commit 3b8d22ec2c
13 files changed
+721 -125

No files matched your search

+6
View File
@@ -7,6 +7,9 @@ mod fs;
mod history;
pub(crate) use history::HISTORY_ITEM_PAGE_LIMIT;
pub(crate) use history::HISTORY_ITEM_SCAN_LIMIT;
pub(crate) use history::HistoryHydrationScope;
pub(crate) use history::thread_items_page_params;
use crate::bottom_pane::FeedbackAudience;
use crate::legacy_core::config::Config;
@@ -578,6 +581,7 @@ impl AppServerSession {
response.turns_backwards_cursor.clone(),
response.items_backwards_cursor.clone(),
Some(&config),
HistoryHydrationScope::Initial,
)
.await?;
let fork_parent_title = self
@@ -691,6 +695,7 @@ impl AppServerSession {
/*turn_cursor*/ None,
/*item_cursor*/ None,
Some(&config),
HistoryHydrationScope::Initial,
)
.await?;
}
@@ -824,6 +829,7 @@ impl AppServerSession {
/*turn_cursor*/ None,
/*item_cursor*/ None,
/*config*/ None,
HistoryHydrationScope::Initial,
)
.await?;
Ok(response.thread)