# agent_ui: Improve auto-scroll when editing previous messages \(\#52876\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 3bc55a48df5356af8aed7c3313802e13a053c6bd

Requested commit: 3bc55a48df5356af8aed7c3313802e13a053c6bd

Commit: 3bc55a48df5356af8aed7c3313802e13a053c6bd

Tree: 94576a0fcafff2bfeb2c193350fe73a1c267f529

Author: Danilo Leal

Committer: GitHub

## Message

```
agent_ui: Improve auto-scroll when editing previous messages (#52876)

This PR improves the unreliability of the new top-down flow when editing
previous user messages. Previously, sometimes the thread wouldn't
auto-scroll as you're editing older messages and re-submitting them. It
turns out, the culprit seems to be a bit of a race condition where the
Stopped event (which sets the follow_tail method to false) could still
be emitted a while after a generation has been stopped. So depending on
time, one given possibility could happen. But now, this is what we do:

- If it is still generating, that means the stop/error event is stale
relative to a newer turn, so we do not run the cleanup that disables
follow-tail.
- If it is not generating, then it’s a real completion for the active
turn, and we do the normal cleanup.

--- 

Release Notes:

- N/A
```

## Parents

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

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