## **NOTE:**
I'm new both to Rust and Zed, so it's mostly vibecoded alleged fix for
#57295, just as a PoC of expected behavior that works on macOS. So
please be critical and skeptical of the code, as it may not account for
many nuances and behavior on other platforms.
## Summary
- Fixes #57295: the `Add to Agent Thread` action (or `cmd->`) was a
silent
no-op when a terminal thread was the active conversation in the agent
panel.
- The action's deferred handler only routed through
`active_conversation_view()`,
which returns `None` for `BaseView::Terminal`, so the selection was
dropped.
- Extends the handler with an `else if` branch that, when a terminal
thread is
active, formats the selection as `@<rel-path>:<start>-<end>` (matching
the
mention syntax CLI agents already understand) and pastes it into the
terminal, then focuses the terminal so the user can edit/submit.
## Test plan
- [x] Select a range of lines in a buffer, open a terminal thread in the
agent
panel, invoke `Add to Agent Thread` from the context menu → the
formatted
mention is pasted into the terminal.
- [x] Same flow via the `cmd->` keybinding on macOS.
- [x] Multiple selections in one buffer produce space-separated
mentions.
- [x] `cargo check -p agent_ui` and `./script/clippy -p agent_ui` pass.
## Demo
<img width="2928" height="1920" alt="ScreenShot 2026-05-20 at 21 03 27"
src="https://github.com/user-attachments/assets/dc29f380-a864-4c12-b454-bdb4201f5b8d"
/>
https://github.com/user-attachments/assets/9d3914d8-8ba2-4bcb-be43-78efb342d8a8
## Release Notes:
- Fixed `Add to Agent Thread` being a no-op when a terminal thread is
the active conversation in the agent panel
---------
Co-authored-by: Martin Ye <martin@zed.dev>2 files changedLine totals unavailable