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(mobile): hold the terminal search bar still as search opens
tony99a60c2be6a1
diff --git a/mobile/lib/phone/terminal_header.dart b/mobile/lib/phone/terminal_header.dartindex 930a5a27e..29e809d36 100644--- a/mobile/lib/phone/terminal_header.dart+++ b/mobile/lib/phone/terminal_header.dart@@ -28,10 +28,22 @@ class TerminalHeader extends StatelessWidget {super.key,required this.onSearch,this.trailing = const [],+ this.barHidden = false,});final VoidCallback onSearch;+ /// Whether the search overlay is drawing the bar instead of this row.+ ///+ /// ⚠️ **The bar still takes its space — it is only not PAINTED.** The overlay+ /// draws an identical field at these very pixels, and two of them stacked put+ /// one translucent rim over another: the border comes out darker than either+ /// alone, and the fill deepens, for the whole of the open. Keeping the layout+ /// and dropping the paint leaves this row doing what it still has to do —+ /// holding the trailing controls in place while they fade — without a second+ /// field showing through the first.+ final bool barHidden;+/// The page's controls, right of the bar: `+`, `⋯`, and the reclaim button/// when the stream is read-only.final List<Widget> trailing;@@ -51,6 +63,14 @@ class TerminalHeader extends StatelessWidget {/// The hint's type.static const double hintSize = 14;+ /// 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`.+ static const double barGap = 6;+/// What the bar says it will search.////// ⚠️ Names both kinds on purpose. The query spans agents AND machines, and@@ -71,8 +91,22 @@ class TerminalHeader extends StatelessWidget {),child: Row(children: [- Expanded(child: _SearchBar(onTap: onSearch)),- const SizedBox(width: 6),+ Expanded(+ child: Visibility(+ visible: !barHidden,+ // Keeps the box, drops the paint and the hit test. See [barHidden].+ maintainSize: true,+ maintainAnimation: true,+ maintainState: true,+ child: _SearchBar(onTap: onSearch),+ ),+ ),+ // ⚠️ **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....trailing,],),diff --git a/mobile/lib/phone/terminal_page.dart b/mobile/lib/phone/terminal_page.dartindex ba4aee443..2e434697e 100644--- a/mobile/lib/phone/terminal_page.dart+++ b/mobile/lib/phone/terminal_page.dart@@ -191,18 +191,27 @@ class _TerminalPageState extends State<TerminalPage>/// value — two controllers, or an implicit animation on either side, would let/// the two drift apart on a dropped frame and show the terminal through the/// gap.+ /// ⚠️ Unhurried on purpose. Nothing here moves any more — the header swaps+ /// one control for another and the results fade up — and a cross-fade run+ /// fast enough for a slide reads as a flicker rather than as an exchange. The+ /// way back is a little quicker than the way in, the way dismissals usually+ /// are.late final AnimationController _searchOpen = AnimationController(vsync: this,- duration: const Duration(milliseconds: 260),- reverseDuration: const Duration(milliseconds: 220),+ duration: const Duration(milliseconds: 420),+ reverseDuration: const Duration(milliseconds: 340),);- /// The curve everything on the open/close reads. Eased out on the way in so- /// the bar arrives rather than snaps, and symmetric on the way back.+ /// The curve everything on the open/close reads.+ ///+ /// ⚠️ Eased at BOTH ends, where this was once eased out alone. An ease-out+ /// starts at its quickest, which suits something travelling into place —+ /// nothing here travels. What is left is opacity, and opacity leaving its+ /// resting value at full speed is seen as a blink at the start of the fade.late final Animation<double> _searchCurve = CurvedAnimation(parent: _searchOpen,- curve: Curves.easeOutCubic,- reverseCurve: Curves.easeInCubic,+ curve: Curves.easeInOutCubic,+ reverseCurve: Curves.easeInOutCubic,);/// Whether the search overlay is BUILT — true from the first frame of the@@ -640,6 +649,26 @@ 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].+ //+ // ⚠️ [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+ // 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.+ final headerActions =+ (machine != null &&+ phoneMachineStatusOf(machine) == PhoneMachineStatus.ready+ ? 1+ : 0) ++ (agent != null ? 1 : 0) ++ (reclaim != null ? 1 : 0);+ final trailingExtent = _TrailingSwap.extentFor(context, headerActions);return Scaffold(backgroundColor: AppPalette.windowBg,// ⚠️ No fab. New agent is the `+` in the header — see the note there.@@ -865,85 +894,109 @@ class _TerminalPageState extends State<TerminalPage>// the frame while an identical one came in from off-screen.// See `terminal_search.dart`.onSearch: _openSearch,+ // ⚠️ Tracks [_searching], NOT the animation's value:+ // the overlay's own bar exists for exactly as long as+ // the overlay is mounted, including the closing frames+ // where the animation is already near zero. Reading the+ // value here would paint this row's field back under+ // the overlay's for the tail of every collapse.+ barHidden: _searching,// ⚠️ No title and no engine mark up here any more: the search// bar takes the row, and the agent's name moved to// [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+ // 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.trailing: [- // Read-only is a state to get OUT of, so its way out is a- // labelled button in the header rather than a line in the- // actions sheet: the sheet is where you go having decided- // to do something, and this is the thing telling you that- // typing will go nowhere until you do.- if (reclaim != null)- _ReclaimButton(- action: reclaim,- onPressed: () => widget.notifier.selectAgent(- widget.machineId,- widget.agentId,- ),- ),- // New agent, search and the actions menu: the three the- // page offers, in the order they are reached for — create,- // find, then everything else.- //- // ⚠️ They are spaced by [_HeaderAction], not drawn bare.- // [AppIconButton] is a fixed 24px box whatever glyph size- // it is given, so a 22px search glyph fills its box edge to- // edge while a 20px ellipsis sits inside one — three- // buttons butted together then read as unevenly spaced- // when the gaps are in fact identical. One glyph size and- // one padding across the three is what evens the rhythm.- //- // ⚠️ `+` here rather than floating over the terminal. A fab- // covers the last line of output — the line being read —- // and this page has no list to scroll it clear of.- //- // Gated on the machine ANSWERING, the same gate the Agents- // tab puts on its fab: creating needs the machine to list- // its folders and name its engines, so one that is offline- // or still wants its password cannot host a new agent.- if (machine != null &&- phoneMachineStatusOf(machine) ==- PhoneMachineStatus.ready)- _HeaderAction(- icon: LucideIcons.plus300,- size: 21,- tooltip: 'New agent',- // Awaited for the same reason search is: the form may- // be backed out of rather than completed, and this page- // gets no rebuild when it lands back on top.- onPressed: () async {- await openNewAgent(- context,- widget.notifier,- widget.machineId,- );- if (mounted) setState(() {});- },- ),- // ⚠️ Both stay put while the keyboard is up. They were once- // hidden while typing to spare the row — but the row was- // never what was short, and the controls jumping position- // on every keyboard raise cost more than the two columns- // bought back. A header that holds still is worth more.- //- // Null while the agent is not loaded: there is nothing to act on yet, and a- // menu of actions that all fail is worse than no menu.- if (agent != null)- _HeaderAction(- icon: LucideIcons.ellipsis300,- size: 21,- tooltip: 'Agent actions',- // Last in the row, so its padding stops at the header's- // own right inset rather than adding to it.- last: true,- onPressed: () => _showActions(- machineName:- machine?.machine.displayName ?? '',- agentName: agent.name,- ),+ _TrailingSwap(+ progress: _searchCurve,+ cancel: _CancelSearchButton(+ onTap: _closeSearch,),+ extent: trailingExtent,+ children: [+ // Read-only is a state to get OUT of, so its way out is a+ // labelled button in the header rather than a line in the+ // actions sheet: the sheet is where you go having decided+ // to do something, and this is the thing telling you that+ // typing will go nowhere until you do.+ if (reclaim != null)+ _ReclaimButton(+ action: reclaim,+ onPressed: () =>+ widget.notifier.selectAgent(+ widget.machineId,+ widget.agentId,+ ),+ ),+ // New agent, search and the actions menu: the three the+ // page offers, in the order they are reached for — create,+ // find, then everything else.+ //+ // ⚠️ They are spaced by [_HeaderAction], not drawn bare.+ // [AppIconButton] is a fixed 24px box whatever glyph size+ // it is given, so a 22px search glyph fills its box edge to+ // edge while a 20px ellipsis sits inside one — three+ // buttons butted together then read as unevenly spaced+ // when the gaps are in fact identical. One glyph size and+ // one padding across the three is what evens the rhythm.+ //+ // ⚠️ `+` here rather than floating over the terminal. A fab+ // covers the last line of output — the line being read —+ // and this page has no list to scroll it clear of.+ //+ // Gated on the machine ANSWERING, the same gate the Agents+ // tab puts on its fab: creating needs the machine to list+ // its folders and name its engines, so one that is offline+ // or still wants its password cannot host a new agent.+ if (machine != null &&+ phoneMachineStatusOf(machine) ==+ PhoneMachineStatus.ready)+ _HeaderAction(+ icon: LucideIcons.plus300,+ size: 21,+ tooltip: 'New agent',+ // Awaited for the same reason search is: the form may+ // be backed out of rather than completed, and this page+ // gets no rebuild when it lands back on top.+ onPressed: () async {+ await openNewAgent(+ context,+ widget.notifier,+ widget.machineId,+ );+ if (mounted) setState(() {});+ },+ ),+ // ⚠️ Both stay put while the keyboard is up. They were once+ // hidden while typing to spare the row — but the row was+ // never what was short, and the controls jumping position+ // on every keyboard raise cost more than the two columns+ // bought back. A header that holds still is worth more.+ //+ // Null while the agent is not loaded: there is nothing to act on yet, and a+ // menu of actions that all fail is worse than no menu.+ if (agent != null)+ _HeaderAction(+ icon: LucideIcons.ellipsis300,+ size: 21,+ tooltip: 'Agent actions',+ // Last in the row, so its padding stops at the header's+ // own right inset rather than adding to it.+ last: true,+ onPressed: () => _showActions(+ machineName:+ machine?.machine.displayName ?? '',+ agentName: agent.name,+ ),+ ),+ ],+ ),],),Divider(height: 1, color: AppGlass.hair),@@ -993,6 +1046,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.+ trailingExtent: trailingExtent,),),],@@ -1269,6 +1326,192 @@ 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.+///+/// ⚠️ **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.+///+/// 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({+ required this.progress,+ required this.children,+ required this.cancel,+ required this.extent,+ });++ /// 0 the page's own controls are showing, 1 Cancel is.+ 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.+ 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+ // stops on the header's own inset.+ const box = 24.0;+ 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);+ }++ @override+ Widget 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),+ ),+ ],+ ),+ );+ },+ );+}+/// One of the header's trailing controls, padded so the three sit evenly.////// ⚠️ The padding is what makes the row look right, and the reason is thatdiff --git a/mobile/lib/phone/terminal_search.dart b/mobile/lib/phone/terminal_search.dartindex caf5aba45..28a5dc7f4 100644--- a/mobile/lib/phone/terminal_search.dart+++ b/mobile/lib/phone/terminal_search.dart@@ -13,13 +13,19 @@ import 'terminal_header.dart';/// ⚠️ **Not a route, and that is the point of the whole file.** The bar sits in/// the terminal's header, and pushing [PhoneSearchPage] slid a fresh screen in/// from the right — the bar the finger had just touched went out of the frame-/// while an identical one arrived from off-screen. Growing out of the bar keeps-/// the thing that was tapped on screen and expands it, which is what the gesture-/// says will happen.+/// while an identical one arrived from off-screen. Opening in place leaves the+/// thing that was tapped exactly where it was.///-/// The way out is Cancel beside the bar, which collapses it the way it came. The-/// system back gesture reaches it too — see [TerminalSearchOverlay]'s-/// [PopScope].+/// ⚠️ **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.+///+/// The way out is that Cancel. The system back gesture reaches 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@@ -30,10 +36,15 @@ class TerminalSearchOverlay extends StatefulWidget {required this.notifier,required this.animation,required this.onClose,+ required this.trailingExtent,});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].+ final double trailingExtent;+/// The open/close animation the terminal page drives — 0 collapsed into the/// header bar, 1 filling the screen.///@@ -80,39 +91,45 @@ class _TerminalSearchOverlayState extends State<TerminalSearchOverlay> {onPopInvokedWithResult: (didPop, _) {if (!didPop) _close();},+ // ⚠️ No [ListenableBuilder] around this any more. [PhoneSearchResults]+ // watches the notifier itself — and its recall store with it — so a+ // second listener here would rebuild the field on every agent-list tick+ // for nothing.child: Column(children: [- // ⚠️ **The bar is NOT faded in over the header's own.** The two- // are the same shape in the same place, so cross-fading them- // looked like nothing happening at all — which is exactly what- // this screen was reported as doing. It is opaque from frame one- // and animates its WIDTH instead: Cancel opens out of the right- // edge while `+` and `⋯` collapse behind it, and the field takes- // the space. That is the move the tap promises.+ // ⚠️ **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`.+ //+ // ⚠️ 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._Bar(controller: _controller,focus: _focus,- animation: widget.animation,onChanged: (value) => setState(() => _query = value),- onCancel: _close,+ trailingExtent: widget.trailingExtent,),- // ⚠️ Fades AND rises, on the second half of the animation alone.- // Rows arriving while the bar is still opening read as two things- // at once; waiting until the bar is nearly home makes it one move- // — the bar opens, the list comes up into it.+ // ⚠️ Fades on the back half of the animation alone. The header's+ // controls are still trading places over the front half, and rows+ // arriving under them is two things happening at once.Expanded(- child: _Rise(+ child: _FadeIn(animation: widget.animation,child: ColoredBox(color: AppPalette.windowBg,+ // ⚠️ Handed the query and nothing else. Ranking lives inside+ // it now, so this screen and [PhoneSearchPage] cannot drift+ // into returning different rows for the same words.child: PhoneSearchResults(notifier: widget.notifier,query: _query,- // ⚠️ Nothing pops this search — opening an agent swaps- // the terminal underneath it instead — so tapping a row- // has to close it by hand. Without this the keyboard- // would still be up over an agent nobody asked to type- // into.+ // ⚠️ Nothing pops this search — opening an agent swaps the+ // terminal underneath it instead — so tapping a row has to+ // close it by hand. Without this the keyboard would still be+ // up over an agent nobody asked to type into.onOpen: _close,),),@@ -124,150 +141,190 @@ class _TerminalSearchOverlayState extends State<TerminalSearchOverlay> {}}-/// The field and the way out, on the row the collapsed bar came from.+/// 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+/// height, same corner radius, same outer padding, same right edge — or the bar+/// jumps on the frame the overlay takes over.///-/// ⚠️ **Exactly [TerminalHeader]'s geometry, and that is what sells the-/// expansion.** The two rows are drawn by different widgets but must land on the-/// same pixels: same height, same corner radius, same outer padding. Anything-/// off by a point makes the bar jump on the frame 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`.class _Bar extends StatelessWidget {const _Bar({required this.controller,required this.focus,- required this.animation,required this.onChanged,- required this.onCancel,+ required this.trailingExtent,});final TextEditingController controller;final FocusNode focus;- /// 0 collapsed into the header's bar, 1 open. Drives Cancel's width, which is- /// what makes the field grow: the two share the row.- final Animation<double> animation;-final ValueChanged<String> onChanged;- final VoidCallback onCancel;++ /// 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.+ ///+ /// ⚠️ 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.+ final double trailingExtent;@overrideWidget build(BuildContext context) {AppTheme.watch(context);- return ColoredBox(- color: AppPalette.windowBg,- child: Padding(- padding: const EdgeInsets.fromLTRB(- TerminalHeader.sideInset,- TerminalHeader.topInset,- TerminalHeader.sideInset,- TerminalHeader.bottomInset,- ),- 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 once, by the rim of the box the field fills.- border: Border.all(- color: focus.hasFocus- ? AppPalette.accentOnSurface- : AppGlass.hair,- ),+ // ⚠️ **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,+ ),+ 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: child,),child: Row(children: [- Icon(- LucideIcons.search300,- size: TerminalHeader.glyphSize,- color: AppPalette.textFaint,- ),- const SizedBox(width: 8),- Expanded(- child: _Input(- controller: controller,- focus: focus,- onChanged: onChanged,+ // ⚠️ **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,),),- _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();- },- ),+ 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();+ },+ ),+ ],+ ),),- // ⚠️ **Opens from zero width, and that IS the animation.** `+` and- // `⋯` are gone while searching — they act on the agent underneath,- // which is not what is on screen — so Cancel takes their column, and- // the field widens into whatever Cancel has not claimed yet. Fading- // one bar over another identical one showed nothing; a row whose- // proportions move shows the tap landing.- //- // ⚠️ Rebuilt on every tick by this builder. The button reads- // `animation.value` directly, and a stateless widget given an- // Animation does not listen to it — the row would have snapped to its- // open width on the first frame and shown nothing moving.- AnimatedBuilder(- animation: animation,- builder: (context, _) =>- _CancelButton(animation: animation, onTap: onCancel),- ),- ],- ),+ ),+ // ⚠️ **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.+ ],),);}}-/// The results, rising into place as the bar finishes opening.+/// The results, fading in under the bar.+///+/// ⚠️ **A fade alone, and it was once a rise too.** It used to+/// translate 18pt as it faded, which belonged to a screen whose bar was also+/// growing: one move explaining another. Now that the bar holds still, a list+/// sliding under it was the only thing on screen that moved, and it read as the+/// results being nudged rather than as the terminal being replaced.///-/// A translation rather than a slide transition: [SlideTransition] moves by a-/// fraction of the child's own size, and this child is most of the screen — a-/// tenth of it is half a phone. A fixed number of points is what reads as the-/// list settling.-class _Rise extends StatelessWidget {- const _Rise({required this.animation, required this.child});+/// ⚠️ On the back half of the animation only. The header's controls are still+/// trading places over the first half, and rows arriving under them makes two+/// things happen at once; waiting lets the eye finish one before the next.+class _FadeIn extends StatelessWidget {+ const _FadeIn({required this.animation, required this.child});final Animation<double> animation;final Widget child;- /// How far below its place the list starts. Far enough to be a move, near- /// enough that nothing is ever seen sliding past the bar.- static const double _drop = 18;-@overrideWidget build(BuildContext context) {final curve = CurvedAnimation(parent: animation,- curve: const Interval(0.35, 1, curve: Curves.easeOutCubic),+ curve: const Interval(0.35, 1, curve: Curves.easeInOut),);return AnimatedBuilder(animation: curve,- builder: (context, child) => Opacity(- opacity: curve.value,- child: Transform.translate(- offset: Offset(0, _drop * (1 - curve.value)),- child: child,- ),- ),+ builder: (context, child) => Opacity(opacity: curve.value, child: child),child: child,);}@@ -375,10 +432,15 @@ 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.///-/// ⚠️ **It opens by WIDTH, from nothing, and the field's growth is the other-/// side of that.** The two share the row, so every point Cancel takes is a point-/// the field gives up — which is what makes the bar look like it is expanding-/// out of the header rather than being replaced by a copy of itself.+/// ⚠️ **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_elementclass _CancelButton extends StatelessWidget {const _CancelButton({required this.animation, required this.onTap});