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
feat(search): implement single search bar with chevron for closing, removing Cancel button
Dev jacob294e6da7a7b9
diff --git a/mobile/lib/phone/terminal_header.dart b/mobile/lib/phone/terminal_header.dartindex 29e809d36..b5c612eaf 100644--- a/mobile/lib/phone/terminal_header.dart+++ b/mobile/lib/phone/terminal_header.dart@@ -66,9 +66,9 @@ class TerminalHeader extends StatelessWidget {/// The gap between the bar and whatever sits right of it.////// ⚠️ Carried by the trailing controls themselves, not laid in this row. The- /// page swaps those controls for a Cancel as search opens, and a gap sitting- /// outside that swap would be points neither side accounts for — see- /// `_TrailingSwap` in `terminal_page.dart`.+ /// page sizes their slot from one count, and the search field is laid out+ /// from that same number; a gap sitting outside the slot would be points+ /// neither side accounts for — see `_TrailingFade` in `terminal_page.dart`.static const double barGap = 6;/// What the bar says it will search.@@ -102,11 +102,10 @@ class TerminalHeader extends StatelessWidget {),),// ⚠️ **No gap of its own before these — see [barGap].** The page- // swaps these controls for a Cancel of a different width, and sizes- // the slot they share from one measurement. A spacer sitting outside- // that slot is points the measurement does not know about, so the- // search overlay's field — which is laid out from the same number —- // would stop short of where this row's own does, by exactly six.+ // sizes their slot from one count. A spacer sitting outside that slot+ // is points the count does not know about, so the search overlay's+ // field — which is laid out from the same number — would stop short+ // of where this row's own does, by exactly six....trailing,],),diff --git a/mobile/lib/phone/terminal_page.dart b/mobile/lib/phone/terminal_page.dartindex 2e434697e..888ee6e1a 100644--- a/mobile/lib/phone/terminal_page.dart+++ b/mobile/lib/phone/terminal_page.dart@@ -402,8 +402,8 @@ 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() {@@ -649,15 +649,15 @@ class _TerminalPageState extends State<TerminalPage>.where((a) => a.id == widget.agentId).firstOrNull;final reclaim = phoneReclaimAction(session);- // The header's trailing controls, counted before they are built: the- // slot they share with Cancel is sized from this, and the search field- // is laid out against that same width. The conditions must match the- // ones guarding each control below — see [_TrailingSwap.extentFor].+ // The header's trailing controls, counted before they are built: their+ // slot is sized from this, and the search field is laid out against+ // that same width. The conditions must match the ones guarding each+ // control below — see [_TrailingFade.extentFor].//// ⚠️ [reclaim] is counted too, though it is a labelled button rather// than one of the fixed 24px icon boxes. It cannot be measured from a// constant — its width is its label's — so the slot treats it as a- // MINIMUM rather than a fixed size: see [_TrailingSwap], which floors+ // MINIMUM rather than a fixed size: see [_TrailingFade], which floors// the width it is given instead of forcing it. Sizing it exactly is not// worth a second TextPainter for a button that shows only on a// read-only stream.@@ -668,7 +668,7 @@ class _TerminalPageState extends State<TerminalPage>: 0) +(agent != null ? 1 : 0) +(reclaim != null ? 1 : 0);- final trailingExtent = _TrailingSwap.extentFor(context, headerActions);+ final trailingExtent = _TrailingFade.extentFor(context, headerActions);return Scaffold(backgroundColor: AppPalette.windowBg,// ⚠️ No fab. New agent is the `+` in the header — see the note there.@@ -906,18 +906,15 @@ class _TerminalPageState extends State<TerminalPage>// [TerminalFootBar] at the foot of the page, where it reads// as identity rather than as chrome.//- // ⚠️ **Wrapped so the pair can hand over to Cancel.** They act+ // ⚠️ **Wrapped so they can step aside for search.** They act// on the agent underneath, which is not what is on screen once- // search is up — so they cross-fade for the way out, in a slot- // that keeps one width throughout. See [_TrailingSwap]: the- // field beside it must not move, which is what the earlier- // collapse-and-reopen got wrong.+ // search is up — so they fade out while the search field+ // widens over their place. No Cancel takes it: the way out+ // is the chevron at the field's own leading edge. See+ // [_TrailingFade] and `terminal_search.dart`.trailing: [- _TrailingSwap(+ _TrailingFade(progress: _searchCurve,- cancel: _CancelSearchButton(- onTap: _closeSearch,- ),extent: trailingExtent,children: [// Read-only is a state to get OUT of, so its way out is a@@ -1046,9 +1043,10 @@ class _TerminalPageState extends State<TerminalPage>notifier: widget.notifier,animation: _searchCurve,onClose: _closeSearch,- // What the header's trailing slot holds — the field stops- // there rather than reaching under Cancel. The same number- // the header lays that slot out from, so the two agree.+ // What the header's trailing slot holds — where the field+ // starts from before it widens over the fading controls.+ // The same number the header lays that slot out from, so+ // the two agree on the first frame.trailingExtent: trailingExtent,),),@@ -1326,130 +1324,39 @@ String _clipTitle(String name) {return '${String.fromCharCodes(runes.take(_titleMaxChars)).trimRight()}…';}-/// The way out of search, in the header where the page's own controls were.+/// The header's trailing end, fading its controls out as search opens — in a+/// column whose width the search field can count on.///-/// ⚠️ **It draws at a fixed size and does not animate.** Its arrival is-/// [_TrailingSwap]'s fade; a width or a scale of its own on top of that is what-/// made the field beside it move, and the field holding still is the point.+/// There is no Cancel to swap in: the way out of search is the chevron at the+/// field's leading edge, as on the search page. The field widens over this slot+/// as the controls fade, one move in one direction; see `_Bar` in+/// `terminal_search.dart`.///-/// The word rather than a glyph: this is the one control on the row that leaves,-/// and a second `×` beside the field's own clear would be two ways out sitting-/// together.-class _CancelSearchButton extends StatelessWidget {- const _CancelSearchButton({required this.onTap});-- final VoidCallback onTap;-- static const String _label = 'Cancel';-- /// The gap between the field and the word.- static const double _lead = 12;-- static const TextStyle _style = TextStyle(- fontSize: 14,- fontWeight: FontWeight.w500,- );-- /// How wide this button comes out, laid against [context]'s text scaling.- ///- /// ⚠️ **Measured, not assumed.** The search overlay draws its field beside- /// this and has to stop exactly where the word starts; a hard-coded width- /// would be wrong the moment the system font scale moves, and the field would- /// either overhang "Cancel" or leave a gap before it. [TextPainter] is what- /// the row itself will lay out with, so the two agree by construction.- static double extentFor(BuildContext context) {- final painter = TextPainter(- text: TextSpan(text: _label, style: _style),- textDirection: Directionality.of(context),- textScaler: MediaQuery.textScalerOf(context),- maxLines: 1,- )..layout();- final width = painter.width;- painter.dispose();- return _lead + width;- }-- @override- Widget build(BuildContext context) {- AppTheme.watch(context);- return Semantics(- button: true,- label: 'Cancel search',- child: GestureDetector(- behavior: HitTestBehavior.opaque,- onTap: onTap,- child: SizedBox(- // The bar's own height, so the target covers the row rather than just- // the word's line box.- height: TerminalHeader.barHeight,- child: Padding(- // Leading gap from the field; nothing trailing, so the word stops on- // the header's own right inset the way the last action does.- padding: const EdgeInsets.only(left: _lead),- child: Center(- child: Text(- _label,- maxLines: 1,- softWrap: false,- style: _style.copyWith(color: AppPalette.accentOnSurface),- ),- ),- ),- ),- ),- );- }-}--/// The header's trailing end, cross-fading its controls for Cancel as search-/// opens — in a column that never changes width.-///-/// ⚠️ **A [Stack], not a collapse, and the search field's steadiness is the-/// whole reason.** Handing these points back made the field widen into them and-/// then narrow again as Cancel claimed its own — two layout changes in opposite-/// directions inside one gesture, which reads as the row snapping about rather-/// than as anything opening. Keeping both sets in the same slot means the field-/// is laid out once and never moves: what changes is only which of the two is-/// painted.-///-/// ⚠️ **The slot is given an explicit width, not sized by its children.** A-/// [Stack] would take the wider of the two, which is a number nothing outside-/// this widget can predict — and the search overlay MUST predict it, because it-/// draws its field up to this slot's left edge. [extentFor] is that number, and-/// both this and the overlay are laid out from it.-///-/// ⚠️ Both children stay laid out for the whole animation. That is what lets-/// them cross-fade at all, and it is why each is wrapped in its own-/// [IgnorePointer] — an invisible Cancel over a live `⋯` would otherwise take-/// the tap meant for the menu.-class _TrailingSwap extends StatelessWidget {- const _TrailingSwap({+/// ⚠️ **The slot is given an explicit width, not sized by its children.** The+/// search overlay draws its field up to this slot's left edge on the first frame+/// of the open, so it must be able to predict that edge. [extentFor] is that+/// number, and both this and the overlay are laid out from it.+class _TrailingFade extends StatelessWidget {+ const _TrailingFade({required this.progress,required this.children,- required this.cancel,required this.extent,});- /// 0 the page's own controls are showing, 1 Cancel is.+ /// 0 the page's own controls are showing, 1 search is fully open.final Animation<double> progress;/// The header's controls: `+`, `⋯`, and reclaim when the stream is read-only.final List<Widget> children;- /// The way out of search, shown in their place.- final Widget cancel;-/// The slot's width, from [extentFor].final double extent;/// How wide a slot holding [actions] controls must be.///- /// The wider of the two states, so the field beside it lands in the same place- /// whichever is showing — which is the entire point of the swap.- ///- /// ⚠️ Counts [TerminalHeader.barGap] once, at the front. Both states carry- /// that gap (see the [Row] below and [_CancelSearchButton]'s own leading pad),- /// so it belongs to the slot rather than to either side of it.+ /// ⚠️ Counts [TerminalHeader.barGap] once, at the front: the gap between the+ /// field and the controls belongs to the slot, so the field's right edge is+ /// the slot's left one.static double extentFor(BuildContext context, int actions) {// Each action is [AppIconButton]'s fixed 24px box with [_HeaderAction.gap]// either side, except the last, whose trailing pad is dropped so the row@@ -1458,57 +1365,39 @@ class _TrailingSwap extends StatelessWidget {final controls = actions == 0? 0.0: actions * (box + _HeaderAction.gap * 2) - _HeaderAction.gap;- final cancel = _CancelSearchButton.extentFor(context);- return TerminalHeader.barGap + (controls > cancel ? controls : cancel);+ return TerminalHeader.barGap + controls;}@overrideWidget build(BuildContext context) => AnimatedBuilder(animation: progress,- builder: (context, _) {- final open = progress.value;- // ⚠️ Fading straight across leaves the middle of the move half-lit on- // both sides, which reads as a smear rather than as an exchange. Each- // takes its own half: the outgoing is gone by the midpoint, and the- // incoming starts from there.- final out = (1 - open * 2).clamp(0.0, 1.0);- final into = (open * 2 - 1).clamp(0.0, 1.0);- return ConstrainedBox(- // ⚠️ A MINIMUM, not a fixed width. The reclaim button is labelled, so- // its width is its text's and no constant describes it — forcing the- // measured width on the row would clip it. A floor gives the field a- // width it can count on while leaving a wider control room to be itself:- // the only cost is that the field is a little shorter than it could be- // on a read-only stream, which is a state search is rarely opened from.- constraints: BoxConstraints(minWidth: extent),- child: Stack(- // Against the right edge: whichever is showing, it ends on the- // header's own inset rather than floating inside the slot.- alignment: Alignment.centerRight,- children: [- Opacity(- opacity: out,- child: IgnorePointer(- // Untappable from the first frame of the open: they act on the- // agent underneath, and search is what is on screen now.- ignoring: open > 0,- // ⚠️ No gap of its own before these — the slot's width already- // carries [TerminalHeader.barGap], and a second one here would- // push the controls off the header's right inset.- child: Row(mainAxisSize: MainAxisSize.min, children: children),- ),- ),- Opacity(- opacity: into,- // Live only once it is the thing on screen. Taken on the tail of- // the fade rather than at the very end, so a finger arriving as- // the word settles is not ignored.- child: IgnorePointer(ignoring: open < 0.5, child: cancel),- ),- ],+ builder: (context, child) => ConstrainedBox(+ // ⚠️ A MINIMUM, not a fixed width. The reclaim button is labelled, so its+ // width is its text's and no constant describes it — forcing the counted+ // width on the row would clip it.+ constraints: BoxConstraints(minWidth: extent),+ child: Align(+ // Against the right edge, so the controls end on the header's own inset+ // rather than floating inside the slot.+ alignment: Alignment.centerRight,+ widthFactor: 1,+ child: Opacity(+ // Gone by the midpoint: the field is widening into this space, and+ // controls still lit under it read as two things fighting for it.+ opacity: (1 - progress.value * 2).clamp(0.0, 1.0),+ child: IgnorePointer(+ // Untappable from the first frame of the open: they act on the+ // agent underneath, and search is what is on screen now.+ ignoring: progress.value > 0,+ child: child,+ ),),- );- },+ ),+ ),+ // ⚠️ No gap of its own before these — the slot's width already carries+ // [TerminalHeader.barGap], and a second one here would push the controls+ // off the header's right inset.+ child: Row(mainAxisSize: MainAxisSize.min, children: children),);}diff --git a/mobile/lib/phone/terminal_search.dart b/mobile/lib/phone/terminal_search.dartindex 054a9d4c6..daeec07a2 100644--- a/mobile/lib/phone/terminal_search.dart+++ b/mobile/lib/phone/terminal_search.dart@@ -17,16 +17,18 @@ import 'terminal_header.dart';/// while an identical one arrived from off-screen. Opening in place leaves the/// thing that was tapped exactly where it was.///-/// ⚠️ **Nothing here moves, and that took two tries to get right.** The bar-/// first grew into the screen, then merely widened as Cancel opened beside it;-/// both widened the field and then narrowed it again within the one gesture,-/// which is felt as the row snapping about. The field is now laid out once, at-/// one width, for the whole of the open. What changes is the header's trailing-/// end, which cross-fades `+` and `⋯` for Cancel — see `_TrailingSwap` in-/// `terminal_page.dart` — and the results, which fade up underneath.+/// ⚠️ **One bar, no Cancel — the search page's shape.** The way out is the+/// chevron at the field's leading edge, which the magnifier turns into as the+/// search opens, exactly where [PhoneSearchField] keeps its own. A Cancel beside+/// the bar was a second way out sitting next to the field's clear, and it cost+/// the field the width of a word.///-/// The way out is that Cancel. The system back gesture reaches it too — see-/// [TerminalSearchOverlay]'s [PopScope].+/// ⚠️ **The field moves once, in one direction.** It starts on the header's own+/// bar, then widens over `+` and `⋯` as they fade (see `_TrailingFade` in+/// `terminal_page.dart`). An earlier Cancel widened the field and then narrowed+/// it again within the one gesture, which is felt as the row snapping about;+/// with nothing claiming the space back, that cannot happen. 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@@ -42,8 +44,8 @@ class TerminalSearchOverlay extends StatefulWidget {final AppNotifier notifier;- /// How much of the header's row its trailing slot is holding — the Cancel the- /// header swaps in as this opens. The field stops there; see [_Bar].+ /// How much of the header's row its trailing slot is holding: where the+ /// field starts from before it widens over that slot. See [_Bar].final double trailingExtent;/// The open/close animation the terminal page drives — 0 collapsed into the@@ -98,23 +100,23 @@ class _TerminalSearchOverlayState extends State<TerminalSearchOverlay> {// for nothing.child: Column(children: [- // ⚠️ **The bar neither fades in nor changes size.** It lands exactly- // on the header's own, which hides its picture of a field while this- // real one is up. Nothing about this row moves: the whole transition- // is the header trading `+` and `⋯` for Cancel beside it — see- // `_TrailingSwap` in `terminal_page.dart`.+ // ⚠️ **The bar never fades in.** It lands exactly on the header's+ // own, which hides its picture of a field while this real one is up,+ // and then only widens — see [_Bar].//- // ⚠️ Transparent, and that is what lets the swap be seen. This row- // sits directly over the header, so a fill here would cover the very- // controls whose exchange IS the animation.+ // ⚠️ Transparent, and that is what lets the fade be seen. This row+ // sits directly over the header, so a fill here would cover `+` and+ // `⋯` stepping aside for the field._Bar(controller: _controller,focus: _focus,+ animation: widget.animation,onChanged: (value) => setState(() => _query = value),+ onBack: _close,trailingExtent: widget.trailingExtent,),// ⚠️ Fades on the back half of the animation alone. The header's- // controls are still trading places over the front half, and rows+ // controls are still stepping aside over the front half, and rows// arriving under them is two things happening at once.Expanded(child: _FadeIn(@@ -144,37 +146,44 @@ class _TerminalSearchOverlayState extends State<TerminalSearchOverlay> {/// The real field, drawn over the header's picture of one.///-/// ⚠️ **Exactly [TerminalHeader]'s geometry, and that is the whole job.** The-/// header draws a tappable box that only looks like a field; this draws the-/// [TextField] that replaces it, and the header hides its own for as long as-/// this is up (see `barHidden`). The two must land on the same pixels — same+/// ⚠️ **It starts on exactly [TerminalHeader]'s geometry.** The header draws a+/// tappable box that only looks like a field; this draws the [TextField] that+/// replaces it, and the header hides its own for as long as this is up (see+/// `barHidden`). On the first frame the two must land on the same pixels — same/// height, same corner radius, same outer padding, same right edge — or the bar-/// jumps on the frame the overlay takes over.+/// jumps as the overlay takes over.///-/// ⚠️ It takes no animation. Nothing in this row moves: the field is laid out-/// once at one width, and the only thing that changes across the open is which-/// control the header paints at its trailing end. See `_TrailingSwap` in-/// `terminal_page.dart`.+/// From there it only widens: its right edge travels from the header's+/// trailing slot to the header's own inset while `+` and `⋯` fade out of the+/// way, so the open search is one bar across the row, as on the search page.class _Bar extends StatelessWidget {const _Bar({required this.controller,required this.focus,+ required this.animation,required this.onChanged,+ required this.onBack,required this.trailingExtent,});final TextEditingController controller;final FocusNode focus;+ /// 0 sitting on the header's bar, 1 across the whole row.+ final Animation<double> animation;+final ValueChanged<String> onChanged;+ /// Closes the search — the chevron at the field's leading edge.+ final VoidCallback onBack;+/// How much of the row the header's trailing slot is holding, so this field- /// stops exactly where the header's picture of it does.+ /// starts exactly where the header's picture of it ends.////// ⚠️ Measured by the header rather than guessed at here. The slot's width/// depends on which controls the page is showing — `+` comes and goes with the/// machine's readiness, reclaim with the stream — and a field that assumed a- /// fixed number of them would overhang Cancel by the difference.+ /// fixed number of them would start short of, or over, the header's own.final double trailingExtent;@override@@ -182,119 +191,129 @@ class _Bar extends StatelessWidget {AppTheme.watch(context);// ⚠️ **No fill of its own.** The real header is directly underneath and is// already opaque — [_TerminalPageState] reveals it before opening this — so- // this row only has to draw the field. Filling it would cover the `+` and- // `⋯` whose fade into Cancel is the transition.- return Padding(- padding: EdgeInsets.fromLTRB(- TerminalHeader.sideInset,- TerminalHeader.topInset,- // ⚠️ The header's own inset PLUS whatever its trailing slot is holding.- // The field ends where the header's picture of it ends; the controls- // beyond are the header's to draw, and this must not reach over them.- TerminalHeader.sideInset + trailingExtent,- TerminalHeader.bottomInset,+ // this row only has to draw the field. Filling it would cover `+` and `⋯`+ // fading out of the field's way.+ return AnimatedBuilder(+ animation: animation,+ builder: (context, field) => Padding(+ padding: EdgeInsets.fromLTRB(+ TerminalHeader.sideInset,+ TerminalHeader.topInset,+ // The header's own inset, plus whatever of its trailing slot the+ // field has not yet taken over.+ TerminalHeader.sideInset + trailingExtent * (1 - animation.value),+ TerminalHeader.bottomInset,+ ),+ child: field,),- child: Row(- children: [- Expanded(- child: ListenableBuilder(- listenable: focus,- builder: (context, child) => AnimatedContainer(- duration: AppMotion.hover,- curve: AppMotion.curve,- height: TerminalHeader.barHeight,- padding: const EdgeInsets.symmetric(- horizontal: TerminalHeader.barPadding,- ),- 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: TerminalHeader.glyphSize,- 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!),- ],- ),+ // ⚠️ **The field rides through as the builder's child.** Only the inset+ // above changes per frame; the [TextField] holds the input connection and+ // is not rebuilt for it.+ child: ListenableBuilder(+ listenable: focus,+ builder: (context, child) => AnimatedContainer(+ duration: AppMotion.hover,+ curve: AppMotion.curve,+ height: TerminalHeader.barHeight,+ padding: const EdgeInsets.symmetric(+ horizontal: TerminalHeader.barPadding,+ ),+ decoration: BoxDecoration(+ color: AppGlass.rowFill,+ borderRadius: BorderRadius.circular(AppCard.radius),+ // Focus is said once, by the rim of the box the field fills. The+ // accent is the same one the caret already uses.+ border: Border.all(+ color: focus.hasFocus+ ? AppPalette.accentOnSurface+ : AppGlass.hair,+ ),+ ),+ 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: [+ _BackGlyph(animation: animation, onTap: onBack),+ const SizedBox(width: 8),+ Expanded(+ child: _Input(+ controller: controller,+ focus: focus,+ onChanged: onChanged,),- // ⚠️ **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(+ ),+ _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();+ },+ ),+ ],+ ),+ ),+ );+ }+}++/// The field's leading glyph: the header's magnifier, turning into the chevron+/// that closes the search as it opens.+///+/// ⚠️ **The magnifier's own footprint, and a thumb's reach.** Both glyphs are+/// drawn in [TerminalHeader.glyphSize] on the spot the header's magnifier holds,+/// so the hint beside them does not shift as one becomes the other;+/// [TouchTarget] takes the tap to 44pt without moving either.+class _BackGlyph extends StatelessWidget {+ const _BackGlyph({required this.animation, required this.onTap});++ final Animation<double> animation;+ final VoidCallback onTap;++ @override+ Widget build(BuildContext context) {+ AppTheme.watch(context);+ return Semantics(+ button: true,+ label: 'Close search',+ child: TouchTarget(+ child: GestureDetector(+ behavior: HitTestBehavior.opaque,+ onTap: onTap,+ child: SizedBox.square(+ dimension: TerminalHeader.glyphSize,+ child: AnimatedBuilder(+ animation: animation,+ builder: (context, _) => Stack(+ alignment: Alignment.center,children: [- Expanded(- child: _Input(- controller: controller,- focus: focus,- onChanged: onChanged,+ Opacity(+ opacity: 1 - animation.value,+ child: Icon(+ LucideIcons.search300,+ size: TerminalHeader.glyphSize,+ color: AppPalette.textFaint,),),- _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();- },+ Opacity(+ opacity: animation.value,+ child: Icon(+ LucideIcons.chevronLeft,+ size: TerminalHeader.glyphSize,+ color: AppPalette.textPrimary,+ ),),],),),),- // ⚠️ **Cancel is NOT here — it belongs to the header, and must.** It- // once opened out of this row from zero width, which widened the field- // as it grew and then narrowed it again as the word claimed its place:- // two layout changes in opposite directions inside one tap, felt as- // the row snapping about. The header now cross-fades its `+` and `⋯`- // for Cancel inside a slot of one fixed width — see `_TrailingSwap` in- // `terminal_page.dart` — so the field is laid out once and never- // moves. This row draws the field and nothing else.- ],+ ),),);}@@ -434,69 +453,3 @@ class _ClearButton extends StatelessWidget {);}}--/// The word, not a glyph. This is the one control on the row that leaves, and a-/// second `×` beside the field's own would be two ways out sitting together.-///-/// ⚠️ **Superseded — Cancel is drawn by the header now.** It opened by WIDTH-/// from nothing, taking its points off the field beside it, so the field widened-/// while this grew and narrowed again as it settled. Two layout changes in-/// opposite directions inside one tap read as the row snapping about, which is-/// what replaced it: `_CancelSearchButton` in `terminal_page.dart` draws at a-/// fixed size and arrives on a cross-fade, leaving the field still.-///-/// Kept for the geometry, should a width-opening control ever be wanted here.-// ignore: unused_element-class _CancelButton extends StatelessWidget {- const _CancelButton({required this.animation, required this.onTap});-- final Animation<double> animation;- 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: TerminalHeader.barHeight,- // ⚠️ Align + a widthFactor, not an animated `width`. The label must- // not reflow while the box narrows — a "Cancel" wrapping to "Canc /- // el" for four frames is what a `SizedBox(width: …)` around text- // does. This clips it instead, from the left, so the word slides out- // from behind the field's right edge.- child: ClipRect(- child: Align(- alignment: Alignment.centerRight,- widthFactor: animation.value,- child: Padding(- padding: const EdgeInsets.only(left: 12, right: 2),- child: Center(- child: Opacity(- // The word itself catches up late, so it is legible the- // moment there is room for it rather than smearing in.- opacity: Curves.easeIn.transform(animation.value),- 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 80c68abe6..7a628cb72 100644--- a/mobile/test/phone_search_test.dart+++ b/mobile/test/phone_search_test.dart@@ -448,6 +448,39 @@ void main() {}});+ testWidgets('terminal search: one bar, no Cancel, 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++,+ trailingExtent: 62,+ ),+ ),+ ),+ );+ await tester.pump();+ expect(find.text('Cancel'), findsNothing);+ // Open all the way, the field runs to the header's own inset: the trailing+ // slot it started beside is its to take.+ final screen = tester.getSize(find.byType(Scaffold)).width;+ final field = tester.getRect(find.byType(AnimatedContainer).first);+ expect(field.right, closeTo(screen - 14, 0.5));++ await tester.tap(find.bySemanticsLabel('Close search'));+ await tester.pump();+ expect(closed, 1);+ });+testWidgets('one bar: no Cancel beside it, and its chevron closes search', (tester,) async {