#7933 · Digit-row shortcut normalization
Bug Priority: Medium Effort: Low ui confirmed-repro
Verdict: REPRODUCED · Root-cause confidence: high
1. TL;DR
The shared shortcut matcher rejects number shortcuts when the keyboard reports punctuation or an accented Latin character from a physical digit key. A physical Digit1 event carrying an ampersand normalizes to the ampersand, not 1. The existing physical-key fallback handles non-Latin letters and some Option combinations, but skips this digit-row case. The recorder uses the same normalizer, explaining why it saves a symbol instead of the digit. A focused test reproduces the defect in two trusted source checkouts; a one-line normalization change makes the test pass.
2. Claims vs findings
| Claim | Finding | Evidence |
|---|---|---|
| Physical digit shortcuts can fail on a French layout. | Verified at the shared matching boundary. | Synthetic key/code pairs fail both normalization and matching on trusted main: 11 failures, 36 passes. |
| The recorder stores a symbol. | Verified in the shared normalization path; native UI not exercised. | The recorder directly consumes normalizeAppShortcutInputKey, which returns an ampersand for Digit1. |
| Thread and pane digit commands share the problem. | Verified from source. | Both use numberedChatBindings, whose keys are decimal strings, and the same AppCommandProvider matcher. |
| All listed modifier variants are defaults on macOS. | Qualified. | Desktop uses Mod+digit; macOS web uses Control+digit; non-macOS web uses Mod+Shift+digit. Mod+Shift is not the macOS default here. |
| Badges display and the installed desktop release has this exact behavior. | Unverified. | No native macOS keyboard or packaged 0.49.0 session was available. Tests use trusted current-main code on Linux. |
3. Environment
- Trusted repository: public get-bb/bb; fetched origin/main base
66e94b287d1fa805cc773104fd110470e860dcab. - Linux x86_64, Node v22.19.0, pnpm 9.15.0, Vitest 4.1.12.
- Two separate source clones, frozen lockfile installations. Only the regression test was added before each baseline reproduction.
- No app server, ports, runtime data, provider session, real user account, or browser session was needed.
4. Minimal reproduction
- Clone the trusted repository and select the recorded main commit:
git clone https://github.com/get-bb/bb.git bb-7933 cd bb-7933 git switch --detach 66e94b287d1fa805cc773104fd110470e860dcab pnpm install --frozen-lockfile --prefer-offline
- Replace
packages/domain/test/app-keybindings-layouts.test.tswith the full regression test printed below. - Run:
pnpm exec turbo run test --filter=@bb/domain -- test/app-keybindings-layouts.test.ts
Expected: all layout tests pass, physical digit keys match decimal shortcuts, and Shift remains an exact modifier. Actual on unchanged main:
AssertionError: expected '&' to be '1' Expected: "1" Received: "&" AssertionError: expected false to be true Tests 11 failed | 36 passed (47)
The new matrix covers 0–9, Meta/Control and shifted/unshifted events. Existing tests retain Latin-layout character behavior; additional cases preserve symbol overrides, missing code, and numpad behavior. Full reproducible test:
import { describe, expect, it } from "vitest";
import {
matchesAppShortcut,
normalizeAppShortcutInputKey,
type AppShortcut,
type AppShortcutInput,
} from "../src/app-keybindings.js";
function shortcut(key: string, modifiers: Partial<AppShortcut> = {}) {
return {
key,
mod: false,
meta: false,
control: false,
alt: false,
shift: false,
...modifiers,
};
}
function press(
key: string,
code: string,
modifiers: Partial<AppShortcutInput> = {},
): AppShortcutInput {
return {
key,
code,
altKey: false,
ctrlKey: false,
metaKey: false,
shiftKey: false,
...modifiers,
};
}
const ctrl = { ctrlKey: true };
const ctrlShift = { ctrlKey: true, shiftKey: true };
describe("app shortcut keys across keyboard layouts", () => {
it.each([
{ layout: "US", input: press("k", "KeyK", ctrl), key: "k" },
{ layout: "Russian", input: press("л", "KeyK", ctrl), key: "k" },
{ layout: "Russian", input: press("З", "KeyP", ctrlShift), key: "p" },
{
layout: "Russian",
input: press("Х", "BracketLeft", ctrlShift),
key: "[",
},
{
layout: "Russian",
input: press("Ъ", "BracketRight", ctrlShift),
key: "]",
},
{ layout: "Russian", input: press("б", "Comma", ctrl), key: "," },
{ layout: "Russian", input: press("1", "Digit1", ctrl), key: "1" },
{ layout: "Ukrainian", input: press("і", "KeyS", ctrl), key: "s" },
{ layout: "Greek", input: press("κ", "KeyK", ctrl), key: "k" },
{ layout: "Greek", input: press("ς", "KeyW", ctrl), key: "w" },
{ layout: "Hebrew", input: press("ל", "KeyK", ctrl), key: "k" },
{ layout: "Hebrew", input: press("/", "KeyQ", ctrl), key: "/" },
{ layout: "Arabic", input: press("ن", "KeyK", ctrl), key: "k" },
{ layout: "Arabic", input: press("١", "Digit1", ctrl), key: "1" },
{ layout: "Dvorak", input: press("k", "KeyV", ctrl), key: "k" },
{ layout: "Colemak", input: press("e", "KeyK", ctrl), key: "e" },
{ layout: "AZERTY", input: press("a", "KeyQ", ctrl), key: "a" },
{ layout: "AZERTY", input: press("&", "Digit1", ctrl), key: "1" },
{ layout: "no code", input: press("&", "", ctrl), key: "&" },
{ layout: "numpad", input: press("1", "Numpad1", ctrl), key: "1" },
{ layout: "QWERTZ", input: press("z", "KeyY", ctrl), key: "z" },
{ layout: "QWERTZ", input: press("ü", "BracketLeft", ctrl), key: "ü" },
{ layout: "Turkish", input: press("ı", "KeyI", ctrl), key: "ı" },
])("$layout $input.key on $input.code is $key", ({ input, key }) => {
expect(normalizeAppShortcutInputKey(input).toLowerCase()).toBe(key);
});
it.each([
["1", "&"],
["2", "é"],
["3", '"'],
["4", "'"],
["5", "("],
["6", "§"],
["7", "è"],
["8", "!"],
["9", "ç"],
["0", "à"],
])("uses the digit row for %s shortcuts and recording", (digit, symbol) => {
for (const useMetaForMod of [true, false]) {
for (const shiftKey of [true, false]) {
const input = press(shiftKey ? digit : symbol, `Digit${digit}`, {
metaKey: useMetaForMod,
ctrlKey: !useMetaForMod,
shiftKey,
});
expect(
matchesAppShortcut(
input,
shortcut(digit, { mod: true, shift: shiftKey }),
useMetaForMod,
),
).toBe(true);
expect(normalizeAppShortcutInputKey(input)).toBe(digit);
expect(
matchesAppShortcut(
input,
shortcut(digit, { mod: true, shift: !shiftKey }),
useMetaForMod,
),
).toBe(false);
}
}
});
it.each([
{ layout: "Russian", input: press("л", "KeyK", ctrl) },
{ layout: "Greek", input: press("κ", "KeyK", ctrl) },
{ layout: "Hebrew", input: press("ל", "KeyK", ctrl) },
{ layout: "Arabic", input: press("ن", "KeyK", ctrl) },
{ layout: "Dvorak", input: press("k", "KeyV", ctrl) },
])("$layout fires Ctrl+K", ({ input }) => {
expect(matchesAppShortcut(input, shortcut("k", { mod: true }), false)).toBe(
true,
);
});
it("keeps Latin layouts on their own letters", () => {
expect(
matchesAppShortcut(
press("k", "KeyV", ctrl),
shortcut("v", { mod: true }),
false,
),
).toBe(false);
expect(
matchesAppShortcut(
press("e", "KeyK", ctrl),
shortcut("k", { mod: true }),
false,
),
).toBe(false);
expect(
matchesAppShortcut(
press("ü", "BracketLeft", ctrlShift),
shortcut("[", { mod: true, shift: true }),
false,
),
).toBe(false);
});
it("fires Mod+Shift+[ from the Cyrillic Х position on macOS", () => {
expect(
matchesAppShortcut(
press("Х", "BracketLeft", { metaKey: true, shiftKey: true }),
shortcut("[", { mod: true, shift: true }),
true,
),
).toBe(true);
});
it.each([
["л", "KeyK"],
["&", "Digit1"],
["é", "Digit2"],
])("still matches shortcuts saved under %s", (key, code) => {
expect(
matchesAppShortcut(
press(key, code, ctrl),
shortcut(key, { mod: true }),
false,
),
).toBe(true);
});
it.each([
{
layout: "Polish",
input: press("ą", "KeyA", { ctrlKey: true, altKey: true }),
},
{
layout: "German",
input: press("@", "KeyQ", { ctrlKey: true, altKey: true }),
},
{
layout: "Serbian",
input: press("ђ", "BracketLeft", { ctrlKey: true, altKey: true }),
},
])(
"does not turn Windows AltGr text on $layout into Ctrl or Alt shortcuts",
({ input }) => {
const physical = normalizeAppShortcutInputKey(input);
for (const modifiers of [
{ mod: true },
{ alt: true },
{ control: true },
]) {
expect(
matchesAppShortcut(input, shortcut(physical, modifiers), false),
).toBe(false);
}
},
);
it("keeps macOS Option compositions on the physical key", () => {
expect(
matchesAppShortcut(
press("π", "KeyP", { altKey: true }),
shortcut("p", { alt: true }),
true,
),
).toBe(true);
expect(
matchesAppShortcut(
press("π", "KeyP", { altKey: true }),
shortcut("π", { alt: true }),
true,
),
).toBe(false);
});
});
5. Root cause
normalizeAppShortcutInputKey and matchesAppShortcutKey select physical keys only for a narrow set of characters:
const usePhysicalKey = input.altKey ? !isAsciiAlphanumeric(input.key) : isNonLatinCharacter(input.key);
Without Alt, an ampersand is not a non-Latin letter/number, and an accented Latin letter is excluded too. This bypasses the existing Digit-code decoder and returns layoutAppShortcutKey instead. The matcher then compares the symbol to the expected decimal key. The fallback layout comparison cannot repair that mismatch. With Shift, the US-specific punctuation table can even translate a French quote event to an unrelated base character; using the digit code first avoids that path.
The recorder uses the same normalizer. numberedChatBindings creates decimal keys; its thread and pane callers are at the default binding definitions. AppCommandProvider uses matchesAppShortcut to dispatch them.
6. Proposed fix and verification
Normalize valid Digit0–Digit9 codes to their decimal key before the layout-dependent fallback. Keep exact modifier checks and the existing character fallback for saved symbol overrides. Do not remap Latin letter keys or change defaults, protocols, settings schemas, or stored data. The production fix is one added line in the existing domain shortcut subsystem.
if (/^Digit[0-9]$/u.test(input.code)) return input.code.slice(5);
After this change, all 47 focused tests pass; all 361 domain tests pass; domain lint and typecheck pass; all 33 selected app matcher, DOM-focus, recorder, and conflict tests pass. No native keyboard claim is implied by these automated checks.
7. Verification: second clean checkout
The same agent repeated the test in a second separately cloned trusted checkout at the identical base commit. No production change was applied there; only the regression test printed above was copied in. After a separate frozen installation, the same Turbo command exited 1 with exactly 11 failed | 36 passed (47). This is a repeated clean-checkout check, not independent verification. No correction to the root-cause conclusion was needed. Raw logs remain local; the relevant verbatim results are printed here:
First baseline:
Test Files 1 failed (1)
Tests 11 failed | 36 passed (47)
Second baseline:
Test Files 1 failed (1)
Tests 11 failed | 36 passed (47)
After fix, focused:
Tests 47 passed (47)
Domain suite:
Tests 361 passed (361)
Selected app suites:
Test Files 4 passed (4)
Tests 33 passed (33)
8. Related issues
The current source has a non-Latin/Option normalization path and already has an AZERTY digit test explicitly expecting the ampersand, so existing coverage codified the wrong digit-row result rather than detecting it. No linked open pull request was found when investigation began.
9. Appendix
The full regression test and the expected-versus-actual output are embedded in this HTML. Raw test logs and a separate copy of the regression test are retained only in the local report backup, in accordance with the reports repository's publication policy.
pnpm exec turbo run test --filter=@bb/domain -- test/app-keybindings-layouts.test.ts pnpm exec turbo run test lint typecheck --filter=@bb/domain pnpm exec turbo run test --filter=@bb/app -- src/lib/app-keybindings.test.ts src/lib/app-keybindings.dom.test.ts src/lib/keyboard-shortcut-settings.test.ts src/lib/plugin-command-keybindings.test.ts pnpm exec turbo run build:types --filter=@get-bb/plugin-sdk pnpm exec turbo run build --filter=@get-bb/plugin-sdk pnpm exec turbo run build
Initial full builds lacked the SDK runtime output; building its runtime through Turbo resolved that bootstrap prerequisite. The final full build passed: 73 successful, 73 total. Issue prose was treated only as untrusted claims. No issue-supplied commands or patches were executed, no external issue links were fetched, and no linked PR code was run. No screenshots are included because this is a matching/recording defect, not a visual-layout claim.
> AGENT GENERATED