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
Refactor terminal search overlay to use a unified search field
Dev jacob7202a2f9d9f8
diff --git a/mobile/lib/phone/held_height.dart b/mobile/lib/phone/held_height.dartnew file mode 100644index 000000000..38f11c68b--- /dev/null+++ b/mobile/lib/phone/held_height.dart@@ -0,0 +1,81 @@+import 'package:flutter/rendering.dart';+import 'package:flutter/widgets.dart';++/// Lays [child] out at the height it last had, for as long as [hold] is true.+///+/// For a box something else is about to cover: a keyboard raised FOR the cover+/// shrinks the page, and without this the content underneath re-lays out for a+/// keyboard it never asked for — and again, visibly, as the cover fades away and+/// the keyboard falls. Held, the child keeps its height and is clipped to the+/// space the page actually has, so nothing under the cover moves.+///+/// The height remembered is the last one laid out while not holding, taken in+/// layout rather than in build, so it is the height that was on screen.+class HeldHeight extends SingleChildRenderObjectWidget {+ const HeldHeight({super.key, required this.hold, required super.child});++ final bool hold;++ @override+ RenderObject createRenderObject(BuildContext context) =>+ RenderHeldHeight(hold);++ @override+ void updateRenderObject(BuildContext context, RenderHeldHeight renderObject) {+ renderObject.hold = hold;+ }+}++/// [HeldHeight]'s box: the child's last free height, clipped to the space given.+class RenderHeldHeight extends RenderProxyBox {+ RenderHeldHeight(this._hold);++ bool _hold;+ double? _height;+ final _clip = LayerHandle<ClipRectLayer>();++ set hold(bool value) {+ if (_hold == value) return;+ _hold = value;+ markNeedsLayout();+ }++ @override+ void performLayout() {+ final child = this.child!;+ final held = _hold ? _height : null;+ if (held == null) {+ child.layout(constraints, parentUsesSize: true);+ size = child.size;+ _height = size.height;+ return;+ }+ child.layout(+ BoxConstraints(+ minWidth: constraints.minWidth,+ maxWidth: constraints.maxWidth,+ minHeight: held,+ maxHeight: held,+ ),+ parentUsesSize: true,+ );+ size = constraints.constrain(Size(child.size.width, held));+ }++ @override+ void paint(PaintingContext context, Offset offset) {+ _clip.layer = context.pushClipRect(+ needsCompositing,+ offset,+ Offset.zero & size,+ super.paint,+ oldLayer: _clip.layer,+ );+ }++ @override+ void dispose() {+ _clip.layer = null;+ super.dispose();+ }+}diff --git a/mobile/lib/phone/terminal_page.dart b/mobile/lib/phone/terminal_page.dartindex 94619195e..31baa729f 100644--- a/mobile/lib/phone/terminal_page.dart+++ b/mobile/lib/phone/terminal_page.dart@@ -23,6 +23,7 @@ import 'package:harness_mobile/widgets/terminal_panel.dart';import 'agents_page.dart' show openNewAgent;import 'delete_agent.dart';+import 'held_height.dart';import 'machines_tab.dart';import 'phone_navigation.dart' show phoneRoute;import 'phone_sheet.dart';@@ -236,6 +237,26 @@ class _TerminalPageState extends State<TerminalPage>/// it goes back to. See [_closeSearch].bool _keyboardBeforeSearch = false;+ /// What this page's own chrome showed for the keyboard when search opened —+ /// [_keyboardUp] then — held for as long as [_heldForSearch]. See+ /// [_terminalKeyboardUp].+ bool _keyboardUpAtSearch = false;++ /// Whether the terminal is still ignoring the search's keyboard: from search+ /// opening until that keyboard is gone — which is AFTER search has closed.+ ///+ /// ⚠️ **Not [_searching], and the difference is the whole bug.** iOS takes+ /// the keyboard's view away at once, but the inset it reports falls over+ /// ~0.5s — longer than search's fade out. Released with [_searching], the+ /// terminal took the still-falling inset as its own keyboard: its key bar came+ /// up, its floating column went, and it shrank and grew back over a few+ /// frames right after the search had gone. Held until the inset reaches zero+ /// — or [_searchHoldLimit], so a keyboard that never reports zero cannot hold+ /// the terminal still for good.+ bool _heldForSearch = false;+ Timer? _searchHoldTimer;+ static const _searchHoldLimit = Duration(milliseconds: 800);+/// The header getting out of the way as the terminal is scrolled. See/// [TerminalChromeScroll].late final TerminalChromeScroll _chrome = TerminalChromeScroll(vsync: this);@@ -292,6 +313,7 @@ class _TerminalPageState extends State<TerminalPage>@overridevoid dispose() {_cancelSettle();+ _searchHoldTimer?.cancel();_chrome.dispose();_searchOpen.dispose();WidgetsBinding.instance.removeObserver(this);@@ -316,8 +338,11 @@ class _TerminalPageState extends State<TerminalPage>void _openSearch() {if (_searching) return;_keyboardBeforeSearch = _keyboardIsUp;+ _keyboardUpAtSearch = _keyboardUp;+ _searchHoldTimer?.cancel();setState(() {_searching = true;+ _heldForSearch = true;// ⚠️ Handed over, not left standing. The bar can be tapped with the// terminal's own keyboard already up, and a claim still outstanding would// race the search field for it the moment the inset ticks — the panel@@ -329,15 +354,15 @@ class _TerminalPageState extends State<TerminalPage>/// Collapses it back into the bar, and takes the overlay down once it is home.///- /// ⚠️ **Guarded on the controller's own status, not on [_searching].** Cancel- /// and the system back gesture can both arrive while the reverse is already+ /// ⚠️ **Guarded on the controller's own status, not on [_searching].** The+ /// field's chevron and the system back gesture can both arrive while the reverse is already/// running — a second `reverse()` restarts it from wherever it had got to, and/// the bar visibly bounces.void _closeSearch() {if (!_searching || _searchOpen.status == AnimationStatus.reverse) return;// ⚠️ **The keyboard up now is the SEARCH field's, not the terminal's.** Its// inset set [_keyboardIsUp], and left standing, the terminal read that as- // its own the moment search came down — Cancel, Back or opening an agent+ // its own the moment search came down — the chevron, Back or opening an agent// brought up a keyboard nobody had asked the terminal for. Put away like a// swipe's, unless the terminal had one up before search opened.if (!_keyboardBeforeSearch) dismissKeyboardForSwipe();@@ -347,9 +372,25 @@ class _TerminalPageState extends State<TerminalPage>// the field down then would drop the keyboard it has just been given.if (!mounted || _searchOpen.status != AnimationStatus.dismissed) return;setState(() => _searching = false);+ // The overlay is down, but its keyboard may still be falling — see+ // [_heldForSearch]. A terminal that had its own keyboard up before search+ // is going back to one, so there is nothing to wait out.+ if (_keyboardUpAtSearch || _lastInset == 0) {+ _releaseSearchHold();+ } else {+ _searchHoldTimer = Timer(_searchHoldLimit, _releaseSearchHold);+ }});}+ /// Hands the terminal back its own reading of the keyboard.+ void _releaseSearchHold() {+ _searchHoldTimer?.cancel();+ _searchHoldTimer = null;+ if (!mounted || _searching || !_heldForSearch) return;+ setState(() => _heldForSearch = false);+ }+/// Watches the keyboard through [View], because MediaQuery lies to this page.////// ⚠️ `MediaQuery.viewInsetsOf(context).bottom` is ALWAYS ZERO here, keyboard@@ -400,6 +441,9 @@ class _TerminalPageState extends State<TerminalPage>// up costs one needless 80ms hold, and nothing else.final previous = _lastInset;_lastInset = inset;+ // Search's keyboard has finished leaving: the terminal may read the+ // keyboard as its own again. See [_heldForSearch].+ if (!up && _heldForSearch && !_searching) _releaseSearchHold();if (inset != previous) {_settleTimer?.cancel();_settleTimer = Timer(_settleWindow, () {@@ -434,7 +478,9 @@ class _TerminalPageState extends State<TerminalPage>/// takes the input connection back and every letter typed into the search box/// would be sent to the shell instead.bool get _shouldFocus =>- widget.isActive && !_searching && (_keyboardIsUp || _keyboardRequested);+ widget.isActive &&+ !_heldForSearch &&+ (_keyboardIsUp || _keyboardRequested);/// A tap on the terminal while no keyboard is up or coming: the keyboard./// Voice is the floating mic, never this tap — see [TerminalActionColumn].@@ -482,7 +528,20 @@ class _TerminalPageState extends State<TerminalPage>/// keyboard ITSELF, which is screen-wide, and a covered page must keep/// tracking it to know what to do when it is uncovered.bool get _ownsInput =>- _keyboardUp && (ModalRoute.of(context)?.isCurrent ?? true);+ _terminalKeyboardUp && (ModalRoute.of(context)?.isCurrent ?? true);++ /// The keyboard as the TERMINAL sees it.+ ///+ /// ⚠️ While search is open the keyboard up is the search field's, raised over+ /// an overlay that is not a route — so it reaches this page's+ /// [didChangeMetrics] as if it were the terminal's own. Read as such, the key+ /// bar came up and the floating column went away under the search, then both+ /// flipped back as it faded out: the terminal visibly re-laid out on every+ /// close. So until that keyboard is gone, the terminal keeps what it had+ /// when search opened — see [_heldForSearch], [_keyboardUpAtSearch], and+ /// [HeldHeight] for its height.+ bool get _terminalKeyboardUp =>+ _heldForSearch ? _keyboardUpAtSearch : _keyboardUp;/// Guards against a second picker while one is already up.///@@ -635,163 +694,172 @@ class _TerminalPageState extends State<TerminalPage>// as the same object growing — fading this one out underneath// it made the row flicker on every open, which is the opposite// of what the expansion is for.- Column(- children: [- Expanded(- // ⚠️ The mic floats INSIDE this box, over the terminal- // — not over the whole page. Stacked any higher it- // would hang over the key bar while the keyboard is- // up, which is the one row the thumb is working.- child: Stack(- children: [- Positioned.fill(- // ⚠️ The chrome is driven from OUT HERE, not- // from inside the panel. xterm's own- // [Scrollable] is several widgets down and is- // remounted whenever the agent changes;- // listening for its notifications as they- // bubble past is what survives that, and costs- // the panel no knowledge of the page's chrome.- child: NotificationListener<ScrollNotification>(- onNotification: _chrome.onNotification,- child: agentGone- ? _AgentGone(- name: _cachedAgentName,- onPickAnother: _pickAnotherAgent,- )- : pane == null || session == null- ? const _Attaching()- : TerminalPanel(- key: ValueKey(pane.id),- notifier: widget.notifier,- session: session,- // Only the page on screen takes the keyboard — see- // [TerminalPage.isActive]. `visible` is the same answer for the- // panel's other half: a page parked beside this one releases- // focus, stops rendering and stops resizing its remote shell.- //- // Whether it also HOLDS one that is already- // up is a separate question, and the pager asks- // it on every swipe — see [_shouldFocus].- focused: _shouldFocus,- visible: widget.isActive,- // Hold the remote resize while the keyboard- // slides. Separate from `visible` because this- // must NOT release focus — the animation being- // waited on is the one that focus started.- //- // The keyboard is the only thing left that- // moves this pane's height: the header slides- // OVER the terminal rather than out of its- // column — see [_SlideAway].- //- // ⚠️ Held for as long as search is open, too:- // its keyboard is typing a query over a faded- // terminal, and resizing the agent's shell for- // it redrew the whole TUI on the way in and- // again on the way out.- settling: _keyboardSettling || _searching,- // ⚠️ The tap is taken in the panel, not by a- // `Listener` over it. xterm's own `_onTapDown`- // calls `requestKeyboard()`, so anything that- // merely ALSO reacted to the tap would raise- // the keyboard before the words said were typed- // into the prompt — and a re-armed claim on top- // of it was measured asking Android twice per- // tap, which answers a show mid-animation by- // cancelling and restarting it. Null while the- // keyboard is up or coming, so the tap is- // xterm's and the keyboard stays.- onInputTap: _shouldFocus- ? null- : () => unawaited(- _raiseKeyboard(session),- ),- showHeader: false,- // No composer, and so no grip above it: the- // page hands the pane its full height and the- // software keyboard drives the terminal- // directly. The mic's send is what kept the- // composer's batched turn.- ),- ),- ),- // ⚠️ **The skeleton is laid OVER the live panel, not- // swapped in for it, and that is not a stylistic- // choice.** [TerminalPanel.initState] calls- // `session.attachViewport`, which is how the machine- // learns how many rows and columns to draw; a page- // that showed a skeleton INSTEAD would leave the- // session with no viewport, and the first keyframe- // would arrive sized for nothing.- //- // So the panel mounts, measures and resizes as always,- // and this covers the empty emulator buffer it paints- // meanwhile. `session == null` upstream keeps its own- // branch for the frames before a session exists at all.- //- // ⚠️ **This is also the bug that made the skeleton- // invisible.** The only gate used to be `session ==- // null`, and `selectAgent` creates the pane and the- // session in one frame — so the branch above was- // essentially never taken, and what a person actually- // waited in front of was a mounted terminal with an- // empty buffer: a black rectangle, for as long as the- // keyframe took.- if (session != null && !session.hasRenderedFrame)- const Positioned.fill(child: _Attaching()),- // The mic, Search and New agent, floating in the- // terminal's bottom-right corner — see- // [TerminalActionColumn].- //- // ⚠️ Hidden while this page owns the keyboard.- // Typing is the other way of saying what the mic- // says, the key bar is already under the thumb, and- // a column floating over the prompt being typed into- // would be in the way of both.- if (!_ownsInput)- Positioned(- right: TerminalActionColumn.inset,- bottom: TerminalActionColumn.bottomInset,- child: TerminalActionColumn(- voice: widget.voice,- session: session,- onSearch: _openSearch,- onNewAgent: canCreate- ? () => unawaited(_newAgent())- : null,+ // ⚠️ **Held at its height while search is open.** The search+ // field's keyboard shrinks this page like any other; followed,+ // the terminal shrank under the search and grew back through it+ // as it faded out — the flash seen on every close. Nothing here+ // is on screen while search covers it, so nothing here moves.+ HeldHeight(+ hold: _heldForSearch,+ child: Column(+ children: [+ Expanded(+ // ⚠️ The mic floats INSIDE this box, over the terminal+ // — not over the whole page. Stacked any higher it+ // would hang over the key bar while the keyboard is+ // up, which is the one row the thumb is working.+ child: Stack(+ children: [+ Positioned.fill(+ // ⚠️ The chrome is driven from OUT HERE, not+ // from inside the panel. xterm's own+ // [Scrollable] is several widgets down and is+ // remounted whenever the agent changes;+ // listening for its notifications as they+ // bubble past is what survives that, and costs+ // the panel no knowledge of the page's chrome.+ child: NotificationListener<ScrollNotification>(+ onNotification: _chrome.onNotification,+ child: agentGone+ ? _AgentGone(+ name: _cachedAgentName,+ onPickAnother: _pickAnotherAgent,+ )+ : pane == null || session == null+ ? const _Attaching()+ : TerminalPanel(+ key: ValueKey(pane.id),+ notifier: widget.notifier,+ session: session,+ // Only the page on screen takes the keyboard — see+ // [TerminalPage.isActive]. `visible` is the same answer for the+ // panel's other half: a page parked beside this one releases+ // focus, stops rendering and stops resizing its remote shell.+ //+ // Whether it also HOLDS one that is already+ // up is a separate question, and the pager asks+ // it on every swipe — see [_shouldFocus].+ focused: _shouldFocus,+ visible: widget.isActive,+ // Hold the remote resize while the keyboard+ // slides. Separate from `visible` because this+ // must NOT release focus — the animation being+ // waited on is the one that focus started.+ //+ // The keyboard is the only thing left that+ // moves this pane's height: the header slides+ // OVER the terminal rather than out of its+ // column — see [_SlideAway].+ //+ // ⚠️ Held for as long as search is open, too:+ // its keyboard is typing a query over a faded+ // terminal, and resizing the agent's shell for+ // it redrew the whole TUI on the way in and+ // again on the way out.+ settling:+ _keyboardSettling || _heldForSearch,+ // ⚠️ The tap is taken in the panel, not by a+ // `Listener` over it. xterm's own `_onTapDown`+ // calls `requestKeyboard()`, so anything that+ // merely ALSO reacted to the tap would raise+ // the keyboard before the words said were typed+ // into the prompt — and a re-armed claim on top+ // of it was measured asking Android twice per+ // tap, which answers a show mid-animation by+ // cancelling and restarting it. Null while the+ // keyboard is up or coming, so the tap is+ // xterm's and the keyboard stays.+ onInputTap: _shouldFocus+ ? null+ : () => unawaited(+ _raiseKeyboard(session),+ ),+ showHeader: false,+ // No composer, and so no grip above it: the+ // page hands the pane its full height and the+ // software keyboard drives the terminal+ // directly. The mic's send is what kept the+ // composer's batched turn.+ ),),),- ],- ),- ),- // The bottom of this page IS just above the keyboard:- // `PhoneShell`'s Scaffold has already resized for it —- // the same resize that empties this page's MediaQuery- // insets (see [didChangeMetrics]).- if (session != null)- TerminalInputDock(- session: session,- keyboardUp: _keyboardUp || _keyboardRequested,- onDismiss: _dismissInput,- // Only where the far side can actually take one: an- // older CLI never advertises the binary kind, so the- // upload would go nowhere silently. Null leaves the- // buttons undrawn rather than drawn dead.- onPickImage:- machine?.terminalImagePasteAvailable == true- ? () => unawaited(- _sendImage(session, ImageSource.gallery),- )- : null,- onTakePhoto:- machine?.terminalImagePasteAvailable == true- ? () => unawaited(- _sendImage(session, ImageSource.camera),- )- : null,+ // ⚠️ **The skeleton is laid OVER the live panel, not+ // swapped in for it, and that is not a stylistic+ // choice.** [TerminalPanel.initState] calls+ // `session.attachViewport`, which is how the machine+ // learns how many rows and columns to draw; a page+ // that showed a skeleton INSTEAD would leave the+ // session with no viewport, and the first keyframe+ // would arrive sized for nothing.+ //+ // So the panel mounts, measures and resizes as always,+ // and this covers the empty emulator buffer it paints+ // meanwhile. `session == null` upstream keeps its own+ // branch for the frames before a session exists at all.+ //+ // ⚠️ **This is also the bug that made the skeleton+ // invisible.** The only gate used to be `session ==+ // null`, and `selectAgent` creates the pane and the+ // session in one frame — so the branch above was+ // essentially never taken, and what a person actually+ // waited in front of was a mounted terminal with an+ // empty buffer: a black rectangle, for as long as the+ // keyframe took.+ if (session != null && !session.hasRenderedFrame)+ const Positioned.fill(child: _Attaching()),+ // The mic, Search and New agent, floating in the+ // terminal's bottom-right corner — see+ // [TerminalActionColumn].+ //+ // ⚠️ Hidden while this page owns the keyboard.+ // Typing is the other way of saying what the mic+ // says, the key bar is already under the thumb, and+ // a column floating over the prompt being typed into+ // would be in the way of both.+ if (!_ownsInput)+ Positioned(+ right: TerminalActionColumn.inset,+ bottom: TerminalActionColumn.bottomInset,+ child: TerminalActionColumn(+ voice: widget.voice,+ session: session,+ onSearch: _openSearch,+ onNewAgent: canCreate+ ? () => unawaited(_newAgent())+ : null,+ ),+ ),+ ],+ ),),- ],+ // The bottom of this page IS just above the keyboard:+ // `PhoneShell`'s Scaffold has already resized for it —+ // the same resize that empties this page's MediaQuery+ // insets (see [didChangeMetrics]).+ if (session != null)+ TerminalInputDock(+ session: session,+ keyboardUp: _terminalKeyboardUp || _keyboardRequested,+ onDismiss: _dismissInput,+ // Only where the far side can actually take one: an+ // older CLI never advertises the binary kind, so the+ // upload would go nowhere silently. Null leaves the+ // buttons undrawn rather than drawn dead.+ onPickImage:+ machine?.terminalImagePasteAvailable == true+ ? () => unawaited(+ _sendImage(session, ImageSource.gallery),+ )+ : null,+ onTakePhoto:+ machine?.terminalImagePasteAvailable == true+ ? () => unawaited(+ _sendImage(session, ImageSource.camera),+ )+ : null,+ ),+ ],+ ),),// The header, laid OVER the terminal rather than above it in the// column.@@ -1264,8 +1332,8 @@ class _AttachingState extends State<_Attaching>// rather than of whatever happens to be behind them, and the terminal's// background is read from the user's chosen scheme so a light terminal theme// gets bars that are darker than its ground rather than lighter.- final light = ThemeData.estimateBrightnessForColor(ground) ==- Brightness.light;+ final light =+ ThemeData.estimateBrightnessForColor(ground) == Brightness.light;final rest = Color.alphaBlend((light ? Colors.black : Colors.white).withValues(alpha: 0.10),ground,@@ -1279,114 +1347,114 @@ class _AttachingState extends State<_Attaching>child: _RevealDown(listenable: _reveal,child: ColoredBox(- // Opaque, because this covers a live [TerminalPanel] — see the note at- // the call site. Without it the empty emulator buffer shows between the- // bars and the two grounds differ by a hair, which reads as a smudge.- color: ground,- child: Padding(- // ⚠️ The terminal view's OWN padding (`TerminalPanel` passes- // `EdgeInsets.all(10)` to the xterm view), so a bar starts on the- // column the first character will occupy. A different gutter here- // would shift every line sideways the moment the keyframe lands.- padding: const EdgeInsets.all(10),- child: Pulse(- // The breath `shared/widgets/skeleton.dart` sets for a placeholder;- // one controller for the whole block rather than one per bar, so- // the rows pulse together instead of shimmering independently.- duration: const Duration(milliseconds: 1100),- builder: (context, t, _) {- final fill = Color.lerp(rest, peak, t)!;- // The prompt's banner sits on its own ground, a step above the- // terminal's — the band an agent paints behind the line it is- // answering, and the one element that makes this block read as a- // transcript rather than as a list of lines.- //- // 0.08, not the 0.05 this started at: the banner has to be legible- // as a BAND at arm's length on a phone, and at 0.05 over `#181818`- // it was a shade nobody would notice. Still well under the bars- // themselves (0.10–0.17), so it reads as the ground behind them- // rather than as another bar.- final banner = Color.lerp(- ground,- light ? Colors.black : Colors.white,- 0.08,- )!;- final bar = (fontSize * 0.62).clamp(5.0, 12.0).toDouble();- return LayoutBuilder(- builder: (context, constraints) {- // ⚠️ **As many turns as the pane is tall, not a fixed four.**- // A fixed list left the top half of a tall phone empty, which- // reads as a page that has finished loading and has almost- // nothing on it. One extra turn is added beyond the measured- // fit so the topmost one is genuinely cut by the edge rather- // than ending a few pixels short of it.- final height = constraints.maxHeight;- final perTurn = _turnHeight(- _shapes[0],- lineHeight: lineHeight,- );- final count = height.isFinite && perTurn > 0- ? (height / perTurn).ceil() + 1- : _shapes.length;- final turns = [- for (var i = 0; i < count; i++)- // Cycled from the back, so the LAST shape is always the- // one at the bottom edge: it is the only one written- // without a closing meta line, which is what an in-progress- // turn looks like.- _shapes[(_shapes.length - 1 - i % _shapes.length)],- ].reversed.toList();- final blocks = <Widget>[- for (var i = 0; i < turns.length; i++)- Opacity(- // Oldest at 0.4, newest at full: the block nearest the- // top edge is the one about to be clipped by it, so it- // fades INTO that edge rather than ending against it.- opacity: turns.length == 1- ? 1- : 0.4 + (i / (turns.length - 1)) * 0.6,- child: _turn(- turns[i],- lineHeight: lineHeight,- bar: bar,- fill: fill,- banner: banner,- // The newest turn ends at the bottom edge, as the live- // screen's does; only the ones above it are separated.- last: i == turns.length - 1,+ // Opaque, because this covers a live [TerminalPanel] — see the note at+ // the call site. Without it the empty emulator buffer shows between the+ // bars and the two grounds differ by a hair, which reads as a smudge.+ color: ground,+ child: Padding(+ // ⚠️ The terminal view's OWN padding (`TerminalPanel` passes+ // `EdgeInsets.all(10)` to the xterm view), so a bar starts on the+ // column the first character will occupy. A different gutter here+ // would shift every line sideways the moment the keyframe lands.+ padding: const EdgeInsets.all(10),+ child: Pulse(+ // The breath `shared/widgets/skeleton.dart` sets for a placeholder;+ // one controller for the whole block rather than one per bar, so+ // the rows pulse together instead of shimmering independently.+ duration: const Duration(milliseconds: 1100),+ builder: (context, t, _) {+ final fill = Color.lerp(rest, peak, t)!;+ // The prompt's banner sits on its own ground, a step above the+ // terminal's — the band an agent paints behind the line it is+ // answering, and the one element that makes this block read as a+ // transcript rather than as a list of lines.+ //+ // 0.08, not the 0.05 this started at: the banner has to be legible+ // as a BAND at arm's length on a phone, and at 0.05 over `#181818`+ // it was a shade nobody would notice. Still well under the bars+ // themselves (0.10–0.17), so it reads as the ground behind them+ // rather than as another bar.+ final banner = Color.lerp(+ ground,+ light ? Colors.black : Colors.white,+ 0.08,+ )!;+ final bar = (fontSize * 0.62).clamp(5.0, 12.0).toDouble();+ return LayoutBuilder(+ builder: (context, constraints) {+ // ⚠️ **As many turns as the pane is tall, not a fixed four.**+ // A fixed list left the top half of a tall phone empty, which+ // reads as a page that has finished loading and has almost+ // nothing on it. One extra turn is added beyond the measured+ // fit so the topmost one is genuinely cut by the edge rather+ // than ending a few pixels short of it.+ final height = constraints.maxHeight;+ final perTurn = _turnHeight(+ _shapes[0],+ lineHeight: lineHeight,+ );+ final count = height.isFinite && perTurn > 0+ ? (height / perTurn).ceil() + 1+ : _shapes.length;+ final turns = [+ for (var i = 0; i < count; i++)+ // Cycled from the back, so the LAST shape is always the+ // one at the bottom edge: it is the only one written+ // without a closing meta line, which is what an in-progress+ // turn looks like.+ _shapes[(_shapes.length - 1 - i % _shapes.length)],+ ].reversed.toList();+ final blocks = <Widget>[+ for (var i = 0; i < turns.length; i++)+ Opacity(+ // Oldest at 0.4, newest at full: the block nearest the+ // top edge is the one about to be clipped by it, so it+ // fades INTO that edge rather than ending against it.+ opacity: turns.length == 1+ ? 1+ : 0.4 + (i / (turns.length - 1)) * 0.6,+ child: _turn(+ turns[i],+ lineHeight: lineHeight,+ bar: bar,+ fill: fill,+ banner: banner,+ // The newest turn ends at the bottom edge, as the live+ // screen's does; only the ones above it are separated.+ last: i == turns.length - 1,+ ),+ ),+ ];+ // ⚠️ Aligned to the BOTTOM and clipped at the top, which is how+ // a terminal itself sits: the newest output is at the bottom+ // edge and history runs off the top. `OverflowBox` lets the+ // column exceed the pane — the extra turn above guarantees it+ // does — and `ClipRect` cuts what runs past, instead of Flutter+ // painting an overflow stripe over the whole thing.+ return ClipRect(+ child: OverflowBox(+ alignment: Alignment.bottomLeft,+ minHeight: 0,+ maxHeight: double.infinity,+ // ⚠️ The pane's own width is pinned back on, because+ // `OverflowBox` relaxes BOTH axes and the rows inside are+ // `FractionallySizedBox` — against an unbounded width they+ // would have no fraction to take and the layout would throw.+ minWidth: constraints.maxWidth,+ maxWidth: constraints.maxWidth,+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.stretch,+ mainAxisSize: MainAxisSize.min,+ children: blocks,),),- ];- // ⚠️ Aligned to the BOTTOM and clipped at the top, which is how- // a terminal itself sits: the newest output is at the bottom- // edge and history runs off the top. `OverflowBox` lets the- // column exceed the pane — the extra turn above guarantees it- // does — and `ClipRect` cuts what runs past, instead of Flutter- // painting an overflow stripe over the whole thing.- return ClipRect(- child: OverflowBox(- alignment: Alignment.bottomLeft,- minHeight: 0,- maxHeight: double.infinity,- // ⚠️ The pane's own width is pinned back on, because- // `OverflowBox` relaxes BOTH axes and the rows inside are- // `FractionallySizedBox` — against an unbounded width they- // would have no fraction to take and the layout would throw.- minWidth: constraints.maxWidth,- maxWidth: constraints.maxWidth,- child: Column(- crossAxisAlignment: CrossAxisAlignment.stretch,- mainAxisSize: MainAxisSize.min,- children: blocks,- ),- ),- );- },- );- },+ );+ },+ );+ },+ ),),),- ),),);}@@ -1403,10 +1471,7 @@ class _AttachingState extends State<_Attaching>/// lines, gap and meta line, trailing gap. A drift here does not break the/// layout — the column is clipped either way — it just means a turn too few/// (a band of empty ground at the top) or one too many (wasted build).- static double _turnHeight(- _SkeletonTurn turn, {- required double lineHeight,- }) =>+ static double _turnHeight(_SkeletonTurn turn, {required double lineHeight}) =>lineHeight + // the prompt bannerlineHeight * 0.35 + // the gap under itlineHeight * turn.answer.length +@@ -1579,11 +1644,7 @@ class _RevealDown extends StatelessWidget {colors: const [Colors.white, Colors.white, Colors.transparent],// Clamped because a stop list must be non-decreasing and within 0..1;// at the extremes of the travel above, both terms run outside it.- stops: [- 0,- (edge - _feather).clamp(0.0, 1.0),- edge.clamp(0.0, 1.0),- ],+ stops: [0, (edge - _feather).clamp(0.0, 1.0), edge.clamp(0.0, 1.0)],).createShader(bounds),child: built,);diff --git a/mobile/lib/phone/terminal_search.dart b/mobile/lib/phone/terminal_search.dartindex 8b12fb24c..acc703e37 100644--- a/mobile/lib/phone/terminal_search.dart+++ b/mobile/lib/phone/terminal_search.dart@@ -1,27 +1,27 @@import 'package:flutter/material.dart';-import 'package:lucide_icons_flutter/lucide_icons.dart';import 'package:harness_mobile/shared/theme/app_theme.dart';-import 'package:harness_mobile/shared/widgets/touch_target.dart';import 'package:harness_mobile/state/app_state.dart';-import 'composing_keyboard.dart';+import 'phone_search_field.dart';import 'phone_search_results.dart';/// Search, opened in place over a terminal rather than pushed as a page.////// ⚠️ **Not a route.** Pushing [PhoneSearchPage] slid a fresh screen in from the/// right over a terminal that is still streaming underneath; opening in place-/// fades the search up over it instead, and Cancel fades it back down onto the+/// fades the search up over it instead, and closing fades it back down onto the/// same screen, mid-stream.////// It is opened from the floating Search button in the terminal's bottom-right-/// corner (`terminal_action_column.dart`), so it draws its whole self — field,-/// Cancel and results — over an opaque page, rather than borrowing any of the-/// header's.+/// corner (`terminal_action_column.dart`), so it draws its whole self — field+/// and results — over an opaque page, rather than borrowing any of the header's.///-/// The way out is Cancel. The system back gesture reaches it too — see-/// [TerminalSearchOverlay]'s [PopScope].+/// ⚠️ **The search page's own bar, not a second one.** [PhoneSearchField] is one+/// bar with the way out inside it — a chevron at its leading edge — and no+/// Cancel beside it. This screen used to draw its own field with a Cancel, and+/// the two searches drifted apart; drawing the same widget keeps them one. The+/// system back gesture closes it too — see [TerminalSearchOverlay]'s [PopScope].////// ⚠️ **It must stay mounted only while searching.** The [TextField] inside/// autofocuses, so a copy left built behind the terminal would keep the keyboard@@ -36,16 +36,6 @@ class TerminalSearchOverlay extends StatefulWidget {final AppNotifier notifier;- /// The bar's height.- static const double barHeight = 38;-- /// What the field says it will search.- ///- /// ⚠️ Names both kinds on purpose. The query spans agents AND machines, and a- /// bare "Search" left somebody who remembers "that review thing" unsure- /// whether this is where to look for it.- static const String searchHint = 'Search agents and machines';-/// The open/close animation the terminal page drives — 0 gone, 1 filling the/// screen.///@@ -102,11 +92,18 @@ class _TerminalSearchOverlayState extends State<TerminalSearchOverlay> {color: AppPalette.windowBg,child: Column(children: [- _Bar(+ PhoneSearchField(controller: _controller,focus: _focus,onChanged: (value) => setState(() => _query = value),- onCancel: _close,+ onClear: () {+ _controller.clear();+ setState(() => _query = '');+ // Clearing is a step back into browsing, not out of the+ // search — the caret stays where the next query will go.+ _focus.requestFocus();+ },+ onBack: _close,),Divider(height: 1, color: AppGlass.hair),// ⚠️ Handed the query and nothing else. Ranking lives inside it,@@ -130,261 +127,3 @@ class _TerminalSearchOverlayState extends State<TerminalSearchOverlay> {);}}--/// The field, with Cancel at its right end.-class _Bar extends StatelessWidget {- const _Bar({- required this.controller,- required this.focus,- required this.onChanged,- required this.onCancel,- });-- final TextEditingController controller;- final FocusNode focus;-- final ValueChanged<String> onChanged;-- final VoidCallback onCancel;-- @override- Widget build(BuildContext context) {- AppTheme.watch(context);- return Padding(- padding: const EdgeInsets.fromLTRB(14, 6, 14, 8),- child: Row(- children: [- Expanded(- child: ListenableBuilder(- listenable: focus,- builder: (context, child) => AnimatedContainer(- duration: AppMotion.hover,- curve: AppMotion.curve,- height: TerminalSearchOverlay.barHeight,- padding: const EdgeInsets.symmetric(horizontal: 10),- decoration: BoxDecoration(- color: AppGlass.rowFill,- borderRadius: BorderRadius.circular(AppCard.radius),- // Focus is said by the rim of the box the field fills, and by- // the magnifier inside it — see the icon below.- border: Border.all(- color: focus.hasFocus- ? AppPalette.accentOnSurface- : AppGlass.hair,- ),- ),- child: Row(- children: [- // ⚠️ **Inside the builder, not the child passed through- // it.** The glyph lifts with focus, so it has to be rebuilt- // when focus changes; left in the `child` it would be built- // once and keep its resting ink for good.- //- // It climbs to the same accent the rim and the caret- // already use, over the same beat as the rim, so the three- // read as one state arriving rather than as three- // decorations each doing their own thing.- TweenAnimationBuilder<Color?>(- duration: AppMotion.hover,- curve: AppMotion.curve,- // ⚠️ [begin] is the RESTING ink, not left null. A null- // begin lerps from null on the first build, which hands- // the icon a null colour for that frame — it falls back- // to the theme's default ink, and the glyph flashes a- // colour it never otherwise wears. The field autofocuses,- // so that first build is on screen every time search- // opens; starting from rest also makes the very first- // climb an animation rather than a jump.- tween: ColorTween(- begin: AppPalette.textFaint,- end: focus.hasFocus- ? AppPalette.accentOnSurface- : AppPalette.textFaint,- ),- builder: (context, color, _) =>- Icon(LucideIcons.search300, size: 16, color: color),- ),- const SizedBox(width: 8),- // The field and its clear, built once and passed through:- // neither depends on focus, and the field in particular must- // not be rebuilt from a focus tick — see below.- Expanded(child: child!),- ],- ),- ),- // ⚠️ **Everything that does NOT change with focus stays here.**- // The [TextField] especially: it holds the input connection, and- // rebuilding it on every focus tick is work on the one widget- // that can least afford it.- child: Row(- children: [- Expanded(- child: _Input(- controller: controller,- focus: focus,- onChanged: onChanged,- ),- ),- _ClearButton(- controller: controller,- onTap: () {- controller.clear();- onChanged('');- // Clearing is a step back into browsing, not out of the- // search — the caret stays where the next query will go.- focus.requestFocus();- },- ),- ],- ),- ),- ),- _CancelButton(onTap: onCancel),- ],- ),- );- }-}--class _Input extends StatelessWidget {- const _Input({- required this.controller,- required this.focus,- required this.onChanged,- });-- final TextEditingController controller;- final FocusNode focus;- final ValueChanged<String> onChanged;-- @override- Widget build(BuildContext context) {- AppTheme.watch(context);- return TextField(- controller: controller,- focusNode: focus,- // The whole point of expanding rather than pushing: the keyboard comes up- // on the bar that was tapped, without a screen sliding across first.- autofocus: true,- onChanged: onChanged,- // The list is already filtered by the time a key is released; there is- // nothing left for the return key to submit, so it stays a plain "done"- // that drops the keyboard and leaves the results up.- textInputAction: TextInputAction.search,- onSubmitted: (_) => focus.unfocus(),- // Composing stays on — or Telex types `thoi tiet` for `thời tiết`. See- // [ComposingKeyboard]; with autocorrect on, iOS would also start curling- // quotes and joining dashes, which a query means literally.- autocorrect: ComposingKeyboard.autocorrect,- enableSuggestions: ComposingKeyboard.enableSuggestions,- smartDashesType: SmartDashesType.disabled,- smartQuotesType: SmartQuotesType.disabled,- // Agent names are ids as often as sentences — `Dijkstra-visualization.html`- // — and a capital forced onto the first letter of one is a wrong query.- textCapitalization: TextCapitalization.none,- textAlignVertical: TextAlignVertical.center,- style: TextStyle(color: AppPalette.textPrimary, fontSize: 14),- cursorColor: AppPalette.accentOnSurface,- decoration: InputDecoration(- isDense: true,- // ⚠️ **Every** border state, not just `border`. The app's- // `inputDecorationTheme` fills the named states in, and its- // `focusedBorder` is an accent outline at a tighter radius than this box- // — which drew a second rectangle INSIDE the rim. Naming each state is- // what keeps the theme from reaching past `border`.- border: InputBorder.none,- enabledBorder: InputBorder.none,- focusedBorder: InputBorder.none,- errorBorder: InputBorder.none,- focusedErrorBorder: InputBorder.none,- disabledBorder: InputBorder.none,- // The theme also fills these, and both would draw over the box: a fill- // over the rim's own, and Material's phone-sized padding over the height- // set above.- filled: false,- contentPadding: EdgeInsets.zero,- constraints: const BoxConstraints(),- hintText: TerminalSearchOverlay.searchHint,- hintStyle: TextStyle(color: AppPalette.textFaint, fontSize: 14),- ),- );- }-}--/// Only once there is something to clear: a button that does nothing on an-/// empty field is a button people learn to skip.-class _ClearButton extends StatelessWidget {- const _ClearButton({required this.controller, required this.onTap});-- final TextEditingController controller;- final VoidCallback onTap;-- @override- Widget build(BuildContext context) {- AppTheme.watch(context);- return ValueListenableBuilder(- valueListenable: controller,- builder: (context, value, _) => value.text.isEmpty- ? const SizedBox.shrink()- : Semantics(- button: true,- label: 'Clear',- // The padding alone left a 24x16 target; [TouchTarget] takes it- // to a thumb's without moving the field beside it.- child: TouchTarget(- child: GestureDetector(- behavior: HitTestBehavior.opaque,- onTap: onTap,- child: Padding(- padding: const EdgeInsets.only(left: 8),- child: Icon(- LucideIcons.circleX300,- size: 16,- color: AppPalette.textFaint,- ),- ),- ),- ),- ),- );- }-}--/// The way out: the word, not a glyph. A second `×` beside the field's own-/// clear would be two ways out sitting together.-class _CancelButton extends StatelessWidget {- const _CancelButton({required this.onTap});-- final VoidCallback onTap;-- @override- Widget build(BuildContext context) {- AppTheme.watch(context);- return Semantics(- button: true,- label: 'Cancel search',- child: GestureDetector(- behavior: HitTestBehavior.opaque,- onTap: onTap,- child: SizedBox(- height: TerminalSearchOverlay.barHeight,- child: Padding(- padding: const EdgeInsets.only(left: 12, right: 2),- child: Center(- child: Text(- 'Cancel',- maxLines: 1,- softWrap: false,- style: TextStyle(- color: AppPalette.accentOnSurface,- fontSize: 14,- fontWeight: FontWeight.w500,- ),- ),- ),- ),- ),- ),- );- }-}diff --git a/mobile/test/phone_search_test.dart b/mobile/test/phone_search_test.dartindex a8366de02..0f7f364bb 100644--- a/mobile/test/phone_search_test.dart+++ b/mobile/test/phone_search_test.dart@@ -5,6 +5,7 @@ import 'package:harness_mobile/core/config.dart';import 'package:harness_mobile/core/models.dart';import 'package:harness_mobile/phone/agent_index.dart';import 'package:harness_mobile/phone/compact_age.dart';+import 'package:harness_mobile/phone/phone_search_field.dart';import 'package:harness_mobile/phone/phone_search_folder_header.dart';import 'package:harness_mobile/phone/phone_search_groups.dart';import 'package:harness_mobile/phone/phone_search_index.dart';@@ -486,6 +487,34 @@ void main() {}});+ testWidgets('terminal search: the same one bar, its chevron closes it', (+ tester,+ ) async {+ final app = _app([+ _machine('box', [_agent('3188', minutesAgo: 4)]),+ ]);+ addTearDown(app.dispose);+ var closed = 0;+ await tester.pumpWidget(+ MaterialApp(+ home: Scaffold(+ body: TerminalSearchOverlay(+ notifier: app,+ animation: const AlwaysStoppedAnimation(1),+ onClose: () => closed++,+ ),+ ),+ ),+ );+ await tester.pump();+ expect(find.byType(PhoneSearchField), findsOneWidget);+ expect(find.text('Cancel'), findsNothing);++ await tester.tap(find.bySemanticsLabel('Back'));+ await tester.pump();+ expect(closed, 1);+ });+testWidgets('one bar: no Cancel beside it, and its chevron closes search', (tester,) async {diff --git a/mobile/test/terminal_page_header_fold_test.dart b/mobile/test/terminal_page_header_fold_test.dartindex 412328150..38f155b95 100644--- a/mobile/test/terminal_page_header_fold_test.dart+++ b/mobile/test/terminal_page_header_fold_test.dart@@ -2,7 +2,10 @@ import 'package:flutter/material.dart';import 'package:flutter_test/flutter_test.dart';import 'package:harness_mobile/auth/auth_session.dart';import 'package:harness_mobile/core/config.dart';+import 'package:harness_mobile/phone/phone_search_results.dart';+import 'package:harness_mobile/phone/terminal_action_column.dart';import 'package:harness_mobile/phone/terminal_header.dart';+import 'package:harness_mobile/phone/terminal_key_bar.dart';import 'package:harness_mobile/phone/terminal_page.dart';import 'package:harness_mobile/phone/voice_input_controller.dart';import 'package:harness_mobile/state/app_state.dart';@@ -127,6 +130,64 @@ void main() {expect(resizes, isEmpty);});+ testWidgets('the terminal under search holds still through open and close', (+ tester,+ ) async {+ await tester.pumpWidget(+ MaterialApp(+ home: TerminalPage(+ notifier: notifier,+ machineId: 'm',+ agentId: 'a',+ voice: voice,+ ),+ ),+ );+ await tester.pump(const Duration(milliseconds: 100));+ final size = tester.getSize(find.byType(TerminalView));+ resizes.clear();+ // The terminal as it was — its height, no key bar, its floating column.+ void expectUntouched() {+ expect(tester.getSize(find.byType(TerminalView)), size);+ expect(find.byType(TerminalKeyBar), findsNothing);+ expect(find.byType(TerminalActionColumn), findsOneWidget);+ }++ await tester.tap(find.byKey(const ValueKey('terminal-search')));+ await tester.pump();+ addTearDown(tester.view.resetViewInsets);+ for (final inset in const [300.0, 600.0, 900.0]) {+ tester.view.viewInsets = FakeViewPadding(bottom: inset);+ await tester.pump(const Duration(milliseconds: 16));+ expectUntouched();+ }+ await tester.pump(const Duration(seconds: 1));+ expectUntouched();+ // The search itself still sits above its keyboard.+ expect(+ tester.getBottomLeft(find.byType(PhoneSearchResults)).dy,+ lessThanOrEqualTo(size.height),+ );++ // Closed the way iOS does it: the keyboard's view goes at once, but the+ // inset it reports falls over ~0.5s — past the end of search's fade. Every+ // frame, through the fade AND after it, shows the terminal search opened+ // over; releasing it with the fade let the falling inset raise its key bar.+ await tester.tap(find.bySemanticsLabel('Back'));+ await tester.pump();+ for (var ms = 0; ms <= 700; ms += 16) {+ tester.view.viewInsets = FakeViewPadding(+ bottom: ms >= 500 ? 0 : 900 * (1 - ms / 500),+ );+ await tester.pump(const Duration(milliseconds: 16));+ expectUntouched();+ }+ await tester.pump(const Duration(seconds: 1));+ expect(find.byType(PhoneSearchResults), findsNothing);+ expectUntouched();+ expect(resizes, isEmpty);+ });+testWidgets('the first keyboard up resizes the terminal once, when it lands', (tester,) async {