From 9cdb69739892c5815603029c9572d5c239d228be Mon Sep 17 00:00:00 2001 From: "zed-zippy[bot]" <234243425+zed-zippy[bot]@users.noreply.github.com> Date: Mon, 19 Jan 2026 21:31:37 +0000 Subject: [PATCH] agent: Patch image format bug (#45978) (cherry-pick to preview) (#47174) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cherry-pick of #45978 to preview ---- Closes #44694 Release Notes: - Fixed images being converted to png but retaining old format ## Before: Screenshot 2026-01-02 at 5 34 24 PM ## After: Screenshot 2026-01-02 at 5 34 36 PM --------- Co-authored-by: versecafe <147033096+versecafe@users.noreply.github.com> Co-authored-by: MrSubidubi Co-authored-by: Mason Palmer <97921708+mason-palmer@users.noreply.github.com> Co-authored-by: versecafe <147033096+versecafe@users.noreply.github.com> Co-authored-by: MrSubidubi --- crates/agent_ui/src/mention_set.rs | 6 ++---- crates/language_model/src/request.rs | 3 +++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/crates/agent_ui/src/mention_set.rs b/crates/agent_ui/src/mention_set.rs index 92a9751706debc03abcb819ceabc0dcb3a780e26..ef229e0bb53e91703d75c59a928e999ca6708fb7 100644 --- a/crates/agent_ui/src/mention_set.rs +++ b/crates/agent_ui/src/mention_set.rs @@ -297,14 +297,13 @@ impl MentionSet { return cx.spawn(async move |_, cx| { let image = task.await?; let image = image.update(cx, |image, _| image.image.clone()); - let format = image.format; let image = cx .update(|cx| LanguageModelImage::from_image(image, cx)) .await; if let Some(image) = image { Ok(Mention::Image(MentionImage { data: image.source, - format, + format: LanguageModelImage::FORMAT, })) } else { Err(anyhow!("Failed to convert image")) @@ -672,7 +671,6 @@ pub(crate) fn paste_images_as_context( }; let task = cx .spawn(async move |cx| { - let format = image.format; let image = cx .update(|_, cx| LanguageModelImage::from_image(image, cx)) .map_err(|e| e.to_string())? @@ -681,7 +679,7 @@ pub(crate) fn paste_images_as_context( if let Some(image) = image { Ok(Mention::Image(MentionImage { data: image.source, - format, + format: LanguageModelImage::FORMAT, })) } else { Err("Failed to convert image".into()) diff --git a/crates/language_model/src/request.rs b/crates/language_model/src/request.rs index 96ed0907427c305211b1484e17ab61d434781ed6..e655e964e43847a776d4ba3f5e658b1ceb22a0d0 100644 --- a/crates/language_model/src/request.rs +++ b/crates/language_model/src/request.rs @@ -92,6 +92,9 @@ const DEFAULT_IMAGE_MAX_BYTES: usize = 5 * 1024 * 1024; const MAX_IMAGE_DOWNSCALE_PASSES: usize = 8; impl LanguageModelImage { + // All language model images are encoded as PNGs. + pub const FORMAT: ImageFormat = ImageFormat::Png; + pub fn empty() -> Self { Self { source: "".into(),