Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

feat(mobile): fold the terminal header away as the output is scrolled

tony0f1c6f3014ce
diff --git a/mobile/lib/phone/terminal_chrome_scroll.dart b/mobile/lib/phone/terminal_chrome_scroll.dart
new file mode 100644
index 000000000..fafad727f
--- /dev/null
+++ b/mobile/lib/phone/terminal_chrome_scroll.dart
@@ -0,0 +1,220 @@
+import 'package:flutter/widgets.dart';
+
+/// How far the terminal's header has travelled off the top, driven by scrolling.
+///
+/// Scrolling forward sends it up and out at the first push; it comes back only
+/// after a real journey in the other direction.
+///
+/// ⚠️ **Leaving is about intent; coming back is about distance.** Any scroll
+/// forward hides the row — somebody reading ahead wants the screen, and wants it
+/// now. But a flick upward in the middle of a long scrollback is still the
+/// middle of a long scrollback, so the return is paid for in travel: see
+/// [_returnTravel].
+///
+/// ⚠️ **It cannot be done by position, and that was measured rather than
+/// assumed.** The obvious rule is "show the header when the content is back at
+/// offset zero", and it was written that way first. While an agent runs a
+/// full-screen program the terminal is on its ALTERNATE buffer, where scrolling
+/// moves no viewport at all — the gesture becomes arrow keys for the program,
+/// through a `Scrollable` whose extents are both infinite. Device logs showed
+/// every notification the page gets carrying `min=-Infinity max=Infinity`, so
+/// there is no zero to be near. Distance is what survives both buffers.
+///
+/// ⚠️ **What replaces it is not nothing.** The row's controls fly out of it as
+/// it goes and come to rest as floating buttons down the right edge — see
+/// `terminal_header_floats.dart`. They ride the same value, so there is no
+/// moment where the header has gone and its controls have not arrived. A header
+/// that simply went would have left the page with no way to search or to reach
+/// the actions until somebody scrolled back for it.
+///
+/// ⚠️ **The foot row is not driven from here and must not be.** An earlier
+/// version hid it on any scroll at all. It costs the terminal one short line and
+/// carries what the mic needs somebody to read, which is wanted most while
+/// things are moving.
+///
+/// ⚠️ **A value, not a boolean, and it animates.** The page reads it as 0 (fully
+/// down) to 1 (fully gone) so the row can slide rather than blink.
+///
+/// ⚠️ **Not a [ChangeNotifier], and it must not become one.** [header] is an
+/// [Animation] the row listens to on its own, so a scroll repaints a header and
+/// nothing else. Notifying the page on every tick would rebuild the whole
+/// terminal sixty times a second while somebody drags it.
+///
+/// The page is told exactly twice per move, through [onMovingChanged]: once when
+/// the row starts changing size, once when it is still again. That is what the
+/// terminal's resize gate hangs on — see [moving].
+class TerminalChromeScroll {
+ TerminalChromeScroll({required TickerProvider vsync, this.onMovingChanged})
+ : _header = AnimationController(
+ vsync: vsync,
+ // ⚠️ **This one value paces the whole hand-over, which is why it is
+ // longer than a plain hide would want.** The row shrinking is only half
+ // of it: the three floating buttons fly out of the header on this same
+ // clock, and each is staggered up to 0.2 behind the first — so the last
+ // one gets barely two thirds of whatever is set here. At 200 the
+ // sequence read as a snap rather than as a move.
+ duration: const Duration(milliseconds: 340),
+ ) {
+ _header.addStatusListener(_onStatus);
+ }
+
+ /// What everything reads, rather than the controller underneath it.
+ ///
+ /// ⚠️ The raw controller is LINEAR, and a header that leaves at a constant
+ /// speed reads as being dragged off by a machine. Easing out on the way there
+ /// and in on the way back is what makes it look like it was let go of.
+ late final CurvedAnimation _curved = CurvedAnimation(
+ parent: _header,
+ curve: Curves.easeOutCubic,
+ reverseCurve: Curves.easeInCubic,
+ );
+
+ final AnimationController _header;
+
+ /// Called when [moving] flips, and only then.
+ final ValueChanged<bool>? onMovingChanged;
+
+ /// How far the content must move before the header is asked to do anything.
+ ///
+ /// ⚠️ **Not zero, and this is what keeps the header still.** A terminal that
+ /// is streaming scrolls itself by a line at a time, and the finger resting on
+ /// the glass reports sub-pixel wobble — either would have the row leaving on
+ /// every frame of a scroll that is going nowhere.
+ static const double _threshold = 6;
+
+ /// How far back somebody must scroll, without turning round, before the header
+ /// comes home.
+ ///
+ /// ⚠️ **Much larger than [_threshold], and deliberately asymmetric.** Leaving
+ /// is about intent — one push forward means "give me the screen" — where
+ /// coming back is about having actually travelled: more than a phone screen's
+ /// worth of content, so a stray flick upward while reading does not drag the
+ /// row back over the output underneath it.
+ static const double _returnTravel = 300;
+
+ /// Movement in one direction since the last time the header changed its mind,
+ /// in logical pixels. Reset on every reversal, so the threshold is measured
+ /// per-direction rather than as a running total.
+ double _travel = 0;
+
+ /// Whether the scroll now running was begun by a finger. See [onNotification].
+ bool _dragging = false;
+
+ bool _moving = false;
+
+ /// 0 fully down, 1 fully off the top.
+ Animation<double> get header => _curved;
+
+ /// Whether the header is part-way in or out right now.
+ ///
+ /// ⚠️ **What keeps a scroll from resizing the remote shell dozens of times.**
+ /// The row gives its height back as it goes, so the terminal beside it grows
+ /// frame by frame — xterm re-derives its grid from each new height and fires
+ /// `onResize`, which is a `terminal_resize` frame and a real SIGWINCH per
+ /// frame. `TerminalPanel.settling` gates exactly that loop, so the shell is
+ /// asked once, for the height the header settles at.
+ bool get moving => _moving;
+
+ void _onStatus(AnimationStatus _) {
+ final moving = _header.isAnimating;
+ if (moving == _moving) return;
+ _moving = moving;
+ onMovingChanged?.call(moving);
+ }
+
+ /// Puts the header back on screen, at once and without animating.
+ ///
+ /// For the cases where it must simply BE open and no gesture is going to open
+ /// it: search growing out of its bar, the keyboard coming up, a swipe landing
+ /// on a different agent.
+ void reveal() {
+ _travel = 0;
+ // A gesture still in flight must not carry on driving the header it was just
+ // told to show — a fling running under an opening search would send it back
+ // off the top behind the overlay.
+ _dragging = false;
+ _header.value = 0;
+ // A jump, not an animation, so no status listener fires — and a move left
+ // running by whatever was interrupted would never be cleared.
+ _onStatus(AnimationStatus.dismissed);
+ }
+
+ /// Feeds one scroll notification in. Returns false so the notification carries
+ /// on to anything else listening.
+ ///
+ /// ⚠️ **Only what a FINGER started gets through, and without that filter the
+ /// header leaves by itself.** A terminal following its own output scrolls on
+ /// every line the agent prints, and those arrive as ordinary updates: the
+ /// header would fold away while somebody sat still and read, and come back the
+ /// moment the agent went quiet.
+ ///
+ /// ⚠️ **The gate is on the START of the gesture, not on each update.** A
+ /// thrown scroll keeps moving after the thumb is gone — `dragDetails` is null
+ /// for every one of those frames, so testing each update would have dropped
+ /// the whole fling, which is most of the distance somebody actually travels.
+ /// [_dragging] carries the answer from the start notification through to the
+ /// end of the ballistic run that follows it.
+ bool onNotification(ScrollNotification notification) {
+ if (notification is ScrollStartNotification) {
+ _dragging = notification.dragDetails != null;
+ } else if (notification is ScrollUpdateNotification) {
+ if (_dragging) _onScrolled(notification.scrollDelta ?? 0);
+ } else if (notification is ScrollEndNotification) {
+ _dragging = false;
+ }
+ return false;
+ }
+
+ /// One scroll tick, in logical pixels. Positive is towards the newest output.
+ ///
+ /// ⚠️ **Distance travelled, not position, and the terminal leaves no choice.**
+ /// While an agent is running a full-screen program the terminal is on its
+ /// ALTERNATE buffer, and there scrolling does not move a viewport at all — the
+ /// gesture is translated into arrow keys and handed to the program, through a
+ /// `Scrollable` that reports `minScrollExtent: -infinity` and
+ /// `maxScrollExtent: +infinity`. There is no offset zero to be near. This was
+ /// established from the device rather than the source: every notification the
+ /// page receives carries those infinities.
+ ///
+ /// So "back at the start" is measured as the only thing that survives both
+ /// buffers — how far somebody has scrolled BACK, continuously, without
+ /// turning round.
+ void _onScrolled(double delta) {
+ if (delta == 0) return;
+ // ⚠️ A reversal resets the count rather than subtracting from it. Otherwise
+ // a long scroll one way banks up travel that a short scroll back has to pay
+ // off before anything moves, and the row ignores the first flick back.
+ if (delta.isNegative != _travel.isNegative) _travel = 0;
+ _travel += delta;
+
+ // Going forward: away at the first deliberate push, because somebody
+ // reading ahead wants the screen and wants it now.
+ if (_travel >= _threshold) {
+ _travel = 0;
+ _header.forward();
+ return;
+ }
+
+ // Coming back: only after a real journey. ⚠️ [_returnTravel], not
+ // [_threshold] — a flick upward in the middle of a long scrollback is still
+ // the middle of it, and a header that came back there sat over output
+ // nobody had scrolled to the top of.
+ //
+ // Several quick flicks up count the same as one long drag: the tally only
+ // resets when the direction turns round or when it has paid out, so the
+ // distance accumulates across the lifts that a real journey is made of.
+ if (-_travel >= _returnTravel) {
+ _travel = 0;
+ _header.reverse();
+ }
+ }
+
+ void dispose() {
+ _header.removeStatusListener(_onStatus);
+ // ⚠️ Before the controller it wraps: a CurvedAnimation holds a listener on
+ // its parent, and disposing the parent first leaves that registration
+ // pointing at a controller that has gone.
+ _curved.dispose();
+ _header.dispose();
+ }
+}
diff --git a/mobile/lib/phone/terminal_foot_bar.dart b/mobile/lib/phone/terminal_foot_bar.dart
index 75b171aa9..2b89ee2f5 100644
--- a/mobile/lib/phone/terminal_foot_bar.dart
+++ b/mobile/lib/phone/terminal_foot_bar.dart
@@ -54,54 +54,69 @@ class TerminalFootBar extends StatelessWidget {
/// ⚠️ Short on purpose, and the whole reason the mic left. Every point here
/// is a point taken off the terminal above, which is then resized.
///
- /// ⚠️ **20 is what one line of 10.5pt text fits in, and nothing more.** The
- /// type, the engine mark and the status dot were all cut to match when this
- /// came down from 26 — a child that kept its old size would overflow rather
- /// than shrink the row, because the height is fixed above everything in it.
- static const double height = 20;
+ /// ⚠️ **18 is what one line of 10.5pt text fits in, and nothing more.** The
+ /// type, the engine mark and the status dot were all cut to match — a child
+ /// that kept its old size would overflow rather than shrink the row, because
+ /// the height is fixed above everything in it.
+ ///
+ /// The sums, for whoever comes to change one of these: the system face lays
+ /// 10.5pt out in a line box of about 12.5, the engine mark is the tallest
+ /// thing in the row at 11, and that leaves roughly 3pt of air above and below.
+ /// It is tight on purpose — this row's top edge is the terminal's bottom edge
+ /// — but it is tight enough that the text scale below is no longer optional.
+ static const double height = 18;
@override
Widget build(BuildContext context) {
AppTheme.watch(context);
return SizedBox(
height: height,
- child: Padding(
- // The mic floats over the terminal ABOVE this row rather than over the
- // row itself, so the right inset is only the screen's own margin — but
- // it stays generous, because the mic's hit area reaches down to within
- // a few points of this line and text running right up to it would look
- // like part of the button.
- padding: const EdgeInsets.only(left: 16, right: 16),
- child: ListenableBuilder(
- listenable: voice,
- builder: (context, _) => Row(
- children: [
- Expanded(
- child: AnimatedSwitcher(
- duration: const Duration(milliseconds: 180),
- layoutBuilder: _alignStart,
- child:
- _voiceLine(voice, slippedOff) ??
- _IdentityLine(
- key: const ValueKey('identity'),
- name: name,
- status: status,
- agent: agent,
- ),
+ // ⚠️ **Text scaling is pinned here, and this row is one of the few places
+ // in the app where that is right.** Its height is fixed — the terminal's
+ // bottom edge sits on it — so type that grew with the system setting would
+ // overflow rather than reflow, and there is no second line for it to take.
+ // The words here are chrome that names the agent; the terminal above,
+ // which is what somebody is actually reading, honours the setting as it
+ // always did.
+ child: MediaQuery.withNoTextScaling(
+ child: Padding(
+ // The mic floats over the terminal ABOVE this row rather than over the
+ // row itself, so the right inset is only the screen's own margin — but
+ // it stays generous, because the mic's hit area reaches down to within
+ // a few points of this line and text running right up to it would look
+ // like part of the button.
+ padding: const EdgeInsets.only(left: 16, right: 16),
+ child: ListenableBuilder(
+ listenable: voice,
+ builder: (context, _) => Row(
+ children: [
+ Expanded(
+ child: AnimatedSwitcher(
+ duration: const Duration(milliseconds: 180),
+ layoutBuilder: _alignStart,
+ child:
+ _voiceLine(voice, slippedOff) ??
+ _IdentityLine(
+ key: const ValueKey('identity'),
+ name: name,
+ status: status,
+ agent: agent,
+ ),
+ ),
),
- ),
- // ⚠️ **At the END OF THE LINE it dismisses, not over the mic.**
- // Stacked above the floating button it sat in the middle of the
- // terminal with nothing beside it — a lone glyph over streaming
- // output, which reads as a rendering fault rather than as a
- // control. Here it is plainly the way to get rid of the words to
- // its left.
- //
- // The mic cannot be shifted by it either, which is what put it
- // over there in the first place: the mic floats and this is in
- // the layout, so they no longer share a row.
- if (_showsDismiss(voice)) _DismissButton(onTap: voice.clear),
- ],
+ // ⚠️ **At the END OF THE LINE it dismisses, not over the mic.**
+ // Stacked above the floating button it sat in the middle of the
+ // terminal with nothing beside it — a lone glyph over streaming
+ // output, which reads as a rendering fault rather than as a
+ // control. Here it is plainly the way to get rid of the words to
+ // its left.
+ //
+ // The mic cannot be shifted by it either, which is what put it
+ // over there in the first place: the mic floats and this is in
+ // the layout, so they no longer share a row.
+ if (_showsDismiss(voice)) _DismissButton(onTap: voice.clear),
+ ],
+ ),
),
),
),
@@ -183,9 +198,17 @@ class _DismissButton extends StatelessWidget {
final VoidCallback onTap;
- /// What the finger may land on, against the 20pt the row gives it.
+ /// What the finger may land on, against the 18pt the row gives it.
static const double _touch = 40;
+ /// How wide the glyph's own slot is.
+ ///
+ /// ⚠️ **Wider than the row is tall, on purpose.** The row's height came down
+ /// to 18 for the type, but the `×` is round and 18pt of width crowds it hard
+ /// against the words to its left. Width costs the terminal nothing — only the
+ /// height is shared with it.
+ static const double _slot = 24;
+
@override
Widget build(BuildContext context) {
AppTheme.watch(context);
@@ -193,7 +216,7 @@ class _DismissButton extends StatelessWidget {
button: true,
label: 'Cancel',
child: SizedBox(
- width: TerminalFootBar.height,
+ width: _slot,
height: TerminalFootBar.height,
child: OverflowBox(
maxWidth: _touch,
@@ -207,10 +230,17 @@ class _DismissButton extends StatelessWidget {
onTap: onTap,
child: SizedBox.square(
dimension: _touch,
- child: Center(
+ // ⚠️ **Aligned to the ROW's middle, not the target's.** The hit
+ // box is 40pt pinned to an 18pt row's top edge, so its own centre
+ // sits 11pt BELOW the line of text — a `Center` here drew the
+ // glyph hanging off the bottom of the bar, clear of the words it
+ // belongs to. The fraction puts it back on the text's centreline
+ // while the target it lives in still reaches down past the row.
+ child: Align(
+ alignment: Alignment(0, -1 + (TerminalFootBar.height / _touch)),
child: Icon(
LucideIcons.x300,
- size: 13,
+ size: 12,
color: AppPalette.textSecondary,
),
),
@@ -249,12 +279,13 @@ class _IdentityLine extends StatelessWidget {
return Row(
children: [
if (agent != null) ...[
- // Small enough to read as a mark beside the name rather than as an
- // avatar — this row is 20pt tall and the mark may not crowd it.
+ // ⚠️ The TALLEST thing in the row, so it is what sets the floor under
+ // [TerminalFootBar.height] — not the text. Small enough to read as a
+ // mark beside the name rather than as an avatar.
EngineMark(
engine: agent.engine,
displayName: agent.engineDisplayName,
- size: 12,
+ size: 11,
),
const SizedBox(width: 5),
Flexible(
@@ -302,7 +333,9 @@ class _IdentityLine extends StatelessWidget {
padding: const EdgeInsets.symmetric(horizontal: 4),
child: Text(
'·',
- style: TextStyle(color: AppPalette.textFaint, fontSize: 12),
+ // Down with everything else in the row: left at 12 it was the tallest
+ // piece of type here and set the line box on its own.
+ style: TextStyle(color: AppPalette.textFaint, fontSize: 10.5),
),
);
}
diff --git a/mobile/lib/phone/terminal_header.dart b/mobile/lib/phone/terminal_header.dart
index f91ef21da..930a5a27e 100644
--- a/mobile/lib/phone/terminal_header.dart
+++ b/mobile/lib/phone/terminal_header.dart
@@ -17,6 +17,12 @@ import 'package:harness_mobile/shared/theme/app_theme.dart';
/// `terminal_search.dart`, which draws the same bar at the same geometry so the
/// two frames line up. That is what the measurements below are public for: the
/// expanded bar has to land on the pixels the collapsed one left.
+///
+/// ⚠️ **It leaves on a scroll, and its controls carry on without it.** The page
+/// shrinks this row away as the terminal is scrolled forward, and the search
+/// bar, `+` and `⋯` fly out of it to become floating buttons down the right
+/// edge — see `terminal_header_floats.dart`. Nothing here knows about that; the
+/// row is either laid out or it is not.
class TerminalHeader extends StatelessWidget {
const TerminalHeader({
super.key,
@@ -42,6 +48,9 @@ class TerminalHeader extends StatelessWidget {
static const double barPadding = 10;
static const double glyphSize = 16;
+ /// The hint's type.
+ static const double hintSize = 14;
+
/// What the bar says it will search.
///
/// ⚠️ Names both kinds on purpose. The query spans agents AND machines, and
@@ -117,7 +126,7 @@ class _SearchBar extends StatelessWidget {
softWrap: false,
style: TextStyle(
color: AppPalette.textFaint,
- fontSize: 14,
+ fontSize: TerminalHeader.hintSize,
fontWeight: FontWeight.w500,
),
),
diff --git a/mobile/lib/phone/terminal_header_floats.dart b/mobile/lib/phone/terminal_header_floats.dart
new file mode 100644
index 000000000..ada75f368
--- /dev/null
+++ b/mobile/lib/phone/terminal_header_floats.dart
@@ -0,0 +1,227 @@
+import 'dart:ui' show lerpDouble;
+
+import 'package:flutter/material.dart';
+
+import 'package:harness_mobile/shared/theme/app_theme.dart';
+
+/// One of the things the header held, as a floating button.
+class TerminalHeaderChoice {
+ const TerminalHeaderChoice({
+ required this.icon,
+ required this.label,
+ required this.onTap,
+ });
+
+ final IconData icon;
+
+ /// For screen readers and the long-press tooltip. The buttons carry no words
+ /// of their own — three marks in a column, in the order they sat in the row
+ /// they came out of, is what makes them readable.
+ final String label;
+
+ final VoidCallback onTap;
+}
+
+/// The header's controls, floating down the right edge once the row itself has
+/// scrolled away.
+///
+/// ⚠️ **Three buttons, not one that opens three.** A single button folding the
+/// lot away was tried first: it put the page's only search and its only actions
+/// menu behind a tap and a fan, which is two gestures to reach what had been
+/// one. These stay in the order they had in the header — search, new, actions —
+/// so the column reads as that row stood on its end.
+///
+/// ⚠️ **Each one flies out of its own place in the header.** The row's search
+/// bar, `+` and `⋯` are at known points across the top of the screen, and each
+/// button travels from its own to its place in this column. A set that simply
+/// faded in would say nothing about where the header went, which was the
+/// complaint that produced this file.
+class TerminalHeaderFloats extends StatelessWidget {
+ const TerminalHeaderFloats({
+ super.key,
+ required this.choices,
+ required this.progress,
+ required this.origins,
+ });
+
+ final List<TerminalHeaderChoice> choices;
+
+ /// 0 the header is in place and these are nowhere, 1 fully arrived.
+ final Animation<double> progress;
+
+ /// Where each button starts, relative to its resting place in the column.
+ ///
+ /// ⚠️ Given by the page, not worked out here. The origins are points in the
+ /// header's own row, and that row's layout is the page's business — this
+ /// widget knows only how to fly something from A to B.
+ final List<Offset> origins;
+
+ /// A button's diameter, and the gap from one to the next.
+ ///
+ /// ⚠️ **Smaller than the mic, and that is the right way round.** The mic is
+ /// the page's one action and is held through a whole sentence; these are
+ /// chrome that scrolling put here, tapped once and rarely. Sizing them to
+ /// match made three circles compete with the output they float over.
+ ///
+ /// ⚠️ 32 is a floor. [touchExtent] is what a finger actually gets — the
+ /// circles are drawn small and hit large, so shrinking them further would cost
+ /// legibility without buying the terminal anything.
+ static const double extent = 32;
+ static const double pitch = 40;
+
+ /// What the finger may land on, against the [extent] that is drawn.
+ ///
+ /// ⚠️ **Capped at [pitch], and it must not exceed it.** The targets are drawn
+ /// small and hit large, but two that overlap would hand the shared band to
+ /// whichever is painted later — the lower button, since the column builds top
+ /// down — so a tap aimed just under Search would open New agent. Matching the
+ /// pitch is what makes the targets meet exactly and leave no dead glass
+ /// between them either.
+ static const double touchExtent = pitch;
+
+ /// How far the column sits from the screen's top and right edges.
+ static const double inset = 10;
+
+ /// What a column of [count] buttons is tall.
+ static double heightFor(int count) =>
+ count == 0 ? 0 : (count - 1) * pitch + extent;
+
+ @override
+ Widget build(BuildContext context) {
+ AppTheme.watch(context);
+ return SizedBox(
+ width: extent,
+ height: heightFor(choices.length),
+ child: Stack(
+ clipBehavior: Clip.none,
+ children: [
+ for (final (index, choice) in choices.indexed)
+ Positioned(
+ top: index * pitch,
+ right: 0,
+ child: _Float(
+ progress: progress,
+ // ⚠️ Staggered from the top down, in the order they left the
+ // header. Arriving together reads as a menu appearing; one after
+ // another reads as the row coming apart.
+ delay: index * 0.1,
+ origin: index < origins.length ? origins[index] : Offset.zero,
+ choice: choice,
+ ),
+ ),
+ ],
+ ),
+ );
+ }
+}
+
+/// One button, travelling from where it sat in the header to where it floats.
+class _Float extends StatelessWidget {
+ const _Float({
+ required this.progress,
+ required this.delay,
+ required this.origin,
+ required this.choice,
+ });
+
+ final Animation<double> progress;
+
+ /// How far into the run this one starts, 0 to 1.
+ final double delay;
+
+ /// Where it comes from, relative to where it ends up.
+ final Offset origin;
+
+ final TerminalHeaderChoice choice;
+
+ @override
+ Widget build(BuildContext context) {
+ AppTheme.watch(context);
+ return AnimatedBuilder(
+ animation: progress,
+ // Built once: what moves is the transform around it.
+ child: _Button(choice: choice),
+ builder: (context, child) {
+ // ⚠️ The stagger comes off the shared VALUE rather than from a timer of
+ // its own. One clock keeps the three in step when a scroll reverses
+ // part-way through; separate controllers would each be somewhere
+ // different when the reverse began, and they would land untidily.
+ final t = ((progress.value - delay) / (1 - delay)).clamp(0.0, 1.0);
+ if (t == 0) return const SizedBox.shrink();
+ return Transform.translate(
+ offset: Offset(origin.dx * (1 - t), origin.dy * (1 - t)),
+ child: Opacity(
+ // ⚠️ Fades in over the FIRST part of the journey only. A button
+ // still translucent as it lands looks like it failed to arrive — and
+ // the header it came from is fading over the same stretch, so two
+ // half-transparent things in one place would read as a smear.
+ opacity: (t / 0.6).clamp(0.0, 1.0),
+ child: Transform.scale(scale: lerpDouble(0.55, 1, t), child: child),
+ ),
+ );
+ },
+ );
+ }
+}
+
+class _Button extends StatelessWidget {
+ const _Button({required this.choice});
+
+ final TerminalHeaderChoice choice;
+
+ @override
+ Widget build(BuildContext context) {
+ AppTheme.watch(context);
+ return Semantics(
+ button: true,
+ label: choice.label,
+ child: Tooltip(
+ message: choice.label,
+ // ⚠️ The target is the OUTER box and the circle is drawn inside it: the
+ // visible button is 32pt, which is under what a thumb wants, and an
+ // [OverflowBox] is what lets the hit area exceed the slot the column
+ // lays out without pushing the circles apart.
+ child: GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: choice.onTap,
+ child: SizedBox.square(
+ dimension: TerminalHeaderFloats.extent,
+ child: OverflowBox(
+ maxWidth: TerminalHeaderFloats.touchExtent,
+ maxHeight: TerminalHeaderFloats.touchExtent,
+ child: SizedBox.square(
+ dimension: TerminalHeaderFloats.touchExtent,
+ child: Center(
+ child: Container(
+ width: TerminalHeaderFloats.extent,
+ height: TerminalHeaderFloats.extent,
+ decoration: BoxDecoration(
+ shape: BoxShape.circle,
+ color: AppGlass.surfaceFill,
+ border: Border.all(color: AppGlass.lift),
+ // ⚠️ A shadow, because these float over streaming output rather
+ // than over a surface. Without one the circle's edge disappears
+ // wherever a bright line runs under it.
+ boxShadow: [
+ BoxShadow(
+ color: Colors.black.withValues(alpha: 0.3),
+ blurRadius: 10,
+ offset: const Offset(0, 2),
+ ),
+ ],
+ ),
+ child: Icon(
+ choice.icon,
+ size: 15,
+ color: AppPalette.textPrimary,
+ ),
+ ),
+ ),
+ ),
+ ),
+ ),
+ ),
+ ),
+ );
+ }
+}
diff --git a/mobile/lib/phone/terminal_page.dart b/mobile/lib/phone/terminal_page.dart
index 077e3f1f2..4d04cb8a3 100644
--- a/mobile/lib/phone/terminal_page.dart
+++ b/mobile/lib/phone/terminal_page.dart
@@ -7,6 +7,7 @@ import 'package:flutter/services.dart';
import 'package:image_picker/image_picker.dart';
import 'package:lucide_icons_flutter/lucide_icons.dart';
+import 'package:harness_mobile/core/models.dart' show Agent;
import 'package:harness_mobile/shared/theme/app_theme.dart';
import 'package:harness_mobile/shared/widgets/app_icon_button.dart';
import 'package:harness_mobile/state/app_state.dart';
@@ -23,8 +24,10 @@ import 'phone_sheet.dart';
import 'phone_status.dart';
import 'settings_page.dart';
import 'status_pill.dart';
+import 'terminal_chrome_scroll.dart';
import 'terminal_foot_bar.dart';
import 'terminal_header.dart';
+import 'terminal_header_floats.dart';
import 'terminal_input_dock.dart';
import 'terminal_search.dart';
import 'voice_input_controller.dart';
@@ -128,7 +131,7 @@ void dismissKeyboardForSwipe() {
}
class _TerminalPageState extends State<TerminalPage>
- with WidgetsBindingObserver, SingleTickerProviderStateMixin {
+ with WidgetsBindingObserver, TickerProviderStateMixin {
/// Whether this page's pane ever existed.
///
/// ⚠️ Load-bearing, and the reason this page is stateful at all. The page is pushed BEFORE the
@@ -207,6 +210,24 @@ class _TerminalPageState extends State<TerminalPage>
/// keyboard and swallows what the terminal is owed.
bool _searching = false;
+ /// The chrome getting out of the way as the terminal is scrolled — the header
+ /// on direction, the foot row on movement. See [TerminalChromeScroll].
+ late final TerminalChromeScroll _chrome = TerminalChromeScroll(
+ vsync: this,
+ // ⚠️ Rebuilds the page twice per move — at the start and at the end — and
+ // never per frame. What it changes is [TerminalPanel.settling], which holds
+ // the terminal's grid still while the chrome gives its height back. Without
+ // it every frame of a hiding header is a SIGWINCH on the far machine, and a
+ // full-screen TUI redraws for each one.
+ onMovingChanged: (moving) {
+ if (mounted) setState(() => _chromeMoving = moving);
+ },
+ );
+
+ /// Whether the chrome is mid-slide, and so the terminal's height is still
+ /// changing frame by frame. See [TerminalChromeScroll.moving].
+ bool _chromeMoving = false;
+
/// The last bottom inset seen, in physical pixels, and the timer that decides
/// the animation has stopped.
///
@@ -242,6 +263,11 @@ class _TerminalPageState extends State<TerminalPage>
void didUpdateWidget(TerminalPage oldWidget) {
super.didUpdateWidget(oldWidget);
if (oldWidget.isActive && !widget.isActive) {
+ // ⚠️ Parked pages come back with their chrome shown. A page swiped away
+ // with its header hidden would arrive that way the next time it is swiped
+ // to — chrome missing on a screen nobody has scrolled yet, and no gesture
+ // on the new page to bring it back.
+ _chrome.reveal();
// A keyboard asked for and still on its way belongs to the page that
// asked; a parked page must not claim it when it comes.
_keyboardRequested = false;
@@ -253,11 +279,103 @@ class _TerminalPageState extends State<TerminalPage>
@override
void dispose() {
_cancelSettle();
+ _chrome.dispose();
_searchOpen.dispose();
WidgetsBinding.instance.removeObserver(this);
super.dispose();
}
+ /// The three the header held, for when the row is not on screen to hold them.
+ ///
+ /// ⚠️ Built from the same conditions as the header's own row, so the column
+ /// never offers something the row would have withheld — `+` needs a machine
+ /// that is answering, `⋯` needs an agent that has loaded. That also means the
+ /// column can be two buttons rather than three, which is why its height is
+ /// computed rather than fixed.
+ List<TerminalHeaderChoice> _headerChoices(
+ MachineState? machine,
+ Agent? agent,
+ ) => [
+ TerminalHeaderChoice(
+ icon: LucideIcons.search300,
+ label: 'Search',
+ onTap: _openSearch,
+ ),
+ if (machine != null &&
+ phoneMachineStatusOf(machine) == PhoneMachineStatus.ready)
+ TerminalHeaderChoice(
+ icon: LucideIcons.plus300,
+ label: 'New agent',
+ onTap: () async {
+ await openNewAgent(context, widget.notifier, widget.machineId);
+ if (mounted) setState(() {});
+ },
+ ),
+ if (agent != null)
+ TerminalHeaderChoice(
+ icon: LucideIcons.ellipsis300,
+ label: 'Agent actions',
+ onTap: () => _showActions(
+ machineName: machine?.machine.displayName ?? '',
+ agentName: agent.name,
+ ),
+ ),
+ ];
+
+ /// Where each floating button starts its flight, relative to where it lands.
+ ///
+ /// ⚠️ **Worked out from the header's own constants rather than measured.** A
+ /// [GlobalKey] on each control would give the true rectangles, but the header
+ /// is being taken apart at exactly the moment these are read — its render
+ /// objects are mid-shrink, and half of them are already gone. Constants are
+ /// the only description of where the row's controls WERE that survives the row
+ /// leaving.
+ ///
+ /// The trade is that the origins drift if the header's layout changes without
+ /// this changing with it. That shows up as buttons flying from slightly the
+ /// wrong place, never as a crash or a missed target.
+ List<Offset> _headerOrigins(int count) {
+ // The column's own geometry: each button rests [pitch] below the one above,
+ // with the first at [inset] from the top.
+ const inset = TerminalHeaderFloats.inset;
+ const pitch = TerminalHeaderFloats.pitch;
+ const extent = TerminalHeaderFloats.extent;
+
+ // Where the header's controls sat, as centres measured from the top-right of
+ // the safe area. The trailing actions are [_HeaderAction]s: 24px boxes with
+ // 7 either side, laid from the right edge inwards past the header's own
+ // 14pt inset.
+ const actionPitch = 24 + _HeaderAction.gap * 2;
+ final headerMidY = TerminalHeader.topInset + TerminalHeader.barHeight / 2;
+
+ return [
+ for (var i = 0; i < count; i++)
+ () {
+ // ⚠️ The FIRST choice is search, and it came from the bar — which
+ // spans the row rather than sitting at a point. Its left end is where
+ // the magnifier is, and that is what the button flies from.
+ final fromRight = i == 0
+ ? _searchGlyphFromRight(context)
+ : TerminalHeader.sideInset +
+ actionPitch * (count - 1 - i) +
+ actionPitch / 2;
+ final restFromRight = inset + extent / 2;
+ final restY = inset + i * pitch + extent / 2;
+ return Offset(restFromRight - fromRight, headerMidY - restY);
+ }(),
+ ];
+ }
+
+ /// How far the search bar's magnifier sits from the screen's right edge.
+ ///
+ /// The bar fills what the trailing actions leave, so this is the whole width
+ /// less the row's insets and the glyph's own place inside the bar.
+ double _searchGlyphFromRight(BuildContext context) =>
+ MediaQuery.sizeOf(context).width -
+ TerminalHeader.sideInset -
+ TerminalHeader.barPadding -
+ TerminalHeader.glyphSize / 2;
+
/// Grows the header's bar into the search screen.
///
/// ⚠️ The overlay is mounted on THIS frame and the animation started on it,
@@ -266,6 +384,11 @@ class _TerminalPageState extends State<TerminalPage>
/// move, which is a beat too late for a bar that was tapped to type in.
void _openSearch() {
if (_searching) return;
+ // The bar being tapped may be a bar that scrolling had slid halfway off. It
+ // has to be home before the overlay's copy grows out of it, or the two start
+ // from different places and the expansion reads as a jump.
+ //
+ _chrome.reveal();
setState(() {
_searching = true;
// ⚠️ Handed over, not left standing. The bar can be tapped with the
@@ -387,6 +510,9 @@ class _TerminalPageState extends State<TerminalPage>
/// transcribed first: tapping the terminal mid-sentence is asking to fix that
/// sentence, not to lose it.
Future<void> _raiseKeyboard(TerminalSession session) async {
+ // Typing is not scrolling: the chrome has no reason to be out of the way,
+ // and the header holds the controls somebody reaches for next.
+ _chrome.reveal();
final heard = await widget.voice.takeTranscript();
if (!mounted) return;
if (heard.isNotEmpty && session.acceptsInput) {
@@ -545,93 +671,115 @@ class _TerminalPageState extends State<TerminalPage>
// of what the expansion is for.
Column(
children: [
- TerminalHeader(
- // ⚠️ Grows in place — no route is pushed. [openPhoneSearch]
- // is still what the LIST screens use, and this page used it
- // too until the bar arrived: pushing slid a fresh screen in
- // from the right, so the bar the finger had just touched left
- // the frame while an identical one came in from off-screen.
- // See `terminal_search.dart`.
- onSearch: _openSearch,
- // ⚠️ 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.
- 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,
+ // ⚠️ **Shrinks to nothing and gives that height to the
+ // terminal**, which is what lets the output fill the screen
+ // rather than leaving a band of empty window. What keeps the
+ // page usable while it is gone is [TerminalHeaderFloats] —
+ // the same controls, as a column of floating buttons down
+ // the right edge, each one flown out of the place it held in
+ // this row.
+ //
+ // The cost of handing the space over is that the terminal's
+ // height moves frame by frame, which xterm answers with a
+ // SIGWINCH apiece — [_chromeMoving] is what holds its grid
+ // still until the resize lands.
+ //
+ // ⚠️ It FADES as well as shrinking, on a curve that is spent
+ // well before the row is gone. The floating buttons are
+ // fading IN over the same stretch and pass through the same
+ // corner; two half-transparent copies of `⋯` a few points
+ // apart read as a smear rather than as a move.
+ _SlideAway(
+ progress: _chrome.header,
+ fade: true,
+ child: TerminalHeader(
+ // ⚠️ Grows in place — no route is pushed. [openPhoneSearch]
+ // is still what the LIST screens use, and this page used it
+ // too until the bar arrived: pushing slid a fresh screen in
+ // from the right, so the bar the finger had just touched left
+ // the frame while an identical one came in from off-screen.
+ // See `terminal_search.dart`.
+ onSearch: _openSearch,
+ // ⚠️ 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.
+ 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,
- );
- 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,
+ 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,
+ ),
+ ),
+ ],
+ ),
),
Expanded(
child: Column(
@@ -645,50 +793,68 @@ class _TerminalPageState extends State<TerminalPage>
child: Stack(
children: [
Positioned.fill(
- child: 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 renderer still while the keyboard
- // slides. Separate from `visible` because this
- // must NOT release focus — the animation being
- // waited on is the one that focus started.
- settling: _keyboardSettling,
- // ⚠️ 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 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: 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 renderer still while the keyboard
+ // slides. Separate from `visible` because this
+ // must NOT release focus — the animation being
+ // waited on is the one that focus started.
+ // Two reasons the height is a
+ // moving target, and the panel
+ // needs to sit still for both:
+ // the keyboard sliding, and the
+ // chrome giving its rows back.
+ settling:
+ _keyboardSettling ||
+ _chromeMoving,
+ // ⚠️ 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 mic — the one voice control the page has,
// floating over the terminal's bottom right corner
@@ -757,6 +923,14 @@ class _TerminalPageState extends State<TerminalPage>
// bar is already tall, and a line wedged under it is a
// row of chrome the terminal loses for nothing — who the
// agent is is not what is being read mid-typing.
+ //
+ // ⚠️ **It does not move with scrolling, and an earlier
+ // version that did was wrong.** This row is one line
+ // of identity and the mic's running commentary — it
+ // costs the terminal 20 points, and hiding it whenever
+ // the content moved meant the words the mic needs read
+ // went away exactly while somebody was looking for
+ // them.
if (!_ownsInput)
TerminalFootBar(
name: machine?.machine.displayName ?? '',
@@ -770,6 +944,33 @@ class _TerminalPageState extends State<TerminalPage>
),
],
),
+ // The header's controls, floating down the right edge once
+ // the row itself has scrolled away.
+ //
+ // ⚠️ **Built on the animation, not on a flag the page keeps.**
+ // These have to be somewhere on every frame of the slide — they
+ // fly out of the header as it goes — so their position is read
+ // per frame. A boolean flipped in a callback would put them
+ // there in one jump, which is the thing this replaced.
+ AnimatedBuilder(
+ animation: _chrome.header,
+ builder: (context, _) {
+ if (_chrome.header.value == 0) {
+ return const SizedBox.shrink();
+ }
+ final choices = _headerChoices(machine, agent);
+ if (choices.isEmpty) return const SizedBox.shrink();
+ return Positioned(
+ top: TerminalHeaderFloats.inset,
+ right: TerminalHeaderFloats.inset,
+ child: TerminalHeaderFloats(
+ choices: choices,
+ progress: _chrome.header,
+ origins: _headerOrigins(choices.length),
+ ),
+ );
+ },
+ ),
// Search, grown out of the header bar. Only built while it is
// on its way in, up, or on its way out — see [_searching].
//
@@ -980,6 +1181,76 @@ class _Attaching extends StatelessWidget {
);
}
+/// A row of chrome that shrinks away to nothing, handing its height to whatever
+/// shares its [Column].
+///
+/// ⚠️ **[Align.heightFactor], not a translation, and the two are not
+/// interchangeable.** A `Transform` or a `FractionalTranslation` paints the row
+/// somewhere else and leaves its box exactly where it was — so the header
+/// "hides" and a band of empty window stays behind it. Shrinking the box is what
+/// actually gives the space to the terminal beside it.
+///
+/// The price is that the terminal's height then moves every frame, and xterm
+/// answers a height change with a SIGWINCH. See
+/// [TerminalChromeScroll.moving] for what holds that still.
+///
+class _SlideAway extends StatelessWidget {
+ const _SlideAway({
+ required this.progress,
+ required this.child,
+ this.fade = false,
+ // ignore: unused_element_parameter
+ this.fromTop = true,
+ });
+
+ /// Whether the row also dims on its way out.
+ ///
+ /// ⚠️ Needed wherever something else is arriving over the same ground — see
+ /// the header's call site. A row that only shrinks is fully opaque right up to
+ /// its last few points, and a button fading in behind it shows through.
+ final bool fade;
+
+ /// 0 fully shown, 1 fully hidden.
+ final Animation<double> progress;
+
+ /// Which edge it leaves by — up for the header, down for the foot row.
+ final bool fromTop;
+
+ final Widget child;
+
+ @override
+ Widget build(BuildContext context) => AnimatedBuilder(
+ animation: progress,
+ // ⚠️ Built ONCE and passed through. The child is a whole header, and
+ // rebuilding it on every frame of a scroll is work for nothing — what
+ // changes is the box around it, not anything in it.
+ child: child,
+ builder: (context, child) {
+ // Fully open is the common case and the one worth keeping cheap: no
+ // align, no clip, no extra render object in the tree while nobody is
+ // scrolling.
+ if (progress.value == 0) return child!;
+ return ClipRect(
+ child: Opacity(
+ // Spent by the two-thirds mark, which is where the floating buttons
+ // are arriving. Anything still visible after that competes with them.
+ opacity: fade ? (1 - progress.value / 0.66).clamp(0.0, 1.0) : 1.0,
+ child: Align(
+ // ⚠️ **A heightFactor, which is what actually GIVES the space back.**
+ // The row shrinks to nothing and the terminal beside it in the Column
+ // grows into what it let go — the screen the scroll was asking for.
+ // Translating instead left the row's height reserved and a band of
+ // empty window where the header had been.
+ alignment: fromTop ? Alignment.bottomCenter : Alignment.topCenter,
+ heightFactor: 1 - progress.value,
+ child: child,
+ ),
+ ),
+ );
+ },
+ );
+}
+
/// The longest agent name the header will print before it cuts.
///
/// An agent's name is usually a filename, and the header row has to hold three
@@ -1051,11 +1322,11 @@ class _HeaderAction extends StatelessWidget {
/// actions and the gap from the last one to the screen edge are then the
/// same measure, and the three read as evenly placed rather than as a group
/// shoved against the corner.
- static const double _gap = 7;
+ static const double gap = 7;
@override
Widget build(BuildContext context) => Padding(
- padding: EdgeInsets.fromLTRB(_gap, 0, last ? 0 : _gap, 0),
+ padding: EdgeInsets.fromLTRB(gap, 0, last ? 0 : gap, 0),
child: AppIconButton(
icon: icon,
size: size,
diff --git a/mobile/lib/phone/voice_mic_button.dart b/mobile/lib/phone/voice_mic_button.dart
index 72dd548fc..f5458c2a1 100644
--- a/mobile/lib/phone/voice_mic_button.dart
+++ b/mobile/lib/phone/voice_mic_button.dart
@@ -362,9 +362,41 @@ class _Core extends StatelessWidget {
border: Border.all(
color: lit ? Colors.white.withValues(alpha: 0.28) : AppGlass.lift,
),
+ // ⚠️ **Two different shadows for two different jobs, and the resting one
+ // is not optional.** Lit, the button glows in its own colour — that is
+ // state, saying the mic is open. At rest it casts a plain drop shadow
+ // instead: it floats over streaming output rather than over a surface, and
+ // without one its edge disappears against every dark line it happens to
+ // sit on. The screenshot that prompted this had it all but invisible.
boxShadow: lit
- ? [BoxShadow(color: _tint.withValues(alpha: 0.4), blurRadius: 12)]
- : null,
+ ? [
+ BoxShadow(color: _tint.withValues(alpha: 0.4), blurRadius: 12),
+ // The lift, under the glow. The glow says "recording"; it does
+ // not separate the circle from the text behind it, because it is
+ // the same brightness as the accent the terminal itself uses.
+ BoxShadow(
+ color: Colors.black.withValues(alpha: 0.35),
+ blurRadius: 10,
+ offset: const Offset(0, 3),
+ ),
+ ]
+ : [
+ // Cast down and soft: enough to lift the circle off the text
+ // behind it without reading as a second ring around it.
+ BoxShadow(
+ color: Colors.black.withValues(alpha: 0.45),
+ blurRadius: 12,
+ offset: const Offset(0, 3),
+ ),
+ // A tight, darker core under the edge, which is what keeps the
+ // outline readable where the blur alone washes out over a bright
+ // line of output.
+ BoxShadow(
+ color: Colors.black.withValues(alpha: 0.3),
+ blurRadius: 3,
+ offset: const Offset(0, 1),
+ ),
+ ],
),
child: Center(
child: AnimatedSwitcher(