Skip to content

Cmd-K palette selects a result when Enter confirms IME composition #3413

Description

@kongenpei

Summary

While composing text with an IME in the Cmd-K palette search field, pressing Enter to confirm the composition also selects the highlighted bb result and closes the palette. Enter should commit the IME candidate only; result selection should wait for a non-composing Enter event.

Versions and environment

  • bb 0.42.0
  • Source at commit 8ac123f3551e7502a91c93e87329797f34ee626b (origin/main)
  • macOS 26.3 (25D125), Chinese Pinyin IME
  • Node v24.6.0
  • Managed worktree environment

Steps to reproduce

  1. Open the bb app on macOS with the Chinese Pinyin input source active.
  2. Press Cmd-K to open the command palette.
  3. Type into the search field while leaving a bb result highlighted and the IME candidate window active.
  4. Press Enter to confirm the highlighted IME candidate.

A deterministic component-level reproduction dispatches keydown with { key: "Enter", isComposing: true } to the real Cmd-K combobox after a result is highlighted.

Expected vs actual

Expected:

Pressing Enter while isComposing is true confirms the IME candidate. The palette remains open and does not run or navigate to a bb result.

Actual:

The palette consumes Enter, selects the highlighted command or thread, and closes.

The targeted regression test failed twice before the diagnostic guard:

FAIL src/components/commands/CommandPalette.test.tsx > CommandPalette > does not run the highlighted command when Enter confirms an IME composition
TestingLibraryElementError: Unable to find an accessible element with the role "combobox"
Test Files  1 failed (1)
Tests  1 failed | 23 skipped (24)

Evidence

  • Investigation thread: thr_45jjczbvhq (project proj_7q2p9ejasx, environment env_t9aupz56py)
  • The input wires onKeyDown directly to handleKeyDown:
    className="h-11 w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground"
    placeholder={inputLabel}
    value={query}
    onChange={(event) => {
    const nextQuery = event.target.value;
    setQuery(nextQuery);
    if (!nextQuery.startsWith(">")) setThreadItems([]);
    setHighlightedIndex(0);
    if (listRef.current !== null) listRef.current.scrollTop = 0;
    }}
    onKeyDown={handleKeyDown}
  • The Enter branch selects the active result without checking composition state:
    if (event.key === "Enter") {
    event.preventDefault();
    if (mode === "commands") {
    const choice = rankedCommands[activeIndex];
    if (choice !== undefined) chooseAction(choice.action);
    return;
    }
    const choice = threadItems[activeIndex];
    if (choice !== undefined) chooseThread(choice);
  • Other text inputs already guard Enter with event.nativeEvent.isComposing:
    const handleKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {
    if (event.nativeEvent.isComposing) {
    return;
    }
    if (event.key === "Enter") {
    event.preventDefault();
    event.stopPropagation();
    closeOnce(onSubmit);
  • Adding only if (event.nativeEvent.isComposing) return; at the start of this handler made the same targeted test pass: 1 passed | 23 skipped.

What you ruled out

  • Not caused by Dialog or global shortcut handling: changing only the local CommandPalette handler made the exact reproduction pass.
  • Still present on origin/main at 8ac123f3551e7502a91c93e87329797f34ee626b.
  • Searched open and closed issues for IME, composition, Pinyin, command palette, and Cmd-K Enter; no duplicate found.

Suggested priority and effort

Medium priority, low effort. It affects IME users whenever Enter is used to confirm composition; switching input sources is a workaround. No data loss observed.

  • I reproduced this on main.
  • I searched open and closed issues for the same problem.

AGENT GENERATED

Activity

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

    confirmed-reproBug reproduced again from a clean trusted checkout; see linked reportuiApp shell, sidebar, composer, rendering

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions