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
3bc55a48dfDanilo Leal committed on 4/2/2026, 3:10:10 AM· committed by GitHubparent20368ba
1 file changedLine totals unavailable