Skip to content

Handle standalone image generation failures as terminal items#27920

Merged
won-openai merged 3 commits into
mainfrom
imggenux
Jun 12, 2026
Merged

Handle standalone image generation failures as terminal items#27920
won-openai merged 3 commits into
mainfrom
imggenux

Conversation

@won-openai

@won-openai won-openai commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Why

Standalone image generation emitted a started item but no terminal item when the backend failed. Clients could leave the operation unresolved or render it as successful.

What changed

  • Emit a terminal image-generation item with status: "failed" when generation or editing fails.
  • Skip image persistence for failed terminal items.
  • Render failed image generation distinctly in TUI history.
  • Preserve the status when handling live and replayed terminal items.

Looks for TUI, App-Side change needed

image

Validation

  • just test -p codex-image-generation-extension
  • App-server image-generation tests
  • Core stream-event tests
  • TUI image-generation lifecycle and snapshot tests
  • Scoped Clippy and formatting

Follow-Up

UX Follow-Up incoming for the extension tool

@won-openai
won-openai requested a review from a team as a code owner June 12, 2026 18:00

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0ca854c673

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

call.turn_item_emitter
.emit_completed(ExtensionTurnItem::ImageGeneration(ImageGenerationItem {
id: call.call_id.clone(),
status: "failed".to_string(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge Don’t report failed image generations as generated

When this branch emits a terminal item with status: "failed", the /agent preview still treats every ThreadItem::ImageGeneration as Generated an image (codex-rs/tui/src/app/agent_status_feed.rs:187). In sub-agent activity, a backend failure will therefore still be summarized as a successful generation, which is the client misrendering this change is trying to avoid; please key that summary off the status too.

Useful? React with 👍 / 👎.

@fcoury-oai fcoury-oai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

From a TUI perspective, I think there is an opportunity to align this with the existing failure presentation while preserving the actual failure reason.

The current rendering introduces a bespoke ✗ Image generation failed cell, while MCP, exec, and hook failures generally use a red status marker followed by an indented error detail.

The failed terminal item does not include message and sets result to an empty string. Although the message is returned to the model, clients only receive the prompt and generic failure status not the backend error, which may be important for diagnosing the issue.

Could we propagate the error message on the terminal image-generation item and render it using the existing tool-error convention? For example:

• Image generation failed
  └ Error: <backend error>

We should also apply the existing wrapping and truncation behavior so an unexpectedly large backend response cannot dominate the transcript.

The revised prompt can remain as secondary context if useful, but it should not replace the failure reason.

@won-openai
won-openai merged commit b6baa77 into main Jun 12, 2026
31 checks passed
@won-openai
won-openai deleted the imggenux branch June 12, 2026 18:57
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 12, 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.

3 participants