@@ -166,7 +166,6 @@ export function SocketProvider({ children, user }: SocketProviderProps) {
166166 const positionUpdateTimeouts = useRef < Map < string , number > > ( new Map ( ) )
167167 const isRejoiningRef = useRef < boolean > ( false )
168168 const pendingPositionUpdates = useRef < Map < string , any > > ( new Map ( ) )
169- const deletedWorkflowIdRef = useRef < string | null > ( null )
170169
171170 const generateSocketToken = async ( ) : Promise < string > => {
172171 const res = await fetch ( '/api/auth/socket-token' , {
@@ -372,7 +371,6 @@ export function SocketProvider({ children, user }: SocketProviderProps) {
372371
373372 socketInstance . on ( 'workflow-deleted' , ( data ) => {
374373 logger . warn ( `Workflow ${ data . workflowId } has been deleted` )
375- deletedWorkflowIdRef . current = data . workflowId
376374 setCurrentWorkflowId ( ( current ) => {
377375 if ( current === data . workflowId ) {
378376 setPresenceUsers ( [ ] )
@@ -502,11 +500,7 @@ export function SocketProvider({ children, user }: SocketProviderProps) {
502500 if ( error ?. type === 'SESSION_ERROR' ) {
503501 const workflowId = urlWorkflowIdRef . current
504502
505- if (
506- workflowId &&
507- ! isRejoiningRef . current &&
508- deletedWorkflowIdRef . current !== workflowId
509- ) {
503+ if ( workflowId && ! isRejoiningRef . current ) {
510504 isRejoiningRef . current = true
511505 logger . info ( `Session expired, rejoining workflow: ${ workflowId } ` )
512506 socketInstance . emit ( 'join-workflow' , {
@@ -558,25 +552,13 @@ export function SocketProvider({ children, user }: SocketProviderProps) {
558552 const hydrationPhase = useWorkflowRegistryStore ( ( s ) => s . hydration . phase )
559553
560554 useEffect ( ( ) => {
561- if ( ! socket || ! isConnected || ! urlWorkflowId ) {
562- if ( ! urlWorkflowId ) {
563- deletedWorkflowIdRef . current = null
564- }
565- return
566- }
555+ if ( ! socket || ! isConnected || ! urlWorkflowId ) return
567556
568557 if ( hydrationPhase === 'creating' ) return
569558
570559 // Skip if already in the correct room
571560 if ( currentWorkflowId === urlWorkflowId ) return
572561
573- // Prevent rejoining a workflow that was just deleted. The URL param may
574- // still reference the old workflow while router.push() propagates.
575- if ( deletedWorkflowIdRef . current === urlWorkflowId ) {
576- return
577- }
578- deletedWorkflowIdRef . current = null
579-
580562 logger . info (
581563 `URL workflow changed from ${ currentWorkflowId } to ${ urlWorkflowId } , switching rooms`
582564 )
0 commit comments