Prevent concurrent draft agent creation - #3272
Conversation
React submit state is render-lagged, so callbacks entering in the same render can all start create requests. Claim the draft synchronously in the shared create-flow store before the first request begins.
|
| Filename | Overview |
|---|---|
| packages/app/src/composer/draft/create-flow.ts | Adds a synchronous shared-store availability check before draft agent creation; no actionable defect was established in the reachable production flow. |
| packages/app/src/composer/draft/create-flow.test.ts | Adds focused regression coverage showing concurrent same-render submissions issue only one create request. |
Sequence Diagram
sequenceDiagram
participant U as Submit callbacks
participant H as Draft create flow
participant S as Create-flow store
participant D as Daemon
U->>H: First submission
H->>S: Check draft availability
S-->>H: Available
H->>S: Set lifecycle active
H->>D: Create agent request
U->>H: Concurrent submission
H->>S: Check draft availability
S-->>H: Active
H-->>U: Reject without daemon request
Reviews (1): Last reviewed commit: "fix(app): prevent concurrent draft agent..." | Re-trigger Greptile
|
Closing this because the Playwright user-action check did not reproduce duplicate creation with or without the change. The unit test manufactured concurrent callbacks without establishing that users can reach that state, so this is not a supported fix for issue 3217.\n\n_Posted by an agent, not the maintainer; reviewed by the maintainer._ |
Linked issue
Refs #3217
Type of change
Reasoning
Draft creation used React render state as its only in-flight guard. Multiple submit callbacks entering before React committed the first state transition each started a separate agent creation request. The shared create-flow store is updated synchronously before the request, so it is the operation owner that can reject later callbacks in the same render.
This fixes the demonstrated client-side duplicate-submit producer. It does not claim to explain the paired six outline requests in #3217; the hosted relay path does not fan out client frames, so that part remains under investigation.
Goals
Non-goals
list_promptsrequest fails #3217.Supersedes
mainwith failing-first regression coverage.QA
npx vitest run packages/app/src/composer/draft/create-flow.test.ts --bail=1timed out because both same-render submissions entered the unresolved create request.npm run typecheckpasses.npm run lintpasses.npm run format:files -- packages/app/src/composer/draft/create-flow.ts packages/app/src/composer/draft/create-flow.test.tspasses.Checklist
npm run typecheckpassesnpm run lintpassesnpm run formatpasses