Skip to content

API key modal: paste only inserts up to a dash #52

Description

@dderuntz

Reported

Confirmed during v0.9.89 OpenAI provider testing. When the API-key entry modal appears (e.g., right-click → Intelligence → ChatGPT-5.2 → modal prompt), pasting (Cmd+V) an API key only inserts characters up to the first dash. The rest of the key is silently dropped.

The same key pastes fine into the text field in Settings → Intelligence (where keys are managed long-term).

Repro

  1. Copy an API key that contains a dash (any modern OpenAI/Anthropic key, e.g. sk-proj-abc123...)
  2. Right-click the duck status bar icon → Intelligence → ChatGPT-5.2 (or any provider without a key)
  3. Modal appears asking for the key, with a text field
  4. Cmd+V to paste
  5. Observe only sk (or up to whatever's before the first dash) appears

Suspected cause

The modal is built in DuckConfig.ensureKey() (widget/Sources/RubberDuckWidget/DuckConfig.swift:236) using NSAlert with an NSTextField accessory view. Likely a paste-via-services / responder-chain quirk specific to NSAlert accessory text fields — the field may not be wired to the standard Edit menu paste action, or some other input handling is intercepting the dash character.

The Preferences pane uses SwiftUI's SecureField / TextField which routes paste through the SwiftUI text system and works correctly.

Possible fixes to investigate

  • Replace the modal's NSTextField with an explicit first-responder + Edit menu wiring
  • Switch the modal to a small SwiftUI sheet instead of an NSAlert with accessory view
  • Test whether NSSecureTextField (which we should probably be using for API keys anyway) has the same bug

Workaround

Skip the modal: open Settings → Intelligence pane and paste the key there directly. The provider auto-switches once the key is saved.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions