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:
2026-11-26 02:43:57 +00:00
parent e526150b1e
commit c5af000453
36 changed files with 1730 additions and 173 deletions
@@ -5,6 +5,7 @@ import 'package:pipelines_app/features/chat/shell/chat_shell_runs_controller.dar
import 'package:xterm/xterm.dart';
import 'chat_shell_fixtures.dart';
import 'terminal_typing.dart';
void main() {
late ShellGateway gateway;
@@ -43,8 +44,8 @@ void main() {
expect(find.byKey(const Key('chat-shell-terminal-field')), findsNothing);
await tester.tap(find.byType(TerminalView));
await tester.pump();
await tester.sendKeyEvent(LogicalKeyboardKey.keyG);
await tester.sendKeyEvent(LogicalKeyboardKey.digit7);
await typeKey(tester, LogicalKeyboardKey.keyG);
await typeKey(tester, LogicalKeyboardKey.digit7);
await tester.sendKeyEvent(LogicalKeyboardKey.arrowUp);
await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft);
await tester.sendKeyEvent(LogicalKeyboardKey.keyC);
@@ -156,7 +157,7 @@ void main() {
await press(tester, LogicalKeyboardKey.arrowLeft, modifiers: alt);
await press(tester, LogicalKeyboardKey.arrowRight, modifiers: ctrl);
await press(tester, LogicalKeyboardKey.keyT, modifiers: ctrl);
await press(tester, LogicalKeyboardKey.keyX);
await typeKey(tester, LogicalKeyboardKey.keyX);
expect(
typed(),
'\x1bb\x1bf\x1b.\x1bB\x1b\x7f\x1f\x1d'
@@ -289,10 +290,8 @@ void main() {
),
);
await openRunning(tester);
await tester.tap(find.byKey(const Key('chat-shell-key-paste')));
await tester.pump();
await tester.tap(find.byKey(const Key('chat-shell-key-enter')));
await tester.pump();
await tapKey(tester, 'paste');
await tapKey(tester, 'enter');
expect(typed(), 'gho_pasted-token\r');
});
@@ -301,13 +300,16 @@ void main() {
) async {
await openRunning(tester, output: 'Password: ');
for (final key in ['ctrl-c', 'tab', 'esc', 'left', 'down', 'right']) {
await tester.tap(find.byKey(Key('chat-shell-key-$key')));
await tester.pump();
await tapKey(tester, key);
}
expect(typed(), '\x03\t\x1b\x1b[D\x1b[B\x1b[C');
gateway.calls.clear();
// Typing goes to the terminal key by key; Line opens a field for a
// whole line.
final field = find.byKey(const Key('chat-shell-terminal-field'));
expect(field, findsNothing);
await tapKey(tester, 'line');
expect(field, findsOneWidget);
await tester.tap(find.byKey(const Key('chat-shell-terminal-hide')));
await tester.pump();
@@ -331,8 +333,7 @@ void main() {
expect(tester.testTextInput.isVisible, isTrue);
expect(tester.testTextInput.hasAnyClients, isTrue);
gateway.calls.clear();
tester.testTextInput.enterText('tok');
await tester.pump();
await commitText(tester, 'tok');
await tester.testTextInput.receiveAction(TextInputAction.newline);
await tester.pump();
expect(typed(), startsWith('tok'));
@@ -390,7 +391,7 @@ void main() {
expect(claim['activate'], isTrue);
expect((claim['cols'], claim['rows']), (laidOut['cols'], laidOut['rows']));
// Typing carries this client's size.
await tester.sendKeyEvent(LogicalKeyboardKey.keyG);
await typeKey(tester, LogicalKeyboardKey.keyG);
await tester.pump();
var inputs = gateway.bodies('chat_shell_input');
expect(inputs.single['data'], 'g');