Skip to content

agent_ui: Make thread generation top-down#52440

Merged
danilo-leal merged 15 commits intomainfrom
thread-top-down-generation
Mar 26, 2026
Merged

agent_ui: Make thread generation top-down#52440
danilo-leal merged 15 commits intomainfrom
thread-top-down-generation

Conversation

@danilo-leal
Copy link
Copy Markdown
Member

Ever since we introduced the agent panel the way it is right now back in May 2025, we wanted to make the thread generation be top-down. Now, with the changes we're planning to launch very soon revolving around parallel agents, doing this become even more important for a better experience. Particularly because in the agent panel's new empty state, the message editor is full screen. We want to minimize as much as possible layout shift between writing your first prompt and actually submitting it. So this means that content will stream down from your first prompt and auto-scroll you if it goes beyond the viewport.

To pull this off, we added a follow_tail feature directly to the GPUI list so that we could only call it in the thread view layer as opposed to doing it all there.

Screenshot.2026-03-25.at.3.47.mp4

Release Notes:

  • Agent: Made the thread generation be top-down instead of bottom-up. Agent content now streams from the top and auto-scroll as they go beyond the viewport.

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Mar 25, 2026
@zed-codeowner-coordinator zed-codeowner-coordinator bot requested review from a team, maxbrunsfeld and rtfeldman and removed request for a team March 25, 2026 19:00
@zed-community-bot zed-community-bot bot added the staff Pull requests authored by a current member of Zed staff label Mar 25, 2026
@github-actions

This comment was marked as off-topic.

@github-actions github-actions bot added Size XL and removed Size L labels Mar 26, 2026
content_height - self.scrollbar_drag_start_height.unwrap_or(content_height);
let new_scroll_top = (point.y - drag_offset).abs().max(px(0.)).min(scroll_max);

self.follow_tail = false;
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.

@danilo-leal I found a couple of edge cases this was missing and I just pushed fixes instead of suggestions 😄

This one was for the case where you're dragging the scroll bar around instead of using a ScrollWheel event; I assume we want to disengage follow_tail there too!

Copy link
Copy Markdown
Contributor

@rtfeldman rtfeldman left a comment

Choose a reason for hiding this comment

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

Excited to use this! 😃

@danilo-leal danilo-leal merged commit a3d72e5 into main Mar 26, 2026
31 checks passed
@danilo-leal danilo-leal deleted the thread-top-down-generation branch March 26, 2026 11:52
eholk added a commit that referenced this pull request Apr 2, 2026
This PR fixes an issue where, sometimes, you couldn't scroll all the way
to the bottom of the thread's content. The scrollbar would show up at
the bottom of the scrollable container but the content was visibly cut
off. Turns out that's a consequence of the top-down thread generation
introduced in #52440, where
changing the list alignment to `Top` made it visible that sometimes, the
maximum scroll area would get underestimated because the items in the
thread view's list would have a stale height measurement. So, the way
this PR fixes the issue is by calling `splice_focusable` in the
`EntryUpdated` event, too, so that the height of the items in the
overdraw area get marked as unmeasured, triggering a list re-render and
re-measuring.

We started by writing a test at the list level that would reproduce the
regression but then later figured out that this is not an inherent list
problem; it was rather a problem with its use within the thread view
layer. Then, we explored writing a test that documented the regression,
but it turned out to be very hard to simulate this sort of set up in
which certain elements would have its height changed during streaming,
which would be how you'd get to a mismatched height situation.

Therefore, given `AcpThreadEvent::NewEntry` already called
`splice_focusable` and don't have a test for it, we figure it'd be safe
to move forward without one, too. We then introduced a helper that's now
shared between `AcpThreadEvent::NewEntry` and
`AcpThreadEvent::EntryUpdated`.

Release Notes:

- Agent: Fixed an issue where sometimes you couldn't scroll all the way
to the bottom of the thread even though there's visibly more content
below the fold.

Co-authored-by: Eric Holk <eric@zed.dev>
@admtech
Copy link
Copy Markdown

admtech commented Apr 9, 2026

That’s a nice feature - how can I turn it off again? Why can’t you switch it on or off via a setting? I find it very fiddly to have to look right at the top of a 32-inch monitor for the AI output after I’ve typed something at the bottom. Such fundamental changes to the GUI should always have an on/off switch. I’ve been using Zed since the very beginning, and here and there you’re being a bit too intrusive when it comes to the user interface. Just when you’ve got used to it, you change it again. This feature is yet another jarring break in the GUI. So please, give us an on/off switch. I’d like the output to be placed back where it was, and not 2700 pixels above the input. Thanks.

Update One more minor bug: the scrolling in the new version always eats up the last line when you finally reach the bottom (macOS Version).

@nsxdavid
Copy link
Copy Markdown

Yeah this is a pretty awful change for anyone who considers this the sort of thing you fight against in bad implementations of a scrolling stream. (sigh)

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 large-pr staff Pull requests authored by a current member of Zed staff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants