Problem
The Rust MCP contract suite currently documents a live limitation:
act with kind: "focus" and a DOM ref fails instead of focusing the referenced element.
The contract case is named act: focus by ref reports the current DOM-domain limitation in packages/browseros-agent/contracts/claw-mcp/tests/cases-act.ts.
While debugging PR #2583, the same underlying path surfaced in CI as:
act failed: CDP error: Document needs to be requested first
That error came from the core focus path:
packages/browseros-agent/crates/browseros-core/src/input/geometry.rs
focus_element() calls DOM.pushNodesByBackendIdsToFrontend
- then calls
DOM.focus
In the BrowserOS CI browser, DOM.pushNodesByBackendIdsToFrontend can fail unless the DOM document has first been requested for that session.
Impact
Agents can click/fill/type referenced elements, but cannot reliably call the explicit focus action by ref. This also makes future ref-targeted keyboard behavior easy to regress, because focusing via the DOM domain is not usable in every session state.
Expected behavior
act { kind: "focus", ref } should focus the referenced element successfully, or core should use a focus implementation that does not require prior DOM.getDocument state for the session.
Possible fix
Use the runtime/object path already used by other semantic ref actions:
- Resolve the backend node with
DOM.resolveNode.
- Call
Runtime.callFunctionOn with this.focus().
- Keep the existing DOM-domain
DOM.focus path only if there is a reason it is preferred after DOM.getDocument.
PR #2583 added a runtime focus path for press(ref) because it hit this limitation; the standalone focus action still uses the brittle DOM-domain path.
Problem
The Rust MCP contract suite currently documents a live limitation:
actwithkind: "focus"and a DOMreffails instead of focusing the referenced element.The contract case is named
act: focus by ref reports the current DOM-domain limitationinpackages/browseros-agent/contracts/claw-mcp/tests/cases-act.ts.While debugging PR #2583, the same underlying path surfaced in CI as:
That error came from the core focus path:
packages/browseros-agent/crates/browseros-core/src/input/geometry.rsfocus_element()callsDOM.pushNodesByBackendIdsToFrontendDOM.focusIn the BrowserOS CI browser,
DOM.pushNodesByBackendIdsToFrontendcan fail unless the DOM document has first been requested for that session.Impact
Agents can click/fill/type referenced elements, but cannot reliably call the explicit focus action by ref. This also makes future ref-targeted keyboard behavior easy to regress, because focusing via the DOM domain is not usable in every session state.
Expected behavior
act { kind: "focus", ref }should focus the referenced element successfully, or core should use a focus implementation that does not require priorDOM.getDocumentstate for the session.Possible fix
Use the runtime/object path already used by other semantic ref actions:
DOM.resolveNode.Runtime.callFunctionOnwiththis.focus().DOM.focuspath only if there is a reason it is preferred afterDOM.getDocument.PR #2583 added a runtime focus path for
press(ref)because it hit this limitation; the standalone focus action still uses the brittle DOM-domain path.