mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Render completed assistant messages directly during replay (#42325)
## Why Buffered thread snapshots can contain both streaming deltas and the completed assistant item. Replaying both reconstructs an already-finished stream instead of restoring its finalized transcript entry. ## What changed - Omit superseded assistant deltas from replay snapshots when a matching completed item follows them. - Preserve unfinished or unrelated deltas and treat other events as replay barriers so text needed before tools or prompts is not dropped. - Render completed replay items directly as formatted history cells while preserving message order, separators, and composer drafts. ## Testing Added replay tests covering completed, unfinished, unrelated, and barrier-separated deltas, plus deterministic Markdown rendering and draft preservation. GitOrigin-RevId: 2870b09a04b32c0a4c0e9ab76970a8ebc3f5a7d4
This commit is contained in:
1 parent
637c3227b3
commit
e6ff749506
8 files changed
+246
-15
No files matched your search
@@ -330,7 +330,28 @@ impl ChatWidget {
|
||||
}
|
||||
}
|
||||
let parsed = parse_assistant_markdown(&message, self.config.cwd.as_path());
|
||||
self.finalize_completed_assistant_message(Some(parsed.visible_markdown.as_str()));
|
||||
if from_replay && self.stream_controller.is_none() && !parsed.visible_markdown.is_empty() {
|
||||
self.prepare_assistant_message();
|
||||
self.mark_safety_buffering_agent_message_started();
|
||||
self.bottom_pane.hide_status_indicator();
|
||||
let context = self.thread_id.and_then(|thread_id| {
|
||||
crate::inline_visualization::InlineVisualizationContext::from_config(
|
||||
&self.config,
|
||||
thread_id,
|
||||
)
|
||||
});
|
||||
self.add_to_history(
|
||||
history_cell::AgentMarkdownCell::new_with_inline_visualizations(
|
||||
parsed.visible_markdown.clone(),
|
||||
self.config.cwd.as_path(),
|
||||
context,
|
||||
),
|
||||
);
|
||||
self.handle_stream_finished();
|
||||
self.request_redraw();
|
||||
} else {
|
||||
self.finalize_completed_assistant_message(Some(parsed.visible_markdown.as_str()));
|
||||
}
|
||||
if matches!(item.phase, Some(MessagePhase::FinalAnswer) | None)
|
||||
&& !parsed.visible_markdown.is_empty()
|
||||
{
|
||||
@@ -453,20 +474,7 @@ impl ChatWidget {
|
||||
self.mark_safety_buffering_agent_message_started();
|
||||
}
|
||||
if self.stream_controller.is_none() {
|
||||
// Before starting an agent stream, flush any active exec cell group.
|
||||
self.flush_unified_exec_wait_streak();
|
||||
self.flush_active_cell();
|
||||
// If the previous turn inserted non-stream history (exec output, patch status, MCP
|
||||
// calls), render a separator before starting the next streamed assistant message.
|
||||
if self.transcript.needs_final_message_separator && self.transcript.had_work_activity {
|
||||
self.add_to_history(history_cell::FinalMessageSeparator::new(
|
||||
/*elapsed_seconds*/ None, /*runtime_metrics*/ None,
|
||||
));
|
||||
self.transcript.needs_final_message_separator = false;
|
||||
} else if self.transcript.needs_final_message_separator {
|
||||
// Reset the flag even if we don't show separator (no work was done)
|
||||
self.transcript.needs_final_message_separator = false;
|
||||
}
|
||||
self.prepare_assistant_message();
|
||||
let inline_visualization_context = self.thread_id.and_then(|thread_id| {
|
||||
crate::inline_visualization::InlineVisualizationContext::from_config(
|
||||
&self.config,
|
||||
|
||||
Reference in new issue
Block a user