Repository navigation
Description
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
- 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.comframe inside the merchant's checkout. A local repro works too: a page onlocalhostthat embeds<iframe src="http://127.0.0.1:<port>/field">with an<input>inside it. - Leave keyboard focus in the chat composer, which is the normal state while an agent works.
- Have the agent click the field (
preview_clickon its ref), then type withpreview_type(with the field's ref) orpreview_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 agent's click does land in the field (fix(desktop): agent clicks reach cross-site iframes in preview tabs that aren't on screen #41611).
- Focus then goes back to the composer (fix(desktop): preserve host focus on preview pointer presses #28549), so the preview never has focus when the keys arrive.
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.insertTextcrashes the guest when a cross-site frame has focus.sendInputEventonly 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.
Activity