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.

feat(mobile): Find opens with keyboard down, hides New Harness while typing

tony99f720bd82f7
diff --git a/mobile/lib/phone/terminal_search.dart b/mobile/lib/phone/terminal_search.dart
index fb1a18cc0..00b217ace 100644
--- a/mobile/lib/phone/terminal_search.dart
+++ b/mobile/lib/phone/terminal_search.dart
@@ -47,7 +47,9 @@ import 'phone_search_results.dart';
/// ⚠️ **Full height, and a keyboard lifts only its foot.** It runs up under the status bar; a
/// keyboard, when it comes, takes the drawer's foot onto its own top rather than covering the rows.
///
-/// The field takes focus on opening so a query can be typed immediately.
+/// ⚠️ **The field waits for a tap.** Find opens on its list with the keyboard down: the rows are
+/// what it is opened to see, and a keyboard raised on every open took half of them away for a look
+/// that needed no typing. A tap on the field — or the mic — is what starts a search.
///
/// ⚠️ **Not a route.** Pushed, the sheet would sit in a navigator above the shell, and an agent
/// opened from it would be pushed over the shell rather than take the home screen (see
@@ -144,7 +146,7 @@ class _TerminalSearchOverlayState extends State<TerminalSearchOverlay>
/// height.
final _sheetKey = GlobalKey(debugLabel: 'Terminal search sheet');
- /// Whether the field has been tapped: Cancel beside it instead of `+`.
+ /// Whether a search is under way: the field tapped, or a query spoken into the mic ([_talk]).
///
/// ⚠️ **Entered on focus, left on Cancel — not tied to focus both ways.** The keyboard goes away
/// for reasons that are not "stop searching" — the return key puts it away on purpose. The query
@@ -454,7 +456,7 @@ class _TerminalSearchOverlayState extends State<TerminalSearchOverlay>
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
SizedBox(height: media.padding.top + 8),
- // The field takes the keyboard on entry, like ⌘P.
+ // No autofocus: the keyboard comes with a tap on the field — see the class note.
// No Cancel: a swipe left is the way out, as it was the way in.
Padding(
padding: const EdgeInsets.symmetric(horizontal: Tty.origin),
@@ -464,7 +466,6 @@ class _TerminalSearchOverlayState extends State<TerminalSearchOverlay>
child: TtyField(
controller: _controller,
focus: _focus,
- autofocus: true,
hint: _search.canGoBack
? 'Search in ${_search.scopeName}'
: _search.hint.replaceAll('…', ''),
@@ -533,25 +534,33 @@ class _TerminalSearchOverlayState extends State<TerminalSearchOverlay>
),
// ⚠️ **Stuck to the foot, outside the list.** The list's own `+ New Harness` row
// comes after every harness on the account — a few hundred rows down, where no
- // thumb goes. This one is always in reach, riding the keyboard while it is up. On
- // the machine of the harness on screen, as that row does with nothing typed.
+ // thumb goes. This one is always in reach while the keys are down. On the machine
+ // of the harness on screen, as that row does with nothing typed.
//
- // ⚠️ **Kept while a keyboard is up.** It was hidden with the keys once, and on an
- // iPhone that meant never: Find raises the keyboard as it opens, a scroll keeps
- // it (see `phone_search_results.dart`), and the iPhone's keys have no button to
- // put them away — so the button never came back.
+ // ⚠️ **Gone while a keyboard is up.** The keys take half the screen already, and
+ // the rows left are what the query is typed to find. Hiding it costs nothing on
+ // opening only because Find opens with the keys DOWN (no autofocus): while the
+ // field took the keyboard on every open, the iPhone — whose keys have no button
+ // to put them away, and a scroll keeps them (`phone_search_results.dart`) —
+ // never showed it at all. Read off the keyboard's height, not the field's focus:
+ // with a hardware keyboard nothing covers the foot.
if (newAgent != null && !models)
- Padding(
- padding: const EdgeInsets.fromLTRB(
- Tty.origin,
- 8,
- Tty.origin,
- 8,
- ),
- child: TtyPrimaryButton(
- key: const ValueKey('find-new-harness'),
- label: 'New Harness',
- onPressed: () => newAgent(null),
+ ValueListenableBuilder<double>(
+ valueListenable: _keyboard,
+ builder: (context, keyboard, button) =>
+ keyboard > 0 ? const SizedBox.shrink() : button!,
+ child: Padding(
+ padding: const EdgeInsets.fromLTRB(
+ Tty.origin,
+ 8,
+ Tty.origin,
+ 8,
+ ),
+ child: TtyPrimaryButton(
+ key: const ValueKey('find-new-harness'),
+ label: 'New Harness',
+ onPressed: () => newAgent(null),
+ ),
),
),
// Over the home indicator while the keyboard is down; on the keys once it is up.
@@ -577,6 +586,11 @@ class _TerminalSearchOverlayState extends State<TerminalSearchOverlay>
voice.submit((text) async {
if (!mounted) return false;
final query = text.trim().replaceAll(RegExp(r'[.!?]+$'), '');
+ // ⚠️ A search started by voice is a search, field tapped or not. The field no longer
+ // takes focus on opening, so without this a spoken query left [_searching] off: a row
+ // that then narrowed the search (a project, a machine) moved the query without the
+ // field following, and Back closed Find instead of stepping out of the narrowing.
+ if (!_searching) setState(() => _searching = true);
_controller.value = TextEditingValue(
text: query,
selection: TextSelection.collapsed(offset: query.length),