Skip to content

fix(dashboard): reset the Add API key modal between opens - #16628

Merged
diegosouzapw merged 2 commits into
release/v3.8.52from
fix/port-pr-4027-add-api-key-modal-reset
Oct 15, 2026
Merged

diegosouzapw merged 2 commits into
release/v3.8.52from
fix/port-pr-4027-add-api-key-modal-reset

Conversation

@diegosouzapw

Copy link
Copy Markdown
Collaborator

Summary

  • The Add API key modal no longer keeps the previous credential after a save or cancel: reopening it starts from an empty form.
  • ProviderModalsPanel now mounts AddApiKeyModal only while it is open, and the modal itself rebuilds its whole form on every open for callers that keep it mounted.

Attribution

Thanks to @hamedniroomand and @semihisikman for the original implementation.

Changes

Test plan

  • New tests fail before the fix (production files restored from HEAD with git show):
    • npx vitest run --config vitest.config.ts addApiKeyModalReset → Tests 3 failed | 2 passed (5) (API key kept after reopen, bulk tab + textarea kept, key kept after a successful save; the unique-name and failed-save cases pass as regression guards).
    • npx vitest run --config vitest.config.ts addApiKeyModalMountOnOpen → Tests 1 failed (1) (expected <div …> to be null: modal mounted while closed).
  • After the fix: npx vitest run --config vitest.config.ts addApiKeyModalMountOnOpen addApiKeyModalReset → Test Files 2 passed (2), Tests 6 passed (6).
  • Related suites (everything that imports AddApiKeyModal / ProviderModalsPanel): npx vitest run --config vitest.config.ts tests/unit/ui/confirm-delete-connection-7361 tests/unit/ui/add-api-key-modal tests/unit/ui/compatible-provider-apikey-setup tests/unit/ui/web-session-cookie-modal-size-6265 proxySaveRefresh useApiKeySaveSkipsFullSync addApiKeyModalMountOnOpen addApiKeyModalReset connModals addApiKeyModal-default-name-15006 → Test Files 13 passed (13), Tests 49 passed (49).
  • node --import tsx/esm --test tests/unit/compute-connection-default-name-11033.test.ts tests/unit/compute-connection-default-name-6499.test.ts tests/unit/freebuff-risk-notice-15058.test.ts → ℹ tests 10 ℹ pass 10 ℹ fail 0.
  • npx eslint --suppressions-location config/quality/eslint-suppressions.json <5 changed files> → exit 0; npx prettier --check <5 changed files> → all formatted.
  • npm run typecheck:core → exit 0. Targeted tsc over the 5 changed files: identical pre-existing error set before and after (37 = 37, none in the new code).
  • node scripts/check/check-pr-test-policy.mjs → Result: PASS; GITHUB_BASE_REF=release/v3.8.52 npm run check:test-masking → OK — 0 modified, 0 deleted.

⚠️ base-red inherited: #15306 — unit/vitest/integration/package-artifact gates on release/v3.8.52

diegosouzapw and others added 2 commits October 14, 2026 19:55
The Add API key modal stayed mounted and only toggled `isOpen`, and its
open effect refreshed just the name and base URL. Closing it (X, Cancel,
or the parent closing after a successful save) kept the previous API key,
token secret, AWS credentials, bulk text and the bulk tab, so the next add
started pre-filled with the last credential.

- ProviderModalsPanel mounts AddApiKeyModal only while it is open, so a
  close drops the whole form.
- The modal itself rebuilds its form from createInitialAddApiKeyFormData()
  on every closed-to-open transition and resets mode, bulk state, advanced
  toggle, validation capabilities and the OpenRouter preset, covering
  callers that keep it mounted. The unique default name (#6499, #11033,
  #15006) is still recomputed on each open.
- A failed save keeps the typed input and shows the error.

Co-authored-by: Hamed Niroomand <hamed@niroomand.dev>
Inspired-by: decolua/9router#4027
Co-authored-by: semihisikman <semihisikman@users.noreply.github.com>
Inspired-by: decolua/9router#4582
@github-actions

Copy link
Copy Markdown
Contributor

CI Coverage Report

  • Coverage job: skipped
  • PR test policy: success

Coverage artifact was not available for this run.

@diegosouzapw
diegosouzapw merged commit 78cd4be into release/v3.8.52 Oct 15, 2026
40 of 56 checks passed
@diegosouzapw
diegosouzapw deleted the fix/port-pr-4027-add-api-key-modal-reset branch October 18, 2026 23:50
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.

1 participant