Stop the macOS transcript jumping while scrolling

This commit is contained in:
Ian Gulliver
2026-10-17 10:14:06 -07:00
parent 1808ca8be6
commit ad458b3a8b
3 changed files with 38 additions and 16 deletions
+9 -5
View File
@@ -495,6 +495,7 @@ private struct TranscriptScroll: View {
@Environment(Store.self) private var store
@Environment(\.paneAccent) private var accent
@ViewState private var position = ScrollPosition(edge: .bottom)
@ViewState private var scrolling = false
var body: some View {
let running = model.running
@@ -536,13 +537,16 @@ private struct TranscriptScroll: View {
.onScrollGeometryChange(for: ScrollMetrics.self) { g in
ScrollMetrics(content: g.contentSize.height, visible: g.visibleRect.height, distance: g.contentSize.height - g.visibleRect.maxY)
} action: { old, new in
if new.content != old.content || new.visible != old.visible {
if model.stuck && new.distance > 1 {
position.scrollTo(edge: .bottom)
}
if scrolling {
model.stuck = new.distance < 80
return
}
model.stuck = new.distance < 80
if model.stuck && new.distance > 1 && (new.content != old.content || new.visible != old.visible) {
position.scrollTo(edge: .bottom)
}
}
.onScrollPhaseChange { _, phase in
scrolling = phase.isScrolling
}
.onChange(of: model.builder.pending.count) {
model.stuck = true