Skip to content

fix(search): open cmd+K with the cursor in the search box - #833

Merged
xintaofei merged 2 commits into
xintaofei:mainfrom
Jonathan-Asher:pr/cmdk-focus
Sep 28, 2026
Merged

xintaofei merged 2 commits into
xintaofei:mainfrom
Jonathan-Asher:pr/cmdk-focus

Conversation

@Jonathan-Asher

Copy link
Copy Markdown
Contributor

Summary

The cmd+K search dialog now opens with the cursor in its search box, and keeps it there when switching between the Conversations and Files tabs.

Cause

The dialog's first focusable element is the Conversations tab button, so that is where Radix's open auto-focus landed. Typing right after cmd+K went nowhere until the search box was clicked, and clicking a tab moved focus onto the tab.

Changes

  • CommandInput takes focus when the dialog opens (autoFocus).
  • The tab buttons don't take focus on mouse down, and switching tabs returns focus to the search box.

Verification

  • New search-command-dialog.test.tsx (2 tests): fails on main (focus sits on the tab button and typed text never reaches the input), passes with this change.
  • Checked in the running app (WebKit and Chrome): after cmd+K, typing goes straight into the search box; after clicking Files, the cursor stays in the box.
  • CI: frontend (lint, vitest, build) and every Rust desktop/server cell on Ubuntu, macOS and Windows pass. There are no Rust changes.

The dialog's first focusable element is the Conversations tab button, so
that is where Radix put focus when the dialog opened: typing right after
cmd+K went nowhere until the search box was clicked. Clicking a tab moved
focus onto the tab as well.

The search box now takes focus when the dialog opens and keeps it when
switching tabs (the tab buttons no longer take focus on mouse down).

@dawNotPoi dawNotPoi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed focus behavior on opening the dialog and switching tabs at e20e455. The focused search-dialog tests pass (2/2) locally, as do TypeScript and ESLint for the changed files. No blocking findings in this scope.

`autoFocus` focused the search box while the dialog was still mounting,
before Radix's focus trap started listening, so the trap never recorded
it and had nothing to pull focus back to. The chat composer refocuses
itself when an agent turn ends; with the dialog open over it, the rest
of the query was typed into the composer, where Enter sends it to the
agent.

Focus the box from the dialog's open auto-focus instead (CommandDialog
now forwards onOpenAutoFocus), which runs once the trap is listening.
The agent filter chips now keep the cursor in the box on mouse down, as
the tabs do, so picking a filter doesn't stop typing from searching.
@xintaofei

Copy link
Copy Markdown
Owner

codeg work task 247 is done — #833 (3 files, +84/-10).

@xintaofei
xintaofei merged commit 7e9ae9e into xintaofei:main Sep 28, 2026
7 checks passed
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.

3 participants