Avoid retaining decoded MCP images in history cells (#34206)

## Why

The MCP image output cell only renders a fixed placeholder, so it does not need
to keep the decoded image alive for the lifetime of the history cell.

## What changed

Decode image content to validate it, then return a marker cell without storing
the resulting `DynamicImage`. The rendered history output remains unchanged.

GitOrigin-RevId: b2c12d08e8ba281d2bb993a8524d338c26d52b96
This commit is contained in:
Charlie Marsh
2026-07-19 17:36:39 +00:00
committed by copyberry
parent 54994582b1
commit 3e2f79727a
+6 -7
View File
@@ -3,10 +3,9 @@
use super::*;
#[derive(Debug)]
struct CompletedMcpToolCallWithImageOutput {
_image: DynamicImage,
}
impl HistoryCell for CompletedMcpToolCallWithImageOutput {
struct McpImageOutputCell;
impl HistoryCell for McpImageOutputCell {
fn display_lines(&self, _width: u16) -> Vec<Line<'static>> {
vec!["tool result (image output)".into()]
}
@@ -267,15 +266,15 @@ pub(crate) fn new_active_mcp_tool_call(
/// even when the first block is not a valid image.
fn try_new_completed_mcp_tool_call_with_image_output(
result: &Result<codex_protocol::mcp::CallToolResult, String>,
) -> Option<CompletedMcpToolCallWithImageOutput> {
let image = result
) -> Option<McpImageOutputCell> {
result
.as_ref()
.ok()?
.content
.iter()
.find_map(decode_mcp_image)?;
Some(CompletedMcpToolCallWithImageOutput { _image: image })
Some(McpImageOutputCell)
}
/// Decodes an MCP `ImageContent` block into an in-memory image.