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): merge desk tabs and terminal search into one sheet
tonyece68673897c
diff --git a/mobile/lib/phone/desk_add_agent_sheet.dart b/mobile/lib/phone/desk_add_agent_sheet.dartindex c3ffa30e5..194b35748 100644--- a/mobile/lib/phone/desk_add_agent_sheet.dart+++ b/mobile/lib/phone/desk_add_agent_sheet.dart@@ -104,9 +104,9 @@ class _AddAgentSheet extends StatelessWidget {),),),- // The same half-screen the tabs panel keeps, for the same reason: the- // sheet must not stand up and sit down as one account's three agents- // give way to another's dozen.+ // One height, as the tabs panel keeps one, and for the same reason:+ // the sheet must not stand up and sit down as one account's three+ // agents give way to another's dozen.SizedBox(height: MediaQuery.sizeOf(context).height * 0.5,child: ListView.separated(diff --git a/mobile/lib/phone/desk_tab_strip.dart b/mobile/lib/phone/desk_tab_strip.dartindex 0aca358d0..a8c721686 100644--- a/mobile/lib/phone/desk_tab_strip.dart+++ b/mobile/lib/phone/desk_tab_strip.dart@@ -7,17 +7,22 @@ import 'package:lucide_icons_flutter/lucide_icons.dart';import 'package:harness_mobile/shared/theme/app_theme.dart';import 'desk_groups.dart';+import 'sheet_list.dart';-/// The account's tabs as a row of names, with a bar under the one being shown.+/// The account's tabs as a row of pills, the one being shown filled in.////// ```-/// Desktop Docker Other-/// ━━━━━━━+/// (▓Desktop▓) ( Docker ) ( Other ) (+)/// ```///-/// It lives at the top of the tabs popup — see [showDeskTabsPopup] — and picks-/// which tab's agents the row under it lists. Nothing here opens an agent: the-/// name changes what is offered, the card below is what is chosen.+/// It lives at the top of the tabs panel — see [DeskTabsPanel] — and picks+/// which tab's agents the list under it holds. Nothing here opens an agent: the+/// pill changes what is offered, the row below is what is chosen.+///+/// ⚠️ **Pills, not names over an underline.** The sheet around this is drawn+/// the way iOS draws its own — a filled search bar, an inset-grouped list —+/// and a bar under a word is Material's tab. A filled pill says "this one" at+/// the weight of the list it picks, rather than in a 2pt line under it.////// ⚠️ **A tab with nothing this phone can open is drawn dim, but still picked.**/// Its agents are on a machine that is asleep or wants its password. Dropping it@@ -45,7 +50,7 @@ class DeskTabStrip extends StatefulWidget {final List<DeskGroup> groups;/// [DeskGroup.id] of the tab whose agents are listed below. Null is a real- /// value: it is the leftover group, and it wears the bar like any other.+ /// value: it is the leftover group, and it is filled in like any other.final String? selectedId;final void Function(DeskGroup group) onPick;@@ -60,28 +65,26 @@ class DeskTabStrip extends StatefulWidget {/// to change.final void Function(DeskGroup group)? onRename;- /// The row's height, which the popup counts into its own.- ///- /// One 15pt line, the bar under it, and the air that keeps the names off the- /// drag handle above and the cards below.- static const double height = 40;+ /// The row's height: a 32pt pill with 6pt either side of it, which a tap+ /// still lands in — a pill is short for a thumb, the row around it is not.+ static const double height = 44;- /// The popup's own side inset — the measure [showPhoneSheet] gives its rows,- /// so the first name starts on the same line as everything else in a sheet.- static const double sideInset = 20;+ /// The sheet's one side inset — see [kSheetInset] — so the first pill starts+ /// on the field's edge and the group's.+ static const double sideInset = kSheetInset;- /// The gap between two names. Wide enough that two short tabs — `All`, `adu`- /// — read as two, narrow enough that four fit on a phone without scrolling.- static const double _gap = 22;+ /// The gap between two pills: their outlines already part them, so this+ /// only has to keep two of them from reading as one wide one.+ static const double _gap = 8;@overrideState<DeskTabStrip> createState() => _DeskTabStripState();}class _DeskTabStripState extends State<DeskTabStrip> {- /// Rides whichever name is the selected one, so the row can be scrolled to- /// it without knowing how wide any of the others are — names keep their own- /// widths here, so there is no index-times-extent to jump to.+ /// Rides whichever pill is the selected one, so the row can be scrolled to+ /// it without knowing how wide any of the others are — pills keep their+ /// names' own widths, so there is no index-times-extent to jump to.final _selected = GlobalKey();@override@@ -105,12 +108,22 @@ class _DeskTabStripState extends State<DeskTabStrip> {}}+ /// Scrolls the row until the selected name sits in its middle.+ ///+ /// ⚠️ **The row's own scroll, and nothing above it.** `Scrollable.ensureVisible`+ /// walks every scrollable the name sits in, and this row sits inside the+ /// terminal page now — inside the pager that swipes between agents (see+ /// [DeskTabsPanel]). Centring a name there would drag the pager part of a+ /// page sideways, off the agent on screen.void _reveal(Duration duration) {final context = _selected.currentContext;if (context == null || !mounted) return;+ final name = context.findRenderObject();+ final row = Scrollable.maybeOf(context);+ if (name == null || !name.attached || row == null) return;unawaited(- Scrollable.ensureVisible(- context,+ row.position.ensureVisible(+ name,// Centred rather than merely brought inside the edge: a name flush// against the right-hand end reads as the last tab there is.alignment: 0.5,@@ -144,17 +157,17 @@ class _DeskTabStripState extends State<DeskTabStrip> {padding: EdgeInsets.only(left: sideInset,// A full inset only where the row ends in nothing. Beside the- // `+`, the button's own margin is the gap, and a name stopping+ // `+`, the button's own margin is the gap, and a pill stopping// an inset short of it as well reads as a row that ran out// rather than one that scrolls.- right: onAddTab == null ? sideInset : 4,+ right: onAddTab == null ? sideInset : 0,),itemCount: groups.length,separatorBuilder: (context, index) => const SizedBox(width: gap),itemBuilder: (context, index) {final group = groups[index];final selected = group.id == selectedId;- return _DeskTabName(+ return _DeskTabPill(key: selected ? _selected : null,name: group.name,selected: selected,@@ -190,13 +203,13 @@ class _DeskTabStripState extends State<DeskTabStrip> {}}-/// The `+` that opens a tab, at the right-hand end of the names.+/// The `+` that opens a tab: a round pill of its own at the end of the row.////// ⚠️ **An icon alone, and it can be, because of where it stands.** The other/// `+` on this panel — the one that adds an agent to the tab being read — is a-/// full-width row down in the list, carrying the words. Two bare `+`s would be-/// a guess; a mark on the tab row and a labelled row in the agent list are two-/// different things before either is read. See [showDeskTabsPopup].+/// row down in the list, carrying the words. Two bare `+`s would be a guess; a+/// pill among the tab pills and a labelled row in the agent list are two+/// different things before either is read. See [DeskTabsPanel].class _AddTabButton extends StatelessWidget {const _AddTabButton({required this.onTap});@@ -215,17 +228,27 @@ class _AddTabButton extends StatelessWidget {onTap();},child: Padding(- // A thumb's worth of row either side of a 20pt glyph, and the strip's- // own inset on the outside so it lines up with `⋯` in the header.+ // The gap to the last pill on the inside and the strip's inset on the+ // outside are both the button's: a 32pt circle is a small target,+ // and the row around it is what the thumb actually lands in.padding: const EdgeInsets.only(- left: 10,+ left: DeskTabStrip._gap,right: DeskTabStrip.sideInset,),child: Center(- child: Icon(- LucideIcons.plus300,- size: 20,- color: AppPalette.textSecondary,+ child: Container(+ width: _DeskTabPill.height,+ height: _DeskTabPill.height,+ alignment: Alignment.center,+ decoration: BoxDecoration(+ shape: BoxShape.circle,+ border: Border.all(color: AppGlass.hair),+ ),+ child: Icon(+ LucideIcons.plus,+ size: 16,+ color: AppPalette.textSecondary,+ ),),),),@@ -234,15 +257,10 @@ class _AddTabButton extends StatelessWidget {}}-/// One name in the row, with the bar under it while it is the tab being shown.-///-/// ⚠️ **The bar is drawn in a [Stack] rather than under the text in a column.**-/// It has to be exactly as wide as the name it belongs to, and a column in a-/// horizontally scrolling list is laid out against an infinite width — there is-/// no cross-axis measure for a `stretch`ed bar to take. Stacked, the text is-/// the non-positioned child that sizes the whole thing, and the bar spans it.-class _DeskTabName extends StatelessWidget {- const _DeskTabName({+/// One tab in the row: an outlined pill, filled in while it is the tab being+/// shown.+class _DeskTabPill extends StatelessWidget {+ const _DeskTabPill({super.key,required this.name,required this.selected,@@ -260,67 +278,76 @@ class _DeskTabName extends StatelessWidget {final VoidCallback onTap;- /// A double tap on the name. Null on the groups that cannot be renamed, and- /// that is worth more than a dead callback would be: a name with no+ /// A double tap on the pill. Null on the groups that cannot be renamed, and+ /// that is worth more than a dead callback would be: a pill with no/// double-tap recognizer answers a SINGLE tap at once, while one that has to/// wait and see whether a second is coming answers it 300ms later. So the/// tabs that cannot be renamed keep the snappier tap.final VoidCallback? onRename;- static const double _barHeight = 2;- static const double _barGap = 5;+ static const double height = 32;++ /// The longest a name is drawn before it ellipsises. Far wider than any+ /// name a tab is usually given — the row scrolls, and names keep their own+ /// widths — but a name pasted in whole must not make one pill wider than+ /// the phone.+ static const double _maxLabelWidth = 220;@overrideWidget build(BuildContext context) {AppTheme.watch(context);- final color = switch ((reachable, selected)) {- (false, _) => AppPalette.textFaint,- (true, true) => AppPalette.textPrimary,- (true, false) => AppPalette.textSecondary,- };- return GestureDetector(- // Opaque, so the whole height of the row either side of the name takes- // the tap — a 15pt word is a small thing to hit with a thumb.- behavior: HitTestBehavior.opaque,- onTap: _tapped,- onDoubleTap: onRename == null ? null : _renamed,- child: Center(- child: Stack(- children: [- Padding(- padding: const EdgeInsets.only(bottom: _barGap + _barHeight),+ // The tab being shown is filled in the ink the names are written in, with+ // its name cut out of it in the sheet's own colour. One out of reach keeps+ // that shape a step dimmer: it is still the tab you are in while you read+ // why it is empty.+ final fill = !selected+ ? const Color(0x00000000)+ : reachable+ ? AppPalette.textPrimary+ : AppPalette.textSecondary;+ final ink = selected+ ? sheetFill+ : reachable+ ? AppPalette.textSecondary+ : AppPalette.textFaint;+ return Semantics(+ button: true,+ selected: selected,+ child: GestureDetector(+ // Opaque, so the whole height of the row either side of the pill takes+ // the tap — see [DeskTabStrip.height].+ behavior: HitTestBehavior.opaque,+ onTap: _tapped,+ onDoubleTap: onRename == null ? null : _renamed,+ child: Center(+ child: AnimatedContainer(+ duration: AppMotion.swap,+ curve: AppMotion.curve,+ height: height,+ padding: const EdgeInsets.symmetric(horizontal: 14),+ alignment: Alignment.center,+ decoration: BoxDecoration(+ color: fill,+ borderRadius: BorderRadius.circular(height / 2),+ border: Border.all(color: selected ? fill : AppGlass.hair),+ ),+ child: ConstrainedBox(+ constraints: const BoxConstraints(maxWidth: _maxLabelWidth),child: Text(name,maxLines: 1,overflow: TextOverflow.ellipsis,style: TextStyle(- color: color,- fontSize: 15,- // The tab being shown is a weight heavier as well as darker,- // which is what carries it to someone who cannot see the bar- // — the same pairing [PhoneTabBar] uses below.+ color: ink,+ fontSize: 14.5,+ // The tab being shown is a weight heavier as well as filled,+ // which is what carries it to someone who cannot see the+ // fill — the same pairing [PhoneTabBar] uses below.fontWeight: selected ? FontWeight.w600 : FontWeight.w500,- height: 1.2,),),),- if (selected)- Positioned(- left: 0,- right: 0,- bottom: 0,- child: Container(- height: _barHeight,- decoration: BoxDecoration(- // The bar keeps the primary ink even under a dim name: it- // marks where you are, and a tab out of reach is still- // where you are while you are reading it.- color: AppPalette.textPrimary,- borderRadius: BorderRadius.circular(_barHeight / 2),- ),- ),- ),- ],+ ),),),);diff --git a/mobile/lib/phone/desk_tabs_panel.dart b/mobile/lib/phone/desk_tabs_panel.dartnew file mode 100644index 000000000..192c72edd--- /dev/null+++ b/mobile/lib/phone/desk_tabs_panel.dart@@ -0,0 +1,515 @@+import 'dart:async';++import 'package:flutter/material.dart';+import 'package:flutter/services.dart';+import 'package:lucide_icons_flutter/lucide_icons.dart';++import 'package:harness_mobile/core/last_opened_agent.dart' show AgentRef;+import 'package:harness_mobile/shared/theme/app_theme.dart';+import 'package:harness_mobile/state/app_state.dart';++import 'agent_index.dart';+import 'agents_page.dart' show openNewAgent;+import 'desk_add_agent_sheet.dart';+import 'desk_groups.dart';+import 'desk_tab_rename_dialog.dart';+import 'desk_tab_strip.dart';+import 'phone_navigation.dart';+import 'phone_status.dart';+import 'sheet_list.dart';++/// The account's tabs, and the agents inside the one being read — what the+/// terminal's search sheet shows under its field until the field is focused.+///+/// ```+/// (▓Desktop▓) ( Docker ) ( Other ) (+)+/// DESKTOP 2+/// ╭────────────────────────────────╮+/// │ ▣ api-3 ◌ › │+/// │ harness · ⑂ main · Mac mini │+/// │ ────────────────────────────│+/// │ + Add harness to this tab │+/// ╰────────────────────────────────╯+/// ```+///+/// ⚠️ **Two moves, not one.** A tab's pill changes which agents the list below+/// offers and nothing else; opening happens on a row. That is what lets+/// somebody look into another tab — see what is running there — without losing+/// the terminal they are in, which a sheet of tab names could not do.+///+/// ⚠️ **Under the search field, not behind a mark of its own.** This was a+/// sheet of its own, opened from a grid mark in the terminal header, beside a+/// search that was a second screen. Finding an agent by where it is and finding+/// it by name are one errand, so they are one sheet now, opened from the+/// floating Search button and reading the tabs until something is typed — see+/// [TerminalSearchOverlay].+///+/// ⚠️ **The agents scroll DOWN, in one inset group.** They were cards side by+/// side, which put a scroll across the panel at right angles to the one every+/// other list here has — and made a phone read four agents through a+/// letterbox. They were then the Agents tab's own cards ([AgentTile]), until+/// it showed that the search replacing them in place drew the same agents as+/// flat lines: focusing the field swapped one look for another. Both are+/// [SheetRow]s now — see [DeskAgentRow].+///+/// ⚠️ **It fills the height it is given, and the sheet around it gives one+/// height whatever the tab holds.** Sized to its contents, the panel stood up+/// and sat down as tabs were read — a tab of one agent, then a tab of six — and+/// the pills along the top moved with it, so the next tab was somewhere else by+/// the time the thumb got there.+class DeskTabsPanel extends StatefulWidget {+ const DeskTabsPanel({+ super.key,+ required this.notifier,+ required this.onOpen,+ required this.onClose,+ this.showing,+ });++ /// ⚠️ **The groups are rebuilt from here on every change, not passed in+ /// once.** An agent added to a tab from this panel has to appear in it while+ /// the panel is still open — a list computed before the panel was shown+ /// answered a tap by doing nothing visible at all.+ final AppNotifier notifier;++ /// A row tapped: the agent, and the tab it was picked out of — what+ /// [openDeskAgent] takes.+ ///+ /// ⚠️ The caller puts the panel away FIRST: a terminal arriving under a panel+ /// still on its way out is the order every sheet here avoids.+ final void Function(DeskGroup group, AgentEntry entry) onOpen;++ /// Puts the panel away without opening anything here — for the paths that+ /// leave it for another screen, the new-agent form.+ final VoidCallback onClose;++ /// The agent on screen: it decides which tab the panel opens on (see+ /// [activeDeskGroup]), and its row is the one wearing the check. Null opens+ /// on the tab the phone was last in, and checks nothing.+ final AgentRef? showing;++ @override+ State<DeskTabsPanel> createState() => _DeskTabsPanelState();+}++class _DeskTabsPanelState extends State<DeskTabsPanel> {+ /// The tab being read: at first the one the agent on screen belongs to.+ ///+ /// ⚠️ Kept by this state and nothing above it, so a panel that stays built+ /// while something covers it comes back on the tab that was being read — see+ /// [TerminalSearchOverlay], which keeps it built under the results.+ late String? _selectedId = activeDeskGroup(+ widget.notifier,+ _groups,+ widget.showing,+ ).id;++ List<DeskGroup> get _groups =>+ deskGroups(widget.notifier, visibleAgents(agentIndex(widget.notifier)));++ /// The tab being read. Falls back to the first, which is only reachable if+ /// the desk dropped a tab while the panel was open.+ DeskGroup _groupIn(List<DeskGroup> groups) =>+ groups.where((group) => group.id == _selectedId).firstOrNull ??+ groups.first;++ /// Whether [group] can take another agent: a real tab on a desk this phone+ /// may write to. The leftover group is not a tab — there is nothing to add+ /// an agent TO — and neither is the single group a phone with no desk shows.+ bool _canAddTo(DeskGroup group) =>+ group.id != null && widget.notifier.deskWritable;++ /// Every agent this phone could put in a tab: the ones it can actually open,+ /// which is the same test [deskGroups] makes of the ones already in them.+ List<AgentEntry> get _openable => [+ for (final entry in visibleAgents(agentIndex(widget.notifier)))+ if (entry.agent.terminalAvailable) entry,+ ];++ /// The machine a new agent would be made on: the first that can host one,+ /// which is also the form's own first question and changed there. Null where+ /// none can — every machine asleep, or wanting its password — and that is+ /// what leaves "New agent" out of the sheet rather than drawn dead.+ String? get _hostMachineId => [+ for (final machine in filterableMachines(widget.notifier))+ if (phoneMachineStatusOf(machine) == PhoneMachineStatus.ready) machine,+ ].firstOrNull?.machine.machineId;++ AgentRef _refOf(AgentEntry entry) =>+ (machineId: entry.machineId, agentId: entry.agent.id);++ /// Whether an empty [group] is empty because its agents are out of REACH, or+ /// because it holds none at all.+ ///+ /// The two look identical on screen and are nothing alike: the first is a+ /// machine asleep and the agents are still there, the second is a tab that+ /// has been emptied or has only just been made. Read from the desk itself —+ /// [DeskGroup] carries the agents this phone can open, which is by definition+ /// none in both cases.+ bool _everHeldAgents(DeskGroup group) =>+ widget.notifier.deskTabs+ .where((tab) => tab.id == group.id)+ .firstOrNull+ ?.panes+ .isNotEmpty ??+ false;++ /// A double tap on a tab's name.+ ///+ /// ⚠️ **The tab is picked as well as renamed, and not as an afterthought.**+ /// The first tap of the two has already picked it, so the panel below is+ /// showing what is being named — and after a rename the row under the names+ /// would otherwise belong to a different tab than the one just typed.+ void _rename(DeskGroup group) {+ final id = group.id;+ if (id == null) return;+ setState(() => _selectedId = id);+ unawaited(+ showDeskTabRenameDialog(+ context,+ widget.notifier,+ tabId: id,+ currentName: group.name,+ ),+ );+ }++ /// The `+` on the tab row: a tab of its own for an agent picked or made now.+ ///+ /// ⚠️ **The tab is written only once there is something to put in it.** A+ /// tab created up front and then abandoned — the form cancelled, the machine+ /// refusing — would be an empty tab on every computer the person owns, put+ /// there by a tap they took back. For a new agent that means arming+ /// [AppNotifier.openNextAgentInNewDeskTab] and letting the agent's own+ /// arrival make the tab.+ void _addTab() {+ final notifier = widget.notifier;+ final host = _hostMachineId;+ unawaited(+ showDeskAddAgentSheet(+ context,+ title: 'New tab',+ choices: _openable,+ onPick: (entry) {+ final group = DeskGroup(+ id: notifier.createDeskTabFor(+ _refOf(entry),+ name: entry.agent.name,+ ),+ name: entry.agent.name,+ entries: [entry],+ );+ if (group.id == null) return;+ // Opened, not merely listed: the tab exists now and the phone is in+ // it, and a panel that stayed put would say neither.+ widget.onOpen(group, entry);+ },+ onCreate: host == null+ ? null+ : () {+ notifier.openNextAgentInNewDeskTab();+ // Away first, then the form: it is pushed over the terminal,+ // and must not arrive under a panel still on its way out.+ widget.onClose();+ unawaited(+ openNewAgent(+ context,+ notifier,+ host,+ ).whenComplete(notifier.forgetNewDeskTabIntent),+ );+ },+ ),+ );+ }++ /// The `+` at the foot of a tab's list: another agent in the tab being read.+ ///+ /// The panel stays open on the way back — this is a list being filled, and+ /// the agent appears in it under the thumb that added it.+ void _addAgentTo(DeskGroup group) {+ final id = group.id;+ if (id == null) return;+ final notifier = widget.notifier;+ final host = _hostMachineId;+ unawaited(+ showDeskAddAgentSheet(+ context,+ title: 'Add to “${group.name}”',+ choices: [+ for (final entry in _openable)+ if (!group.holds(_refOf(entry))) entry,+ ],+ onPick: (entry) => notifier.addAgentToDeskTab(id, _refOf(entry)),+ onCreate: host == null+ ? null+ : () {+ // The tab the phone is in is the tab an agent made here joins+ // — see [PhoneDesk.adopt] — so this is what aims that.+ notifier.selectDeskTab(id);+ widget.onClose();+ unawaited(openNewAgent(context, notifier, host));+ },+ ),+ );+ }++ @override+ Widget build(BuildContext context) {+ AppTheme.watch(context);+ return ListenableBuilder(+ listenable: widget.notifier,+ builder: (context, _) => _panel(context),+ );+ }++ Widget _panel(BuildContext context) {+ final groups = _groups;+ final group = _groupIn(groups);+ final showing = widget.showing;+ final canAdd = _canAddTo(group);+ final count = group.entries.length + (canAdd ? 1 : 0);+ final padding = EdgeInsets.fromLTRB(+ kSheetInset,+ 0,+ kSheetInset,+ MediaQuery.paddingOf(context).bottom + 16,+ );+ return Column(+ crossAxisAlignment: CrossAxisAlignment.stretch,+ children: [+ DeskTabStrip(+ groups: groups,+ selectedId: group.id,+ onPick: (picked) => setState(() => _selectedId = picked.id),+ // Undrawn on a desk that cannot be written to — see+ // [AppNotifier.deskWritable].+ onAddTab: widget.notifier.deskWritable ? _addTab : null,+ onRename: widget.notifier.deskWritable ? _rename : null,+ ),+ SheetCaption(+ label: group.name,+ // A count only where there is something to count: `0` over a tab+ // whose machine is asleep would say the tab is empty, which is the+ // one thing the sentence under it says it is not.+ count: group.isEmpty ? null : '${group.entries.length}',+ ),+ Expanded(+ // ⚠️ **An empty tab keeps its sentence AND gets the `+`.** The two+ // answer different halves of the same screen: the sentence says why+ // there is nothing here, and the `+` is what to do about it. Dropped+ // in favour of the row, a tab whose machine is asleep silently became+ // a tab that merely had nothing in it.+ child: group.isEmpty+ // A list, not a column, though it holds two things: the height+ // it is given is what the sheet has left over, and on a phone+ // lying on its side that is less than the two of them.+ ? ListView(+ padding: padding,+ children: [+ _TabIsEmpty(everHeldAgents: _everHeldAgents(group)),+ if (canAdd)+ _AddAgentRow(+ tabName: group.name,+ first: true,+ last: true,+ onTap: () => _addAgentTo(group),+ ),+ ],+ )+ : ListView.builder(+ padding: padding,+ itemCount: count,+ itemBuilder: (context, index) {+ // ⚠️ **Last in the group, and a row of it rather than a+ // mark like the `+` on the tab row.** This one adds an+ // agent to the tab being read; that one opens a tab. Two+ // identical marks would be a guess, so the one that could+ // be mistaken carries the words — and closing the group+ // of the tab's agents is itself the sentence "into this+ // list".+ if (index == group.entries.length) {+ return _AddAgentRow(+ tabName: group.name,+ first: index == 0,+ last: true,+ onTap: () => _addAgentTo(group),+ );+ }+ final entry = group.entries[index];+ return DeskAgentRow(+ entry: entry,+ onScreen:+ showing != null &&+ entry.machineId == showing.machineId &&+ entry.agent.id == showing.agentId,+ first: index == 0,+ last: index == count - 1,+ onTap: () => widget.onOpen(group, entry),+ );+ },+ ),+ ),+ ],+ );+ }+}++/// One agent in the tab being read.+///+/// The row the sheet's search draws an agent with too ([SheetSearchRow]), so+/// focusing the field changes which agents are listed and not how one looks.+class DeskAgentRow extends StatelessWidget {+ const DeskAgentRow({+ super.key,+ required this.entry,+ required this.onScreen,+ required this.first,+ required this.last,+ required this.onTap,+ });++ final AgentEntry entry;++ /// The agent on screen. It keeps its row — it is the one you came from, and+ /// the list would read as missing an agent without it — and wears the check+ /// where the others have a chevron.+ final bool onScreen;++ /// Whether this row opens the group, and whether it closes it.+ final bool first, last;++ final VoidCallback onTap;++ @override+ Widget build(BuildContext context) {+ AppTheme.watch(context);+ final agent = entry.agent;+ final project = entry.project;+ return SheetRow(+ first: first,+ last: last,+ selected: onScreen,+ enabled: agent.terminalAvailable,+ onTap: agent.terminalAvailable ? onTap : null,+ leading: SheetEngineTile(+ engine: agent.engine,+ displayName: agent.engineDisplayName,+ ),+ title: Text(+ agent.name,+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: sheetRowTitleStyle(),+ ),+ subtitle: SheetPlaceLine(+ machine: entry.machineName,+ folder: project?.folder,+ branch: project?.branchLabel,+ ),+ trailing: SheetAgentStatus(summary: entry.summary, onScreen: onScreen),+ chevron: !onScreen,+ );+ }+}++/// The `+` at the foot of a tab's agents: one more agent in THIS tab.+///+/// ⚠️ **A row, not a mark, and that is the whole of how it is told apart from+/// the `+` on the tab row above.** They are the same glyph doing two different+/// things, so nothing rests on the glyph: this one is a row of the group it+/// fills, closes it, is written in the accent iOS gives a row that acts rather+/// than opens, and says which tab it fills. See [DeskTabStrip].+class _AddAgentRow extends StatelessWidget {+ const _AddAgentRow({+ required this.tabName,+ required this.first,+ required this.last,+ required this.onTap,+ });++ final String tabName;+ final bool first, last;+ final VoidCallback onTap;++ @override+ Widget build(BuildContext context) {+ AppTheme.watch(context);+ final accent = AppPalette.accentOnSurface;+ return SheetRow(+ first: first,+ last: last,+ // ⚠️ The words on the row are "this tab", which is clear under a thumb+ // that has just read the tab's name and useless read aloud on its own.+ // Read aloud, the row names the tab it fills.+ semanticsLabel: 'Add harness to $tabName',+ leading: SheetTile(+ child: Icon(LucideIcons.plus, size: 18, color: accent),+ ),+ title: Text(+ 'Add harness to this tab',+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: sheetRowTitleStyle().copyWith(color: accent),+ ),+ // It adds here rather than going anywhere.+ chevron: false,+ onTap: () {+ HapticFeedback.selectionClick();+ onTap();+ },+ );+ }+}++/// A tab whose agents are all out of reach — the machine they run on is asleep+/// or wants its password. The tab is still listed and still opens to this,+/// because a tab missing from the row reads as one somebody deleted.+class _TabIsEmpty extends StatelessWidget {+ const _TabIsEmpty({required this.everHeldAgents});++ /// Whether the tab holds agents this phone cannot reach, as opposed to no+ /// agents at all — see [_DeskTabsPanelState._everHeldAgents].+ final bool everHeldAgents;++ @override+ Widget build(BuildContext context) {+ AppTheme.watch(context);+ return Padding(+ // Under the caption's own first letter, and clear of the row below it.+ padding: const EdgeInsets.fromLTRB(+ kSheetCaptionInset - kSheetInset,+ 2,+ kSheetCaptionInset - kSheetInset,+ 14,+ ),+ child: Text(+ everHeldAgents+ ? 'Nothing here this phone can open — the machine these harnesses run '+ 'on is asleep or wants its password.'+ : 'This tab has no harnesses yet.',+ style: TextStyle(+ color: AppPalette.textSecondary,+ fontSize: 13.5,+ height: 1.4,+ ),+ ),+ );+ }+}++/// Open [entry] from [group]: the phone is in that tab from here.+///+/// ⚠️ The order matters. [AppNotifier.selectDeskTab] is what settles which tab+/// an agent that sits on TWO of them belongs to (see [activeDeskGroup]); set+/// after the open, it would be read a frame too late and the panel would come+/// back barring the tab that was left.+void openDeskAgent(+ BuildContext context,+ AppNotifier notifier,+ DeskGroup group,+ AgentEntry entry,+) {+ notifier.selectDeskTab(group.id);+ openAgent(context, notifier, entry.machineId, entry.agent.id);+}diff --git a/mobile/lib/phone/desk_tabs_popup.dart b/mobile/lib/phone/desk_tabs_popup.dartdeleted file mode 100644index ce8e24c35..000000000--- a/mobile/lib/phone/desk_tabs_popup.dart+++ /dev/null@@ -1,521 +0,0 @@-import 'dart:async';--import 'package:flutter/material.dart';-import 'package:flutter/services.dart';-import 'package:lucide_icons_flutter/lucide_icons.dart';--import 'package:harness_mobile/core/last_opened_agent.dart' show AgentRef;-import 'package:harness_mobile/shared/theme/app_theme.dart';-import 'package:harness_mobile/state/app_state.dart';--import 'agent_index.dart';-import 'agent_tile.dart';-import 'agents_page.dart' show openNewAgent;-import 'desk_add_agent_sheet.dart';-import 'desk_groups.dart';-import 'desk_tab_rename_dialog.dart';-import 'desk_tab_strip.dart';-import 'phone_card.dart';-import 'phone_navigation.dart';-import 'phone_status.dart';--/// The account's tabs, and the agents inside the one being read, as a panel up-/// from the bottom of the terminal.-///-/// ```-/// ────────────────────────────────-/// Desktop Docker Other-/// ───────-/// ┌──────────────────────────┐-/// │ ◆ api-3 Live › │-/// │ harness · Mac mini │-/// ├──────────────────────────┤-/// │ ◆ web Idle › │-/// │ site · Mac mini │-/// └──────────────────────────┘-/// ```-///-/// ⚠️ **Two moves, not one.** A tab name changes which agents the list below-/// offers and nothing else; opening happens on a row. That is what lets-/// somebody look into another tab — see what is running there — without losing-/// the terminal they are in, which a sheet of tab names could not do.-///-/// ⚠️ **From the bottom, because that is where the thumb is.** The mark that-/// opens it rides the header at the top of the phone, but the list it opens is-/// a list to reach into, so it comes up from the bottom edge like every other-/// phone sheet here.-///-/// ⚠️ **The agents scroll DOWN, and they are the Agents tab's own rows.** They-/// were cards side by side, which put a scroll across the panel at right-/// angles to the one every other list here has — and made a phone read four-/// agents through a letterbox. A column reads at a glance, takes long names-/// whole, and is the row an agent already has everywhere else ([AgentTile]).-///-/// [showing] is the agent on screen: it decides which tab the panel opens on-/// (see [activeDeskGroup]), and its row is the one wearing the rim.-Future<void> showDeskTabsPopup(- BuildContext context,- AppNotifier notifier, {- required AgentRef showing,-}) {- final groups = deskGroups(notifier, visibleAgents(agentIndex(notifier)));- final active = activeDeskGroup(notifier, groups, showing);- return showModalBottomSheet<void>(- context: context,- useRootNavigator: true,- showDragHandle: true,- backgroundColor: AppPalette.panelBg,- // A column of rows outgrows Flutter's 9/16 cap, which is not a height- // anything here asked for — see [_DeskTabsPanelState.build] for the one- // this panel keeps.- isScrollControlled: true,- builder: (sheetContext) => _DeskTabsPanel(- notifier: notifier,- initialId: active.id,- showing: showing,- // Close first, then open: the terminal this pushes must not arrive- // underneath a panel that is still animating out — the same order every- // row in [showPhoneSheet] takes.- onOpen: (group, entry) {- Navigator.of(sheetContext).pop();- openDeskAgent(context, notifier, group, entry);- },- ),- );-}--/// The rows' own side inset: [phoneListPadding]'s 16, not the strip's 20. A-/// card carries its content 13 further in again, so rows lined up on the names-/// above them read as indented from them.-const double _sideInset = 16;--/// The panel itself: the tab names, and the rows of whichever tab is picked.-class _DeskTabsPanel extends StatefulWidget {- const _DeskTabsPanel({- required this.notifier,- required this.initialId,- required this.showing,- required this.onOpen,- });-- /// ⚠️ **The groups are rebuilt from here on every change, not passed in- /// once.** An agent added to a tab from this panel has to appear in it while- /// the panel is still open — a list computed before the sheet was shown- /// answered a tap by doing nothing visible at all.- final AppNotifier notifier;-- /// The tab the panel opens on — the one the agent on screen belongs to.- final String? initialId;-- final AgentRef showing;-- final void Function(DeskGroup group, AgentEntry entry) onOpen;-- @override- State<_DeskTabsPanel> createState() => _DeskTabsPanelState();-}--class _DeskTabsPanelState extends State<_DeskTabsPanel> {- late String? _selectedId = widget.initialId;-- List<DeskGroup> get _groups =>- deskGroups(widget.notifier, visibleAgents(agentIndex(widget.notifier)));-- /// The tab being read. Falls back to the first, which is only reachable if- /// the desk dropped a tab while the panel was open.- DeskGroup _groupIn(List<DeskGroup> groups) =>- groups.where((group) => group.id == _selectedId).firstOrNull ??- groups.first;-- /// Whether [group] can take another agent: a real tab on a desk this phone- /// may write to. The leftover group is not a tab — there is nothing to add- /// an agent TO — and neither is the single group a phone with no desk shows.- bool _canAddTo(DeskGroup group) =>- group.id != null && widget.notifier.deskWritable;-- /// Every agent this phone could put in a tab: the ones it can actually open,- /// which is the same test [deskGroups] makes of the ones already in them.- List<AgentEntry> get _openable => [- for (final entry in visibleAgents(agentIndex(widget.notifier)))- if (entry.agent.terminalAvailable) entry,- ];-- /// The machine a new agent would be made on: the first that can host one,- /// which is also the form's own first question and changed there. Null where- /// none can — every machine asleep, or wanting its password — and that is- /// what leaves "New agent" out of the sheet rather than drawn dead.- String? get _hostMachineId => [- for (final machine in filterableMachines(widget.notifier))- if (phoneMachineStatusOf(machine) == PhoneMachineStatus.ready) machine,- ].firstOrNull?.machine.machineId;-- AgentRef _refOf(AgentEntry entry) =>- (machineId: entry.machineId, agentId: entry.agent.id);-- /// Whether an empty [group] is empty because its agents are out of REACH, or- /// because it holds none at all.- ///- /// The two look identical on screen and are nothing alike: the first is a- /// machine asleep and the agents are still there, the second is a tab that- /// has been emptied or has only just been made. Read from the desk itself —- /// [DeskGroup] carries the agents this phone can open, which is by definition- /// none in both cases.- bool _everHeldAgents(DeskGroup group) =>- widget.notifier.deskTabs- .where((tab) => tab.id == group.id)- .firstOrNull- ?.panes- .isNotEmpty ??- false;-- /// A double tap on a tab's name.- ///- /// ⚠️ **The tab is picked as well as renamed, and not as an afterthought.**- /// The first tap of the two has already picked it, so the panel below is- /// showing what is being named — and after a rename the row under the names- /// would otherwise belong to a different tab than the one just typed.- void _rename(DeskGroup group) {- final id = group.id;- if (id == null) return;- setState(() => _selectedId = id);- unawaited(- showDeskTabRenameDialog(- context,- widget.notifier,- tabId: id,- currentName: group.name,- ),- );- }-- /// The `+` on the tab row: a tab of its own for an agent picked or made now.- ///- /// ⚠️ **The tab is written only once there is something to put in it.** A- /// tab created up front and then abandoned — the form cancelled, the machine- /// refusing — would be an empty tab on every computer the person owns, put- /// there by a tap they took back. For a new agent that means arming- /// [AppNotifier.openNextAgentInNewDeskTab] and letting the agent's own- /// arrival make the tab.- void _addTab() {- final notifier = widget.notifier;- final host = _hostMachineId;- unawaited(- showDeskAddAgentSheet(- context,- title: 'New tab',- choices: _openable,- onPick: (entry) {- final group = DeskGroup(- id: notifier.createDeskTabFor(- _refOf(entry),- name: entry.agent.name,- ),- name: entry.agent.name,- entries: [entry],- );- if (group.id == null) return;- // Opened, not merely listed: the tab exists now and the phone is in- // it, and a panel that stayed put would say neither.- widget.onOpen(group, entry);- },- onCreate: host == null- ? null- : () {- notifier.openNextAgentInNewDeskTab();- Navigator.of(context).pop();- unawaited(- openNewAgent(- context,- notifier,- host,- ).whenComplete(notifier.forgetNewDeskTabIntent),- );- },- ),- );- }-- /// The `+` at the foot of a tab's list: another agent in the tab being read.- ///- /// The panel stays open on the way back — this is a list being filled, and- /// the agent appears in it under the thumb that added it.- void _addAgentTo(DeskGroup group) {- final id = group.id;- if (id == null) return;- final notifier = widget.notifier;- final host = _hostMachineId;- unawaited(- showDeskAddAgentSheet(- context,- title: 'Add to “${group.name}”',- choices: [- for (final entry in _openable)- if (!group.holds(_refOf(entry))) entry,- ],- onPick: (entry) => notifier.addAgentToDeskTab(id, _refOf(entry)),- onCreate: host == null- ? null- : () {- // The tab the phone is in is the tab an agent made here joins- // — see [PhoneDesk.adopt] — so this is what aims that.- notifier.selectDeskTab(id);- Navigator.of(context).pop();- unawaited(openNewAgent(context, notifier, host));- },- ),- );- }-- @override- Widget build(BuildContext context) {- AppTheme.watch(context);- return ListenableBuilder(- listenable: widget.notifier,- builder: (context, _) => _panel(context),- );- }-- Widget _panel(BuildContext context) {- final groups = _groups;- final group = _groupIn(groups);- return SafeArea(- child: Column(- mainAxisSize: MainAxisSize.min,- crossAxisAlignment: CrossAxisAlignment.stretch,- children: [- DeskTabStrip(- groups: groups,- selectedId: group.id,- onPick: (picked) => setState(() => _selectedId = picked.id),- // Undrawn on a desk that cannot be written to — see- // [AppNotifier.deskWritable].- onAddTab: widget.notifier.deskWritable ? _addTab : null,- onRename: widget.notifier.deskWritable ? _rename : null,- ),- const SizedBox(height: 6),- // ⚠️ **One height, whatever the tab holds.** Sized to its contents,- // the panel stood up and sat down as tabs were read — a tab of one- // agent, then a tab of six — and the names along the top moved with- // it, so the next tab was somewhere else by the time the thumb got- // there. Half the screen: enough for four rows, and the terminal- // keeps the other half.- SizedBox(- height: MediaQuery.sizeOf(context).height * 0.5,- // ⚠️ **An empty tab keeps its sentence AND gets the `+`.** The two- // answer different halves of the same screen: the sentence says- // why there is nothing here, and the `+` is what to do about it.- // Dropped in favour of the row, a tab whose machine is asleep- // silently became a tab that merely had nothing in it.- child: group.isEmpty- ? Column(- crossAxisAlignment: CrossAxisAlignment.stretch,- children: [- _TabIsEmpty(everHeldAgents: _everHeldAgents(group)),- if (_canAddTo(group))- Padding(- padding: const EdgeInsets.symmetric(- horizontal: _sideInset,- ),- child: _AddAgentRow(- tabName: group.name,- onTap: () => _addAgentTo(group),- ),- ),- ],- )- : ListView.separated(- padding: EdgeInsets.fromLTRB(- _sideInset,- 4,- _sideInset,- MediaQuery.paddingOf(context).bottom + 8,- ),- itemCount:- group.entries.length + (_canAddTo(group) ? 1 : 0),- separatorBuilder: (context, index) =>- const SizedBox(height: kPhoneCardGap),- itemBuilder: (context, index) {- // ⚠️ **Last in the list, and shaped like the rows above- // it rather than like the `+` on the tab row.** This one- // adds an agent to the tab being read; that one opens a- // tab. Two identical marks would be a guess, so the one- // that could be mistaken carries the words — and standing- // IN the list is itself the sentence "into this list".- if (index == group.entries.length) {- return _AddAgentRow(- tabName: group.name,- onTap: () => _addAgentTo(group),- );- }- final entry = group.entries[index];- final showing =- entry.machineId == widget.showing.machineId &&- entry.agent.id == widget.showing.agentId;- return AgentTile(- machine: entry.machine,- agent: entry.agent,- // The agent already on screen keeps its row — it is the- // one you came from, and the list would read as missing- // an agent without it — and wears the accent rim.- border: showing- ? Border.all(- color: AppPalette.accentOnSurface,- width: 1.5,- )- : null,- onTap: () => widget.onOpen(group, entry),- );- },- ),- ),- ],- ),- );- }-}--/// The `+` at the foot of a tab's agents: one more agent in THIS tab.-///-/// ⚠️ **A row, not a mark, and that is the whole of how it is told apart from-/// the `+` on the tab row above.** They are the same glyph doing two different-/// things, so nothing rests on the glyph: this one is as wide as the agent-/// rows, sits at the end of them, is drawn in the dashes that mean "not filled-/// in yet", and says which tab it fills. See [DeskTabStrip].-class _AddAgentRow extends StatelessWidget {- const _AddAgentRow({required this.tabName, required this.onTap});-- final String tabName;- final VoidCallback onTap;-- @override- Widget build(BuildContext context) {- AppTheme.watch(context);- return Semantics(- button: true,- label: 'Add harness to $tabName',- // ⚠️ The words on the row are "this tab", which is clear under a thumb- // that has just read the tab's name and useless read aloud on its own.- // Excluded, the row announces the tab it fills.- excludeSemantics: true,- child: GestureDetector(- behavior: HitTestBehavior.opaque,- onTap: () {- HapticFeedback.selectionClick();- onTap();- },- child: CustomPaint(- painter: _DashedRim(color: AppGlass.hair),- child: SizedBox(- height: 56,- child: Row(- mainAxisAlignment: MainAxisAlignment.center,- children: [- Icon(- LucideIcons.plus300,- size: 18,- color: AppPalette.textSecondary,- ),- const SizedBox(width: 8),- Flexible(- child: Text(- 'Add harness to this tab',- maxLines: 1,- overflow: TextOverflow.ellipsis,- style: TextStyle(- color: AppPalette.textSecondary,- fontSize: 14.5,- fontWeight: FontWeight.w500,- ),- ),- ),- ],- ),- ),- ),- ),- );- }-}--/// The dashes around [_AddAgentRow]. A card's own rim is a hairline all the way-/// round, which is what every FILLED row here wears; broken, it reads as a-/// place for a row rather than as one.-class _DashedRim extends CustomPainter {- const _DashedRim({required this.color});-- final Color color;-- static const double _radius = 14;- static const double _dash = 5;- static const double _gap = 4;-- @override- void paint(Canvas canvas, Size size) {- final rim = Path()- ..addRRect(- RRect.fromRectAndRadius(- Offset.zero & size,- const Radius.circular(_radius),- ),- );- final brush = Paint()- ..style = PaintingStyle.stroke- ..strokeWidth = 1- ..color = color;- for (final metric in rim.computeMetrics()) {- var at = 0.0;- while (at < metric.length) {- canvas.drawPath(- metric.extractPath(at, (at + _dash).clamp(0, metric.length)),- brush,- );- at += _dash + _gap;- }- }- }-- @override- bool shouldRepaint(_DashedRim old) => old.color != color;-}--/// A tab whose agents are all out of reach — the machine they run on is asleep-/// or wants its password. The tab is still listed and still opens to this,-/// because a tab missing from the row reads as one somebody deleted.-class _TabIsEmpty extends StatelessWidget {- const _TabIsEmpty({required this.everHeldAgents});-- /// Whether the tab holds agents this phone cannot reach, as opposed to no- /// agents at all — see [_DeskTabsPanelState._everHeldAgents].- final bool everHeldAgents;-- @override- Widget build(BuildContext context) {- AppTheme.watch(context);- return Padding(- padding: const EdgeInsets.fromLTRB(_sideInset, 10, _sideInset, 18),- child: Text(- everHeldAgents- ? 'Nothing here this phone can open — the machine these harnesses run '- 'on is asleep or wants its password.'- : 'This tab has no harnesses yet.',- style: TextStyle(color: AppPalette.textSecondary, fontSize: 13.5),- ),- );- }-}--/// Open [entry] from [group]: the phone is in that tab from here.-///-/// ⚠️ The order matters. [AppNotifier.selectDeskTab] is what settles which tab-/// an agent that sits on TWO of them belongs to (see [activeDeskGroup]); set-/// after the open, it would be read a frame too late and the panel would come-/// back barring the tab that was left.-void openDeskAgent(- BuildContext context,- AppNotifier notifier,- DeskGroup group,- AgentEntry entry,-) {- notifier.selectDeskTab(group.id);- openAgent(context, notifier, entry.machineId, entry.agent.id);-}diff --git a/mobile/lib/phone/phone_search_controller.dart b/mobile/lib/phone/phone_search_controller.dartindex 6ca0accd2..a145b510c 100644--- a/mobile/lib/phone/phone_search_controller.dart+++ b/mobile/lib/phone/phone_search_controller.dart@@ -143,6 +143,16 @@ class PhoneSearchController extends ChangeNotifier {return true;}+ /// Back to an empty box: no query, and out of any project or machine chosen+ /// on the way — what a search that was cancelled opens on next time.+ void reset() {+ if (query.isEmpty && _groupScope == null) return;+ _groupScope = null;+ query = '';+ _filter();+ notifyListeners();+ }+/// What a tap does: scope to a group, take a `?` row's mode, or hand the row/// back for the caller to open. Null when the tap was absorbed here.PhoneDestination? submit(PhoneDestination row) {diff --git a/mobile/lib/phone/phone_search_field.dart b/mobile/lib/phone/phone_search_field.dartindex 3fe6a90c1..08e2861a4 100644--- a/mobile/lib/phone/phone_search_field.dart+++ b/mobile/lib/phone/phone_search_field.dart@@ -5,6 +5,7 @@ import 'package:harness_mobile/shared/theme/app_theme.dart';import 'composing_keyboard.dart';import 'phone_search_controller.dart';+import 'sheet_list.dart';/// The search page's whole header: one bar, with the way out inside it.///@@ -17,6 +18,8 @@ import 'phone_search_controller.dart';/// the edge swipe, Android's back button and the chevron every other page wears/// already say; the chevron takes the place of the magnifier, which the hint/// text made redundant.+///+/// The terminal's sheet draws its own — see [SheetSearchField].class PhoneSearchField extends StatelessWidget {const PhoneSearchField({super.key,@@ -100,6 +103,10 @@ class PhoneSearchField extends StatelessWidget {onChanged: onChanged,autofocus: autofocus,hintText: hintText,+ // A size down from the query's own 16pt: the hint spells out+ // four modes and has to survive a 390pt screen without+ // ellipsing the last of them.+ hintStyle: TextStyle(color: AppPalette.textFaint, fontSize: 13),),),_ClearButton(controller: controller, onTap: onClear),@@ -110,6 +117,189 @@ class PhoneSearchField extends StatelessWidget {}}+/// The terminal sheet's field: iOS's own search bar — a filled box with the+/// magnifier at its head, and "Cancel" beside it while the sheet is searching.+///+/// ```+/// ┌─────────────────────────┐+/// │ ⌕ Search harnesses │ Cancel+/// └─────────────────────────┘+/// ```+///+/// ⚠️ **Not [PhoneSearchField], though it types the same.** That one is a+/// page's header — a rimmed bar with the way back inside it. This one sits in+/// a sheet the system's own sheets are drawn like, over a list drawn like+/// iOS's grouped lists, and a rimmed Material box at the top of it was the one+/// thing on the sheet speaking another language. What is typed is set up+/// identically — both hand their text to [_QueryInput].+///+/// ⚠️ **No rim on focus.** Cancel sliding in is what says the field has the+/// keyboard — the caret and the word are iOS's own way of saying it, and a+/// ring on top of them would be the same news told twice.+///+/// The hint names harnesses and nothing else: the modes `>` `#` `@` `?` are+/// offered as chips under the field once it is focused (see+/// `terminal_search.dart`), which is room this box never had to spell them out+/// in.+class SheetSearchField extends StatelessWidget {+ const SheetSearchField({+ super.key,+ required this.controller,+ required this.focus,+ required this.onChanged,+ required this.onClear,+ required this.hintText,+ this.onCancel,+ });++ final TextEditingController controller;+ final FocusNode focus;+ final ValueChanged<String> onChanged;+ final VoidCallback onClear;+ final String hintText;++ /// "Cancel", beside the box. Null leaves it out.+ ///+ /// Set for as long as the sheet is searching: it ends the SEARCH — results+ /// out, tabs back — and leaves the sheet up. It slides in as it is set and+ /// out as it is cleared, the box giving it room as it comes; see+ /// [_CancelButton].+ final VoidCallback? onCancel;++ /// The box's height — `UISearchBar`'s, a size under a row's so the field+ /// reads as part of the sheet's chrome rather than as its first row.+ static const double _height = 36;++ @override+ Widget build(BuildContext context) {+ AppTheme.watch(context);+ return Padding(+ // Close under the grip, and closer still to what follows: the pills and+ // the chips under it bring 6pt of their own, so the two gaps land level.+ padding: const EdgeInsets.fromLTRB(16, 6, 16, 4),+ child: Row(+ children: [+ Expanded(+ child: GestureDetector(+ // The magnifier is part of the box, and a tap on it is a tap on+ // the field — the TextField itself only reaches from the hint on.+ onTap: focus.requestFocus,+ child: Container(+ height: _height,+ padding: const EdgeInsets.symmetric(horizontal: 8),+ decoration: BoxDecoration(+ // The rows' own fill: iOS fills its search field with the+ // same lift over the sheet as the cells below it, so the+ // box reads as part of the list it searches.+ color: sheetRowFill,+ borderRadius: BorderRadius.circular(10),+ ),+ child: Row(+ children: [+ Icon(+ LucideIcons.search,+ size: 16,+ color: AppPalette.textSecondary,+ ),+ const SizedBox(width: 6),+ Expanded(+ child: _QueryInput(+ controller: controller,+ focus: focus,+ onChanged: onChanged,+ // The sheet is opened to read its tabs, and a keyboard+ // raised with it would cover half of them.+ autofocus: false,+ hintText: hintText,+ // The query's own size, and ink a step under it: the+ // hint is one short phrase here, and iOS draws its+ // placeholder bright enough to be read at a glance.+ hintStyle: TextStyle(+ color: AppPalette.textSecondary,+ fontSize: 16,+ ),+ ),+ ),+ _ClearButton(controller: controller, onTap: onClear),+ ],+ ),+ ),+ ),+ ),+ _CancelButton(onTap: onCancel),+ ],+ ),+ );+ }+}++/// "Cancel" — see [SheetSearchField.onCancel].+///+/// ⚠️ **Kept built while it leaves, and dead while it does.** The word has to+/// be on screen to be seen sliding out; taken down with the search, the box+/// would jump back to its full width over a gap. And the tap that ended the+/// search must not land on it a second time on the way out.+class _CancelButton extends StatelessWidget {+ const _CancelButton({required this.onTap});++ final VoidCallback? onTap;++ static const Duration _slide = Duration(milliseconds: 250);++ @override+ Widget build(BuildContext context) {+ AppTheme.watch(context);+ final onTap = this.onTap;+ return TweenAnimationBuilder<double>(+ tween: Tween(end: onTap == null ? 0 : 1),+ duration: _slide,+ curve: Curves.easeOutCubic,+ builder: (context, shown, child) => shown == 0+ ? const SizedBox.shrink()+ : ClipRect(+ child: Align(+ // Pinned by its LEFT edge to the room the box gives up, so the+ // word arrives from the right-hand edge of the screen and+ // leaves the same way.+ alignment: Alignment.centerLeft,+ widthFactor: shown,+ child: Opacity(opacity: shown, child: child),+ ),+ ),+ child: Semantics(+ button: true,+ enabled: onTap != null,+ child: GestureDetector(+ behavior: HitTestBehavior.opaque,+ onTap: onTap,+ child: Padding(+ // Padding, not a gap: the space between the box and the word is+ // part of the word's target.+ padding: const EdgeInsets.only(left: 12),+ child: SizedBox(+ height: SheetSearchField._height,+ child: Center(+ child: Text(+ 'Cancel',+ maxLines: 1,+ style: TextStyle(+ // The accent the caret already wears: the word belongs to+ // the state the caret is in, and goes with it. Regular+ // weight, as the system's own Cancel is — it is a way out,+ // not the thing the sheet is for.+ color: AppPalette.accentOnSurface,+ fontSize: 16,+ ),+ ),+ ),+ ),+ ),+ ),+ ),+ );+ }+}+/// The bar's full height and a thumb's width, not the glyph's: the chevron sits/// against the bar's rounded edge, where a miss is the easiest to make.class _BackButton extends StatelessWidget {@@ -147,6 +337,7 @@ class _QueryInput extends StatelessWidget {required this.onChanged,required this.autofocus,required this.hintText,+ required this.hintStyle,});final TextEditingController controller;@@ -155,6 +346,11 @@ class _QueryInput extends StatelessWidget {final bool autofocus;final String hintText;+ /// The hint's size and ink, which is the one thing the two fields that+ /// share this input disagree on — see the call sites for why each is sized+ /// as it is.+ final TextStyle hintStyle;+@overrideWidget build(BuildContext context) {AppTheme.watch(context);@@ -179,8 +375,9 @@ class _QueryInput extends StatelessWidget {// — and a capital forced onto the first letter of one is a wrong query.textCapitalization: TextCapitalization.none,// With the decoration's padding zeroed below, the field is exactly one line- // tall inside a 44pt box; this is what centres that line on the chevron- // beside it instead of letting it sit on the box's top edge.+ // tall inside its box (44pt on the page, 36 in the sheet); this is what+ // centres that line on the chevron or magnifier beside it instead of+ // letting it sit on the box's top edge.textAlignVertical: TextAlignVertical.center,style: TextStyle(color: AppPalette.textPrimary, fontSize: 16),cursorColor: AppPalette.accentOnSurface,@@ -201,15 +398,13 @@ class _QueryInput extends StatelessWidget {focusedErrorBorder: InputBorder.none,disabledBorder: InputBorder.none,// The theme also fills these, and both would draw on top of the box: a- // `surfaceContainerHighest` fill over the rim's own, and Material's- // phone-sized padding over the 44pt height set above.+ // `surfaceContainerHighest` fill over the box's own, and Material's+ // phone-sized padding over the box's height.filled: false,contentPadding: EdgeInsets.zero,constraints: const BoxConstraints(),hintText: hintText,- // A size down from the query's own 16pt: the hint spells out four modes- // and has to survive a 390pt screen without ellipsing the last of them.- hintStyle: TextStyle(color: AppPalette.textFaint, fontSize: 13),+ hintStyle: hintStyle,),);}diff --git a/mobile/lib/phone/phone_search_results.dart b/mobile/lib/phone/phone_search_results.dartindex 478f52b42..38f13333c 100644--- a/mobile/lib/phone/phone_search_results.dart+++ b/mobile/lib/phone/phone_search_results.dart@@ -3,6 +3,7 @@ import 'dart:async';import 'package:flutter/material.dart';import 'package:lucide_icons_flutter/lucide_icons.dart';+import 'package:harness_mobile/core/last_opened_agent.dart' show AgentRef;import 'package:harness_mobile/shared/theme/app_theme.dart';import 'package:harness_mobile/shared/widgets/empty_state.dart';import 'package:harness_mobile/state/app_state.dart';@@ -15,6 +16,8 @@ import 'phone_search_controller.dart';import 'phone_search_rank.dart';import 'phone_search_row.dart';import 'resume_agent.dart';+import 'sheet_list.dart';+import 'sheet_search_row.dart';/// What the query reaches, drawn.///@@ -39,6 +42,8 @@ class PhoneSearchResults extends StatefulWidget {required this.notifier,required this.controller,this.onOpen,+ this.grouped = false,+ this.showing,});final AppNotifier notifier;@@ -52,6 +57,16 @@ class PhoneSearchResults extends StatefulWidget {/// search away first. Null on [PhoneSearchPage], where the pop does it.final VoidCallback? onOpen;+ /// Draws the rows as one inset group of [SheetSearchRow]s — the terminal+ /// sheet's list, whose tabs are drawn the same way — rather than the page's+ /// flat list in the terminal's face. What is listed, and what a tap does, is+ /// the same either way.+ final bool grouped;++ /// The agent the terminal sheet was opened over, whose row wears the check+ /// in the grouped list. Unread by the flat one.+ final AgentRef? showing;+@overrideState<PhoneSearchResults> createState() => _PhoneSearchResultsState();}@@ -101,6 +116,7 @@ class _PhoneSearchResultsState extends State<PhoneSearchResults> {AppTheme.watch(context);final search = widget.controller;final rows = search.rows;+ if (widget.grouped) return _grouped(search, rows);if (rows.isEmpty) return _empty(search);final terms = phoneSearchTerms(search.matchQuery);final now = DateTime.now();@@ -137,16 +153,64 @@ class _PhoneSearchResultsState extends State<PhoneSearchResults> {},);- Widget _empty(PhoneSearchController search) {+ /// The rows as the terminal sheet lists them — see [grouped].+ Widget _grouped(PhoneSearchController search, List<PhoneDestination> rows) {+ final bottom = MediaQuery.paddingOf(context).bottom + 16;+ if (rows.isEmpty) {+ // ⚠️ **In a list, though it is one thing.** The sheet can be left a+ // couple of rows' height above the keyboard, and the empty state is+ // taller than that — laid out bare, it would overflow the sheet.+ return ListView(+ keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag,+ padding: EdgeInsets.fromLTRB(kSheetInset, 8, kSheetInset, bottom),+ children: [_empty(search, compact: true)],+ );+ }+ final terms = phoneSearchTerms(search.matchQuery);+ final previews = widget.notifier.sessionPreviews;+ final showing = widget.showing;+ return ListView.builder(+ // As in the flat list: dragging is how a result is reached with the+ // keyboard still up.+ keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag,+ // No top padding: the caption or the chips over the list end in the gap+ // a group keeps from what labels it.+ padding: EdgeInsets.fromLTRB(kSheetInset, 0, kSheetInset, bottom),+ itemCount: rows.length,+ itemBuilder: (context, index) {+ final row = rows[index];+ final entry = row.entry;+ return SheetSearchRow(+ row: row,+ terms: terms,+ openable: search.canSubmit(row),+ resuming: _resuming == row.id,+ busy: _resuming != null,+ quote: phoneContentSnippet(row, terms, previews),+ onScreen:+ showing != null &&+ entry != null &&+ entry.machineId == showing.machineId &&+ entry.agent.id == showing.agentId,+ first: index == 0,+ last: index == rows.length - 1,+ onTap: () => _tap(row),+ );+ },+ );+ }++ Widget _empty(PhoneSearchController search, {bool compact = false}) {if (search.total == 0 && search.matchQuery.trim().isEmpty) {- return const EmptyState(+ return EmptyState(icon: LucideIcons.laptopMinimal300,title: 'Nothing to search yet',message: 'Link a machine and its harnesses will be findable from here.',+ compact: compact,);}return EmptyState.noMatches(- compact: false,+ compact: compact,message: 'Nothing matches “${search.matchQuery.trim()}”.',);}diff --git a/mobile/lib/phone/phone_search_row_trailing.dart b/mobile/lib/phone/phone_search_row_trailing.dartindex e64273b63..20d43c44c 100644--- a/mobile/lib/phone/phone_search_row_trailing.dart+++ b/mobile/lib/phone/phone_search_row_trailing.dart@@ -39,34 +39,37 @@ class PhoneSearchTrailing extends StatelessWidget {Widget build(BuildContext context) {AppTheme.watch(context);if (resuming) return const _Spinner();- final badge = _badge;+ final badge = phoneSearchBadge(row, openable: openable);return badge == null ? const SizedBox.shrink() : _Badge(badge);}+}- String? get _badge {- final machine = row.machine;- return switch (row.kind) {- // Saved work, not a dead row: the tap resumes it and opens it. Said- // plainly because the wait that follows is a second or two of nothing.- // Stopped work with no conversation to reopen says so in the desktop's- // words, rather than the `No terminal` of a live agent that lost its pane.- PhoneDestinationKind.agent => switch (row.entry?.agent) {- final agent? when agent.isStopped =>- openable ? 'Stopped' : 'Resume unavailable',- _ => openable ? null : 'No terminal',- },- PhoneDestinationKind.machine => switch (machine == null- ? null- : phoneMachineStatusOf(machine)) {- PhoneMachineStatus.offline => 'Offline',- PhoneMachineStatus.needsPassword => 'Unlock',- _ => null,- },- // A group says its size in its own detail line ("Project · 3 harnesses"),- // and a command has nothing to be fresh about.+/// The word a result ends in, or null for a row a tap simply opens — see+/// [PhoneSearchTrailing]. Shared with the terminal sheet's rows+/// (`sheet_search_row.dart`), which say the same thing in their own type.+String? phoneSearchBadge(PhoneDestination row, {required bool openable}) {+ final machine = row.machine;+ return switch (row.kind) {+ // Saved work, not a dead row: the tap resumes it and opens it. Said+ // plainly because the wait that follows is a second or two of nothing.+ // Stopped work with no conversation to reopen says so in the desktop's+ // words, rather than the `No terminal` of a live agent that lost its pane.+ PhoneDestinationKind.agent => switch (row.entry?.agent) {+ final agent? when agent.isStopped =>+ openable ? 'Stopped' : 'Resume unavailable',+ _ => openable ? null : 'No terminal',+ },+ PhoneDestinationKind.machine => switch (machine == null+ ? null+ : phoneMachineStatusOf(machine)) {+ PhoneMachineStatus.offline => 'Offline',+ PhoneMachineStatus.needsPassword => 'Unlock',_ => null,- };- }+ },+ // A group says its size in its own detail line ("Project · 3 harnesses"),+ // and a command has nothing to be fresh about.+ _ => null,+ };}/// The wait between tapping stopped work and its terminal arriving. Sized todiff --git a/mobile/lib/phone/sheet_list.dart b/mobile/lib/phone/sheet_list.dartnew file mode 100644index 000000000..136559670--- /dev/null+++ b/mobile/lib/phone/sheet_list.dart@@ -0,0 +1,548 @@+import 'package:flutter/material.dart';+import 'package:lucide_icons_flutter/lucide_icons.dart';++import 'package:harness_mobile/shared/theme/app_theme.dart';+import 'package:harness_mobile/widgets/engine_identity.dart';++import 'phone_prompt_context.dart';+import 'phone_status.dart';+import 'search_result_text.dart';+import 'status_pill.dart';++// The pieces the terminal's search sheet lists with: iOS's inset-grouped list+// — one card of rows with hairlines between them, a caption over it. See+// [SheetRow] for why the tabs and the results share them.++/// How far a group stands in from the sheet's sides — the field and the tab+/// pills keep the same margin, so the sheet has one left edge.+const double kSheetInset = 16;++/// A row's content, in from its card's edge.+const double _rowPadding = 12;++/// The square at the head of a row: iOS Settings' icon tile.+const double _tileSize = 29;+const double _tileGap = 12;++/// Where a row's words start, measured from the card's edge. The hairline+/// between two rows starts here too, so it runs under the words and stops+/// short of the tiles — iOS's inset separator.+const double _textInset = _rowPadding + _tileSize + _tileGap;++/// A caption's inset: the group's margin plus the row's own padding, so a+/// caption starts over the tiles rather than over the card's rounded corner.+const double kSheetCaptionInset = kSheetInset + _rowPadding;++/// The floor every row clears — two lines of text and their padding. A row+/// with only a title is padded up to it, so a group reads as evenly spaced.+const double _minRowHeight = 56;++/// The sheet's own fill: the palette's card — the fill the app's dialogs stand+/// on their veil with — a step ABOVE the terminal the sheet covers.+///+/// ⚠️ **Lifted, not darkened around.** It was the panel, the darkest step the+/// palette has — darker than the terminal itself — and under the veil (see+/// [TerminalSearchOverlay]) the two blacks met: the sheet did not read as+/// standing on anything. A darker veil only moves both further towards black+/// and barely parts them. In a dark UI a raised surface is told by being+/// LIGHTER, which is how iOS draws its own sheets.+Color get sheetFill => AppPalette.cardBg;++/// A group's rows, the search field and the mode chips: the sheet's fill with+/// a wash of white over it.+///+/// A wash rather than the palette's next step, because the steps are not+/// spaced alike across palettes — Graphite's card and hover are a shade+/// apart, Midnight's a clear step — and a wash lifts by the same amount on+/// every one of them.+Color get sheetRowFill => Color.alphaBlend(AppSurface.selectedFill, sheetFill);++/// A row or a chip under the finger: lighter again, as a cell highlights on+/// iOS.+Color get sheetRowPressedFill =>+ Color.alphaBlend(AppSurface.recessHover, sheetRowFill);++/// A row's name.+TextStyle sheetRowTitleStyle() =>+ TextStyle(color: AppPalette.textPrimary, fontSize: 16, height: 1.25);++/// The line under a row's name.+TextStyle sheetRowSubtitleStyle() =>+ TextStyle(color: AppPalette.textSecondary, fontSize: 13, height: 1.3);++/// The line over a run of rows: what the run is, and how many it holds.+///+/// With [onBack] it is also the way out of what it names — a project or a+/// machine the search was narrowed to. iOS has no back button to do that, and+/// without it the only way out of a machine was Cancel, which throws the+/// search away with it.+class SheetCaption extends StatelessWidget {+ const SheetCaption({super.key, required this.label, this.count, this.onBack});++ final String label;++ /// The run's size, or `4/14` once a query has narrowed it. Null leaves the+ /// right-hand end empty.+ final String? count;++ final VoidCallback? onBack;++ @override+ Widget build(BuildContext context) {+ AppTheme.watch(context);+ final onBack = this.onBack;+ final style = TextStyle(+ // The ink of the line under a row's name, not the faint one: on the+ // lifted sheet the faint ink fell under 3:1 at this size.+ color: onBack == null+ ? AppPalette.textSecondary+ : AppPalette.accentOnSurface,+ fontSize: 12,+ fontWeight: FontWeight.w500,+ letterSpacing: 0.4,+ );+ final caption = Padding(+ // Closer to the rows it labels than to what is above it, so it reads as+ // theirs.+ padding: const EdgeInsets.fromLTRB(+ kSheetCaptionInset,+ 10,+ kSheetCaptionInset,+ 7,+ ),+ child: Row(+ children: [+ if (onBack != null) ...[+ Icon(LucideIcons.chevronLeft500, size: 14, color: style.color),+ const SizedBox(width: 2),+ ],+ Expanded(+ child: Text(+ label.toUpperCase(),+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: style,+ ),+ ),+ if (count != null)+ Padding(+ padding: const EdgeInsets.only(left: 12),+ child: Text(+ count!,+ style: style.copyWith(+ color: AppPalette.textSecondary,+ fontFeatures: AppFont.tabularFigures,+ ),+ ),+ ),+ ],+ ),+ );+ if (onBack == null) return Semantics(header: true, child: caption);+ return Semantics(+ button: true,+ label: 'Back',+ child: GestureDetector(+ behavior: HitTestBehavior.opaque,+ onTap: onBack,+ child: caption,+ ),+ );+ }+}++/// One row of an inset group: a tile, a name with a line under it, and what+/// the row ends in.+///+/// ```+/// OTHER 10+/// ╭──────────────────────────────────────╮+/// │ ▣ Super AI ◌ › │+/// │ BBB · ⑂ main · Mac mini │+/// │ ──────────────────────────────────│+/// │ ▣ Hỏi vài câu nhiều lựa chọn ✓ │+/// │ codex-2026-09-22 · Mac mini │+/// ╰──────────────────────────────────────╯+/// ```+///+/// ⚠️ **One row for the tabs and for the search, and that is what it is for.**+/// The sheet reads the account's tabs until its field is focused, then swaps+/// them in place for results — and the same agent was drawn two unrelated+/// ways either side of that swap: a tall card in the tabs, a flat monospaced+/// line in the results. The swap read as a second app arriving. Both lists are+/// built from this now, so focusing the field changes which rows are listed+/// and nothing about how a row looks.+///+/// Status is said with a mark, not a word — see [SheetAgentStatus].+///+/// ⚠️ **Each row draws its own share of the card**, rounding the corners only+/// where it opens or closes the group ([first], [last]). A card drawn once+/// around the rows would have to be a column of every row in it, and the+/// search can list forty — a lazy list builds only the rows on screen, and+/// only if each can be drawn on its own.+class SheetRow extends StatefulWidget {+ const SheetRow({+ super.key,+ required this.leading,+ required this.title,+ required this.first,+ required this.last,+ this.subtitle,+ this.trailing,+ this.chevron = true,+ this.onTap,+ this.enabled = true,+ this.selected = false,+ this.semanticsLabel,+ });++ /// A [SheetTile] — the row's engine, or the mode it belongs to.+ final Widget leading;++ final Widget title;+ final Widget? subtitle;++ /// What the row says before its chevron: its status, or why it cannot be+ /// opened.+ final Widget? trailing;++ /// The `›` that says a tap goes somewhere. Off where it goes nowhere new —+ /// the agent already on screen — and where it adds rather than opens.+ final bool chevron;++ /// Whether this row opens its group, and whether it closes it.+ final bool first, last;++ final VoidCallback? onTap;++ /// False dims the row's content — never its card, which would leave a hole+ /// in the group — for a row a tap cannot open.+ final bool enabled;++ /// The row whose agent is already on screen.+ final bool selected;++ /// Read in place of what the row says, for a row whose words only make+ /// sense to somebody looking at the rest of the sheet.+ final String? semanticsLabel;++ @override+ State<SheetRow> createState() => _SheetRowState();+}++class _SheetRowState extends State<SheetRow> {+ bool _pressed = false;++ void _press(bool pressed) {+ if (widget.onTap == null || _pressed == pressed) return;+ setState(() => _pressed = pressed);+ }++ @override+ Widget build(BuildContext context) {+ AppTheme.watch(context);+ const corner = Radius.circular(AppCard.radius);+ final subtitle = widget.subtitle;+ final trailing = widget.trailing;+ return Semantics(+ container: true,+ button: widget.onTap != null,+ selected: widget.selected,+ label: widget.semanticsLabel,+ excludeSemantics: widget.semanticsLabel != null,+ child: GestureDetector(+ behavior: HitTestBehavior.opaque,+ onTapDown: (_) => _press(true),+ onTapUp: (_) => _press(false),+ onTapCancel: () => _press(false),+ onTap: widget.onTap,+ child: AnimatedContainer(+ duration: AppMotion.press,+ curve: AppMotion.curve,+ constraints: const BoxConstraints(minHeight: _minRowHeight),+ decoration: BoxDecoration(+ // A cell highlights under the finger and does not move — the+ // group is one card, and a row shrinking inside it would tear it.+ color: _pressed ? sheetRowPressedFill : sheetRowFill,+ borderRadius: BorderRadius.vertical(+ top: widget.first ? corner : Radius.zero,+ bottom: widget.last ? corner : Radius.zero,+ ),+ ),+ child: Stack(+ alignment: AlignmentDirectional.centerStart,+ children: [+ Padding(+ padding: const EdgeInsets.symmetric(+ horizontal: _rowPadding,+ vertical: 8,+ ),+ child: Opacity(+ opacity: widget.enabled ? 1 : 0.55,+ child: Row(+ children: [+ widget.leading,+ const SizedBox(width: _tileGap),+ Expanded(+ child: Column(+ mainAxisSize: MainAxisSize.min,+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ widget.title,+ if (subtitle != null) ...[+ const SizedBox(height: 2),+ subtitle,+ ],+ ],+ ),+ ),+ if (trailing != null) ...[+ const SizedBox(width: 10),+ trailing,+ ],+ if (widget.chevron) ...[+ const SizedBox(width: 6),+ Icon(+ LucideIcons.chevronRight500,+ size: 16,+ color: AppPalette.textFaint,+ ),+ ],+ ],+ ),+ ),+ ),+ if (!widget.first)+ PositionedDirectional(+ top: 0,+ start: _textInset,+ end: 0,+ child: Container(+ // One device pixel, whatever the screen: iOS's hairline.+ // A logical point is three of them on a phone, which reads+ // as a rule drawn between rows rather than a seam.+ height: 1 / MediaQuery.devicePixelRatioOf(context),+ color: AppGlass.hair,+ ),+ ),+ ],+ ),+ ),+ ),+ );+ }+}++/// The square at the head of a row, iOS Settings' icon tile.+class SheetTile extends StatelessWidget {+ const SheetTile({super.key, required this.child, this.fill});++ final Widget child;++ /// Null draws the tile's content bare — the `+` of a row that adds.+ final Color? fill;++ @override+ Widget build(BuildContext context) => SizedBox.square(+ dimension: _tileSize,+ child: DecoratedBox(+ decoration: BoxDecoration(+ color: fill,+ borderRadius: BorderRadius.circular(7),+ ),+ child: Center(child: child),+ ),+ );+}++/// An agent's tile: its engine's own mark on a wash of the engine's colour.+///+/// ⚠️ **A wash, not the solid tile iOS Settings draws.** Settings can fill its+/// tiles because it draws the glyphs on them, in white. These are the engines'+/// own marks — most of them full-colour pictures (Codex's blue cloud, Amp's+/// whole app icon) — and a solid fill behind one is a picture on a picture,+/// while a white mark on white (Pi, Grok) disappears outright. The wash keeps+/// the tile telling engines apart by colour and leaves each mark as its+/// owner draws it.+class SheetEngineTile extends StatelessWidget {+ const SheetEngineTile({super.key, required this.engine, this.displayName});++ final String? engine;+ final String? displayName;++ @override+ Widget build(BuildContext context) {+ AppTheme.watch(context);+ final identity = engineIdentity(engine, displayName: displayName);+ return SheetTile(+ fill: identity.color.withValues(alpha: 0.2),+ child: EngineMark(engine: engine, displayName: displayName, size: 18),+ );+ }+}++/// A tile holding the character that reaches its row from the field: `>` for+/// a command, `#` a project, `@` a machine. The row is its own lesson in the+/// modes.+class SheetGlyphTile extends StatelessWidget {+ const SheetGlyphTile(this.glyph, {super.key});++ final String glyph;++ @override+ Widget build(BuildContext context) {+ AppTheme.watch(context);+ return SheetTile(+ fill: AppSurface.recessHover,+ child: Text(+ glyph,+ // ⚠️ Sized to the tile, which does not grow with the app's text size+ // — so neither may the glyph, or it outgrows its own square.+ textScaler: TextScaler.noScaling,+ style: phoneBoxMonoStyle(+ size: 14,+ color: AppPalette.textPrimary,+ weight: FontWeight.w700,+ ).copyWith(height: 1),+ ),+ );+ }+}++/// What an agent's row ends in: the check on the agent already on screen, and+/// otherwise what it is doing — only when that is something, and never in+/// words.+///+/// ⚠️ **The spinner is drawn in the row's own grey, not the accent.** A list+/// with four agents working is four spinners, and four accent-blue ones were+/// the loudest thing on the sheet — louder than the names. Waiting keeps its+/// colour: it is the one state somebody has to act on.+class SheetAgentStatus extends StatelessWidget {+ const SheetAgentStatus({+ super.key,+ required this.summary,+ this.onScreen = false,+ });++ final PhoneSummary summary;++ /// The agent this sheet was opened over: it says so, and nothing else —+ /// whatever it is doing is on the screen behind the sheet.+ final bool onScreen;++ @override+ Widget build(BuildContext context) {+ AppTheme.watch(context);+ if (onScreen) {+ return Icon(+ LucideIcons.check500,+ size: 18,+ color: AppPalette.accentOnSurface,+ );+ }+ return switch (summary.tone) {+ PhoneTone.busy || PhoneTone.attention => StatusDot(+ summary: summary,+ size: 11,+ spinnerColor: AppPalette.textSecondary,+ ),+ _ => const SizedBox.shrink(),+ };+ }+}++/// A row's quiet word at its end — `Stopped`, `Offline` — iOS's detail text.+class SheetRowNote extends StatelessWidget {+ const SheetRowNote(this.text, {super.key});++ final String text;++ @override+ Widget build(BuildContext context) {+ AppTheme.watch(context);+ return Text(+ text,+ maxLines: 1,+ style: TextStyle(color: AppPalette.textSecondary, fontSize: 14),+ );+ }+}++/// The wait on a row being brought back — stopped work resuming.+class SheetRowSpinner extends StatelessWidget {+ const SheetRowSpinner({super.key});++ @override+ Widget build(BuildContext context) {+ AppTheme.watch(context);+ return SizedBox.square(+ dimension: 13,+ child: CircularProgressIndicator(+ strokeWidth: 1.6,+ color: AppPalette.textFaint,+ ),+ );+ }+}++/// Where an agent is, as one line under its name:+/// `folder · ⑂ branch · machine`.+///+/// One line, ellipsed from its end, rather than [AgentContextLine]'s two+/// halves — the row has a tile and a status beside it, and halves this narrow+/// cut both the folder and the machine to a word each.+class SheetPlaceLine extends StatelessWidget {+ const SheetPlaceLine({+ super.key,+ required this.machine,+ this.folder,+ this.branch,+ this.note,+ this.matches = const [],+ });++ final String machine;+ final String? folder;+ final String? branch;++ /// Said first, ahead of the place — `Offline`, for an agent whose machine is.+ final String? note;++ /// What the query reached, so the part of the line that earned the row its+ /// place is set in bold. Empty in the tabs, where nothing was searched.+ final Iterable<PhoneFieldMatch> matches;++ static const _separator = ' · ';++ @override+ Widget build(BuildContext context) {+ AppTheme.watch(context);+ final before = [+ note,+ folder,+ ].whereType<String>().where((part) => part.isNotEmpty).join(_separator);+ final branch = this.branch;+ final hasBranch = branch != null && branch.isNotEmpty;+ final text = [+ before,+ if (hasBranch) branch,+ machine,+ ].where((part) => part.isNotEmpty).join(_separator);+ return SearchResultText(+ text,+ matches: matches,+ style: sheetRowSubtitleStyle(),+ // Drawn rather than written, because `main` alone reads as a folder.+ inlineIcon: hasBranch+ ? Icon(+ LucideIcons.gitBranch300,+ size: 12,+ color: AppPalette.textFaint,+ )+ : null,+ iconOffset: hasBranch && before.isNotEmpty+ ? before.length + _separator.length+ : 0,+ );+ }+}diff --git a/mobile/lib/phone/sheet_search_row.dart b/mobile/lib/phone/sheet_search_row.dartnew file mode 100644index 000000000..22f89c6cf--- /dev/null+++ b/mobile/lib/phone/sheet_search_row.dart@@ -0,0 +1,156 @@+import 'package:flutter/material.dart';++import 'package:harness_mobile/shared/theme/app_theme.dart';++import 'phone_destination.dart';+import 'phone_search_row_trailing.dart';+import 'search_result_text.dart';+import 'sheet_list.dart';++/// One result in the terminal sheet's search: what [PhoneSearchRow] says,+/// drawn as the row the sheet's tabs are drawn with — see [SheetRow].+///+/// ⚠️ **Set in the app's own face, not the terminal's.** [PhoneSearchRow] sets+/// its names in the terminal font for parity with the desktop's box, and on+/// the search page that holds. In the sheet the same agents were drawn in the+/// app's face a moment before, in the tabs these results replace — so the row+/// an agent had there is the row it keeps here, and the swap between the two+/// changes what is listed rather than how.+class SheetSearchRow extends StatelessWidget {+ const SheetSearchRow({+ super.key,+ required this.row,+ required this.terms,+ required this.openable,+ required this.first,+ required this.last,+ required this.onTap,+ this.quote,+ this.resuming = false,+ this.busy = false,+ this.onScreen = false,+ });++ final PhoneDestination row;+ final List<String> terms;++ /// Whether a tap can do anything — see [PhoneSearchRow.openable]. A row that+ /// cannot is dimmed, with the reason at its end.+ final bool openable;++ /// Whether this row opens its group, and whether it closes it.+ final bool first, last;++ final VoidCallback onTap;++ /// See [PhoneSearchRow.quote].+ final String? quote;++ /// See [PhoneSearchRow.resuming].+ final bool resuming;++ /// See [PhoneSearchRow.busy].+ final bool busy;++ /// Whether this is the agent the sheet was opened over. It wears the check,+ /// as it does in the tabs.+ final bool onScreen;++ @override+ Widget build(BuildContext context) {+ AppTheme.watch(context);+ final row = this.row;+ final matches = phoneResultMatches(row, terms);+ return SheetRow(+ first: first,+ last: last,+ enabled: openable,+ selected: onScreen,+ onTap: openable && !busy ? _open : null,+ leading: _tile(row),+ title: SearchResultText(+ _title(row),+ matches: matches.where((match) => match.title),+ style: sheetRowTitleStyle(),+ ),+ subtitle: _subtitle(row, matches),+ trailing: _trailing(row),+ chevron: openable && !onScreen && !resuming,+ );+ }++ void _open() {+ // The keyboard goes away with the sheet, not a frame after it — dismissing+ // it first keeps the terminal from opening under a collapsing inset.+ FocusManager.instance.primaryFocus?.unfocus();+ onTap();+ }++ static Widget _tile(PhoneDestination row) => switch (row.kind) {+ PhoneDestinationKind.agent => SheetEngineTile(+ engine: row.engine,+ displayName: row.entry?.agent.engineDisplayName,+ ),+ PhoneDestinationKind.machine => const SheetGlyphTile('@'),+ PhoneDestinationKind.project => const SheetGlyphTile('#'),+ PhoneDestinationKind.command => const SheetGlyphTile('>'),+ PhoneDestinationKind.mode => SheetGlyphTile(_modeGlyph(row) ?? '?'),+ };++ /// A `?` row's own character — the one a tap on it puts in the field.+ static String? _modeGlyph(PhoneDestination row) {+ final glyph = row.pickerQuery?.trim();+ return glyph == null || glyph.isEmpty ? null : glyph;+ }++ /// The name as the row draws it. A `?` row's title carries its character at+ /// its head — `> Commands` — and the tile beside it already says that.+ static String _title(PhoneDestination row) {+ final glyph = row.isMode ? _modeGlyph(row) : null;+ if (glyph == null || !row.title.startsWith(glyph)) return row.title;+ return row.title.substring(glyph.length).trimLeft();+ }++ /// The line under the name — in [PhoneSearchRow]'s own order of preference:+ /// a quote from the conversation when that is why the row is here, where+ /// the agent is when it is one, and otherwise the detail a group or a+ /// command carries.+ Widget? _subtitle(PhoneDestination row, List<PhoneFieldMatch> matches) {+ final details = matches.where((match) => !match.title);+ final quote = this.quote;+ if (quote != null) {+ return SearchResultText(+ quote,+ matches: phoneContentMatches(terms),+ style: sheetRowSubtitleStyle(),+ );+ }+ final identity = row.promptContext;+ if (identity != null) {+ return SheetPlaceLine(+ machine: identity.machine ?? row.machineLabel,+ folder: identity.project,+ branch: identity.branch,+ note: identity.leading,+ matches: details,+ );+ }+ if (row.detail.isEmpty) return null;+ return SearchResultText(+ row.detail,+ matches: details,+ style: sheetRowSubtitleStyle(),+ );+ }++ /// What the row ends in: the wait while it resumes, the word for why it will+ /// not simply open, or else — for an agent — what it is doing.+ Widget? _trailing(PhoneDestination row) {+ if (resuming) return const SheetRowSpinner();+ final badge = phoneSearchBadge(row, openable: openable);+ if (badge != null) return SheetRowNote(badge);+ final entry = row.entry;+ if (entry == null) return null;+ return SheetAgentStatus(summary: entry.summary, onScreen: onScreen);+ }+}diff --git a/mobile/lib/phone/terminal_header.dart b/mobile/lib/phone/terminal_header.dartindex f25bd6fa1..6364ee815 100644--- a/mobile/lib/phone/terminal_header.dart+++ b/mobile/lib/phone/terminal_header.dart@@ -101,8 +101,7 @@ class TerminalHeader extends StatelessWidget {/// The engine mark with the session's state notched into its corner.///-/// The header draws it beside the agent's name, and the tabs popup on each of-/// its cards — an agent reads the same wherever it is offered.+/// The header draws it beside the agent's name.class BadgedEngineMark extends StatelessWidget {const BadgedEngineMark({super.key,diff --git a/mobile/lib/phone/terminal_header_action.dart b/mobile/lib/phone/terminal_header_action.dartindex 9a6993023..d467c6312 100644--- a/mobile/lib/phone/terminal_header_action.dart+++ b/mobile/lib/phone/terminal_header_action.dart@@ -4,8 +4,8 @@ import 'package:harness_mobile/shared/theme/app_theme.dart';import 'package:harness_mobile/shared/widgets/app_icon_button.dart';import 'package:harness_mobile/shared/widgets/touch_target.dart';-/// One mark in the terminal header's trailing row — the tabs grid, `⋮`,-/// and the Take control button's neighbours.+/// One mark in the terminal header's trailing row — `⋮`, beside the Take+/// control button.////// Its own file because [gap] is an invariant with arithmetic behind it and/// a test that checks it (`terminal_header_action_test.dart`); a private classdiff --git a/mobile/lib/phone/terminal_page.dart b/mobile/lib/phone/terminal_page.dartindex 5b65faf65..5ba4023b1 100644--- a/mobile/lib/phone/terminal_page.dart+++ b/mobile/lib/phone/terminal_page.dart@@ -31,7 +31,6 @@ import 'agent_model_sheet.dart';import 'agents_list_page.dart';import 'agents_page.dart' show openNewAgent;import 'delete_agent.dart';-import 'desk_tabs_popup.dart';import 'held_height.dart';import 'machines_tab.dart';import 'phone_navigation.dart' show phoneRoute;@@ -178,7 +177,6 @@ typedef _PageFacts = ({bool redialling,bool imagePaste,String? machineName,- bool deskTabs,});/// What a page has asked for back — see [_TerminalPageState._reclaiming].@@ -235,43 +233,37 @@ class _TerminalPageState extends State<TerminalPage>/// the remote resize until this clears.bool _keyboardSettling = false;- /// Drives search opening out of the header bar and collapsing back into it.- ///- /// ⚠️ **One controller for both halves of the move, read by both.** The search- /// overlay grows on it while the terminal and its chrome fade out on the same- /// 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.+ /// Drives the search sheet up from the bottom edge and back down — see+ /// [TerminalSearchOverlay].+ ///+ /// ⚠️ **One controller for the sheet and the dimming behind it, read by+ /// both.** Two, or an implicit animation on either side, would let them drift+ /// apart on a dropped frame: a sheet arriving over a page not yet dimmed, or+ /// the dimming still there after the sheet had gone.+ ///+ /// The timings are [BottomSheet]'s own, as is the curve below, so this sheet+ /// comes and goes like every sheet the app opens as a route — the way down a+ /// little quicker than the way up, the way dismissals usually are.late final AnimationController _searchOpen = AnimationController(vsync: this,- duration: const Duration(milliseconds: 420),- reverseDuration: const Duration(milliseconds: 340),+ duration: const Duration(milliseconds: 250),+ reverseDuration: const Duration(milliseconds: 200),);- /// 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.+ /// The curve everything on the open/close reads: [BottomSheet]'s, which+ /// arrives quickly and settles, and leaves the same way run backwards.late final Animation<double> _searchCurve = CurvedAnimation(parent: _searchOpen,- curve: Curves.easeInOutCubic,- reverseCurve: Curves.easeInOutCubic,+ curve: Easing.legacyDecelerate,);- /// Whether the search overlay is BUILT — true from the first frame of the+ /// Whether the search sheet is BUILT — true from the first frame of the/// opening animation to the last frame of the closing one.///- /// ⚠️ Not the same question as "is the animation at 1". The overlay holds a- /// focused [TextField], so it must come down the moment the collapse finishes- /// and not a frame later — a field left mounted behind the terminal keeps the- /// keyboard and swallows what the terminal is owed.+ /// ⚠️ Not the same question as "is the animation at 1". The sheet holds a+ /// [TextField] that may have the keyboard, so it must come down the moment+ /// the sheet is gone and not a frame later — a field left mounted behind the+ /// terminal keeps the keyboard and swallows what the terminal is owed.bool _searching = false;/// Whether the terminal had the keyboard up when search opened — what closing@@ -288,7 +280,7 @@ class _TerminalPageState extends State<TerminalPage>////// ⚠️ **Not [_searching], and the difference is the whole bug.** iOS takes/// the keyboard's view away at once, but the inset it reports falls over- /// ~0.5s — longer than search's fade out. Released with [_searching], the+ /// ~0.5s — longer than the sheet takes to go. Released with [_searching], the/// terminal took the still-falling inset as its own keyboard: its key bar came/// up, its floating column went, and it shrank and grew back over a few/// frames right after the search had gone. Held until the inset reaches zero@@ -561,11 +553,6 @@ class _TerminalPageState extends State<TerminalPage>phoneMachineRedialling(machine),imagePaste: machine?.terminalImagePasteAvailable ?? false,machineName: machine?.machine.displayName,- // ⚠️ Read here, and not in `build` alone, because this page is rebuilt- // only when one of these facts moves. Tabs arriving from another computer- // change nothing else about this agent, and the mark that opens them- // would not appear until something unrelated happened to redraw the page.- deskTabs: notifier.deskTabs.isNotEmpty,);}@@ -664,42 +651,49 @@ class _TerminalPageState extends State<TerminalPage>if (mounted) setState(() {});}- /// Fades the search screen up over the terminal.+ /// Brings the search sheet up over the terminal, reading the account's tabs+ /// with its field not yet focused — see [TerminalSearchOverlay].///- /// ⚠️ The overlay is mounted on THIS frame and the animation started on it,- /// so the field is there to take the keyboard as the screen opens. Mounting- /// at the end of the fade would land the caret a beat too late for a button- /// that was tapped to type in.+ /// ⚠️ **The terminal is held from THIS frame, though no keyboard is coming+ /// yet.** The sheet's field raises one the moment it is tapped, and by then+ /// the terminal must already be ignoring it — see [_heldForSearch] for what+ /// it does with that keyboard otherwise.void _openSearch() {if (_searching) return;_keyboardBeforeSearch = _keyboardIsUp;_keyboardUpAtSearch = _keyboardUp;_searchHoldTimer?.cancel();+ // ⚠️ **Whatever holds the keys lets go of them.** The sheet opens with its+ // field NOT focused, so nothing takes focus from the terminal the way the+ // search once did by focusing itself — and a terminal on a hardware+ // keyboard keeps its focus with no inset to show for it, so it would go on+ // typing into the shell from under the dimming.+ FocusManager.instance.primaryFocus?.unfocus();setState(() {_searching = true;_heldForSearch = true;- // ⚠️ Handed over, not left standing. The bar can be tapped with the- // terminal's own keyboard already up, and a claim still outstanding would- // race the search field for it the moment the inset ticks — the panel- // would win and the query would be typed into the shell.+ // ⚠️ Handed over, not left standing. A claim still outstanding when the+ // sheet opens would race the search field for the keyboard the moment+ // the field raises one — the panel would win and the query would be+ // typed into the shell._keyboardRequested = false;});_searchOpen.forward();}- /// Collapses it back into the bar, and takes the overlay down once it is home.+ /// Sends the sheet back down, and takes it down once it is gone.///- /// ⚠️ **Guarded on the controller's own status, not on [_searching].** The- /// field's chevron and the system back gesture can both arrive while the reverse is already- /// running — a second `reverse()` restarts it from wherever it had got to, and- /// the bar visibly bounces.+ /// ⚠️ **Guarded on the controller's own status, not on [_searching].** A tap+ /// on the dimmed page, a pull on the sheet and the system back gesture can+ /// all arrive while the reverse is already running — a second `reverse()`+ /// restarts it from wherever it had got to, and the sheet visibly bounces.void _closeSearch() {if (!_searching || _searchOpen.status == AnimationStatus.reverse) return;// ⚠️ **The keyboard up now is the SEARCH field's, not the terminal's.** Its// inset set [_keyboardIsUp], and left standing, the terminal read that as- // its own the moment search came down — the chevron, Back or opening an agent- // brought up a keyboard nobody had asked the terminal for. Put away like a- // swipe's, unless the terminal had one up before search opened.+ // its own the moment search came down — closing the sheet, Back or opening+ // an agent brought up a keyboard nobody had asked the terminal for. Put+ // away like a swipe's, unless the terminal had one up before search opened.if (!_keyboardBeforeSearch) dismissKeyboardForSwipe();_searchOpen.reverse().whenCompleteOrCancel(() {// A completed reverse is the only thing that unmounts the overlay; a@@ -1184,399 +1178,374 @@ class _TerminalPageState extends State<TerminalPage>// frame: the terminal ran a layout loop and the page juddered. Cleared// here, the inset reaches nothing below — which is the whole intent of// turning it off.- body: MediaQuery.removePadding(- context: context,- removeBottom: true,- child: SafeArea(- bottom: false,- // ⚠️ **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- ? _Attaching(key: _skeletonKey)- : 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)- Positioned.fill(- child: _Attaching(key: _skeletonKey),- ),- // The mic, Search and New agent, floating in the- // terminal's bottom-right corner — see- // [TerminalActionColumn].- //- // ⚠️ Hidden while this page owns the keyboard.- // Typing is the other way of saying what the mic- // says, the key bar is already under the thumb, and- // a column floating over the prompt being typed into- // would be in the way of both.- if (!_ownsInput)- Positioned(- right: TerminalActionColumn.inset,- bottom: TerminalActionColumn.bottomInset,- child: TerminalActionColumn(- voice: widget.voice,- session: session,- onSearch: _openSearch,- onNewAgent: canCreate- ? () => unawaited(_newAgent())- : null,- ),- ),- ],- ),- ),- // The bottom of this page IS just above the keyboard:- // `PhoneShell`'s Scaffold has already resized for it —- // the same resize that empties this page's MediaQuery- // insets (see [didChangeMetrics]).- if (session != null)- TerminalInputDock(- session: session,- keyboardUp: _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,+ body: Stack(+ children: [+ MediaQuery.removePadding(+ context: context,+ removeBottom: true,+ child: SafeArea(+ bottom: false,+ // ⚠️ **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(- mainAxisSize: MainAxisSize.min,children: [- TerminalHeader(- agent: agent,- status: headerStatus,- 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]. Gone while- // that stream is already coming back — see- // `reconnecting` above.- if (reclaim != null &&- !blocked &&- _reclaiming == null)- _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)- TerminalHeaderAction(- icon: LucideIcons.layoutGrid300,- tooltip: 'Tabs',- onPressed: () => unawaited(- showDeskTabsPopup(- context,- widget.notifier,- showing: (- machineId: widget.machineId,- agentId: widget.agentId,+ 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+ ? _Attaching(key: _skeletonKey)+ : 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.+ ),),- ),- ),),- // 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)- TerminalHeaderAction(- // Stood up, not laid flat: three dots in a- // column is the narrower mark AND the one a- // phone means by "more actions", so it reads- // as a menu rather than as a truncation.- icon: LucideIcons.ellipsisVertical300,- size: 21,- tooltip: 'Harness 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,+ // ⚠️ **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)+ Positioned.fill(+ child: _Attaching(key: _skeletonKey),),- ),- ],- ),- // The hairline, carrying a sweep while the header- // reads as a wait — Attaching, Resyncing,- // Reconnecting. See [TerminalHeaderRule].- TerminalHeaderRule(- busy: headerStatus.tone == PhoneTone.busy,+ // 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,+ ),+ ),+ ],+ ),),- // ⚠️ 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.- //- // Up for a take in flight, not for a reconnect: that one is the header's- // own wait, and a band over it said "Taking control…" of a stream nobody- // else held. See [_reclaiming].- if (blocked || _reclaiming == _Reclaim.control)- _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,),],),),- ),- ),- // 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: (_windowBottomInset - navigationBar).clamp(- 0.0,- double.infinity,+ // 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: headerStatus,+ 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]. Gone while+ // that stream is already coming back — see+ // `reconnecting` above.+ if (reclaim != null &&+ !blocked &&+ _reclaiming == null)+ _ReclaimButton(+ action: reclaim,+ // The same call the band's button makes — see+ // [_takeControl].+ onPressed: () =>+ unawaited(_takeControl()),+ ),+ // ⚠️ **No tabs mark here.** The account's tabs+ // are the first thing the floating Search button+ // opens, above the thumb — see+ // [TerminalSearchOverlay] — and a mark up here+ // for the same panel was a second door to it.+ // 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)+ TerminalHeaderAction(+ // Stood up, not laid flat: three dots in a+ // column is the narrower mark AND the one a+ // phone means by "more actions", so it reads+ // as a menu rather than as a truncation.+ icon: LucideIcons.ellipsisVertical300,+ size: 21,+ tooltip: 'Harness 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,+ ),+ ),+ ],+ ),+ // The hairline, carrying a sweep while the header+ // reads as a wait — Attaching, Resyncing,+ // Reconnecting. See [TerminalHeaderRule].+ TerminalHeaderRule(+ busy: headerStatus.tone == PhoneTone.busy,+ ),+ // ⚠️ 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.+ //+ // Up for a take in flight, not for a reconnect: that one is the header's+ // own wait, and a band over it said "Taking control…" of a stream nobody+ // else held. See [_reclaiming].+ if (blocked || _reclaiming == _Reclaim.control)+ _ControlBanner(+ watching: session?.watching ?? false,+ busy: !blocked,+ takeoverNotice: takeoverNotice,+ onTakeControl: _takeControl,+ ),+ ],+ ),),),- child: TerminalSearchOverlay(- notifier: widget.notifier,- animation: _searchCurve,- onClose: _closeSearch,- ),),- ),- ],+ ],+ ),+ ),),),- ),+ // The search sheet, up from the bottom edge over the whole page —+ // built from the first frame of its way up to the last of its way+ // down, and not otherwise. See [_searching].+ //+ // ⚠️ **Out here, beside the insets rather than inside them.** It is a+ // sheet over the page, and the page includes the strip under the+ // status bar: laid inside the `SafeArea`, the dimming would stop at+ // the header and leave the clock on a bright band above a darkened+ // screen. Its foot runs under the home indicator the same way, and it+ // is TOLD that inset rather than reading it — the body strips it from+ // the MediaQuery (see the note on `removePadding` above).+ if (_searching)+ Positioned.fill(+ child: TerminalSearchOverlay(+ notifier: widget.notifier,+ showing: (machineId: widget.machineId, agentId: widget.agentId),+ animation: _searchCurve,+ bottomInset: _windowBottomInset,+ onClose: _closeSearch,+ ),+ ),+ ],),);}diff --git a/mobile/lib/phone/terminal_search.dart b/mobile/lib/phone/terminal_search.dartindex f5911a2bc..d02c868c8 100644--- a/mobile/lib/phone/terminal_search.dart+++ b/mobile/lib/phone/terminal_search.dart@@ -1,33 +1,72 @@+import 'dart:math' as math;+import 'dart:ui' show ImageFilter;+import 'package:flutter/material.dart';+import 'package:flutter/services.dart';+import 'package:harness_mobile/core/last_opened_agent.dart' show AgentRef;import 'package:harness_mobile/shared/theme/app_theme.dart';+import 'package:harness_mobile/shared/widgets/app_dialog.dart'+ show kDialogVeilBlur;import 'package:harness_mobile/state/app_state.dart';+import 'agent_index.dart';+import 'desk_groups.dart';+import 'desk_tabs_panel.dart';+import 'phone_prompt_context.dart';import 'phone_search_actions.dart';import 'phone_search_controller.dart';import 'phone_search_field.dart';import 'phone_search_results.dart';-import 'phone_search_scope_bar.dart';+import 'sheet_list.dart';-/// Search, opened in place over a terminal rather than pushed as a page.+/// The terminal's way to another agent: a sheet up from the bottom, over the+/// terminal, holding the account's tabs with a search field across its top.+///+/// ```+/// ╭──────────────────────────────────╮+/// │ ━━━ │+/// │ ┌────────────────────┐ │+/// │ │ ⌕ Search harnesses │ Cancel │ ← focused, it grows a Cancel+/// │ └────────────────────┘ │+/// │ (▓Desktop▓) ( Docker ) (+) │ ← until then, the tabs —+/// │ DESKTOP 2 │ [DeskTabsPanel]+/// │ ╭────────────────────────────╮ │+/// │ │ ▣ api-3 ◌ › │ │+/// ```+///+/// Drawn the way iOS draws its own sheets — a filled search bar, pills, an+/// inset-grouped list — and the same way in both states: the results are the+/// rows the tabs are ([SheetRow]), so the field taking focus changes what is+/// listed and nothing about how.///-/// ⚠️ **Not a route.** Pushing [PhoneSearchPage] slid a fresh screen in from the-/// right over a terminal that is still streaming underneath; opening in place-/// fades the search up over it instead, and closing fades it back down onto the-/// same screen, mid-stream.+/// ⚠️ **Two ways to the same place, one sheet.** An agent is found by where it+/// is — its tab — or by what it is called, and those were two doors: a grid+/// mark in the header for the tabs, and the floating Search button for a search+/// that covered the screen. The button opens both now. The sheet reads the tabs+/// until the field is focused; then the results take their place, and Cancel+/// puts the tabs back.///-/// It is opened from the floating Search button in the terminal's bottom-right-/// corner (`terminal_action_column.dart`), so it draws its whole self — field-/// and results — over an opaque page, rather than borrowing any of the header's.+/// ⚠️ **In place, never a screen of its own.** Focusing the field once stood+/// the sheet up to the top of the screen for the results, and it read as a+/// second screen arriving over the first — the full-screen search this sheet+/// replaced. The results take the tabs' place and nothing else moves: the+/// keyboard, when it comes, takes the bottom of the sheet and leaves its top+/// where it was.///-/// ⚠️ **The search page's own bar, not a second one.** [PhoneSearchField] is one-/// bar with the way out inside it — a chevron at its leading edge — and no-/// Cancel beside it. This screen used to draw its own field with a Cancel, and-/// the two searches drifted apart; drawing the same widget keeps them one. The-/// system back gesture closes it too — see [TerminalSearchOverlay]'s [PopScope].+/// ⚠️ **The field is not focused on the way in.** The tabs are what the sheet+/// is opened to read, and a keyboard raised with it would cover half of them.///-/// ⚠️ **It must stay mounted only while searching.** The [TextField] inside-/// autofocuses, so a copy left built behind the terminal would keep the keyboard+/// ⚠️ **Not a route.** Pushed, the sheet would sit in a navigator above the+/// shell, and an agent opened from it would be pushed over the shell rather+/// than take the home screen (see [openAgent]). Worse, the terminal beneath+/// would still be the current route of ITS navigator: it would read the+/// field's keyboard as its own and claim the input back, and the query would+/// be typed into the shell. In place, the page holds its terminal still for as+/// long as this is up — see `_heldForSearch` in `terminal_page.dart`.+///+/// ⚠️ **It must stay mounted only while it is up.** The field inside keeps the+/// keyboard once tapped, so a copy left built behind the terminal would keep it/// and eat every keystroke the terminal is owed.class TerminalSearchOverlay extends StatefulWidget {const TerminalSearchOverlay({@@ -35,26 +74,91 @@ class TerminalSearchOverlay extends StatefulWidget {required this.notifier,required this.animation,required this.onClose,+ this.showing,+ this.bottomInset = 0,});final AppNotifier notifier;- /// The open/close animation the terminal page drives — 0 gone, 1 filling the- /// screen.+ /// The open/close animation the terminal page drives — 0 gone, 1 up.////// Run by the page rather than here, because the page is what decides when- /// this widget stops existing: the collapse has to finish before the overlay- /// comes down, and a controller owned by a widget being unmounted cannot- /// outlive itself to say so.+ /// this widget stops existing: the sheet has to be all the way down before+ /// the overlay comes down, and a controller owned by a widget being unmounted+ /// cannot outlive itself to say so.final Animation<double> animation;final VoidCallback onClose;+ /// The agent on screen: the tab the sheet opens on, and the row wearing the+ /// check — in the tabs and in the results. See [DeskTabsPanel.showing].+ final AgentRef? showing;++ /// The strip at the foot of the window the sheet runs down over — the home+ /// indicator, Android's navigation bar — which its lists keep their last row+ /// clear of. Zero while a keyboard is up: the page already ends at its top.+ ///+ /// Handed in because the page is what knows it. The MediaQuery here does not+ /// carry the window's inset — see `_windowBottomInset` in+ /// `terminal_page.dart`.+ final double bottomInset;+@overrideState<TerminalSearchOverlay> createState() => _TerminalSearchOverlayState();}-class _TerminalSearchOverlayState extends State<TerminalSearchOverlay> {+class _TerminalSearchOverlayState extends State<TerminalSearchOverlay>+ with TickerProviderStateMixin {+ /// The corner iOS gives a sheet — rounder than a card, far less round than+ /// [BottomSheet]'s 28, whose curve made a sheet drawn like the system's+ /// own read as Material wearing its clothes.+ static const double _radius = 14;++ /// What the field says while it reads the tabs. The modes it also takes are+ /// offered as chips once it is focused — see [_SearchHead].+ static const String _hint = 'Search harnesses';++ /// How dark the page goes behind the sheet — a step past the `black54`+ /// every other sheet here draws, with the page blurred under it as well.+ ///+ /// ⚠️ **Blurred, because what is behind this sheet is a live terminal.**+ /// Dimmed text is still text: at any tint that leaves the page reading as+ /// the page, its lines stayed legible — and moving — and the eye went on+ /// picking words out of them instead of settling on the list it came to+ /// choose from. The blur takes the letterforms away, at the strength the+ /// app's dialogs use for the same job ([kDialogVeilBlur]); the tint only has+ /// to set the depth, which is why it can stay this far short of theirs.+ static const double _scrim = 0.64;++ /// A fling down faster than this closes the sheet however little it moved —+ /// [BottomSheet]'s own figure, so this sheet lets go like the others do.+ static const double _flingSpeed = 700;++ /// What the sheet stands at while it reads the tabs: this share of the+ /// screen, the strip at its foot included.+ ///+ /// ⚠️ **One height, whatever the tab holds** — see [DeskTabsPanel]. Enough+ /// for four or five rows, and the terminal keeps the rest in view above it.+ ///+ /// ⚠️ **Not [TerminalSearchOverlay.bottomInset] on top of a share.** That+ /// inset reads zero while a keyboard is up and comes back as the keyboard+ /// lands, so a height that counted it would jump by the home indicator's+ /// worth the moment Cancel's keyboard finished going down.+ static const double _restingShare = 0.64;++ /// How close under the status bar the sheet may be pushed, when a keyboard+ /// leaves it no room lower down: a strip of the dimmed page left showing,+ /// which is what says it is a layer over the terminal rather than a page of+ /// its own.+ static const double _topGap = 8;++ /// The least the sheet keeps above a keyboard: the grip, the field, the mode+ /// chips and the first rows of results. A keyboard that would leave less — a+ /// small phone, one lying on its side — lifts the sheet's top instead, since+ /// a field with no room under it is a search with nowhere to put its+ /// answers.+ static const double _minHeight = 200;+final _controller = TextEditingController();final _focus = FocusNode(debugLabel: 'Terminal search');late final PhoneSearchController _search = PhoneSearchController(@@ -63,9 +167,55 @@ class _TerminalSearchOverlayState extends State<TerminalSearchOverlay> {commands: () => phoneSearchCommands(context, widget.notifier),);+ /// The sheet's own box, measured to turn a drag's pixels into a share of its+ /// height.+ final _sheetKey = GlobalKey(debugLabel: 'Terminal search sheet');++ /// Whether the sheet is searching: results where the tabs were, Cancel+ /// beside the field.+ ///+ /// ⚠️ **Entered on focus, left on Cancel — not tied to focus both ways.** The+ /// keyboard goes away for plenty of reasons that are not "stop searching": a+ /// drag on the results puts it away on purpose (see [PhoneSearchResults]),+ /// and so does the return key. The results stay up through all of them, the+ /// way a search does anywhere on a phone; only Cancel, or Back, ends it.+ bool _searching = false;++ /// Whether the results are BUILT — from the focus that started the search to+ /// the last frame of their fade after Cancel. Not [_searching]: they have to+ /// stay on screen to be seen going.+ bool _resultsUp = false;++ /// The tabs and the results trading places, in the same spot.+ late final AnimationController _swap = AnimationController(+ vsync: this,+ duration: const Duration(milliseconds: 250),+ reverseDuration: const Duration(milliseconds: 200),+ )..addStatusListener(_onSwap);++ /// The tabs out over the first half of the swap and the results in over the+ /// later part, so the two are never both at full strength — one list printed+ /// over another reads as neither.+ late final CurvedAnimation _tabsGoing = CurvedAnimation(+ parent: _swap,+ curve: const Interval(0, 0.5, curve: Curves.easeIn),+ );+ late final Animation<double> _tabsShown = ReverseAnimation(_tabsGoing);+ late final CurvedAnimation _resultsShown = CurvedAnimation(+ parent: _swap,+ curve: const Interval(0.35, 1, curve: Curves.easeOut),+ );++ /// How far a finger has pulled the sheet down, as a share of its height.+ late final AnimationController _pull = AnimationController(vsync: this);+@overridevoid initState() {super.initState();+ _focus.addListener(_onFocus);+ _search.addListener(_followQuery);+ // The order the box opens in comes off disk. Not awaited: what is known+ // draws now, and the visits fold in a frame later.widget.notifier.searchHistory.load().then((_) {if (mounted) _search.setQuery(_search.query);});@@ -73,20 +223,89 @@ class _TerminalSearchOverlayState extends State<TerminalSearchOverlay> {@overridevoid dispose() {+ _focus.removeListener(_onFocus);+ _search.removeListener(_followQuery);_controller.dispose();_focus.dispose();_search.dispose();+ _tabsGoing.dispose();+ _resultsShown.dispose();+ _swap.dispose();+ _pull.dispose();super.dispose();}- /// Back leaves the chosen project or machine first, and only then the search —- /// the same step `#`/`@` took to get in.+ /// A tap on the field is what starts a search — see [_searching].+ void _onFocus() {+ if (!_focus.hasFocus || _searching) return;+ // A search cancelled a moment ago can still be fading out with its query+ // in it: see [_cancel]. The empty field is the truth.+ if (_controller.text.isEmpty) _search.reset();+ setState(() {+ _searching = true;+ _resultsUp = true;+ });+ _swap.forward();+ }++ /// Cancel: the search is over and the sheet goes back to the tabs, leaving+ /// the query behind with it — the next tap on the field starts from an empty+ /// box, as a search cancelled anywhere else does.+ ///+ /// ⚠️ The field is emptied now and the search itself only once the results+ /// have faded ([_onSwap]). Emptied at once, the fading list would swap to+ /// the empty query's rows on its way out — a different list for a blink.+ void _cancel() {+ if (!_searching) return;+ _focus.unfocus();+ _controller.clear();+ setState(() => _searching = false);+ _swap.reverse();+ }++ void _onSwap(AnimationStatus status) {+ if (status != AnimationStatus.dismissed || _searching || !_resultsUp) {+ return;+ }+ _search.reset();+ setState(() => _resultsUp = false);+ }++ /// Puts the query in the field when it moved without a keystroke — a chip,+ /// a `?` row taking its mode, a project or a machine narrowing the search,+ /// Back stepping out of one.+ ///+ /// ⚠️ **Only while searching.** After Cancel the field is emptied at once and+ /// the query only once the results have faded (see [_cancel]); a change+ /// announced in between would otherwise put the cancelled query back in the+ /// field on its way out.+ void _followQuery() {+ if (!_searching) return;+ final query = _search.query;+ if (query == _controller.text) return;+ _controller.value = TextEditingValue(+ text: query,+ selection: TextSelection.collapsed(offset: query.length),+ );+ }++ /// A mode chip: its character in the field, and the caret after it, ready+ /// for the rest of the query.+ void _pickMode(String prefix) {+ _search.setQuery(prefix);+ _focus.requestFocus();+ }++ /// Back steps out of a chosen project or machine first, then out of the+ /// search, and only then out of the sheet — the steps `#`/`@` and the field+ /// took on the way in.void _back() {- if (_search.back()) {- _controller.text = _search.query;+ if (!_searching) {+ _close();return;}- _close();+ if (_search.back()) return;+ _cancel();}/// ⚠️ Drops the keyboard BEFORE handing back, so the terminal underneath does@@ -98,57 +317,440 @@ class _TerminalSearchOverlayState extends State<TerminalSearchOverlay> {widget.onClose();}+ /// A row in the tabs: away first, then the agent — see [openDeskAgent].+ void _open(DeskGroup group, AgentEntry entry) {+ final notifier = widget.notifier;+ final showing = widget.showing;+ _close();+ // ⚠️ **The agent already on screen, in the tab the phone is already in,+ // opens nothing.** The tap asks to stay where it is. Sent on, it would —+ // on a page reached by a swipe — rebuild the pager around the page it is+ // on (see [AgentHome]) and load that terminal again for nothing.+ if (showing != null &&+ entry.machineId == showing.machineId &&+ entry.agent.id == showing.agentId) {+ final groups = deskGroups(notifier, visibleAgents(agentIndex(notifier)));+ if (activeDeskGroup(notifier, groups, showing).id == group.id) return;+ }+ openDeskAgent(context, notifier, group, entry);+ }++ void _onPull(DragUpdateDetails details) {+ final height = _sheetKey.currentContext?.size?.height ?? 0;+ if (height <= 0) return;+ _pull.value += details.primaryDelta! / height;+ }++ /// Let go: closed on a fling down or past half its height — [BottomSheet]'s+ /// own rule — and back up otherwise.+ void _onRelease(DragEndDetails details) {+ if ((details.primaryVelocity ?? 0) > _flingSpeed || _pull.value > 0.5) {+ _close();+ return;+ }+ _settle();+ }++ void _settle() {+ _pull.animateTo(+ 0,+ duration: const Duration(milliseconds: 200),+ curve: Curves.easeOutCubic,+ );+ }+@overrideWidget build(BuildContext context) {AppTheme.watch(context);+ // Built once per build and handed down whole, so the frames of the slide+ // and of a pull — and of a keyboard resizing the page — move it without+ // building it again.+ final sheet = _sheet(context);return PopScope(- // Back closes the search instead of leaving the agent — the terminal is- // still underneath, and this is what is covering it.+ // Back steps out of the search and then closes the sheet — never leaves+ // the agent: the terminal is still underneath, and this is what covers+ // it.canPop: false,onPopInvokedWithResult: (didPop, _) {if (!didPop) _back();},- // ⚠️ 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: FadeTransition(- opacity: widget.animation,- child: ColoredBox(- color: AppPalette.windowBg,- child: Column(- children: [- ListenableBuilder(- listenable: _search,- builder: (context, _) => PhoneSearchField(- controller: _controller,- focus: _focus,- hintText: _search.hint,- onChanged: _search.setQuery,- onClear: () {- _controller.clear();- _search.setQuery('');- // Clearing is a step back into browsing, not out of the- // search — the caret stays where the next query will go.- _focus.requestFocus();- },- onBack: _back,+ // The terminal under the dimming is not what a screen reader should be+ // walking while the sheet is up.+ child: BlockSemantics(+ child: GestureDetector(+ // ⚠️ **A sideways drag anywhere over the page is claimed here and+ // goes nowhere.** The pager under the terminal swipes on exactly+ // that, and it would carry the sheet off with the page it belongs+ // to. The tab pills and the mode chips scroll sideways too, and win+ // it for themselves where they are.+ onHorizontalDragStart: (_) {},+ child: LayoutBuilder(+ builder: (context, box) => _layOut(context, box.biggest, sheet),+ ),+ ),+ ),+ );+ }++ Widget _layOut(BuildContext context, Size area, Widget sheet) {+ final view = View.of(context);+ // What a keyboard has taken off the foot of the page — the view's own+ // figure, since the MediaQuery here has had it taken out (see+ // `didChangeMetrics` in `terminal_page.dart`).+ final keyboard = view.viewInsets.bottom / view.devicePixelRatio;+ final ceiling = MediaQuery.paddingOf(context).top + _topGap;+ final full = math.max(0.0, area.height - ceiling);+ // ⚠️ **The top is placed against the page as it stands with NO keyboard**+ // — a share of the screen up from its foot — so a keyboard coming up, the+ // field's or the rename dialog's, takes the bottom of the sheet and leaves+ // its top where it was. The sheet being read stays the sheet being read.+ final top = math.max(+ ceiling,+ area.height ++ keyboard -+ MediaQuery.sizeOf(context).height * _restingShare,+ );+ final height = (area.height - top)+ .clamp(math.min(full, _minHeight), full)+ .toDouble();+ return AnimatedBuilder(+ animation: Listenable.merge([widget.animation, _pull]),+ child: sheet,+ builder: (context, sheet) {+ final open = widget.animation.value;+ final pull = _pull.value;+ // How much of the veil is up: all of it with the sheet, and less of it+ // as a finger pulls the sheet back down — the blur and the tint clear+ // together, so a pull shows the terminal coming back into focus.+ final veil = open * (1 - pull);+ final blur = kDialogVeilBlur * veil;+ return Stack(+ children: [+ Positioned.fill(+ child: Semantics(+ button: true,+ label: MaterialLocalizations.of(context)+ .modalBarrierDismissLabel,+ child: GestureDetector(+ behavior: HitTestBehavior.opaque,+ onTap: _close,+ // Clipped, so the blur reads only the page this overlay+ // covers — a filter with no clip above it takes in the whole+ // screen.+ child: ClipRect(+ child: BackdropFilter(+ // Off while there is nothing to blur: the first frame of+ // the way up, the last of the way down.+ enabled: blur > 0,+ filter: ImageFilter.blur(sigmaX: blur, sigmaY: blur),+ child: ColoredBox(+ color: Colors.black.withValues(alpha: _scrim * veil),+ ),+ ),+ ),),),- Divider(height: 1, color: AppGlass.hair),- PhoneSearchScopeBar(search: _search),- // ⚠️ Handed the query and nothing else. Ranking lives inside it,- // so this screen and [PhoneSearchPage] cannot drift into- // returning different rows for the same words.- Expanded(- child: PhoneSearchResults(- notifier: widget.notifier,- controller: _search,- // ⚠️ 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,+ ),+ Positioned(+ left: 0,+ right: 0,+ bottom: 0,+ height: height,+ child: Transform.translate(+ offset: Offset(0, (1 - open + pull) * height),+ child: sheet,+ ),+ ),+ ],+ );+ },+ );+ }++ Widget _sheet(BuildContext context) {+ final media = MediaQuery.of(context);+ return GestureDetector(+ key: _sheetKey,+ // The whole sheet can be pulled down, as a route's sheet can. The lists+ // in it scroll on the same drag and win it where they are.+ onVerticalDragUpdate: _onPull,+ onVerticalDragEnd: _onRelease,+ onVerticalDragCancel: _settle,+ child: CustomPaint(+ foregroundPainter: _TopRim(color: AppGlass.hair),+ child: Material(+ // A step above the terminal it covers — see [sheetFill].+ color: sheetFill,+ shape: const RoundedRectangleBorder(+ borderRadius: BorderRadius.vertical(top: Radius.circular(_radius)),+ ),+ clipBehavior: Clip.antiAlias,+ child: MediaQuery(+ // The lists run down under the strip at the foot of the window and+ // pad their own last row clear of it. The top is the sheet's edge,+ // nowhere near the status bar.+ data: media.copyWith(+ padding: media.padding.copyWith(+ top: 0,+ bottom: widget.bottomInset,+ ),+ ),+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.stretch,+ children: [+ const _Grip(),+ ListenableBuilder(+ listenable: _search,+ builder: (context, _) => SheetSearchField(+ controller: _controller,+ focus: _focus,+ // Inside a project or a machine the box says which — the+ // one thing on the sheet that does, other than the caption.+ hintText: _search.canGoBack ? _search.hint : _hint,+ onChanged: _search.setQuery,+ onClear: () {+ _controller.clear();+ _search.setQuery('');+ // Clearing is a step back into browsing, not out of the+ // search — the caret stays where the next query will go.+ _focus.requestFocus();+ },+ onCancel: _searching ? _cancel : null,+ ),+ ),+ Expanded(child: _content()),+ ],+ ),+ ),+ ),+ ),+ );+ }++ Widget _content() => Stack(+ fit: StackFit.expand,+ children: [+ // ⚠️ **The tabs stay built under the results**, faded out and deaf to+ // touch, rather than coming down with the search. The tab being read is+ // their own state, and Cancel has to land back on it — not on the tab+ // the sheet happened to open on.+ IgnorePointer(+ ignoring: _searching,+ child: ExcludeSemantics(+ excluding: _searching,+ child: FadeTransition(+ opacity: _tabsShown,+ child: DeskTabsPanel(+ notifier: widget.notifier,+ showing: widget.showing,+ onOpen: _open,+ onClose: _close,+ ),+ ),+ ),+ ),+ if (_resultsUp)+ IgnorePointer(+ ignoring: !_searching,+ child: FadeTransition(+ opacity: _resultsShown,+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.stretch,+ children: [+ _SearchHead(search: _search, onMode: _pickMode, onBack: _back),+ // ⚠️ Handed the query and nothing else. Ranking lives inside+ // it, so this sheet and [PhoneSearchPage] cannot drift into+ // returning different rows for the same words.+ Expanded(+ child: PhoneSearchResults(+ notifier: widget.notifier,+ controller: _search,+ // The rows the tabs under them are drawn with.+ grouped: true,+ showing: widget.showing,+ // ⚠️ Nothing pops this sheet — 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,+ ),+ ),+ ],+ ),+ ),+ ),+ ],+ );+}++/// What sits over the results: the modes while the field is empty, and once+/// there is a query, a caption naming what is listed and how much of it.+///+/// ```+/// (> Commands) (# Projects) (@ Machines) (? Help) ← nothing typed yet+/// HARNESSES 4/14 ← a query+/// ‹ MACBOOK PRO 9 ← inside a machine+/// ```+///+/// ⚠️ **The chips are where the modes are taught now.** The field used to+/// spell all four out in its hint — `Search harnesses > commands # proj…` —+/// at 13pt and still cut off on a phone. A chip is read at full size and+/// takes you into its mode, which is the lesson a hint could only describe.+///+/// ⚠️ **No caption over an untouched list.** "Recent" over the rows the+/// search opens on would cost a row of a sheet the keyboard has already+/// halved, and say nothing the order of the rows does not.+class _SearchHead extends StatelessWidget {+ const _SearchHead({+ required this.search,+ required this.onMode,+ required this.onBack,+ });++ final PhoneSearchController search;++ /// A chip tapped: the mode's character, to go in the field.+ final ValueChanged<String> onMode;++ /// The caption's chevron, inside a project or a machine.+ final VoidCallback onBack;++ @override+ Widget build(BuildContext context) => ListenableBuilder(+ listenable: search,+ builder: (context, _) {+ AppTheme.watch(context);+ final scoped = search.canGoBack;+ if (!scoped && search.query.trim().isEmpty) {+ return _ModeChips(onPick: onMode);+ }+ return SheetCaption(+ label: scoped+ ? search.scopeName ?? ''+ : search.isCommandMode || search.isHelpMode || search.isGroupMode+ ? search.title+ : 'Harnesses',+ // Only once the query has actually excluded something: `14/14` over+ // an untouched list is noise dressed as information.+ count: search.matchCount == search.total+ ? '${search.total}'+ : '${search.matchCount}/${search.total}',+ onBack: scoped ? onBack : null,+ );+ },+ );+}++/// The four modes the field takes, as a row of chips — see [_SearchHead].+class _ModeChips extends StatelessWidget {+ const _ModeChips({required this.onPick});++ final ValueChanged<String> onPick;++ /// The desktop's four, in the order the field's hint used to spell them+ /// out, with Help last: it is the one that explains the other three.+ static const _modes = [+ ('>', 'Commands'),+ ('#', 'Projects'),+ ('@', 'Machines'),+ ('?', 'Help'),+ ];++ @override+ Widget build(BuildContext context) => SizedBox(+ // A 30pt chip, the 6pt the pills keep above theirs, and the 12pt a group+ // keeps from what is over it.+ height: 48,+ child: ListView.separated(+ scrollDirection: Axis.horizontal,+ padding: const EdgeInsets.fromLTRB(kSheetInset, 6, kSheetInset, 12),+ itemCount: _modes.length,+ separatorBuilder: (context, index) => const SizedBox(width: 8),+ itemBuilder: (context, index) {+ final (glyph, label) = _modes[index];+ return _ModeChip(+ glyph: glyph,+ label: label,+ // The space is the desktop's: `> ` is where a query in that mode+ // starts, and the caret lands after it.+ onTap: () => onPick('$glyph '),+ );+ },+ ),+ );+}++class _ModeChip extends StatefulWidget {+ const _ModeChip({+ required this.glyph,+ required this.label,+ required this.onTap,+ });++ final String glyph;+ final String label;+ final VoidCallback onTap;++ @override+ State<_ModeChip> createState() => _ModeChipState();+}++class _ModeChipState extends State<_ModeChip> {+ bool _pressed = false;++ void _press(bool pressed) {+ if (_pressed == pressed) return;+ setState(() => _pressed = pressed);+ }++ @override+ Widget build(BuildContext context) {+ AppTheme.watch(context);+ return Semantics(+ button: true,+ label: '${widget.label} mode',+ excludeSemantics: true,+ child: GestureDetector(+ behavior: HitTestBehavior.opaque,+ onTapDown: (_) => _press(true),+ onTapUp: (_) => _press(false),+ onTapCancel: () => _press(false),+ onTap: () {+ HapticFeedback.selectionClick();+ widget.onTap();+ },+ child: AnimatedContainer(+ duration: AppMotion.press,+ curve: AppMotion.curve,+ padding: const EdgeInsets.symmetric(horizontal: 12),+ alignment: Alignment.center,+ decoration: BoxDecoration(+ // The rows' own fill: a chip is a row of the list that happens+ // to be short, not a button of the chrome.+ color: _pressed ? sheetRowPressedFill : sheetRowFill,+ borderRadius: BorderRadius.circular(15),+ ),+ child: Row(+ mainAxisSize: MainAxisSize.min,+ children: [+ // The character in the terminal's face and the accent — it is+ // what gets typed, and it should look like something typed.+ Text(+ widget.glyph,+ style: phoneBoxMonoStyle(+ size: 13,+ color: AppPalette.accentOnSurface,+ weight: FontWeight.w600,+ ).copyWith(height: 1),+ ),+ const SizedBox(width: 6),+ Text(+ widget.label,+ maxLines: 1,+ style: TextStyle(+ color: AppPalette.textPrimary,+ fontSize: 13.5,+ fontWeight: FontWeight.w500,),),],@@ -158,3 +760,69 @@ class _TerminalSearchOverlayState extends State<TerminalSearchOverlay> {);}}++/// The sheet's top edge, drawn: a hairline of light round its two corners and+/// across, where the sheet meets the veil.+///+/// ⚠️ **The rim does what the fill cannot.** Two dark surfaces are parted by+/// very little however their fills are chosen, and a veil darkens the page+/// towards the sheet as much as away from it — the rim is the one thing on the+/// edge brighter than both. It is the app's own recipe for anything floating+/// over dark (see [AppMenu]): the fill lifts, the rim draws the edge.+///+/// ⚠️ **The top only.** The sheet runs the full width of the phone and down+/// under the home indicator; a rim all the way round would be a line down+/// each side of the screen.+class _TopRim extends CustomPainter {+ const _TopRim({required this.color});++ final Color color;++ @override+ void paint(Canvas canvas, Size size) {+ const radius = _TerminalSearchOverlayState._radius;+ // Half the stroke in from the edge, so the whole line lies on the sheet+ // rather than half of it out over the veil.+ const inset = 0.5;+ const corner = Radius.circular(radius - inset);+ final rim = Path()+ ..moveTo(inset, radius)+ ..arcToPoint(const Offset(radius, inset), radius: corner)+ ..lineTo(size.width - radius, inset)+ ..arcToPoint(Offset(size.width - inset, radius), radius: corner);+ canvas.drawPath(+ rim,+ Paint()+ ..style = PaintingStyle.stroke+ ..strokeWidth = 1+ ..color = color,+ );+ }++ @override+ bool shouldRepaint(_TopRim old) => old.color != color;+}++/// The bar at the top of the sheet that says it can be pulled down: iOS's+/// grabber, at its size — drawn by hand because this sheet is not a route's.+class _Grip extends StatelessWidget {+ const _Grip();++ @override+ Widget build(BuildContext context) {+ AppTheme.watch(context);+ return SizedBox(+ height: 16,+ child: Center(+ child: Container(+ width: 36,+ height: 5,+ decoration: BoxDecoration(+ color: AppPalette.textFaint,+ borderRadius: BorderRadius.circular(2.5),+ ),+ ),+ ),+ );+ }+}