Skip to content

Spike: nested-frame keyboard delivery and disappearing custom menus (dogfood observations) #26

Closed

Description

@SSFSKIM

Question

Two behaviours from the dogfood run need isolation before any fix or guidance: (1) locator press on a nested iframe's body timed out while coordinate focus plus tab-level keyboard input worked, and lowercase f key presses did not advance a widget while uppercase F after refocusing did; (2) open custom dropdown menus sometimes vanished between calls, so option selection found no match until the menu was reopened and selected immediately.

Method

Owned fixture pages (nested iframe with a key listener; a custom listbox) served locally; serial calls through cua serve; test keyboard delivery by frame target and key case, and menu persistence across two consecutive calls with no user activity.

Deliverable

Findings comment with the reproduced or refuted behaviours and the resulting guidance (host notes or README) or a bug ticket against the vendor API usage in cua.

Activity

  1. added
    status:ready-for-implementer
    priority:P3
    spike
    status:in-progress
    and removed
    status:ready-for-implementer
    on Oct 5, 2026
  2. SSFSKIM commented on Oct 6, 2026

    @SSFSKIM
    OwnerAuthor

    Spike #26 findings (2026-10-05, live run through cua serve, profile personal)

    Setup. I served owned fixtures on 127.0.0.1:48761: a nested iframe (#outer > #inner) whose inner document logs keydown/keypress on body, on a div#widget[tabindex=0] and on the document, with event.key, code, keyCode, shiftKey, target, activeElement, hasFocus and visibilityState; and three custom listboxes. Listbox A closes on focusout, outside mousedown, visibilitychange and window blur, and logs which one fired. B closes on a 2 s timer. C closes only on toggle. The fixtures live outside the repo (job tmp). I opened one tab (tabs.new 80 ms, goto 366 ms), ran every js call serially, then closed the tab; end_task returned ended. The vendor opened the tab visible, and visibilityState read visible at every read. I did not touch any other tab to push it to the background, so hidden-tab behaviour was not exercised.

    API cited from the browser document the first getBrowser returned: PlaywrightLocator.press(value, {timeoutMs}), pressSequentially(value, …), PlaywrightFrameLocator.frameLocator/locator, CUAAPI.click({x,y}), CUAAPI.keypress({keys}) ("press control characters at the current focused element (focus it first via click/dblclick)"), CUAAPI.type({text}).

    1. Nested-frame keys: the timeout reproduced; "lowercase is broken" refuted

    Call Result
    frameLocator('#outer').frameLocator('#inner').locator('body').press('f') fails after 3,045 ms with Playwright selector deadline exceeded; the diagnostics say matchCount:1, visible:true, and no key event reaches the page
    the same with {timeoutMs:1500} fails at 1,500 ms
    tab.playwright.locator('body').press('f') (top document) ok, 147 ms
    frameLocator('#outer').locator('body').press('f') (one level deep) fails, 2,539 ms
    inner.locator('[tabindex]').press('f') ok, 44 ms: window.focus then widget.focus, then keydown key="f" code=KeyF keyCode=70 target=div#widget
    #widget.press('F') / ('Shift+f') / ('Shift+F') / ('f') all ok (28 to 59 ms). 'F' gives key="F", keyCode 70, shiftKey=false. 'Shift+f' and 'Shift+F' give a Shift keydown, then key="F" with shiftKey=true
    #widget.pressSequentially('fF') fails, 2,533 ms (needs an editable element)
    top h1.click(), then tab.cua.keypress({keys:['f']}) returns ok; nothing reaches the inner frame, because the keys go to the focused top document
    tab.cua.click({x:132,y:179}) on the widget, then cua.keypress with ['f'], ['F'], ['shift','f'], ['SHIFT','F'] all delivered to div#widget, with the same key/shift semantics as press
    tab.cua.type({text:'f'}) / {text:'F'} return ok, but no key event at all

    Mechanism (vendor @oai/browser-desktop browser-service.mjs, chatgpt-26.928.40906):

    • playwright_locator_press focuses the target through focusLocator → K1 (around line 56676) before sending the key. K1 calls focusNode and then requires expect(el, 'to.be.focused'), and it throws Element is not focused, which is retried until the 3 s deadline. A subframe's body cannot take focus, and that frame's document does not have focus, so the check never passes. The top-level body passes because it is already the active element of the focused document. The cause is therefore the vendor's strict focus check, not the frame depth and not the transport. The surfaced "selector deadline exceeded" with matchCount:1 hides the real reason. That is vendor diagnostics, which cua cannot change.
    • pressSequentially checks visible, enabled, editable (prepareSequentialInput), so it cannot drive a non-editable widget.
    • cua_type → Vi performs a clipboard paste, not key events, so it does nothing for key-driven widgets.
    • Key case follows Playwright semantics: f and F share code KeyF and keyCode 70. They differ only in event.key (and in the keypress charCode, 102 vs 70), and 'F' does not hold Shift.
    • The benchmark's T7 is consistent with this: it pressed on a focusable <input>.

    The dogfood "lowercase f did nothing; refocus plus F worked" is best explained by focus. The lowercase presses went wherever focus was: the frame-body press timed out, and an unfocused cua.keypress lands in the top document. The refocus is what fixed it. Case matters only to a page that compares event.key case-sensitively, reads the keypress charCode, or checks shiftKey.

    2. Disappearing custom menus: refuted as a cua/vendor effect under cua serve

    Step Result
    Call 1: #btn-a.click() (628 ms) A open at 01:14:18.2Z
    Read-only calls after ~3.0 s, ~9.6 s and ~39 s of idle A still open; no blur, focusout, visibilitychange or mousedown logged
    Reopen A, then one call with tab.screenshot(), domSnapshot(), dom_cua.get_visible_dom(), dev.logs(), title()/url() A open after each one
    A further ~131 s of idle across calls A still open; getByRole('option',{name:'Bravo'}).click() in that later call worked (1,066 ms)
    Timer variant B: opened in one call, read 3.4 s later closed with CLOSE by timer2s; the option click then fails with Locator diagnostics: {"kind":"no_matches", …, "matchCount":0}, the exact dogfood signature

    Mechanism. On debugger attach the vendor enables Emulation.setFocusEmulationEnabled (enableFocusEmulation, around line 48116), so the page keeps hasFocus()===true and sees no window blur while the owner uses other apps. It detaches tabs only in detachTurn, which runs on turn_ended (around lines 64752 and 68043). cua sends turn_ended only from end_task or on connection close (src/mcp/task.mjs #beginEnding), so within one task nothing the backend does between calls removes focus from the page. The dogfood closures therefore came from the site (a timer, hover-out, a re-render after a slow load) or from a real visibility change (the tab hidden by the user or by the extension; the benchmark's pw-report shows the latter happening). Not verified here: hidden-tab behaviour, and whether a turn-end detach blurs the page. The second applies to the Codex/ChatGPT app, which ends a turn every model turn, not to cua serve.

    Guidance

    Host notes (src/mcp/surface.mjs, 2,035/2,048 characters). Replace two lines; the net change is +11, which gives about 2,046:

    • - Chrome tabs are DOM-only: act through tab.playwright locators, not native typeText/click. →
      - Chrome tabs are DOM-only: act through tab.playwright locators, not native typeText/click. Press keys on a focusable element, never a frame's body; tab.cua.type pastes, sending no keys.
    • The 3 s line →
      - Browser locator actions, waits and evaluate stop at 3 s (timeoutMs can only shorten it); to wait longer, loop short waits to your own deadline under a larger js timeout_ms.
      The BROWSER_RULES 3 s pattern in test/mcp-browser-surface.test.mjs pins the old wording verbatim and would change with it.

    README, browser troubleshooting:

    • "press('F') sends key "F" without Shift (Playwright semantics); use 'Shift+F' when the page checks shiftKey."
    • "An option locator reporting no_matches after a menu opened in an earlier call means the site closed it; cua keeps page focus between calls. Open and select in the same call."

    No cua bug was found, so I am proposing no ticket. Side observation: the read-only evaluate world also lacks parseFloat and document.hasFocus, beyond the documented no fetch/require.

  3. removed
    status:in-progress
    on Oct 6, 2026
  4. SSFSKIM commented on Oct 6, 2026

    @SSFSKIM
    OwnerAuthor

    [board] done: Frame-body press fails on the vendor focus check (press a focusable element instead; cua.type pastes, so it sends no keys); menus are closed by the site, not cua (focus emulation holds until end_task). Host-note swap proposed, no cua bug.

  5. added a commit that references this issue on Oct 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority:P3spike

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions