fix(deploy): consolidate deployment detection into single source of truth#3606
fix(deploy): consolidate deployment detection into single source of truth#3606waleedlatif1 merged 11 commits intostagingfrom
Conversation
|
You have used all 50 Bugbot PR reviews included in your free trial for your GitHub account on this workspace. To keep getting Bugbot reviews, enable Bugbot for your team in the Cursor dashboard. |
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Greptile SummaryThis PR eliminates two separate, inconsistent deployment-detection code paths by consolidating them into a single server-side Key changes:
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant EditorHeader as Deploy Button (Editor)
participant ChildBadge as Child/Tool Badge
participant RQ as React Query Cache
participant DeployAPI as /api/workflows/[id]/deploy (GET)
participant StatusAPI as /api/workflows/[id]/status (GET)
participant DeployedAPI as /api/workflows/[id]/deployed (GET)
participant Utils as checkNeedsRedeployment()
Note over EditorHeader: On mount (isDeployed=true)
EditorHeader->>RQ: useDeployedWorkflowState (staleTime 30s)
RQ->>DeployedAPI: fetch deployed snapshot
DeployedAPI-->>RQ: WorkflowState (baseline)
RQ-->>EditorHeader: deployedState
EditorHeader->>EditorHeader: useMemo hasWorkflowChanged(current, deployed)
Note over ChildBadge: On mount
ChildBadge->>RQ: useDeploymentInfo (staleTime 30s)
RQ->>DeployAPI: GET /deploy
DeployAPI->>Utils: checkNeedsRedeployment()
Utils-->>DeployAPI: needsRedeployment: bool
DeployAPI-->>RQ: {isDeployed, needsRedeployment, ...}
RQ-->>ChildBadge: deployment info
Note over EditorHeader: User clicks Deploy/Update
EditorHeader->>RQ: useDeployWorkflow.mutateAsync()
RQ->>DeployAPI: POST /deploy
DeployAPI-->>RQ: success
RQ->>RQ: invalidateDeploymentQueries(info+deployedState+versions)
RQ->>RQ: invalidate workflowKeys.state
RQ-->>EditorHeader: re-fetch deployedState (new baseline)
RQ-->>ChildBadge: re-fetch deploymentInfo
|
...workspace/[workspaceId]/w/[workflowId]/components/workflow-block/hooks/use-child-workflow.ts
Outdated
Show resolved
Hide resolved
...sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/deploy/deploy.tsx
Outdated
Show resolved
Hide resolved
...pace/[workspaceId]/w/[workflowId]/components/panel/components/deploy/hooks/use-deployment.ts
Outdated
Show resolved
Hide resolved
...workspaceId]/w/[workflowId]/components/panel/components/deploy/hooks/use-change-detection.ts
Outdated
Show resolved
Hide resolved
6f6e99b to
1fcff2b
Compare
- Remove redundant isLoading check (subset of isPending in RQ v5) - Make deployedState prop nullable to avoid non-null assertion - Destructure mutateAsync to eliminate ESLint suppression - Guard debounced invalidation against stale workflowId on switch
…tion dep - Remove self-explanatory comments in deploy.tsx, tool-input.tsx, use-child-workflow.ts - Tighten non-obvious comments in use-change-detection.ts - Destructure mutate/isPending in WorkflowToolDeployBadge to avoid unstable mutation object in useCallback deps (TanStack Query no-unstable-deps pattern)
|
@greptile |
|
@cursor review |
|
You have used all 50 Bugbot PR reviews included in your free trial for your GitHub account on this workspace. To keep getting Bugbot reviews, enable Bugbot for your team in the Cursor dashboard. |
...workspaceId]/w/[workflowId]/components/panel/components/deploy/hooks/use-change-detection.ts
Outdated
Show resolved
Hide resolved
Avoid running mergeSubblockStateWithValues on every render for non-deployed workflows where changeDetected always returns false.
|
@greptile |
|
bugbot run |
|
You have used all 50 Bugbot PR reviews included in your free trial for your GitHub account on this workspace. To keep getting Bugbot reviews, enable Bugbot for your team in the Cursor dashboard. |
Pre-existing type error — workflow table was used but not imported.
Match the pattern used by all other fetch helpers in the file so in-flight requests are cancelled on component unmount or query re-trigger.
All three queries (active version, normalized data, workflow variables) now run concurrently via Promise.all, saving one DB round trip on the common path.
|
@greptile |
…ver polling The lastSaved-based server polling was triggering API calls on every local store mutation (before socket persistence), wasting requests and checking stale DB state. Revert the editor header to pure client-side hasWorkflowChanged comparison — zero network during editing, instant badge updates. Child workflow badges still use server-side useDeploymentInfo (they don't have Zustand state). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
bugbot run |
|
You have used all Bugbot PR reviews included in your free trial for your GitHub account on this workspace. To continue using Bugbot reviews, enable Bugbot for your team in the Cursor dashboard. |
|
@cursor review |
|
You have used all Bugbot PR reviews included in your free trial for your GitHub account on this workspace. To continue using Bugbot reviews, enable Bugbot for your team in the Cursor dashboard. |
|
@greptile |
…fetch Guard change detection on isFetching (not just isLoading) so the comparison is suppressed during background refetches after mutations, preventing a brief Update→Live badge flicker. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
You have used all Bugbot PR reviews included in your free trial for your GitHub account on this workspace. To continue using Bugbot reviews, enable Bugbot for your team in the Cursor dashboard. |
|
Re: transient "Update" badge flash after redeploy (Greptile finding) Addressed in f7cfa26 — we now destructure |
|
@greptile |
Summary
useDeploymentInfo), one mutation hook (useDeployWorkflow), one server function (checkNeedsRedeployment), one invalidation helper (invalidateDeploymentQueries)hasWorkflowChangedfor instant badge updates with zero API calls during editing. The deployed state snapshot is fetched once via React Query and refreshed after deploy/undeploy/version-activate mutations.useDeploymentInfowith 30s staleTime (they don't have Zustand state for client comparison)useDeployedStatehook (110 lines),useChildDeploymentStatus,useDeployChildWorkflow,fetchChildDeploymentStatus, inline comparison logic in deploy/status routesBefore
/status+/deployments) withstaleTime: 0andcache: 'no-store'/deployand/statusroute handlersAfter
checkNeedsRedeployment()for both server endpointsuseDeploymentInfohook shared by all badge consumers (30s staleTime, React Query deduplication)useMemoclient comparison — zero network during editinginvalidateDeploymentQueries()for consistent cache refreshTest plan
/api/workflows/{id}/deployduring editing (Network tab)bunx tsc --noEmit)