Skip to content

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

feat(mobile): redesign phone sheets and rename dialog

tony73575110e1c3
diff --git a/mobile/lib/phone/phone_sheet.dart b/mobile/lib/phone/phone_sheet.dart
index 6799726e7..8b0dea657 100644
--- a/mobile/lib/phone/phone_sheet.dart
+++ b/mobile/lib/phone/phone_sheet.dart
@@ -1,7 +1,13 @@
+import 'dart:ui' show ImageFilter;
+
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/shared/widgets/app_dialog.dart'
+ show kDialogVeilBlur, kSheetVeilOpacity;
+
+import 'settings_row.dart';
/// One action in a phone sheet.
class PhoneSheetAction {
@@ -13,6 +19,7 @@ class PhoneSheetAction {
this.value,
this.valueColor,
this.enabled = true,
+ this.chevron = false,
});
final IconData icon;
@@ -27,23 +34,30 @@ class PhoneSheetAction {
/// A quiet word at the end of the row — a machine's state, on a machine row.
final String? value;
- /// The colour of [value]; the faint text colour when null.
+ /// The colour of [value]; the secondary text colour when null — what a [SettingsRow]'s value
+ /// is drawn in, since the two rows now sit in the same cards.
final Color? valueColor;
/// False draws the row dimmed and leaves the sheet open on a tap: an offline machine is listed
/// so its absence is not a mystery, not so it can be opened.
final bool enabled;
+
+ /// Ends the row with a chevron: it opens a page or a picker of its own rather than acting where
+ /// it stands — Harnesses, Machines, Settings on an agent's sheet.
+ ///
+ /// The mark a [SettingsRow] that opens something carries, so a door reads as a door on both.
+ /// Without it the doors and the actions were the same row, and nothing told them apart.
+ final bool chevron;
}
-/// A captioned run of rows in a phone sheet.
+/// A run of rows in a phone sheet, drawn as one card — under a caption, or with none.
class PhoneSheetSection {
- PhoneSheetSection({
- required this.caption,
- required this.actions,
- this.maxVisible,
- });
+ PhoneSheetSection({this.caption, required this.actions, this.maxVisible});
- final String caption;
+ /// The heading over the card. Null draws the card bare, a gap below the one before it: for a
+ /// run the sheet's title already names, or for a row that has to stand apart from its
+ /// neighbours — the destructive one that ends an agent's sheet.
+ final String? caption;
final List<PhoneSheetAction> actions;
/// Rows shown before an "N more" row that reveals the rest. Null shows everything.
@@ -62,14 +76,23 @@ class PhoneSheetSection {
void expand() => _expanded = true;
}
-/// The `⋯` menu on a phone page: a title line and a column of actions.
+/// The `⋯` menu on a phone page: a title line, then its actions in inset cards.
///
/// The desktop reaches the same actions through a right-click menu, which a phone has no gesture
/// for. One sheet rather than a menu per page: the actions differ, the shape does not.
///
-/// [sections] draws captioned groups after [actions]; an empty section is left out.
+/// The rows sit in cards — the Settings page's own [SettingsGroup], under its [SettingsCaption] —
+/// so a sheet and the pages it opens onto read as one surface. A card is also what says which rows
+/// belong together: in one flat column of equal rows, the actions ON the subject and the doors to
+/// other pages looked the same, and the one row that cannot be undone sat among them like the rest.
+///
+/// [actions] is the first card, with no caption. Each of [sections] is a card after it — under its
+/// caption, or a gap below the card before when it has none. An empty section is left out.
///
-/// [titleDetail] is drawn under [titleParts] — machine, folder and branch, on an agent's sheet.
+/// [titleLeading] is drawn left of the title — the engine mark, on an agent's sheet — and
+/// [titleDetail] under [titleParts]: machine, folder and branch.
+///
+/// The page behind stands on the app's sheet veil, dimmed and blurred — see [_PhoneSheetRoute].
Future<void> showPhoneSheet(
BuildContext context, {
required String title,
@@ -78,138 +101,230 @@ Future<void> showPhoneSheet(
PhoneSheetAction? titleAction,
List<String>? titleParts,
Widget? titleDetail,
-}) => showModalBottomSheet<void>(
- context: context,
- useRootNavigator: true,
- showDragHandle: true,
- backgroundColor: AppPalette.panelBg,
- // ⚠️ **Without this the sheet is capped at 9/16 of the screen**, which is Flutter's default and
- // is not a height anything here asked for. An agent's sheet — three actions, two captions, a
- // three-line title detail — outgrows it on a normal phone, and the row that fell past the cap was
- // Settings: the column below scrolls, so nothing was broken, but a sheet that ends mid-list with
- // no bottom edge in sight reads as the whole menu rather than as a scrollable one.
- isScrollControlled: true,
- // A ceiling of its own, because `isScrollControlled` alone removes the cap altogether and lets a
- // long sheet stand up the full height of the screen — voice input's six languages would. Short of
- // the top on purpose: the gap is what says a sheet is a layer over the page rather than a page of
- // its own, and it keeps the terminal underneath recognisable while its own menu is open.
- constraints: BoxConstraints(
- maxHeight: MediaQuery.sizeOf(context).height * 0.85,
- ),
- builder: (sheetContext) => SafeArea(
- child: Column(
- mainAxisSize: MainAxisSize.min,
- crossAxisAlignment: CrossAxisAlignment.stretch,
- children: [
- Padding(
- padding: EdgeInsets.fromLTRB(20, 0, titleAction == null ? 20 : 8, 10),
- child: Row(
- children: [
- Expanded(
- child: titleParts == null
- ? Text(
- title,
- maxLines: 2,
- overflow: TextOverflow.ellipsis,
- style: TextStyle(
- color: AppPalette.textSecondary,
- fontSize: 13,
- ),
- )
- : Column(
- mainAxisSize: MainAxisSize.min,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- _TitleParts(parts: titleParts),
- if (titleDetail != null) ...[
- const SizedBox(height: 3),
- titleDetail,
- ],
- ],
- ),
+ Widget? titleLeading,
+}) {
+ assert(debugCheckHasMediaQuery(context));
+ assert(debugCheckHasMaterialLocalizations(context));
+ // What `showModalBottomSheet` does, with [_PhoneSheetRoute] pushed in place of its route —
+ // that function has no way to take another. Every argument below is one it would pass for the
+ // same call; the veil is the only difference.
+ final navigator = Navigator.of(context, rootNavigator: true);
+ final localizations = MaterialLocalizations.of(context);
+ return navigator.push(
+ _PhoneSheetRoute<void>(
+ capturedThemes: InheritedTheme.capture(
+ from: context,
+ to: navigator.context,
+ ),
+ barrierLabel: localizations.scrimLabel,
+ barrierOnTapHint: localizations.scrimOnTapHint(
+ localizations.bottomSheetLabel,
+ ),
+ showDragHandle: true,
+ backgroundColor: AppPalette.panelBg,
+ // ⚠️ **Without this the sheet is capped at 9/16 of the screen**, which is Flutter's default and
+ // is not a height anything here asked for. An agent's sheet — three cards, a caption, a two-line
+ // title detail under the name — outgrows it on a normal phone, and the row that fell past the cap was
+ // Settings: the column below scrolls, so nothing was broken, but a sheet that ends mid-list with
+ // no bottom edge in sight reads as the whole menu rather than as a scrollable one.
+ isScrollControlled: true,
+ // A ceiling of its own, because `isScrollControlled` alone removes the cap altogether and lets a
+ // long sheet stand up the full height of the screen — voice input's six languages would. Short of
+ // the top on purpose: the gap is what says a sheet is a layer over the page rather than a page of
+ // its own, and it keeps the terminal underneath recognisable while its own menu is open.
+ constraints: BoxConstraints(
+ maxHeight: MediaQuery.sizeOf(context).height * 0.85,
+ ),
+ builder: (sheetContext) => SafeArea(
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ Padding(
+ // 20 from the edge is 4 inside the cards' own 16 — where a Settings caption stands over
+ // its card — so the title reads as the heading of what follows it. A title with parts
+ // (an agent's name over where it runs) is a block of its own and takes more room below.
+ padding: EdgeInsets.fromLTRB(
+ 20,
+ 0,
+ titleAction == null ? 20 : 8,
+ titleParts == null ? 12 : 16,
),
- // [titleAction]: an icon on the title line — for something that is not about the
- // subject of the sheet (Settings, on an agent's sheet), so it does not take a row
- // among the actions that are. Its label is the tooltip.
- if (titleAction != null)
- IconButton(
- tooltip: titleAction.label,
- icon: Icon(
- titleAction.icon,
- size: 20,
- color: AppPalette.textSecondary,
+ child: Row(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ if (titleLeading != null) ...[
+ titleLeading,
+ const SizedBox(width: 14),
+ ],
+ Expanded(
+ child: titleParts == null
+ ? Text(
+ title,
+ maxLines: 2,
+ overflow: TextOverflow.ellipsis,
+ style: TextStyle(
+ color: AppPalette.textSecondary,
+ fontSize: 13,
+ ),
+ )
+ : Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ _TitleParts(parts: titleParts),
+ if (titleDetail != null) ...[
+ const SizedBox(height: 3),
+ titleDetail,
+ ],
+ ],
+ ),
),
- visualDensity: VisualDensity.compact,
- onPressed: () {
- Navigator.of(sheetContext).pop();
- titleAction.onTap();
- },
- ),
- ],
- ),
- ),
- // Scrolls once the rows outgrow the sheet — voice input's six languages do on a short phone —
- // and is laid out exactly like a plain column until then.
- Flexible(
- // Stateful only for [PhoneSheetSection.maxVisible]: "N more" opens the rest in place
- // rather than closing the sheet.
- child: StatefulBuilder(
- builder: (context, setSheetState) => ListView(
- shrinkWrap: true,
- padding: EdgeInsets.zero,
- children: [
- for (final action in actions)
- _SheetRow(
- action: action,
+ // [titleAction]: an icon on the title line — for something that is not about the
+ // subject of the sheet (Settings, on an agent's sheet), so it does not take a row
+ // among the actions that are. Its label is the tooltip.
+ if (titleAction != null)
+ IconButton(
+ tooltip: titleAction.label,
+ icon: Icon(
+ titleAction.icon,
+ size: 20,
+ color: AppPalette.textSecondary,
+ ),
+ visualDensity: VisualDensity.compact,
+ onPressed: () {
+ Navigator.of(sheetContext).pop();
+ titleAction.onTap();
+ },
+ ),
+ ],
+ ),
+ ),
+ // Scrolls once the rows outgrow the sheet — voice input's six languages do on a short phone —
+ // and is laid out exactly like a plain column until then.
+ Flexible(
+ // Stateful only for [PhoneSheetSection.maxVisible]: "N more" opens the rest in place
+ // rather than closing the sheet.
+ child: StatefulBuilder(
+ builder: (context, setSheetState) => ListView(
+ shrinkWrap: true,
+ // The cards' inset from the sheet's edge: the Settings list's own 16.
+ padding: const EdgeInsets.symmetric(horizontal: 16),
+ children: _sheetCards(
+ actions: actions,
+ sections: sections,
// Close first, then act: an action that opens a dialog or pushes a page must not
// do it underneath a sheet that is still animating out.
- onTap: () {
+ onAction: (action) {
Navigator.of(sheetContext).pop();
action.onTap();
},
+ // Stays open: this row reveals, it does not act.
+ onExpand: (section) => setSheetState(section.expand),
),
- for (final section in sections)
- if (section.actions.isNotEmpty) ...[
- Padding(
- padding: const EdgeInsets.fromLTRB(20, 14, 20, 4),
- child: Text(
- section.caption.toUpperCase(),
- style: TextStyle(
- color: AppPalette.textFaint,
- fontSize: 11.5,
- fontWeight: FontWeight.w600,
- letterSpacing: 0.6,
- ),
- ),
- ),
- for (final action in section.visible)
- _SheetRow(
- action: action,
- onTap: () {
- Navigator.of(sheetContext).pop();
- action.onTap();
- },
- ),
- if (section.hiddenCount > 0)
- _SheetRow(
- action: PhoneSheetAction(
- icon: LucideIcons.ellipsis300,
- label: '${section.hiddenCount} more',
- onTap: () {},
- ),
- // Stays open: this row reveals, it does not act.
- onTap: () => setSheetState(section.expand),
- ),
- ],
- ],
+ ),
+ ),
),
- ),
+ const SizedBox(height: 12),
+ ],
),
- const SizedBox(height: 8),
- ],
+ ),
),
- ),
-);
+ );
+}
+
+/// The route [showPhoneSheet] pushes: Material's own bottom sheet, standing on the app's sheet veil
+/// rather than a flat `black54` — the page dimmed to [kSheetVeilOpacity] and blurred at
+/// [kDialogVeilBlur], as it is under the search sheet.
+///
+/// ⚠️ **Blurred, because what is behind these sheets is usually a live terminal.** Dimmed text is
+/// still text: under the flat tint its lines stayed legible — and moving — and the eye went on
+/// reading them instead of the rows it opened the sheet for.
+///
+/// The blur rides the route's own animation on the tint's curve, so the two deepen together as the
+/// sheet rises and thin together as a drag pulls it down. The route's `filter` would not: that is
+/// applied at full strength from the first frame to the last, so the page would go soft before the
+/// tint had begun and snap sharp only once the sheet had gone.
+///
+/// Everything else is [ModalBottomSheetRoute]'s own — the barrier this wraps included, with its tap
+/// to dismiss and its semantics.
+class _PhoneSheetRoute<T> extends ModalBottomSheetRoute<T> {
+ _PhoneSheetRoute({
+ required super.builder,
+ required super.capturedThemes,
+ required super.barrierLabel,
+ required super.barrierOnTapHint,
+ required super.backgroundColor,
+ required super.constraints,
+ required super.showDragHandle,
+ required super.isScrollControlled,
+ }) : super(
+ modalBarrierColor: Colors.black.withValues(alpha: kSheetVeilOpacity),
+ );
+
+ @override
+ Widget buildModalBarrier() {
+ final animation = this.animation!;
+ return AnimatedBuilder(
+ animation: animation,
+ builder: (context, barrier) {
+ final blur = kDialogVeilBlur * barrierCurve.transform(animation.value);
+ return 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: barrier,
+ );
+ },
+ child: super.buildModalBarrier(),
+ );
+ }
+}
+
+/// The body of a sheet, as cards: [actions] first, then every section that has rows.
+List<Widget> _sheetCards({
+ required List<PhoneSheetAction> actions,
+ required List<PhoneSheetSection> sections,
+ required void Function(PhoneSheetAction action) onAction,
+ required void Function(PhoneSheetSection section) onExpand,
+}) {
+ final cards = <Widget>[];
+ void addCard(List<Widget> rows, {String? caption}) {
+ if (caption != null) {
+ cards.add(SettingsCaption(caption));
+ } else if (cards.isNotEmpty) {
+ // A bare card still has to part from the one above it, or the two read as one card with a
+ // seam in it — and the row set apart would not be.
+ cards.add(const SizedBox(height: 16));
+ }
+ cards.add(SettingsGroup(children: rows));
+ }
+
+ if (actions.isNotEmpty) {
+ addCard([
+ for (final action in actions)
+ _SheetRow(action: action, onTap: () => onAction(action)),
+ ]);
+ }
+ for (final section in sections) {
+ if (section.actions.isEmpty) continue;
+ addCard([
+ for (final action in section.visible)
+ _SheetRow(action: action, onTap: () => onAction(action)),
+ if (section.hiddenCount > 0)
+ _SheetRow(
+ action: PhoneSheetAction(
+ icon: LucideIcons.ellipsis300,
+ label: '${section.hiddenCount} more',
+ onTap: () {},
+ ),
+ onTap: () => onExpand(section),
+ ),
+ ], caption: section.caption);
+ }
+ return cards;
+}
/// A title made of named parts — an agent, then its machine — one per line.
///
@@ -231,10 +346,12 @@ class _TitleParts extends StatelessWidget {
parts[index],
maxLines: 2,
overflow: TextOverflow.ellipsis,
+ // 17 over the place lines' 13: the name is what the whole sheet is about, and it has to
+ // read as the heading of the cards under it rather than as one more line among them.
style: index == 0
? TextStyle(
color: AppPalette.textPrimary,
- fontSize: 15,
+ fontSize: 17,
fontWeight: FontWeight.w600,
)
: TextStyle(color: AppPalette.textSecondary, fontSize: 13),
@@ -243,6 +360,11 @@ class _TitleParts extends StatelessWidget {
);
}
+/// One row of a sheet's card: the icon, the label, then a value and a chevron when it has them.
+///
+/// On a [Material] of its own because the card under it is a painted box: an [InkWell] draws on the
+/// nearest Material, which without this is the sheet's — UNDER the card's fill, where no press
+/// would ever show. [SettingsRow] does the same, for the same reason.
class _SheetRow extends StatelessWidget {
const _SheetRow({required this.action, required this.onTap});
@@ -252,53 +374,74 @@ class _SheetRow extends StatelessWidget {
@override
Widget build(BuildContext context) {
AppTheme.watch(context);
+ // ⚠️ **The danger INK, not [AppPalette.dangerFill].** The fill is darkened to carry white
+ // lettering on top of it; used as the lettering itself it measured 3.4:1 on this sheet — under
+ // the 4.5:1 floor, on the one row a reader most needs to read right. `colorScheme.error` is the
+ // red tuned as ink on a dark surface: 4.8:1 on the card.
final color = !action.enabled
? AppPalette.textFaint
: action.destructive
- ? AppPalette.dangerFill
+ ? Theme.of(context).colorScheme.error
: AppPalette.textPrimary;
final value = action.value;
- return InkWell(
- onTap: action.enabled ? onTap : null,
- child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 13),
- child: Row(
- children: [
- Icon(action.icon, size: 20, color: color),
- const SizedBox(width: 14),
- Expanded(
- child: Text(
- action.label,
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: TextStyle(
- color: color,
- fontSize: 16,
- fontWeight: FontWeight.w500,
- ),
- ),
- ),
- if (value != null) ...[
- const SizedBox(width: 12),
- // Capped rather than left to its own width: a value can be as
- // long as a model id, and a Row lays a non-flex child out before
- // it gives the label what is left — so an uncapped one would eat
- // the label first and then run off the end of the sheet.
- ConstrainedBox(
- constraints: const BoxConstraints(maxWidth: 150),
+ return Material(
+ color: Colors.transparent,
+ child: InkWell(
+ onTap: action.enabled ? onTap : null,
+ child: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
+ child: Row(
+ children: [
+ Icon(action.icon, size: 20, color: color),
+ const SizedBox(width: 14),
+ Expanded(
child: Text(
- value,
+ action.label,
maxLines: 1,
overflow: TextOverflow.ellipsis,
- textAlign: TextAlign.end,
style: TextStyle(
- color: action.valueColor ?? AppPalette.textFaint,
- fontSize: 13,
+ color: color,
+ fontSize: 16,
+ fontWeight: FontWeight.w500,
),
),
),
+ if (value != null) ...[
+ const SizedBox(width: 12),
+ // Capped rather than left to its own width: a value can be as
+ // long as a model id, and a Row lays a non-flex child out before
+ // it gives the label what is left — so an uncapped one would eat
+ // the label first and then run off the end of the sheet.
+ ConstrainedBox(
+ constraints: const BoxConstraints(maxWidth: 150),
+ child: Text(
+ value,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ textAlign: TextAlign.end,
+ style: TextStyle(
+ color: action.valueColor ?? AppPalette.textSecondary,
+ fontSize: 14,
+ ),
+ ),
+ ),
+ ],
+ if (action.chevron)
+ Padding(
+ padding: const EdgeInsets.only(left: 4),
+ child: Transform.translate(
+ // Nudged right by the blank the glyph carries — see [kChevronInk] — so the
+ // arrow ends on the row's margin, where a label or a value would.
+ offset: const Offset(kChevronInk, 0),
+ child: Icon(
+ LucideIcons.chevronRight300,
+ size: 20,
+ color: AppPalette.textFaint,
+ ),
+ ),
+ ),
],
- ],
+ ),
),
),
);
diff --git a/mobile/lib/phone/settings_row.dart b/mobile/lib/phone/settings_row.dart
index c76cafde0..c7aaa4d39 100644
--- a/mobile/lib/phone/settings_row.dart
+++ b/mobile/lib/phone/settings_row.dart
@@ -29,7 +29,10 @@ const double kSettingsRowHeight = 50;
/// card's edge to be.
///
/// Re-measure if the icon size or the icon pack changes; this number belongs to both.
-const double _chevronInk = 6.68;
+///
+/// Public because the rows of `showPhoneSheet` end on the same chevron, at the same 20pt, inside
+/// the same cards — one measurement, not two copies of it drifting apart.
+const double kChevronInk = 6.68;
/// A row's own left padding, and the step a [SettingsRow.nested] child takes beyond it.
///
@@ -282,11 +285,11 @@ class SettingsRow extends StatelessWidget {
Padding(
padding: const EdgeInsets.only(left: 4),
child: Transform.translate(
- // Nudged right by the blank the glyph brings with it — see [_chevronInk].
+ // Nudged right by the blank the glyph brings with it — see [kChevronInk].
// Translate rather than a negative right padding, which `EdgeInsets`
// rejects: this has to move the ink WITHOUT giving the row a wider
// trailing box, or the chevron would simply take its padding back.
- offset: const Offset(_chevronInk, 0),
+ offset: const Offset(kChevronInk, 0),
child: Icon(
LucideIcons.chevronRight300,
size: 20,
diff --git a/mobile/lib/phone/terminal_header.dart b/mobile/lib/phone/terminal_header.dart
index 6364ee815..f5d0e0037 100644
--- a/mobile/lib/phone/terminal_header.dart
+++ b/mobile/lib/phone/terminal_header.dart
@@ -517,12 +517,14 @@ class _PlaceLine extends StatelessWidget {
}
}
-/// Where an agent runs, as the `⋯` sheet shows it under the agent's name, one
-/// line each behind its icon: the machine, the folder with its parent —
-/// `~/…/autonomous-harness/mobile` — and the branch.
+/// Where an agent runs, as the `⋯` sheet shows it under the agent's name, each
+/// part behind its icon: the machine on a line of its own, then the folder with
+/// its parent — `~/…/autonomous-harness/mobile` — and the branch side by side,
+/// the pair the header draws together too.
///
/// The header has room for the folder's own name alone; the sheet is where the
-/// rest of the path is read.
+/// rest of the path is read. The pair wraps rather than cutting either short: a
+/// path or branch too long to share the line moves the branch to one of its own.
class AgentPlaceLines extends StatelessWidget {
const AgentPlaceLines({
super.key,
@@ -545,35 +547,47 @@ class AgentPlaceLines extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (machineName.isNotEmpty)
- _line(LucideIcons.laptopMinimal300, machineName),
+ _line(_part(LucideIcons.laptopMinimal300, machineName)),
if (project != null)
- _line(LucideIcons.folder300, projectPathTrail(project.cwd)),
- if (branch != null) _line(LucideIcons.gitBranch300, branch),
+ _line(
+ Wrap(
+ spacing: 14,
+ runSpacing: 2,
+ children: [
+ _part(LucideIcons.folder300, projectPathTrail(project.cwd)),
+ if (branch != null) _part(LucideIcons.gitBranch300, branch),
+ ],
+ ),
+ ),
],
);
}
- Widget _line(IconData icon, String text) => Padding(
- padding: const EdgeInsets.only(top: 2),
- child: Row(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- // Nudged down to sit on the text's first line rather than its top.
- Padding(
- padding: const EdgeInsets.only(top: 2),
- child: Icon(icon, size: 13, color: AppPalette.textFaint),
- ),
- const SizedBox(width: 6),
- Expanded(
- child: Text(
- text,
- maxLines: 2,
- overflow: TextOverflow.ellipsis,
- style: TextStyle(color: AppPalette.textSecondary, fontSize: 13),
- ),
+ Widget _line(Widget child) =>
+ Padding(padding: const EdgeInsets.only(top: 2), child: child);
+
+ /// One part behind its icon, only as wide as its text — so the branch can sit
+ /// beside the folder — and wrapping to a second line, then cut with `…`, only
+ /// when it is longer than the line itself.
+ Widget _part(IconData icon, String text) => Row(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ // Nudged down to sit on the text's first line rather than its top.
+ Padding(
+ padding: const EdgeInsets.only(top: 2),
+ child: Icon(icon, size: 13, color: AppPalette.textFaint),
+ ),
+ const SizedBox(width: 6),
+ Flexible(
+ child: Text(
+ text,
+ maxLines: 2,
+ overflow: TextOverflow.ellipsis,
+ style: TextStyle(color: AppPalette.textSecondary, fontSize: 13),
),
- ],
- ),
+ ),
+ ],
);
}
diff --git a/mobile/lib/phone/terminal_page.dart b/mobile/lib/phone/terminal_page.dart
index c2b224bcb..90740d073 100644
--- a/mobile/lib/phone/terminal_page.dart
+++ b/mobile/lib/phone/terminal_page.dart
@@ -408,6 +408,23 @@ class _TerminalPageState extends State<TerminalPage>
/// the notifier declined without ever changing a status.
_Reclaim? _reclaiming;
+ /// The header's status as of its last build, for the mark on the actions sheet.
+ ///
+ /// The sheet is a route of its own, so this page's `setState` never reaches it: the mark there
+ /// listens to this instead, and shows the dot the header is showing for as long as the sheet is
+ /// up — a reconnect that starts under it included — rather than the moment it opened.
+ ///
+ /// ⚠️ Moved AFTER the frame, never during the build that works it out: the sheet listening to it
+ /// would otherwise be marked dirty in the middle of this page's build. See
+ /// [_publishActionsStatus].
+ final ValueNotifier<PhoneSummary> _actionsStatus = ValueNotifier((
+ label: '',
+ tone: PhoneTone.quiet,
+ ));
+
+ /// The status the end of this frame hands to [_actionsStatus]; null while none is waiting.
+ PhoneSummary? _nextActionsStatus;
+
/// The skeleton's one identity across the two places the body draws it.
///
/// ⚠️ **Two places, one skeleton.** It stands in for the panel while there is no session, and
@@ -627,10 +644,30 @@ class _TerminalPageState extends State<TerminalPage>
_searchHoldTimer?.cancel();
_chrome.dispose();
_searchOpen.dispose();
+ // A sheet still open over a page that is going keeps the last dot it was given; its listener
+ // comes off when it closes, which a disposed notifier allows.
+ _actionsStatus.dispose();
WidgetsBinding.instance.removeObserver(this);
super.dispose();
}
+ /// Hands [status] to the actions sheet's mark once this frame is done — see [_actionsStatus].
+ ///
+ /// The last build of a frame is the one handed over, and nothing is scheduled while the status
+ /// stands still.
+ void _publishActionsStatus(PhoneSummary status) {
+ final waiting = _nextActionsStatus != null;
+ if (!waiting && status == _actionsStatus.value) return;
+ _nextActionsStatus = status;
+ if (waiting) return;
+ WidgetsBinding.instance.addPostFrameCallback((_) {
+ final next = _nextActionsStatus;
+ _nextActionsStatus = null;
+ if (!mounted || next == null) return;
+ _actionsStatus.value = next;
+ });
+ }
+
/// Opens the account-wide agent list.
///
/// Awaited: the list is backed out of as often as it is tapped through, and
@@ -1119,6 +1156,9 @@ class _TerminalPageState extends State<TerminalPage>
takerName: takerName,
reconnecting: reconnecting,
);
+ // The actions sheet draws the same dot beside the agent's name, and is not rebuilt by this
+ // page — see [_actionsStatus].
+ _publishActionsStatus(headerStatus);
// Read this page's own buffer for a dialog, and raise the keyboard when one
// appears. Must run on every build: the session arrives a frame or two
// after the page, and the engine with the agent.
@@ -1471,6 +1511,7 @@ class _TerminalPageState extends State<TerminalPage>
machineName:
machine?.machine.displayName ?? '',
agent: agent,
+ status: headerStatus,
),
),
],
@@ -1575,26 +1616,50 @@ class _TerminalPageState extends State<TerminalPage>
});
}
- void _showActions({required String machineName, required Agent agent}) {
+ void _showActions({
+ required String machineName,
+ required Agent agent,
+ required PhoneSummary status,
+ }) {
+ // Set here, where no build is running, so the sheet opens on the dot the header shows now
+ // rather than on whatever the last frame handed over. See [_actionsStatus].
+ _actionsStatus.value = status;
final agentName = agent.name;
showPhoneSheet(
context,
title: '$agentName · $machineName',
- // The agent, then where it runs — machine, folder with its parent, branch — one line each
- // behind its icon. The header has no room for the path.
+ // The agent, then where it runs — the machine, then the folder with its parent beside the
+ // branch — each behind its icon. The header has no room for the path.
titleParts: [agentName],
+ // The engine mark carrying the header's own dot: the sheet's anchor, and the same picture of
+ // this agent the header draws above it. The ring is the sheet's ground, which the dot is
+ // notched out of.
+ titleLeading: ValueListenableBuilder<PhoneSummary>(
+ valueListenable: _actionsStatus,
+ builder: (context, status, _) {
+ AppTheme.watch(context);
+ return BadgedEngineMark(
+ agent: agent,
+ status: status,
+ ring: AppPalette.panelBg,
+ size: 40,
+ );
+ },
+ ),
titleDetail: AgentPlaceLines(
machineName: machineName,
project: agent.project,
),
- // Two groups: what acts on THIS agent, and the screens the app itself has. Each of those is a
- // door rather than a list of its own — the lists belong on the pages behind them, where they
- // have room for every row and do not push the rest of this sheet down.
+ // Three cards: what acts on THIS agent, the screens the app itself has, and — alone at the
+ // end — the one act that cannot be undone. No caption over the first: the name above it
+ // already says which harness its rows act on, which is also why they no longer repeat
+ // "Harness" in their labels.
+ //
+ // Each screen is a door rather than a list of its own — the lists belong on the pages behind
+ // them, where they have room for every row and do not push the rest of this sheet down. The
+ // chevron is what tells a door from an action.
sections: [
- PhoneSheetSection(
- caption: 'Harness',
- actions: [..._agentActions(agent)],
- ),
+ PhoneSheetSection(actions: _agentActions(agent)),
PhoneSheetSection(
caption: 'App',
actions: [
@@ -1607,11 +1672,13 @@ class _TerminalPageState extends State<TerminalPage>
PhoneSheetAction(
icon: LucideIcons.squareTerminal300,
label: 'Harnesses',
+ chevron: true,
onTap: () => unawaited(_openAgentList()),
),
PhoneSheetAction(
icon: LucideIcons.laptopMinimal300,
label: 'Machines',
+ chevron: true,
onTap: () => Navigator.of(context).push(
phoneRoute(
(_) => MachinesTab(notifier: widget.notifier, large: false),
@@ -1621,6 +1688,7 @@ class _TerminalPageState extends State<TerminalPage>
PhoneSheetAction(
icon: LucideIcons.settings300,
label: 'Settings',
+ chevron: true,
onTap: () => Navigator.of(context).push(
phoneRoute(
(_) => SettingsPage(notifier: widget.notifier, large: false),
@@ -1629,10 +1697,12 @@ class _TerminalPageState extends State<TerminalPage>
),
],
),
+ PhoneSheetSection(actions: [_stopAction(agent)]),
],
);
}
+ /// What acts on this agent and can be taken back — the first card of its sheet.
List<PhoneSheetAction> _agentActions(Agent agent) => [
// Where this agent runs, above the actions that act ON it: the desktop
// keeps it in the pane header, and this sheet is the phone's pane header.
@@ -1653,6 +1723,9 @@ class _TerminalPageState extends State<TerminalPage>
agent.engine,
displayName: agent.engineDisplayName,
).label,
+ // A picker of its own, so it ends on the chevron a Settings row with a
+ // value does.
+ chevron: true,
onTap: () => unawaited(
showAgentModelSheet(
context,
@@ -1664,7 +1737,7 @@ class _TerminalPageState extends State<TerminalPage>
),
PhoneSheetAction(
icon: LucideIcons.pencil300,
- label: 'Rename Harness…',
+ label: 'Rename…',
onTap: () => showAgentRenameDialog(
context,
widget.notifier,
@@ -1675,32 +1748,36 @@ class _TerminalPageState extends State<TerminalPage>
),
PhoneSheetAction(
icon: LucideIcons.refreshCw300,
- label: 'Restart Harness',
+ label: 'Restart',
onTap: () => unawaited(_restart()),
),
- // Last, and alone in red: the two above are recoverable and this one is
- // not, so it does not sit where a thumb lands on the way to them.
- //
- // ⚠️ Nothing here pops this page. Deleting detaches the pane, and the
- // `_hadPane` branch above leaves on its own when that happens — the same
- // path a delete from the list, or from the desktop, already takes. A pop
- // here would be a second one, and the parked pages in this pager share
- // the route.
- PhoneSheetAction(
- icon: LucideIcons.trash2300,
- label: 'Stop Harness…',
- destructive: true,
- onTap: () => unawaited(
- confirmDeleteAgent(
- context,
- widget.notifier,
- widget.machineId,
- widget.agentId,
- agent.name,
- ),
+ ];
+
+ /// Stopping the agent: the last card of its sheet, alone.
+ ///
+ /// Alone and in red because everything above it is recoverable and this is not, so it does not
+ /// sit where a thumb lands on the way to them. The label keeps "Harness" where the others dropped
+ /// it: a bare "Stop" in a terminal reads as stopping the reply that is running, and the list's
+ /// own sheet and the desktop say it this way too.
+ ///
+ /// ⚠️ Nothing here pops this page. Deleting detaches the pane, and the `_hadPane` branch above
+ /// leaves on its own when that happens — the same path a delete from the list, or from the
+ /// desktop, already takes. A pop here would be a second one, and the parked pages in this pager
+ /// share the route.
+ PhoneSheetAction _stopAction(Agent agent) => PhoneSheetAction(
+ icon: LucideIcons.trash2300,
+ label: 'Stop Harness…',
+ destructive: true,
+ onTap: () => unawaited(
+ confirmDeleteAgent(
+ context,
+ widget.notifier,
+ widget.machineId,
+ widget.agentId,
+ agent.name,
),
),
- ];
+ );
/// Asks for the terminal this pane is only watching, or reopens the stream it lost — the band's
/// button, and the header's.
diff --git a/mobile/lib/phone/terminal_search.dart b/mobile/lib/phone/terminal_search.dart
index d02c868c8..ccf9d247f 100644
--- a/mobile/lib/phone/terminal_search.dart
+++ b/mobile/lib/phone/terminal_search.dart
@@ -7,7 +7,7 @@ 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;
+ show kDialogVeilBlur, kSheetVeilOpacity;
import 'package:harness_mobile/state/app_state.dart';
import 'agent_index.dart';
@@ -118,8 +118,10 @@ class _TerminalSearchOverlayState extends State<TerminalSearchOverlay>
/// 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.
+ /// How dark the page goes behind the sheet — a step past Material's
+ /// `black54`, with the page blurred under it as well. The phone sheets stand
+ /// on the same veil ([kSheetVeilOpacity]), so every sheet over a terminal
+ /// dims it alike.
///
/// ⚠️ **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
@@ -128,7 +130,7 @@ class _TerminalSearchOverlayState extends State<TerminalSearchOverlay>
/// 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;
+ static const double _scrim = kSheetVeilOpacity;
/// 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.
diff --git a/mobile/lib/shared/widgets/app_dialog.dart b/mobile/lib/shared/widgets/app_dialog.dart
index 22f8f50f9..17ae811da 100644
--- a/mobile/lib/shared/widgets/app_dialog.dart
+++ b/mobile/lib/shared/widgets/app_dialog.dart
@@ -31,6 +31,16 @@ const double kDialogVeilBlur = 7;
/// stays in the background while the active surface has the user's attention.
const Color kDialogVeilTint = Color(0xE6000000);
+/// How dark the page goes behind a sheet — a step past the `black54` Material
+/// draws — with the page blurred at [kDialogVeilBlur] under it.
+///
+/// Far short of [kDialogVeilTint]: a sheet covers only part of the window and
+/// leaves the page above it in view, so the blur takes the page's text away and
+/// the tint only has to set the depth. One figure for the search sheet and for
+/// every `showPhoneSheet` sheet, so the sheets over a terminal all stand on the
+/// same veil.
+const double kSheetVeilOpacity = 0.64;
+
/// The app's dialog barrier: a blur, then a tint, then whatever opened.
///
/// Use it in place of `showDialog` wherever a panel should take the window's
diff --git a/mobile/lib/widgets/rename_agent_dialog.dart b/mobile/lib/widgets/rename_agent_dialog.dart
index 4ac8bb194..143ac0e17 100644
--- a/mobile/lib/widgets/rename_agent_dialog.dart
+++ b/mobile/lib/widgets/rename_agent_dialog.dart
@@ -1,8 +1,13 @@
+import 'dart:async';
+
import 'package:flutter/material.dart';
+import 'package:lucide_icons_flutter/lucide_icons.dart';
+import '../core/models.dart' show Agent;
import '../shared/theme/app_theme.dart' as grid;
import '../shared/widgets/app_dialog.dart';
import '../state/app_state.dart';
+import 'engine_identity.dart';
/// The one "Edit name" dialog, opened from every place a name is shown.
///
@@ -13,6 +18,11 @@ import '../state/app_state.dart';
/// Keyboard-complete on purpose — autofocus, Enter submits, Escape closes —
/// because the way in is a double click but the way through should never need
/// the mouse again.
+///
+/// And sized for a thumb as much as for a pointer, because the other way in is
+/// the phone's `⋯` sheet: the name at 17pt in a 50pt field, selected so the
+/// first key replaces it, and 46pt buttons. The title stays small — it names
+/// the act; the name is what the dialog is for.
Future<void> showAgentRenameDialog(
BuildContext context,
AppNotifier notifier,
@@ -29,6 +39,9 @@ Future<void> showAgentRenameDialog(
),
);
+/// The field's corner. Its focus ring stands 4 outside it, on the same curve.
+const double _fieldRadius = 12;
+
/// ⚠️ A widget that OWNS its controller, not a `StatefulBuilder` over one made
/// beside `showDialog`.
///
@@ -59,18 +72,90 @@ class _RenameAgentDialog extends StatefulWidget {
}
class _RenameAgentDialogState extends State<_RenameAgentDialog> {
- late final _controller = TextEditingController(text: widget.currentName);
+ /// Opens with the whole name selected, as the tab rename dialog does: the
+ /// name is there to be replaced, so the first key wipes it, and a thumb that
+ /// meant to edit it still has the caret.
+ late final _controller = TextEditingController(text: widget.currentName)
+ ..selection = TextSelection(
+ baseOffset: 0,
+ extentOffset: widget.currentName.length,
+ );
+
+ /// The field's focus, which is what draws the ring around it.
+ final _focus = FocusNode();
+
+ /// Where the agent runs, as it stood when the dialog opened — see [_placeOf].
+ late final _place = _placeOf(
+ widget.notifier,
+ widget.machineId,
+ widget.agentId,
+ );
+
+ /// The text as of the last edit. The controller also notifies on a caret
+ /// move, and only a change to the name itself takes an error back.
+ ///
+ /// ⚠️ Set in [initState], not by a `late` initializer: that would first run
+ /// inside [_onEdit] — after the edit — and read the new text as the old one,
+ /// so the first keystroke would change nothing on screen.
+ late String _text;
/// The CLI's refusal, shown under the field. Null until one arrives.
String? _error;
+ /// A rename is on its way to the machine: Save spins, and nothing sends a
+ /// second one behind it.
+ bool _busy = false;
+
+ @override
+ void initState() {
+ super.initState();
+ _text = _controller.text;
+ _controller.addListener(_onEdit);
+ _focus.addListener(_onFocus);
+ }
+
@override
void dispose() {
_controller.dispose();
+ _focus.dispose();
super.dispose();
}
+ String get _name => _controller.text.trim();
+
+ bool get _unchanged => _name == widget.currentName.trim();
+
+ /// Save is offered only for a name that is there and is new: the same name
+ /// sent back was a round trip for nothing, and an empty one was only ever
+ /// going to be refused.
+ bool get _canSave => !_busy && _name.isNotEmpty && !_unchanged;
+
+ void _onFocus() => setState(() {});
+
+ /// An edit takes back the last refusal — it was about a name that is not
+ /// there any more — and moves Save with it.
+ void _onEdit() {
+ if (_controller.text == _text) return;
+ setState(() {
+ _text = _controller.text;
+ _error = null;
+ });
+ }
+
Future<void> _submit() async {
+ if (_busy) return;
+ // Enter on the name it already has: nothing to send, and closing is what
+ // Save would have done had there been anything to save. An empty name goes
+ // through — the notifier refuses it on the spot, without a round trip, and
+ // the refusal is the answer the Enter was owed.
+ if (_name.isNotEmpty && _unchanged) {
+ Navigator.of(context).pop();
+ return;
+ }
+ setState(() {
+ _busy = true;
+ _error = null;
+ });
final result = await widget.notifier.renameAgent(
widget.machineId,
widget.agentId,
@@ -81,47 +166,302 @@ class _RenameAgentDialogState extends State<_RenameAgentDialog> {
Navigator.of(context).pop();
return;
}
- setState(() => _error = result);
+ setState(() {
+ _busy = false;
+ _error = result;
+ });
+ _focus.requestFocus();
}
@override
Widget build(BuildContext context) {
grid.AppTheme.watch(context);
- return AlertDialog(
- title: const Text('Rename Harness'),
- content: SizedBox(
- width: 360,
- child: Column(
- mainAxisSize: MainAxisSize.min,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- TextField(
- controller: _controller,
- autofocus: true,
- style: grid.kFieldTextStyle,
- onSubmitted: (_) => _submit(),
+ // The red tuned as ink on a dark surface, not [grid.AppPalette.dangerFill]:
+ // that one is darkened to carry white lettering, and as the lettering
+ // itself it measured 3.1:1 on this card.
+ final danger = Theme.of(context).colorScheme.error;
+ final error = _error;
+ return Dialog(
+ // 16 from a phone's edges rather than Material's 40, so the field is as
+ // wide as the name needs, up to the 360 the dialog stops at on anything
+ // wider.
+ insetPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 24),
+ child: Semantics(
+ scopesRoute: true,
+ namesRoute: true,
+ explicitChildNodes: true,
+ label: 'Rename Harness',
+ child: ConstrainedBox(
+ constraints: const BoxConstraints(maxWidth: 360),
+ child: Padding(
+ padding: const EdgeInsets.all(20),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ _heading(),
+ const SizedBox(height: 18),
+ _field(danger: danger, error: error),
+ if (error != null)
+ Semantics(
+ liveRegion: true,
+ child: Padding(
+ padding: const EdgeInsets.fromLTRB(2, 10, 2, 0),
+ child: Row(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Padding(
+ padding: const EdgeInsets.only(top: 1),
+ child: Icon(
+ LucideIcons.circleAlert300,
+ size: 15,
+ color: danger,
+ ),
+ ),
+ const SizedBox(width: 6),
+ Expanded(
+ child: Text(
+ error,
+ style: TextStyle(
+ color: danger,
+ fontSize: 13,
+ height: 1.35,
+ ),
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
+ const SizedBox(height: 20),
+ _actions(),
+ ],
),
- if (_error case final error?) ...[
- const SizedBox(height: 10),
+ ),
+ ),
+ ),
+ );
+ }
+
+ /// What is being renamed: the engine's mark, the act, and where the agent
+ /// runs. Small on purpose — the field under it is what the dialog is for.
+ Widget _heading() {
+ final agent = _place.agent;
+ return Row(
+ children: [
+ if (agent != null) ...[
+ EngineMark(
+ engine: agent.engine,
+ displayName: agent.engineDisplayName,
+ size: 32,
+ ),
+ const SizedBox(width: 12),
+ ],
+ Expanded(
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
Text(
- error,
+ 'Rename Harness',
style: TextStyle(
- color: grid.AppPalette.dangerFill,
- fontFamily: grid.AppFont.sans,
- fontSize: 11.2,
+ color: grid.AppPalette.textPrimary,
+ fontSize: 17,
+ fontWeight: grid.AppFont.semibold,
),
),
+ if (_place.detail.isNotEmpty) ...[
+ const SizedBox(height: 2),
+ Text(
+ _place.detail,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: TextStyle(
+ color: grid.AppPalette.textSecondary,
+ fontSize: 13,
+ ),
+ ),
+ ],
],
- ],
+ ),
),
+ ],
+ );
+ }
+
+ /// The name, in a field recessed below the card, with a ring around it while
+ /// it has focus — in red, while a refusal stands under it.
+ Widget _field({required Color danger, required String? error}) {
+ final accent = grid.AppPalette.accent;
+ final ring = error != null
+ ? danger.withValues(alpha: 0.2)
+ : _focus.hasFocus
+ ? accent.withValues(alpha: 0.3)
+ : Colors.transparent;
+ OutlineInputBorder border(Color color, {double width = 1}) =>
+ OutlineInputBorder(
+ borderRadius: BorderRadius.circular(_fieldRadius),
+ borderSide: BorderSide(color: color, width: width),
+ );
+ return AnimatedContainer(
+ duration: MediaQuery.disableAnimationsOf(context)
+ ? Duration.zero
+ : const Duration(milliseconds: 150),
+ curve: Curves.easeOut,
+ decoration: BoxDecoration(
+ borderRadius: BorderRadius.circular(_fieldRadius),
+ // A ring rather than a glow: no blur, spread only, so it reads as the
+ // field's edge standing out rather than as light behind it.
+ boxShadow: [BoxShadow(color: ring, spreadRadius: 4)],
),
- actions: [
- TextButton(
- onPressed: () => Navigator.of(context).pop(),
- child: const Text('Cancel'),
+ child: TextField(
+ controller: _controller,
+ focusNode: _focus,
+ autofocus: true,
+ // Held still while the machine answers: an edit made under the spinner
+ // would be a name nobody sent.
+ readOnly: _busy,
+ textInputAction: TextInputAction.done,
+ style: grid.kFieldTextStyle.copyWith(
+ fontSize: 17,
+ letterSpacing: grid.AppFont.trackingFor(17),
+ ),
+ onSubmitted: (_) => unawaited(_submit()),
+ decoration: InputDecoration(
+ filled: true,
+ fillColor: grid.AppPalette.panelBg,
+ isDense: true,
+ constraints: const BoxConstraints(minHeight: 50),
+ contentPadding: const EdgeInsets.fromLTRB(14, 15, 8, 15),
+ border: border(error != null ? danger : grid.AppGlass.hair),
+ enabledBorder: border(error != null ? danger : grid.AppGlass.hair),
+ focusedBorder: border(error != null ? danger : accent, width: 1.5),
+ suffixIcon: _controller.text.isEmpty || _busy
+ ? null
+ : IconButton(
+ tooltip: 'Clear',
+ visualDensity: VisualDensity.compact,
+ onPressed: () {
+ _controller.clear();
+ _focus.requestFocus();
+ },
+ icon: Icon(
+ LucideIcons.circleX300,
+ size: 18,
+ color: grid.AppPalette.textFaint,
+ ),
+ ),
+ suffixIconConstraints: const BoxConstraints(
+ minWidth: 44,
+ minHeight: 44,
+ ),
+ ),
+ ),
+ );
+ }
+
+ /// Cancel and Save, half the width each and tall enough for a thumb.
+ ///
+ /// Cancel is a neutral well rather than accent text: blue lettering on this
+ /// card measured 3.0:1, and a way out does not need the accent to be found.
+ Widget _actions() {
+ final accent = grid.AppPalette.accent;
+ return Row(
+ children: [
+ Expanded(
+ child: FilledButton(
+ style: _buttonStyle(
+ background: grid.AppSurface.recess,
+ foreground: grid.AppPalette.textPrimary,
+ ),
+ onPressed: () => Navigator.of(context).pop(),
+ child: const Text('Cancel'),
+ ),
+ ),
+ const SizedBox(width: 10),
+ Expanded(
+ child: FilledButton(
+ style: _buttonStyle(
+ background: accent,
+ foreground: Colors.white,
+ // Kept at full colour while it spins: the press was taken, and a
+ // button that greyed out under the thumb would read as refused.
+ disabledBackground: _busy
+ ? accent
+ : accent.withValues(alpha: 0.22),
+ disabledForeground: _busy
+ ? Colors.white
+ : Colors.white.withValues(alpha: 0.4),
+ ),
+ onPressed: _canSave ? () => unawaited(_submit()) : null,
+ child: _busy
+ ? Semantics(
+ label: 'Saving',
+ child: SizedBox.square(
+ dimension: 18,
+ child: CircularProgressIndicator(
+ strokeWidth: 2,
+ color: Colors.white,
+ backgroundColor: Colors.white.withValues(alpha: 0.35),
+ ),
+ ),
+ )
+ : const Text('Save'),
+ ),
),
- FilledButton(onPressed: _submit, child: const Text('Save')),
],
);
}
}
+
+/// A dialog button at a thumb's size: 46 tall, 16pt, on the field's corner.
+///
+/// Built on the app's filled button, so everything this leaves unsaid — the
+/// shrink-wrapped tap target, the hover overlay — is still the theme's.
+ButtonStyle _buttonStyle({
+ required Color background,
+ required Color foreground,
+ Color? disabledBackground,
+ Color? disabledForeground,
+}) => FilledButton.styleFrom(
+ backgroundColor: background,
+ foregroundColor: foreground,
+ disabledBackgroundColor: disabledBackground,
+ disabledForegroundColor: disabledForeground,
+ minimumSize: const Size.fromHeight(46),
+ padding: const EdgeInsets.symmetric(horizontal: 12),
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(_fieldRadius),
+ ),
+ // `ButtonStyle.textStyle` does not inherit the family from the text theme —
+ // see `_buttonTextStyle` in the theme — so it is named here too.
+ textStyle: TextStyle(
+ fontFamily: grid.AppFont.sans,
+ fontFamilyFallback: grid.AppFont.sansFallback,
+ fontSize: 16,
+ fontWeight: grid.AppFont.semibold,
+ ),
+);
+
+/// Where an agent runs, for the line under the title: the agent (for its
+/// engine's mark) and "machine · folder" — the two names every other place
+/// tells it apart by.
+///
+/// Read once, when the dialog opens. An agent missing from its machine's list
+/// leaves the mark out and names the machine alone; the rename then answers
+/// for itself.
+({Agent? agent, String detail}) _placeOf(
+ AppNotifier notifier,
+ String machineId,
+ String agentId,
+) {
+ final machine = notifier.stateOf(machineId);
+ final agent = machine?.agents.where((a) => a.id == agentId).firstOrNull;
+ return (
+ agent: agent,
+ detail: [
+ ?machine?.machine.displayName,
+ ?agent?.project?.folder,
+ ].where((part) => part.isNotEmpty).join(' · '),
+ );
+}