From 6c3f2dbac8295a7ea5dc8a25f5f3782c4bd26f3e Mon Sep 17 00:00:00 2001 From: t Date: Fri, 9 Oct 2026 10:57:18 -0400 Subject: [PATCH] After Playback: scroll via view.scroll, and only when the stop point is off-screen Stop no longer writes the session's scroll directly (everything is a command) and leaves the view alone when the stopped position is visible. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/lib.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 4fc47a9a..f9f6b20b 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -354,10 +354,19 @@ impl SoundApp { self.engine.session_mut().edit.selection = Range::point(pos); } if after_playback { - // After Playback never scrolls while playing, so jump the view to - // the stopped position now; every other mode keeps its view. + // After Playback never scrolls while playing, so bring the stopped + // position into view now (only if it is off-screen); every other + // mode keeps its view. let at = stop_at.max(0); - self.engine.session_mut().edit.zoom.scroll = at; + let (scroll, spp) = { + let z = &self.engine.session().edit.zoom; + (z.scroll, z.samples_per_px.max(0.01)) + }; + let width = f64::from(self.edit_layout.timeline[2] - self.edit_layout.timeline[0]).max(0.0); + let end = scroll.saturating_add((width * spp) as Samples); + if at < scroll || at >= end { + let _ = self.engine.execute("view.scroll", &json!({ "to": at })); + } } self.edit_layout.follow_hold = false; }