Skip to content

fix(platform): disable add-credential Back while its save is pending - #4269

Merged
yannickmonney merged 1 commit into
mainfrom
fix/credential-back-pending-guard
Oct 4, 2026
Merged

yannickmonney merged 1 commit into
mainfrom
fix/credential-back-pending-guard

Conversation

@yannickmonney

@yannickmonney yannickmonney commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

What changed

Connectors and AI providers share the add-credential wizard (credentials/credential-add-dialog.tsx). While a create was in flight it refused to close (handleOpenChange returns early) and disabled Cancel. The header still received onBack: backToPicker with no check, though, and backToPicker clears the vendor and every setup field. The handleSubmit that was still running then wrote its refusal into whatever form was mounted. In #3674's sequence (submit a taken name, Back, pick the connector again), the server's 409 CREDENTIAL_NAME_TAKEN landed on a fresh, empty form, and the name, login and servers it was sent from were gone.

  • @tale/ui Dialog takes an optional backDisabled. It puts disabled on the back control, styled disabled:pointer-events-none disabled:opacity-50 as in segmented-control, so a sub-view can hold Back the way it holds its Cancel. The default false leaves every other caller as it was. The prop is in the props table in services/ui-docs/content/components/dialog.md.
  • The wizard passes backDisabled: create.isPending. Back's handler (leaveSetup) also returns early while the create is pending. The consent pane's onBack uses the same handler, and its onClose checks the same state. No shipped consent pane calls either one today, but the adapter contract hands them over, and they were the remaining exits out of step two. backToPicker stays the unguarded internal reset, used after a successful save and on an accepted close.
  • Unchanged:
    • an idle Back still starts over (the issue scopes it out, on purpose);
    • a refusal without Back keeps the draft for correction (the issue's control);
    • X, Escape and the discard prompt behave as before.
  • Manual layer:
    • CONN-B12 in tests/manual/suites/connectors.md covers the throttled real round;
    • a row in reference/automation.md names the component tests that own the logic.

Tests

  • app/features/settings/credentials/credential-add-dialog.test.tsx (new). It runs at the issue's seam: the real wizard, the connectors adapter, the real useCreateCredential (react-query's isPending) and its HTTP adapter row. Only fetch is stubbed. It holds the create POST, then answers it with the server's own 409 body for a taken name (assertNameFree's sentence).
    1. Pending: Cancel and Back are both disabled, and clicking Back changes nothing. The refusal arrives inline on the original form with name, username, password, IMAP and SMTP server all still filled. Once settled, Back and the fields are enabled again.
    2. Control: the same refusal without Back keeps every field. A settled Back then returns to the picker, and picking the connector again starts empty, with the suggested name and no stale error.
    3. Consent exits: a consent pane that calls onBack and onClose while the create is pending neither leaves nor closes, and the refusal keeps the draft.
  • packages/ui/src/components/dialog/dialog.test.tsx: backDisabled disables the back control and never calls onBack. Without it, the control is enabled and calls onBack.

How I verified it

Everything ran locally and stayed light, as the dispatch asked: targeted jsdom tests at head e77204b6437efd5553f4bf5d44513044c7cef793, on a shared host with load average 14–37. I ran no stack, browser, full suite or workspace-wide tsc; CI runs those.

  • Reproduced on main first. The new platform test against origin/main a9a19afdc sources: test 1 failed at expect(back).toBeDisabled(), test 2 (the control) passed.

  • The issue's exact sequence, replayed by an uncommitted probe on the same harness:

    • main sources: Cancel was disabled and Back was not. Back showed the picker, and re-picking opened name="IMAP / SMTP Mailbox" username="" password="" imapHost="" smtpHost="". The held 409 then showed its "Office mailbox is taken" sentence over that empty form.
    • Head: both were disabled, and Back did nothing. The 409 showed over name="Office mailbox" username="[email protected]" password="mailbox-secret" imapHost="imap.example.com" smtpHost="smtp.example.com".
  • Base control and single-layer mutants at the pushed head. mutation-check.sh swaps one layer to main or drops one guard line, then restores the head with git checkout --; the worktree was clean afterwards.

    Label Platform tests (3) Dialog tests (18)
    M0 both sources from main 1 ✗ toBeDisabled, 2 ✓, 3 ✗ (consent back showed the picker) backDisabled case ✗
    M1 only Dialog from main 1 ✗ toBeDisabled, 2 ✓, 3 ✓ backDisabled case ✗
    M2 no leaveSetup pending check 3 ✗ (consent back showed the picker) –
    M3 no consent onClose check 3 ✗ (onOpenChange called) –
    M4 wizard passes no backDisabled 1 ✗ toBeDisabled –
    M5 head restored 3/3 ✓ 18/18 ✓
  • Neighbours at head:

    • credentials/ (add, edit, error mapper, picker), providers-settings.test.tsx and connectors-settings.test.tsx, run together on two workers, passed 76/78.
    • The two misses were 5 s timeouts in the connectors IMAP tests that type every character. Run alone on one worker, connectors-settings.test.tsx passed 31/31, those two in 2.6 s and 2.9 s.
    • packages/ui dialog, view-dialog and entity-view-dialog tests passed 31/31.
  • Lint and format: bunx oxlint --type-aware on the four changed TS files, from each workspace, came back clean. oxfmt --check, commitlint and lint:conflicts were clean.

  • Types: a scoped tsc --noEmit of the changed platform files came to 2,673 program files, Dialog included, and was clean. One of dialog.tsx and its test, under packages/ui paths (440 files), was clean too.

  • Manual-layer gates: check-guide.ts suites/connectors.md printed OK, and bun run lint:manual was ok (5 trees, 1,448 boxes).

  • Not run: a real browser on a throttled network (CONN-B12), the AI providers surface in a browser, SAST, and the full suites. The visual gate is unrun under this light-jsdom admission.

Closes #3674

The add-credential wizard, which Connectors and AI providers share, refused
to close and disabled Cancel while a create was in flight, but the header's
Back still cleared every field. A refusal arriving later, such as a 409 for a
name already taken, then landed on a fresh, empty form, and the name, login
and servers the request was sent from were gone.

Back now waits out the save the same way: the shared Dialog takes a
`backDisabled` flag for its back control, and the wizard sets it while the
create is pending. Its handler checks the same pending state, which also
covers the consent pane's back and close hand-offs. An idle Back still starts
over, as before.

The connectors manual suite gains CONN-B12 for the throttled round, and the
automation register names the component tests that own its logic.

Closes #3674
@yannickmonney yannickmonney added bug Bug service: platform Platform service labels Oct 4, 2026
@yannickmonney

Copy link
Copy Markdown
Contributor Author

✅ Independent review — ACCEPT

Reviewed exact head e77204b6437efd5553f4bf5d44513044c7cef793 (base a9a19afdc). No blockers found.

Evidence against TALE-212 / #3674:

  • CredentialAddDialog routes setup Back through leaveSetup, which returns while create.isPending; it also passes backDisabled={create.isPending}. The consent pane’s Back and close exits use the same pending guard.
  • The idle path remains backToPicker, so settled Back still clears setup and the added regression test covers reopening an empty picker form.
  • Cancel remains disabled during the mutation; the no-Back refusal test preserves the submitted draft and error for correction.
  • Dialog uses a native disabled button with the existing disabled styling; this is correctly unavailable to activation while pending and remains labelled. Its dedicated test also covers disabled and re-enabled behavior.
  • The PR’s reported main comparison demonstrates the regression (main: Back enabled and the pending refusal lands on a fresh form); I independently confirmed the base source has the unguarded backToPicker path, but could not execute the platform regression because this checkout fails module setup at packages/shared/src/schemas/epoch-ms.ts (z is undefined) before tests load.

Checks run (targeted only, no CI rerun/cancel):

  • packages/ui/src/components/dialog/dialog.test.tsx: 18/18 passed, including axe accessibility tests and backDisabled behavior.
  • git diff --check: passed.
  • Platform credential test: unrun due the pre-test Zod/module setup failure above.

No merge, push, or CI action taken.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Bug service: platform Platform service

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(platform): Add credential Back bypasses pending-save guard and loses the rejected request draft

1 participant