Thanks for the quick response 🙌
I was actually doing the same thing already using onChange, and it works fine in simpler scenarios.
In my case, I’m building an AI chat app where responses are streamed and can get very long (for example, asking it to write a 1000-word essay). When these large streaming responses come in repeatedly, and the user scrolls somewhere in the middle of the chat and sends a new message, I noticed that sometimes the scroll doesn’t return to the expected position based on the message .id.
What helped a lot in my case was flipping the scroll view upside down so new messages naturally appear at the bottom. After doing this, the scrolling behavior became much more stable with long, continuously updating content.
.flippedUpsideDown()
func flippedUpsideDown() -> some View {
self
.rotationEffect(.radians(.pi))
.scaleEffect(x: -1, y: 1, anchor: .center)
}