mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Paginate TUI transcript history (#36950)
## What changed - Load older transcript items in bounded pages as users scroll upward, and let `Home` continue fetching until the start of the thread. - Show loading, partial-history, retry, and complete states in the transcript overlay while preserving the visible scroll position as pages are prepended. - Use paginated history for resume, fork, retry, and prompt-edit flows, while falling back to legacy history requests when the app server does not support pagination. ## Testing - Cover multi-page transcript loading, page-boundary prompt reconciliation, legacy-server fallback, bounded retry history, and transcript history-state rendering. GitOrigin-RevId: cc6b764bc4185d079b2f68bedf235c1d08278dfb
This commit is contained in:
1 parent
3b8d22ec2c
commit
dbcd837c20
16 files changed
+1019
-169
No files matched your search
@@ -3,9 +3,12 @@
|
||||
use super::session_lifecycle::ThreadAttachPresentation;
|
||||
use super::*;
|
||||
use crate::app_server_session::ForkGoalContinuation;
|
||||
use crate::app_server_session::HISTORY_ITEM_PAGE_LIMIT;
|
||||
use crate::chatwidget::ThreadInputState;
|
||||
use crate::chatwidget::ThreadInputStateRestoreMode;
|
||||
use crate::chatwidget::UserMessage;
|
||||
use codex_app_server_protocol::ThreadHistoryMode;
|
||||
use codex_app_server_protocol::TurnItemsView;
|
||||
use codex_app_server_protocol::UserInput;
|
||||
|
||||
pub(super) struct SafetyBufferedRetry {
|
||||
@@ -76,9 +79,52 @@ impl App {
|
||||
return;
|
||||
}
|
||||
|
||||
let thread = match app_server
|
||||
.thread_read(thread_id, /*include_turns*/ true)
|
||||
.await
|
||||
let thread = match async {
|
||||
let mut thread = app_server
|
||||
.thread_read(thread_id, /*include_turns*/ false)
|
||||
.await?;
|
||||
if thread.history_mode == ThreadHistoryMode::Legacy {
|
||||
app_server
|
||||
.hydrate_initial_thread_history(
|
||||
&mut thread,
|
||||
/*turn_cursor*/ None,
|
||||
/*item_cursor*/ None,
|
||||
/*config*/ None,
|
||||
crate::app_server_session::HistoryHydrationScope::Initial,
|
||||
)
|
||||
.await?;
|
||||
} else {
|
||||
let page = app_server
|
||||
.thread_turns_page(thread_id, /*cursor*/ None)
|
||||
.await?;
|
||||
thread.turns = page.data.into_iter().rev().collect();
|
||||
if let Some(turn_index) = thread.turns.iter().position(|turn| turn.id == turn_id) {
|
||||
let page = app_server
|
||||
.thread_items_page(
|
||||
thread_id,
|
||||
Some(&turn_id),
|
||||
/*cursor*/ None,
|
||||
HISTORY_ITEM_PAGE_LIMIT,
|
||||
)
|
||||
.await?;
|
||||
if page.next_cursor.is_some() {
|
||||
color_eyre::eyre::bail!(
|
||||
"Cannot safely retry a turn whose input exceeds the bounded history page."
|
||||
);
|
||||
}
|
||||
let turn = &mut thread.turns[turn_index];
|
||||
turn.items = page
|
||||
.data
|
||||
.into_iter()
|
||||
.rev()
|
||||
.map(|entry| entry.item)
|
||||
.collect();
|
||||
turn.items_view = TurnItemsView::Full;
|
||||
}
|
||||
}
|
||||
Ok::<_, color_eyre::Report>(thread)
|
||||
}
|
||||
.await
|
||||
{
|
||||
Ok(thread) => thread,
|
||||
Err(err) => {
|
||||
|
||||
Reference in new issue
Block a user