| … | … | @@ -278,217 +349,96 @@ export function useTimelineFollow(input: TimelineFollowInput) { | |
| 462 | - | removeListeners?.(); | |
| 384 | + | } | |
| 385 | + | }; | |
| 386 | + | const handleNavigationStable = useStableCallback(handleNavigation); | |
🟡 Medium chat/useTimelineFollow.ts:386
When a thread switch is followed by find opening, its position-restore navigation can leave the displayed thread in follow mode, so streamed content continues scrolling and new runs continue anchoring despite find releasing follow. handleNavigationStable still uses the previous render's visit when the child layout effect fires before useStableCallback refreshes its implementation in the parent layout effect; ensure the navigation handler resolves the newly attached visit at invocation time.
🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
| 1 | In file @apps/web/src/components/chat/useTimelineFollow.ts around line 386: |
| 2 | |
| 3 | When a thread switch is followed by find opening, its position-restore navigation can leave the displayed thread in follow mode, so streamed content continues scrolling and new runs continue anchoring despite find releasing follow. `handleNavigationStable` still uses the previous render's `visit` when the child layout effect fires before `useStableCallback` refreshes its implementation in the parent layout effect; ensure the navigation handler resolves the newly attached visit at invocation time. |
Real. Child layout effects run before the parent's, so useStableCallback (refreshed in a parent layout effect) still pointed at the previous render's handleNavigation when the position restore fired viewport.navigate from MessagesTimeline's layout effect. Fixed at the source in d5d74f184d: useStableCallback now refreshes in useInsertionEffect, which runs before every layout effect in the commit. apps/web/src/hooks/useStableCallback.browser.test.tsx fails without the fix (second->first) and passes with it.
I can’t verify this yet: d5d74f184d isn’t available from the current branch/history. Please push or share the reachable commit, and I’ll re-check the fix.
Correction: this PR merged at cd5e9f904d before d5d74f184d reached it, so main does not have this fix yet. The commit (the useStableCallback insertion-effect change plus its failing-first test) is on git.cafe branch effect/split-web-timeline-viewport and needs a follow-up PR.
Want me to open a follow-up PR against main? Reply “fix it for me” to confirm.