Skip to content

fix(wait): resume live/draft async waits and preserve cell context on chained waits#4814

Merged
TheodoreSpeaks merged 2 commits into
stagingfrom
fix/wait-in-live-run
May 30, 2026
Merged

fix(wait): resume live/draft async waits and preserve cell context on chained waits#4814
TheodoreSpeaks merged 2 commits into
stagingfrom
fix/wait-in-live-run

Conversation

@TheodoreSpeaks
Copy link
Copy Markdown
Collaborator

Summary

  • Honor explicit useDraftState when building the execution context instead of deriving it from isDeployedContext. Server-side draft runs (table dispatcher, HITL) no longer get forced onto the deployed branch on resume, fixing the "has no active deployment" error.
  • Merge (not overwrite) paused_executions.metadata in persistPauseResult's update branch so the stashed cellContext survives a re-pause. Chained async waits now write back to the table row after the second wait.

Type of Change

  • Bug fix

Testing

Tested manually. Added unit tests (executor context useDraftState honoring/fallback, serializer preservation, persistPauseResult metadata merge). 194 tests pass across executor/execution, wait-handler, and execution-core suites. bun run lint and bun run check:api-validation:strict pass.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link
Copy Markdown

vercel Bot commented May 30, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped May 30, 2026 7:02pm

Request Review

@cursor
Copy link
Copy Markdown

cursor Bot commented May 30, 2026

PR Summary

Medium Risk
Changes execution draft/deployed resolution and pause persistence metadata used by async waits and table cell flows; scope is narrow and covered by new unit tests.

Overview
Execution context now honors explicit metadata.useDraftState when building the context, falling back to the isDeployedContext heuristic only when unset. That fixes server-side draft runs (e.g. table dispatcher, HITL) being forced onto the deployed path on resume.

When an existing paused row is updated on re-pause, paused_executions.metadata is merged with prior values instead of replaced, so stashed cellContext survives chained async waits and table rows can be written back after a second wait.

The workflow state API contract allows description to be null in stamped read metadata. Unit tests cover draft-state precedence, snapshot serialization, and metadata merge on re-pause.

Reviewed by Cursor Bugbot for commit e39fa94. Bugbot is set up for automated code reviews on this repo. Configure here.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 30, 2026

Greptile Summary

This PR fixes two bugs in the async-wait/resume pipeline: it honors an explicit useDraftState from incoming execution metadata instead of always deriving it from isDeployedContext, and it merges (rather than overwrites) paused_executions.metadata on re-pause so that fields like cellContext survive chained waits.

  • executor.ts: useDraftState now uses ?? to fall back to the isDeployedContext heuristic only when no explicit value is present, fixing "has no active deployment" errors in table-dispatcher and HITL server-side draft runs.
  • human-in-the-loop-manager.ts: The update branch of persistPauseResult spreads existing.metadata before the new metadata, preserving caller-stashed keys (e.g., cellContext) across re-pauses.
  • contracts/workflows.ts: Adds .nullable() to the description field to allow null values in addition to undefined.

Confidence Score: 5/5

Safe to merge — both fixes are narrowly scoped, well-tested, and address confirmed runtime failures without altering unrelated code paths.

The useDraftState fix is a single-expression change that only affects contexts where the metadata field is explicitly set — all other callers get the same isDeployedContext fallback as before. The metadata merge in persistPauseResult only touches the update branch and spreads existing keys before new ones, so new values still win for shared fields while extra caller-stashed keys survive. Both changes are covered by focused unit tests, and the PR reports 194 passing tests.

No files require special attention.

Important Files Changed

Filename Overview
apps/sim/executor/execution/executor.ts One-line fix: uses ?? to honor explicit useDraftState from incoming metadata before falling back to the isDeployedContext heuristic.
apps/sim/lib/workflows/executor/human-in-the-loop-manager.ts Merges existing.metadata into the update payload so extra fields like cellContext survive chained re-pauses; new metadata values still win for shared keys.
apps/sim/lib/api/contracts/workflows.ts Adds .nullable() to the description field schema to allow explicit null values alongside undefined.
apps/sim/executor/execution/executor.test.ts New test suite covering the three useDraftState resolution cases: explicit true, explicit false, and fallback to the isDeployedContext heuristic.
apps/sim/executor/execution/snapshot-serializer.test.ts Adds a serializer test confirming that an explicit useDraftState=true is preserved in the serialized snapshot even when isDeployedContext is true.
apps/sim/lib/workflows/executor/human-in-the-loop-manager.test.ts New test drives the update branch of persistPauseResult through the mock DB chain and verifies that cellContext survives the metadata merge on re-pause.

Reviews (3): Last reviewed commit: "fix(wait): resume live/draft async waits..." | Re-trigger Greptile

Comment thread apps/sim/executor/execution/executor.ts
@TheodoreSpeaks
Copy link
Copy Markdown
Collaborator Author

@greptile review

1 similar comment
@TheodoreSpeaks
Copy link
Copy Markdown
Collaborator Author

@greptile review

@TheodoreSpeaks TheodoreSpeaks merged commit 1d4a277 into staging May 30, 2026
14 checks passed
@TheodoreSpeaks TheodoreSpeaks deleted the fix/wait-in-live-run branch May 30, 2026 23:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant