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
Add phone status management and settings UI
Dev jacobb1c1619969ce
diff --git a/desktop/lib/main.dart b/desktop/lib/main.dartindex 4c465a658..1edfcd416 100644--- a/desktop/lib/main.dart+++ b/desktop/lib/main.dart@@ -8,6 +8,8 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';import 'analytics/analytics_lifecycle.dart';import 'core/crash_log.dart';import 'core/desktop_window.dart';+import 'phone/phone_layout.dart';+import 'phone/phone_shell.dart';import 'screens/swarm_screen.dart';import 'screens/login_screen.dart';import 'state/app_state.dart';@@ -265,7 +267,11 @@ class _RootShellState extends ConsumerState<RootShell>case AppStatus.unauthenticated:screen = LoginScreen(notifier: app);case AppStatus.authenticated:- screen = SwarmScreen(notifier: app);+ // A phone gets one agent at a time, reached machine → agents → terminal:+ // the desktop's tab strip above a grid of panes does not fit in its width.+ screen = usePhoneLayout(context)+ ? PhoneShell(notifier: app)+ : SwarmScreen(notifier: app);}// Only the home shell carries its own drag handle and traffic-light// clearance (the rail's head). Every other screen fills the windowdiff --git a/desktop/lib/phone/account_button.dart b/desktop/lib/phone/account_button.dartnew file mode 100644index 000000000..b1b7b89e5--- /dev/null+++ b/desktop/lib/phone/account_button.dart@@ -0,0 +1,96 @@+import 'dart:async';++import 'package:flutter/material.dart';++import '../shared/theme/app_theme.dart';+import '../state/app_state.dart';++/// Who is signed in, as a round initial in the corner of the machine list — and, on a tap, the+/// one account action a viewer has: signing out.+class AccountButton extends StatelessWidget {+ const AccountButton({super.key, required this.notifier});++ final AppNotifier notifier;++ String get _initial {+ final user = notifier.currentUser;+ final name = user?.name?.trim() ?? '';+ final source = name.isNotEmpty ? name : (user?.email ?? '');+ return source.isEmpty ? '?' : source.substring(0, 1).toUpperCase();+ }++ @override+ Widget build(BuildContext context) {+ AppTheme.watch(context);+ return Semantics(+ button: true,+ label: 'Account',+ child: GestureDetector(+ onTap: () => _showAccountSheet(context),+ child: Container(+ width: 40,+ height: 40,+ decoration: BoxDecoration(+ color: AppPalette.avatarFill,+ shape: BoxShape.circle,+ ),+ alignment: Alignment.center,+ child: Text(+ _initial,+ style: const TextStyle(+ color: Colors.white,+ fontSize: 16,+ fontWeight: FontWeight.w600,+ ),+ ),+ ),+ ),+ );+ }++ void _showAccountSheet(BuildContext context) {+ final user = notifier.currentUser;+ showModalBottomSheet<void>(+ context: context,+ useRootNavigator: true,+ showDragHandle: true,+ backgroundColor: AppPalette.panelBg,+ builder: (sheetContext) => SafeArea(+ child: Padding(+ padding: const EdgeInsets.fromLTRB(20, 0, 20, 16),+ child: Column(+ mainAxisSize: MainAxisSize.min,+ crossAxisAlignment: CrossAxisAlignment.stretch,+ children: [+ Text(+ user?.name ?? 'Signed in',+ style: TextStyle(+ color: AppPalette.textPrimary,+ fontSize: 17,+ fontWeight: FontWeight.w600,+ ),+ ),+ const SizedBox(height: 4),+ Text(+ user?.email ?? '',+ style: TextStyle(color: AppPalette.textSecondary, fontSize: 14),+ ),+ const SizedBox(height: 20),+ FilledButton(+ style: FilledButton.styleFrom(+ backgroundColor: AppPalette.dangerFill,+ minimumSize: const Size.fromHeight(48),+ ),+ onPressed: () {+ Navigator.of(sheetContext).pop();+ unawaited(notifier.logout());+ },+ child: const Text('Sign out'),+ ),+ ],+ ),+ ),+ ),+ );+ }+}diff --git a/desktop/lib/phone/agent_hero.dart b/desktop/lib/phone/agent_hero.dartnew file mode 100644index 000000000..1931e2644--- /dev/null+++ b/desktop/lib/phone/agent_hero.dart@@ -0,0 +1,258 @@+import 'package:flutter/material.dart';++import '../shared/theme/app_theme.dart';++/// The row expanding into the header of the page it opens.+///+/// ⚠️ **The Hero carries the HEADER, not the whole page.** Two earlier versions got this wrong in+/// opposite directions and both read as broken:+///+/// - Wrapping only the engine mark made one glyph fly across an otherwise ordinary push — a+/// detail escaping the transition rather than a transition.+/// - Wrapping the entire page made the flight cover the screen while the route was also fading,+/// so two full-screen layers crossed and the screen visibly flashed at both ends.+///+/// A row is header-shaped: a mark, a title, a status line, 70pt tall. The terminal page's header is+/// the same shape. So the row becomes the header — one object, one motion — and the terminal body+/// below it arrives on its own, sliding up under a header that has already landed. That is also the+/// order the data is ready in: the header can be drawn from the agent immediately, the terminal+/// cannot be drawn until the pane attaches.+///+/// ⚠️ **The tag must include where the flight STARTED, not just the agent.**+///+/// The phone shell is an [IndexedStack] of three tabs, and every tab stays MOUNTED — that is what+/// lets a tab remember its stack. Both the Agents tab and the Machines tab draw rows for the same+/// agents, so keying on the agent alone puts two Heroes with one tag in the same subtree, and+/// Flutter throws `There are multiple heroes that share the same tag within a subtree` the moment+/// either is pushed from.+String agentHeroTag({+ required String machineId,+ required String agentId,+ required AgentHeroSource source,+}) => 'agent:$machineId/$agentId@${source.name}';++/// Which list a terminal page was opened from — the half of [agentHeroTag] that keeps two mounted+/// tabs from claiming one tag.+enum AgentHeroSource {+ /// The Agents tab's cross-machine list.+ agents,++ /// One machine's own agent list, under the Machines tab.+ machine,+}++/// How long the body takes to arrive after the header has landed.+const Duration kAgentBodyDelay = Duration(milliseconds: 90);++/// How long the flight itself runs. Longer than Material's 300ms default: the box travels most of+/// the screen's height, and at 300ms that distance reads as a jump rather than a movement.+const Duration kAgentHeroDuration = Duration(milliseconds: 340);++/// Wraps a list row so it expands into the page's header.+///+/// [tag] is null where there is nothing to fly to — an agent with no terminal does not open, so a+/// Hero on it would be a tag with one end. That case draws the plain child.+class AgentHeroCard extends StatelessWidget {+ const AgentHeroCard({super.key, required this.tag, required this.child});++ final String? tag;+ final Widget child;++ @override+ Widget build(BuildContext context) => _wrap(tag, child);+}++/// The header end of the flight.+class AgentHeroHeader extends StatelessWidget {+ const AgentHeroHeader({super.key, required this.tag, required this.child});++ final String? tag;+ final Widget child;++ @override+ Widget build(BuildContext context) => _wrap(tag, child);+}++Widget _wrap(String? tag, Widget child) {+ if (tag == null) return child;+ return Hero(+ tag: tag,+ // A straight rect tween, not Material's default arc. The row and the header are both at the top+ // of the screen and differ mostly in width, so an arced path bows the box sideways on the way —+ // motion across an axis the two ends do not actually differ on.+ createRectTween: (begin, end) => RectTween(begin: begin, end: end),+ flightShuttleBuilder: (_, animation, direction, fromContext, toContext) =>+ _Shuttle(+ animation: animation,+ forward: direction == HeroFlightDirection.push,+ from: (fromContext.widget as Hero).child,+ to: (toContext.widget as Hero).child,+ ),+ child: child,+ );+}++/// What is drawn while the row is becoming the header.+///+/// The box itself is what moves — Flutter tweens its rect — and this only has to make the surface+/// inside it change from a card to a page header: the corner straightens and the row's fill drains+/// away to nothing, because the header sits directly on the page rather than on a card.+///+/// The two ends cross-fade over the middle of the flight rather than at its edges. At the start the+/// box is still row-shaped and the row's own layout is the only one that fits it; at the end it is+/// header-shaped and the header's is. Swapping in the middle is the one point where neither is+/// visibly wrong.+class _Shuttle extends StatelessWidget {+ const _Shuttle({+ required this.animation,+ required this.forward,+ required this.from,+ required this.to,+ });++ final Animation<double> animation;+ final bool forward;+ final Widget from;+ final Widget to;++ @override+ Widget build(BuildContext context) {+ AppTheme.watch(context);+ // On a pop the flight runs backwards, so read the animation the other way for every tween below+ // to follow the direction of travel.+ final t = forward+ ? animation+ : ReverseAnimation(animation) as Animation<double>;+ final eased = CurvedAnimation(parent: t, curve: Curves.easeInOutCubic);+ return AnimatedBuilder(+ animation: eased,+ builder: (context, _) {+ final v = eased.value;+ // The card's surface fades out rather than lerping to the page colour: the header has no+ // fill of its own, and lerping to `windowBg` would paint an opaque rectangle over whatever+ // the page is drawing behind the header — the flash the full-page version had.+ final fill = AppGlass.rowFill.withValues(+ alpha: AppGlass.rowFill.a * (1 - v),+ );+ return DecoratedBox(+ decoration: BoxDecoration(+ color: fill,+ borderRadius: BorderRadius.circular(AppCard.radius * (1 - v)),+ border: Border.all(+ color: AppGlass.hair.withValues(alpha: AppGlass.hair.a * (1 - v)),+ ),+ ),+ child: ClipRRect(+ borderRadius: BorderRadius.circular(AppCard.radius * (1 - v)),+ child: Stack(+ fit: StackFit.expand,+ children: [+ if (v < 0.6)+ Opacity(+ opacity: (1 - v / 0.6).clamp(0.0, 1.0),+ child: _Loose(child: from),+ ),+ if (v > 0.4)+ Opacity(+ opacity: ((v - 0.4) / 0.6).clamp(0.0, 1.0),+ child: _Loose(child: to),+ ),+ ],+ ),+ ),+ );+ },+ );+ }+}++/// Lays a flight end out at its own natural height inside the moving box.+///+/// Both ends are built for a height they do not have mid-flight, and letting either lay out against+/// the in-between box makes it reflow on every frame. An unbounded height plus the clip above shows+/// whatever fits and hides the rest.+class _Loose extends StatelessWidget {+ const _Loose({required this.child});++ final Widget child;++ @override+ Widget build(BuildContext context) => OverflowBox(+ alignment: Alignment.topCenter,+ minHeight: 0,+ maxHeight: double.infinity,+ child: child,+ );+}++/// The terminal body, arriving after the header has landed.+///+/// Held back until the flight is nearly over and then slid up a short distance. Two reasons it is+/// not simply part of the page from the first frame: a full-screen terminal drawn behind a header+/// that is still mid-flight is the second layer that made the old version flash, and the body is+/// genuinely not ready that early — the pane attaches after the push.+class AgentBodyReveal extends StatefulWidget {+ const AgentBodyReveal({super.key, required this.child});++ final Widget child;++ @override+ State<AgentBodyReveal> createState() => _AgentBodyRevealState();+}++class _AgentBodyRevealState extends State<AgentBodyReveal>+ with SingleTickerProviderStateMixin {+ late final AnimationController _controller = AnimationController(+ vsync: this,+ duration: const Duration(milliseconds: 260),+ );++ /// Guards the one-time start: `didChangeDependencies` runs again on any inherited-widget change+ /// (a theme flip, a metrics change), and restarting the reveal there would replay it mid-session.+ bool _started = false;++ @override+ void didChangeDependencies() {+ super.didChangeDependencies();+ if (_started) return;+ _started = true;+ // `ModalRoute.of` needs a context that is already in the tree, so this cannot be `initState`.+ //+ // A route with no animation, or one already finished — a rebuild, a page restored under an+ // existing one — resolves immediately and the body is simply there. Only a live push waits.+ final animation = ModalRoute.of(context)?.animation;+ if (animation == null || animation.isCompleted) {+ _controller.value = 1;+ return;+ }+ Future<void>.delayed(kAgentBodyDelay, () {+ if (mounted) _controller.forward();+ });+ }++ @override+ void dispose() {+ _controller.dispose();+ super.dispose();+ }++ @override+ Widget build(BuildContext context) {+ final curve = CurvedAnimation(+ parent: _controller,+ curve: Curves.easeOutCubic,+ );+ return FadeTransition(+ opacity: curve,+ child: SlideTransition(+ // A short rise — 4% of the body's height. Enough to read as arriving from under the header,+ // small enough that nothing is off-screen long enough to notice.+ position: Tween<Offset>(+ begin: const Offset(0, 0.04),+ end: Offset.zero,+ ).animate(curve),+ child: widget.child,+ ),+ );+ }+}diff --git a/desktop/lib/phone/agent_index.dart b/desktop/lib/phone/agent_index.dartnew file mode 100644index 000000000..8779e2397--- /dev/null+++ b/desktop/lib/phone/agent_index.dart@@ -0,0 +1,110 @@+import '../core/models.dart';+import '../state/app_state.dart';+import 'phone_status.dart';++/// One agent, together with the machine it runs on.+///+/// The app's state is keyed by machine — `machineStates[id].agents` — which is the right shape for+/// the desktop's rail, where a machine is a heading with its agents under it. The phone's Agents+/// tab asks the other question: *every* agent on the account, whichever machine it is on. This is+/// that flattening, done in one place so the tab, its filter and its badge cannot disagree.+class AgentEntry {+ const AgentEntry({required this.machine, required this.agent});++ final MachineState machine;+ final Agent agent;++ String get machineId => machine.machine.machineId;+ String get machineName => machine.machine.displayName;++ /// Whether this agent is blocked on an answer from the person holding the phone.+ bool get isWaiting => machine.blockedAgents.containsKey(agent.id);++ bool get isWorking => machine.processingAgentIds.contains(agent.id);++ PhoneSummary get summary => phoneAgentSummary(machine, agent);+}++/// Every agent the account can reach, ordered the way the tab draws them.+///+/// Only machines that are LINKED and answering contribute: an offline machine's agent list is+/// whatever was last seen there, and drawing it beside live ones would offer rows that cannot be+/// opened. Those machines are reachable on the Machines tab instead, which is where the thing to+/// do about them lives.+List<AgentEntry> agentIndex(AppNotifier notifier) {+ final entries = <AgentEntry>[];+ for (final machine in notifier.machines) {+ final state = notifier.stateOf(machine.machineId);+ if (state == null) continue;+ if (phoneMachineStatusOf(state) != PhoneMachineStatus.ready) continue;+ for (final agent in state.agents) {+ entries.add(AgentEntry(machine: state, agent: agent));+ }+ }+ return entries;+}++/// The agents waiting on an answer, across every machine.+///+/// This is what the Agents tab's badge counts and what its first section lists. It is the whole+/// reason the phone app exists: somebody is away from their desk and an agent has stopped to ask+/// them something.+List<AgentEntry> waitingAgents(List<AgentEntry> entries) =>+ entries.where((entry) => entry.isWaiting).toList();++/// The rest, with the busy ones first.+///+/// Sorted rather than left in machine order because "working" is the only remaining state that+/// changes on its own — an idle agent will still be idle in a minute, and a row that is moving is+/// the one worth putting where the eye lands.+List<AgentEntry> otherAgents(List<AgentEntry> entries) {+ final rest = entries.where((entry) => !entry.isWaiting).toList();+ rest.sort((a, b) {+ if (a.isWorking != b.isWorking) return a.isWorking ? -1 : 1;+ // Then agents that can actually be opened, so a row with no terminal never heads the list.+ final aOpen = a.agent.terminalAvailable;+ final bOpen = b.agent.terminalAvailable;+ if (aOpen != bOpen) return aOpen ? -1 : 1;+ return 0;+ });+ return rest;+}++/// The machines the filter chips offer, in the order they are drawn.+///+/// Every machine on the account, not just the ready ones: a chip is also how somebody notices that+/// a machine needs its password. A chip for a machine that cannot be opened is drawn disabled by+/// the widget, from [phoneMachineStatusOf].+///+/// ⚠️ **Ordered by what a chip can DO, not by account order.** The rail is one line on a phone and+/// scrolls horizontally, so whatever lands first is the only part most people ever see — and a chip+/// that cannot be tapped is worth nothing there. Account order put the unusable machines first as+/// often as not, pushing the one machine actually running agents off the right edge.+///+/// [PhoneMachineStatus] already ranks them: `ready` is tappable, `connecting` is about to be, and+/// the last two need something done elsewhere before they mean anything here. Ties keep account+/// order, so the row does not reshuffle itself as machines answer.+List<MachineState> filterableMachines(AppNotifier notifier) {+ final states = [+ for (final machine in notifier.machines)+ ?notifier.stateOf(machine.machineId),+ ];+ // A stable sort, which `List.sort` is not — an unstable one would let two ready machines swap+ // places on an unrelated rebuild, moving a chip out from under a finger already reaching for it.+ final indexed = [for (final (index, state) in states.indexed) (index, state)]+ ..sort((a, b) {+ final rank = _chipRank(a.$2).compareTo(_chipRank(b.$2));+ return rank != 0 ? rank : a.$1.compareTo(b.$1);+ });+ return [for (final (_, state) in indexed) state];+}++/// Where a machine's chip sits: lower sorts first.+int _chipRank(MachineState machine) => switch (phoneMachineStatusOf(machine)) {+ PhoneMachineStatus.ready => 0,+ PhoneMachineStatus.connecting => 1,+ // Both need action somewhere else before a chip here can do anything, but a password is+ // something the person holding the phone can fix right now; a machine that is off is not.+ PhoneMachineStatus.needsPassword => 2,+ PhoneMachineStatus.offline => 3,+};diff --git a/desktop/lib/phone/agent_row.dart b/desktop/lib/phone/agent_row.dartnew file mode 100644index 000000000..19e16d116--- /dev/null+++ b/desktop/lib/phone/agent_row.dart@@ -0,0 +1,116 @@+import 'package:flutter/material.dart';+import 'package:lucide_icons_flutter/lucide_icons.dart';++import '../shared/theme/app_theme.dart';+import '../widgets/engine_identity.dart';+import 'agent_hero.dart';+import 'agent_index.dart';+import 'phone_card.dart';+import 'status_pill.dart';++/// One agent in the Agents tab.+///+/// Differs from [AgentTile] — the row a single machine's page draws — in the one way the tab needs:+/// it names the MACHINE, because this list mixes them and a name alone is ambiguous the moment two+/// machines both have a `main` or a `docs` agent.+class AgentRow extends StatelessWidget {+ const AgentRow({super.key, required this.entry, required this.onTap});++ final AgentEntry entry;+ final VoidCallback onTap;++ @override+ Widget build(BuildContext context) {+ AppTheme.watch(context);+ final agent = entry.agent;+ return AgentHeroCard(+ // An agent with no terminal does not open, so there is no page for the row to become — a tag+ // here would be one end of a flight that never happens.+ tag: agent.terminalAvailable+ ? agentHeroTag(+ machineId: entry.machineId,+ agentId: agent.id,+ source: AgentHeroSource.agents,+ )+ : null,+ child: PhoneCard(+ onTap: agent.terminalAvailable ? onTap : null,+ // A rim in the attention colour, so a waiting agent is findable in a long list without+ // reading a word of it — the list's whole job on a phone.+ border: entry.isWaiting+ ? Border.all(color: AppPalette.warn.withValues(alpha: 0.42))+ : null,+ child: Row(+ children: [+ PhoneCardGlyph(+ child: EngineMark(+ engine: agent.engine,+ displayName: agent.engineDisplayName,+ size: 22,+ ),+ ),+ const SizedBox(width: 14),+ Expanded(+ child: Column(+ mainAxisAlignment: MainAxisAlignment.center,+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ Text(+ agent.name,+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: TextStyle(+ color: AppPalette.textPrimary,+ fontSize: 16,+ fontWeight: FontWeight.w600,+ ),+ ),+ const SizedBox(height: 5),+ _StatusAndMachine(entry: entry),+ ],+ ),+ ),+ const SizedBox(width: 8),+ if (agent.terminalAvailable)+ Icon(+ LucideIcons.chevronRight300,+ size: 22,+ color: AppPalette.textFaint,+ ),+ ],+ ),+ ),+ );+ }+}++/// The status line, with the machine's name after it.+///+/// One line rather than two: a phone row is 70pt and a third line of type would either shrink the+/// name above it or push the card taller than a thumb's reach for the list.+class _StatusAndMachine extends StatelessWidget {+ const _StatusAndMachine({required this.entry});++ final AgentEntry entry;++ @override+ Widget build(BuildContext context) {+ AppTheme.watch(context);+ return Row(+ children: [+ Flexible(child: StatusPill(summary: entry.summary)),+ const SizedBox(width: 6),+ // The machine is context, not status, so it is drawn a step quieter than the pill it+ // follows — and it yields its width first when both cannot fit.+ Flexible(+ child: Text(+ '· ${entry.machineName}',+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: TextStyle(color: AppPalette.textFaint, fontSize: 13),+ ),+ ),+ ],+ );+ }+}diff --git a/desktop/lib/phone/agent_tile.dart b/desktop/lib/phone/agent_tile.dartnew file mode 100644index 000000000..3a3d42dd7--- /dev/null+++ b/desktop/lib/phone/agent_tile.dart@@ -0,0 +1,82 @@+import 'package:flutter/material.dart';+import 'package:lucide_icons_flutter/lucide_icons.dart';++import '../core/models.dart';+import '../shared/theme/app_theme.dart';+import '../state/app_state.dart';+import '../widgets/engine_identity.dart';+import 'agent_hero.dart';+import 'phone_card.dart';+import 'phone_status.dart';+import 'status_pill.dart';++/// One agent on a machine's page: its engine, its name, and what it is doing. An agent with no+/// terminal to attach is drawn dimmed and does not open.+class AgentTile extends StatelessWidget {+ const AgentTile({+ super.key,+ required this.machine,+ required this.agent,+ required this.onTap,+ });++ final MachineState machine;+ final Agent agent;+ final VoidCallback onTap;++ @override+ Widget build(BuildContext context) {+ AppTheme.watch(context);+ return AgentHeroCard(+ // Null where the row does not open — see [AgentHeroCard].+ tag: agent.terminalAvailable+ ? agentHeroTag(+ machineId: machine.machine.machineId,+ agentId: agent.id,+ source: AgentHeroSource.machine,+ )+ : null,+ child: PhoneCard(+ onTap: agent.terminalAvailable ? onTap : null,+ child: Row(+ children: [+ PhoneCardGlyph(+ child: EngineMark(+ engine: agent.engine,+ displayName: agent.engineDisplayName,+ size: 22,+ ),+ ),+ const SizedBox(width: 14),+ Expanded(+ child: Column(+ mainAxisAlignment: MainAxisAlignment.center,+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ Text(+ agent.name,+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: TextStyle(+ color: AppPalette.textPrimary,+ fontSize: 16,+ fontWeight: FontWeight.w600,+ ),+ ),+ const SizedBox(height: 5),+ StatusPill(summary: phoneAgentSummary(machine, agent)),+ ],+ ),+ ),+ const SizedBox(width: 8),+ Icon(+ LucideIcons.chevronRight300,+ size: 22,+ color: AppPalette.textFaint,+ ),+ ],+ ),+ ),+ );+ }+}diff --git a/desktop/lib/phone/agents_page.dart b/desktop/lib/phone/agents_page.dartnew file mode 100644index 000000000..efe22bf9c--- /dev/null+++ b/desktop/lib/phone/agents_page.dart@@ -0,0 +1,216 @@+import 'dart:async';++import 'package:flutter/material.dart';+import 'package:lucide_icons_flutter/lucide_icons.dart';++import '../shared/theme/app_theme.dart';+import '../shared/widgets/app_icon_button.dart';+import '../shared/widgets/empty_state.dart';+import '../state/app_state.dart';+import 'agent_hero.dart';+import 'agent_tile.dart';+import 'link_page.dart';+import 'phone_card.dart';+import 'phone_header.dart';+import 'phone_navigation.dart';+import 'phone_sheet.dart';+import 'phone_status.dart';+import 'status_pill.dart';++/// One machine's agents. A tap opens that agent full screen, and it is the only one open.+class AgentsPage extends StatelessWidget {+ const AgentsPage({+ super.key,+ required this.notifier,+ required this.machineId,+ });++ final AppNotifier notifier;+ final String machineId;++ @override+ Widget build(BuildContext context) => ListenableBuilder(+ listenable: notifier,+ builder: (context, _) {+ AppTheme.watch(context);+ final machine = notifier.stateOf(machineId);+ return Scaffold(+ backgroundColor: AppPalette.windowBg,+ body: SafeArea(+ bottom: false,+ child: Column(+ children: [+ PhoneHeader(+ title: machine?.machine.displayName ?? 'Machine',+ subtitle: machine == null+ ? null+ : StatusPill(summary: phoneMachineSummary(machine)),+ trailing: [+ if (machine != null)+ AppIconButton(+ icon: LucideIcons.ellipsis300,+ size: 20,+ tooltip: 'Machine actions',+ color: AppPalette.textSecondary,+ onPressed: () =>+ _showMachineActions(context, notifier, machine),+ ),+ ],+ ),+ if (machine != null)+ Expanded(+ child: _AgentsBody(notifier: notifier, machine: machine),+ ),+ ],+ ),+ ),+ );+ },+ );++ void _showMachineActions(+ BuildContext context,+ AppNotifier notifier,+ MachineState machine,+ ) {+ final machineId = machine.machine.machineId;+ final linked = !machine.needsLink;+ showPhoneSheet(+ context,+ title: machine.machine.displayName,+ actions: [+ PhoneSheetAction(+ icon: LucideIcons.refreshCw300,+ label: 'Reload agents',+ onTap: () => unawaited(notifier.reloadMachineData(machineId)),+ ),+ // Only where there is a link to replace. A machine that never had one reaches its form by+ // being tapped, which is the same screen this would open.+ if (linked)+ PhoneSheetAction(+ icon: LucideIcons.keyRound300,+ label: 'Re-enter password…',+ onTap: () => Navigator.of(context).push(+ phoneRoute(+ (_) => LinkPage(notifier: notifier, machineId: machineId),+ ),+ ),+ ),+ if (linked)+ PhoneSheetAction(+ icon: LucideIcons.unlink300,+ label: 'Unlink this phone…',+ destructive: true,+ onTap: () => unawaited(_confirmUnlink(context, notifier, machine)),+ ),+ ],+ );+ }++ /// Unlinking drops THIS device's trust pin for the machine — see `AppNotifier.unlinkMachine`,+ /// which is deliberately not `deleteMachine`. The wording says so, because "Unlink" alone reads+ /// as removing the machine from the account, which is a different and much larger thing.+ Future<void> _confirmUnlink(+ BuildContext context,+ AppNotifier notifier,+ MachineState machine,+ ) async {+ final name = machine.machine.displayName;+ final confirmed = await confirmPhoneAction(+ context,+ title: 'Unlink $name?',+ message:+ 'This phone will need $name\'s password again to open its agents. '+ 'The machine itself is not changed, and its agents keep running.',+ confirmLabel: 'Unlink',+ );+ if (!confirmed || !context.mounted) return;+ final error = await notifier.unlinkMachine(machine.machine.machineId);+ if (!context.mounted) return;+ if (error != null) {+ ScaffoldMessenger.maybeOf(context)+ ?.showSnackBar(SnackBar(content: Text(error)));+ return;+ }+ // The page is now showing a machine this phone can no longer open; the list behind it is where+ // the re-link starts.+ Navigator.of(context).maybePop();+ }+}++class _AgentsBody extends StatelessWidget {+ const _AgentsBody({required this.notifier, required this.machine});++ final AppNotifier notifier;+ final MachineState machine;++ String get _machineId => machine.machine.machineId;++ @override+ Widget build(BuildContext context) {+ final agents = machine.agents;+ final status = phoneMachineStatusOf(machine);+ if (status == PhoneMachineStatus.needsPassword) {+ return EmptyState(+ icon: LucideIcons.lockKeyhole300,+ title: 'This machine needs its password',+ message: 'Every machine has its own. Enter it once to link this phone.',+ action: FilledButton(+ onPressed: () => Navigator.of(context).pushReplacement(+ phoneRoute(+ (_) => LinkPage(notifier: notifier, machineId: _machineId),+ ),+ ),+ child: const Text('Enter password'),+ ),+ );+ }+ if (status == PhoneMachineStatus.offline) {+ return EmptyState(+ icon: LucideIcons.cloudOff300,+ title: "Harness isn't running there",+ message:+ 'Start Harness on ${machine.machine.displayName} and its agents '+ 'will show up here.',+ );+ }+ if (agents.isEmpty && status == PhoneMachineStatus.connecting) {+ return const PhoneListSkeleton();+ }+ final loadError = machine.agentsLoadError;+ if (agents.isEmpty && loadError != null) {+ return EmptyState(+ icon: LucideIcons.circleAlert300,+ title: "Couldn't load its agents",+ message: loadError,+ action: FilledButton(+ onPressed: () => notifier.reloadMachineData(_machineId),+ child: const Text('Try again'),+ ),+ );+ }+ if (agents.isEmpty) {+ return const EmptyState(+ icon: LucideIcons.squareTerminal300,+ title: 'No agents yet',+ message:+ 'Start one from Harness on that machine and it will appear here.',+ );+ }+ return PhoneCardList(+ onRefresh: () => notifier.reloadMachineData(_machineId),+ itemCount: agents.length,+ itemBuilder: (context, index) => AgentTile(+ machine: machine,+ agent: agents[index],+ onTap: () => openAgent(+ context,+ notifier,+ _machineId,+ agents[index].id,+ heroSource: AgentHeroSource.machine,+ ),+ ),+ );+ }+}diff --git a/desktop/lib/phone/agents_tab.dart b/desktop/lib/phone/agents_tab.dartnew file mode 100644index 000000000..4f6cbf822--- /dev/null+++ b/desktop/lib/phone/agents_tab.dart@@ -0,0 +1,249 @@+import 'package:flutter/material.dart';+import 'package:lucide_icons_flutter/lucide_icons.dart';++import '../shared/theme/app_theme.dart';+import '../shared/widgets/empty_state.dart';+import '../state/app_state.dart';+import 'agent_hero.dart';+import 'agent_index.dart';+import 'agent_row.dart';+import 'account_button.dart';+import 'machine_filter_bar.dart';+import 'phone_card.dart';+import 'phone_header.dart';+import 'phone_navigation.dart';+import 'phone_status.dart';++/// Every agent on the account, whichever machine it runs on.+///+/// The phone's home, and the direction's whole bet: people remember what an agent is CALLED, not+/// which computer it happens to be on. The machine is still there — as a filter above the list and+/// as a line under each name — it just stops being the thing you have to navigate through first.+class AgentsTab extends StatefulWidget {+ const AgentsTab({super.key, required this.notifier});++ final AppNotifier notifier;++ @override+ State<AgentsTab> createState() => _AgentsTabState();+}++class _AgentsTabState extends State<AgentsTab> {+ /// The machine the list is narrowed to, or null for all of them.+ ///+ /// Held as an id rather than a [MachineState]: the state objects are rebuilt as machines answer,+ /// and a filter holding a stale instance would quietly stop matching anything.+ String? _machineId;++ @override+ Widget build(BuildContext context) => ListenableBuilder(+ listenable: widget.notifier,+ builder: (context, _) {+ AppTheme.watch(context);+ final machines = filterableMachines(widget.notifier);+ // A machine that goes away — unlinked, or dropped from the account — must not leave the list+ // filtered to nothing with no way to see it is.+ final selected = machines.any((m) => m.machine.machineId == _machineId)+ ? _machineId+ : null;+ final all = agentIndex(widget.notifier);+ final shown = selected == null+ ? all+ : all.where((entry) => entry.machineId == selected).toList();+ final error = widget.notifier.lastError;+ return Scaffold(+ backgroundColor: AppPalette.windowBg,+ body: SafeArea(+ bottom: false,+ child: Column(+ children: [+ PhoneHeader(+ large: true,+ title: 'Agents',+ trailing: [AccountButton(notifier: widget.notifier)],+ ),+ if (error != null)+ _ErrorStrip(message: error, notifier: widget.notifier),+ if (machines.isNotEmpty)+ MachineFilterBar(+ machines: machines,+ selectedId: selected,+ countFor: (id) =>+ all.where((entry) => entry.machineId == id).length,+ totalCount: all.length,+ onSelect: (id) => setState(() => _machineId = id),+ ),+ Expanded(+ child: _Body(+ notifier: widget.notifier,+ entries: shown,+ machines: machines,+ filtered: selected != null,+ ),+ ),+ ],+ ),+ ),+ );+ },+ );+}++class _Body extends StatelessWidget {+ const _Body({+ required this.notifier,+ required this.entries,+ required this.machines,+ required this.filtered,+ });++ final AppNotifier notifier;+ final List<AgentEntry> entries;+ final List<MachineState> machines;+ final bool filtered;++ /// Whether anything is still on its way in — a machine connecting, or its agent list not yet+ /// answered. "Loading" and "answered with nothing" must not render the same.+ bool get _stillArriving => machines.any(+ (machine) => switch (phoneMachineStatusOf(machine)) {+ PhoneMachineStatus.connecting => true,+ _ => false,+ },+ );++ @override+ Widget build(BuildContext context) {+ if (entries.isEmpty) {+ if (notifier.machines.isEmpty && notifier.machinesLoading) {+ return const PhoneListSkeleton();+ }+ if (notifier.machines.isEmpty) {+ return const EmptyState(+ icon: LucideIcons.laptopMinimal300,+ title: 'No machines yet',+ message:+ 'Run Harness on a computer signed in to this account and it '+ 'will appear here.',+ );+ }+ if (_stillArriving) return const PhoneListSkeleton();+ if (filtered) {+ return const EmptyState(+ icon: LucideIcons.squareTerminal300,+ title: 'No agents on this machine',+ message: 'Start one from Harness there and it will appear here.',+ );+ }+ // Machines exist and have answered, but none of them can be reached — every one needs its+ // password or is offline. The Machines tab is where that is fixed, so say so.+ final reachable = machines.any(+ (machine) => phoneMachineStatusOf(machine) == PhoneMachineStatus.ready,+ );+ if (!reachable) {+ return const EmptyState(+ icon: LucideIcons.lockKeyhole300,+ title: 'No machines are open yet',+ message:+ 'Open the Machines tab to enter a machine password, or start '+ 'Harness on a computer that is offline.',+ );+ }+ return const EmptyState(+ icon: LucideIcons.squareTerminal300,+ title: 'No agents yet',+ message: 'Start one from Harness on a machine and it will appear here.',+ );+ }++ final waiting = waitingAgents(entries);+ final rest = otherAgents(entries);+ return RefreshIndicator(+ onRefresh: notifier.retryMachines,+ child: ListView(+ physics: const AlwaysScrollableScrollPhysics(),+ padding: phoneListPadding(context),+ children: [+ if (waiting.isNotEmpty) ...[+ const _SectionLabel('Waiting for you'),+ for (final entry in waiting) _row(context, entry),+ const SizedBox(height: 6),+ ],+ if (rest.isNotEmpty) ...[+ if (waiting.isNotEmpty) const _SectionLabel('All agents'),+ for (final entry in rest) _row(context, entry),+ ],+ ],+ ),+ );+ }++ Widget _row(BuildContext context, AgentEntry entry) => Padding(+ padding: const EdgeInsets.only(bottom: kPhoneCardGap),+ child: AgentRow(+ entry: entry,+ onTap: () => openAgent(+ context,+ notifier,+ entry.machineId,+ entry.agent.id,+ heroSource: AgentHeroSource.agents,+ ),+ ),+ );+}++class _SectionLabel extends StatelessWidget {+ const _SectionLabel(this.text);++ final String text;++ @override+ Widget build(BuildContext context) {+ AppTheme.watch(context);+ return Padding(+ padding: const EdgeInsets.fromLTRB(4, 8, 4, 8),+ child: Text(+ text.toUpperCase(),+ style: TextStyle(+ color: AppPalette.textFaint,+ fontSize: 11.5,+ fontWeight: FontWeight.w600,+ letterSpacing: 0.5,+ ),+ ),+ );+ }+}++class _ErrorStrip extends StatelessWidget {+ const _ErrorStrip({required this.message, required this.notifier});++ final String message;+ final AppNotifier notifier;++ @override+ Widget build(BuildContext context) {+ AppTheme.watch(context);+ return Padding(+ padding: const EdgeInsets.fromLTRB(20, 0, 12, 8),+ child: Row(+ children: [+ Icon(LucideIcons.circleAlert300, size: 18, color: AppPalette.warn),+ const SizedBox(width: 8),+ Expanded(+ child: Text(+ message,+ maxLines: 2,+ overflow: TextOverflow.ellipsis,+ style: TextStyle(color: AppPalette.textSecondary, fontSize: 13),+ ),+ ),+ TextButton(+ onPressed: notifier.retryMachines,+ child: const Text('Retry'),+ ),+ ],+ ),+ );+ }+}diff --git a/desktop/lib/phone/link_page.dart b/desktop/lib/phone/link_page.dartnew file mode 100644index 000000000..21a52c074--- /dev/null+++ b/desktop/lib/phone/link_page.dart@@ -0,0 +1,101 @@+import 'package:flutter/material.dart';++import '../shared/theme/app_theme.dart';+import '../state/app_state.dart';+import '../widgets/link_machine_screen.dart';+import 'agents_page.dart';+import 'phone_header.dart';+import 'phone_navigation.dart';++/// A machine's password form, as a phone page — the same [LinkMachineScreen] the desktop pops+/// up, since the exchange behind it is the same.+///+/// It leaves by itself both ways: forward onto the machine's agents once the link lands, and+/// back when the form's own Close is pressed.+class LinkPage extends StatefulWidget {+ const LinkPage({super.key, required this.notifier, required this.machineId});++ final AppNotifier notifier;+ final String machineId;++ @override+ State<LinkPage> createState() => _LinkPageState();+}++class _LinkPageState extends State<LinkPage> {+ /// The form's Close marks the prompt dismissed. One already dismissed before this page opened+ /// must not shut the page on its first frame.+ late final bool _dismissedBefore = widget.notifier.isLinkPromptDismissed(+ widget.machineId,+ );+ bool _leaving = false;++ @override+ void initState() {+ super.initState();+ widget.notifier.addListener(_follow);+ }++ @override+ void dispose() {+ widget.notifier.removeListener(_follow);+ super.dispose();+ }++ void _follow() {+ if (_leaving || !mounted) return;+ final machine = widget.notifier.stateOf(widget.machineId);+ final navigator = Navigator.of(context);+ if (machine != null && !machine.needsLink) {+ _leaving = true;+ navigator.pushReplacement(+ phoneRoute(+ (_) => AgentsPage(+ notifier: widget.notifier,+ machineId: widget.machineId,+ ),+ ),+ );+ return;+ }+ final closed =+ !_dismissedBefore &&+ widget.notifier.isLinkPromptDismissed(widget.machineId);+ if (machine == null || closed) {+ _leaving = true;+ navigator.maybePop();+ }+ }++ @override+ Widget build(BuildContext context) {+ AppTheme.watch(context);+ final machine = widget.notifier.stateOf(widget.machineId);+ return Scaffold(+ backgroundColor: AppPalette.windowBg,+ body: SafeArea(+ child: Column(+ children: [+ PhoneHeader(+ title: machine?.machine.displayName ?? 'Machine',+ subtitle: Text(+ 'Enter the password set on this machine',+ style: TextStyle(color: AppPalette.textSecondary, fontSize: 13),+ ),+ ),+ if (machine != null)+ Expanded(+ child: SingleChildScrollView(+ padding: const EdgeInsets.fromLTRB(16, 8, 16, 24),+ child: LinkMachineScreen(+ notifier: widget.notifier,+ machineState: machine,+ ),+ ),+ ),+ ],+ ),+ ),+ );+ }+}diff --git a/desktop/lib/phone/machine_filter_bar.dart b/desktop/lib/phone/machine_filter_bar.dartnew file mode 100644index 000000000..d4bfcf5d5--- /dev/null+++ b/desktop/lib/phone/machine_filter_bar.dart@@ -0,0 +1,188 @@+import 'package:flutter/material.dart';++import '../shared/theme/app_theme.dart';+import '../state/app_state.dart';+import 'phone_status.dart';+import 'status_pill.dart';++/// The machine chips over the Agents tab.+///+/// The machine does not disappear in this direction — it stops being a page you walk through and+/// becomes a way to narrow the list you are already looking at. A chip for a machine that cannot+/// be opened is drawn disabled rather than hidden: seeing that a machine needs its password is+/// half of why somebody would look here at all.+class MachineFilterBar extends StatelessWidget {+ const MachineFilterBar({+ super.key,+ required this.machines,+ required this.selectedId,+ required this.countFor,+ required this.totalCount,+ required this.onSelect,+ });++ final List<MachineState> machines;++ /// The machine the list is narrowed to, or null for all of them.+ final String? selectedId;++ /// How many agents a machine contributes, for the figure on its chip.+ final int Function(String machineId) countFor;++ final int totalCount;++ /// Null selects every machine.+ final ValueChanged<String?> onSelect;++ @override+ Widget build(BuildContext context) {+ AppTheme.watch(context);+ return SizedBox(+ height: 42,+ child: ListView(+ scrollDirection: Axis.horizontal,+ padding: const EdgeInsets.symmetric(horizontal: 16),+ children: [+ _Chip(+ label: 'All',+ count: totalCount,+ selected: selectedId == null,+ onTap: () => onSelect(null),+ ),+ for (final machine in machines) _chipFor(machine),+ ],+ ),+ );+ }++ Widget _chipFor(MachineState machine) {+ final id = machine.machine.machineId;+ final status = phoneMachineStatusOf(machine);+ final ready = status == PhoneMachineStatus.ready;+ return _Chip(+ label: machine.machine.displayName,+ // A count only where there is one to give. A machine that has not answered would otherwise+ // read as "0 agents", which is a claim rather than a silence.+ count: ready ? countFor(id) : null,+ tone: phoneMachineSummary(machine).tone,+ selected: selectedId == id,+ // Narrowing to a machine with nothing to show is a dead end, so those chips do not select.+ // They still say what is wrong through their dot, and the Machines tab is where it is fixed.+ onTap: ready ? () => onSelect(id) : null,+ );+ }+}++class _Chip extends StatelessWidget {+ const _Chip({+ required this.label,+ required this.selected,+ required this.onTap,+ this.count,+ this.tone,+ });++ final String label;+ final bool selected;+ final VoidCallback? onTap;+ final int? count;++ /// Drawn as the leading dot. Null on the "All" chip, which is not a machine and has no state.+ final PhoneTone? tone;++ @override+ Widget build(BuildContext context) {+ AppTheme.watch(context);+ final enabled = onTap != null;+ return Padding(+ padding: const EdgeInsets.only(right: 7, top: 4, bottom: 4),+ child: Opacity(+ opacity: enabled ? 1 : 0.5,+ child: Material(+ color: selected ? AppSurface.accentWash : AppGlass.rowFill,+ borderRadius: BorderRadius.circular(999),+ child: InkWell(+ onTap: onTap,+ borderRadius: BorderRadius.circular(999),+ child: Container(+ padding: const EdgeInsets.symmetric(horizontal: 12),+ alignment: Alignment.center,+ decoration: BoxDecoration(+ borderRadius: BorderRadius.circular(999),+ border: Border.all(+ color: selected+ ? AppPalette.accentOnSurface.withValues(alpha: 0.5)+ : AppGlass.hair,+ ),+ ),+ child: Row(+ mainAxisSize: MainAxisSize.min,+ children: [+ if (tone != null) ...[+ _Dot(tone: tone!),+ const SizedBox(width: 6),+ ],+ ConstrainedBox(+ // A long machine name must not push the chips off the rail; it ellipsises and+ // the ones after it stay reachable.+ //+ // 108 rather than a rounder 140: hostnames run long by default — a stock+ // `caokhanh-Inspiron-3520` or `MacBooks-MacBook-Pro` is over twenty characters+ // — and at 140 just two of them fill a 390pt screen, hiding every chip after+ // them. Ellipsised earlier, four fit, and the leading characters are the part+ // that tells two machines apart anyway.+ constraints: const BoxConstraints(maxWidth: 108),+ child: Text(+ label,+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: TextStyle(+ color: selected+ ? AppPalette.textPrimary+ : AppPalette.textSecondary,+ fontSize: 13,+ fontWeight: FontWeight.w500,+ ),+ ),+ ),+ if (count != null) ...[+ const SizedBox(width: 6),+ Text(+ '$count',+ style: TextStyle(+ color: AppPalette.textFaint,+ fontSize: 13,+ fontWeight: FontWeight.w500,+ fontFeatures: AppFont.tabularFigures,+ ),+ ),+ ],+ ],+ ),+ ),+ ),+ ),+ ),+ );+ }+}++class _Dot extends StatelessWidget {+ const _Dot({required this.tone});++ final PhoneTone tone;++ @override+ Widget build(BuildContext context) {+ AppTheme.watch(context);+ return SizedBox.square(+ dimension: 7,+ child: DecoratedBox(+ decoration: BoxDecoration(+ color: phoneToneColor(tone),+ shape: BoxShape.circle,+ ),+ ),+ );+ }+}diff --git a/desktop/lib/phone/machine_tile.dart b/desktop/lib/phone/machine_tile.dartnew file mode 100644index 000000000..5903b2bad--- /dev/null+++ b/desktop/lib/phone/machine_tile.dart@@ -0,0 +1,67 @@+import 'package:flutter/material.dart';+import 'package:lucide_icons_flutter/lucide_icons.dart';++import '../shared/theme/app_theme.dart';+import '../state/app_state.dart';+import 'phone_card.dart';+import 'phone_status.dart';+import 'status_pill.dart';++/// One machine on the phone's first screen: its name, its state, and — in the trailing glyph —+/// what a tap does. A padlock means the tap asks for this machine's own password.+class MachineTile extends StatelessWidget {+ const MachineTile({super.key, required this.machine, required this.onTap});++ final MachineState machine;+ final VoidCallback onTap;++ @override+ Widget build(BuildContext context) {+ AppTheme.watch(context);+ final status = phoneMachineStatusOf(machine);+ final offline = status == PhoneMachineStatus.offline;+ return PhoneCard(+ onTap: onTap,+ child: Row(+ children: [+ PhoneCardGlyph(+ child: Icon(+ LucideIcons.laptopMinimal300,+ size: 22,+ color: offline ? AppPalette.textFaint : AppPalette.textSecondary,+ ),+ ),+ const SizedBox(width: 14),+ Expanded(+ child: Column(+ mainAxisAlignment: MainAxisAlignment.center,+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ Text(+ machine.machine.displayName,+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: TextStyle(+ color: AppPalette.textPrimary,+ fontSize: 16,+ fontWeight: FontWeight.w600,+ ),+ ),+ const SizedBox(height: 5),+ StatusPill(summary: phoneMachineSummary(machine)),+ ],+ ),+ ),+ const SizedBox(width: 8),+ Icon(+ status == PhoneMachineStatus.needsPassword+ ? LucideIcons.lockKeyhole300+ : LucideIcons.chevronRight300,+ size: 22,+ color: AppPalette.textFaint,+ ),+ ],+ ),+ );+ }+}diff --git a/desktop/lib/phone/machines_tab.dart b/desktop/lib/phone/machines_tab.dartnew file mode 100644index 000000000..f6b03358e--- /dev/null+++ b/desktop/lib/phone/machines_tab.dart@@ -0,0 +1,134 @@+import 'package:flutter/material.dart';+import 'package:lucide_icons_flutter/lucide_icons.dart';++import '../shared/theme/app_theme.dart';+import '../shared/widgets/empty_state.dart';+import '../state/app_state.dart';+import 'machine_tile.dart';+import 'phone_card.dart';+import 'phone_header.dart';+import 'phone_navigation.dart';+import 'phone_status.dart';++/// The machines on the account, grouped by what they need.+///+/// The desktop lists machines in account order, because its rail shows every one at once and the+/// order is the only stable thing about it. A phone screen holds five or six rows, so the order+/// has to carry meaning instead: a machine somebody must DO something about — enter a password,+/// start Harness — goes above the ones that are simply working.+class MachinesTab extends StatelessWidget {+ const MachinesTab({super.key, required this.notifier});++ final AppNotifier notifier;++ @override+ Widget build(BuildContext context) => ListenableBuilder(+ listenable: notifier,+ builder: (context, _) {+ AppTheme.watch(context);+ return Scaffold(+ backgroundColor: AppPalette.windowBg,+ body: SafeArea(+ bottom: false,+ child: Column(+ children: [+ const PhoneHeader(large: true, title: 'Machines'),+ Expanded(child: _Body(notifier: notifier)),+ ],+ ),+ ),+ );+ },+ );+}++class _Body extends StatelessWidget {+ const _Body({required this.notifier});++ final AppNotifier notifier;++ @override+ Widget build(BuildContext context) {+ final states = [+ for (final machine in notifier.machines)+ ?notifier.stateOf(machine.machineId),+ ];+ if (states.isEmpty && notifier.machinesLoading) {+ return const PhoneListSkeleton();+ }+ if (states.isEmpty) {+ return const EmptyState(+ icon: LucideIcons.laptopMinimal300,+ title: 'No machines yet',+ message:+ 'Run Harness on a computer signed in to this account and it will '+ 'appear here.',+ );+ }++ // Two runs, by whether the machine is usable as it stands. A machine that is merely connecting+ // belongs with the working ones: it needs nothing from anybody, it is just not ready yet.+ final needsAttention = <MachineState>[];+ final working = <MachineState>[];+ for (final state in states) {+ switch (phoneMachineStatusOf(state)) {+ case PhoneMachineStatus.needsPassword:+ case PhoneMachineStatus.offline:+ needsAttention.add(state);+ case PhoneMachineStatus.connecting:+ case PhoneMachineStatus.ready:+ working.add(state);+ }+ }++ return RefreshIndicator(+ onRefresh: notifier.retryMachines,+ child: ListView(+ physics: const AlwaysScrollableScrollPhysics(),+ padding: phoneListPadding(context),+ children: [+ if (needsAttention.isNotEmpty) ...[+ const _SectionLabel('Needs your attention'),+ for (final state in needsAttention) _tile(context, state),+ const SizedBox(height: 6),+ ],+ if (working.isNotEmpty) ...[+ if (needsAttention.isNotEmpty) const _SectionLabel('Linked'),+ for (final state in working) _tile(context, state),+ ],+ ],+ ),+ );+ }++ Widget _tile(BuildContext context, MachineState state) => Padding(+ padding: const EdgeInsets.only(bottom: kPhoneCardGap),+ child: MachineTile(+ machine: state,+ onTap: () => openMachine(context, notifier, state.machine.machineId),+ ),+ );+}++class _SectionLabel extends StatelessWidget {+ const _SectionLabel(this.text);++ final String text;++ @override+ Widget build(BuildContext context) {+ AppTheme.watch(context);+ return Padding(+ padding: const EdgeInsets.fromLTRB(4, 8, 4, 8),+ child: Text(+ text.toUpperCase(),+ style: TextStyle(+ color: AppPalette.textFaint,+ fontSize: 11.5,+ fontWeight: FontWeight.w600,+ letterSpacing: 0.5,+ ),+ ),+ );+ }+}diff --git a/desktop/lib/phone/phone_card.dart b/desktop/lib/phone/phone_card.dartnew file mode 100644index 000000000..47838c2fc--- /dev/null+++ b/desktop/lib/phone/phone_card.dart@@ -0,0 +1,139 @@+import 'package:flutter/material.dart';++import '../shared/theme/app_theme.dart';+import '../shared/widgets/skeleton.dart';++/// The gap between two cards in a phone list.+const double kPhoneCardGap = 10;++/// A phone card row's height: a 44pt glyph plus its padding. The skeleton is drawn at exactly+/// this, so a list that answers does not jump.+const double kPhoneCardHeight = 70;++/// A phone list's padding: clear of the screen edges, and of the home indicator at the bottom.+EdgeInsets phoneListPadding(BuildContext context) =>+ EdgeInsets.fromLTRB(16, 4, 16, MediaQuery.paddingOf(context).bottom + 24);++/// A tappable row on the phone: a glass card that sinks a little under the finger. Without an+/// [onTap] it is drawn dimmed and does not move.+class PhoneCard extends StatefulWidget {+ const PhoneCard({super.key, required this.child, this.onTap, this.border});++ final Widget child;+ final VoidCallback? onTap;++ /// Overrides the card's hairline rim. Used to mark a row that needs attention — a waiting agent —+ /// so it is findable in a long list before a word of it is read. Null keeps the ordinary rim.+ final BoxBorder? border;++ @override+ State<PhoneCard> createState() => _PhoneCardState();+}++class _PhoneCardState extends State<PhoneCard> {+ 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);+ return GestureDetector(+ behavior: HitTestBehavior.opaque,+ onTapDown: (_) => _press(true),+ onTapUp: (_) => _press(false),+ onTapCancel: () => _press(false),+ onTap: widget.onTap,+ child: AnimatedScale(+ scale: _pressed ? 0.975 : 1,+ duration: AppMotion.press,+ curve: AppMotion.curve,+ child: AnimatedContainer(+ duration: AppMotion.press,+ curve: AppMotion.curve,+ height: kPhoneCardHeight,+ padding: const EdgeInsets.symmetric(horizontal: 13),+ decoration: BoxDecoration(+ color: _pressed ? AppGlass.rowHoverFill : AppGlass.rowFill,+ borderRadius: BorderRadius.circular(AppCard.radius),+ border: widget.border ?? Border.all(color: AppGlass.hair),+ ),+ child: Opacity(+ opacity: widget.onTap == null ? 0.55 : 1,+ child: widget.child,+ ),+ ),+ ),+ );+ }+}++/// The square glyph at the head of a card — a machine's screen, an agent's engine mark.+class PhoneCardGlyph extends StatelessWidget {+ const PhoneCardGlyph({super.key, required this.child});++ final Widget child;++ @override+ Widget build(BuildContext context) {+ AppTheme.watch(context);+ return Container(+ width: 44,+ height: 44,+ decoration: BoxDecoration(+ color: AppSurface.recess,+ borderRadius: BorderRadius.circular(12),+ ),+ child: Center(child: child),+ );+ }+}++/// A pull-to-refresh list of cards, laid out the one way every phone list is.+class PhoneCardList extends StatelessWidget {+ const PhoneCardList({+ super.key,+ required this.onRefresh,+ required this.itemCount,+ required this.itemBuilder,+ });++ final Future<void> Function() onRefresh;+ final int itemCount;+ final IndexedWidgetBuilder itemBuilder;++ @override+ Widget build(BuildContext context) => RefreshIndicator(+ onRefresh: onRefresh,+ child: ListView.separated(+ physics: const AlwaysScrollableScrollPhysics(),+ padding: phoneListPadding(context),+ itemCount: itemCount,+ separatorBuilder: (_, _) => const SizedBox(height: kPhoneCardGap),+ itemBuilder: itemBuilder,+ ),+ );+}++/// A list of cards that has not answered yet: the same cards, empty, at a real row's height.+class PhoneListSkeleton extends StatelessWidget {+ const PhoneListSkeleton({super.key, this.rows = 3});++ final int rows;++ @override+ Widget build(BuildContext context) => ListView.separated(+ physics: const NeverScrollableScrollPhysics(),+ padding: phoneListPadding(context),+ itemCount: rows,+ separatorBuilder: (_, _) => const SizedBox(height: kPhoneCardGap),+ itemBuilder: (_, _) => const Skeleton(+ width: double.infinity,+ height: kPhoneCardHeight,+ radius: AppCard.radius,+ ),+ );+}diff --git a/desktop/lib/phone/phone_header.dart b/desktop/lib/phone/phone_header.dartnew file mode 100644index 000000000..90c3de5dc--- /dev/null+++ b/desktop/lib/phone/phone_header.dart@@ -0,0 +1,96 @@+import 'package:flutter/material.dart';+import 'package:lucide_icons_flutter/lucide_icons.dart';++import '../shared/theme/app_theme.dart';+import '../shared/widgets/app_icon_button.dart';++/// The top of a phone page, drawn below the status bar and the Dynamic Island rather than into+/// them — the desktop chrome only ever had traffic lights to clear.+///+/// [large] is the first page's big title, the iOS way. Every other page gets a back chevron and+/// a compact title that can carry a [leading] mark and a quieter [subtitle] line.+class PhoneHeader extends StatelessWidget {+ const PhoneHeader({+ super.key,+ required this.title,+ this.subtitle,+ this.leading,+ this.trailing = const [],+ this.large = false,+ });++ final String title;+ final Widget? subtitle;+ final Widget? leading;+ final List<Widget> trailing;+ final bool large;++ @override+ Widget build(BuildContext context) {+ AppTheme.watch(context);+ final canPop = !large && Navigator.of(context).canPop();+ return Padding(+ padding: EdgeInsets.fromLTRB(+ canPop ? 6 : 20,+ large ? 14 : 6,+ 14,+ large ? 16 : 10,+ ),+ child: Row(+ children: [+ if (canPop) ...[+ AppIconButton(+ icon: LucideIcons.chevronLeft300,+ size: 30,+ tooltip: 'Back',+ color: AppPalette.textPrimary,+ onPressed: () => Navigator.of(context).maybePop(),+ ),+ const SizedBox(width: 2),+ ],+ if (leading != null) ...[leading!, const SizedBox(width: 10)],+ Expanded(+ child: _Titles(title: title, subtitle: subtitle, large: large),+ ),+ ...trailing,+ ],+ ),+ );+ }+}++class _Titles extends StatelessWidget {+ const _Titles({+ required this.title,+ required this.subtitle,+ required this.large,+ });++ final String title;+ final Widget? subtitle;+ final bool large;++ @override+ Widget build(BuildContext context) => Column(+ mainAxisSize: MainAxisSize.min,+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ Text(+ title,+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: TextStyle(+ color: AppPalette.textPrimary,+ fontSize: large ? 32 : 17,+ fontWeight: large ? FontWeight.w700 : FontWeight.w600,+ letterSpacing: large ? -0.6 : -0.2,+ ),+ ),+ if (subtitle != null)+ Padding(+ padding: EdgeInsets.only(top: large ? 4 : 2),+ child: subtitle,+ ),+ ],+ );+}diff --git a/desktop/lib/phone/phone_layout.dart b/desktop/lib/phone/phone_layout.dartnew file mode 100644index 000000000..f1b981ffd--- /dev/null+++ b/desktop/lib/phone/phone_layout.dart@@ -0,0 +1,16 @@+import 'package:flutter/widgets.dart';++import '../core/viewer_mode.dart';+import '../shared/layouts/window_size.dart';++/// The shortest side under which a viewer draws its phone layout — the shell's own compact+/// breakpoint, so an iPad keeps the rail beside its terminals.+const double kPhoneShortestSide = WindowSizeClass.compactMax;++/// Whether this screen gets the phone layout: one agent at a time, reached machine → agents →+/// terminal, instead of the desktop's rail beside a grid of tiles.+///+/// A viewer build only. A desktop build always has a window wide enough for the rail, and+/// resizing one small must not turn it into a phone.+bool usePhoneLayout(BuildContext context) =>+ kViewerMode && MediaQuery.sizeOf(context).shortestSide < kPhoneShortestSide;diff --git a/desktop/lib/phone/phone_navigation.dart b/desktop/lib/phone/phone_navigation.dartnew file mode 100644index 000000000..b9c15eb4d--- /dev/null+++ b/desktop/lib/phone/phone_navigation.dart@@ -0,0 +1,97 @@+import 'dart:async';++import 'package:flutter/cupertino.dart';++import '../state/app_state.dart';+import 'agent_hero.dart';+import 'agents_page.dart';+import 'link_page.dart';+import 'terminal_page.dart';++/// Every phone page slides in the iOS way, and goes back with the edge swipe.+Route<void> phoneRoute(WidgetBuilder builder) =>+ CupertinoPageRoute<void>(builder: builder);++/// The route a terminal opens on: the row grows into the page's header, and nothing else moves.+///+/// ⚠️ **The page itself gets NO transition of its own, and that is the whole point.** A plain+/// [CupertinoPageRoute] slides the incoming page in from the right *while* the Hero flies the+/// header up out of the list — two motions in different directions, which is what makes a Hero+/// look like a piece escaping the transition. Fading the page instead is no better: the page+/// paints its own opaque background, so a fade is a full-screen rectangle changing opacity across+/// the flight, and the eye reads that as the screen flashing.+///+/// With no transition the page is simply *there*, under the flying header, and the only thing+/// moving is the header and the body rising under it ([AgentBodyReveal]).+///+/// Still a [CupertinoPageRoute] subclass so the edge-swipe back gesture survives — and the swipe+/// runs the Hero in reverse, which is the point of using one.+class _AgentPageRoute extends CupertinoPageRoute<void> {+ _AgentPageRoute({required super.builder});++ /// Matches the flight, so the route is finished exactly when the header lands.+ @override+ Duration get transitionDuration => kAgentHeroDuration;++ @override+ Widget buildTransitions(+ BuildContext context,+ Animation<double> animation,+ Animation<double> secondaryAnimation,+ Widget child,+ ) => child;+}++/// Where a tap on a machine goes. A machine this device holds no link to opens on ITS password+/// form — each machine has its own remote password — and only a linked one opens on its agents.+void openMachine(BuildContext context, AppNotifier notifier, String machineId) {+ final machine = notifier.stateOf(machineId);+ if (machine == null) return;+ Navigator.of(context).push(+ phoneRoute(+ (_) => machine.needsLink+ ? LinkPage(notifier: notifier, machineId: machineId)+ : AgentsPage(notifier: notifier, machineId: machineId),+ ),+ );+}++/// Opens one agent full screen.+///+/// ONE at a time, and that is the whole difference from the desktop grid: a phone has no room+/// for a second tile, so whatever else was open is closed rather than left attached somewhere+/// nobody can see it. The page goes up first and says it is attaching; the attach follows.+///+/// [heroSource] names the list this was opened from, so the engine mark's Hero tag matches the row+/// it is flying out of — see [agentHeroTag] for why the source has to be part of the tag at all.+void openAgent(+ BuildContext context,+ AppNotifier notifier,+ String machineId,+ String agentId, {+ required AgentHeroSource heroSource,+}) {+ Navigator.of(context).push(+ _AgentPageRoute(+ builder: (_) => TerminalPage(+ notifier: notifier,+ machineId: machineId,+ agentId: agentId,+ heroSource: heroSource,+ ),+ ),+ );+ unawaited(_showOnly(notifier, machineId, agentId));+}++Future<void> _showOnly(+ AppNotifier notifier,+ String machineId,+ String agentId,+) async {+ await notifier.selectAgent(machineId, agentId);+ final keep = notifier.focusedPane?.id;+ for (final pane in [...notifier.panes]) {+ if (pane.id != keep) await notifier.closePane(pane.id);+ }+}diff --git a/desktop/lib/phone/phone_sheet.dart b/desktop/lib/phone/phone_sheet.dartnew file mode 100644index 000000000..59070a8d8--- /dev/null+++ b/desktop/lib/phone/phone_sheet.dart@@ -0,0 +1,139 @@+import 'package:flutter/material.dart';++import '../shared/theme/app_theme.dart';++/// One action in a phone sheet.+class PhoneSheetAction {+ const PhoneSheetAction({+ required this.icon,+ required this.label,+ required this.onTap,+ this.destructive = false,+ });++ final IconData icon;+ final String label;++ /// Run AFTER the sheet has closed — see [showPhoneSheet], which pops first and then calls this.+ /// A dialog opened from here would otherwise open behind the closing sheet.+ final VoidCallback onTap;++ final bool destructive;+}++/// The `⋯` menu on a phone page: a title line and a column of actions.+///+/// 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.+Future<void> showPhoneSheet(+ BuildContext context, {+ required String title,+ required List<PhoneSheetAction> actions,+}) => showModalBottomSheet<void>(+ context: context,+ useRootNavigator: true,+ showDragHandle: true,+ backgroundColor: AppPalette.panelBg,+ builder: (sheetContext) => SafeArea(+ child: Column(+ mainAxisSize: MainAxisSize.min,+ crossAxisAlignment: CrossAxisAlignment.stretch,+ children: [+ Padding(+ padding: const EdgeInsets.fromLTRB(20, 0, 20, 10),+ child: Text(+ title,+ maxLines: 2,+ overflow: TextOverflow.ellipsis,+ style: TextStyle(color: AppPalette.textSecondary, fontSize: 13),+ ),+ ),+ for (final action in actions)+ _SheetRow(+ action: action,+ // 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: () {+ Navigator.of(sheetContext).pop();+ action.onTap();+ },+ ),+ const SizedBox(height: 8),+ ],+ ),+ ),+);++class _SheetRow extends StatelessWidget {+ const _SheetRow({required this.action, required this.onTap});++ final PhoneSheetAction action;+ final VoidCallback onTap;++ @override+ Widget build(BuildContext context) {+ AppTheme.watch(context);+ final color = action.destructive+ ? AppPalette.dangerFill+ : AppPalette.textPrimary;+ return InkWell(+ onTap: onTap,+ 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,+ style: TextStyle(+ color: color,+ fontSize: 16,+ fontWeight: FontWeight.w500,+ ),+ ),+ ),+ ],+ ),+ ),+ );+ }+}++/// A yes/no question before something that cannot be undone — deleting an agent, unlinking a+/// machine. Returns true only if the destructive button was the one pressed.+Future<bool> confirmPhoneAction(+ BuildContext context, {+ required String title,+ required String message,+ required String confirmLabel,+}) async {+ final confirmed = await showDialog<bool>(+ context: context,+ useRootNavigator: true,+ builder: (dialogContext) => AlertDialog(+ backgroundColor: AppPalette.panelBg,+ title: Text(+ title,+ style: TextStyle(color: AppPalette.textPrimary, fontSize: 18),+ ),+ content: Text(+ message,+ style: TextStyle(color: AppPalette.textSecondary, fontSize: 14),+ ),+ actions: [+ TextButton(+ onPressed: () => Navigator.of(dialogContext).pop(false),+ child: const Text('Cancel'),+ ),+ FilledButton(+ style: FilledButton.styleFrom(backgroundColor: AppPalette.dangerFill),+ onPressed: () => Navigator.of(dialogContext).pop(true),+ child: Text(confirmLabel),+ ),+ ],+ ),+ );+ return confirmed ?? false;+}diff --git a/desktop/lib/phone/phone_shell.dart b/desktop/lib/phone/phone_shell.dartnew file mode 100644index 000000000..b045b79ee--- /dev/null+++ b/desktop/lib/phone/phone_shell.dart@@ -0,0 +1,163 @@+import 'package:flutter/material.dart';++import '../state/app_state.dart';+import 'agent_index.dart';+import 'agents_tab.dart';+import 'machines_tab.dart';+import 'phone_tab_bar.dart';+import 'settings_page.dart';++/// The signed-in phone app: three tabs, each with its own page stack.+///+/// Its own [Navigator] per tab, nested under the app's, on purpose. Two reasons, and both are+/// things a single shared navigator gets wrong:+///+/// - `RootShell` swaps this whole shell out on sign-out, and the pages have to go with it rather+/// than stay stacked over the login screen, as they would on the root navigator.+/// - A tab remembers where it was. Walking into a machine's agents, switching to Settings and+/// coming back returns to that machine, not to the root of the tab — which is what every phone+/// OS does and what a single stack cannot express.+class PhoneShell extends StatefulWidget {+ const PhoneShell({super.key, required this.notifier});++ final AppNotifier notifier;++ @override+ State<PhoneShell> createState() => _PhoneShellState();+}++class _PhoneShellState extends State<PhoneShell> {+ PhoneTab _tab = PhoneTab.agents;++ final _navigators = {+ for (final tab in PhoneTab.values) tab: GlobalKey<NavigatorState>(),+ };++ /// One per tab — see the note at the `HeroControllerScope` below for why they cannot be shared.+ final _heroControllers = {+ for (final tab in PhoneTab.values) tab: HeroController(),+ };++ @override+ void dispose() {+ for (final controller in _heroControllers.values) {+ controller.dispose();+ }+ super.dispose();+ }++ NavigatorState? get _currentNavigator => _navigators[_tab]?.currentState;++ void _select(PhoneTab tab) {+ if (tab == _tab) {+ // A second tap on the tab you are already on pops that tab back to its root — the phone+ // convention, and the only way back out of a deep stack without walking every page.+ _currentNavigator?.popUntil((route) => route.isFirst);+ _syncCanPop();+ return;+ }+ // The new tab has a depth of its own, so the back gesture's answer changes with it.+ setState(() {+ _tab = tab;+ _tabCanPop = _navigators[tab]?.currentState?.canPop() ?? false;+ });+ }++ Widget _rootFor(PhoneTab tab) => switch (tab) {+ PhoneTab.agents => AgentsTab(notifier: widget.notifier),+ PhoneTab.machines => MachinesTab(notifier: widget.notifier),+ PhoneTab.settings => SettingsPage(notifier: widget.notifier),+ };++ /// Whether the tab on screen has a page to go back to — what [PopScope] is given.+ ///+ /// Kept as state rather than read inline in `build`, because a push or pop inside a nested+ /// [Navigator] does not rebuild this widget: the flag has to be pushed here by the notification+ /// below, or `canPop` would answer with whatever was true when the shell last happened to build.+ bool _tabCanPop = false;++ /// Android's back button, handled per tab.+ ///+ /// ⚠️ Deliberately NOT `NavigatorPopHandler`, which is what a single-stack phone shell would+ /// use. It tracks one `canPop` flag fed by `NavigationNotification`s bubbling out of its+ /// subtree — and an [IndexedStack] keeps all three navigators MOUNTED and notifying, so the flag+ /// ends up reflecting whichever tab spoke last rather than the one on screen. A back press on a+ /// root Agents tab would then be swallowed because Settings happened to be two pages deep.+ ///+ /// So the notification is used only as a SIGNAL that some stack moved, and the answer is then+ /// read from the current tab's navigator — the one stack the person is actually looking at.+ bool _onNavigation(NavigationNotification notification) {+ _syncCanPop();+ // Let it keep bubbling: the root navigator above this shell tracks its own state from it.+ return false;+ }++ void _syncCanPop() {+ final next = _currentNavigator?.canPop() ?? false;+ if (next == _tabCanPop) return;+ // The notification arrives mid-build of the subtree that sent it, so defer rather than calling+ // setState inside another widget's build.+ WidgetsBinding.instance.addPostFrameCallback((_) {+ if (!mounted) return;+ final current = _currentNavigator?.canPop() ?? false;+ if (current == _tabCanPop) return;+ setState(() => _tabCanPop = current);+ });+ }++ void _handleBack(bool didPop, Object? result) {+ if (didPop) return;+ _currentNavigator?.maybePop().then((_) {+ if (mounted) _syncCanPop();+ });+ }++ @override+ Widget build(BuildContext context) => ListenableBuilder(+ listenable: widget.notifier,+ builder: (context, _) => PopScope<Object?>(+ // False while this tab has somewhere to go back to, so the gesture reaches [_handleBack]+ // instead of leaving the app. True at a tab's root: the press then belongs to the system.+ canPop: !_tabCanPop,+ onPopInvokedWithResult: _handleBack,+ child: NotificationListener<NavigationNotification>(+ onNotification: _onNavigation,+ child: Scaffold(+ body: IndexedStack(+ index: PhoneTab.values.indexOf(_tab),+ sizing: StackFit.expand,+ children: [+ for (final tab in PhoneTab.values)+ // ⚠️ Each tab's navigator needs its OWN HeroController, and without this the+ // engine-mark flights simply never happen — silently, with no error.+ //+ // `MaterialApp` installs one controller for the ROOT navigator only; a nested+ // `Navigator` inherits nothing, so its routes have no observer to drive a flight.+ // One shared controller is not the fix either — `navigator.dart` on+ // `HeroControllerScope`: "The hero controller ... can only subscribe to one+ // navigator", and these three are all mounted at once inside the IndexedStack.+ HeroControllerScope(+ controller: _heroControllers[tab]!,+ child: Navigator(+ key: _navigators[tab],+ // ⚠️ The controller goes in the SCOPE ONLY, never also in `observers`.+ // `NavigatorState._updateEffectiveObservers` appends the scope's controller to+ // `widget.observers` itself, so listing it here registers it twice and trips+ // "A HeroController can not be shared by multiple Navigators" — which reads+ // like a sharing bug and is really a double-subscription by one navigator.+ onGenerateRoute: (_) =>+ MaterialPageRoute<void>(builder: (_) => _rootFor(tab)),+ ),+ ),+ ],+ ),+ bottomNavigationBar: PhoneTabBar(+ current: _tab,+ onSelect: _select,+ waitingCount: waitingAgents(agentIndex(widget.notifier)).length,+ ),+ ),+ ),+ ),+ );+}diff --git a/desktop/lib/phone/phone_status.dart b/desktop/lib/phone/phone_status.dartnew file mode 100644index 000000000..6200de474--- /dev/null+++ b/desktop/lib/phone/phone_status.dart@@ -0,0 +1,99 @@+import '../core/models.dart';+import '../state/app_state.dart';+import '../terminal/terminal_session.dart';++/// How a phone status line is coloured. The widgets turn this into a palette colour, so the+/// rules below stay testable without a theme.+enum PhoneTone { good, busy, attention, bad, quiet }++/// A status line: what it says, and how it is coloured.+typedef PhoneSummary = ({String label, PhoneTone tone});++/// What a machine's row says, and so where a tap on it goes.+enum PhoneMachineStatus {+ /// Reachable, but this device holds no link to it yet. A tap asks for THAT machine's remote+ /// password — every machine sets its own.+ needsPassword,++ /// Harness is not running there, so none of its agents can be reached until it is.+ offline,++ /// The socket is still coming up, or its agent list has not answered yet.+ connecting,++ /// Linked and answering: a tap lists its agents.+ ready,+}++PhoneMachineStatus phoneMachineStatusOf(MachineState machine) {+ if (machine.needsLink) return PhoneMachineStatus.needsPassword;+ if (machine.nodeOnline == false) return PhoneMachineStatus.offline;+ final answering =+ machine.connectionStatus == ConnectionStatus.connected &&+ machine.agentLoadStatus != AgentLoadStatus.loading;+ return answering ? PhoneMachineStatus.ready : PhoneMachineStatus.connecting;+}++PhoneSummary phoneMachineSummary(MachineState machine) =>+ switch (phoneMachineStatusOf(machine)) {+ PhoneMachineStatus.needsPassword => (+ label: 'Needs its password',+ tone: PhoneTone.attention,+ ),+ PhoneMachineStatus.offline => (label: 'Offline', tone: PhoneTone.bad),+ PhoneMachineStatus.connecting => (+ label: 'Connecting…',+ tone: PhoneTone.busy,+ ),+ PhoneMachineStatus.ready => (+ label: _agentCount(machine.agents.length),+ tone: PhoneTone.good,+ ),+ };++String _agentCount(int count) => switch (count) {+ 0 => 'No agents yet',+ 1 => '1 agent',+ _ => '$count agents',+};++/// What an agent is doing, as its row says it. Waiting on the person outranks working, which+/// outranks everything else: it is the one state somebody has to act on.+PhoneSummary phoneAgentSummary(MachineState machine, Agent agent) {+ if (machine.blockedAgents.containsKey(agent.id)) {+ return (label: 'Waiting for you', tone: PhoneTone.attention);+ }+ if (machine.processingAgentIds.contains(agent.id)) {+ return (label: 'Working…', tone: PhoneTone.busy);+ }+ if (!agent.terminalAvailable) {+ return (+ label: agent.terminalUnavailableReason ?? 'No terminal',+ tone: PhoneTone.quiet,+ );+ }+ return (+ label: agent.engineDisplayName ?? agent.engine ?? 'Agent',+ tone: PhoneTone.quiet,+ );+}++/// The terminal's own state, for the header over it. No session yet reads as attaching: the+/// page opens before the pane has one.+PhoneSummary phoneSessionSummary(+ TerminalSession? session,+) => switch (session?.status) {+ null ||+ TerminalSessionStatus.opening => (label: 'Attaching…', tone: PhoneTone.busy),+ TerminalSessionStatus.resyncing => (+ label: 'Resyncing…',+ tone: PhoneTone.busy,+ ),+ TerminalSessionStatus.controlling => (label: 'Live', tone: PhoneTone.good),+ TerminalSessionStatus.takenOver => (+ label: 'Taken over',+ tone: PhoneTone.attention,+ ),+ TerminalSessionStatus.error => (label: 'Disconnected', tone: PhoneTone.bad),+ TerminalSessionStatus.closed => (label: 'Closed', tone: PhoneTone.quiet),+};diff --git a/desktop/lib/phone/phone_tab_bar.dart b/desktop/lib/phone/phone_tab_bar.dartnew file mode 100644index 000000000..da81c0222--- /dev/null+++ b/desktop/lib/phone/phone_tab_bar.dart@@ -0,0 +1,187 @@+import 'package:flutter/material.dart';+import 'package:lucide_icons_flutter/lucide_icons.dart';++import '../shared/theme/app_theme.dart';++/// The three places a phone can be. Agents first: it is where the app opens and the only tab with+/// anything to act on.+///+/// Lucide, like the rest of the app's navigation — Settings' rail and the desktop machine rail are+/// both Lucide 300, and Material's own glyphs are a heavier, rounder family that reads as a+/// different product beside them. `smartToy`, the obvious Material pick for an agent, is a+/// toy robot head; these are terminals, which is what [PhoneTab.agents] actually lists.+enum PhoneTab {+ agents(+ LucideIcons.squareTerminal300,+ LucideIcons.squareTerminal400,+ 'Agents',+ ),+ machines(+ LucideIcons.laptopMinimal300,+ LucideIcons.laptopMinimal400,+ 'Machines',+ ),+ settings(LucideIcons.settings300, LucideIcons.settings400, 'Settings');++ const PhoneTab(this.icon, this.selectedIcon, this.label);++ final IconData icon;++ /// The tab you are on, drawn a weight heavier rather than filled.+ ///+ /// A line-art set has no filled variant to switch to, and Lucide ships the same glyph at 100–600+ /// instead — so the selected tab thickens where a Material one would solidify. Same purpose: a+ /// second signal beside colour, for anyone who cannot use the colour.+ final IconData selectedIcon;++ final String label;+}++/// The bar along the bottom of the phone's root pages.+///+/// Drawn only on the three root pages. A pushed page — a terminal, a machine's agents — covers it,+/// because a terminal needs the bottom of the screen for its composer and key row, and three+/// layers of chrome stacked under the thumb is what that would otherwise be.+class PhoneTabBar extends StatelessWidget {+ const PhoneTabBar({+ super.key,+ required this.current,+ required this.onSelect,+ this.waitingCount = 0,+ });++ final PhoneTab current;+ final ValueChanged<PhoneTab> onSelect;++ /// How many agents are waiting on an answer — the badge on the Agents tab. Zero draws none.+ final int waitingCount;++ @override+ Widget build(BuildContext context) {+ AppTheme.watch(context);+ return DecoratedBox(+ decoration: BoxDecoration(+ color: AppPalette.panelBg,+ border: Border(top: BorderSide(color: AppGlass.hair)),+ ),+ child: SafeArea(+ top: false,+ child: Padding(+ padding: const EdgeInsets.only(top: 6, bottom: 2),+ child: Row(+ children: [+ for (final tab in PhoneTab.values)+ Expanded(+ child: _Tab(+ tab: tab,+ selected: tab == current,+ badge: tab == PhoneTab.agents ? waitingCount : 0,+ onTap: () => onSelect(tab),+ ),+ ),+ ],+ ),+ ),+ ),+ );+ }+}++class _Tab extends StatelessWidget {+ const _Tab({+ required this.tab,+ required this.selected,+ required this.badge,+ required this.onTap,+ });++ final PhoneTab tab;+ final bool selected;+ final int badge;+ final VoidCallback onTap;++ @override+ Widget build(BuildContext context) {+ AppTheme.watch(context);+ final color = selected+ ? AppPalette.accentOnSurface+ : AppPalette.textSecondary;+ return Semantics(+ button: true,+ selected: selected,+ label: badge > 0 ? '${tab.label}, $badge waiting' : tab.label,+ child: InkWell(+ onTap: onTap,+ borderRadius: BorderRadius.circular(10),+ child: Padding(+ padding: const EdgeInsets.symmetric(vertical: 5),+ child: Column(+ mainAxisSize: MainAxisSize.min,+ children: [+ // The badge rides the icon, so the label below stays on one baseline across tabs.+ Stack(+ clipBehavior: Clip.none,+ children: [+ Icon(+ selected ? tab.selectedIcon : tab.icon,+ size: 23,+ color: color,+ ),+ if (badge > 0)+ Positioned(top: -4, left: 14, child: _Badge(count: badge)),+ ],+ ),+ const SizedBox(height: 3),+ Text(+ tab.label,+ style: TextStyle(+ color: color,+ fontSize: 10.5,+ fontWeight: FontWeight.w500,+ ),+ ),+ ],+ ),+ ),+ ),+ );+ }+}++class _Badge extends StatelessWidget {+ const _Badge({required this.count});++ final int count;++ @override+ Widget build(BuildContext context) {+ AppTheme.watch(context);+ return Container(+ constraints: const BoxConstraints(minWidth: 16),+ padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 1),+ decoration: BoxDecoration(+ color: AppPalette.warn,+ borderRadius: BorderRadius.circular(999),+ // A rim in the bar's own colour, so the badge reads as a separate mark rather than+ // smudging into the icon it overlaps.+ border: Border.all(color: AppPalette.panelBg, width: 1.5),+ ),+ alignment: Alignment.center,+ child: Text(+ // Past 99 the exact figure stops meaning anything and the pill would widen off the icon.+ count > 99 ? '99+' : '$count',+ style: TextStyle(+ // The ink follows the theme because the fill does: [AppPalette.warn] is a light amber in+ // dark (#FFB020) and a dark ochre in light (#B45309). One fixed ink cannot carry both —+ // measured, a dark numeral reads 9.71:1 on dark's fill but only 3.54:1 on light's, under+ // the 4.5:1 floor. White on light's fill is 5.02:1.+ color: AppTheme.pick(Colors.white, const Color(0xFF181818)),+ fontSize: 10,+ height: 1.2,+ fontWeight: FontWeight.w700,+ fontFeatures: AppFont.tabularFigures,+ ),+ ),+ );+ }+}diff --git a/desktop/lib/phone/settings_page.dart b/desktop/lib/phone/settings_page.dartnew file mode 100644index 000000000..f0e12fdda--- /dev/null+++ b/desktop/lib/phone/settings_page.dart@@ -0,0 +1,239 @@+import 'dart:async';++import 'package:flutter/material.dart';+import 'package:lucide_icons_flutter/lucide_icons.dart';++import '../core/app_version.dart';+import '../shared/theme/app_theme.dart';+import '../shared/theme/appearance_prefs_store.dart';+import '../state/app_state.dart';+import '../terminal/terminal_font_store.dart';+import 'phone_header.dart';+import 'phone_sheet.dart';+import 'settings_row.dart';++/// The phone's Settings tab.+///+/// DELIBERATELY not the desktop's eight sections. Four of them cannot work in a viewer build and+/// would each be a screen that opens on nothing:+///+/// - **Usage** reads `~/.claude/projects`, `~/.codex` and OpenCode's SQLite file ON THIS DISK. A+/// phone has none of them — every figure would be zero, for agents that really are running.+/// - **Autonomous devices** flashes an ESP32 over a serial port, through the CLI. A viewer has no+/// CLI and a phone has no serial port.+/// - **Keyboard shortcuts** is a list of ⌘ combinations for a keyboard that is not there.+/// - **Check for updates** belongs to the desktop updater; a phone build is updated by its store.+///+/// What a phone adds instead is the account and the machine links, which the desktop keeps in its+/// rail footer — on a phone there is no rail, so this is the only way to reach either.+class SettingsPage extends StatelessWidget {+ const SettingsPage({super.key, required this.notifier});++ final AppNotifier notifier;++ @override+ Widget build(BuildContext context) => ListenableBuilder(+ listenable: notifier,+ builder: (context, _) {+ AppTheme.watch(context);+ return Scaffold(+ backgroundColor: AppPalette.windowBg,+ body: SafeArea(+ bottom: false,+ child: Column(+ children: [+ const PhoneHeader(large: true, title: 'Settings'),+ Expanded(child: _Body(notifier: notifier)),+ ],+ ),+ ),+ );+ },+ );+}++class _Body extends StatelessWidget {+ const _Body({required this.notifier});++ final AppNotifier notifier;++ @override+ Widget build(BuildContext context) => ListView(+ padding: EdgeInsets.fromLTRB(+ 16,+ // Zero: the first caption brings its own 22pt top, and any padding here would stack on it —+ // the gap under the big "Settings" title would then be a header gap plus a between-groups+ // gap, wider than every other gap on the screen.+ 0,+ 16,+ MediaQuery.paddingOf(context).bottom + 24,+ ),+ children: [+ const SettingsCaption('Account'),+ SettingsGroup(+ children: [+ SettingsRow(+ leading: _Avatar(notifier: notifier),+ title: notifier.currentUser?.displayName ?? 'Signed in',+ detail: notifier.currentUser?.email,+ onTap: () => _showAccountSheet(context, notifier),+ ),+ ],+ ),+ const SettingsCaption('Terminal'),+ SettingsGroup(children: [_FontRow(), _SizeRow()]),+ const SettingsCaption('Appearance'),+ SettingsGroup(children: [_TextSizeRow()]),+ const SettingsNote('Harness is dark-only, so there is no theme to pick.'),+ const SettingsCaption('About'),+ SettingsGroup(children: [const _VersionRow()]),+ ],+ );++ void _showAccountSheet(BuildContext context, AppNotifier notifier) {+ showPhoneSheet(+ context,+ title: notifier.currentUser?.email ?? 'Signed in',+ actions: [+ PhoneSheetAction(+ icon: LucideIcons.logOut300,+ label: 'Sign out',+ destructive: true,+ onTap: () => unawaited(notifier.logout()),+ ),+ ],+ );+ }+}++class _Avatar extends StatelessWidget {+ const _Avatar({required this.notifier});++ final AppNotifier notifier;++ @override+ Widget build(BuildContext context) {+ AppTheme.watch(context);+ final user = notifier.currentUser;+ final source = (user?.name?.trim().isNotEmpty ?? false)+ ? user!.name!.trim()+ : (user?.email ?? '');+ final initial = source.isEmpty ? '?' : source.substring(0, 1).toUpperCase();+ return Container(+ // 34, matching the stepper beside it two rows down: both are the tallest thing in their row,+ // and at 38 this one alone pushed its row past [kSettingsRowHeight] while the others sat on+ // it — one card with a taller first row.+ width: 34,+ height: 34,+ decoration: BoxDecoration(+ color: AppPalette.avatarFill,+ shape: BoxShape.circle,+ ),+ alignment: Alignment.center,+ child: Text(+ initial,+ style: const TextStyle(+ color: Colors.white,+ // Scaled with the disc: 15pt inside 34 left almost no ring around the letter, which+ // reads as a cramped badge rather than an avatar.+ fontSize: 14,+ fontWeight: FontWeight.w600,+ ),+ ),+ );+ }+}++/// The terminal typeface. A sheet rather than a dropdown: a phone has room for the whole list.+class _FontRow extends StatelessWidget {+ @override+ Widget build(BuildContext context) => ValueListenableBuilder(+ valueListenable: terminalFontStore,+ builder: (context, _, _) {+ AppTheme.watch(context);+ return SettingsRow(+ title: 'Font',+ value: terminalFontStore.family.label,+ onTap: () => showPhoneSheet(+ context,+ title: 'Terminal font',+ actions: [+ for (final choice in TerminalFontChoice.available)+ PhoneSheetAction(+ icon: choice == terminalFontStore.family+ ? LucideIcons.check300+ : LucideIcons.type300,+ label: choice.label,+ onTap: () => unawaited(terminalFontStore.setFamily(choice)),+ ),+ ],+ ),+ );+ },+ );+}++/// Terminal text size, as a stepper rather than buried a screen deeper: on a phone this is the+/// setting people actually reach for, because the same pane that reads fine indoors is unreadable+/// at arm's length on a train.+class _SizeRow extends StatelessWidget {+ @override+ Widget build(BuildContext context) => ValueListenableBuilder(+ valueListenable: terminalFontStore,+ builder: (context, _, _) {+ AppTheme.watch(context);+ final size = terminalFontStore.size;+ return SettingsRow(+ title: 'Size',+ trailing: SettingsStepper(+ value: size.toStringAsFixed(0),+ // The bounds are the store's own, so a lit + that does nothing is impossible.+ onDecrease: size > TerminalFontStore.minSize+ ? () => unawaited(terminalFontStore.decreaseSize())+ : null,+ onIncrease: size < TerminalFontStore.maxSize+ ? () => unawaited(terminalFontStore.increaseSize())+ : null,+ ),+ );+ },+ );+}++/// The app's own text size — everything that is not the terminal.+class _TextSizeRow extends StatelessWidget {+ @override+ Widget build(BuildContext context) => ValueListenableBuilder(+ valueListenable: appearancePrefsStore,+ builder: (context, prefs, _) {+ AppTheme.watch(context);+ final size = prefs.uiSize;+ return SettingsRow(+ title: 'Text size',+ trailing: SettingsStepper(+ value: size.toStringAsFixed(0),+ onDecrease: size > AppearancePrefs.uiSizeMin+ ? () => unawaited(appearancePrefsStore.setUiSize(size - 1))+ : null,+ onIncrease: size < AppearancePrefs.uiSizeMax+ ? () => unawaited(appearancePrefsStore.setUiSize(size + 1))+ : null,+ ),+ );+ },+ );+}++/// The version, read from the bundle rather than from `pubspec.yaml` — see [appVersion].+class _VersionRow extends StatelessWidget {+ const _VersionRow();++ @override+ Widget build(BuildContext context) => FutureBuilder<String>(+ future: runningAppVersion(),+ builder: (context, snapshot) {+ AppTheme.watch(context);+ return SettingsRow(title: 'Version', value: snapshot.data ?? '—');+ },+ );+}diff --git a/desktop/lib/phone/settings_row.dart b/desktop/lib/phone/settings_row.dartnew file mode 100644index 000000000..528cb5f89--- /dev/null+++ b/desktop/lib/phone/settings_row.dart@@ -0,0 +1,353 @@+import 'package:flutter/material.dart';+import 'package:lucide_icons_flutter/lucide_icons.dart';++import '../shared/theme/app_theme.dart';++/// The pieces a phone settings list is built from — the grouped inset list every phone OS uses,+/// rather than the desktop's `SettingRow` (a raised block with a fixed-width control on the right,+/// sized for a pane that is never narrower than a sidebar allows).+///+/// The height every settings row clears.+///+/// Set by the tallest control a row can carry — the stepper, at 34pt — plus 8pt of breathing room+/// above and below it. A row with only text is padded up to the same, so a group reads as evenly+/// spaced rather than as rows of two different sizes.+const double kSettingsRowHeight = 50;++/// How far a chevron's arrow stops short of the right edge of its own box.+///+/// MEASURED, not eyeballed: in `lucide.ttf` the `chevron-right` outline runs from 334 to 666 across+/// a 1000-unit advance, so at the 20pt this row draws it the arrow carries 6.68pt of blank on either+/// side. A chevron laid flush against the row's 13pt padding therefore LOOKS inset by nearly 20,+/// while "1.0.0" on the About row below — plain text, no built-in margin — really does end at 13.+/// One padding value, two different right edges: the ragged margin the Font and Version rows showed.+/// Cancelling the glyph's own blank puts the arrow where the text ends, which is where the eye reads+/// the 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;++/// A caption over a run of rows.+class SettingsCaption extends StatelessWidget {+ const SettingsCaption(this.text, {super.key});++ final String text;++ @override+ Widget build(BuildContext context) {+ AppTheme.watch(context);+ return Padding(+ // 22 above, 8 below: the caption belongs to the group under it, so it sits much closer to+ // that group than to the one it follows. Equal gaps either side would leave every caption+ // floating between two cards with nothing to say which it labels.+ padding: const EdgeInsets.fromLTRB(4, 22, 4, 8),+ child: Text(+ text.toUpperCase(),+ style: TextStyle(+ color: AppPalette.textFaint,+ fontSize: 11.5,+ fontWeight: FontWeight.w600,+ letterSpacing: 0.5,+ ),+ ),+ );+ }+}++/// A quiet sentence under a run, explaining something the rows cannot say themselves.+class SettingsNote extends StatelessWidget {+ const SettingsNote(this.text, {super.key});++ final String text;++ @override+ Widget build(BuildContext context) {+ AppTheme.watch(context);+ return Padding(+ // 10 rather than 8, and the extra 2 is doing work: the caption above a group sits at 8, so a+ // note at the same gap reads as another caption for whatever follows rather than as a remark+ // on the group it belongs to.+ padding: const EdgeInsets.fromLTRB(4, 10, 4, 0),+ child: Text(+ text,+ style: TextStyle(+ color: AppPalette.textFaint,+ fontSize: 12.5,+ height: 1.45,+ ),+ ),+ );+ }+}++/// One run of rows, drawn as a single card with hairlines between them.+class SettingsGroup extends StatelessWidget {+ const SettingsGroup({super.key, required this.children});++ final List<Widget> children;++ @override+ Widget build(BuildContext context) {+ AppTheme.watch(context);+ return Container(+ // Full width, so a card is as wide as the list lets it be rather than as wide as its widest+ // row happens to need. Belt and braces with the `stretch` below: the alignment makes the rows+ // fill the card, this makes the card fill the list.+ width: double.infinity,+ decoration: BoxDecoration(+ color: AppGlass.rowFill,+ borderRadius: BorderRadius.circular(AppCard.radius),+ border: Border.all(color: AppGlass.hair),+ ),+ child: ClipRRect(+ borderRadius: BorderRadius.circular(AppCard.radius),+ child: Column(+ mainAxisSize: MainAxisSize.min,+ // ⚠️ `stretch`, not the `center` default — this is what makes every card the same width.+ //+ // A Column sizes itself to its WIDEST child and then centres the narrower ones inside+ // that. A group whose rows are all text (Font, Version) has no wide child to stretch it,+ // so its card came out narrower than one holding a stepper — and since the list centres+ // the cards, the difference showed up as a short right edge on some groups and not+ // others. Stretching makes every row take the full width the list gives the card, so all+ // the cards end on one line whatever is inside them.+ crossAxisAlignment: CrossAxisAlignment.stretch,+ children: [+ for (var i = 0; i < children.length; i++) ...[+ if (i > 0) Divider(height: 1, thickness: 1, color: AppGlass.hair),+ children[i],+ ],+ ],+ ),+ ),+ );+ }+}++/// One row: a title, an optional detail line, and either a value with a chevron (it opens+/// something) or a [trailing] control (it changes something in place).+class SettingsRow extends StatelessWidget {+ const SettingsRow({+ super.key,+ required this.title,+ this.detail,+ this.value,+ this.leading,+ this.trailing,+ this.onTap,+ this.destructive = false,+ });++ final String title;+ final String? detail;++ /// The current setting, shown at the right. Paired with [onTap] it gets a chevron.+ final String? value;++ final Widget? leading;++ /// A control that changes the setting without leaving the page — a stepper. Mutually exclusive+ /// with [value] in practice; if both are given, this wins and no chevron is drawn.+ final Widget? trailing;++ final VoidCallback? onTap;+ final bool destructive;++ @override+ Widget build(BuildContext context) {+ AppTheme.watch(context);+ final titleColor = destructive+ ? AppPalette.dangerFill+ : AppPalette.textPrimary;+ final row = Container(+ // A floor rather than a fixed height, so a row with a two-line detail still grows. Every row+ // in a group clears the same bar — without it a row carrying a stepper (34pt tall) stands+ // visibly taller than one carrying only a value, and a group of four reads as ragged.+ constraints: const BoxConstraints(minHeight: kSettingsRowHeight),+ padding: const EdgeInsets.symmetric(horizontal: 13, vertical: 8),+ child: Row(+ children: [+ if (leading != null) ...[leading!, const SizedBox(width: 12)],+ Expanded(+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ mainAxisSize: MainAxisSize.min,+ children: [+ Text(+ title,+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: TextStyle(+ color: titleColor,+ fontSize: 15,+ fontWeight: FontWeight.w500,+ ),+ ),+ if (detail != null) ...[+ const SizedBox(height: 3),+ Text(+ detail!,+ maxLines: 2,+ overflow: TextOverflow.ellipsis,+ style: TextStyle(+ color: AppPalette.textSecondary,+ fontSize: 12.5,+ height: 1.4,+ ),+ ),+ ],+ ],+ ),+ ),+ // Everything on the right sits in one run, so a value + chevron and a stepper end on the+ // same margin. Previously the value was a bare `Flexible` between two other children,+ // which let it settle wherever the title's `Expanded` left it — "SF Mono ›" floated in+ // from the edge while the stepper below it stayed flush, and the card's right margin+ // read as two different margins.+ if (trailing != null)+ trailing!+ else if (value != null || onTap != null)+ Flexible(+ child: Row(+ mainAxisSize: MainAxisSize.min,+ mainAxisAlignment: MainAxisAlignment.end,+ children: [+ if (value != null)+ Flexible(+ child: Padding(+ padding: const EdgeInsets.only(left: 10),+ child: Text(+ value!,+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ textAlign: TextAlign.end,+ style: TextStyle(+ color: AppPalette.textSecondary,+ fontSize: 14,+ ),+ ),+ ),+ ),+ if (onTap != null)+ Padding(+ padding: const EdgeInsets.only(left: 4),+ child: Transform.translate(+ // Nudged right by the blank the glyph brings with it — see [_chevronInk].+ // 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),+ child: Icon(+ LucideIcons.chevronRight300,+ size: 20,+ color: AppPalette.textFaint,+ ),+ ),+ ),+ ],+ ),+ ),+ ],+ ),+ );+ if (onTap == null) return row;+ return Material(+ color: Colors.transparent,+ child: InkWell(onTap: onTap, child: row),+ );+ }+}++/// − value + in a recessed well. A null callback greys its side out, so a control at its limit+/// says so instead of answering a tap by doing nothing.+class SettingsStepper extends StatelessWidget {+ const SettingsStepper({+ super.key,+ required this.value,+ this.onDecrease,+ this.onIncrease,+ });++ final String value;+ final VoidCallback? onDecrease;+ final VoidCallback? onIncrease;++ @override+ Widget build(BuildContext context) {+ AppTheme.watch(context);+ return DecoratedBox(+ decoration: BoxDecoration(+ color: AppSurface.recess,+ borderRadius: BorderRadius.circular(8),+ ),+ child: Row(+ mainAxisSize: MainAxisSize.min,+ children: [+ _StepButton(+ icon: LucideIcons.minus300,+ tooltip: 'Smaller',+ onPressed: onDecrease,+ ),+ SizedBox(+ width: 34,+ child: Text(+ value,+ textAlign: TextAlign.center,+ style: TextStyle(+ color: AppPalette.textPrimary,+ fontSize: 13.5,+ fontWeight: FontWeight.w500,+ fontFeatures: AppFont.tabularFigures,+ ),+ ),+ ),+ _StepButton(+ icon: LucideIcons.plus300,+ tooltip: 'Larger',+ onPressed: onIncrease,+ ),+ ],+ ),+ );+ }+}++class _StepButton extends StatelessWidget {+ const _StepButton({+ required this.icon,+ required this.tooltip,+ required this.onPressed,+ });++ final IconData icon;+ final String tooltip;+ final VoidCallback? onPressed;++ @override+ Widget build(BuildContext context) {+ AppTheme.watch(context);+ return Semantics(+ button: true,+ enabled: onPressed != null,+ label: tooltip,+ child: Material(+ color: Colors.transparent,+ child: InkWell(+ onTap: onPressed,+ borderRadius: BorderRadius.circular(8),+ child: SizedBox(+ width: 36,+ height: 34,+ child: Icon(+ icon,+ size: 17,+ color: onPressed == null+ ? AppPalette.textFaint+ : AppPalette.textPrimary,+ ),+ ),+ ),+ ),+ );+ }+}diff --git a/desktop/lib/phone/status_pill.dart b/desktop/lib/phone/status_pill.dartnew file mode 100644index 000000000..5a13c85eb--- /dev/null+++ b/desktop/lib/phone/status_pill.dart@@ -0,0 +1,60 @@+import 'package:flutter/material.dart';++import '../shared/theme/app_theme.dart';+import 'phone_status.dart';++/// The palette colour a [PhoneTone] draws in.+Color phoneToneColor(PhoneTone tone) => switch (tone) {+ PhoneTone.good => AppPalette.online,+ PhoneTone.busy => AppPalette.accent,+ PhoneTone.attention => AppPalette.warn,+ PhoneTone.bad => AppPalette.offline,+ PhoneTone.quiet => AppPalette.textFaint,+};++/// A status line: a dot — a small spinner while something is under way — and its label.+class StatusPill extends StatelessWidget {+ const StatusPill({super.key, required this.summary, this.fontSize = 13});++ final PhoneSummary summary;+ final double fontSize;++ @override+ Widget build(BuildContext context) {+ AppTheme.watch(context);+ final color = phoneToneColor(summary.tone);+ final quiet = summary.tone == PhoneTone.quiet;+ return Row(+ mainAxisSize: MainAxisSize.min,+ children: [+ SizedBox.square(+ dimension: 10,+ child: summary.tone == PhoneTone.busy+ ? CircularProgressIndicator(strokeWidth: 1.6, color: color)+ : Center(+ child: DecoratedBox(+ decoration: BoxDecoration(+ color: color,+ shape: BoxShape.circle,+ ),+ child: const SizedBox.square(dimension: 8),+ ),+ ),+ ),+ const SizedBox(width: 7),+ Flexible(+ child: Text(+ summary.label,+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: TextStyle(+ color: quiet ? AppPalette.textSecondary : color,+ fontSize: fontSize,+ fontWeight: FontWeight.w500,+ ),+ ),+ ),+ ],+ );+ }+}diff --git a/desktop/lib/phone/terminal_page.dart b/desktop/lib/phone/terminal_page.dartnew file mode 100644index 000000000..44e37b4dd--- /dev/null+++ b/desktop/lib/phone/terminal_page.dart@@ -0,0 +1,257 @@+import 'dart:async';++import 'package:flutter/material.dart';+import 'package:lucide_icons_flutter/lucide_icons.dart';++import '../shared/theme/app_theme.dart';+import '../shared/widgets/app_icon_button.dart';+import '../state/app_state.dart';+import '../widgets/engine_identity.dart';+import '../widgets/rename_agent_dialog.dart';+import '../widgets/terminal_panel.dart';+import 'agent_hero.dart';+import 'phone_header.dart';+import 'phone_sheet.dart';+import 'phone_status.dart';+import 'status_pill.dart';++/// One agent's terminal, filling the phone. The header says whose it is and whether it is live;+/// everything below it is the same [TerminalPanel] a desktop tile draws, minus that tile's own+/// header.+///+/// A pushed page, so the tab bar is covered: the bottom of this screen belongs to the composer, and+/// a nav bar under it would put two rows of chrome in the thumb's way.+class TerminalPage extends StatefulWidget {+ const TerminalPage({+ super.key,+ required this.notifier,+ required this.machineId,+ required this.agentId,+ required this.heroSource,+ });++ final AppNotifier notifier;+ final String machineId;+ final String agentId;++ /// Which list opened this page — one half of the engine mark's Hero tag, so the flight pairs with+ /// the row it came from rather than an identical row in the other mounted tab.+ final AgentHeroSource heroSource;++ @override+ State<TerminalPage> createState() => _TerminalPageState();+}++class _TerminalPageState extends State<TerminalPage> {+ /// Whether this page's pane ever existed.+ ///+ /// ⚠️ Load-bearing, and the reason this page is stateful at all. The page is pushed BEFORE the+ /// attach — that is what lets it say "Attaching…" — so a null pane means two opposite things+ /// depending on when it is seen: not yet (wait) or no longer (leave).+ ///+ /// Without the distinction, the second case renders as a spinner that never resolves. It is+ /// reachable in normal use now that two tabs can each open a terminal: `openAgent` keeps exactly+ /// one pane, so opening an agent from the Machines tab closes the pane belonging to a+ /// TerminalPage still sitting in the Agents tab's stack.+ bool _hadPane = false;++ /// The composer starts OPEN here, and the phone owns that answer rather than the pane.+ ///+ /// On a desktop tile the box is off until asked for: the terminal itself takes the keyboard, and+ /// the box only buys you a batched send. On a phone there is no other way to type — a software+ /// keyboard has no Esc, no Tab and no Ctrl, so driving the pane per-keystroke was never the+ /// point — so a terminal that opens with nothing to type into reads as broken.+ ///+ /// Local, not `TerminalPane.composerVisible`, on purpose: that field is persisted DESKTOP layout,+ /// shared with the grid, and flipping its default there would turn the box on for every tile on+ /// every machine. A phone shows one agent at a time and there is nothing to remember.+ bool _composerVisible = true;++ @override+ Widget build(BuildContext context) {+ // Clear of the home indicator — except while the keyboard is up, which already is.+ final keyboardUp = MediaQuery.viewInsetsOf(context).bottom > 0;+ return ListenableBuilder(+ listenable: widget.notifier,+ builder: (context, _) {+ AppTheme.watch(context);+ final pane = widget.notifier.panes+ .where(+ (p) =>+ p.machineId == widget.machineId &&+ p.agentId == widget.agentId,+ )+ .firstOrNull;+ if (pane != null) {+ _hadPane = true;+ } else if (_hadPane) {+ // The pane this page was showing is gone — another tab opened a different agent, or the+ // agent was deleted. Leave rather than spin: there is nothing here to come back.+ _leave();+ }+ final session = pane?.session;+ final machine = widget.notifier.stateOf(widget.machineId);+ final agent = machine?.agents+ .where((a) => a.id == widget.agentId)+ .firstOrNull;+ final status = phoneSessionSummary(session);+ return Scaffold(+ backgroundColor: AppPalette.windowBg,+ body: SafeArea(+ bottom: !keyboardUp,+ child: Column(+ children: [+ // The header alone carries the flight — see [AgentHeroHeader]. Only once the agent+ // is known: the row's end of the flight is built from the agent, and a flight begun+ // against a placeholder would land on content that then changes under it.+ AgentHeroHeader(+ tag: agent == null+ ? null+ : agentHeroTag(+ machineId: widget.machineId,+ agentId: widget.agentId,+ source: widget.heroSource,+ ),+ child: PhoneHeader(+ title: agent?.name ?? 'Agent',+ leading: EngineMark(+ engine: agent?.engine,+ displayName: agent?.engineDisplayName,+ size: 22,+ ),+ subtitle: StatusPill(+ fontSize: 12,+ summary: (+ label:+ '${machine?.machine.displayName ?? ''} · ${status.label}',+ tone: status.tone,+ ),+ ),+ trailing: [+ // 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)+ AppIconButton(+ icon: LucideIcons.ellipsis300,+ size: 20,+ tooltip: 'Agent actions',+ color: AppPalette.textSecondary,+ onPressed: () => _showActions(+ machineName: machine?.machine.displayName ?? '',+ agentName: agent.name,+ ),+ ),+ ],+ ),+ ),+ // Everything under the header arrives after the flight lands, rising a little into+ // place — see [AgentBodyReveal]. Drawn full-screen from the first frame it would be+ // a second layer crossing the header still in flight, which is what made the old+ // whole-page version flash.+ Expanded(+ child: AgentBodyReveal(+ child: Column(+ children: [+ Divider(height: 1, color: AppGlass.hair),+ Expanded(+ child: pane == null || session == null+ ? const _Attaching()+ : TerminalPanel(+ key: ValueKey(pane.id),+ notifier: widget.notifier,+ session: session,+ focused: true,+ showHeader: false,+ composerVisible: _composerVisible,+ // Kept, and it is the only way back: a full-screen TUI wants the+ // rows the box is standing on.+ onToggleComposer: () => setState(+ () => _composerVisible = !_composerVisible,+ ),+ ),+ ),+ ],+ ),+ ),+ ),+ ],+ ),+ ),+ );+ },+ );+ }++ /// Pops after the frame: this runs from inside a build, where popping a route synchronously is+ /// not allowed.+ void _leave() {+ WidgetsBinding.instance.addPostFrameCallback((_) {+ if (!mounted) return;+ final navigator = Navigator.of(context);+ if (navigator.canPop()) navigator.pop();+ });+ }++ void _showActions({required String machineName, required String agentName}) {+ showPhoneSheet(+ context,+ title: '$agentName · $machineName',+ actions: [+ PhoneSheetAction(+ icon: LucideIcons.pencil300,+ label: 'Rename agent…',+ onTap: () => showAgentRenameDialog(+ context,+ widget.notifier,+ widget.machineId,+ widget.agentId,+ agentName,+ ),+ ),+ PhoneSheetAction(+ icon: LucideIcons.refreshCw300,+ label: 'Restart agent',+ onTap: () => unawaited(_restart()),+ ),+ ],+ );+ }++ /// Restarting is a round trip that can fail, and the phone has no status rail to fail into — so+ /// the answer lands as a snackbar, which is the one surface a pushed page here always has.+ Future<void> _restart() async {+ final messenger = ScaffoldMessenger.maybeOf(context);+ final result = await widget.notifier.restartAgent(+ widget.machineId,+ widget.agentId,+ );+ final error = result.error;+ if (error == null || messenger == null || !mounted) return;+ messenger.showSnackBar(SnackBar(content: Text(error)));+ }+}++class _Attaching extends StatelessWidget {+ const _Attaching();++ @override+ Widget build(BuildContext context) => Center(+ child: Column(+ mainAxisSize: MainAxisSize.min,+ children: [+ SizedBox.square(+ dimension: 22,+ child: CircularProgressIndicator(+ strokeWidth: 2,+ color: AppPalette.accent,+ ),+ ),+ const SizedBox(height: 14),+ Text(+ 'Attaching to the agent…',+ style: TextStyle(color: AppPalette.textSecondary, fontSize: 14),+ ),+ ],+ ),+ );+}diff --git a/desktop/lib/state/app_state.dart b/desktop/lib/state/app_state.dartindex 0ff4402b6..bfd63fb5f 100644--- a/desktop/lib/state/app_state.dart+++ b/desktop/lib/state/app_state.dart@@ -1861,6 +1861,8 @@ class AppNotifier extends ChangeNotifier {}Future<void> ensureCliDaemonReady() async {+ // A viewer has no daemon to start: it reaches every machine through the relay.+ if (viewer != null) return;final revision = _authRevision;final discovery = _discovery;final probe = await discovery.ensureRunning();diff --git a/desktop/lib/widgets/terminal_panel.dart b/desktop/lib/widgets/terminal_panel.dartindex 0fd3d57ba..c847650f3 100644--- a/desktop/lib/widgets/terminal_panel.dart+++ b/desktop/lib/widgets/terminal_panel.dart@@ -59,6 +59,11 @@ class TerminalPanel extends StatefulWidget {final bool focused;final bool visible;final bool compactHeader;++ /// The tile's own header strip — engine, title, status, pin, close. Off on a+ /// phone, whose page draws its own header and has no tile to pin, close or+ /// drag (`phone/terminal_page.dart`).+ final bool showHeader;final int focusRequest;/// Whether this tile's composer textbox is showing. Only consulted for a remote machine.@@ -84,6 +89,7 @@ class TerminalPanel extends StatefulWidget {required this.focused,this.visible = true,this.compactHeader = false,+ this.showHeader = true,this.focusRequest = 0,this.composerVisible = false,this.readOnly = false,@@ -1041,7 +1047,9 @@ class _TerminalPanelState extends State<TerminalPanel>maintainSize: true,maintainAnimation: true,maintainState: true,- child: _buildHeader(context, remote: remote),+ child: widget.showHeader+ ? _buildHeader(context, remote: remote)+ : const SizedBox.shrink(),),if (_find != null)Positioned.fill(