From 409973e0e217a3d271d0bb425085eef077743ac6 Mon Sep 17 00:00:00 2001 From: Benjamin Carlsson Date: Wed, 18 Nov 2026 02:11:46 +0000 Subject: [PATCH] Extract TUI thread resume finalization (#62171) ## What changed Move subscription state updates, history hydration, and resumed session setup into `finish_thread_resume`. Let callers supply a `HistoryHydrationScope` and keep using `HistoryHydrationScope::Initial` for the existing resume path. GitOrigin-RevId: ebb8b422827a2374d8dce194e8d59afe57327f29 --- .../src/app_server_session/rollout_history.rs | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/codex-rs/tui/src/app_server_session/rollout_history.rs b/codex-rs/tui/src/app_server_session/rollout_history.rs index 6921853093..ce014c5761 100644 --- a/codex-rs/tui/src/app_server_session/rollout_history.rs +++ b/codex-rs/tui/src/app_server_session/rollout_history.rs @@ -291,7 +291,7 @@ impl AppServerSession { }) .await; drop(rollout_maintenance_guard); - let mut response: ThreadResumeResponse = match resume_response { + let response: ThreadResumeResponse = match resume_response { Ok(response) => response, Err(TypedRequestError::Server { source, .. }) if params.exclude_turns && is_history_pagination_unsupported(&source) => @@ -313,6 +313,24 @@ impl AppServerSession { )); } }; + self.finish_thread_resume( + local_settings, + &config, + thread_id, + response, + HistoryHydrationScope::Initial, + ) + .await + } + + pub(crate) async fn finish_thread_resume( + &mut self, + local_settings: &crate::local_settings::LocalSettings, + config: &Config, + thread_id: ThreadId, + mut response: ThreadResumeResponse, + scope: HistoryHydrationScope<'_>, + ) -> Result { if let Some(subscribed) = &mut self.attachment_subscribed { *subscribed = true; } @@ -320,9 +338,9 @@ impl AppServerSession { &mut response.thread, response.turns_backwards_cursor.clone(), response.items_backwards_cursor.clone(), - Some(&config), + Some(config), Some(local_settings), - HistoryHydrationScope::Initial, + scope, ) .await?; let fork_parent_title = self