mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:50:52 +00:00
Prevent duplicate assistant messages around interleaved commands (#54365)
## Why When a command starts before an assistant message completes, the TUI can flush the streamed text and then render it again when the completion arrives. This duplicates the preamble in both live output and replay. ## What changed Track the turn ID, item ID, and source text of the flushed message. Skip rendering its completion again when the identity and text match, allowing for the trailing newline added during stream finalization. Continue rendering completions whose identity or text differs. ## Testing Add an end-to-end test that delays message completion until a command starts and checks that live and replayed transcripts contain the preamble once. Add regression coverage for completions with different text or item IDs. GitOrigin-RevId: 59af0198a99f26ba8ba2a47644ba662301c30011
This commit is contained in:
@@ -48,6 +48,10 @@ pub(super) struct TranscriptState {
|
||||
/// Latest `/status` card and fields, retained across copying until a later turn or command.
|
||||
pub(super) last_status_copy_targets: Option<StatusCopySource>,
|
||||
pub(super) last_completed_agent_message: Option<(String, String)>,
|
||||
/// Turn and item IDs for the agent message currently supplying streamed deltas.
|
||||
pub(super) active_streamed_agent_message: Option<(String, String)>,
|
||||
/// Turn/item identity and raw source of the latest interleaved stream flush.
|
||||
pub(super) last_flushed_agent_message: Option<((String, String), String)>,
|
||||
/// Raw markdown of the most recently completed proposed plan.
|
||||
pub(super) latest_proposed_plan_markdown: Option<String>,
|
||||
/// Whether this turn already produced a copyable response.
|
||||
@@ -107,6 +111,8 @@ impl TranscriptState {
|
||||
pub(super) fn reset_turn_flags(&mut self) {
|
||||
self.saw_copy_source_this_turn = false;
|
||||
self.last_completed_agent_message = None;
|
||||
self.active_streamed_agent_message = None;
|
||||
self.last_flushed_agent_message = None;
|
||||
self.saw_plan_update_this_turn = false;
|
||||
self.saw_plan_item_this_turn = false;
|
||||
self.latest_proposed_plan_markdown = None;
|
||||
|
||||
Reference in New Issue
Block a user