agent_ui: Add selection to terminal thread - #57301
Merged
MartinYe1234 merged 9 commits intoJun 2, 2026
Merged
Conversation
…minal thread When a terminal thread is active in the agent panel, AddSelectionToThread silently no-ops because the handler only routes through active_conversation_view. Extend the handler to format the editor selection as @<rel-path>:<start>-<end> and paste it into the terminal, mirroring the format CLI agents already accept.
|
We require contributors to sign our Contributor License Agreement, and we don't have @rkiyanchuk on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'. |
Contributor
Author
|
@cla-bot check |
|
The cla-bot has been summoned, and re-checked this pull request! |
|
I’m really looking forward to this feature. It’s so convenient! |
…-add-selection-to-terminal-thread
The agent process inside a terminal thread resolves `@path` mentions relative to its own working directory, not the buffer's worktree root. Emit a path relative to the terminal's working directory when the selection lives under it, and fall back to an absolute path otherwise.
Detect the foreground program of a terminal thread and format the selection mention the way that agent expects. The codex CLI uses bare, cwd-relative paths (quoted when they contain whitespace) with no leading `@`, so emit that form when codex is running and fall back to the generic `@path:line` mention otherwise. Also append a trailing space so the mention doesn't fuse with subsequent input at the prompt.
Cover the terminal-thread branch of the AddSelectionToThread action: a no-op when nothing is highlighted, and the formatted @<rel-path>:<start>-<end> mention once a selection exists.
Drop the per-CLI mention formatting and foreground-process detection. Selections added to a terminal thread are now always pasted as <path>:<start>-<end>, with no provider-specific quoting or prefix.
MartinYe1234
approved these changes
Jun 2, 2026
Contributor
|
Thanks for your contribution @rkiyanchuk , I made a few fixes and added a test. |
dandv
pushed a commit
to dandv/zed
that referenced
this pull request
Jun 3, 2026
## **NOTE:** I'm new both to Rust and Zed, so it's mostly vibecoded alleged fix for zed-industries#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 zed-industries#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>
|
Has this been released? It still does not work for me. |
TomPlanche
pushed a commit
to TomPlanche/zed
that referenced
this pull request
Jun 8, 2026
## **NOTE:** I'm new both to Rust and Zed, so it's mostly vibecoded alleged fix for zed-industries#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 zed-industries#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>
This was referenced Jun 10, 2026
This was referenced Jun 18, 2026
Closed
This was referenced Jul 1, 2026
This was referenced Jul 10, 2026
jonx
pushed a commit
to jonx/zed-aros
that referenced
this pull request
Jul 17, 2026
## **NOTE:** I'm new both to Rust and Zed, so it's mostly vibecoded alleged fix for zed-industries#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 zed-industries#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>
handlename
added a commit
to handlename/ztx
that referenced
this pull request
Jul 26, 2026
Zed's `agent::AddSelectionToThread` (`cmd->`) has worked with Terminal Threads since zed-industries/zed#57301 (merged 2026-06-02, a565ab4): it formats the selection as `@<rel-path>:<start>-<end>` and pastes it into the active terminal thread. Feature 4 existed only to fill that gap. The removal reaches further than the feature itself. `ztx setup zed` installed nothing but the `ztx: send selection` task and its `cmd-alt-z` binding, so it loses its reason to exist along with `ztx send`. Four subcommands remain: run, export, notify, sessions. The IPC paste path had `ztx send` as its only caller. notify's control frames share the socket but not the code path, so the socket, `ipc::send` and one-session-per-project routing all stay. CONTROL_PREFIX (the leading NUL) stays even though every frame is now a control frame: a session started by an older ztx still pastes any non-NUL payload straight into the agent's prompt, so dropping the marker would make a new `ztx notify` spray JSON into it. Non-control frames are now logged and discarded. docs/*/getting-started/zed-setup.md shrinks rather than disappears -- its terminal_init_command section is onboarding content unrelated to selections. Verified manually with Claude Code: `cmd->` pastes the mention and the agent resolves the line range. antigravity-cli is left unverified by decision, not oversight; if it does not resolve `@path:start-end` the fix belongs upstream rather than in a restored `ztx send`. BREAKING CHANGE: the `ztx send` and `ztx setup zed` subcommands are removed. Zed's built-in `cmd->` replaces them. User request: zedのターミナルセッションでも AddSelectionToThread が使えるようになっていたようだ。 zed-industries/zed#57301 つまり、ztx の "Pull editor selections into the session" 機能は不要という事にならないか? Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
16 tasks
jolutz
pushed a commit
to jolutz/zed
that referenced
this pull request
Aug 8, 2026
## **NOTE:** I'm new both to Rust and Zed, so it's mostly vibecoded alleged fix for zed-industries#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 zed-industries#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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
NOTE:
I'm new both to Rust and Zed, so it's a crudely vibecoded 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
Add to Agent Threadaction (orcmd->) was a silentno-op when a terminal thread was the active conversation in the agent panel.
active_conversation_view(),which returns
NoneforBaseView::Terminal, so the selection was dropped.else ifbranch that, when a terminal thread isactive, formats the selection as
@<rel-path>:<start>-<end>(matching themention syntax CLI agents already understand) and pastes it into the
terminal, then focuses the terminal so the user can edit/submit.
Test plan
panel, invoke
Add to Agent Threadfrom the context menu → the formattedmention is pasted into the terminal.
cmd->keybinding on macOS.cargo check -p agent_uiand./script/clippy -p agent_uipass.Demo
zed-selection-insert-agent-panel.mp4
Release Notes:
Add to Agent Threadbeing a no-op when a terminal thread is the active conversation in the agent panel