# gpui: Refactor follow_tail implementation to fix scroll snapping bugs \(\#53101\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/2fbf83049ff924b8612365fa7c19b65c7d7e1e07)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 2fbf83049ff924b8612365fa7c19b65c7d7e1e07

Requested commit: 2fbf83049ff924b8612365fa7c19b65c7d7e1e07

Commit: 2fbf83049ff924b8612365fa7c19b65c7d7e1e07

Tree: 4f415dffbe99aad0d0cae6650dd994a93fc04fcd

Author: Danilo Leal

Committer: GitHub

## Message

```
gpui: Refactor follow_tail implementation to fix scroll snapping bugs (#53101)

Follow up to https://github.com/zed-industries/zed/pull/53017

This PR does some significant refactoring of the `follow_tail` feature
in the GPUI list. That's only used by the agent panel's thread view and
given to the height-changing nature of streaming agent responses, we
were seeing some scroll snapping bugs upon scrolling while the thread is
generating. In the process of fixing it, we introduced a
`remeasure_items` method as an alternative to `splice` so that we could
get the remeasurement fix without scroll position changes. We already
had a `remeasure` method that did that for all of the indexes, but we
needed something more scoped out for the agent panel case, so as to not
remeasure the entire list's content on every new streamed token.

Effectively, this ends up reverting what the PR linked above introduced,
but it improved the API in the process.
 
Release Notes:

- N/A

Co-authored-by: Mikayla Maki <mikayla.c.maki@gmail.com>
```

## Parents

- [203f48d25cfd1a923a70941bdb388109f06d6e13](https://git.cafe/gitcafe/zed/commit/203f48d25cfd1a923a70941bdb388109f06d6e13?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/2fbf83049ff924b8612365fa7c19b65c7d7e1e07?format=markdown)
