@@ -328,6 +328,7 @@ import {
328328 hasServerAcknowledgedLocalDispatch ,
329329 isBranchMismatchDismissedForSession ,
330330 shouldDockDraftHeroForSubmission ,
331+ shouldReleaseTimelineAnchorForToolActivity ,
331332 shouldShowBranchMismatchBanner ,
332333 getStartedThreadModelChangeBlockReason ,
333334 LAST_INVOKED_SCRIPT_BY_PROJECT_KEY ,
@@ -1756,6 +1757,12 @@ function ChatViewContent(props: ChatViewProps) {
17561757 return openTerminalThreadKeys . filter ( ( nextThreadKey ) => existingThreadKeys . has ( nextThreadKey ) ) ;
17571758 } , [ draftThreadKeys , openTerminalThreadKeys , serverThreadKeys ] ) ;
17581759 const activeLatestTurn = activeThread ?. latestTurn ?? null ;
1760+ const activeRunningTurnId =
1761+ activeThread ?. session ?. status === "running"
1762+ ? activeThread . session . activeTurnId
1763+ : activeLatestTurn ?. state === "running"
1764+ ? activeLatestTurn . turnId
1765+ : null ;
17591766 // Reading a finished thread clears the sidebar's Done badge. The visit is
17601767 // stamped at the turn's completion time — not now/updatedAt — so it clears
17611768 // exactly the completion the user is looking at: a wake or completion that
@@ -3895,6 +3902,8 @@ function ChatViewContent(props: ChatViewProps) {
38953902 liveFollowUserScrollGenerationRef . current = anchorUserScrollGenerationRef . current ;
38963903 setTimelineLiveFollowEnabled ( true ) ;
38973904 pendingTimelineAnchorRef . current = null ;
3905+ positionedTimelineAnchorRef . current = null ;
3906+ settledTimelineAnchorRef . current = null ;
38983907 activeTimelineAnchorIndexRef . current = null ;
38993908 showScrollDebouncer . current . cancel ( ) ;
39003909 setShowScrollToBottom ( false ) ;
@@ -3903,6 +3912,28 @@ function ChatViewContent(props: ChatViewProps) {
39033912 void legendListRef . current ?. scrollToEnd ?.( { animated } ) ;
39043913 } ) ;
39053914 } , [ ] ) ;
3915+ useLayoutEffect ( ( ) => {
3916+ if ( timelineScrollModeRef . current !== "anchoring-new-turn" ) {
3917+ return ;
3918+ }
3919+
3920+ if (
3921+ shouldReleaseTimelineAnchorForToolActivity ( {
3922+ anchorMessageId : timelineAnchorMessageId ,
3923+ liveFollowEnabled : timelineLiveFollowEnabled ,
3924+ runningTurnId : activeRunningTurnId ,
3925+ timelineEntries,
3926+ } )
3927+ ) {
3928+ scrollToEnd ( ) ;
3929+ }
3930+ } , [
3931+ activeRunningTurnId ,
3932+ scrollToEnd ,
3933+ timelineAnchorMessageId ,
3934+ timelineEntries ,
3935+ timelineLiveFollowEnabled ,
3936+ ] ) ;
39063937 useEffect ( ( ) => {
39073938 let removeListeners : ( ( ) => void ) | null = null ;
39083939 let frame : number | null = null ;
@@ -6640,11 +6671,7 @@ function ChatViewContent(props: ChatViewProps) {
66406671 listRef = { legendListRef }
66416672 timelineEntries = { timelineEntries }
66426673 latestTurn = { activeLatestTurn }
6643- runningTurnId = {
6644- activeThread . session ?. status === "running"
6645- ? activeThread . session . activeTurnId
6646- : null
6647- }
6674+ runningTurnId = { activeRunningTurnId }
66486675 turnDiffSummaryByAssistantMessageId = { turnDiffSummaryByAssistantMessageId }
66496676 activeThreadEnvironmentId = { activeThread . environmentId }
66506677 routeThreadKey = { routeThreadKey }
0 commit comments