Skip to content

fix(builder): await pending graph writes before version save - #48

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-management-af90
Draft

cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-management-af90

Conversation

@cursor

@cursor cursor Bot commented Aug 9, 2026

Copy link
Copy Markdown

Summary

Fixes a race where manual version saves could snapshot stale database state while canvas mutations were still in flight.

Bug and impact

POST /api/workflows/{id}/versions reads the workflow from the database. If the user hits Save (toolbar, ⌘S, or version panel) while a node drag, edge delete, or other graph PATCH is still pending, the saved version checkpoint does not match the canvas. With Supabase-backed version storage (PR #39), that stale snapshot is durable and restorable — restoring it drops newer edits.

Root cause

handleSaveVersion and the version history panel's separate save path did not wait for in-flight graph mutation fetches before creating a version from the DB.

Fix and validation

  • Added createPendingWriteTracker to track in-flight graph mutation fetches.
  • Wrapped all graph mutation safeFetch calls with trackWrite.
  • handleSaveVersion now awaits pending writes before POSTing a version.
  • Wired version history panel through the shared onSave handler.
  • pnpm run test:run -- tests/lib/pending-writes.test.ts — pass (237 total tests).
Open in Web View Automation 

Version POST snapshots the DB while canvas mutations may still be
in flight, persisting stale checkpoints to Supabase. Track mutation
fetches and flush them before save; route version panel through the
shared save handler.

Co-authored-by: esadrianno <esadrianno@gmail.com>
@vercel

vercel Bot commented Aug 9, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
v0-agent-kit Ready Ready Preview, v0 Aug 9, 2026 11:10am

This branch was successfully deployed

1 active deployment
Preview — 5c3dd5f7 Deployed Aug 9, 2026 by vercel[bot]
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