Skip to content

fix(workbench): avoid duplicate Flow after create - #84

Merged
l1shen merged 1 commit into
oomol-lab:mainfrom
songpaopao:fix/workbench-flow-create-race
Sep 7, 2026
Merged

fix(workbench): avoid duplicate Flow after create#84
l1shen merged 1 commit into
oomol-lab:mainfrom
songpaopao:fix/workbench-flow-create-race

Conversation

@songpaopao

Copy link
Copy Markdown
Contributor

Summary

  • reuse the idempotent Flow catalog insertion path after creation
  • avoid duplicate Flow rows and an inflated total when a catalog notification reload completes first
  • add a deterministic regression test for the notification/create race

Motivation

The Server publishes flows.changed before returning the create response. If the Workbench reloads the catalog before FlowCatalog.create() resumes, the previous implementation appended the same Flow again and incremented total twice.

Verification

  • bun run --cwd packages/open-flow check
  • bun run test
  • bun run build
  • regression test verified red against the previous implementation

Reuse the idempotent catalog insert path when a create notification reloads before the request completes.

Co-Authored-By: AtomCode (GLM-5.2) <noreply@atomgit.com>
@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: 1fbe1ec0-6d68-4844-a444-760a9fa33188

📥 Commits

Reviewing files that changed from the base of the PR and between beaa5d5 and 26361ba.

📒 Files selected for processing (2)
  • packages/open-flow/src/workbench/browser/runtime/stores/flowCatalog.ts
  • packages/open-flow/src/workbench/browser/runtime/stores/workspaceStore.test.ts

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


Summary by CodeRabbit

  • Bug Fixes

    • Prevented duplicate flows from appearing in the catalog when a flow is created while the catalog refreshes.
    • Catalog totals now remain accurate when the same flow is received through multiple updates.
  • Tests

    • Added coverage for concurrent flow creation and catalog refresh scenarios.

Walkthrough

FlowCatalog.create now delegates to insert. The existing deduplication prevents duplicate Flows and incorrect total increments when a catalog refresh adds the Flow before the creation request completes. A regression test covers this asynchronous sequence and verifies that the catalog contains one Flow with a total of 1.

Merge Risk: ⚪ Minimal · up to 26361

Flow creation now avoids duplicate catalog entries when a refresh races the create response, with regression coverage for the final item count and total. No current merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title uses the required <type>(<scope>): <subject> format and accurately describes the duplicate Flow fix.
Description check ✅ Passed The description directly explains the duplicate Flow issue, the race condition, the implementation, and the regression test.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
✨ Simplify code
  • Create PR with simplified code

Comment @coderabbitai help to get the list of available commands.

@l1shen
l1shen merged commit 16d9286 into oomol-lab:main Sep 7, 2026
8 checks passed
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.

2 participants