fix(web): complete thread position restore only against the switched thread's rows #12222
Closedsaphid(GitHub profile, opens in a new tab)wants to merge 7 commits into
main fromrefs/pull/12222/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:S
- apps/web/src/components/chat/MessagesTimeline.tsx line 896Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -856,3 +861,12 @@856861 const position = rememberedPosition;857862 const index = position ? rows.findIndex((row) => row.id === position.rowId) : -1;858863 if (position?.atEnd === false) onManualNavigation();864+ if (position?.atEnd === false && index < 0) {865+ // The displayed rows may briefly be a paint-only projection of another866+ // thread. Restoring against those would clamp the offset and mark the867+ // restoration done before the real rows arrive, so wait for rows that868+ // contain the saved anchor (bounded) before falling back.869+ if (restoreDeadlineRef.current === null) {870+ restoreDeadlineRef.current = Date.now() + 2_000;871+ }872+ if (Date.now() < restoreDeadlineRef.current) {
- apps/web/src/components/chat/MessagesTimeline.tsx lines 872 to 873OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -856,3 +861,13 @@856861 const position = rememberedPosition;857862 const index = position ? rows.findIndex((row) => row.id === position.rowId) : -1;858863 if (position?.atEnd === false) onManualNavigation();864+ if (position?.atEnd === false && index < 0) {865+ // The displayed rows may briefly be a paint-only projection of another866+ // thread. Restoring against those would clamp the offset and mark the867+ // restoration done before the real rows arrive, so wait for rows that868+ // contain the saved anchor (bounded) before falling back.869+ if (restoreDeadlineRef.current === null) {870+ restoreDeadlineRef.current = Date.now() + 2_000;871+ }872+ if (Date.now() < restoreDeadlineRef.current) {873+ return;
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:S
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
- apps/web/src/components/chat/MessagesTimeline.tsx line 906OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -864,2 +886,21 @@864886 if (position?.atEnd === false) onManualNavigation();865887 if (cancelPositionRestoreRef) cancelPositionRestoreRef.current = cancelRestoration;888+ if (position?.atEnd === false && index < 0) {889+ // The displayed rows may briefly be a paint-only projection of another890+ // thread. Restoring against those would clamp the offset and mark the891+ // restoration done before the real rows arrive, so wait for rows that892+ // contain the saved anchor (bounded) before falling back. Gestures keep893+ // cancelling through the wait, and the wait always terminates.894+ if (restoreDeadlineRef.current === null) {895+ restoreDeadlineRef.current = Date.now() + 2_000;896+ }897+ if (Date.now() < restoreDeadlineRef.current) {898+ waitTimer = setTimeout(899+ () => {900+ if (!cancelled) setRestoreWaitTick((tick) => tick + 1);901+ },902+ restoreDeadlineRef.current - Date.now() + 25,903+ );904+ return detach;905+ }906+ restoreDeadlineRef.current = null;
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
juliusmarminge closed this
Sign in to join this conversation.







macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed