The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
Enhance mobile text input handling for software keyboards on iOS and Android
Dev jacobd1e160a75cc4
diff --git a/desktop/third_party/xterm/README.autonomous.md b/desktop/third_party/xterm/README.autonomous.mdindex 307897586..0f705cf47 100644--- a/desktop/third_party/xterm/README.autonomous.md+++ b/desktop/third_party/xterm/README.autonomous.md@@ -136,3 +136,21 @@ it if one is dropped.vertical scrolling and app-owned Meta shortcuts keep their bindings.Regression: the macOS/Linux pair in `test/terminal_panel_focus_test.dart`exercises physical key events through `TerminalPanel` to binary PTY input.++9. **A software keyboard is allowed to compose**+ (`lib/src/ui/custom_text_edit.dart`). The strict+ `autocorrect: false` / `enableSuggestions: false` this connection attached+ with is right for a hardware keyboard — a desktop IME composes through+ marked text, which neither flag touches — but on a phone those two flags ARE+ the IME: iOS maps `autocorrect` onto `UITextAutocorrectionTypeNo` and+ Android maps `enableSuggestions` onto `TYPE_TEXT_FLAG_NO_SUGGESTIONS`, and+ with no pre-edit buffer to work in a Vietnamese Telex keyboard converted+ nothing — `hoom` reached the pty as four raw letters instead of `hôm`, and a+ CJK candidate window never opened. iOS and Android now attach with+ composition left on (iOS needs `autocorrect`, the only knob it has; Android+ needs `enableSuggestions` and keeps autocorrection itself off), and smart+ dashes and quotes — which default to ENABLED, and which iOS only acts on+ once autocorrect is on — are switched off on every platform so `"` and+ `--flag` stay syntax rather than typography. Regression:+ `mobile/test/terminal_ime_input_test.dart`, the only build that reaches the+ mobile branch.diff --git a/desktop/third_party/xterm/lib/src/ui/custom_text_edit.dart b/desktop/third_party/xterm/lib/src/ui/custom_text_edit.dartindex 858617ce3..204184186 100644--- a/desktop/third_party/xterm/lib/src/ui/custom_text_edit.dart+++ b/desktop/third_party/xterm/lib/src/ui/custom_text_edit.dart@@ -167,6 +167,13 @@ class CustomTextEditState extends State<CustomTextEdit> with TextInputClient {bool get _shouldCreateInputConnection => kIsWeb || !widget.readOnly;+ /// Whether the platform's on-screen keyboard is the input method itself,+ /// rather than a layer a hardware keyboard composes through. See the IME+ /// note in [_openInputConnection].+ static bool get _composesThroughSoftwareKeyboard =>+ defaultTargetPlatform == TargetPlatform.iOS ||+ defaultTargetPlatform == TargetPlatform.android;+void _openInputConnection() {if (!_shouldCreateInputConnection) {return;@@ -179,8 +186,29 @@ class CustomTextEditState extends State<CustomTextEdit> with TextInputClient {inputType: widget.inputType,inputAction: widget.inputAction,keyboardAppearance: widget.keyboardAppearance,- autocorrect: false,- enableSuggestions: false,+ // ⚠️ On a phone the software keyboard IS the input method, and these two+ // switches are what turn its pre-edit buffer off: iOS maps+ // `autocorrect: false` onto `UITextAutocorrectionTypeNo`, Android maps+ // `enableSuggestions: false` onto `TYPE_TEXT_FLAG_NO_SUGGESTIONS`. With+ // either one set the keyboard has nowhere to compose, so Vietnamese+ // Telex converted nothing and `hoom` reached the pty as four raw+ // letters instead of `hôm`; a CJK candidate window dies the same way.+ // A desktop IME composes through marked text, which neither flag+ // touches, so those platforms keep the strict config — a terminal has+ // no business autocorrecting a command.+ //+ // iOS has no finer knob: that one `autocorrect` gates its autocorrection+ // AND its Telex conversion. Android's composing hangs off+ // `enableSuggestions` alone, so its autocorrect flag+ // (`TYPE_TEXT_FLAG_AUTO_CORRECT`) stays off there and Gboard rewrites+ // nothing that was typed.+ autocorrect: defaultTargetPlatform == TargetPlatform.iOS,+ enableSuggestions: _composesThroughSoftwareKeyboard,+ // Straight quotes and hyphens, always: `"` and `--flag` are syntax at a+ // prompt, not typography. Both default to ENABLED, and turning+ // autocorrect on above is what would finally let iOS act on them.+ smartDashesType: SmartDashesType.disabled,+ smartQuotesType: SmartQuotesType.disabled,enableIMEPersonalizedLearning: false,);diff --git a/mobile/test/terminal_ime_input_test.dart b/mobile/test/terminal_ime_input_test.dartnew file mode 100644index 000000000..563e0fcdd--- /dev/null+++ b/mobile/test/terminal_ime_input_test.dart@@ -0,0 +1,122 @@+import 'package:flutter/material.dart';+import 'package:flutter_test/flutter_test.dart';+import 'package:xterm/xterm.dart';++/// The phone has no composer box under its pane — see `phone/terminal_page.dart`+/// — so the terminal's own input connection is the only place a software+/// keyboard has to compose in. Whatever this config says, a Vietnamese Telex or+/// CJK keyboard either gets a pre-edit buffer or types raw letters into the pty.+void main() {+ Terminal newTerminal() =>+ Terminal(maxLines: 200, reflowEnabled: false)..resize(80, 12);++ Future<void> pumpTerminal(WidgetTester tester, Terminal terminal) async {+ await tester.pumpWidget(+ MaterialApp(+ home: Scaffold(+ body: SizedBox(+ width: 400,+ height: 320,+ child: TerminalView(terminal, autofocus: true),+ ),+ ),+ ),+ );+ await tester.pump();+ expect(tester.testTextInput.hasAnyClients, isTrue);+ }++ Future<Map<String, dynamic>> attachedConfig(WidgetTester tester) async {+ await pumpTerminal(tester, newTerminal());+ return tester.testTextInput.setClientArgs!;+ }++ testWidgets(+ 'iOS keeps the autocorrection machinery its Telex conversion rides on',+ (tester) async {+ final config = await attachedConfig(tester);++ // `autocorrect: false` reaches UIKit as `UITextAutocorrectionTypeNo`,+ // which is also what stops the Vietnamese keyboard turning `hoo` into+ // `hô`. iOS exposes no separate switch for the two.+ expect(config['autocorrect'], isTrue);+ expect(config['enableSuggestions'], isTrue);+ },+ variant: TargetPlatformVariant.only(TargetPlatform.iOS),+ );++ testWidgets(+ 'Android composes with suggestions on and rewrites nothing with '+ 'autocorrection off',+ (tester) async {+ final config = await attachedConfig(tester);++ // `enableSuggestions: false` reaches Android as+ // TYPE_TEXT_FLAG_NO_SUGGESTIONS, which takes the composing region — and+ // with it Telex — away entirely.+ expect(config['enableSuggestions'], isTrue);+ expect(config['autocorrect'], isFalse);+ },+ variant: TargetPlatformVariant.only(TargetPlatform.android),+ );++ testWidgets(+ 'a desktop keyboard composes through marked text and keeps the strict '+ 'config',+ (tester) async {+ final config = await attachedConfig(tester);++ expect(config['autocorrect'], isFalse);+ expect(config['enableSuggestions'], isFalse);+ },+ variant: TargetPlatformVariant.desktop(),+ );++ testWidgets(+ 'quotes and dashes stay straight on every platform',+ (tester) async {+ final config = await attachedConfig(tester);++ // `"` and `--flag` are syntax at a prompt. Both of these default to+ // enabled, and iOS acts on them the moment autocorrect goes on.+ expect(config['smartDashesType'], SmartDashesType.disabled.index.toString());+ expect(config['smartQuotesType'], SmartQuotesType.disabled.index.toString());+ },+ variant: TargetPlatformVariant.all(),+ );++ testWidgets(+ 'Telex sends the composed word, not the letters it was typed from',+ (tester) async {+ final terminal = newTerminal();+ final outbound = <String>[];+ terminal.onOutput = outbound.add;+ await pumpTerminal(tester, terminal);++ // `h`, `o`, `o`, `m` as the keyboard rewrites its own pre-edit text.+ for (final pending in const ['h', 'ho', 'hô', 'hôm']) {+ tester.testTextInput.updateEditingValue(+ TextEditingValue(+ text: pending,+ selection: TextSelection.collapsed(offset: pending.length),+ composing: TextRange(start: 0, end: pending.length),+ ),+ );+ await tester.pump();+ expect(outbound, isEmpty, reason: 'pre-edit `$pending` left the pty');+ }++ // Space ends the composition and commits it.+ tester.testTextInput.updateEditingValue(+ const TextEditingValue(+ text: 'hôm ',+ selection: TextSelection.collapsed(offset: 4),+ ),+ );+ await tester.pump();++ expect(outbound, ['hôm ']);+ },+ variant: TargetPlatformVariant.only(TargetPlatform.iOS),+ );+}diff --git a/mobile/third_party/xterm/README.autonomous.md b/mobile/third_party/xterm/README.autonomous.mdindex 5912e9a02..75c215b60 100644--- a/mobile/third_party/xterm/README.autonomous.md+++ b/mobile/third_party/xterm/README.autonomous.md@@ -113,3 +113,21 @@ it if one is dropped.vertical scrolling and app-owned Meta shortcuts keep their bindings.Regression: the macOS/Linux pair in `test/terminal_panel_focus_test.dart`exercises physical key events through `TerminalPanel` to binary PTY input.++9. **A software keyboard is allowed to compose**+ (`lib/src/ui/custom_text_edit.dart`). The strict+ `autocorrect: false` / `enableSuggestions: false` this connection attached+ with is right for a hardware keyboard — a desktop IME composes through+ marked text, which neither flag touches — but on a phone those two flags ARE+ the IME: iOS maps `autocorrect` onto `UITextAutocorrectionTypeNo` and+ Android maps `enableSuggestions` onto `TYPE_TEXT_FLAG_NO_SUGGESTIONS`, and+ with no pre-edit buffer to work in a Vietnamese Telex keyboard converted+ nothing — `hoom` reached the pty as four raw letters instead of `hôm`, and a+ CJK candidate window never opened. iOS and Android now attach with+ composition left on (iOS needs `autocorrect`, the only knob it has; Android+ needs `enableSuggestions` and keeps autocorrection itself off), and smart+ dashes and quotes — which default to ENABLED, and which iOS only acts on+ once autocorrect is on — are switched off on every platform so `"` and+ `--flag` stay syntax rather than typography. Regression:+ `mobile/test/terminal_ime_input_test.dart`, the only build that reaches the+ mobile branch.diff --git a/mobile/third_party/xterm/lib/src/ui/custom_text_edit.dart b/mobile/third_party/xterm/lib/src/ui/custom_text_edit.dartindex 858617ce3..204184186 100644--- a/mobile/third_party/xterm/lib/src/ui/custom_text_edit.dart+++ b/mobile/third_party/xterm/lib/src/ui/custom_text_edit.dart@@ -167,6 +167,13 @@ class CustomTextEditState extends State<CustomTextEdit> with TextInputClient {bool get _shouldCreateInputConnection => kIsWeb || !widget.readOnly;+ /// Whether the platform's on-screen keyboard is the input method itself,+ /// rather than a layer a hardware keyboard composes through. See the IME+ /// note in [_openInputConnection].+ static bool get _composesThroughSoftwareKeyboard =>+ defaultTargetPlatform == TargetPlatform.iOS ||+ defaultTargetPlatform == TargetPlatform.android;+void _openInputConnection() {if (!_shouldCreateInputConnection) {return;@@ -179,8 +186,29 @@ class CustomTextEditState extends State<CustomTextEdit> with TextInputClient {inputType: widget.inputType,inputAction: widget.inputAction,keyboardAppearance: widget.keyboardAppearance,- autocorrect: false,- enableSuggestions: false,+ // ⚠️ On a phone the software keyboard IS the input method, and these two+ // switches are what turn its pre-edit buffer off: iOS maps+ // `autocorrect: false` onto `UITextAutocorrectionTypeNo`, Android maps+ // `enableSuggestions: false` onto `TYPE_TEXT_FLAG_NO_SUGGESTIONS`. With+ // either one set the keyboard has nowhere to compose, so Vietnamese+ // Telex converted nothing and `hoom` reached the pty as four raw+ // letters instead of `hôm`; a CJK candidate window dies the same way.+ // A desktop IME composes through marked text, which neither flag+ // touches, so those platforms keep the strict config — a terminal has+ // no business autocorrecting a command.+ //+ // iOS has no finer knob: that one `autocorrect` gates its autocorrection+ // AND its Telex conversion. Android's composing hangs off+ // `enableSuggestions` alone, so its autocorrect flag+ // (`TYPE_TEXT_FLAG_AUTO_CORRECT`) stays off there and Gboard rewrites+ // nothing that was typed.+ autocorrect: defaultTargetPlatform == TargetPlatform.iOS,+ enableSuggestions: _composesThroughSoftwareKeyboard,+ // Straight quotes and hyphens, always: `"` and `--flag` are syntax at a+ // prompt, not typography. Both default to ENABLED, and turning+ // autocorrect on above is what would finally let iOS act on them.+ smartDashesType: SmartDashesType.disabled,+ smartQuotesType: SmartQuotesType.disabled,enableIMEPersonalizedLearning: false,);