improvement(workflows): replace Zustand workflow sync with React Query as single source of truth#3860
improvement(workflows): replace Zustand workflow sync with React Query as single source of truth#3860waleedlatif1 wants to merge 8 commits intostagingfrom
Conversation
…y as single source of truth
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview Adds shared Written by Cursor Bugbot for commit c282858. Configure here. |
Greptile SummaryThis PR replaces the Zustand Key changes:
Minor issues found:
Confidence Score: 5/5Safe to merge — all remaining findings are P2 style/consistency issues with no functional impact on correctness or data integrity. The refactoring is architecturally sound: RQ cache becomes the single source of truth, optimistic updates follow the canonical pattern with proper rollback, and the hydration state machine is correctly simplified. The previously flagged sandbox/academy execution bug is fixed. No P0/P1 issues found; the three P2 notes cover a stale closure, an incomplete useCallback dep list (stable references), and a minor cache-invalidation scope inconsistency — none of which affect runtime correctness. apps/sim/hooks/queries/workflows.ts — onSettled invalidation scope inconsistency across mutations worth aligning before adding more scope-aware consumers. Important Files Changed
Reviews (4): Last reviewed commit: "fix(workflows): address PR review — awai..." | Re-trigger Greptile |
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-workflow-execution.ts
Show resolved
Hide resolved
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow.tsx
Outdated
Show resolved
Hide resolved
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/panel.tsx
Outdated
Show resolved
Hide resolved
apps/sim/app/workspace/[workspaceId]/w/components/sidebar/hooks/use-drag-drop.ts
Show resolved
Hide resolved
…tion deadlock, test mock, copy casing
…pe-safe conditional queries
- Throw on state PUT failure in useCreateWorkflow instead of swallowing - Use Map for O(1) lookups in duplicate/export loops (3 hooks) - Broaden invalidation scope in update/delete mutations to lists() - Switch workflow-block to useWorkflowMap for direct ID lookup - Consolidate use-workflow-operations to single useWorkflowMap hook - Remove workspace transition guard (sync body, unreachable timeout) - Make switchToWorkspace synchronous (remove async/try-catch/finally)
|
@greptile |
|
@cursor review |
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow.tsx
Outdated
Show resolved
Hide resolved
loadWorkflowState used hydration.workspaceId (null on cold start) to look up the RQ cache, causing "Workflow not found" even when the workflow exists in the DB. Now falls back to getWorkspaceIdFromUrl() and skips the cache guard when the cache is empty (letting the API fetch proceed). Also removes the redundant isRegistryReady guard in workflow.tsx that blocked setActiveWorkflow when hydration.workspaceId was null.
Dashboard and EmbeddedWorkflow checked workflow list length before the RQ query resolved, briefly showing "No workflows" or "Workflow not found" on initial load. Now gates on isPending first.
|
@greptile |
|
@cursor review |
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-workflow-execution.ts
Show resolved
Hide resolved
...l/components/deploy/components/deploy-modal/components/general/components/api-info-modal.tsx
Show resolved
Hide resolved
…state PUT throw - api-info-modal: use mutateAsync for description update so errors are caught by the surrounding try/catch instead of silently swallowed - useCreateWorkflow: revert state PUT to log-only — the workflow is already created in the DB, throwing rolls back the optimistic entry and makes it appear the creation failed when it actually succeeded
|
@greptile |
|
@cursor review |
Summary
workflowsrecord and sync effects from Zustand registry store — React Query is now the single source of truth for workflow metadatauseWorkflowMaphook withselectfor structural sharing (replaces consumer-sideuseMemo+Object.fromEntries)useUpdateWorkflowMutationanduseDeleteWorkflowMutationwith optimistic updatesworkflowKeysto shared util to avoid circular imports between store and query hooksisPending/isSuccess)optimistic-update.tsutil (zero consumers)Type of Change
Testing
Tested manually
Checklist