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.

fix(mobile): the terminal stops above Android's navigation bar

bubu-dudu5c0dba3bf06b
diff --git a/mobile/lib/phone/terminal_page.dart b/mobile/lib/phone/terminal_page.dart
index 0a20f3c75..feeaa3a2f 100644
--- a/mobile/lib/phone/terminal_page.dart
+++ b/mobile/lib/phone/terminal_page.dart
@@ -1,5 +1,8 @@
import 'dart:async';
+// `defaultTargetPlatform` — the navigation bar this page keeps clear of is
+// Android's alone; see [_TerminalPageState._navigationBar].
+import 'package:flutter/foundation.dart' show defaultTargetPlatform;
import 'package:flutter/material.dart';
// `PlatformException` — a refused camera permission arrives as one, and it is
// the one picker failure with something the person can do about it.
@@ -650,13 +653,29 @@ class _TerminalPageState extends State<TerminalPage>
//
// The flag belongs to [_armSettle] and [_endSettle] alone now; they know
// about both clocks, and this method arms them like any other caller.
- if (up == _keyboardUp && requested == _keyboardRequested) return;
+ // The bar itself can come and go under a live page — a switch from buttons
+ // to gestures in Settings, a rotation that moves it to the side — and
+ // nothing else here would notice: [_navigationBar] reads the view rather
+ // than a MediaQuery, so no rebuild follows the change on its own.
+ final bar = View.of(context).viewPadding.bottom;
+ final barMoved = bar != _lastViewPaddingBottom;
+ _lastViewPaddingBottom = bar;
+ if (up == _keyboardUp && requested == _keyboardRequested) {
+ if (barMoved) setState(() {});
+ return;
+ }
setState(() {
_keyboardUp = up;
_keyboardRequested = requested;
});
}
+ /// The window's own bottom inset as of the last metrics tick, in physical
+ /// pixels — see the note above on why it is watched. Starts at -1 rather than
+ /// 0 so a page that first hears from the platform with no bar at all is not
+ /// read as a page whose bar has just gone.
+ double _lastViewPaddingBottom = -1;
+
/// Whether [TerminalPanel] should hold the input connection: while the
/// keyboard is up, and while one is on its way — see [_keyboardRequested].
///
@@ -747,6 +766,43 @@ class _TerminalPageState extends State<TerminalPage>
/// [_keyBarUp] as of the last build, so a change to it can be spotted.
bool _keyBarWasUp = false;
+ /// The strip at the foot of the window the terminal must stay out of:
+ /// Android's navigation BAR, and nothing else. Zero everywhere else, which is
+ /// what keeps the page edge to edge where there is nothing solid to clash
+ /// with.
+ ///
+ /// ⚠️ **A bar and a gesture handle are not the same inset, though both arrive
+ /// as `viewPadding.bottom`.** The handle is a hairline drawn ON the content —
+ /// output running under it still reads, and reserving a strip for it would
+ /// leave a band of window background under the newest line, which is the line
+ /// being read. A three-button bar is opaque chrome with targets in it: output
+ /// under THAT is gone, and a tap meant for the terminal ends the app. So the
+ /// height is what separates them — a handle is 24dp on every Android that
+ /// draws one, a bar is 48dp — and [_navigationBarMin] sits between the two.
+ /// (`Settings.Secure.navigation_mode` would say it outright, but it needs a
+ /// platform channel and a native class on both platforms to answer what one
+ /// number already answers.)
+ ///
+ /// ⚠️ **Zero while the keyboard is up.** Android's IME inset already includes
+ /// the bar — the keyboard reserves that strip inside its own height and the
+ /// bar is drawn over it — and `PhoneShell`'s Scaffold has resized this page
+ /// to sit above the whole of it. Reserving it again here opened a band of
+ /// background between the key bar and the keyboard.
+ ///
+ /// [View.of] rather than MediaQuery for the reason [didChangeMetrics] gives,
+ /// and its value is in PHYSICAL pixels.
+ double get _navigationBar {
+ if (defaultTargetPlatform != TargetPlatform.android) return 0;
+ if (_keyboardUp) return 0;
+ final view = View.of(context);
+ final inset = view.viewPadding.bottom / view.devicePixelRatio;
+ return inset >= _navigationBarMin ? inset : 0;
+ }
+
+ /// Between a 24dp gesture handle and a 48dp navigation bar — see
+ /// [_navigationBar].
+ static const double _navigationBarMin = 36;
+
/// Starts the hold that covers [TerminalKeyBar]'s slide, if this build is the
/// one that sets it going.
///
@@ -915,6 +971,9 @@ class _TerminalPageState extends State<TerminalPage>
final canCreate =
machine != null &&
phoneMachineStatusOf(machine) == PhoneMachineStatus.ready;
+ // Read once: the body reserves it, and search subtracts what the body
+ // already took. See [_navigationBar].
+ final navigationBar = _navigationBar;
return Scaffold(
backgroundColor: AppPalette.windowBg,
// ⚠️ No fab. New agent is the `+` in the header — see the note there.
@@ -951,359 +1010,379 @@ class _TerminalPageState extends State<TerminalPage>
removeBottom: true,
child: SafeArea(
bottom: false,
- child: Stack(
- children: [
- // ⚠️ The terminal is FADED, never unbuilt, while search is
- // open. Taking it down would detach the pane and drop the
- // scrollback; cancelling has to hand back the same screen that
- // was there, mid-stream.
- //
- // ⚠️ **The header is NOT inside the fade, on purpose.** The
- // overlay's bar sits exactly on top of this one and has to read
- // as the same object growing — fading this one out underneath
- // it made the row flicker on every open, which is the opposite
- // of what the expansion is for.
- // ⚠️ **Held at its height while search is open.** The search
- // field's keyboard shrinks this page like any other; followed,
- // the terminal shrank under the search and grew back through it
- // as it faded out — the flash seen on every close. Nothing here
- // is on screen while search covers it, so nothing here moves.
- HeldHeight(
- hold: _heldForSearch,
- child: Column(
- children: [
- Expanded(
- // ⚠️ The mic floats INSIDE this box, over the terminal
- // — not over the whole page. Stacked any higher it
- // would hang over the key bar while the keyboard is
- // up, which is the one row the thumb is working.
- child: Stack(
- children: [
- Positioned.fill(
- // ⚠️ The chrome is driven from OUT HERE, not
- // from inside the panel. xterm's own
- // [Scrollable] is several widgets down and is
- // remounted whenever the agent changes;
- // listening for its notifications as they
- // bubble past is what survives that, and costs
- // the panel no knowledge of the page's chrome.
- child: NotificationListener<ScrollNotification>(
- onNotification: _chrome.onNotification,
- child: agentGone
- ? _AgentGone(
- name: _cachedAgentName,
- onPickAnother: _pickAnotherAgent,
- )
- : pane == null || session == null
- ? const _Attaching()
- : TerminalPanel(
- key: ValueKey(pane.id),
- notifier: widget.notifier,
- session: session,
- // Only the page on screen takes the keyboard — see
- // [TerminalPage.isActive]. `visible` is the same answer for the
- // panel's other half: a page parked beside this one releases
- // focus, stops rendering and stops resizing its remote shell.
- //
- // Whether it also HOLDS one that is already
- // up is a separate question, and the pager asks
- // it on every swipe — see [_shouldFocus].
- focused: _shouldFocus,
- visible: widget.isActive,
- // Hold the remote resize while the keyboard
- // slides. Separate from `visible` because this
- // must NOT release focus — the animation being
- // waited on is the one that focus started.
- //
- // The keyboard is the only thing left that
- // moves this pane's height: the header slides
- // OVER the terminal rather than out of its
- // column — see [_SlideAway].
- //
- // ⚠️ Held for as long as search is open, too:
- // its keyboard is typing a query over a faded
- // terminal, and resizing the agent's shell for
- // it redrew the whole TUI on the way in and
- // again on the way out.
- settling:
- _keyboardSettling || _heldForSearch,
- // ⚠️ The tap is taken in the panel, not by a
- // `Listener` over it. xterm's own `_onTapDown`
- // calls `requestKeyboard()`, so anything that
- // merely ALSO reacted to the tap would raise
- // the keyboard before the words said were typed
- // into the prompt — and a re-armed claim on top
- // of it was measured asking Android twice per
- // tap, which answers a show mid-animation by
- // cancelling and restarting it. Null while the
- // keyboard is up or coming, so the tap is
- // xterm's and the keyboard stays.
- //
- // ⚠️ A tap on a pane that cannot take input
- // asks for the TERMINAL, not the keyboard:
- // raising one over a read-only pane offers
- // a prompt that silently swallows every
- // letter. The band above says why, so the
- // tap takes the person to its button. See
- // [_ControlBanner].
- onInputTap: blocked
- ? () => unawaited(_takeControl())
- : _shouldFocus
- ? null
- : () => unawaited(
- _raiseKeyboard(session),
- ),
- showHeader: false,
- // No composer, and so no grip above it: the
- // page hands the pane its full height and the
- // software keyboard drives the terminal
- // directly. The mic's send is what kept the
- // composer's batched turn.
- ),
- ),
- ),
- // ⚠️ **The skeleton is laid OVER the live panel, not
- // swapped in for it, and that is not a stylistic
- // choice.** [TerminalPanel.initState] calls
- // `session.attachViewport`, which is how the machine
- // learns how many rows and columns to draw; a page
- // that showed a skeleton INSTEAD would leave the
- // session with no viewport, and the first keyframe
- // would arrive sized for nothing.
- //
- // So the panel mounts, measures and resizes as always,
- // and this covers the empty emulator buffer it paints
- // meanwhile. `session == null` upstream keeps its own
- // branch for the frames before a session exists at all.
- //
- // ⚠️ **This is also the bug that made the skeleton
- // invisible.** The only gate used to be `session ==
- // null`, and `selectAgent` creates the pane and the
- // session in one frame — so the branch above was
- // essentially never taken, and what a person actually
- // waited in front of was a mounted terminal with an
- // empty buffer: a black rectangle, for as long as the
- // keyframe took.
- //
- // ⚠️ **A page on a terminal another app holds still
- // renders.** It attaches as a WATCHER — live output,
- // no typing (see [TerminalSession.watching]) — so the
- // keyframe this covers arrives exactly as it does for
- // any other page, and nothing here needs to know the
- // difference. The header says who has it and offers
- // "Take control"; the body is the terminal.
- if (session != null && !session.hasRenderedFrame)
- const Positioned.fill(child: _Attaching()),
- // The mic, Search and New agent, floating in the
- // terminal's bottom-right corner — see
- // [TerminalActionColumn].
- //
- // ⚠️ Hidden while this page owns the keyboard.
- // Typing is the other way of saying what the mic
- // says, the key bar is already under the thumb, and
- // a column floating over the prompt being typed into
- // would be in the way of both.
- if (!_ownsInput)
- Positioned(
- right: TerminalActionColumn.inset,
- bottom: TerminalActionColumn.bottomInset,
- child: TerminalActionColumn(
- voice: widget.voice,
- session: session,
- onSearch: _openSearch,
- onNewAgent: canCreate
- ? () => unawaited(_newAgent())
- : null,
+ // ⚠️ **The one bottom inset that IS taken back, by hand rather than
+ // through the MediaQuery the lines above strip.** Android's
+ // navigation bar is opaque chrome with targets in it, so the page
+ // ends above it; a gesture handle or a home indicator is not, and
+ // this is zero there — see [_navigationBar]. Padding the box rather
+ // than restoring the inset is deliberate: xterm reads
+ // `MediaQuery.padding` as its own and would size rows for a height
+ // its box does not have, which is the layout loop the note above
+ // describes.
+ child: Padding(
+ padding: EdgeInsets.only(bottom: navigationBar),
+ child: Stack(
+ children: [
+ // ⚠️ The terminal is FADED, never unbuilt, while search is
+ // open. Taking it down would detach the pane and drop the
+ // scrollback; cancelling has to hand back the same screen that
+ // was there, mid-stream.
+ //
+ // ⚠️ **The header is NOT inside the fade, on purpose.** The
+ // overlay's bar sits exactly on top of this one and has to read
+ // as the same object growing — fading this one out underneath
+ // it made the row flicker on every open, which is the opposite
+ // of what the expansion is for.
+ // ⚠️ **Held at its height while search is open.** The search
+ // field's keyboard shrinks this page like any other; followed,
+ // the terminal shrank under the search and grew back through it
+ // as it faded out — the flash seen on every close. Nothing here
+ // is on screen while search covers it, so nothing here moves.
+ HeldHeight(
+ hold: _heldForSearch,
+ child: Column(
+ children: [
+ Expanded(
+ // ⚠️ The mic floats INSIDE this box, over the terminal
+ // — not over the whole page. Stacked any higher it
+ // would hang over the key bar while the keyboard is
+ // up, which is the one row the thumb is working.
+ child: Stack(
+ children: [
+ Positioned.fill(
+ // ⚠️ The chrome is driven from OUT HERE, not
+ // from inside the panel. xterm's own
+ // [Scrollable] is several widgets down and is
+ // remounted whenever the agent changes;
+ // listening for its notifications as they
+ // bubble past is what survives that, and costs
+ // the panel no knowledge of the page's chrome.
+ child: NotificationListener<ScrollNotification>(
+ onNotification: _chrome.onNotification,
+ child: agentGone
+ ? _AgentGone(
+ name: _cachedAgentName,
+ onPickAnother: _pickAnotherAgent,
+ )
+ : pane == null || session == null
+ ? const _Attaching()
+ : TerminalPanel(
+ key: ValueKey(pane.id),
+ notifier: widget.notifier,
+ session: session,
+ // Only the page on screen takes the keyboard — see
+ // [TerminalPage.isActive]. `visible` is the same answer for the
+ // panel's other half: a page parked beside this one releases
+ // focus, stops rendering and stops resizing its remote shell.
+ //
+ // Whether it also HOLDS one that is already
+ // up is a separate question, and the pager asks
+ // it on every swipe — see [_shouldFocus].
+ focused: _shouldFocus,
+ visible: widget.isActive,
+ // Hold the remote resize while the keyboard
+ // slides. Separate from `visible` because this
+ // must NOT release focus — the animation being
+ // waited on is the one that focus started.
+ //
+ // The keyboard is the only thing left that
+ // moves this pane's height: the header slides
+ // OVER the terminal rather than out of its
+ // column — see [_SlideAway].
+ //
+ // ⚠️ Held for as long as search is open, too:
+ // its keyboard is typing a query over a faded
+ // terminal, and resizing the agent's shell for
+ // it redrew the whole TUI on the way in and
+ // again on the way out.
+ settling:
+ _keyboardSettling || _heldForSearch,
+ // ⚠️ The tap is taken in the panel, not by a
+ // `Listener` over it. xterm's own `_onTapDown`
+ // calls `requestKeyboard()`, so anything that
+ // merely ALSO reacted to the tap would raise
+ // the keyboard before the words said were typed
+ // into the prompt — and a re-armed claim on top
+ // of it was measured asking Android twice per
+ // tap, which answers a show mid-animation by
+ // cancelling and restarting it. Null while the
+ // keyboard is up or coming, so the tap is
+ // xterm's and the keyboard stays.
+ //
+ // ⚠️ A tap on a pane that cannot take input
+ // asks for the TERMINAL, not the keyboard:
+ // raising one over a read-only pane offers
+ // a prompt that silently swallows every
+ // letter. The band above says why, so the
+ // tap takes the person to its button. See
+ // [_ControlBanner].
+ onInputTap: blocked
+ ? () => unawaited(_takeControl())
+ : _shouldFocus
+ ? null
+ : () => unawaited(
+ _raiseKeyboard(session),
+ ),
+ showHeader: false,
+ // No composer, and so no grip above it: the
+ // page hands the pane its full height and the
+ // software keyboard drives the terminal
+ // directly. The mic's send is what kept the
+ // composer's batched turn.
+ ),
),
),
- ],
- ),
- ),
- // The bottom of this page IS just above the keyboard:
- // `PhoneShell`'s Scaffold has already resized for it —
- // the same resize that empties this page's MediaQuery
- // insets (see [didChangeMetrics]).
- if (session != null)
- TerminalInputDock(
- session: session,
- keyboardUp: _keyBarUp,
- onDismiss: _dismissInput,
- // Only where the far side can actually take one: an
- // older CLI never advertises the binary kind, so the
- // upload would go nowhere silently. Null leaves the
- // buttons undrawn rather than drawn dead.
- onPickImage:
- machine?.terminalImagePasteAvailable == true
- ? () => unawaited(
- _sendImage(session, ImageSource.gallery),
- )
- : null,
- onTakePhoto:
- machine?.terminalImagePasteAvailable == true
- ? () => unawaited(
- _sendImage(session, ImageSource.camera),
- )
- : null,
- ),
- ],
- ),
- ),
- // The header, laid OVER the terminal rather than above it in the
- // column.
- //
- // ⚠️ **Over, not beside, and that is what keeps scrolling smooth.**
- // It used to shrink out of the column and hand its height to the
- // terminal. Every fold then changed the terminal's row count: a
- // `terminal_resize` and a real SIGWINCH on the far machine, a
- // keyframe back carrying up to 500 lines of history to re-parse on
- // this thread, and the agent's whole screen redrawn — once as the
- // header left, once as it came back, on every change of scroll
- // direction. The renderer was held frozen for each slide on top of
- // that, so a fling stopped dead for a third of a second.
- //
- // Laid over, the terminal keeps one height whatever the header
- // does. The rows under it are the oldest on the screen, and the
- // first push of a scroll is what slides it away from them.
- //
- // Nothing stands in for it while it is gone: `⋯` comes back with
- // the header on the first scroll the other way.
- Positioned(
- top: 0,
- left: 0,
- right: 0,
- child: _SlideAway(
- progress: _chrome.header,
- // Opaque: the terminal is underneath now, and the row has to
- // read as the same bar it was when the two were stacked.
- child: ColoredBox(
- color: AppPalette.windowBg,
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- TerminalHeader(
- agent: agent,
- status: phoneSessionSummary(
- session,
- takerName: takerName,
- ),
- 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.
- // ⚠️ **Not while the band is up.** The band below
- // carries the same words and the same button, a
- // finger's width under this one, and two "Take
- // control"s stacked read as two different offers.
- // The band is the better of the two — it says WHY
- // typing stopped, and by whom — so this one gives
- // way to it.
+ // ⚠️ **The skeleton is laid OVER the live panel, not
+ // swapped in for it, and that is not a stylistic
+ // choice.** [TerminalPanel.initState] calls
+ // `session.attachViewport`, which is how the machine
+ // learns how many rows and columns to draw; a page
+ // that showed a skeleton INSTEAD would leave the
+ // session with no viewport, and the first keyframe
+ // would arrive sized for nothing.
//
- // Kept for the states the band does not cover:
- // "Reconnect", for a stream that died with nobody
- // else involved. See [_ControlBanner].
- if (reclaim != null && !blocked && !_takingControl)
- _ReclaimButton(
- action: reclaim,
- // The same call the band's button makes — see
- // [_takeControl].
- onPressed: () => unawaited(_takeControl()),
- ),
- // The account's tabs, one mark before `⋯` — the
- // only way to another tab now that a swipe stays
- // inside the one you are in.
+ // So the panel mounts, measures and resizes as always,
+ // and this covers the empty emulator buffer it paints
+ // meanwhile. `session == null` upstream keeps its own
+ // branch for the frames before a session exists at all.
//
- // ⚠️ **A mark, not a rail of tabs across the top.**
- // The terminal is the screen; chrome above it is
- // somebody's session not being shown, and this is a
- // choice made a few times a day. What it opens
- // comes up from the bottom instead, where the thumb
- // already is — see [showDeskTabsPopup].
+ // ⚠️ **This is also the bug that made the skeleton
+ // invisible.** The only gate used to be `session ==
+ // null`, and `selectAgent` creates the pane and the
+ // session in one frame — so the branch above was
+ // essentially never taken, and what a person actually
+ // waited in front of was a mounted terminal with an
+ // empty buffer: a black rectangle, for as long as the
+ // keyframe took.
//
- // Undrawn for an account with no tabs at all: the
- // panel would hold one tab over every agent on the
- // account, which is what a swipe already walks.
- if (widget.notifier.deskTabs.isNotEmpty)
- _HeaderAction(
- icon: LucideIcons.layoutGrid300,
- tooltip: 'Tabs',
- onPressed: () => unawaited(
- showDeskTabsPopup(
- context,
- widget.notifier,
- showing: (
- machineId: widget.machineId,
- agentId: widget.agentId,
- ),
- ),
- ),
- ),
- // 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.
- last: true,
- onPressed: () => _showActions(
- machineName:
- machine?.machine.displayName ?? '',
- agent: agent,
+ // ⚠️ **A page on a terminal another app holds still
+ // renders.** It attaches as a WATCHER — live output,
+ // no typing (see [TerminalSession.watching]) — so the
+ // keyframe this covers arrives exactly as it does for
+ // any other page, and nothing here needs to know the
+ // difference. The header says who has it and offers
+ // "Take control"; the body is the terminal.
+ if (session != null && !session.hasRenderedFrame)
+ const Positioned.fill(child: _Attaching()),
+ // The mic, Search and New agent, floating in the
+ // terminal's bottom-right corner — see
+ // [TerminalActionColumn].
+ //
+ // ⚠️ Hidden while this page owns the keyboard.
+ // Typing is the other way of saying what the mic
+ // says, the key bar is already under the thumb, and
+ // a column floating over the prompt being typed into
+ // would be in the way of both.
+ if (!_ownsInput)
+ Positioned(
+ right: TerminalActionColumn.inset,
+ bottom: TerminalActionColumn.bottomInset,
+ child: TerminalActionColumn(
+ voice: widget.voice,
+ session: session,
+ onSearch: _openSearch,
+ onNewAgent: canCreate
+ ? () => unawaited(_newAgent())
+ : null,
),
),
],
),
- Divider(height: 1, color: AppGlass.hair),
- // ⚠️ Inside the header's own slide, not under it: the two are one bar as far
- // as a scroll is concerned, and a band left behind while the header left
- // would sit on the output with nothing above it.
- if (blocked || _takingControl)
- _ControlBanner(
- watching: session?.watching ?? false,
- busy: !blocked,
- takeoverNotice: takeoverNotice,
- onTakeControl: _takeControl,
+ ),
+ // The bottom of this page IS just above the keyboard:
+ // `PhoneShell`'s Scaffold has already resized for it —
+ // the same resize that empties this page's MediaQuery
+ // insets (see [didChangeMetrics]).
+ if (session != null)
+ TerminalInputDock(
+ session: session,
+ keyboardUp: _keyBarUp,
+ onDismiss: _dismissInput,
+ // Only where the far side can actually take one: an
+ // older CLI never advertises the binary kind, so the
+ // upload would go nowhere silently. Null leaves the
+ // buttons undrawn rather than drawn dead.
+ onPickImage:
+ machine?.terminalImagePasteAvailable == true
+ ? () => unawaited(
+ _sendImage(session, ImageSource.gallery),
+ )
+ : null,
+ onTakePhoto:
+ machine?.terminalImagePasteAvailable == true
+ ? () => unawaited(
+ _sendImage(session, ImageSource.camera),
+ )
+ : null,
+ ),
+ ],
+ ),
+ ),
+ // The header, laid OVER the terminal rather than above it in the
+ // column.
+ //
+ // ⚠️ **Over, not beside, and that is what keeps scrolling smooth.**
+ // It used to shrink out of the column and hand its height to the
+ // terminal. Every fold then changed the terminal's row count: a
+ // `terminal_resize` and a real SIGWINCH on the far machine, a
+ // keyframe back carrying up to 500 lines of history to re-parse on
+ // this thread, and the agent's whole screen redrawn — once as the
+ // header left, once as it came back, on every change of scroll
+ // direction. The renderer was held frozen for each slide on top of
+ // that, so a fling stopped dead for a third of a second.
+ //
+ // Laid over, the terminal keeps one height whatever the header
+ // does. The rows under it are the oldest on the screen, and the
+ // first push of a scroll is what slides it away from them.
+ //
+ // Nothing stands in for it while it is gone: `⋯` comes back with
+ // the header on the first scroll the other way.
+ Positioned(
+ top: 0,
+ left: 0,
+ right: 0,
+ child: _SlideAway(
+ progress: _chrome.header,
+ // Opaque: the terminal is underneath now, and the row has to
+ // read as the same bar it was when the two were stacked.
+ child: ColoredBox(
+ color: AppPalette.windowBg,
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ TerminalHeader(
+ agent: agent,
+ status: phoneSessionSummary(
+ session,
+ takerName: takerName,
+ ),
+ 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.
+ // ⚠️ **Not while the band is up.** The band below
+ // carries the same words and the same button, a
+ // finger's width under this one, and two "Take
+ // control"s stacked read as two different offers.
+ // The band is the better of the two — it says WHY
+ // typing stopped, and by whom — so this one gives
+ // way to it.
+ //
+ // Kept for the states the band does not cover:
+ // "Reconnect", for a stream that died with nobody
+ // else involved. See [_ControlBanner].
+ if (reclaim != null &&
+ !blocked &&
+ !_takingControl)
+ _ReclaimButton(
+ action: reclaim,
+ // The same call the band's button makes — see
+ // [_takeControl].
+ onPressed: () => unawaited(_takeControl()),
+ ),
+ // The account's tabs, one mark before `⋯` — the
+ // only way to another tab now that a swipe stays
+ // inside the one you are in.
+ //
+ // ⚠️ **A mark, not a rail of tabs across the top.**
+ // The terminal is the screen; chrome above it is
+ // somebody's session not being shown, and this is a
+ // choice made a few times a day. What it opens
+ // comes up from the bottom instead, where the thumb
+ // already is — see [showDeskTabsPopup].
+ //
+ // Undrawn for an account with no tabs at all: the
+ // panel would hold one tab over every agent on the
+ // account, which is what a swipe already walks.
+ if (widget.notifier.deskTabs.isNotEmpty)
+ _HeaderAction(
+ icon: LucideIcons.layoutGrid300,
+ tooltip: 'Tabs',
+ onPressed: () => unawaited(
+ showDeskTabsPopup(
+ context,
+ widget.notifier,
+ showing: (
+ machineId: widget.machineId,
+ agentId: widget.agentId,
+ ),
+ ),
+ ),
+ ),
+ // 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.
+ last: true,
+ onPressed: () => _showActions(
+ machineName:
+ machine?.machine.displayName ?? '',
+ agent: agent,
+ ),
+ ),
+ ],
),
- ],
+ Divider(height: 1, color: AppGlass.hair),
+ // ⚠️ Inside the header's own slide, not under it: the two are one bar as far
+ // as a scroll is concerned, and a band left behind while the header left
+ // would sit on the output with nothing above it.
+ if (blocked || _takingControl)
+ _ControlBanner(
+ watching: session?.watching ?? false,
+ busy: !blocked,
+ takeoverNotice: takeoverNotice,
+ onTakeControl: _takeControl,
+ ),
+ ],
+ ),
),
),
),
- ),
- // Search, faded up over the whole page. Only built while it is
- // on its way in, up, or on its way out — see [_searching].
- //
- // ⚠️ **Takes the bottom inset back by hand, because nothing above
- // can hand it over any more.** This is ordinary chrome — a field
- // and a list of results — and it covers the terminal whole, so it
- // wants the inset the terminal gives up: unpadded, its last result
- // sat under the home indicator. A `SafeArea` cannot do it here:
- // the body strips that inset out of the MediaQuery entirely (see
- // the note on `removePadding` above), so a `SafeArea` this far
- // down reads zero and pads by nothing. The view's own padding is
- // the platform's, untouched by any of that. The top inset it
- // already has from the page.
- if (_searching)
- Positioned.fill(
- child: Padding(
- padding: EdgeInsets.only(
- bottom:
- View.of(context).viewPadding.bottom /
- View.of(context).devicePixelRatio,
- ),
- child: TerminalSearchOverlay(
- notifier: widget.notifier,
- animation: _searchCurve,
- onClose: _closeSearch,
+ // Search, faded up over the whole page. Only built while it is
+ // on its way in, up, or on its way out — see [_searching].
+ //
+ // ⚠️ **Takes the bottom inset back by hand, because nothing above
+ // can hand it over any more.** This is ordinary chrome — a field
+ // and a list of results — and it covers the terminal whole, so it
+ // wants the inset the terminal gives up: unpadded, its last result
+ // sat under the home indicator. A `SafeArea` cannot do it here:
+ // the body strips that inset out of the MediaQuery entirely (see
+ // the note on `removePadding` above), so a `SafeArea` this far
+ // down reads zero and pads by nothing. The view's own padding is
+ // the platform's, untouched by any of that. The top inset it
+ // already has from the page.
+ if (_searching)
+ Positioned.fill(
+ child: Padding(
+ padding: EdgeInsets.only(
+ // Less whatever the body has already reserved — on
+ // Android with a navigation bar the two are the same
+ // inset, and padded twice the last result sat a bar's
+ // height above the bar. See [_navigationBar].
+ bottom:
+ (View.of(context).viewPadding.bottom /
+ View.of(context).devicePixelRatio -
+ navigationBar)
+ .clamp(0.0, double.infinity),
+ ),
+ child: TerminalSearchOverlay(
+ notifier: widget.notifier,
+ animation: _searchCurve,
+ onClose: _closeSearch,
+ ),
),
),
- ),
- ],
+ ],
+ ),
),
),
),