Include the final agent message in turn completion summaries (#34777)

## Why

Streamed message deltas can be dropped when the transport is saturated, leaving
clients with a truncated final response.

## What changed

- Include the last non-empty final agent message in successful `turn/completed`
  notifications and mark the items as a summary.
- Treat completed message content as authoritative in the TUI, repairing an
  incomplete stream while avoiding duplicate messages when `item/completed` was
  already received.
- Continue backfilling full turn items for persisted `codex exec` threads when a
  completion contains only the summary view.

## Testing

Added coverage for completion summaries, dropped stream deltas, duplicate item
handling, and directive-only responses.

GitOrigin-RevId: ffe9d36d683d6b6690e4a468ff68aa9189fe6ab7
This commit is contained in:
Eric Traut authored and copyberry committed 2026-07-22 15:41:47 +00:00
1 parent 730ec92003
commit 80f3c3141e
15 files changed
+275 -56

No files matched your search

@@ -0,0 +1,5 @@
---
source: tui/src/app/tests.rs
expression: "rendered.lines.iter().map(rendered_line_text).collect::<Vec<_>>().join(\"\\n\")"
---
before directive
+36
View File
@@ -5180,6 +5180,42 @@ async fn required_stream_reflow_during_capped_initial_replay_uses_transcript_tai
Ok(())
}
#[tokio::test]
async fn directive_only_completion_removes_streamed_directive() -> Result<()> {
let (mut app, _rx, _op_rx) = make_test_app_with_channels().await;
app.config.terminal_resize_reflow.max_rows = TerminalResizeReflowMaxRows::Limit(20);
app.begin_initial_history_replay_buffer();
app.transcript_cells = vec![
plain_line_cell("before directive"),
Arc::new(AgentMessageCell::new(
vec![Line::from(r#"::git-stage{cwd="/tmp"}"#)],
/*is_first_line*/ true,
)),
];
let mut tui = crate::tui::test_support::make_test_tui()?;
app.handle_consolidate_agent_message(
&mut tui,
String::new(),
PathBuf::from("/tmp"),
/*inline_visualization_context*/ None,
ConsolidationScrollbackReflow::Required,
/*deferred_history_cell*/ None,
)?;
let rendered = app.render_transcript_lines_for_reflow(/*width*/ 80);
assert_snapshot!(
"directive_only_completion_removes_streamed_directive",
rendered
.lines
.iter()
.map(rendered_line_text)
.collect::<Vec<_>>()
.join("\n")
);
Ok(())
}
#[tokio::test]
async fn required_stream_reflow_during_capped_initial_replay_survives_transcript_overlay()
-> Result<()> {