Skip to content

fix(dashboard/providers): keep Save actionable after a passing Test (#6144)#6146

Merged
houko merged 2 commits into
mainfrom
fix-provider-save-after-test
Jun 17, 2026
Merged

fix(dashboard/providers): keep Save actionable after a passing Test (#6144)#6146
houko merged 2 commits into
mainfrom
fix-provider-save-after-test

Conversation

@houko

@houko houko commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #6144. Adding an LLM provider (the reporter used "claude") and clicking Test left the Save button greyed out, so the provider appeared impossible to add even though the connection test passed.

Root cause

The configure drawer's testKey (in useProviderConfig) does two things on a Test click:

  1. Persists the entered key via set_provider_key (the backend test endpoint validates the stored credential, so it has to be saved first), then sets keyInput: "" so the password field shows its "existing key" placeholder.
  2. Runs the test mutation and records testResult.

Step 1's clearing of keyInput makes isUnchanged evaluate to true (empty key input, unchanged base/proxy URL), and isUnchanged fed directly into saveDisabled. So after a passing Test the Save button greyed out — even though the credential was already persisted by the Test itself. To the user that reads as "this provider can't be added".

Fix

Keep Save enabled when the form is otherwise unchanged but a Test has just passed (testResult.ok). The credential is already saved at that point, so clicking Save runs the no-op save path and dismisses the drawer with the usual success toast — a clear confirm-and-close affordance instead of a dead-looking button.

-  const saveDisabled = !config.provider || config.saving || config.testing || isUnchanged;
+  const testedOk = config.testResult?.ok === true;
+  const saveDisabled = !config.provider || config.saving || config.testing || (isUnchanged && !testedOk);

Verification

  • Added a regression test in ProvidersPage.test.tsx: open the Add picker, pick an unconfigured provider, enter a key, click Test, and assert Save stays enabled. Confirmed it fails on the pre-fix saveDisabled condition and passes after the fix.
  • pnpm test --run — 786 passed (80 files)
  • pnpm typecheck — clean
  • pnpm lint — 0 errors (pre-existing baseline warnings only, none in the touched files)
  • pnpm build — ok

…6144)

Adding a provider (e.g. "claude") and clicking Test left the Save button greyed out, so the provider looked like it could not be added even though the test passed.

The configure drawer's `testKey` already persists the entered key via `set_provider_key` and then clears `keyInput` so the password field falls back to its "existing key" placeholder. That clearing made `isUnchanged` true (empty key, unchanged base/proxy URL), which fed straight into `saveDisabled`. The credential was in fact already saved by the Test, but the disabled Save button read as "this provider can't be added".

Keep Save enabled when the form is otherwise unchanged but a Test has just passed (`testResult.ok`), giving the user a clear confirm-and-close affordance. Clicking it runs the no-op save path and dismisses the drawer with the usual success toast.

Verification:
- Added a regression test in ProvidersPage.test.tsx that adds an unconfigured provider, enters a key, clicks Test, and asserts Save stays enabled. Confirmed it fails on the pre-fix condition and passes after.
- pnpm test --run (786 passed), pnpm typecheck (clean), pnpm lint (0 errors), pnpm build (ok).
@houko
houko enabled auto-merge (squash) June 17, 2026 06:07
@github-actions github-actions Bot added size/S 10-49 lines changed no-rust-required This task does not require Rust knowledge labels Jun 17, 2026
@houko
houko merged commit 376bd51 into main Jun 17, 2026
33 checks passed
@houko
houko deleted the fix-provider-save-after-test branch June 17, 2026 06:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-rust-required This task does not require Rust knowledge size/S 10-49 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cladue 不能被添加

2 participants