Agent Zero AI framework
Preserve fallback Alt shortcuts
Alessandroefb8401e66ba
diff --git a/plugins/_browser/AGENTS.md b/plugins/_browser/AGENTS.mdindex 240cb0c81..20b8fb6b5 100644--- a/plugins/_browser/AGENTS.md+++ b/plugins/_browser/AGENTS.md@@ -48,7 +48,7 @@- Annotation voice input reuses Whisper STT's configured draft/send delivery mode and shared microphone state.- Internal-browser proxy settings map directly to Playwright's persistent-context proxy option, never to Bring Your Own Browser, and changes must restart active internal runtimes.- Run internal Chromium headful through Patchright on the private virtual display; do not add user-agent or header spoofing on top of the patched driver.-- Browser keyboard layout settings (`keyboard_layout`/`keyboard_variant`, e.g. `de`/`mac`) apply the configured XKB layout to the private browser display with setxkbmap and pin it on the Xpra shadow server so non-US keyboards type their printed characters; layout changes flow through `browser_runtime_config` and restart internal runtimes.+- Browser keyboard layout settings (`keyboard_layout`/`keyboard_variant`, e.g. `de`/`mac`) apply the configured XKB layout to the private browser display with setxkbmap and pin it on the Xpra shadow server so non-US keyboards type their printed characters; layout changes flow through `browser_runtime_config` and restart internal runtimes. Fallback canvas input forwards AltGraph and macOS Option text without converting ordinary Alt shortcuts into text.- Browser startup and on-demand launch must converge on the Chromium revision declared by Patchright; let its installer select the host architecture rather than hardcoding x64 or ARM downloads.- `hooks.prepare_playwright_cache()` owns reconciliation of the pinned Patchright package and Chromium binary so repository self-updates and fresh images use the same setup path.- Browser startup must install the shared virtual-desktop route hook itself; do not make Browser depend on the Desktop plugin being enabled.diff --git a/plugins/_browser/webui/browser-store.js b/plugins/_browser/webui/browser-store.jsindex e85ac38f1..3cd80f413 100644--- a/plugins/_browser/webui/browser-store.js+++ b/plugins/_browser/webui/browser-store.js@@ -86,6 +86,22 @@ function isLocalEditableTarget(target) {return ["", "true", "plaintext-only"].includes(value);}+function isAltTextInput(event, platform = "") {+ const key = String(event?.key || "");+ if (key.length !== 1 || !event?.altKey || event.metaKey) return false;+ const targetPlatform = String(+ platform+ || globalThis.navigator?.userAgentData?.platform+ || globalThis.navigator?.platform+ || "",+ );+ return Boolean(+ event.ctrlKey+ || event.getModifierState?.("AltGraph")+ || /mac/i.test(targetPlatform),+ );+}+function nextAnimationFrame() {return new Promise((resolve) => {const schedule = globalThis.requestAnimationFrame || ((callback) => globalThis.setTimeout(callback, 16));@@ -2909,8 +2925,8 @@ const model = {const contextId = this.normalizeContextId(this.activeBrowserContextId || this.contextId);if (!contextId || !this.activeBrowserId) return;const printable = event.key && event.key.length === 1;- const altGrText = printable && event.altKey && !event.metaKey;- if ((event.ctrlKey || event.metaKey || event.altKey) && !altGrText) return;+ const altText = isAltTextInput(event);+ if ((event.ctrlKey || event.metaKey || event.altKey) && !altText) return;if (isLocalEditableTarget(event?.target)) return;event.preventDefault();await websocket.emit("browser_viewer_input", {diff --git a/tests/test_browser_agent_regressions.py b/tests/test_browser_agent_regressions.pyindex 7da3b37ef..2197fb419 100644--- a/tests/test_browser_agent_regressions.py+++ b/tests/test_browser_agent_regressions.py@@ -1973,6 +1973,28 @@ def test_browser_visual_mode_bridges_clipboard_shortcuts():assert 'runtime.call(\n "clipboard"' in ws_browser+def test_browser_visual_mode_only_forwards_text_producing_alt_keys():+ browser_store = (+ PROJECT_ROOT / "plugins" / "_browser" / "webui" / "browser-store.js"+ ).read_text(encoding="utf-8")+ start = browser_store.index("function isAltTextInput")+ end = browser_store.index("\n}\n", start) + 3+ helper = browser_store[start:end]+ script = helper + """+const check = (condition, message) => {+ if (!condition) throw new Error(message);+};+check(isAltTextInput({ key: "@", altKey: true, ctrlKey: true }, "Windows"), "AltGr text was blocked");+check(isAltTextInput({ key: "€", altKey: true, getModifierState: (name) => name === "AltGraph" }, "Linux"), "AltGraph text was blocked");+check(isAltTextInput({ key: "@", altKey: true }, "MacIntel"), "Option text was blocked");+check(!isAltTextInput({ key: "f", altKey: true }, "Windows"), "Windows Alt shortcut became text");+check(!isAltTextInput({ key: "d", altKey: true }, "Linux"), "Linux Alt shortcut became text");+check(!isAltTextInput({ key: "@", altKey: true, metaKey: true }, "MacIntel"), "Command shortcut became text");+"""++ subprocess.run(["node", "--input-type=module", "-e", script], check=True, text=True)++def test_browser_runtime_and_content_helper_expose_annotation_target():runtime = (PROJECT_ROOT / "plugins" / "_browser" / "helpers" / "runtime.py"