diff --git a/apps/desktop/src/renderer/routes/_authenticated/components/V1ImportModal/ImportWorkspacesPage/ImportWorkspacesPage.tsx b/apps/desktop/src/renderer/routes/_authenticated/components/V1ImportModal/ImportWorkspacesPage/ImportWorkspacesPage.tsx index ed26b709cf2..cec6708fdd6 100644 --- a/apps/desktop/src/renderer/routes/_authenticated/components/V1ImportModal/ImportWorkspacesPage/ImportWorkspacesPage.tsx +++ b/apps/desktop/src/renderer/routes/_authenticated/components/V1ImportModal/ImportWorkspacesPage/ImportWorkspacesPage.tsx @@ -52,9 +52,19 @@ export function ImportWorkspacesPage({ }); const v2ProjectIdByV1Id = useMemo(() => { + const projectIdsInCloud = new Set( + (cloudWorkspacesQuery.data ?? []).map((w) => w.projectId), + ); const v2ByPath = new Map(); for (const v2 of hostProjectListQuery.data ?? []) { - v2ByPath.set(v2.repoPath, v2.id); + const existing = v2ByPath.get(v2.repoPath); + if (!existing) { + v2ByPath.set(v2.repoPath, v2.id); + continue; + } + if (projectIdsInCloud.has(v2.id) && !projectIdsInCloud.has(existing)) { + v2ByPath.set(v2.repoPath, v2.id); + } } const map = new Map(); for (const v1 of projectsQuery.data ?? []) { @@ -62,7 +72,11 @@ export function ImportWorkspacesPage({ if (v2Id) map.set(v1.id, v2Id); } return map; - }, [hostProjectListQuery.data, projectsQuery.data]); + }, [ + hostProjectListQuery.data, + projectsQuery.data, + cloudWorkspacesQuery.data, + ]); const cloudWorkspaceKeys = useMemo(() => { const set = new Set(); @@ -108,6 +122,7 @@ export function ImportWorkspacesPage({ workspacesQuery.isPending || worktreesQuery.isPending || hostProjectListQuery.isPending || + cloudWorkspacesQuery.isPending || worktreeListQueries.some((q) => q.isPending); const [isRefreshing, setIsRefreshing] = useState(false);