@@ -920,6 +920,28 @@ async function readWorkspaceState() {
920920 }
921921 return nextWorkspace ;
922922 } ) ;
923+ // Older desktop state can contain multiple OpenWork remote entries that
924+ // normalize to the same `rem_<workspaceId>` after stripping worker mounts.
925+ // Collapse them here so React never receives duplicate workspace keys.
926+ const workspaceIndexById = new Map ( ) ;
927+ const dedupedWorkspaces = [ ] ;
928+ for ( const workspace of migratedWorkspaces ) {
929+ const workspaceId = String ( workspace ?. id ?? "" ) . trim ( ) ;
930+ if ( ! workspaceId ) {
931+ dedupedWorkspaces . push ( workspace ) ;
932+ continue ;
933+ }
934+ const existingIndex = workspaceIndexById . get ( workspaceId ) ;
935+ if ( existingIndex === undefined ) {
936+ workspaceIndexById . set ( workspaceId , dedupedWorkspaces . length ) ;
937+ dedupedWorkspaces . push ( workspace ) ;
938+ continue ;
939+ }
940+ // Keep the later entry: normal mutations replace-then-push refreshed
941+ // remote workspaces, and there is no persisted updatedAt to compare.
942+ dedupedWorkspaces [ existingIndex ] = workspace ;
943+ changed = true ;
944+ }
923945
924946 const migratedSelectedId = idMap . get ( selectedId ) ?? selectedId ;
925947 const migratedWatchedId = watchedId ? idMap . get ( watchedId ) ?? watchedId : null ;
@@ -931,7 +953,7 @@ async function readWorkspaceState() {
931953 migratedSelectedId ,
932954 watchedId : migratedWatchedId ,
933955 activeId : migratedActiveId ,
934- workspaces : migratedWorkspaces ,
956+ workspaces : dedupedWorkspaces ,
935957 } ;
936958
937959 if ( changed ) {
0 commit comments