Repository navigation
Preview: on macOS a page's script cannot take the keyboard - #1194
Merged
Merged
Conversation
WebKit makes a web view the window's first responder when its page focuses an element, hidden or not. A preview an agent opened in the background then held the keyboard: the composer still showed as focused but got no text, no input method worked, and a press in it gave nothing back. Paste went on working, being a key equivalent. A page now takes the keyboard when the user presses it. gpui-fast 0.1.19 refuses such requests from its own NativeViews only, and gpui-webview puts the page on a composition surface. A page without the keyboard holds back blur and focus, which the agent's click and type had been getting by taking it; the page agent sends them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On macOS, text input in the composer sometimes stopped (no typing, no input method, while paste still worked) and moving focus did not bring it back. A preview page had taken the keyboard, usually one an agent had opened in the background.
NativeViews; gpui-webview puts the page on a composition surface, which that check does not see (read in their sources, not run). The site names the gap.autofocuspage from the address bar, the page needs a press before it takes keys.Evidence
view hidden 1, goes57->59(the focused bit set) 50 ms after its first page commits, and every later text input query goes to it at (-20000, -20000). An AppKit + WKWebView harness reproduced it:autofocusand.focus(), at load or later, leavefirstResponder=WKWebViewwith the view hidden.After: in the same harness with the suppression,
firstResponderstays GPUI's stand-in view, hidden or visible, and a press still moves it to the page..focus()every second): the state stays29(not focused), text typed into the composer arrives; a press on the page gives29->31and a caret. Input was synthetic; no input method composition was exercised, and the hidden page was checked only in the harness.#a, then#b, then clicking#a:cargo fmt --all --check; Clippy--workspace --all-targets -D warnings;tcode-uiandpreview-mcptests: 496 passed, on macOS arm64. The other platforms are CI's.Merge Danger
Door: two-way
Blast Radius: preview
The suppression is macOS only.
agent.jsis shared by every engine: in a page that has the keyboard it sees the native events and sends nothing; in one that has not, a page's listeners now getblurandfocus(untrusted) from an agent's click or type.