From d90e187c5ba2f243870b2cc0e168f45d43838317 Mon Sep 17 00:00:00 2001 From: Richard Solomou Date: Sat, 16 May 2026 17:02:00 -0700 Subject: [PATCH] fix(tasks): only reconcile cloud-environment tasks into workspace registry The sync-cloud-tasks reconciliation effect was creating a cloud workspace for every task without a local workspace, including local-worktree tasks mid-creation. The TaskCreationSaga invalidates `useTasks` before it calls `workspace.create.mutate({ mode: "worktree" })`, so a new worktree task briefly appears with no workspace and races against this effect, ending up registered as cloud. Filter the reconciliation to only tasks whose `latest_run.environment` is "cloud". Generated-By: PostHog Code Task-Id: ee21f72a-87af-4505-926a-a22cc881b47b --- apps/code/src/renderer/components/MainLayout.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/code/src/renderer/components/MainLayout.tsx b/apps/code/src/renderer/components/MainLayout.tsx index 4f712a0f4..b0867db06 100644 --- a/apps/code/src/renderer/components/MainLayout.tsx +++ b/apps/code/src/renderer/components/MainLayout.tsx @@ -98,7 +98,10 @@ export function MainLayout() { if (!syncCloudTasksEnabled) return; if (!tasks || !workspaces || !workspacesFetched) return; const missing = tasks.filter( - (t) => !workspaces[t.id] && !reconcilingTaskIds.current.has(t.id), + (t) => + t.latest_run?.environment === "cloud" && + !workspaces[t.id] && + !reconcilingTaskIds.current.has(t.id), ); if (missing.length === 0) return; for (const t of missing) reconcilingTaskIds.current.add(t.id);