Skip to content

Fix TUI stream cleanup after turn errors#23128

Merged
etraut-openai merged 1 commit into
mainfrom
etraut/fix-tui-stream-error-consolidation
May 18, 2026
Merged

Fix TUI stream cleanup after turn errors#23128
etraut-openai merged 1 commit into
mainfrom
etraut/fix-tui-stream-error-consolidation

Conversation

@etraut-openai
Copy link
Copy Markdown
Collaborator

Summary

Fixes #22726.

After a Responses stream disconnect, the live TUI could keep accepting prompts while leaving partially streamed assistant output in its transient streaming-cell form. That made fenced diffs or SVG/XML-like content appear as raw transcript text until the user closed the TUI and resumed the same session, which rebuilt the transcript from saved history.

This change finalizes the active answer stream before generic failed-turn cleanup clears the stream controller, so the live transcript takes the same source-backed markdown consolidation path as a successful turn.

Reviewer repro

  1. Start a local Codex TUI session.
  2. Trigger an assistant turn that streams markdown content, especially a fenced diff or SVG/XML-like block.
  3. Force or encounter a non-retry stream disconnect before the turn completes.
  4. Continue using the same still-open TUI session.
  5. Before this fix, the live history can stay raw/plain even though codex resume renders the same session normally.
  6. After this fix, the failed-turn path consolidates the partial stream before rendering the error, so the live TUI keeps normal transcript rendering.

@etraut-openai etraut-openai marked this pull request as ready for review May 17, 2026 08:17
@etraut-openai etraut-openai force-pushed the etraut/fix-tui-stream-error-consolidation branch from 281454e to 0fdd40c Compare May 17, 2026 08:25
@etraut-openai etraut-openai changed the title [codex] Fix TUI stream cleanup after turn errors Fix TUI stream cleanup after turn errors May 17, 2026
Copy link
Copy Markdown
Contributor

@fcoury-oai fcoury-oai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some tested with a custom mock python server that triggers a stream disconnected before completion and it handled it gracefully.

Approved 👍

@etraut-openai etraut-openai merged commit deb159d into main May 18, 2026
31 checks passed
@etraut-openai etraut-openai deleted the etraut/fix-tui-stream-error-consolidation branch May 18, 2026 16:01
@github-actions github-actions Bot locked and limited conversation to collaborators May 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLI TUI remains visually corrupted after stream disconnect, while resumed session renders normally

2 participants