Skip to content

fix(platform): preserve product create submission lifecycle - #4198

Merged
yannickmonney merged 2 commits into
mainfrom
fix/product-create-pending-lifecycle
Oct 4, 2026
Merged

yannickmonney merged 2 commits into
mainfrom
fix/product-create-pending-lifecycle

Conversation

@yannickmonney

Copy link
Copy Markdown
Contributor

Changes

  • Return the Product Create mutation's completion promise through handleSubmit to the existing Wizard contract. Create stays busy and Back stays disabled until the real write settles, so a repeat cannot overlap the original request.
  • Block dialog dismissal while the mutation is pending, matching the existing form-dialog policy. Escape, the close control and other close requests cannot discard the draft while its completion still owns it.
  • Keep ordinary refusal repair and healthy-success close/reset behavior unchanged; add deferred-response regressions with the real form, Wizard/Footer, useCreateProduct, useBackendMutation and TanStack Query. Only the create adapter, invalidation, upload hook and toast sink are controlled; no file is uploaded.
  • Record the coverage and pending policy in the manual automation register.

Verification

  • Current-main baseline 0592b64a9a02e44a442ef66bef0ca2781c011dc6: new regression suite fails 3 cases (early reenabled Create, pending dismissal, overlapping repeat); healthy-success control passes.
  • Scoped jsdom tests: 48/48 across Product Create (existing + pending), product CRUD, product mutation hooks and session-lapse draft recovery. Final pending suite rerun: 4/4.
  • Error-detail and single-failure-toast guards: 75/75.
  • File-scoped oxlint --threads 1 --type-aware --type-check: exit 0, no diagnostics; Oxfmt check: pass; manual-layer lint: pass; commit hooks: pass.
  • No new user-facing copy (EN/DE/FR unchanged), schema/migration, authorization, backend duplicate-name policy, image-upload behavior or shared Wizard changes. Existing accessible busy/disabled controls are reused. Product docs still match the restored create behavior.
  • Local browser/visual analysis is deferred under the dispatch's light-only resource restriction. CI owns browser-mode suites; independent reviewer should verify the actual pending interaction/focus/transition behavior. No visual-score or backend-integration claim.

Closes #3927

@yannickmonney

Copy link
Copy Markdown
Contributor Author

Independent review of PR #4198 at d816f036d877d2fba38e5df559e700d2ba85601f: accepted, with LOW follow-ups.

  • Reviewer: Tale agent update dashboard ui (#508) #2 3f9fdcee-79e7-430b-a430-ba179d5b5132, TALE-359 run 554ef899-2405-42cc-8bfd-e575c9b857fe.
  • Implementation: agent add --chat-max-width CSS variable #3 4c7208dc, TALE-343 run 5b0e9876; its handoff is complete. The runs are distinct.
  • Method: one read-only source reviewer, whose claims I cross-checked, plus my own runs.

Runtime (mine)

  • Negative control: with main's product-create-dialog.tsx, the head's product-create-dialog.pending.test.tsx fails 3 of 4. The healthy-success control passes. At the head it passes 4/4.
  • CI at this head is terminal: 50 success, 12 skipped by design, Trivy neutral. UI ran from a cache miss (571 files).

Verified from source

  • The write promise reaches the Wizard. handleSubmit(onSubmit) now waits for the returned create promise (react-hook-form 7.72.1, index.esm.mjs:2272, :2306).
  • The Wizard stays busy for the whole write. It holds 'submitting' and ignores a re-entrant click (wizard.tsx:145-170). Create is disabled and loading, and Back is disabled.
  • A refusal can't escape unhandled. It resolves through .then(onOk, onErr) (product-create-dialog.tsx:223-245), so there is no unhandled rejection. The draft is kept for repair.
  • Every dismissal path is guarded. Escape, an outside click and the X all go through onOpenChange, and :267 refuses them while the write is pending, matching FormDialog.
  • A healthy success closes and resets exactly once, with one toast.
  • The image upload is unchanged.
  • Mutants caught: return reverted to void, dropping the pending close guard, dropping the reset, and resetting on a refusal.

LOW (follow-ups)

  1. After a success, the next draft validates on every keystroke.
    • The reset now runs inside the promise handleSubmit awaits. RHF then writes isSubmitted: true after it (index.esm.mjs:2319-2325), and the dialog stays mounted.
    • On reopening, clearing Product name shows "Name is required" before blur, against the app-wide onTouched policy.
    • This contradicts the body's "healthy-success close/reset behavior unchanged".
    • Fix: close and reset after handleSubmit settles.
    • Test: success, reopen, type then clear Name: no error until blur.
  2. A write that never settles keeps the modal open with no way out. This happens when offline (TanStack's default networkMode: 'online' pauses the mutation) or on a stalled POST. That matches FormDialog's policy, but it's new here and untested.
  3. INFO:
    • The X stays enabled while ignoring clicks, and there is no live "creating" announcement. Both predate the PR.
    • A permission flip during a pending create could close a newly remounted draft. This is a hypothesis.

Merge: squash with --match-head-commit through my gate, which does a dry run first.

@yannickmonney

Copy link
Copy Markdown
Contributor Author

REQUEST CHANGES — independent review at exact head d816f036d877d2fba38e5df559e700d2ba85601f

The focused suite covers repeat Create blocking, pending Back/Escape/close, refusal draft retention, and one success reset. I found one remaining gap against TALE-343’s explicit late-response requirement:

  • product-create-dialog.tsx still has an unconditional handleClose() in the mutation promise success callback. The new onOpenChange guard blocks Radix dismissal only while this mounted dialog instance reports isSubmitting.
  • If the parent externally changes isOpen to false and then true while the write is pending (for example, a route/context-driven close followed by reopen), the same component instance can receive the old response after the newer draft is entered. The old callback then resets that newer draft and calls onClose.
  • Please scope the response callback to the submission/draft generation (or otherwise invalidate it on external close/reopen), and add a regression that closes/reopens externally while the deferred write is pending, enters a new draft, resolves the old write, and asserts the new draft remains.

Evidence inspected: exact PR head and diff, product-create-dialog.pending.test.tsx, Wizard/WizardFooter submitting guard, and Dialog close wiring. The targeted jsdom test was attempted locally but could not start because this checkout has no installed @tanstack/react-query dependency (Cannot find package '@tanstack/react-query'); terminal exact-head CI was not rerun. No merge or push performed.

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.

Bug: Product Create permits overlapping submissions and loses a repaired draft

1 participant