Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Studio: search the shortcut list by pressing the chord (#11256)
Michael Han32fe7764d503
diff --git a/studio/frontend/src/features/settings/lib/keyboard-shortcuts.ts b/studio/frontend/src/features/settings/lib/keyboard-shortcuts.tsindex 43fb3e5c852..b0975192ff7 100644--- a/studio/frontend/src/features/settings/lib/keyboard-shortcuts.ts+++ b/studio/frontend/src/features/settings/lib/keyboard-shortcuts.ts@@ -562,6 +562,24 @@ export function matchesBinding(return event.shiftKey === binding.shift && event.altKey === binding.alt;}+/**+ * Whether `bound` answers to everything `pressed` holds: the same key, with no modifier+ * missing. For searching the list by chord, where the press narrows as modifiers are+ * added: N finds ⌘N and ⇧⌘N, ⌘N drops the ones without ⌘, and ⇧⌘N finds only itself.+ * Not matchesBinding, which is exact because a keypress must run one action.+ */+export function keystrokeMatchesBinding(+ pressed: ShortcutBinding,+ bound: ShortcutBinding,+): boolean {+ if (pressed.code !== bound.code) return false;+ if (pressed.mod && !bound.mod) return false;+ if (pressed.ctrl && !bound.ctrl) return false;+ if (pressed.shift && !bound.shift) return false;+ if (pressed.alt && !bound.alt) return false;+ return true;+}+/** Human label for a code: "KeyO" -> "O", "Comma" -> ",", "ArrowUp" -> "↑". */export function formatCode(code: string): string {if (code.startsWith("Key") && code.length === 4) return code.slice(3);diff --git a/studio/frontend/src/features/settings/tabs/keyboard-shortcuts-tab.tsx b/studio/frontend/src/features/settings/tabs/keyboard-shortcuts-tab.tsxindex d8250adba02..0b2aa1f8856 100644--- a/studio/frontend/src/features/settings/tabs/keyboard-shortcuts-tab.tsx+++ b/studio/frontend/src/features/settings/tabs/keyboard-shortcuts-tab.tsx@@ -15,14 +15,22 @@ import {Alert01Icon,ArrowTurnBackwardIcon,Delete02Icon,+ EnergyRectangleIcon,PencilEdit02Icon,Search01Icon,} from "@hugeicons/core-free-icons";import { HugeiconsIcon } from "@hugeicons/react";-import { type ReactNode, useEffect, useMemo, useState } from "react";+import {+ type ReactNode,+ useEffect,+ useMemo,+ useRef,+ useState,+} from "react";import {SHORTCUT_DEFS,SHORTCUT_SLOTS,+ type ShortcutBinding,type ShortcutDef,type ShortcutId,type ShortcutSlot,@@ -33,6 +41,7 @@ import {isAcceptableBinding,isBrowserReservedBinding,isMacPlatform,+ keystrokeMatchesBinding,parseBinding,} from "../lib/keyboard-shortcuts";import {@@ -130,6 +139,10 @@ export function KeyboardShortcutsTab() {const [recording, setRecording] = useState<RecordingTarget | null>(null);// Shown under the row being recorded when the pressed chord is rejected.const [recordingError, setRecordingError] = useState<string | null>(null);+ // Search the list by pressing a chord instead of typing its name.+ const [byKeystroke, setByKeystroke] = useState(false);+ const [keystroke, setKeystroke] = useState<ShortcutBinding | null>(null);+ const searchRef = useRef<HTMLInputElement>(null);const mac = isMacPlatform();const conflicts = useMemo(() => findConflicts(overrides), [overrides]);@@ -187,7 +200,63 @@ export function KeyboardShortcutsTab() {window.removeEventListener("keydown", onKeyDown, { capture: true });}, [recording, setBinding, t]);+ // Capture phase, as the recorder is: the chord has to arrive before the shortcut+ // it names fires, and before Radix's Escape closes the dialog. The recorder owns+ // the keyboard while it runs, so this stands down for it.+ useEffect(() => {+ if (!byKeystroke || recording) return;+ const onKeyDown = (event: KeyboardEvent) => {+ // Only while the box has focus: the rest of the tab keeps its own keys.+ if (document.activeElement !== searchRef.current) return;+ // Read the key through the binding, not event.code, so the fallback for an+ // engine that reports no code covers Tab and Escape here too.+ const binding = bindingFromEvent(event);+ // Modifier on its own: the chord is still being assembled.+ if (!binding) return;+ const bare = !binding.mod && !binding.ctrl && !binding.alt;+ // Tab still moves focus: a mode that swallowed it would trap the keyboard here.+ if (binding.code === "Tab" && bare) return;+ event.preventDefault();+ event.stopPropagation();+ // Escape backs out a step at a time: the chord first, then the mode. It is the one+ // shipped default the box cannot take as a query (declineToolRequest): the recorder+ // can free Escape because it swallows keys for a single chord, while this mode+ // persists, so freeing it here would leave a focused box eating the dialog's own+ // dismiss for as long as the mode is on. That row is found by name instead, where+ // the query also matches the "Esc" cap. Shift+Escape is unaffected and searchable.+ if (binding.code === "Escape" && bare && !binding.shift) {+ if (keystroke) setKeystroke(null);+ else setByKeystroke(false);+ return;+ }+ setKeystroke(binding);+ };+ window.addEventListener("keydown", onKeyDown, { capture: true });+ return () =>+ window.removeEventListener("keydown", onKeyDown, { capture: true });+ }, [byKeystroke, recording, keystroke]);++ const toggleByKeystroke = () => {+ // The two searches filter the same list, so leaving one arms the other empty.+ setByKeystroke((on) => !on);+ setQuery("");+ setKeystroke(null);+ searchRef.current?.focus();+ };+const matches = useMemo(() => {+ if (byKeystroke) {+ // Nothing pressed yet: the whole list, not an empty one.+ if (!keystroke) return null;+ return new Set(+ SHORTCUT_DEFS.filter((def) =>+ SHORTCUT_SLOTS.some((slot) => {+ const parsed = parseBinding(resolveBinding(overrides, def.id, slot));+ return parsed ? keystrokeMatchesBinding(keystroke, parsed) : false;+ }),+ ).map((def) => def.id),+ );+ }const q = query.trim().toLowerCase();if (!q) return null;return new Set(@@ -202,7 +271,7 @@ export function KeyboardShortcutsTab() {});}).map((def) => def.id),);- }, [query, t, overrides, mac]);+ }, [query, t, overrides, mac, byKeystroke, keystroke]);// One list, in registry order, so the daily rows sit above the fold.const visible = SHORTCUT_DEFS.filter(@@ -358,12 +427,64 @@ export function KeyboardShortcutsTab() {className="pointer-events-none absolute left-4 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"/><Input- value={query}+ ref={searchRef}+ // Chord mode shows the press, not text: the field is read-only there and+ // the capture listener above is what fills it.+ value={+ byKeystroke+ ? keystroke+ ? formatBindingLabel(keystroke, mac)+ : ""+ : query+ }onChange={(e) => setQuery(e.target.value)}- placeholder={t("settings.keyboardShortcuts.searchPlaceholder")}- className="h-11 rounded-full pl-11"- aria-label={t("settings.keyboardShortcuts.searchPlaceholder")}+ readOnly={byKeystroke}+ placeholder={t(+ byKeystroke+ ? "settings.keyboardShortcuts.keystrokePlaceholder"+ : "settings.keyboardShortcuts.searchPlaceholder",+ )}+ className={cn(+ "h-11 rounded-full pl-11 pr-12",+ byKeystroke && "font-medium tabular-nums",+ )}+ aria-label={t(+ byKeystroke+ ? "settings.keyboardShortcuts.keystrokePlaceholder"+ : "settings.keyboardShortcuts.searchPlaceholder",+ )}/>+ <Tooltip>+ <TooltipTrigger asChild={true}>+ <button+ type="button"+ aria-pressed={byKeystroke}+ aria-label={t(+ byKeystroke+ ? "settings.keyboardShortcuts.searchByName"+ : "settings.keyboardShortcuts.searchByKeystrokes",+ )}+ onClick={toggleByKeystroke}+ className={cn(+ "absolute right-2 top-1/2 inline-flex size-8 -translate-y-1/2 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",+ byKeystroke && "bg-muted text-foreground",+ )}+ >+ <HugeiconsIcon+ icon={EnergyRectangleIcon}+ strokeWidth={1.75}+ className="size-4"+ />+ </button>+ </TooltipTrigger>+ <TooltipContent>+ {t(+ byKeystroke+ ? "settings.keyboardShortcuts.searchByName"+ : "settings.keyboardShortcuts.searchByKeystrokes",+ )}+ </TooltipContent>+ </Tooltip></div>{visible.length === 0 ? (diff --git a/studio/frontend/src/i18n/locales/ar.ts b/studio/frontend/src/i18n/locales/ar.tsindex 1aaa330a5fb..1eeae7ecfb8 100644--- a/studio/frontend/src/i18n/locales/ar.ts+++ b/studio/frontend/src/i18n/locales/ar.ts@@ -301,6 +301,9 @@ export const ar = {keyboardShortcuts: {title: "اختصارات لوحة المفاتيح",searchPlaceholder: "بحث في الاختصارات…",+ keystrokePlaceholder: "اضغط اختصارًا للبحث",+ searchByKeystrokes: "البحث بضغط المفاتيح",+ searchByName: "البحث بالاسم",noResults: "لا توجد اختصارات مطابقة لهذا البحث.",unassigned: "غير معيّن",recording: "اضغط المفاتيح…",diff --git a/studio/frontend/src/i18n/locales/de.ts b/studio/frontend/src/i18n/locales/de.tsindex c064acef0bb..77557f3918e 100644--- a/studio/frontend/src/i18n/locales/de.ts+++ b/studio/frontend/src/i18n/locales/de.ts@@ -305,6 +305,9 @@ export const de = {keyboardShortcuts: {title: "Tastenkürzel",searchPlaceholder: "Kürzel suchen…",+ keystrokePlaceholder: "Kürzel drücken, um zu suchen",+ searchByKeystrokes: "Nach Tastendruck suchen",+ searchByName: "Nach Name suchen",noResults: "Keine Kürzel passen zu dieser Suche.",unassigned: "Nicht zugewiesen",recording: "Tasten drücken…",diff --git a/studio/frontend/src/i18n/locales/en.ts b/studio/frontend/src/i18n/locales/en.tsindex 0efe60d3305..7a86e4b8ca2 100644--- a/studio/frontend/src/i18n/locales/en.ts+++ b/studio/frontend/src/i18n/locales/en.ts@@ -306,6 +306,9 @@ export const en = {keyboardShortcuts: {title: "Keyboard shortcuts",searchPlaceholder: "Search shortcuts…",+ keystrokePlaceholder: "Press shortcut to search",+ searchByKeystrokes: "Search by keystrokes",+ searchByName: "Search by name",noResults: "No shortcuts match that search.",unassigned: "Unassigned",recording: "Press keys…",diff --git a/studio/frontend/src/i18n/locales/es.ts b/studio/frontend/src/i18n/locales/es.tsindex ac89871303d..28800430c31 100644--- a/studio/frontend/src/i18n/locales/es.ts+++ b/studio/frontend/src/i18n/locales/es.ts@@ -304,6 +304,9 @@ export const es = {keyboardShortcuts: {title: "Atajos de teclado",searchPlaceholder: "Buscar atajos…",+ keystrokePlaceholder: "Pulsa un atajo para buscar",+ searchByKeystrokes: "Buscar por pulsación",+ searchByName: "Buscar por nombre",noResults: "Ningún atajo coincide con esa búsqueda.",unassigned: "Sin asignar",recording: "Pulsa las teclas…",diff --git a/studio/frontend/src/i18n/locales/fr.ts b/studio/frontend/src/i18n/locales/fr.tsindex 921a0a767fe..5b7919488f1 100644--- a/studio/frontend/src/i18n/locales/fr.ts+++ b/studio/frontend/src/i18n/locales/fr.ts@@ -305,6 +305,9 @@ export const fr = {keyboardShortcuts: {title: "Raccourcis clavier",searchPlaceholder: "Rechercher des raccourcis…",+ keystrokePlaceholder: "Appuyez sur un raccourci pour rechercher",+ searchByKeystrokes: "Rechercher par frappe",+ searchByName: "Rechercher par nom",noResults: "Aucun raccourci ne correspond à cette recherche.",unassigned: "Non attribué",recording: "Appuyez sur les touches…",diff --git a/studio/frontend/src/i18n/locales/hi.ts b/studio/frontend/src/i18n/locales/hi.tsindex 96bccb3e89b..e42908702a6 100644--- a/studio/frontend/src/i18n/locales/hi.ts+++ b/studio/frontend/src/i18n/locales/hi.ts@@ -304,6 +304,9 @@ export const hi = {keyboardShortcuts: {title: "कीबोर्ड शॉर्टकट",searchPlaceholder: "शॉर्टकट खोजें…",+ keystrokePlaceholder: "खोजने के लिए शॉर्टकट दबाएँ",+ searchByKeystrokes: "कीस्ट्रोक से खोजें",+ searchByName: "नाम से खोजें",noResults: "इस खोज से कोई शॉर्टकट मेल नहीं खाता।",unassigned: "असाइन नहीं",recording: "कुंजियाँ दबाएँ…",diff --git a/studio/frontend/src/i18n/locales/it.ts b/studio/frontend/src/i18n/locales/it.tsindex 7086696de2d..a15370cac03 100644--- a/studio/frontend/src/i18n/locales/it.ts+++ b/studio/frontend/src/i18n/locales/it.ts@@ -269,6 +269,9 @@ export const it = {keyboardShortcuts: {title: "Scorciatoie da tastiera",searchPlaceholder: "Cerca scorciatoie…",+ keystrokePlaceholder: "Premi una scorciatoia per cercare",+ searchByKeystrokes: "Cerca per combinazione",+ searchByName: "Cerca per nome",noResults: "Nessuna scorciatoia corrisponde alla ricerca.",unassigned: "Non assegnata",recording: "Premi i tasti…",diff --git a/studio/frontend/src/i18n/locales/ja.ts b/studio/frontend/src/i18n/locales/ja.tsindex 79788893297..bd95873f106 100644--- a/studio/frontend/src/i18n/locales/ja.ts+++ b/studio/frontend/src/i18n/locales/ja.ts@@ -303,6 +303,9 @@ export const ja = {keyboardShortcuts: {title: "キーボードショートカット",searchPlaceholder: "ショートカットを検索…",+ keystrokePlaceholder: "ショートカットを押して検索",+ searchByKeystrokes: "キー入力で検索",+ searchByName: "名前で検索",noResults: "該当するショートカットはありません。",unassigned: "未割り当て",recording: "キーを押してください…",diff --git a/studio/frontend/src/i18n/locales/ko.ts b/studio/frontend/src/i18n/locales/ko.tsindex d09625ab9b6..e1bb2e59c88 100644--- a/studio/frontend/src/i18n/locales/ko.ts+++ b/studio/frontend/src/i18n/locales/ko.ts@@ -301,6 +301,9 @@ export const ko = {keyboardShortcuts: {title: "키보드 단축키",searchPlaceholder: "단축키 검색…",+ keystrokePlaceholder: "단축키를 눌러 검색",+ searchByKeystrokes: "키 입력으로 검색",+ searchByName: "이름으로 검색",noResults: "검색과 일치하는 단축키가 없습니다.",unassigned: "지정 안 됨",recording: "키를 누르세요…",diff --git a/studio/frontend/src/i18n/locales/pt-br.ts b/studio/frontend/src/i18n/locales/pt-br.tsindex 749e89f1666..008f1fd19bb 100644--- a/studio/frontend/src/i18n/locales/pt-br.ts+++ b/studio/frontend/src/i18n/locales/pt-br.ts@@ -303,6 +303,9 @@ export const ptBR = {keyboardShortcuts: {title: "Atalhos de teclado",searchPlaceholder: "Pesquisar atalhos…",+ keystrokePlaceholder: "Pressione um atalho para pesquisar",+ searchByKeystrokes: "Pesquisar por tecla",+ searchByName: "Pesquisar por nome",noResults: "Nenhum atalho corresponde a essa pesquisa.",unassigned: "Não atribuído",recording: "Pressione as teclas…",diff --git a/studio/frontend/src/i18n/locales/ru.ts b/studio/frontend/src/i18n/locales/ru.tsindex c0405fa5336..413fb270ad2 100644--- a/studio/frontend/src/i18n/locales/ru.ts+++ b/studio/frontend/src/i18n/locales/ru.ts@@ -303,6 +303,9 @@ export const ru = {keyboardShortcuts: {title: "Сочетания клавиш",searchPlaceholder: "Поиск сочетаний…",+ keystrokePlaceholder: "Нажмите сочетание для поиска",+ searchByKeystrokes: "Поиск по нажатию",+ searchByName: "Поиск по названию",noResults: "Ни одно сочетание не соответствует запросу.",unassigned: "Не назначено",recording: "Нажмите клавиши…",diff --git a/studio/frontend/src/i18n/locales/zh-CN.ts b/studio/frontend/src/i18n/locales/zh-CN.tsindex e78ad88b1b6..4fc864666d0 100644--- a/studio/frontend/src/i18n/locales/zh-CN.ts+++ b/studio/frontend/src/i18n/locales/zh-CN.ts@@ -299,6 +299,9 @@ export const zhCN = {keyboardShortcuts: {title: "键盘快捷键",searchPlaceholder: "搜索快捷键…",+ keystrokePlaceholder: "按下快捷键进行搜索",+ searchByKeystrokes: "按键搜索",+ searchByName: "按名称搜索",noResults: "没有匹配的快捷键。",unassigned: "未分配",recording: "请按下按键…",diff --git a/studio/frontend/tests/keyboard-shortcuts.test.ts b/studio/frontend/tests/keyboard-shortcuts.test.tsindex 7f31dc4927d..500b0258af4 100644--- a/studio/frontend/tests/keyboard-shortcuts.test.ts+++ b/studio/frontend/tests/keyboard-shortcuts.test.ts@@ -15,6 +15,7 @@ import {isAcceptableBinding,isBrowserReservedBinding,isShortcutId,+ keystrokeMatchesBinding,matchesBinding,parseBinding,} from "../src/features/settings/lib/keyboard-shortcuts.ts";@@ -1993,3 +1994,125 @@ test("the follow-up chords are registered in both composers", async () => {// The reason the second registration is needed rather than optional.assert.match(CHAT_PAGE, /<Thread hideComposer=\{true\}/);});++/** Searching the list by chord: the press narrows, it does not have to be exact. */+function chord(value: string) {+ const parsed = parseBinding(value);+ assert.ok(parsed, `unparsable test binding ${value}`);+ return parsed;+}++test("a keystroke search matches the chord it names", () => {+ assert.equal(+ keystrokeMatchesBinding(chord("Mod+Shift+KeyO"), chord("Mod+Shift+KeyO")),+ true,+ );+ assert.equal(+ keystrokeMatchesBinding(chord("Mod+Shift+KeyO"), chord("Mod+Shift+KeyN")),+ false,+ "a different key is a different chord",+ );+});++test("a keystroke search widens as modifiers come off", () => {+ // Bare O finds every chord on O, which is what makes the key alone a useful search.+ for (const bound of ["Mod+Shift+KeyO", "Mod+Alt+KeyO", "Mod+Alt+Shift+KeyO"]) {+ assert.equal(+ keystrokeMatchesBinding(chord("KeyO"), chord(bound)),+ true,+ bound,+ );+ }+ // ⇧⌘O keeps the ones carrying both, and drops ⌥⌘O.+ assert.equal(+ keystrokeMatchesBinding(chord("Mod+Shift+KeyO"), chord("Mod+Alt+Shift+KeyO")),+ true,+ );+ assert.equal(+ keystrokeMatchesBinding(chord("Mod+Shift+KeyO"), chord("Mod+Alt+KeyO")),+ false,+ );+});++test("a keystroke search never matches a chord missing a modifier it holds", () => {+ for (const pressed of ["Mod+KeyB", "Ctrl+KeyB", "Alt+KeyB", "Shift+KeyB"]) {+ assert.equal(+ keystrokeMatchesBinding(chord(pressed), chord("KeyB")),+ false,+ pressed,+ );+ }+});++test("the matcher finds every shipped default by its own chord and bare key", async () => {+ for (const def of SHORTCUT_DEFS) {+ for (const slot of SHORTCUT_SLOTS) {+ for (const mac of [true, false]) {+ const value = defaultBindingFor(def, slot, mac);+ if (!value) continue;+ const bound = chord(value);+ assert.equal(+ keystrokeMatchesBinding(bound, bound),+ true,+ `${def.id}.${slot} does not find itself`,+ );+ assert.equal(+ keystrokeMatchesBinding({ ...bound, mod: false, ctrl: false, shift: false, alt: false }, bound),+ true,+ `${def.id}.${slot} is not found by its bare key`,+ );+ }+ }+ }+});++test("the shortcuts tab arms the keystroke search ahead of Radix and the registry", async () => {+ const src = await readFile(+ new URL(+ "../src/features/settings/tabs/keyboard-shortcuts-tab.tsx",+ import.meta.url,+ ),+ "utf8",+ );+ // Capture phase, or the dialog's Escape closes it before the box sees the key.+ assert.match(+ src,+ /window\.addEventListener\("keydown", onKeyDown, \{ capture: true \}\)/,+ );+ // Keys read through bindingFromEvent, which carries the fallback for an engine+ // reporting no code. Off event.code, Tab and Escape would not be recognised there.+ const listener = src.slice(+ src.indexOf("if (!byKeystroke || recording) return;"),+ );+ assert.doesNotMatch(listener, /event\.code\s*===/);+ assert.match(listener, /const binding = bindingFromEvent\(event\);/);+ assert.match(listener, /binding\.code === "Escape"/);+ // The recorder owns the keyboard while it runs.+ assert.match(src, /if \(!byKeystroke \|\| recording\) return;/);+});++/**+ * Bare Escape is the one shipped default the chord box will not take as a query: it is+ * what backs out of the box. The recorder can free Escape because it swallows keys for a+ * single chord, while this mode persists, so a focused box would eat the dialog's own+ * dismiss for as long as it is on. The row stays reachable by name, where the query+ * matches the cap label too.+ */+test("the chord box keeps bare Escape, and the name search still finds that row", () => {+ const decline = SHORTCUT_DEFS.find((def) => def.id === "declineToolRequest");+ assert.ok(decline);+ assert.equal(defaultBindingFor(decline, "primary", true), "Escape");+ // What the name search matches on, since the label is part of its haystack.+ const escape = parseBinding("Escape");+ assert.ok(escape);+ assert.equal(formatBindingLabel(escape, true), "Esc");+ assert.ok(formatBindingLabel(escape, true).toLowerCase().includes("esc"));+ // The branch that reserves it, and the modifier that is left searchable.+ assert.match(+ KEYBOARD_SHORTCUTS_TAB,+ /binding\.code === "Escape" && bare && !binding\.shift/,+ );+ const shiftEscape = parseBinding("Shift+Escape");+ assert.ok(shiftEscape);+ assert.equal(shiftEscape.shift, true);+});diff --git a/tests/studio/playwright_settings_tabs.py b/tests/studio/playwright_settings_tabs.pyindex b6b20e5f772..d5ace07834d 100644--- a/tests/studio/playwright_settings_tabs.py+++ b/tests/studio/playwright_settings_tabs.py@@ -457,6 +457,89 @@ def assert_persisted_monitor_restores(page) -> None:report["steps"].append("persisted-monitor-reload")+def run_keystroke_search(page) -> None:+ """Searching the shortcut list by pressing a chord instead of typing its name.++ Ordering is the whole risk here: the press has to reach the box ahead of the+ shortcut it names and ahead of the dialog's own Escape, which only a real+ browser can settle.+ """+ open_dialog(page, "keyboard-shortcuts")+ settle_panel(page)+ rows_js = """() => [...document.querySelectorAll('[data-settings-label]')]+ .map(r => r.dataset.settingsLabel)"""+ box = page.locator(f"{PANEL} input")+ toggle = page.locator(f"{PANEL} button[aria-pressed]")+ click_forced(toggle, timeout = 15000)+ page.wait_for_timeout(SETTLE_MS)+ # Mod is Cmd on macOS and Ctrl everywhere else, and bindingFromEvent drops a Meta+ # chord off macOS outright, so a hardcoded Meta would record nothing on the Linux+ # runner. Same read as isMacPlatform(), which is what the app itself goes by.+ mac = page.evaluate(+ "() => /mac|iphone|ipad|ipod/i.test(`${navigator.platform} ${navigator.userAgent}`)"+ )+ mod = "Meta" if mac else "Control"+ state: dict = {"armed": toggle.get_attribute("aria-pressed"), "mod": mod}++ # A chord narrows to what answers to it: ⇧⌘O is New chat's, and New standalone+ # chat sits on ⌥⌘O, which does not carry the Shift.+ page.keyboard.press(f"{mod}+Shift+KeyO")+ page.wait_for_timeout(SETTLE_MS)+ state["chord"] = box.input_value()+ state["chord_rows"] = page.evaluate(rows_js)++ # The bare key widens to every chord built on it, ⌥⌘O included.+ page.keyboard.press("KeyO")+ page.wait_for_timeout(SETTLE_MS)+ state["bare_rows"] = page.evaluate(rows_js)++ # Escape backs out a step at a time, and the dialog stays open for both. A dialog+ # gone here is the bug this covers: the press reaching Radix before the box.+ page.keyboard.press("Escape")+ page.wait_for_timeout(SETTLE_MS)+ open_after_first = page.locator('div[role="dialog"]').count()+ state["after_first_escape"] = {+ "dialog": open_after_first,+ "value": box.input_value() if open_after_first else None,+ "rows": len(page.evaluate(rows_js)) if open_after_first else 0,+ }+ if open_after_first:+ page.keyboard.press("Escape")+ page.wait_for_timeout(SETTLE_MS)+ open_after_second = page.locator('div[role="dialog"]').count()+ state["after_second_escape"] = {+ "dialog": open_after_second,+ "armed": toggle.get_attribute("aria-pressed") if open_after_second else None,+ }+ else:+ state["after_second_escape"] = {"dialog": 0, "armed": None}+ report["keystroke_search"] = state++ if state["armed"] != "true":+ fail(f"keystroke search: the toggle did not arm ({state['armed']})")+ if not state["chord"]:+ fail("keystroke search: the pressed chord did not reach the box")+ if "New chat" not in state["chord_rows"]:+ fail(f"keystroke search: chord matched {state['chord_rows']}")+ if "New standalone chat" in state["chord_rows"]:+ fail(f"keystroke search: chord matched a lesser chord {state['chord_rows']}")+ if "New standalone chat" not in state["bare_rows"]:+ fail(+ f"keystroke search: the bare key did not widen "+ f"({state['bare_rows']} vs {state['chord_rows']})"+ )+ if state["after_first_escape"]["value"]:+ fail("keystroke search: the first Escape left the chord in the box")+ if state["after_first_escape"]["dialog"] != 1:+ fail("keystroke search: the first Escape closed the dialog")+ if state["after_second_escape"]["armed"] != "false":+ fail("keystroke search: the second Escape left the mode armed")+ if state["after_second_escape"]["dialog"] != 1:+ fail("keystroke search: the second Escape closed the dialog")+ page.evaluate("() => window.__settingsSmoke.close()")+ report["steps"].append("keystroke-search")++def run(page) -> None:if CHUNK_FAIL:run_chunk_fail(page)@@ -565,6 +648,8 @@ def run(page) -> None:log(f"search jump to '{target_label}': flashed, scrollTop {flashed['scrollTop']}")report["steps"].append("search-jump")+ run_keystroke_search(page)+report["page_errors"] = page.evaluate("() => window.__settingsSmoke.errors()")