mirror of
https://github.com/zed-industries/zed.git
synced 2026-12-03 14:01:30 +01:00
## Summary
Clicking a tool call's location label ("Read screenshot.png"), or the
"Go to File" button above image tool output, did nothing for image
files, and each read logged "Binary files are not supported".
`ToolCall::resolve_location` resolves locations by opening a text
buffer, which fails for binary files, and `AgentThreadEntry::location`
required that buffer, so `open_tool_call_location` returned before
opening anything.
`AgentThreadEntry::location` now returns the resolved location as an
`Option<AgentLocation>`. `open_tool_call_location` already opens the
path through the workspace (which picks the image viewer for images), so
the resolved anchor is only used to place the cursor, falling back to
the reported line when unresolved. This also makes a text file location
clickable before resolution finishes. An earlier attempt, #65860, was
closed by the CLA bot without review.
Known limit, unchanged here: when one tool call lists several locations
the label is not clickable (existing `locations.len() == 1` rule), and
every image output's "Go to File" opens the first location, because ACP
doesn't link content blocks to locations.
Implementation and testing were AI-assisted; I understand the fix as
described above and tested it locally.
Closes #65823
## Screenshots
<img width="1100" height="700" alt="1-read-tool-call"
src="https://github.com/user-attachments/assets/8c499ffb-9ab0-4a8e-88df-b0a3b5271763"
/>
Read tool call
<img width="1100" height="700" alt="2-image-opened-from-tool-call"
src="https://github.com/user-attachments/assets/8cd9f6e9-1c0d-4f23-ab1d-8672906c4af5"
/>
Image opened from tool call
## Testing
- New test `test_open_tool_call_location_without_resolved_buffer` in
`agent_ui`: a read tool call for a PNG opens a non-editor item for the
file, and a text file clicked before its location resolves opens at the
reported line. Both halves fail on the old code. Existing `acp_thread`
location tests are updated for the new return type.
- `cargo test -p agent_ui -p acp_thread` passes, except
`test_headless_terminal_retains_process_control` in `acp_thread`, which
is also flaky on unchanged `main` (failed 1 of 3 full runs).
`./script/clippy -p agent_ui -p acp_thread` is clean. macOS only.
- Manual on macOS: had pi-acp read a PNG and clicked the tool call
label, which opened the image viewer. pi-acp renders images as markdown
links rather than ACP image content, so the "Go to File" button on image
output is covered by the test only.
## Self-review
- [ ] I've reviewed my diff for quality, security, reliability, and
performance.
- [x] UI changes follow the
[checklist](https://zed.dev/docs/development/ui-checklist).
- [x] Tests cover the new or changed behavior.
Release Notes:
- Fixed "Go to File" on agent tool calls doing nothing for image files
Co-authored-by: David Jensen <288440181+daejey@users.noreply.github.com>