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): group new tab sheet by machine

tony6a13ca18cf3a
diff --git a/mobile/lib/phone/agent_context_line.dart b/mobile/lib/phone/agent_context_line.dart
index 3136a0abd..158506572 100644
--- a/mobile/lib/phone/agent_context_line.dart
+++ b/mobile/lib/phone/agent_context_line.dart
@@ -22,22 +22,22 @@ import 'package:harness_mobile/shared/theme/app_theme.dart';
/// with the folder and is cut first when that half runs out. It is the least use in *finding* an
/// agent, and the terminal page names it in full once one is open.
class AgentContextLine extends StatelessWidget {
- const AgentContextLine({
- super.key,
- required this.project,
- required this.machineName,
- });
+ const AgentContextLine({super.key, required this.project, this.machineName});
/// Null on a daemon too old to report it, and until the first agent snapshot binds one. The line
/// then names the machine alone rather than holding a gap open where the folder would be.
final AgentProject? project;
- final String machineName;
+ /// Null where the machine is already named above the row — the add-agent sheet groups its rows
+ /// under a heading per machine, and a name repeated on every row there is only width lost to the
+ /// folder and branch.
+ final String? machineName;
@override
Widget build(BuildContext context) {
AppTheme.watch(context);
final branch = project?.shownBranch;
+ final machineName = this.machineName;
final place = <InlineSpan>[
if (project != null) TextSpan(text: project!.label),
if (project != null && branch != null) _separator,
@@ -46,12 +46,13 @@ class AgentContextLine extends StatelessWidget {
return Row(
children: [
if (place.isNotEmpty) Flexible(child: _line(place)),
- Flexible(
- child: _line([
- if (place.isNotEmpty) _separator,
- TextSpan(text: machineName),
- ]),
- ),
+ if (machineName != null)
+ Flexible(
+ child: _line([
+ if (place.isNotEmpty) _separator,
+ TextSpan(text: machineName),
+ ]),
+ ),
],
);
}
diff --git a/mobile/lib/phone/desk_add_agent_sheet.dart b/mobile/lib/phone/desk_add_agent_sheet.dart
index 194b35748..fcff38760 100644
--- a/mobile/lib/phone/desk_add_agent_sheet.dart
+++ b/mobile/lib/phone/desk_add_agent_sheet.dart
@@ -2,38 +2,50 @@ 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 'agent_context_line.dart';
import 'agent_index.dart';
-import 'agent_tile.dart';
-import 'phone_card.dart';
+import 'phone_status.dart';
+import 'status_pill.dart';
/// What joins a tab: an agent the account already has, or one made now.
///
/// ```
/// ──────────────────────────────────
-/// Add to “harness mobile”
-/// ┌────────────────────────────┐
-/// │ + New agent │
-/// └────────────────────────────┘
-/// ┌────────────────────────────┐
-/// │ ◆ api-3 Live › │
-/// └────────────────────────────┘
+/// New tab
+/// ▭ Macbook Pro 2 harnesses
+/// ┌──────────────────────────────┐
+/// │ ✳ api-3 │
+/// │ ◌ Working… · app ⑂ main │
+/// │ ────────────────────────── │
+/// │ ✳ docs │
+/// │ ● Claude Code · site │
+/// └──────────────────────────────┘
+/// ──────────────────────────────────
+/// [ + New Harness ]
/// ```
///
-/// ⚠️ **The agents come first and "New agent" sits above them, rather than the
-/// two being a choice made before either is seen.** Both `+`s on the tabs panel
-/// land here, and in both cases the common move is to put something that is
-/// already running somewhere else — a person who wants a NEW agent is one tap
-/// from the form they would have opened anyway, and one who wants an existing
-/// one is looking at it.
+/// ⚠️ **Grouped under a heading per machine, and the machine is not on the
+/// rows.** A row that carried its machine at the end of the context line lost
+/// it to the ellipsis first — `claude-2026-09-2… · Macbook Pro - …` — which
+/// is the one fact that tells two agents of the same folder apart. On the
+/// heading it is written once, in full, and the row's second line goes to what
+/// it is doing and where.
+///
+/// ⚠️ **"New Harness" is pinned under the list, not the first row of it.**
+/// Both `+`s on the tabs panel land here, and the common move is to put
+/// something already running into the tab — so the agents keep the scrolling
+/// space, and making one is a button that is in the same place under the thumb
+/// however far the list has been scrolled.
///
/// [choices] is what this sheet may offer: for a tab, the agents it does not
/// already hold. An empty list is drawn as a sentence rather than as a hole —
/// an account whose every agent is already in the tab has nothing to pick, and
-/// the "New agent" row above still works.
+/// the "New Harness" button under it still works.
///
/// [onCreate] is null where no machine can host one (all asleep, or wanting a
-/// password), which leaves that row out rather than drawn dead.
+/// password), which leaves the button out rather than drawn dead.
Future<void> showDeskAddAgentSheet(
BuildContext context, {
required String title,
@@ -65,10 +77,27 @@ Future<void> showDeskAddAgentSheet(
),
);
-/// The rows' side inset: [phoneListPadding]'s 16, the measure the tabs panel
+/// The rows' side inset: `phoneListPadding`'s 16, the measure the tabs panel
/// gives its own rows.
const double _sideInset = 16;
+/// A row's inner padding, left and right.
+const double _rowInset = 14;
+
+/// The box the engine mark sits in, and the gap after it — together with
+/// [_rowInset], where a row's text starts and so where the hairline between two
+/// rows starts too.
+const double _markBox = 22;
+const double _markGap = 12;
+
+/// "Working…" as ink on a row, not [phoneToneColor]'s busy tone.
+///
+/// That tone is [AppPalette.accent], which is made to be a FILL under white
+/// text: on the dark row fill (#202020) it is 2.95:1 as a 12.5pt label, under
+/// the 4.5:1 floor. Lightened in dark to 6.9:1, still the same indigo; light
+/// keeps the accent, which already clears it there (5.0:1 on #F3F3F2).
+Color get _busyInk => AppTheme.pick(AppPalette.accent, const Color(0xFF8AA4FF));
+
class _AddAgentSheet extends StatelessWidget {
const _AddAgentSheet({
required this.title,
@@ -92,7 +121,7 @@ class _AddAgentSheet extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Padding(
- padding: const EdgeInsets.fromLTRB(_sideInset, 2, _sideInset, 12),
+ padding: const EdgeInsets.fromLTRB(_sideInset, 2, _sideInset, 14),
child: Text(
title,
maxLines: 1,
@@ -109,86 +138,331 @@ class _AddAgentSheet extends StatelessWidget {
// agents give way to another's dozen.
SizedBox(
height: MediaQuery.sizeOf(context).height * 0.5,
- child: ListView.separated(
- padding: EdgeInsets.fromLTRB(
- _sideInset,
- 0,
- _sideInset,
- MediaQuery.paddingOf(context).bottom + 8,
- ),
- itemCount: choices.length + (onCreate == null ? 0 : 1),
- separatorBuilder: (context, index) =>
- const SizedBox(height: kPhoneCardGap),
- itemBuilder: (context, index) {
- if (onCreate != null && index == 0) {
- return _NewAgentRow(onTap: onCreate);
- }
- final entry = choices[index - (onCreate == null ? 0 : 1)];
- return AgentTile(
- machine: entry.machine,
- agent: entry.agent,
- onTap: () => onPick(entry),
- );
- },
- ),
+ child: choices.isEmpty ? const _Empty() : _machineList(),
),
- if (choices.isEmpty)
- Padding(
- padding: const EdgeInsets.fromLTRB(_sideInset, 0, _sideInset, 8),
- child: Text(
- 'Every harness this phone can open is already here.',
- style: TextStyle(
- color: AppPalette.textSecondary,
- fontSize: 13.5,
- ),
- ),
- ),
+ if (onCreate != null) _NewHarnessBar(onTap: onCreate),
],
),
);
}
+
+ Widget _machineList() {
+ final groups = _byMachine(choices);
+ return ListView(
+ padding: const EdgeInsets.fromLTRB(_sideInset, 0, _sideInset, 16),
+ children: [
+ for (final (index, group) in groups.indexed) ...[
+ if (index > 0) const SizedBox(height: 20),
+ _MachineHeading(name: group.first.machineName, count: group.length),
+ _MachineGroup(entries: group, onPick: onPick),
+ ],
+ ],
+ );
+ }
}
-/// "New agent", drawn as a card the same height as the agents under it so the
-/// list reads as one column of things that can be put in a tab.
-class _NewAgentRow extends StatelessWidget {
- const _NewAgentRow({required this.onTap});
+/// [entries] split by machine, the machines in the order their first agent
+/// comes and each machine's agents in the order they came.
+///
+/// [choices] arrives in [visibleAgents] order — waiting, then working, then the
+/// rest — so the machine with an agent waiting on the person heads the sheet,
+/// and inside every group that same order still holds.
+List<List<AgentEntry>> _byMachine(List<AgentEntry> entries) {
+ final groups = <String, List<AgentEntry>>{};
+ for (final entry in entries) {
+ (groups[entry.machineId] ??= []).add(entry);
+ }
+ return groups.values.toList();
+}
- final VoidCallback onTap;
+/// The line over one machine's agents: the machine, named in full, and how many
+/// of its agents this sheet offers.
+class _MachineHeading extends StatelessWidget {
+ const _MachineHeading({required this.name, required this.count});
+
+ final String name;
+ final int count;
@override
Widget build(BuildContext context) {
AppTheme.watch(context);
- return PhoneCard(
- height: kPhoneAgentCardHeight,
- onTap: onTap,
+ return Padding(
+ padding: const EdgeInsets.fromLTRB(4, 0, 4, 8),
child: Row(
children: [
- PhoneCardGlyph(
- child: Icon(
- LucideIcons.plus300,
- size: 22,
- color: AppPalette.accentOnSurface,
- ),
+ Icon(
+ LucideIcons.laptopMinimal300,
+ size: 15,
+ color: AppPalette.textSecondary,
),
- const SizedBox(width: 14),
+ const SizedBox(width: 8),
Expanded(
child: Text(
- 'New Harness',
+ name,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
style: TextStyle(
color: AppPalette.textPrimary,
- fontSize: 15.5,
+ fontSize: 13,
fontWeight: FontWeight.w600,
),
),
),
- Icon(
- LucideIcons.chevronRight300,
- size: 18,
- color: AppPalette.textFaint,
+ const SizedBox(width: 8),
+ Text(
+ count == 1 ? '1 harness' : '$count harnesses',
+ style: TextStyle(
+ color: AppPalette.textSecondary,
+ fontSize: 12.5,
+ fontWeight: FontWeight.w500,
+ fontFeatures: AppFont.tabularFigures,
+ ),
),
],
),
);
}
}
+
+/// One machine's agents as a single rounded group, a hairline between rows —
+/// one object per machine rather than a card per agent, so the list reads as
+/// machines holding agents.
+class _MachineGroup extends StatelessWidget {
+ const _MachineGroup({required this.entries, required this.onPick});
+
+ final List<AgentEntry> entries;
+ final void Function(AgentEntry entry) onPick;
+
+ @override
+ Widget build(BuildContext context) {
+ AppTheme.watch(context);
+ final radius = BorderRadius.circular(AppCard.radius);
+ return Container(
+ clipBehavior: Clip.antiAlias,
+ decoration: BoxDecoration(color: AppGlass.rowFill, borderRadius: radius),
+ // The rim drawn OVER the rows, so a pressed row's fill runs to the
+ // group's edge without covering it.
+ foregroundDecoration: BoxDecoration(
+ borderRadius: radius,
+ border: Border.all(color: AppGlass.hair),
+ ),
+ child: Column(
+ children: [
+ for (final (index, entry) in entries.indexed) ...[
+ if (index > 0)
+ Padding(
+ padding: const EdgeInsets.only(
+ left: _rowInset + _markBox + _markGap,
+ ),
+ child: Container(height: 1, color: AppPalette.divider),
+ ),
+ _AgentRow(entry: entry, onTap: () => onPick(entry)),
+ ],
+ ],
+ ),
+ );
+ }
+}
+
+/// One agent: its engine, its name, and — on one line — what it is doing, the
+/// folder and the branch. Its machine is the heading above it.
+///
+/// An agent with no terminal is drawn dimmed and does not open, as
+/// `AgentTile` draws one — the tabs panel only offers agents that have one, so
+/// this is the rule kept, not a state the sheet expects to show.
+class _AgentRow extends StatefulWidget {
+ const _AgentRow({required this.entry, required this.onTap});
+
+ final AgentEntry entry;
+ final VoidCallback onTap;
+
+ @override
+ State<_AgentRow> createState() => _AgentRowState();
+}
+
+class _AgentRowState extends State<_AgentRow> {
+ bool _pressed = false;
+
+ bool get _openable => widget.entry.agent.terminalAvailable;
+
+ void _press(bool pressed) {
+ if (!_openable || _pressed == pressed) return;
+ setState(() => _pressed = pressed);
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ AppTheme.watch(context);
+ final agent = widget.entry.agent;
+ return GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTapDown: (_) => _press(true),
+ onTapUp: (_) => _press(false),
+ onTapCancel: () => _press(false),
+ onTap: _openable ? widget.onTap : null,
+ child: AnimatedContainer(
+ duration: AppMotion.press,
+ curve: AppMotion.curve,
+ color: _pressed ? AppGlass.rowHoverFill : AppGlass.rowFill,
+ padding: const EdgeInsets.symmetric(
+ horizontal: _rowInset,
+ vertical: 10,
+ ),
+ child: Opacity(
+ opacity: _openable ? 1 : 0.55,
+ child: Row(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ // Down a point, so the mark sits on the name's line rather than
+ // above it.
+ Padding(
+ padding: const EdgeInsets.only(top: 1),
+ child: SizedBox.square(
+ dimension: _markBox,
+ child: Center(
+ child: EngineMark(
+ engine: agent.engine,
+ displayName: agent.engineDisplayName,
+ size: 20,
+ ),
+ ),
+ ),
+ ),
+ const SizedBox(width: _markGap),
+ Expanded(
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(
+ agent.displayName,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: TextStyle(
+ color: AppPalette.textPrimary,
+ fontSize: 15.5,
+ fontWeight: FontWeight.w600,
+ ),
+ ),
+ const SizedBox(height: 4),
+ _StatusLine(entry: widget.entry),
+ ],
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
+ );
+ }
+}
+
+/// `◌ Working… · harness ⑂ main` — the status first, then [AgentContextLine]
+/// without its machine.
+///
+/// ⚠️ **The label keeps its width and the place gives way.** The label is one
+/// of a few short words, and it is the part a glance at the sheet is for; the
+/// folder and branch ellipsise inside what is left, the branch first — see
+/// [AgentContextLine]. The label is still capped, so an engine with a long name
+/// cannot push the place off the row entirely.
+class _StatusLine extends StatelessWidget {
+ const _StatusLine({required this.entry});
+
+ final AgentEntry entry;
+
+ @override
+ Widget build(BuildContext context) {
+ AppTheme.watch(context);
+ final summary = entry.summary;
+ final project = entry.project;
+ final (color, weight) = switch (summary.tone) {
+ PhoneTone.busy => (_busyInk, FontWeight.w500),
+ PhoneTone.attention => (AppPalette.warn, FontWeight.w600),
+ PhoneTone.quiet => (AppPalette.textSecondary, FontWeight.w500),
+ PhoneTone.good ||
+ PhoneTone.bad => (phoneToneColor(summary.tone), FontWeight.w500),
+ };
+ return Row(
+ children: [
+ StatusDot(
+ summary: summary,
+ spinnerColor: summary.tone == PhoneTone.busy ? _busyInk : null,
+ ),
+ const SizedBox(width: 6),
+ ConstrainedBox(
+ constraints: const BoxConstraints(maxWidth: 150),
+ child: Text(
+ summary.label,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: TextStyle(color: color, fontSize: 12.5, fontWeight: weight),
+ ),
+ ),
+ if (project != null) ...[
+ Text(
+ ' · ',
+ style: TextStyle(color: AppPalette.textFaint, fontSize: 12.5),
+ ),
+ Flexible(child: AgentContextLine(project: project)),
+ ],
+ ],
+ );
+ }
+}
+
+/// Nothing left to offer: every agent this phone can open is in the tab
+/// already. Said in the list's own space, so the button under it stays where it
+/// always is.
+class _Empty extends StatelessWidget {
+ const _Empty();
+
+ @override
+ Widget build(BuildContext context) {
+ AppTheme.watch(context);
+ return Padding(
+ padding: const EdgeInsets.fromLTRB(_sideInset + 4, 8, _sideInset + 4, 0),
+ child: Text(
+ 'Every harness this phone can open is already here.',
+ style: TextStyle(color: AppPalette.textSecondary, fontSize: 13.5),
+ ),
+ );
+ }
+}
+
+/// "New Harness", the sheet's one filled button — the app's primary action,
+/// drawn as the form it opens draws "Create Harness": the same fill, radius and
+/// 44pt height, so the two read as one flow.
+class _NewHarnessBar extends StatelessWidget {
+ const _NewHarnessBar({required this.onTap});
+
+ final VoidCallback onTap;
+
+ @override
+ Widget build(BuildContext context) {
+ AppTheme.watch(context);
+ return DecoratedBox(
+ decoration: BoxDecoration(
+ border: Border(top: BorderSide(color: AppPalette.divider)),
+ ),
+ child: Padding(
+ padding: const EdgeInsets.fromLTRB(_sideInset, 12, _sideInset, 8),
+ child: SizedBox(
+ height: 44,
+ child: FilledButton.icon(
+ style: FilledButton.styleFrom(
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(AppCard.radius),
+ ),
+ ),
+ onPressed: onTap,
+ icon: const Icon(LucideIcons.plus, size: 18),
+ label: const Text(
+ 'New Harness',
+ style: TextStyle(fontSize: 15, fontWeight: FontWeight.w600),
+ ),
+ ),
+ ),
+ ),
+ );
+ }
+}