Skip to content

[Bug]: Agent typing into a cross-site iframe field is refused while the desktop preview isn't focused #44003

Done

Description

@arifali123

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/desktop

Steps to reproduce

  1. In T3 Code Desktop, have an agent open a preview tab on a page whose text field lives in a cross-site iframe. Stripe's card fields are a common case: they're a js.stripe.com frame inside the merchant's checkout. A local repro works too: a page on localhost that embeds <iframe src="http://127.0.0.1:<port>/field"> with an <input> inside it.
  2. Leave keyboard focus in the chat composer, which is the normal state while an agent works.
  3. Have the agent click the field (preview_click on its ref), then type with preview_type (with the field's ref) or preview_press.

Expected behavior

The text goes into the field inside the iframe.

Actual behavior

Every key or text command fails with:

Protocol error (Input.dispatchKeyEvent): The page's focus is inside a cross-site frame, which takes typed input only while the preview has focus. Click the field first.

The field stays empty. The advice in the message doesn't help:

The only way through is for a person at the host to type into the field themselves. When T3 is driven remotely (mobile, app.t3.codes, T3 Connect), there may be nobody at the host to do that. Judging from the code, text a remote viewer types goes through the same check, so a person typing from the mobile app gets the same refusal.

The refusal was added on purpose in #18556, because the safe routes at the time all failed:

  • The page session's CDP key input follows window focus into the app's own page.
  • webContents.insertText crashes the guest when a cross-site frame has focus.
  • sendInputEvent only reaches the main-frame process.

The check is in sendPageCommand in apps/desktop/src/preview/GuestInput.ts.

An earlier report of the same error, from an agent pressing keys in a cross-origin Shopify Admin iframe, is the latest comment on #22095. That issue is about physical typing landing in the composer, which is a separate bug.

Impact

Blocks work completely

Version or commit

0.1.13-nightly.20261126.5305

Environment

macOS 27.2.1, T3 Code (Nightly) desktop with its bundled local server, embedded preview tab, Claude Code provider

Workaround

A person at the host machine types into the field themselves. That isn't possible when T3 is driven remotely.

Proposed fix

#43516 sends key and text input to the focused cross-site frame's own CDP session, using the frame sessions #41611 already tracks. It finds the frame through the page's focus chain, including nested cross-site frames and frames behind a same-site wrapper. If no session is found, it keeps the existing refusal. Clipboard commands are still dropped, so the person's clipboard is never read or replaced.

I checked it in Electron 44.10.1 by running the PR's actual GuestInput.ts against a <webview> guest:

  • The host window had a focused "composer" field.
  • The guest's card field was in an out-of-process cross-site frame.
  • I tried the frame directly in the page, nested inside another cross-site frame, and behind a same-site wrapper frame.
  • I ran each with the window hidden and with it shown.

In every run, insertText, key presses (including Backspace) and Cmd+A with selectAll landed in the iframe field. The composer and the page's own field stayed empty. The same setup without the routing still refused.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions