codex: address PR review feedback (#16803)

Match section breaks when reconciling completed reasoning snapshots against streamed deltas.
This commit is contained in:
Eric Traut
2026-04-04 12:03:25 -07:00
parent 533dbd5b69
commit dfb4e002eb
3 changed files with 89 additions and 2 deletions
+5 -2
View File
@@ -6016,9 +6016,12 @@ impl ChatWidget {
ThreadItem::Reasoning {
summary, content, ..
} => {
let mut completed_reasoning = summary.join("");
let mut completed_reasoning = summary.join("\n\n");
if self.config.show_raw_agent_reasoning {
completed_reasoning.push_str(&content.join(""));
if !completed_reasoning.is_empty() && !content.is_empty() {
completed_reasoning.push_str("\n\n");
}
completed_reasoning.push_str(&content.join("\n\n"));
}
let streamed_reasoning =
format!("{}{}", self.full_reasoning_buffer, self.reasoning_buffer);
@@ -0,0 +1,7 @@
---
source: tui/src/chatwidget/tests/history_replay.rs
expression: rendered
---
• prefix middle
tail
@@ -1,4 +1,5 @@
use super::*;
use codex_app_server_protocol::ReasoningSummaryPartAddedNotification;
use pretty_assertions::assert_eq;
#[tokio::test]
@@ -826,6 +827,82 @@ async fn live_reasoning_item_completed_backfills_missing_prefix_before_streamed_
);
}
#[tokio::test]
async fn live_reasoning_item_completed_backfills_missing_prefix_across_section_breaks() {
let (mut chat, mut rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
chat.show_welcome_banner = false;
chat.handle_server_notification(
ServerNotification::TurnStarted(TurnStartedNotification {
thread_id: "thread-1".to_string(),
turn: AppServerTurn {
id: "turn-1".to_string(),
items: Vec::new(),
status: AppServerTurnStatus::InProgress,
error: None,
},
}),
/*replay_kind*/ None,
);
let _ = drain_insert_history(&mut rx);
chat.handle_server_notification(
ServerNotification::ReasoningSummaryTextDelta(ReasoningSummaryTextDeltaNotification {
thread_id: "thread-1".to_string(),
turn_id: "turn-1".to_string(),
item_id: "reasoning-1".to_string(),
delta: "middle".to_string(),
summary_index: 0,
}),
/*replay_kind*/ None,
);
chat.handle_server_notification(
ServerNotification::ReasoningSummaryPartAdded(ReasoningSummaryPartAddedNotification {
thread_id: "thread-1".to_string(),
turn_id: "turn-1".to_string(),
item_id: "reasoning-1".to_string(),
summary_index: 1,
}),
/*replay_kind*/ None,
);
chat.handle_server_notification(
ServerNotification::ReasoningSummaryTextDelta(ReasoningSummaryTextDeltaNotification {
thread_id: "thread-1".to_string(),
turn_id: "turn-1".to_string(),
item_id: "reasoning-1".to_string(),
delta: "tail".to_string(),
summary_index: 1,
}),
/*replay_kind*/ None,
);
chat.handle_server_notification(
ServerNotification::ItemCompleted(ItemCompletedNotification {
thread_id: "thread-1".to_string(),
turn_id: "turn-1".to_string(),
item: AppServerThreadItem::Reasoning {
id: "reasoning-1".to_string(),
summary: vec!["prefix middle".to_string(), "tail".to_string()],
content: Vec::new(),
},
}),
/*replay_kind*/ None,
);
let rendered = match rx.try_recv() {
Ok(AppEvent::InsertHistoryCell(cell)) => {
lines_to_single_string(&cell.transcript_lines(/*width*/ 80))
}
other => panic!("expected InsertHistoryCell, got {other:?}"),
};
assert_eq!(rendered.matches("prefix middle").count(), 1);
assert!(rendered.contains("tail"));
assert_chatwidget_snapshot!(
"live_reasoning_item_completed_backfills_missing_prefix_across_section_breaks",
rendered
);
}
#[tokio::test]
async fn replayed_turn_started_does_not_mark_task_running() {
let (mut chat, _rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;