Repository navigation
Studio: stop the macOS desktop app typing stray control characters for unhandled keys - #14815
Conversation
…d on macOS In the macOS desktop app, pressing left at the start of the chat box or right at its end typed a stray character. The arrow could not move the caret, so the page left the key unhandled, and the native fallback inserted the key's private-use character (U+F702 and friends). On the macOS desktop app only, mark an arrow that cannot move the caret as handled, after the app's own key handlers have had their turn. The field stays as it was, which is what Windows and Safari already do. Selections, modified arrows, IME composition and right-to-left fields behave as before. Refs unslothai#14764
This reverts commit e6b2579.
The stray characters are C0 controls (U+001C left, U+001D right, U+0001 Home, U+0004 End) inserted through the window's text input after the child webview leaves the key unhandled, so a caret-boundary keydown guard missed Home and End. Cancel those insertText beforeinput events instead: every key keeps its own behaviour and typed text, tabs, line breaks, paste and IME are untouched.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Bravo. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Codex Review: Didn't find any major issues. Hooray! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
# Conflicts: # studio/frontend/scripts/check-bundle-budget.ts
# Conflicts: # studio/frontend/scripts/check-bundle-budget.ts
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…16583) In the macOS desktop app, pressing Home or End in a text field of a web page open in the browser panel types an invisible control character (U+0001 or U+0004) into the field. Nothing shows on screen, but a search box or form then sends the query with those characters in it. The same keys in Studio's own chat box were already fixed in #14815, but browser panel pages are separate webviews and never got that fix. Browser panel pages on macOS now drop typed text that is only control characters, the same filter Studio's own window uses, in every frame of the page. Normal typing, Enter, Tab, paste and caret movement are unchanged, and other platforms are not affected.
Fixes #14764
Before: in the macOS desktop app, pressing the left arrow at the start of the chat box (or the right arrow at its end, or Home / End) typed a stray, invisible control character into the message. Windows and the web UI did nothing, as expected.
After: those keys leave the field unchanged on macOS too. Every key keeps its normal behaviour, and typing, paste, IME, tabs and line breaks are untouched.
Why: the desktop app's webview is a child view (Tauri's
unstablefeature, tauri-apps/tauri#10194). When the page leaves a key unhandled, macOS hands it back to the window, whose text input inserts the key's classic control character into the focused field: U+001C for left, U+001D for right, U+0001 for Home, U+0004 for End. A plain (non-child) webview does not do this.How:
src/lib/mac-stray-key-text.tsadds one capture-phasebeforeinputlistener on the window, installed frommain.tsxonly in the Tauri app on macOS. It cancels aninsertTextwhose data is only C0 control characters or DEL (tab, line feed and carriage return excluded). No key types those on purpose, so nothing else is filtered, and no keydown handling changes.Verified on real macOS 15, macOS 26 and macOS 27.0.1 (26A434, the reporter's version, via the
xcode-27image) runners with a wry 0.57.0 / tao 0.37.1 app (the versions Studio'sCargo.lockpins), keys sent as real CGEvents:xxxxA keydown guard that only cancels arrows at the caret's ends fixed the arrow rows but still let Home and End through, which is why this filters the insertion instead.
Tests:
tests/mac-stray-key-text.test.tscovers the stray characters, kept text (letters, accents, tabs, line breaks, mixed text), other input types (paste, drop, autocorrect, composition, deletion), the capture-phase listener, and the install being limited to the macOS desktop app.Bundle: the guard is eager in
main.tsx, +278 B raw / +129 B transfer at startup, socheck-bundle-budget.tsis raised by exactly that. Re-measured against 14e0178: +114 B transfer / +278 B raw. Main without this PR measures 2,086,290 B transfer against its own 2,085,990 B budget there, so that step is red on main independently of this change.Before / after on macOS 26 (child webview, real key events, screenshot after each press)
Left: main types U+001C / U+001D / U+0001 / U+0004 (drawn as boxes). Right: with this PR the field stays
abc.