Skip to content

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.

fix(mobile): keep a dismissed keyboard down across keyframes

tony1167996c6aa6
diff --git a/mobile/lib/widgets/terminal_panel.dart b/mobile/lib/widgets/terminal_panel.dart
index d9dccaf36..d43a3e3ec 100644
--- a/mobile/lib/widgets/terminal_panel.dart
+++ b/mobile/lib/widgets/terminal_panel.dart
@@ -521,7 +521,14 @@ class _TerminalPanelState extends State<TerminalPanel>
}
}
_followTail = atEnd;
- _afterTerminalMounted(scrollToEnd: atEnd);
+ // ⚠️ **The keyboard is claimed only by a view that does not hold the focus.** One that does kept
+ // its input connection across the swap (`keepsInputAcrossTerminals`), so claiming it again can
+ // only `show()` the keyboard — and the keyboard Back had just put away was up again within
+ // 66–239ms, the resize keyframe that answered its rising landing as it slid down, while the page
+ // still read it as up (a Galaxy S23, 6 of 19 dismissals, 2026-10-14; each bounce one more resize,
+ // a full reprint by Codex and a 165 KB keyframe). A view without the focus still claims it, as
+ // before: a claim that found no laid-out view gets its second chance here.
+ _afterTerminalMounted(scrollToEnd: atEnd, claimFocus: !_focusNode.hasFocus);
}
void _handleFocusChange() {
diff --git a/mobile/test/terminal_panel_phone_test.dart b/mobile/test/terminal_panel_phone_test.dart
index da107750e..4655393a4 100644
--- a/mobile/test/terminal_panel_phone_test.dart
+++ b/mobile/test/terminal_panel_phone_test.dart
@@ -365,6 +365,53 @@ void main() {
expect(view(tester).controller!.selection, isNull);
expect(find.text('Copy'), findsNothing);
});
+
+ // Back puts the keyboard away without a word to the app: the terminal keeps its focus and its
+ // input connection. The resize keyframe that answered the keyboard rising, landing as it slid
+ // down, showed it again (a Galaxy S23, 6 of 19 dismissals, 2026-10-14).
+ testWidgets(
+ 'does not show the keyboard again under a terminal holding the focus',
+ (tester) async {
+ final pane = session();
+ await pumpPanel(tester, pane, focused: true);
+ await keyframe(tester, pane, 0, 'the first screen');
+ expect(tester.testTextInput.hasAnyClients, isTrue);
+ tester.testTextInput.log.clear();
+
+ await keyframe(tester, pane, 1, 'the screen after the resize');
+ await tester.pump();
+
+ expect(identical(view(tester).terminal, pane.terminal), isTrue);
+ expect(
+ tester.testTextInput.log.map((call) => call.method),
+ isNot(contains('TextInput.show')),
+ );
+ // The connection it had is still the one keys arrive on.
+ expect(tester.testTextInput.hasAnyClients, isTrue);
+ // The session's wait for a screen of the size it asked for runs out.
+ await tester.pump(const Duration(seconds: 2));
+ },
+ );
+
+ testWidgets('claims the keyboard for a focused terminal that lost it', (
+ tester,
+ ) async {
+ final pane = session();
+ await pumpPanel(tester, pane, focused: true);
+ await keyframe(tester, pane, 0, 'the first screen');
+ expect(tester.testTextInput.hasAnyClients, isTrue);
+ // The page still asks for this terminal's keyboard; the focus went elsewhere.
+ FocusManager.instance.primaryFocus?.unfocus();
+ await tester.pump();
+ expect(tester.testTextInput.hasAnyClients, isFalse);
+
+ await keyframe(tester, pane, 1, 'the screen after the resize');
+ await tester.pump();
+
+ expect(tester.testTextInput.hasAnyClients, isTrue);
+ // The session's wait for a screen of the size it asked for runs out.
+ await tester.pump(const Duration(seconds: 2));
+ });
});
group('a long press, then Copy', () {