@@ -75,7 +75,7 @@ import {
7575 ThreadInspectorContentStack ,
7676 type ThreadInspectorMode ,
7777} from "./thread-inspector-content-stack" ;
78- import { resolveAppliedThreadViewBoundary , resolveThreadViewCommand } from "./threadViewState" ;
78+ import { resolveThreadViewCommand , resolveThreadViewTrackingState } from "./threadViewState" ;
7979
8080interface ThreadInspectorSelection {
8181 readonly routeThreadIdentity : string | null ;
@@ -292,11 +292,25 @@ function ThreadRouteContent(
292292 const selectedThreadViewedAtRef = useRef ( selectedThread ?. viewedAt ) ;
293293 selectedThreadViewedAtRef . current = selectedThread ?. viewedAt ;
294294 const requestedThreadViewBoundariesRef = useRef ( new Set < string > ( ) ) ;
295- const appliedThreadViewBoundary = resolveAppliedThreadViewBoundary ( {
296- completedAt : selectedThreadCompletedAt ,
297- viewedAt : selectedThread ?. viewedAt ,
298- requestedBoundaries : requestedThreadViewBoundariesRef . current ,
299- } ) ;
295+ const [ threadViewRetryBoundary , setThreadViewRetryBoundary ] = useState < string > ( ) ;
296+ useEffect ( ( ) => {
297+ requestedThreadViewBoundariesRef . current . clear ( ) ;
298+ setThreadViewRetryBoundary ( undefined ) ;
299+ } , [ selectedThreadEnvironmentId , selectedThreadId ] ) ;
300+ useEffect ( ( ) => {
301+ const trackingState = resolveThreadViewTrackingState ( {
302+ completedAt : selectedThreadCompletedAt ,
303+ viewedAt : selectedThread ?. viewedAt ,
304+ requestedBoundaries : requestedThreadViewBoundariesRef . current ,
305+ retryBoundary : threadViewRetryBoundary ,
306+ } ) ;
307+ if ( trackingState . shouldClearRequestedBoundaries ) {
308+ requestedThreadViewBoundariesRef . current . clear ( ) ;
309+ }
310+ if ( trackingState . retryBoundary !== threadViewRetryBoundary ) {
311+ setThreadViewRetryBoundary ( trackingState . retryBoundary ) ;
312+ }
313+ } , [ selectedThread ?. viewedAt , selectedThreadCompletedAt , threadViewRetryBoundary ] ) ;
300314 const supportsThreadViewState = serverConfig ?. environment . capabilities . threadViewState === true ;
301315 const [ appState , setAppState ] = useState ( ( ) => AppState . currentState ) ;
302316 useEffect ( ( ) => {
@@ -315,19 +329,10 @@ function ThreadRouteContent(
315329 appState,
316330 connectionState : routeConnectionState ,
317331 completedAt : selectedThreadCompletedAt ,
318- viewedAt : appliedThreadViewBoundary ?? selectedThreadViewedAtRef . current ,
332+ viewedAt : selectedThreadViewedAtRef . current ,
319333 supported : supportsThreadViewState ,
320334 } ) ;
321- if ( command === undefined ) {
322- if (
323- selectedThreadCompletedAt !== null &&
324- selectedThreadViewedAtRef . current !== undefined &&
325- Date . parse ( selectedThreadViewedAtRef . current ) >= Date . parse ( selectedThreadCompletedAt )
326- ) {
327- requestedThreadViewBoundariesRef . current . clear ( ) ;
328- }
329- return ;
330- }
335+ if ( command === undefined ) return ;
331336
332337 requestedThreadViewBoundariesRef . current . add ( command . viewedThrough ) ;
333338 void viewThread ( {
@@ -339,12 +344,12 @@ function ThreadRouteContent(
339344 } ) ;
340345 } , [
341346 appState ,
342- appliedThreadViewBoundary ,
343347 routeConnectionState ,
344348 selectedThreadCompletedAt ,
345349 selectedThreadEnvironmentId ,
346350 selectedThreadId ,
347351 supportsThreadViewState ,
352+ threadViewRetryBoundary ,
348353 viewThread ,
349354 ] ) ,
350355 ) ;
0 commit comments