David Jensen f88e54eed5 agent_ui: Open tool call locations for files that are not text (#67092)
## 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>
2026-11-18 12:56:01 +00:00
…
…
2026-11-17 12:43:21 +00:00
…
2026-11-17 12:43:21 +00:00
2026-11-17 12:43:21 +00:00
…
…
…
…

Zed

Zed CI

Welcome to Zed, a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.


Installation

On macOS, Linux, and Windows you can download Zed directly or install Zed via your local package manager (macOS/Linux/Windows).

Other platforms are not yet available:

Developing Zed

Contributing

See CONTRIBUTING.md for ways you can contribute to Zed.

Also... we're hiring! Check out our jobs page for open roles.

Licensing

Zed source code is licensed primarily under GPL-3.0-or-later, with Apache-2.0 components where marked.

License information for third party dependencies must be correctly provided for CI to pass.

We use cargo-about to automatically comply with open source licenses. If CI is failing, check the following:

  • Is it showing a no license specified error for a crate you've created? If so, add publish = false under [package] in your crate's Cargo.toml.
  • Is the error failed to satisfy license requirements for a dependency? If so, first determine what license the project has and whether this system is sufficient to comply with this license's requirements. If you're unsure, ask a lawyer. Once you've verified that this system is acceptable add the license's SPDX identifier to the accepted array in script/licenses/zed-licenses.toml.
  • Is cargo-about unable to find the license for a dependency? If so, add a clarification field at the end of script/licenses/zed-licenses.toml, as specified in the cargo-about book.

Sponsorship

Zed is developed by Zed Industries, Inc., a for-profit company.

If you’d like to financially support the project, you can do so via GitHub Sponsors. Sponsorships go directly to Zed Industries and are used as general company revenue. There are no perks or entitlements associated with sponsorship.

S
Description
No description provided
Readme 1.6 GiB
Languages
Rust 95.4%
JSON-with-Comments 2.4%
Python 0.8%
Inno Setup 0.3%
Tree-sitter Query 0.3%
Other 0.4%