From fd250378a041828c6b47e4d6913805680f25a08d Mon Sep 17 00:00:00 2001 From: iris <2+iris@noreply.localhost> Date: Mon, 31 Aug 2026 02:04:06 -0400 Subject: [PATCH] Attach the restore hook only while there is a restore `onPlaced` on the transcript content is the one callback left that would run every frame, and on all but the two frames of a restore it looks at a null and returns. Attaching it only while a position is waiting says that in the modifier chain rather than in a branch inside it. Co-Authored-By: Claude Opus 5 --- .../src/main/kotlin/com/example/aiapp/TranscriptScroll.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/androidApp/src/main/kotlin/com/example/aiapp/TranscriptScroll.kt b/app/androidApp/src/main/kotlin/com/example/aiapp/TranscriptScroll.kt index 2e281e0..7888c39 100644 --- a/app/androidApp/src/main/kotlin/com/example/aiapp/TranscriptScroll.kt +++ b/app/androidApp/src/main/kotlin/com/example/aiapp/TranscriptScroll.kt @@ -262,7 +262,10 @@ fun TranscriptColumn( .fillMaxWidth() // Once for the whole list, not once per row: this is where a saved position is put // back, and by placement the scroll container's own measurements describe this layout. - .onPlaced { state.placed() } + // Only while there is a position waiting to be put back. `onPlaced` is the one hook + // here that would otherwise run on every frame, and it has nothing to do on all but + // the two frames of a restore. + .then(if (state.settling) Modifier.onPlaced { state.placed() } else Modifier) // One gesture detector for the whole list; see [TranscriptScroll.tappedHigh]. On the // initial pass and consuming nothing, so every control inside still gets the gesture // exactly as it would have.