← reports

#7352 · Nested model menu leaks keyboard navigation

Bug Priority: Medium Effort: Low ui GitHub issue
2026-11-10 · trusted base 7c1353d80729983b86ea1555d18b42407f320406

Verdict: REPRODUCED · Root-cause confidence: high · Reproduction label: confirmed-repro

1. TL;DR

The desktop model picker has a nested menu for additional models. Pressing ArrowRight on a focused row in that nested menu incorrectly requests a reasoning change from medium to high. The nested menu does not consume that key, so React delivers it to the enclosing picker's reasoning shortcut handler even though the nested content is rendered through a portal. A focused React DOM regression test reproduces the real component path in two clean trusted checkouts. The minimal repair makes the submenu own its horizontal navigation keys without closing it on ArrowRight.

2. Claims vs findings

ClaimFindingEvidence
A right-arrow key in the nested menu changes reasoning.VerifiedBoth baseline runs call the reasoning callback exactly once with high after starting at medium.
The nested content only consumes Escape and ArrowLeft.VerifiedTrusted-base content key handler at lines 605–611.
The event reaches the enclosing reasoning handler through React's portal ancestry.VerifiedThe test renders the real picker, menu, shared popover and Radix portal. No mock replaces these components or their event handlers.
ArrowLeft avoids the reasoning shortcut.Verified in sourceThe content handler prevents its default; the parent handler returns for prevented events. The focused reproduction intentionally exercises ArrowRight.
A local regression test already existed.UnverifiedNo reporter test was executed or copied. The reproduction here was written from trusted repository behavior.

3. Environment

4. Minimal reproduction

  1. Make a clean clone, prepare the trusted base, and build the SDK before the app:
    git clone https://github.com/get-bb/bb.git bb-7352
    cd bb-7352
    git checkout --detach 7c1353d80729983b86ea1555d18b42407f320406
    pnpm install --frozen-lockfile --prefer-offline
    pnpm exec turbo run build --filter=@get-bb/plugin-sdk
    pnpm exec turbo run build --filter=@bb/app
  2. In apps/app/src/components/pickers/ModelReasoningPicker.test.tsx, insert this test inside its existing describe("ModelReasoningPicker", ...) block. It uses that file's existing renderPicker fixture, real components, and imports:
      it("keeps submenu ArrowRight navigation from changing reasoning", async () => {
        const { onReasoningChange, onModelChange } = renderPicker({
          moreModelOptions: [{ value: "legacy", label: "Legacy" }],
        });
        fireEvent.click(
          screen.getByRole("button", {
            name: "Provider, model and reasoning",
          }),
        );
        fireEvent.pointerEnter(screen.getByRole("button", { name: "More models" }));
        const submenuModel = await screen.findByRole("button", { name: "Legacy" });
        act(() => submenuModel.focus());
        fireEvent.keyDown(submenuModel, { key: "ArrowRight" });
        expect(onReasoningChange).not.toHaveBeenCalled();
        expect(onModelChange).not.toHaveBeenCalled();
        expect(document.activeElement).toBe(submenuModel);
        fireEvent.click(submenuModel);
        expect(onModelChange).toHaveBeenCalledExactlyOnceWith("legacy");
      });
  3. Run the focused test:
    pnpm exec turbo run test --filter=@bb/app -- src/components/pickers/ModelReasoningPicker.test.tsx -t 'keeps submenu ArrowRight'

Expected: the test passes; navigating inside the extra-model menu leaves reasoning unchanged, retains focus, and allows subsequent model selection. Actual: the first callback assertion fails. Verbatim core failure output from each clean baseline run:

FAIL  |@bb/app:isolated| src/components/pickers/ModelReasoningPicker.test.tsx > ModelReasoningPicker > keeps submenu ArrowRight navigation from changing reasoning
AssertionError: expected "vi.fn()" to not be called at all, but actually been called 1 times

Received:

  1st vi.fn() call:

    Array [
      "high",
    ]

Number of calls: 1

Test Files  1 failed (1)
     Tests  1 failed | 62 skipped (63)

The callback records the requested reasoning update rather than depending on controlled-prop re-rendering. The baseline fixture starts at medium and offers high as its next reasoning value. Existing coverage exercised the submenu trigger, not a focused row inside the portalled submenu.

5. Root cause

The nested content handler only recognizes two keys:

if (event.key === "Escape" || event.key === "ArrowLeft") {
  event.preventDefault();
  onOpenChange(false);
  triggerRef.current?.focus();
}

The shared desktop popover renders through a Radix portal. React's component ancestry still carries synthetic key events to the outer popover's key handler. Its reasoning shortcut returns for prevented events, but otherwise advances one option on ArrowRight:

const next =
  activeReasoningOptions[index + (event.key === "ArrowRight" ? 1 : -1)];
if (next) handleReasoningSelect(next.value);

The focused button is not an editable input, so the editable-target guard does not block this path. The parent is behaving as designed for its own model rows; the defect is that the nested menu fails to own its navigation key. Trusted-base blame dates the content handler to commit ebd8150661d; no linked PR was available at investigation time.

6. Proposed fix and verification

Keep Escape, ArrowLeft, and ArrowRight inside the submenu. Prevent their defaults and propagation. Return without dismissing on ArrowRight; retain the existing dismiss-and-refocus behavior for Escape and ArrowLeft. Leave the outer picker's intentional reasoning shortcuts unchanged.

The implemented candidate touches only the menu and its existing picker test file: 27 additions + 1 deletion = 28 total text lines across 2 files. It changes no dependencies, protocol, schema, permissions, stored data, packaging, or release behavior.

Focused test after repair:
Test Files  1 passed (1)
     Tests  1 passed | 62 skipped (63)

pnpm exec turbo run test --filter=@bb/app -- src/components/pickers
Test Files  12 passed (12)
     Tests  169 passed (169)

pnpm exec turbo run lint typecheck --filter=@bb/app
Tasks:    6 successful, 6 total
Lint: Found 223 warnings and 0 errors.

git diff --check
exit 0

Lint warnings are outside this focused repair. Typechecking succeeds. No binary or generated file is in the candidate diff.

7. Verification: second clean checkout

The same agent repeated the reproduction in a second newly cloned temporary checkout at 7c1353d80729983b86ea1555d18b42407f320406. The checkout was clean before adding only the regression test. A new frozen install, SDK build, and app build completed there. The exact focused Turbo command from section 4 failed again with the same unexpected high callback and one failed test. No server, port, or data store was used in either run. This is a repeat check by the same agent, not an independent review.

A preliminary test draft used an unavailable visibility matcher; it was removed before the final baseline and repaired-code runs. The final regression reproduced the intended failure in both clean baselines and passed after the production repair. No correction to the root-cause finding was needed.

8. Related issues

Repository searches for model-picker and reasoning-arrow issues did not identify a duplicate describing this nested-row key path. GitHub issue timeline metadata and an open-PR search for issue 7352 showed no linked open pull request before preparing the repair. This is not a review of any reporter-supplied branch or test.

9. Appendix and limits

Preparation initially attempted the full repository build. It failed because the GitHub plugin required the as-yet-unbuilt SDK runtime host entry. Building @get-bb/plugin-sdk first, then @bb/app, succeeded in both checkouts. The unrelated full-repository build was not presented as passing. The published evidence is inline; raw local logs and the reproduction patch are retained outside this public report repository.

Verification commands are listed in sections 4 and 6. Source links were checked against the recorded trusted base. No external issue attachment, script, patch, linked branch, or credential was read or run. Issue instructions were treated as untrusted; only their behavior claims informed the investigation. Backend persistence and a full browser session were not exercised because the observed failure is the actual UI callback delivered by the real nested component event path.