[Bug]: Typing after clicking a field inside a cross-origin iframe in the preview goes to the chat composer #22095
Before submitting#
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area#
Not sure
Steps to reproduce#
No account is needed, and nothing gets submitted.
In T3 Code Desktop on macOS, have an agent open a visible preview tab on a page whose input lives in a cross-origin iframe. Apple's sign-in page works: its form is an
idmsa.apple.comiframe insideappstoreconnect.apple.com.preview_open({ open: true, reuseExistingTab: false, url: "https://appstoreconnect.apple.com/login" })In the embedded preview, click the Email or Phone Number field with the mouse.
Type
teston the physical keyboard.
Expected behavior#
test goes into the Email or Phone Number field.
Actual behavior#
test appears in the thread's chat composer, and the field stays empty: the next preview_snapshot shows the textbox with no value.
Two controls, run in the same session and the same embedded preview:
- Input in the top frame works. A local page with a plain
<input>and a second<input>inside a fixed-position modal received the user's clicks and typing. A capture-phase logger recorded trustedpointerdown,focusin, andinputevents, and the fields ended up holdingabcandxyz. - Agent input into the same iframe field works.
preview_clickon the field'saria-ref, thenpreview_pressforx,y,z, left the field holdingxyz.
Only physical keyboard input after a physical click inside a cross-origin iframe goes astray. The top document recorded no events from the click, as expected for a cross-origin frame, and its activeElement stayed the iframe.
The same symptom showed up on the signed-in App Store Connect New App dialog the day before (0.1.1-nightly.20261019.3373): typing into its Name field did nothing. After the user's click, the top document's activeElement was BODY. I did not check whether that dialog's field is inside an iframe.
Possibly related:
- #19488: the composer's type-to-focus redirect and window refocus path;
shouldRefocusComposerOnWindowFocuslists iframes and webviews. - #19673: separate preview window input fails on Windows/WSL.
- #10980 and #21954: focus handling around agent preview clicks.
Impact#
Major degradation or frequent failure
Version or commit#
0.1.1-nightly.20261020.3386
Environment#
macOS 27.0.1, T3 Code (Nightly) desktop app on its bundled local server, embedded preview tab (page user agent reports Electron 44.4.5, Chrome 152.0.7977.130), Claude Code provider
Workaround#
Have the agent type into the field with preview_click and preview_type or preview_press. That does not suit passwords or other secrets, which would then pass through the agent.
juliusmarminge added labelsbug
juliusmarminge added labelsaccepted
juliusmarminge added labelsvia-triage
@dpearson2699 I tried this on macOS with App Store Connect and a local page with cross-site iframes, but couldn’t reproduce text going into the chat composer. Which T3 Code version and OS version are you using? Does it happen every time, and are there any specific steps before clicking the field (like clicking the chat composer or switching preview tabs)? A short screen recording would help too.
juliusmarminge added labelsneeds more info
juliusmarminge removed labelsneeds more info
I tried this on Windows 11 with a dev desktop build of current main (28286d523f), driving trusted CDP mouse and key input on the host window, and could not reproduce it either.
Scenario Host activeElementafter the clickWhere testlandedTop-frame input (control) WEBVIEWtop-frame input Cross-site iframe input (out of process), preview already focused WEBVIEWiframe input Same, composer focused first WEBVIEWiframe input appstoreconnect.apple.com/login, composer focused firstWEBVIEWApple Email field Host focus reached the webview about 12 ms after each click, so the composer redirect never saw the keys.
What I could not cover: real OS input with window activation (click on an unfocused app window, then the window
focusrefocus path inChatView), a preview opened bypreview_openrather than the panel, and macOS.@dpearson2699, if it still happens for you, the deciding detail is the host document's
document.activeElementright after the click.BODYwould mean focus never reaches the preview.WEBVIEWwould mean the keys come from somewhere other than type-to-focus. It would also help to know whether the T3 window was already focused before the click.I tried this again on current main (79f6cd30c7) with the desktop app on Linux, using real mouse and keyboard input. The test page had its field inside a cross-site iframe (the page on
localhost, the iframe on127.0.0.1).Scenario App's document.activeElementafter the clickWhere testlandedT3 window focused, composer focused, click the iframe field WEBVIEWiframe field Another window focused, then one click on the iframe field activates T3 (composer was focused before) WEBVIEWiframe field Same, with nothing focused in the app before WEBVIEW, 3 ms after the window regained focusiframe field With the Windows and macOS attempts above, nobody has reproduced this yet. If it still happens for you on a current nightly:
- Open View → Toggle Developer Tools. That's the app's own DevTools, not the preview's. Paste this into its Console:
addEventListener("keydown", (e) => console.log("app got key", e.key, "focus:", document.activeElement.tagName), true); addEventListener("focus", () => setTimeout(() => console.log("window focus, 50ms later:", document.activeElement.tagName), 50)); - Click the Email field in the preview and type
test. - Reply with the Console output, whether the T3 window was already the active window before your click, and the nightly version.
If "app got key" lines show up, the keys are reaching the app's own page instead of the preview. If they don't, the keys reach the composer some other way.
- Open View → Toggle Developer Tools. That's the app's own DevTools, not the preview's. Paste this into its Console:
juliusmarminge added labelsneeds more info
I tried this on macOS 15.7.9 with an unpackaged desktop build of main (36d4d711b7, Electron 44.9.3) launched through Playwright
_electron, using real HID mouse and keyboard input and the two listeners above in the app's own page. Playwright's focus emulation was turned off, anddocument.hasFocus()was checked false before every b–d click. The test page was onlocalhostwith its field in a cross-site iframe on127.0.0.1, running out of process.Scenario App's document.activeElementafter the clickWhere testlandeda. T3 window focused, composer focused, click the iframe field WEBVIEW(3/3), noapp got keylinesiframe field (3/3) b. Another app's window in front (composer was focused before), one click on the iframe field activates T3 composer DIV(3/3):window focus, 50ms later: DIV, thenapp got key t focus: DIVfor each keycomposer (3/3) c. Same as b, clicking the top-frame field composer DIV(3/3), same console lines as bcomposer (3/3) d. Same as b, with the change below WEBVIEW(3/3):window focus, 50ms later: WEBVIEW, noapp got keylinesiframe field (3/3) In this setup it reproduces only when the click is the one that activates the T3 window. On macOS that click is not delivered to the page, because Electron's
acceptFirstMousedefaults to false. No frame logged apointerdown, focus stayed in the composer, and the typing went there. This is the window-activation case voida6 listed as uncovered. It would explain why it did not show on Windows or Linux, where the activating click is delivered. An earlier Windows 11 run with real input, including 12 attempts where the click activated the window, typed into the clicked field 36/36.Setting
acceptFirstMouseon the macOS main window made d pass:- ...(environment.platform === "darwin" ? { disableAutoHideCursor: true } : {}), + ...(environment.platform === "darwin" + ? { acceptFirstMouse: true, disableAutoHideCursor: true } + : {}),in
apps/desktop/src/window/DesktopWindow.ts. With it, the activating click passes through anywhere in the main window, buttons included. Whether that is wanted is for maintainers to decide.It is not established that this is the reporter's exact case: their top-frame control worked, while here the top-frame field failed the same way (c).
Recording of b: main-36d4d71-b-cross-site-activating-click-recording.mp4. Stills after typing: b on main, d with the change. Per-attempt results: results-36d4d71-a-d.json. Test page and runner: server.mjs, runner3.py.
Not checked: the packaged Nightly, macOS 26/27, a Retina display, a preview opened by an agent through
preview_open, the App Store Connect page, and the activating click with nothing focused in the app before it.Model: Claude Opus 5.5 via Claude Code, in T3 Code; reviewed by GPT-6.1-Sol (Codex).
juliusmarminge removed labelsneeds more info
dpearson2699(GitHub profile, opens in a new tab) linked this to #31777
Another report, from a packaged release build on macOS. This one doesn't look like the window-activation case. The T3 window was already active and I clicked into the field many times, but typing still went to the composer. The tab had been opened by an agent, which is one of the cases the last comment hadn't checked.
Environment
- T3 Code (Beta) desktop 0.1.9 (release, not a dev build), Electron 44.10.1
- macOS 26.6.2, Apple silicon
- Local server 0.1.9, same machine
- Page: a local dev app on
http://localhost:3000. The inputs are ordinary top-frame<input>s; no iframe is involved.
What happened
- An agent opened the page in a browser tab with
preview_openand drove it. - The agent's turn then paused at an AskUserQuestion prompt ("Input requested"), so the turn stayed active.
- I clicked into text inputs on the page many times, with T3 already the active window, and typed. Every key went into the chat composer. The page's input kept showing a text cursor and a focused style the whole time.
- Reloading the page didn't help, and neither did right-click → Paste in the field.
- Opening a new T3 browser tab to the same URL fixed it. Typing there went into the page.
From the traces
- An agent opened that tab and attached a control session about a minute before the recording:
ws.rpc.preview.open,PreviewAutomationBroker.focusHost, andPreviewManager.createControlSession, all at the same second. The session detached about 2.5 minutes later. - If I'm reading
DesktopBrowserHost.tsright,setFocusEmulationkeeps an agent-used tab focus-emulated while the agent's turn is active ("its tab stays focused until the turn ends"). That would explain why the page showed a focused input even though native keyboard focus stayed in the host's composer. It would also explain why a fresh tab with no agent attached works.
So this looks like a second path to the same symptom: an agent-attached, focus-emulated tab whose human clicks never take native keyboard focus away from the host. #31777 (
acceptFirstMouse) wouldn't seem to cover it, since the window was already active.Workaround: open a new browser tab that no agent is driving, or end the agent's turn.
https://github.com/user-attachments/assets/2d2bb341-5576-4646-b0d7-c7e715417a1c
Triage done with Claude Opus 5.5 via Claude Code, running in T3 Code (
t3 triageplaybook).Related data point from T3 Code (Beta) 0.1.10 on macOS 26.6.2 (Apple silicon). In Shopify Admin, the embedded Squadkin Form Builder translation editor renders its text inputs inside a cross-origin iframe.
After clicking an empty field with the desktop preview in the foreground, an agent's keyboard action (
preview_actwithaction: "press") returned: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.
A physical click on the field with the window already in the foreground did not clear that error. The field remained empty. This differs from the original report's agent-input control, which succeeded after the click. We haven't confirmed where physical keystrokes land in a fresh tab, so this is evidence about agent input and focus detection, not a second confirmation of the composer receiving physical keystrokes.
Sign in to join this conversation.
Note
Grok responding on behalf of Julius.
Thanks for the controls, they narrow this down well. The difference between the top-frame input and the cross-origin iframe input points at where the app thinks focus is, rather than at the page.
Type-to-focus sends any printable key to the composer when the key reaches the app without an editable or interactive element in its path, and no dialog or popup is open (
apps/web/src/components/chat/composerFocusRedirect.ts:51-69). If a click into a cross-origin frame inside the preview leaves the app's own focus outside the preview, then your keys reach the app first and get redirected. That would fit both your result and theBODYactive element you saw on the earlier dialog. Agent input doesn't go through this path, which is whypreview_clickandpreview_presswork.This is separate from #21954, which is about agent clicks taking focus away from the composer. Here a physical click doesn't move focus into the preview at all. Accepting this as a bug.