Skip to content

agent_ui: Show controls after every agent message - #61245

Merged
ChristopherBiscardi merged 2 commits into
zed-industries:mainfrom
peakxy:after-every-turn-has-three-btn
Jul 18, 2026
Merged

agent_ui: Show controls after every agent message#61245
ChristopherBiscardi merged 2 commits into
zed-industries:mainfrom
peakxy:after-every-turn-has-three-btn

Conversation

@peakxy

@peakxy peakxy commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

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

  • 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:

  • I've reviewed my own diff for quality, security, and reliability
  • Unsafe blocks (if any) have justifying comments (no unsafe blocks)
  • The content adheres to Zed's UI standards (UX/UI and icon guidelines)
  • Tests cover the new/changed behavior
  • 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.

CleanShot.2026-07-18.at.15.44.08.mp4

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.

Copilot AI review requested due to automatic review settings July 18, 2026 07:49
@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Jul 18, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_prompt with scroll_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.

Comment thread crates/agent_ui/src/conversation_view/thread_view.rs Outdated
Comment thread crates/agent_ui/src/conversation_view/thread_view.rs
Comment thread crates/agent_ui/src/conversation_view.rs
Comment thread crates/agent_ui/src/conversation_view/thread_view.rs Outdated
@peakxy

peakxy commented Jul 18, 2026

Copy link
Copy Markdown
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😊

@maxdeviant maxdeviant changed the title feat: agent panel support every turn has three btns agent_ui: Show controls after every agent message Jul 18, 2026
@ChristopherBiscardi ChristopherBiscardi self-assigned this Jul 18, 2026

@ChristopherBiscardi ChristopherBiscardi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

@ChristopherBiscardi
ChristopherBiscardi added this pull request to the merge queue Jul 18, 2026
Merged via the queue into zed-industries:main with commit f032f4d Jul 18, 2026
37 checks passed
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
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The Agent Panel should display the three buttons in the bottom-right corner (Copy and two Scroll buttons) during every round of the conversation.

3 participants