Terminal: text input for IMEs, Capture browser keys, touch key row
- Desktop and web terminals use the text-input path too, so IMEs, dead keys, the emoji picker and dictation work; the key handler still encodes special keys and chords first (handled keys are never typed again), composing text is drawn at the cursor and sent on commit, the platform editable sits at the cursor, and a closed input reopens on the next key. The editable terminal is a semantics text field so web typing also works with semantics on. - Web: "Capture browser keys" (terminal menu and right-click menu) goes full screen and calls navigator.keyboard.lock(); hold Esc to leave. No-op where unsupported; cheatsheet and menu note give alternatives. - Touch: scrollable key row with sticky Ctrl/Alt (tap once, double-tap lock), Esc, Tab, arrows, Home/End, PgUp/PgDn and symbols through the hardware encoder; soft keyboard types per key (delete detection, Return as Enter); the line field moves behind the row's Line button. - Capture kit: compose=, --semantics false, --user-agent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -25,8 +25,10 @@ emulator. Auth flows that print a link, wait for a pasted token and continue
|
||||
Cmd-V on Apple platforms, Ctrl-V or Ctrl-Shift-V elsewhere, plus the
|
||||
toolbar's Paste button. Ctrl-A and other Ctrl keys reach the process. A key
|
||||
toolbar under the terminal: Paste, Enter, Ctrl-C, Tab, Esc, arrows. On
|
||||
Android/iOS the toolbar also has a text field ("Type input, then Enter")
|
||||
for the soft keyboard, with a Hide typing toggle; it is emptied when sent.
|
||||
Android/iOS it is the touch key row (sticky Ctrl/Alt, Esc, Tab, arrows,
|
||||
Home/End, PgUp/PgDn, symbols) and typing goes to the terminal key by
|
||||
key; its Line button opens a text field ("Type input, then Enter") with
|
||||
a Hide typing toggle, emptied when sent.
|
||||
- The terminal is resized to its layout (debounced 150 ms); the process gets
|
||||
SIGWINCH. New runs start at the last laid-out size. A live terminal does
|
||||
not reflow (xterm.dart's reflow left the cursor on another line's row, so
|
||||
@@ -125,8 +127,10 @@ emulator. Auth flows that print a link, wait for a pasted token and continue
|
||||
assumes AltGr arrives as Ctrl+Alt or its own key; a Mac's Option as Meta
|
||||
takes the character from the logical key, else the US position of the
|
||||
physical key, so a non-US Mac layout's Option+key may send the US letter.
|
||||
- Desktop typing uses key events (no IME composition for CJK input). Touch
|
||||
platforms use the field.
|
||||
- Desktop typing uses the text input as well as key events (2026-11-26,
|
||||
see `terminal-panel.md` "Text input"): IMEs, dead keys, the emoji picker
|
||||
and dictation work; touch platforms type key by key into the terminal,
|
||||
with a touch key row and the line field behind its Line button.
|
||||
- A descendant that keeps the PTY open after the command exits is read for
|
||||
1 s; on macOS the PTY has no read deadline, so its reader goroutine ends
|
||||
only when that descendant closes it (the run itself is finished and the
|
||||
|
||||
+112
-2
@@ -172,6 +172,112 @@ context menu, Ctrl+= zoom, OSC 8 link hover underline; a synthetic
|
||||
`contextmenu` event over the terminal is default-prevented, elsewhere not.
|
||||
The capture kit gained `rightclick=<target>`.
|
||||
|
||||
## Text input (round 3, 2026-11-26)
|
||||
|
||||
Shared by the permanent terminal and chat terminal cards; client-side only.
|
||||
|
||||
- **IME, dead keys, emoji picker, dictation (desktop and web):** the view
|
||||
now uses the emulator's text-input path on every platform
|
||||
(`hardwareKeyboardOnly` only for a finished, read-only run), instead of
|
||||
hardware key events alone, which dropped `insertText`. The key handler
|
||||
still runs first: special keys and chords it encodes (arrows, Enter,
|
||||
Backspace, Tab, Ctrl/Alt chords, the view's own keys) are *handled*, so
|
||||
the browser's default (inserting text) is prevented and the OS IME never
|
||||
sees them; a plain printing key is left to the text input, which types
|
||||
it. So no key is sent twice. Committed text goes through
|
||||
`TerminalView.onTextInput` (`chat_shell_terminal_text_input.dart`): a
|
||||
line break is Enter (`\r`, or `\r\n` in line-feed mode), empty commits
|
||||
(a cancelled composition) send nothing. Composing text (CJK, a dead
|
||||
key's accent) is drawn underlined at the cursor, over the cursor, and
|
||||
sent only when committed; while composing, the IME keeps Enter and
|
||||
Backspace. The platform's editable is placed at the cursor
|
||||
(`setEditableSizeAndTransform` with the cursor's offset), so IME
|
||||
candidate windows open there. If the platform closes the text input (a
|
||||
browser window losing focus), the next printing key is typed from the
|
||||
key event and the input reopened.
|
||||
- **Web with semantics on** (assistive technology, the capture kit): the
|
||||
browser's text input is the terminal's semantics text field
|
||||
(`CustomTextEdit` now exposes `Semantics(textField, focused)` as a leaf,
|
||||
like `EditableText`; the scroll view's semantics are excluded so the
|
||||
engine keeps that field focused). Typing, dictation and emoji work
|
||||
there, but Flutter's web engine does not report IME composition for a
|
||||
semantics text field, so a CJK IME's intermediate text is sent as typed
|
||||
in that mode only.
|
||||
- **Capture browser keys (web):** terminal ⋮ menu (panel/window) and the
|
||||
terminal's right-click menu offer "Capture browser keys"
|
||||
(`terminal_browser_keys{,_web,_stub}.dart`): the page goes full screen
|
||||
and calls `navigator.keyboard.lock()`, so Ctrl+W, Ctrl+T, Ctrl+N,
|
||||
Ctrl+Tab and the like reach the terminal. Holding Esc leaves full
|
||||
screen (the browser's rule; a short Esc still reaches the terminal),
|
||||
which ends the capture; the menu item is checked while it is on and
|
||||
releases it. Only where the API exists (Chrome, Edge); Firefox, Safari
|
||||
and native builds do not show the item. A refused lock says so in a
|
||||
snack bar. Alternatives documented in the menu note and the shortcut
|
||||
cheatsheet (web outside macOS): Alt+Backspace instead of Ctrl+W
|
||||
(delete a word), Ctrl+U, Alt+B / Alt+F.
|
||||
- **Touch key row** (narrow terminal page, chat terminal cards on a phone
|
||||
or tablet; `chat_shell_terminal_key_row.dart`): horizontally scrollable
|
||||
Ctrl and Alt (sticky: a tap holds one for the next key or typed
|
||||
character, tonal; a second tap within 400 ms locks it, filled with a
|
||||
lock icon; a tap on a held one releases it), Esc, Tab, arrows,
|
||||
Home/End, PgUp/PgDn, `| ~ - / \`, Enter, Ctrl-C, Paste and Line. Keys
|
||||
use the hardware encoder (`chatShellSpecialKeyBytes`: xterm modifier
|
||||
parameter, DECCKM/SS3, keypad mode); a held Ctrl maps the next typed
|
||||
character to its control code, Alt prefixes ESC; a held modifier also
|
||||
applies to a soft keyboard's key events (Backspace, Enter). The
|
||||
modifiers live on the session (`ChatShellStickyModifiers`), shared by
|
||||
its views.
|
||||
- **Soft keyboard per key:** tapping the terminal opens the soft keyboard
|
||||
and each character, Backspace and Return reaches the process at once
|
||||
(no line to submit): `deleteDetection` keeps two placeholder spaces in
|
||||
the editing state on touch platforms, so a Backspace with nothing typed
|
||||
is still seen; Return's line break is Enter. The old line field is now
|
||||
behind the row's Line button (still with Hide typing) for typing a whole
|
||||
line or a token first.
|
||||
|
||||
Evidence: tests `test/features/chat/shell/chat_shell_terminal_text_input_test.dart`
|
||||
(commits from IME/dead key/emoji/dictation on macOS, Linux, Windows;
|
||||
composing drawn not sent, IME keeps Enter/Backspace while composing;
|
||||
handled keys report handled and printing keys do not; reopen after the
|
||||
platform closes the input; editable at the cursor; read-only attaches
|
||||
none; Android per-key typing, Backspace via delete detection, Return as
|
||||
Enter), `chat_shell_terminal_key_row_test.dart` (sticky state machine,
|
||||
row bytes incl. DECCKM, one-shot/locked Ctrl and Alt on keys, typed
|
||||
text and soft-keyboard key events, Line field),
|
||||
`test/features/terminal/terminal_browser_keys_test.dart` (capture,
|
||||
release, browser-ended, refused, unsupported, ⋮ and right-click menus),
|
||||
`terminal_shortcuts_test.dart`, `keyboard_shortcuts_cheatsheet_test.dart`.
|
||||
Existing desktop typing tests now type printing keys as a platform does
|
||||
(`test/features/chat/shell/terminal_typing.dart`: key event first, its
|
||||
character through the text input only if unhandled).
|
||||
|
||||
Chromium (headless, CanvasKit, capture kit, probe `?terminals=1
|
||||
&terminal=panel`, 1200x800), `/tmp/r3-capture/`:
|
||||
- `ime-nosem/` (`--semantics false`): key presses `echo`, CDP
|
||||
`Input.imeSetComposition` "にほ" drawn underlined at the cursor and not
|
||||
sent, commit "日本" via `Input.insertText`, dead key "´" composing then
|
||||
"é", emoji and `:q!` via `insertText`, Enter one new prompt; the hidden
|
||||
input sits at the cursor (x 143→183 as text is typed, y of the cursor
|
||||
row). Result line `echo 日本 é 👍 :q!`.
|
||||
- `sem/` (semantics on): the focused element is the terminal's text field
|
||||
`INPUT` ("Terminal, type to send input"); key presses and `insertText`
|
||||
type `echo é 👍 日本 xyz`; Ctrl+W and Alt+B add no text (sent as
|
||||
control bytes). `ime/` shows the semantics-mode composition gap.
|
||||
- `lock/`: Chromium has `navigator.keyboard.lock`; ⋮ → Capture browser
|
||||
keys enters full screen (`document.fullscreenElement` set) with the
|
||||
snack bar; the item is then checked; choosing it again leaves full
|
||||
screen; the right-click menu lists it.
|
||||
- `touch/` (`--touch true`, Android user agent, 560x1000, Alt+T opens the
|
||||
narrow page): key row under the terminal, per-key `insertText` typing,
|
||||
Ctrl tonal while held and released after one character, Alt locked
|
||||
with the lock icon after a double tap, the row scrolled sideways to
|
||||
Home/End/PgUp/PgDn.
|
||||
Not verified: a real OS IME (macOS/Windows/Linux), real dictation, Safari
|
||||
and Firefox, a real Ctrl+W in a non-headless browser while captured, and
|
||||
any phone or tablet (no device test ran).
|
||||
The capture kit gained `compose=<text>`, `--semantics false` and
|
||||
`--user-agent`.
|
||||
|
||||
## Protocol (server)
|
||||
|
||||
`internal/protocol/terminal.go`; documented in `docs/cli.md` ("Machine
|
||||
@@ -472,8 +578,12 @@ software) costs about 2 ms more raster. Runs on this machine vary by about
|
||||
shell input already does).
|
||||
- Opening a terminal elsewhere (another device) adds its tab here too: the
|
||||
tabs are the machine's terminals.
|
||||
- Mobile (narrow page, soft-keyboard field) is verified by widget tests and
|
||||
a narrow Chrome capture only; no device test ran. Android/Linux builds
|
||||
- Mobile (narrow page, touch key row, per-key soft keyboard typing) is
|
||||
verified by widget tests and narrow Chromium captures with an Android
|
||||
user agent only; no device test ran.
|
||||
- On the web with semantics on, IME composition is not reported to the
|
||||
app (Flutter web engine limitation for semantics text fields), so a CJK
|
||||
IME's intermediate text is sent; without semantics it is a preedit. Android/Linux builds
|
||||
were not run.
|
||||
- `test/application` and `test/features/settings` have 51 failures that are
|
||||
identical on the base commit 8f06f12d (pending `LaunchUpdateChecker`
|
||||
|
||||
Reference in New Issue
Block a user