@@ -48,6 +48,7 @@ import {
4848 collectControlledWorkspaceReleasePayloads ,
4949 getOrCreateClientId as getWorkspaceClientId ,
5050 getOrCreateDeviceId as getWorkspaceDeviceId ,
51+ shouldRecoverWorkspaceController ,
5152} from "../workspace/workspace-controller" ;
5253import { attachWorkspaceRuntimeWithRetry } from "../workspace/runtime-attach" ;
5354import { createWorkspaceSessionActions } from "../workspace/session-actions" ;
@@ -509,10 +510,7 @@ export const WorkbenchRuntimeCoordinator = ({
509510 ( ) => state . tabs
510511 . filter ( ( tab ) =>
511512 tab . status === "ready"
512- && tab . controller . role === "observer"
513- && ! tab . controller . controllerDeviceId
514- && ! tab . controller . controllerClientId
515- && ! tab . controller . takeoverPending ,
513+ && shouldRecoverWorkspaceController ( tab . controller ) ,
516514 )
517515 . map ( ( tab ) => tab . id )
518516 . join ( "|" ) ,
@@ -527,14 +525,13 @@ export const WorkbenchRuntimeCoordinator = ({
527525 const recoverableWorkspaceIds = ( ) => stateRef . current . tabs
528526 . filter ( ( tab ) =>
529527 tab . status === "ready"
530- && tab . controller . role === "observer"
531- && ! tab . controller . controllerDeviceId
532- && ! tab . controller . controllerClientId
533- && ! tab . controller . takeoverPending ,
528+ && shouldRecoverWorkspaceController ( tab . controller ) ,
534529 )
535530 . map ( ( tab ) => tab . id ) ;
536531
537532 const recoverControllers = ( ) => {
533+ // Observer tabs can miss an initial runtime attach/controller event during reloads.
534+ // Reattaching until the tab converges keeps recovery/replay flows stable across slower environments.
538535 void Promise . all ( recoverableWorkspaceIds ( ) . map ( async ( workspaceId ) => {
539536 await reattachWorkspaceRuntime ( workspaceId ) ;
540537 } ) ) ;
0 commit comments