From c9e5bf3cacc1c83a887d3bcb35ab886d62100c27 Mon Sep 17 00:00:00 2001 From: tlongwell-block <109685178+tlongwell-block@users.noreply.github.com> Date: Wed, 8 Jul 2026 18:25:50 -0400 Subject: [PATCH] fix(desktop): drop redundant post-correction re-baseline (single-writer) The RO compensation callback re-snapshotted `readingAnchorRef` right after its `scrollTo`, but the per-rAF loop is documented as the single writer of that ref and re-snapshots from live geometry next frame (~16ms), already reflecting the correction. The extra write made the "single writer" invariant false for no behavioral gain and cost one `snapshotReadingAnchor` row-walk per correction. Remove it so the invariant holds literally. No behavior change: the next rAF re-baselines regardless. Unit tests (computeAnchorCorrection sign + invariance) unaffected, 8/8 green. Follow-up to Quinn's W1 cross-review (hole #2). Co-authored-by: Dawn (sprout agent) Signed-off-by: tlongwell-block <109685178+tlongwell-block@users.noreply.github.com> --- desktop/src/features/messages/ui/useAnchoredScroll.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/desktop/src/features/messages/ui/useAnchoredScroll.ts b/desktop/src/features/messages/ui/useAnchoredScroll.ts index 1aaa0803d..3206347e3 100644 --- a/desktop/src/features/messages/ui/useAnchoredScroll.ts +++ b/desktop/src/features/messages/ui/useAnchoredScroll.ts @@ -704,9 +704,10 @@ export function useAnchoredScroll({ }); if (target !== null) { container.scrollTo({ top: target, behavior: "auto" }); - // Re-baseline after the correction so the next RO batch measures shift - // from where we just pinned, not the pre-correction position. - readingAnchorRef.current = snapshotReadingAnchor(container); + // No re-baseline here: the rAF loop is the single writer of + // `readingAnchorRef` and re-snapshots from live geometry next frame + // (~16ms), which already reflects this correction. Writing it here too + // would make the "single writer" invariant a lie for no gain. } }); // Observe every timeline row (not the content wrapper): a