Agent Zero AI framework
Keep WebUI browser frames on base64 fallback
Alessandro727a840e10c1
diff --git a/plugins/_browser/AGENTS.md b/plugins/_browser/AGENTS.mdindex e3f2a137e..e80bbe016 100644--- a/plugins/_browser/AGENTS.md+++ b/plugins/_browser/AGENTS.md@@ -19,7 +19,7 @@- Preserve Playwright lifecycle cleanup and WebSocket viewer compatibility across regular host browsers and Electron WebContentsView embedding.- Keep the WebUI Browser inside its own modal/canvas affordance; do not replace it with page-level navigation.- Default the visible WebUI Browser to live CDP screencast for responsiveness. Keep lightweight CDP/DOM state snapshots as the fallback transport.-- Keep Browser viewer frame transport capability-negotiated: updated clients may request binary/slim screencast frames, while older clients must keep the base64/full-metadata fallback.+- Keep Browser viewer frame transport capability-negotiated: updated clients may request binary/slim screencast frames, while older clients must keep the base64/full-metadata fallback. Do not let the WebUI advertise binary frames unless its Socket.IO client reconstructs attachments as real `Blob`, `ArrayBuffer`, or typed-array values.- Keep narrow WebUI Browser controls usable by grouping navigation with Annotate/settings above a full-width address bar.- Browser URL-intent handling must only claim web URL schemes and leave custom Agent Zero schemes to their owning surfaces.- Prefer DOM/CDP browser actions with refs, selectors, frame-chain refs, and screenshots over viewport coordinate input. Coordinates remain a visual fallback.diff --git a/plugins/_browser/webui/browser-store.js b/plugins/_browser/webui/browser-store.jsindex a4b3d4525..c2fdcd84b 100644--- a/plugins/_browser/webui/browser-store.js+++ b/plugins/_browser/webui/browser-store.js@@ -34,7 +34,8 @@ const ANNOTATION_DOM_LIMIT = 1200;const ANNOTATION_TRAY_MARGIN = 10;const BROWSER_VISUAL_SHORTCUT_KEYS = new Set(["a", "c", "insert", "v", "x", "y", "z"]);const LOCAL_EDITABLE_SELECTOR = "input, textarea, select, [contenteditable]";-const BROWSER_BINARY_FRAMES_SUPPORTED = typeof Blob === "function"+const BROWSER_BINARY_FRAME_REQUESTS_ENABLED = false;+const BROWSER_BINARY_PAYLOADS_SUPPORTED = typeof Blob === "function"&& typeof globalThis.URL?.createObjectURL === "function";function makeViewerToken() {@@ -123,8 +124,8 @@ function frameImageSource(data = {}) {const isArrayBuffer = typeof ArrayBuffer !== "undefined" && image instanceof ArrayBuffer;const isView = typeof ArrayBuffer !== "undefined" && ArrayBuffer.isView?.(image);const isBlob = typeof Blob !== "undefined" && image instanceof Blob;- if (data.encoding === "binary" || isArrayBuffer || isView || isBlob) {- if (!BROWSER_BINARY_FRAMES_SUPPORTED) return null;+ if (isArrayBuffer || isView || isBlob) {+ if (!BROWSER_BINARY_PAYLOADS_SUPPORTED) return null;const blob = isBlob ? image : new Blob([image], { type: mime });const src = globalThis.URL.createObjectURL(blob);return {@@ -133,6 +134,7 @@ function frameImageSource(data = {}) {cleanup: () => globalThis.URL.revokeObjectURL(src),};}+ if (data.encoding === "binary") return null;if (typeof image !== "string") return null;return {src: `data:${mime};base64,${image}`,@@ -944,7 +946,7 @@ const model = {},supportsBinaryFrames() {- return BROWSER_BINARY_FRAMES_SUPPORTED;+ return BROWSER_BINARY_FRAME_REQUESTS_ENABLED && BROWSER_BINARY_PAYLOADS_SUPPORTED;},captureDevicePixelRatio() {diff --git a/tests/test_browser_agent_regressions.py b/tests/test_browser_agent_regressions.pyindex 7503efeb3..2cc355a14 100644--- a/tests/test_browser_agent_regressions.py+++ b/tests/test_browser_agent_regressions.py@@ -1182,6 +1182,9 @@ def test_browser_viewer_defaults_to_live_screencast_with_snapshot_fallback():assert "queueFrameRender" in browser_storeassert "requestAnimationFrame" in browser_storeassert "function frameImageSource(data = {})" in browser_store+ assert "const BROWSER_BINARY_FRAME_REQUESTS_ENABLED = false;" in browser_store+ assert "const BROWSER_BINARY_PAYLOADS_SUPPORTED = typeof Blob" in browser_store+ assert "if (data.encoding === \"binary\") return null;" in browser_storeassert 'const BROWSER_VIEWER_TRANSPORT_SNAPSHOT = "snapshot";' in browser_storeassert 'const BROWSER_VIEWER_TRANSPORT_SCREENCAST = "screencast";' in browser_storeassert "viewerTransport: BROWSER_VIEWER_TRANSPORT_SCREENCAST" in browser_store