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): the key strip opens on its own keys — esc no longer slides off the edge

dee124f0f20cc35
diff --git a/mobile/lib/phone/terminal_key_bar.dart b/mobile/lib/phone/terminal_key_bar.dart
index 9b26bc7eb..b040e9844 100644
--- a/mobile/lib/phone/terminal_key_bar.dart
+++ b/mobile/lib/phone/terminal_key_bar.dart
@@ -414,13 +414,11 @@ class _TerminalKeyBarState extends State<TerminalKeyBar> {
/// Keeps the fixed keys and the hints on one row.
final ScrollController _scroll = ScrollController();
- @override
- void initState() {
- super.initState();
- // The strip opens with the keyboard, and a pane already offering its keys
- // shows them as it does.
- if (widget.hints.isNotEmpty) _revealHints();
- }
+ // ⚠️ **Not scrolled to the hints as the strip opens.** It was, and Claude Code
+ // offers `shift+tab to cycle` on every prompt, so every open slid esc and tab
+ // off the left edge — while the pane's own line said "esc to interrupt". The
+ // strip opens on its own keys; hints that ARRIVE while it is open (a question's
+ // keys, say) are scrolled to, and the rest are a sideways swipe away.
@override
void didUpdateWidget(TerminalKeyBar oldWidget) {
diff --git a/mobile/test/terminal_key_bar_test.dart b/mobile/test/terminal_key_bar_test.dart
index 36380da32..5cf0dd3d7 100644
--- a/mobile/test/terminal_key_bar_test.dart
+++ b/mobile/test/terminal_key_bar_test.dart
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:harness_mobile/phone/terminal_key_bar.dart';
+import 'package:harness_mobile/terminal/key_hints.dart';
import 'package:xterm/xterm.dart';
void main() {
@@ -160,4 +161,49 @@ void main() {
await tapKey(tester, 'Hide keyboard');
expect(dismissals, 1);
});
+
+ testWidgets(
+ 'esc stays in view when the pane already offers keys; new ones are scrolled to',
+ (tester) async {
+ // Claude Code's footer offers a key on every prompt.
+ final cycle = parseKeyHints([' ⏵⏵ auto mode on (shift+tab to cycle)']);
+ expect(cycle, isNotEmpty);
+ Widget bar(List<KeyHint> hints) => MaterialApp(
+ home: Scaffold(
+ body: Align(
+ alignment: Alignment.bottomCenter,
+ child: SizedBox(
+ width: 360,
+ child: TerminalKeyBar(
+ terminal: terminal,
+ enabled: true,
+ hints: hints,
+ onDismissKeyboard: () => dismissals++,
+ onPromptEdited: () => edits++,
+ ),
+ ),
+ ),
+ ),
+ );
+ await tester.pumpWidget(bar(cycle));
+ await tester.pumpAndSettle();
+ final scroll = tester.widget<SingleChildScrollView>(
+ find.byType(SingleChildScrollView).first,
+ );
+ // Opened on its own keys: esc is where the thumb expects it.
+ expect(scroll.controller!.offset, 0);
+ expect(
+ find.byKey(const ValueKey('terminal-key-esc')).hitTestable(),
+ findsOneWidget,
+ );
+
+ // A key the pane starts offering while the strip is up is brought into view.
+ final more = parseKeyHints([
+ ' ⏵⏵ auto mode on (shift+tab to cycle) · ctrl+] main prompt',
+ ]);
+ await tester.pumpWidget(bar(more));
+ await tester.pumpAndSettle();
+ expect(scroll.controller!.offset, greaterThan(0));
+ },
+ );
}