From 3e2f79727a4e8ddfc8e3acb838d496b121094b9e Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Sun, 19 Jul 2026 17:28:28 +0000 Subject: [PATCH] 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 --- codex-rs/tui/src/history_cell/mcp.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/codex-rs/tui/src/history_cell/mcp.rs b/codex-rs/tui/src/history_cell/mcp.rs index b71af3d251..eab2cf2d30 100644 --- a/codex-rs/tui/src/history_cell/mcp.rs +++ b/codex-rs/tui/src/history_cell/mcp.rs @@ -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> { 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, -) -> Option { - let image = result +) -> Option { + 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.