fix(app): prevent duplicate draft agent creation - #2614
Closed
lincolnaleixo wants to merge 5 commits into
Closed
Conversation
lincolnaleixo
marked this pull request as ready for review
July 29, 2026 16:49
Contributor
|
| Filename | Overview |
|---|---|
| packages/app/src/composer/draft/create-flow.ts | Adds a synchronous draft-scoped active-attempt check that closes the same-render duplicate-submission window. |
| packages/app/src/composer/draft/create-flow.test.ts | Adds regression coverage for two submissions invoked before React rerenders, asserting only one creation request starts. |
Sequence Diagram
sequenceDiagram
participant U as Submit callbacks
participant H as Draft create hook
participant S as Create-flow store
participant A as Agent creation request
U->>H: First submit
H->>S: Check active attempt
S-->>H: None
H->>S: Store active attempt
H->>A: Start create request
U->>H: Concurrent submit
H->>S: Check active attempt
S-->>H: Active
H-->>U: Reject duplicate submission
A-->>H: Creation completes
H->>S: Mark sent or clear on failure
Reviews (3): Last reviewed commit: "Merge branch 'main' into agent/prevent-d..." | Re-trigger Greptile
11 tasks
7 tasks
Collaborator
|
Superseded by #4442, which takes over the duplicate draft-agent workflow with the shared active-attempt check, stable per-draft creation/message identities, and durable daemon receipts. The canonical PR includes failing-first browser coverage for rapid submissions and replayed requests. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
creatingstate.Root cause
handleCreateFromInputguarded onisSubmitting, which is derived from the reducer state captured by the current render. Multiple submit callbacks in the same event loop all observedisSubmitting === false, generated independent message IDs, and started independentcreateAgentrequests before React could render the firstSUBMITtransition.The create-flow Zustand store is updated synchronously before the request starts, so checking its active attempt closes that render gap while preserving retries after failed attempts are cleared.
Observed impact
In a real Paseo 0.2.3 desktop session, one new-workspace prompt produced seven
create_agent_requestmessages from the same client, session, and connection within one millisecond. All seven became real Codex agents.This may be related to #94, although that issue describes duplicate draft tabs rather than confirmed duplicate provider agents.
Validation
npm run build:app-depsnpm run test --workspace=@getpaseo/app -- src/composer/draft/create-flow.test.tsnpm run typecheck --workspace=@getpaseo/appAll passed locally.