Skip to content

fix(tasks): only reconcile cloud tasks into workspace registry#2153

Merged
richardsolomou merged 1 commit into
mainfrom
posthog-code/fix-sync-cloud-tasks-flag
May 17, 2026
Merged

fix(tasks): only reconcile cloud tasks into workspace registry#2153
richardsolomou merged 1 commit into
mainfrom
posthog-code/fix-sync-cloud-tasks-flag

Conversation

@richardsolomou
Copy link
Copy Markdown
Member

Problem

When the posthog-code-sync-cloud-tasks flag is enabled, creating a new local worktree task ends up registered as a cloud task. Paul hit this and confirmed it goes away after he removes himself from the flag.

The reconciliation effect added in #2146 (apps/code/src/renderer/components/MainLayout.tsx) creates a cloud workspace for every task without a local workspace, regardless of the task's actual environment. The TaskCreationSaga calls onTaskReady (which invalidates useTasks) before workspace.create.mutate({ mode: "worktree" }), so a freshly-created worktree task briefly appears in tasks with no workspace and races the reconciliation effect — which wins and registers it as cloud.

Changes

Filter reconciliation to only tasks whose latest_run?.environment === "cloud". Local-worktree tasks mid-creation no longer match, so the saga's workspace.create runs uncontested.

How did you test this?

  • Typecheck passes locally (pre-commit hook).
  • Manual repro requires the flag, which I don't have; reviewers on the flag can verify worktree creation works again.

Publish to changelog?

no


Created with PostHog Code

…istry

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
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 17, 2026

Reviews (1): Last reviewed commit: "fix(tasks): only reconcile cloud-environ..." | Re-trigger Greptile

@richardsolomou richardsolomou requested a review from a team May 17, 2026 00:05
@richardsolomou richardsolomou added the Create Release This will trigger a new release label May 17, 2026
Copy link
Copy Markdown
Contributor

@joshsny joshsny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@richardsolomou richardsolomou merged commit 4fa436d into main May 17, 2026
15 checks passed
@richardsolomou richardsolomou deleted the posthog-code/fix-sync-cloud-tasks-flag branch May 17, 2026 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Create Release This will trigger a new release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants