agent_ui: Show controls after every agent message - #61245
Merged
ChristopherBiscardi merged 2 commits intoJul 18, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the Agent Panel conversation thread UI so the per-turn action controls (copy response, scroll to the corresponding user prompt, scroll to top) are rendered after every non-blank assistant message, and makes “Scroll to User Message” target the user message associated with that specific assistant response (instead of always jumping to the most recent user message).
Changes:
- Render the thread control bar under each non-blank
AssistantMessage, and gate turn stats + thread feedback controls to the bottom of the thread. - Replace
scroll_to_most_recent_user_promptwithscroll_to_user_message_index(user_message_index: Option<usize>)and wire the per-response “Scroll to User Message” button to the appropriate index. - Update tests to use the new scroll API (and adjust control button IDs to avoid duplicate IDs).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| crates/agent_ui/src/conversation_view/thread_view.rs | Refactors and reuses render_thread_controls per assistant response; adds user-message targeting for scroll; adjusts control rendering/gating. |
| crates/agent_ui/src/conversation_view.rs | Updates existing tests to call the new scroll_to_user_message_index API. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
Author
|
@ChristopherBiscardi Hi, you’ve merged my PR before, so I’d like to trouble you to take a look at this one as well at your convenience😊 |
pull Bot
pushed a commit
to esinanturan/zed
that referenced
this pull request
Jul 20, 2026
…dustries#61362) Follow up to zed-industries#61245. That PR introduced a bug where the thread controls would appear at seemingly random tool boundaries as opposed to only at the end of each turn. It caused this sort of behavior, where we'd have many instances of those buttons showing up: <img width="500" alt="Screenshot 2026-07-20 at 4 03 2@2x" src="https://github.com/user-attachments/assets/6e6f716e-adb5-4532-9f89-e955398cda23" /> Alongside with fixing it, this PR is also making the "scroll to top" only show up only at the very last turn. I think that makes more sense given you'd be most likely interested to go to the top when you're at the bottom, rather than at every turn, but I could be persuaded otherwise; not holding that too strongly. Release Notes: - N/A
This was referenced Jul 31, 2026
jolutz
pushed a commit
to jolutz/zed
that referenced
this pull request
Aug 8, 2026
# Objective Fixes zed-industries#61244 In the Agent Panel, after a multi-turn conversation, the action buttons ("Copy this Agent response", "Scroll to User Message", and "Scroll to top") were only shown after the last assistant response. This was inconvenient for users who wanted to copy or navigate from earlier responses. Additionally, the "Scroll to User Message" button always jumped to the most recent user message in the entire thread, even when clicked from a historical assistant response. This PR addresses both issues by rendering the controls after every non-blank assistant response, and by making "Scroll to User Message" jump to the user prompt associated with that specific response. ## Solution - Refactored `render_thread_controls` in `crates/agent_ui/src/conversation_view/thread_view.rs` to accept an explicit `entry_ix`, `copy_response_index`, `is_thread_bottom`, and `user_message_index`, making it reusable per assistant message. - Rendered the control bar after each non-blank `AssistantMessage` entry, not just the last entry. - Made button IDs unique by using tuple IDs like `("name", entry_ix)`, matching the existing style in this file and avoiding `format!` allocations. - Keyed the copy button ID by the control bar location (`entry_ix`) while still copying `response_index`'s content, so the bottom fallback bar doesn't duplicate IDs with the per-response bar. - Gated the generation/confirmation early return to `is_thread_bottom`, so historical controls remain accessible while the thread is generating or waiting for confirmation. - Gated turn stats and thread feedback buttons to the bottom of the thread so they only appear on the last response. - Replaced `scroll_to_most_recent_user_prompt` with a more general `scroll_to_user_message_index` that takes an optional target user message index. - For each per-response button, computed the associated user message index as the most recent user message before that assistant response. - For the bottom fallback (when the last entry is not an assistant message), passed `None` so the button still scrolls to the most recent user message. - Updated the tooltip from "Scroll to Most Recent User Message" to "Scroll to User Message". - Updated existing tests and added assertions for `scroll_to_user_message_index(Some(ix), cx)`. ## Testing - `cargo check -p agent_ui` - `./script/clippy -p agent_ui` - `cargo test -p agent_ui --lib` (399 passed) - Added assertions in `test_scroll_to_most_recent_user_prompt` to verify `scroll_to_user_message_index(Some(0), cx)` and `scroll_to_user_message_index(Some(2), cx)` scroll to the correct user message indices. - Manual testing recommended: open the Agent Panel, send multiple messages, and verify that each assistant response has the three buttons and that "Scroll to User Message" jumps to the corresponding user prompt. ## Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments (no unsafe blocks) - [x] The content adheres to Zed's UI standards ([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) and [icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md) guidelines) - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable ## Showcase Before: Only the last assistant response in the Agent Panel showed the "Copy this Agent response", "Scroll to User Message", and "Scroll to top" buttons. Clicking "Scroll to User Message" always jumped to the most recent user message. After: Every non-blank assistant response displays these buttons. Clicking "Scroll to User Message" on a historical response scrolls to the user prompt that triggered that specific response. https://github.com/user-attachments/assets/46e02bcc-8bed-4cf3-a08a-9ef91a206d08 --- Release Notes: - Added "Copy this Agent response", "Scroll to User Message", and "Scroll to top" buttons to every agent response in the Agent Panel. - Fixed "Scroll to User Message" so it jumps to the user prompt associated with the current response, rather than the most recent user message.
jolutz
pushed a commit
to jolutz/zed
that referenced
this pull request
Aug 8, 2026
…dustries#61362) Follow up to zed-industries#61245. That PR introduced a bug where the thread controls would appear at seemingly random tool boundaries as opposed to only at the end of each turn. It caused this sort of behavior, where we'd have many instances of those buttons showing up: <img width="500" alt="Screenshot 2026-07-20 at 4 03 2@2x" src="https://github.com/user-attachments/assets/6e6f716e-adb5-4532-9f89-e955398cda23" /> Alongside with fixing it, this PR is also making the "scroll to top" only show up only at the very last turn. I think that makes more sense given you'd be most likely interested to go to the top when you're at the bottom, rather than at every turn, but I could be persuaded otherwise; not holding that too strongly. Release Notes: - N/A
playdohface
pushed a commit
to playdohface/zed
that referenced
this pull request
Aug 29, 2026
# Objective Fixes zed-industries#61244 In the Agent Panel, after a multi-turn conversation, the action buttons ("Copy this Agent response", "Scroll to User Message", and "Scroll to top") were only shown after the last assistant response. This was inconvenient for users who wanted to copy or navigate from earlier responses. Additionally, the "Scroll to User Message" button always jumped to the most recent user message in the entire thread, even when clicked from a historical assistant response. This PR addresses both issues by rendering the controls after every non-blank assistant response, and by making "Scroll to User Message" jump to the user prompt associated with that specific response. ## Solution - Refactored `render_thread_controls` in `crates/agent_ui/src/conversation_view/thread_view.rs` to accept an explicit `entry_ix`, `copy_response_index`, `is_thread_bottom`, and `user_message_index`, making it reusable per assistant message. - Rendered the control bar after each non-blank `AssistantMessage` entry, not just the last entry. - Made button IDs unique by using tuple IDs like `("name", entry_ix)`, matching the existing style in this file and avoiding `format!` allocations. - Keyed the copy button ID by the control bar location (`entry_ix`) while still copying `response_index`'s content, so the bottom fallback bar doesn't duplicate IDs with the per-response bar. - Gated the generation/confirmation early return to `is_thread_bottom`, so historical controls remain accessible while the thread is generating or waiting for confirmation. - Gated turn stats and thread feedback buttons to the bottom of the thread so they only appear on the last response. - Replaced `scroll_to_most_recent_user_prompt` with a more general `scroll_to_user_message_index` that takes an optional target user message index. - For each per-response button, computed the associated user message index as the most recent user message before that assistant response. - For the bottom fallback (when the last entry is not an assistant message), passed `None` so the button still scrolls to the most recent user message. - Updated the tooltip from "Scroll to Most Recent User Message" to "Scroll to User Message". - Updated existing tests and added assertions for `scroll_to_user_message_index(Some(ix), cx)`. ## Testing - `cargo check -p agent_ui` - `./script/clippy -p agent_ui` - `cargo test -p agent_ui --lib` (399 passed) - Added assertions in `test_scroll_to_most_recent_user_prompt` to verify `scroll_to_user_message_index(Some(0), cx)` and `scroll_to_user_message_index(Some(2), cx)` scroll to the correct user message indices. - Manual testing recommended: open the Agent Panel, send multiple messages, and verify that each assistant response has the three buttons and that "Scroll to User Message" jumps to the corresponding user prompt. ## Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments (no unsafe blocks) - [x] The content adheres to Zed's UI standards ([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) and [icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md) guidelines) - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable ## Showcase Before: Only the last assistant response in the Agent Panel showed the "Copy this Agent response", "Scroll to User Message", and "Scroll to top" buttons. Clicking "Scroll to User Message" always jumped to the most recent user message. After: Every non-blank assistant response displays these buttons. Clicking "Scroll to User Message" on a historical response scrolls to the user prompt that triggered that specific response. https://github.com/user-attachments/assets/46e02bcc-8bed-4cf3-a08a-9ef91a206d08 --- Release Notes: - Added "Copy this Agent response", "Scroll to User Message", and "Scroll to top" buttons to every agent response in the Agent Panel. - Fixed "Scroll to User Message" so it jumps to the user prompt associated with the current response, rather than the most recent user message.
playdohface
pushed a commit
to playdohface/zed
that referenced
this pull request
Aug 29, 2026
…dustries#61362) Follow up to zed-industries#61245. That PR introduced a bug where the thread controls would appear at seemingly random tool boundaries as opposed to only at the end of each turn. It caused this sort of behavior, where we'd have many instances of those buttons showing up: <img width="500" alt="Screenshot 2026-07-20 at 4 03 2@2x" src="https://github.com/user-attachments/assets/6e6f716e-adb5-4532-9f89-e955398cda23" /> Alongside with fixing it, this PR is also making the "scroll to top" only show up only at the very last turn. I think that makes more sense given you'd be most likely interested to go to the top when you're at the bottom, rather than at every turn, but I could be persuaded otherwise; not holding that too strongly. Release Notes: - N/A
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.
Objective
Fixes #61244
In the Agent Panel, after a multi-turn conversation, the action buttons ("Copy this Agent response", "Scroll to User Message", and "Scroll to top") were only shown after the last assistant response. This was inconvenient for users who wanted to copy or navigate from earlier responses.
Additionally, the "Scroll to User Message" button always jumped to the most recent user message in the entire thread, even when clicked from a historical assistant response.
This PR addresses both issues by rendering the controls after every non-blank assistant response, and by making "Scroll to User Message" jump to the user prompt associated with that specific response.
Solution
render_thread_controlsincrates/agent_ui/src/conversation_view/thread_view.rsto accept an explicitentry_ix,copy_response_index,is_thread_bottom, anduser_message_index, making it reusable per assistant message.AssistantMessageentry, not just the last entry.("name", entry_ix), matching the existing style in this file and avoidingformat!allocations.entry_ix) while still copyingresponse_index's content, so the bottom fallback bar doesn't duplicate IDs with the per-response bar.is_thread_bottom, so historical controls remain accessible while the thread is generating or waiting for confirmation.scroll_to_most_recent_user_promptwith a more generalscroll_to_user_message_indexthat takes an optional target user message index.Noneso the button still scrolls to the most recent user message.scroll_to_user_message_index(Some(ix), cx).Testing
cargo check -p agent_ui./script/clippy -p agent_uicargo test -p agent_ui --lib(399 passed)test_scroll_to_most_recent_user_promptto verifyscroll_to_user_message_index(Some(0), cx)andscroll_to_user_message_index(Some(2), cx)scroll to the correct user message indices.Self-Review Checklist:
Showcase
Before: Only the last assistant response in the Agent Panel showed the "Copy this Agent response", "Scroll to User Message", and "Scroll to top" buttons. Clicking "Scroll to User Message" always jumped to the most recent user message.
After: Every non-blank assistant response displays these buttons. Clicking "Scroll to User Message" on a historical response scrolls to the user prompt that triggered that specific response.
CleanShot.2026-07-18.at.15.44.08.mp4
Release Notes: