Commit 29ea190
agent_ui: Fix pasted image context showing Image instead of actual filename (zed-industries#52082)
## What
Fix image context mentions always showing the generic label `Image`
instead of the actual filename when pasting from Finder or picking via
the `+` → Image button in the Agent Panel.
## Why
`insert_images_as_context` hardcoded the crease label to
`MentionUri::PastedImage.name()` (`"Image"`) for every image, regardless
of whether it originated from a named file. Both code paths that load
images from file paths — `paste_images_as_context` and
`add_images_from_picker` — discarded the filename before passing images
to the shared insert function.
## Fix
- `agent_ui/src/mention_set.rs`: Changed `insert_images_as_context` to
accept `Vec<(gpui::Image, SharedString)>` instead of `Vec<gpui::Image>`,
using the provided name as the crease label. In
`paste_images_as_context`, extract `file_name()` from each path and pair
it with the loaded image. Raw clipboard images (screenshots, copy from
image editors) continue to use `"Image"` as there is no filename.
- `agent_ui/src/message_editor.rs`: Same fix for
`add_images_from_picker` — extract `file_name()` from each selected path
and pass it alongside the image.
Closes zed-industries#52079
## Test Plan
- [x] `cargo build -p agent_ui` compiles clean
- [x] `cargo fmt --all -- --check` format check
- [x] Manual verification of:
- [x] Copy an image file in Finder (`Cmd+C`), paste into Agent Panel —
mention shows actual filename
- [x] `+` → Image → pick a file — mention shows actual filename
- [x] Screenshot paste (`Cmd+Shift+4`) still shows `Image`
- [x] Regular text paste still works
## Screenshots
<img width="638" height="569" alt="image"
src="https://github.com/user-attachments/assets/859d852c-66f6-4faa-a5fe-59bd34cd3d85"
/>
---
Release Notes:
- Fixed image context mentions always showing `Image` instead of the
actual filename when pasting from Finder or using the image picker in
the Agent Panel1 parent c890b33 commit 29ea190
2 files changed
Lines changed: 33 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
739 | 739 | | |
740 | 740 | | |
741 | 741 | | |
742 | | - | |
| 742 | + | |
743 | 743 | | |
744 | 744 | | |
745 | 745 | | |
| |||
751 | 751 | | |
752 | 752 | | |
753 | 753 | | |
754 | | - | |
| 754 | + | |
755 | 755 | | |
756 | 756 | | |
757 | 757 | | |
| |||
785 | 785 | | |
786 | 786 | | |
787 | 787 | | |
788 | | - | |
| 788 | + | |
789 | 789 | | |
790 | 790 | | |
791 | 791 | | |
| |||
856 | 856 | | |
857 | 857 | | |
858 | 858 | | |
859 | | - | |
| 859 | + | |
| 860 | + | |
860 | 861 | | |
861 | 862 | | |
862 | | - | |
| 863 | + | |
863 | 864 | | |
864 | 865 | | |
865 | 866 | | |
| |||
870 | 871 | | |
871 | 872 | | |
872 | 873 | | |
873 | | - | |
| 874 | + | |
874 | 875 | | |
875 | 876 | | |
876 | 877 | | |
877 | 878 | | |
878 | 879 | | |
879 | | - | |
880 | | - | |
881 | | - | |
882 | | - | |
883 | | - | |
884 | | - | |
885 | | - | |
886 | | - | |
887 | | - | |
888 | | - | |
889 | | - | |
890 | | - | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
891 | 900 | | |
892 | 901 | | |
893 | 902 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1366 | 1366 | | |
1367 | 1367 | | |
1368 | 1368 | | |
1369 | | - | |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
| 1372 | + | |
| 1373 | + | |
| 1374 | + | |
1370 | 1375 | | |
1371 | 1376 | | |
1372 | 1377 | | |
| |||
0 commit comments