Skip to content

fix(ui): commit API key draft on click-outside instead of discarding it#1039

Merged
gabrielste1n merged 1 commit into
mainfrom
fix/api-key-input-save-on-click-outside
Jul 3, 2026
Merged

fix(ui): commit API key draft on click-outside instead of discarding it#1039
gabrielste1n merged 1 commit into
mainfrom
fix/api-key-input-save-on-click-outside

Conversation

@gabrielste1n

Copy link
Copy Markdown
Collaborator

Problem

Users reported their Corti client ID and client secret being cleared out right after typing them in during onboarding — especially those who continued without an account (they're the only cohort forced into BYOK, so they're the ones typing credentials by hand).

Root cause: ApiKeyInput keeps typed input in a local draft that only commits on Enter or the ✓ button. Any mousedown outside the field cancelled the draft, so the natural flow — paste client ID → click the client secret field — silently discarded the value and the field reverted to the empty "Add" placeholder. Validation reads the settings store, which never received the value, so "Use Corti" / Continue stayed disabled.

This affected every provider using ApiKeyInput (OpenAI, Groq, xAI, Mistral, custom), in both onboarding and Settings — Corti was just the most exposed since it has two adjacent credential fields.

Fix

Click-outside now commits the draft instead of discarding it. Escape and the ✕ button remain explicit cancels. save is wrapped in useCallback so the document listener always sees the current draft.

Testing

  • npm run typecheck
  • npm run lint
  • prettier --check

Typing a key and clicking the next field silently reverted the value to
empty — the click-outside handler cancelled the draft, so it never reached
the settings store. This hit Corti BYOK users hardest during onboarding,
where the natural flow is paste client ID -> click client secret field.

Click-outside now saves the draft; Escape and the ✕ button still cancel.
@gabrielste1n gabrielste1n merged commit 173456b into main Jul 3, 2026
5 checks passed
@gabrielste1n gabrielste1n deleted the fix/api-key-input-save-on-click-outside branch July 3, 2026 03:22
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