Skip to content

Conversation

@Kbediako
Copy link
Contributor

@Kbediako Kbediako commented Jan 24, 2026

What?

  • Render an MCP image output cell whenever any image block exists in CallToolResult.content.

Why?

  • Tool results that include caption text before the image currently drop the image output cell.

How?

  • Scan content for an ImageContent entry instead of only checking the first block.
  • Add a unit test that covers text-before-image ordering.

Before

let image_output_cell = match call_tool_result.content.first() {
    Some(CallToolResultContent::Image(image_content)) => Some(history_cell::ImageOutputCell {
        context: Some(format!("Called {tool_name}")),
        caption: image_content.annotation().map(str::to_owned),
        data: image_content.data().to_owned(),
        mime_type: image_content.mime_type().to_owned(),
    }),
    _ => None,
};

After

let image_output_cell = call_tool_result
    .content
    .iter()
    .find_map(|content| match content {
        CallToolResultContent::Image(image_content) => Some(history_cell::ImageOutputCell {
            context: Some(format!("Called {tool_name}")),
            caption: image_content.annotation().map(str::to_owned),
            data: image_content.data().to_owned(),
            mime_type: image_content.mime_type().to_owned(),
        }),
        _ => None,
    });

Risk / Impact

  • Low: only affects image cell creation for MCP tool results; no change for non-image outputs.

Tests

  • just fmt
  • cargo test -p codex-tui

Fixes #9814

@Kbediako Kbediako marked this pull request as ready for review January 24, 2026 12:47
@Kbediako Kbediako changed the title fix: render MCP image outputs regardless of ordering Fix: Render MCP image outputs regardless of ordering Jan 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: TUI drops MCP image output when text precedes image

1 participant