From 05bc61c428047281ec16cb4070bbb9bee0695b53 Mon Sep 17 00:00:00 2001 From: Roy Han Date: Fri, 27 Feb 2026 11:00:32 -0800 Subject: [PATCH] fix issue with resume --- codex-rs/tui/src/app.rs | 47 ++++++++++++++++++++++++++-------- codex-rs/tui/src/chatwidget.rs | 14 +++++++++- 2 files changed, 49 insertions(+), 12 deletions(-) diff --git a/codex-rs/tui/src/app.rs b/codex-rs/tui/src/app.rs index 8ddb597a6d..ffcf4a3469 100644 --- a/codex-rs/tui/src/app.rs +++ b/codex-rs/tui/src/app.rs @@ -2930,14 +2930,14 @@ impl App { self.pending_shutdown_exit_thread_id = None; } if let EventMsg::SessionConfigured(session) = &event.msg - && let Some(first_cell) = self.transcript_cells.first_mut() - && matches!( - first_cell - .as_ref() - .as_any() - .downcast_ref::(), - Some(startup_header) if startup_header.is_loading_placeholder() - ) + && let Some(loading_header_idx) = self.transcript_cells.iter().rposition(|cell| { + matches!( + cell.as_ref() + .as_any() + .downcast_ref::(), + Some(startup_header) if startup_header.is_loading_placeholder() + ) + }) { let cell = Arc::new(history_cell::SessionHeaderHistoryCell::new( session.model.clone(), @@ -2945,13 +2945,38 @@ impl App { session.cwd.clone(), CODEX_CLI_VERSION, )) as Arc; - *first_cell = cell.clone(); + self.transcript_cells[loading_header_idx] = cell.clone(); if matches!(&self.overlay, Some(Overlay::Transcript(_))) { self.overlay = Some(Overlay::new_transcript(self.transcript_cells.clone())); tui.frame_requester().schedule_frame(); } - let display = cell.display_lines(tui.terminal.last_known_screen_size.width); - tui.replace_top_visible_history_lines(display)?; + if loading_header_idx == 0 { + let display = cell.display_lines(tui.terminal.last_known_screen_size.width); + tui.replace_top_visible_history_lines(display)?; + } else { + self.clear_terminal_ui(tui, false)?; + self.deferred_history_lines.clear(); + + let transcript_cells = self.transcript_cells.clone(); + for transcript_cell in transcript_cells { + let mut display = + transcript_cell.display_lines(tui.terminal.last_known_screen_size.width); + if !display.is_empty() { + if !transcript_cell.is_stream_continuation() { + if self.has_emitted_history_lines { + display.insert(0, Line::from("")); + } else { + self.has_emitted_history_lines = true; + } + } + if self.overlay.is_some() { + self.deferred_history_lines.extend(display); + } else { + tui.insert_history_lines(display); + } + } + } + } } self.handle_codex_event_now(event); if self.backtrack_render_pending { diff --git a/codex-rs/tui/src/chatwidget.rs b/codex-rs/tui/src/chatwidget.rs index d0edd2fcad..e5ba0bc322 100644 --- a/codex-rs/tui/src/chatwidget.rs +++ b/codex-rs/tui/src/chatwidget.rs @@ -3096,6 +3096,7 @@ impl ChatWidget { let header_model = model .clone() .unwrap_or_else(|| session_configured.model.clone()); + let header_reasoning_effort = session_configured.reasoning_effort; let active_collaboration_mask = Self::initial_collaboration_mask(&config, models_manager.as_ref(), model_override); let header_model = active_collaboration_mask @@ -3108,7 +3109,7 @@ impl ChatWidget { spawn_agent_from_existing(conversation, session_configured, app_event_tx.clone()); let fallback_default = Settings { - model: header_model, + model: header_model.clone(), reasoning_effort: None, developer_instructions: None, }; @@ -3237,6 +3238,17 @@ impl ChatWidget { ); widget.update_collaboration_mode_indicator(); + widget + .app_event_tx + .send(AppEvent::InsertHistoryCell(Box::new( + history_cell::SessionHeaderHistoryCell::new( + header_model, + header_reasoning_effort, + widget.config.cwd.clone(), + CODEX_CLI_VERSION, + ), + ))); + widget }