Preserve voice caption order when replaying TUI history (#44749)

## Why

Retained voice captions were appended after replayed history, placing earlier speech after later typed turns when switching back to a thread.

## What changed

Anchor completed captions to the next live turn and restore them before that turn during replay. Handle buffered item, delta, and completion events even when the turn-start event has been evicted. Restore remaining captions at the end of replay.

## Testing

Extend regression coverage to verify caption order and avoid duplicates across repeated thread switches. Add coverage for inactive-thread captions replayed before a later buffered turn without its start event, with and without a message delta.

GitOrigin-RevId: 6860a649bdcdda4937afb3ab4bbd75cf4ea5b4e6
This commit is contained in:
Benjamin Carlsson authored and copyberry committed 2026-09-11 06:56:37 +00:00
1 parent eab107fed0
commit ab95cd4dd9
9 files changed
+220 -14

No files matched your search

@@ -1,7 +1,7 @@
---
source: tui/src/app/tests/realtime_requests.rs
assertion_line: 182
expression: "rendered.replace(&app.config.cwd.display().to_string(), \"/tmp/project\")"
assertion_line: 1023
expression: "normalize_voice_snapshot_directory(&rendered, &app.config.cwd)"
---
╭────────────────────────────────────────╮
│ >_ OpenAI Codex (v0.0.0) │
@@ -17,4 +17,7 @@ expression: "rendered.replace(&app.config.cwd.display().to_string(), \"/tmp/proj
/permissions - choose what Codex is allowed to do
/model - choose what model and reasoning effort to use
/review - review any changes and find issues
• Earlier answer
• spoken complete
› Later typed question