Skip to content

bug(ui): Switch Provider keyboard activation can commit a provider the user did not pick #862

Closed

Description

@Juliusolsson05

Expected

In the Switch Provider picker, a keyboard user who Tabs to Cancel and presses Enter closes the picker. A focused button owns its own Enter — the rule components/ui/dialog-actions.tsx documents ("A FOCUSED BUTTON OWNS ITS OWN ENTER … tabbing to Cancel and pressing Enter would CONFIRM").

Actual

ProviderSwitchPickerModal's DialogContent onKeyDown handles every Enter: it calls preventDefault() (which suppresses the focused button's synthesized click) and then commits the highlighted provider row. So Tab → Cancel → Enter starts a provider switch for the targeted agent instead of cancelling.

Reproduction

  1. Focus an agent; run Switch Provider.
  2. Press Tab until Cancel has focus.
  3. Press Enter.

Result: the picker closes and switchSessionProvider runs for the highlighted destination.

Code evidence: src/renderer/src/features/workspace/ui/ProviderSwitchPickerModal.tsx — the event.key === 'Enter' && selected branch has no check of event.target.

Impact

A provider switch translates and replaces the conversation's runtime — not something a Cancel should ever trigger. Keyboard-only users are the ones who hit it.

Notes

Found during review of #860 (New Agent In…), whose dialog copied this pattern and had the same bug. #860 fixes both, with regression tests.

Activity

  1. added a commit that references this issue on Sep 11, 2026
    2e793b5
  2. Juliusolsson05 commented on Sep 11, 2026

    @Juliusolsson05
    OwnerAuthor

    Fixed in #860 (commit 2e793b5) with a regression test in ProviderSwitchPickerModal.renderer.test.tsx; closes when #860 merges.

  3. changed the title [-]bug(ui): Enter on a focused Cancel in Switch Provider starts the provider switch[/-] [+]bug(ui): Switch Provider keyboard activation can commit a provider the user did not pick[/+] on Sep 11, 2026
  4. Juliusolsson05 commented on Sep 11, 2026

    @Juliusolsson05
    OwnerAuthor

    Scope widened after a second review of #860. A second keyboard path commits the wrong target in the same picker: Tab to a provider row, press ArrowDown/Ctrl-N (the highlight moves, DOM focus stays on the Tab-focused row), press Space. The browser activates the FOCUSED row's native button, so the switch goes to that provider, not the highlighted one. Root cause is shared with the Enter-on-Cancel path: rows are tab stops whose focus diverges from the arrow-driven highlight. #860 fixes both paths (rows stop being tab stops, so keyboard focus is only ever on the dialog surface or the footer buttons) and adds a regression test for each.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions