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
fix(mobile): show when the computer is asleep instead of loading
tony69b24e956686
diff --git a/mobile/lib/phone/agent_home.dart b/mobile/lib/phone/agent_home.dartindex f364651f4..f3b1b74db 100644--- a/mobile/lib/phone/agent_home.dart+++ b/mobile/lib/phone/agent_home.dart@@ -363,7 +363,9 @@ class _AgentHomeState extends State<AgentHome> {}return switch (phoneMachineStatusOf(machine)) {PhoneMachineStatus.needsPassword => false,- PhoneMachineStatus.offline => _accountSaysOnline(machine.machine.status),+ PhoneMachineStatus.offline => phoneAccountSaysOnline(+ machine.machine.status,+ ),PhoneMachineStatus.connecting => true,PhoneMachineStatus.ready => switch (machine.agentLoadStatus) {AgentLoadStatus.loaded || AgentLoadStatus.needsLink => false,@@ -405,13 +407,6 @@ class _AgentHomeState extends State<AgentHome> {return true;}- /// The machine list's own word on whether the machine is up — the REST status, not the socket.- static bool _accountSaysOnline(String? status) =>- switch (status?.trim().toLowerCase()) {- 'running' || 'online' || 'connected' || 'ready' => true,- _ => false,- };-/// Whether the screen is currently holding out for the remembered agent — see [_target]. Read by/// build so the wait draws as "Connecting…", never as the empty state.bool _waitingForRestore = false;@@ -741,7 +736,8 @@ class _AgentHomeState extends State<AgentHome> {////// Held with no deadline, on purpose. The terminal on screen already says its machine is offline/// or reconnecting and reattaches by itself when it answers, and Find leaves it at any time — a- /// screen that swaps to another agent on its own, under somebody reading, is the bug.+ /// screen that swaps to another agent on its own, under somebody reading, is the bug. Except with+ /// every machine away, when there is no other agent to swap to: [_dropPagerIfEveryMachineAway].AgentEntry? _awayEntryFor(({String machineId, String agentId}) agent) {final machine = widget.notifier.stateOf(agent.machineId);if (machine == null || phoneMachineListsAgents(machine)) return null;@@ -781,6 +777,7 @@ class _AgentHomeState extends State<AgentHome> {final entries = visibleAgents(agentIndex(widget.notifier));_openNewAgentIfUnlockedMachineIsEmpty(entries);_dropPagerIfShownAgentWasDeleted(entries);+ _dropPagerIfEveryMachineAway();// ⚠️ `_readingLast` holds the screen back so the record gets to name the agent before the// fallback does — but only while the screen is still willing to wait at all. Past// [_loadingTimeout] a read that has not returned is not going to, and going on to pick an@@ -1008,6 +1005,46 @@ class _AgentHomeState extends State<AgentHome> {_pagerGeneration++;}+ /// Every machine asleep: the pager goes, and the screen falls to the machines list.+ ///+ /// ⚠️ **The one exception to [_awayEntryFor]'s hold, and why it can be one.** That hold keeps the+ /// agent on screen through its machine going away, so the screen never swaps to ANOTHER machine's+ /// agent under somebody reading. With every machine away there is no other agent to swap to and+ /// nothing on its way: held, the phone sat on the terminal of a computer that was off — a+ /// skeleton, or its last screen — for as long as it stayed off (owner, 2026-10-08: it should go+ /// back to the machines screen). That list is what [build] shows when no machine can host+ /// anything, and it says which one is asleep and what to do about it.+ ///+ /// [_showing] is KEPT, and it is what brings the agent back: when its machine answers again,+ /// [_target] finds it, and a pager is built around it and attached, exactly as on a launch.+ ///+ /// Away as [phoneMachineAway] means it — the account agrees — so a socket dropping for the+ /// seconds of a redial never takes the terminal down.+ void _dropPagerIfEveryMachineAway() {+ if (_neighboursFor == null || !_everyMachineAway()) return;+ _neighboursFor = null;+ _neighbours = null;+ _pagerGeneration++;+ }++ /// Whether no machine on the account answers or is on its way: each one asleep, or locked for a+ /// password nothing here enters by itself. False before the account's machines are known — that+ /// is a launch, not an answer.+ bool _everyMachineAway() {+ final notifier = widget.notifier;+ final machines = filterableMachines(notifier);+ return machines.isNotEmpty &&+ machines.every(+ (machine) => switch (phoneMachineStatusOf(machine)) {+ PhoneMachineStatus.ready || PhoneMachineStatus.connecting => false,+ // A phone just signed in has every machine locked until the device key log vouches for+ // it, a few seconds later — see [AppNotifier.deviceTrustSettling].+ PhoneMachineStatus.needsPassword => !notifier.deviceTrustSettling,+ PhoneMachineStatus.offline => phoneMachineAway(machine),+ },+ );+ }+/// The first agent after [deleted] in the pager's own order — wrapping past the end, as the pager/// does — that can still be opened.///diff --git a/mobile/lib/phone/phone_status.dart b/mobile/lib/phone/phone_status.dartindex 70516b5a7..1942e3248 100644--- a/mobile/lib/phone/phone_status.dart+++ b/mobile/lib/phone/phone_status.dart@@ -38,6 +38,26 @@ PhoneMachineStatus phoneMachineStatusOf(MachineState machine) {return answering ? PhoneMachineStatus.ready : PhoneMachineStatus.connecting;}+/// The machine list's own word on whether a machine is up — its `/api/machines` status, not the+/// socket.+bool phoneAccountSaysOnline(String? status) =>+ switch (status?.trim().toLowerCase()) {+ 'running' || 'online' || 'connected' || 'ready' => true,+ _ => false,+ };++/// Whether [machine] is away for real: offline by its socket's word, and the account's own record+/// agrees.+///+/// ⚠️ **Both, because the socket alone flaps.** One that drops while it is still being dialled+/// marks the node offline for a moment, for a machine that answers seconds later — saying "asleep"+/// over that would flash a wrong word at every redial. A machine the account also lists as down is+/// one with nothing on the way: switched off, or Harness not running there yet (a computer just+/// restarted was measured taking 70s to reach the relay).+bool phoneMachineAway(MachineState machine) =>+ phoneMachineStatusOf(machine) == PhoneMachineStatus.offline &&+ !phoneAccountSaysOnline(machine.machine.status);+/// Whether [machine]'s agents belong on the agent screens: it is answering, or it answered and its/// socket is only dialling again.///diff --git a/mobile/lib/phone/terminal_page.dart b/mobile/lib/phone/terminal_page.dartindex 45bd5f619..8ea24a7ae 100644--- a/mobile/lib/phone/terminal_page.dart+++ b/mobile/lib/phone/terminal_page.dart@@ -210,6 +210,7 @@ typedef _PageFacts = ({AgentLoadStatus? agentLoadStatus,bool machinePresent,PhoneMachineStatus? machineStatus,+ bool machineAway,bool imagePaste,String? machineName,String? asking,@@ -728,6 +729,8 @@ class _TerminalPageState extends State<TerminalPage>agentLoadStatus: machine?.agentLoadStatus,machinePresent: machine != null,machineStatus: machine == null ? null : phoneMachineStatusOf(machine),+ // Not implied by `machineStatus`: the account's record moves it too — see [phoneMachineAway].+ machineAway: machine != null && phoneMachineAway(machine),imagePaste: machine?.terminalImagePasteAvailable ?? false,machineName: machine?.machine.displayName,// ⚠️ The title's `api-fix asking` is drawn from here too. Left out, a harness elsewhere@@ -1813,6 +1816,12 @@ class _TerminalPageState extends State<TerminalPage>machine.agentLoadStatus == AgentLoadStatus.loaded;// Captured while the agent is still listed, for the sentence above.if (agent != null) _cachedAgentName = agent.displayName;+ final machineAway = machine != null && phoneMachineAway(machine);+ // What stands in for a terminal with nothing to show yet: the skeleton promises a keyframe on+ // its way, which a machine that is away is not sending — see [_MachineAway].+ final placeholder = machineAway+ ? _MachineAway(name: machine.machine.displayName)+ : _Attaching(key: _skeletonKey);// Read-only either way — the terminal was never this pane's (a watcher) or was taken from it.// `_AgentGone` owns the page when the agent itself is missing, so this stays out of its way.final blocked =@@ -2020,7 +2029,7 @@ class _TerminalPageState extends State<TerminalPage>_pickAnotherAgent,): pane == null || session == null- ? _Attaching(key: _skeletonKey)+ ? placeholder: TerminalPanel(tabId: widget.notifier@@ -2157,10 +2166,14 @@ class _TerminalPageState extends State<TerminalPage>// any other page, and nothing here needs to know the// difference. The header says who has it and offers// "Take control"; the body is the terminal.+ //+ // ⚠️ **Not while its machine is away.** The skeleton+ // then promised a keyframe nothing was sending: a+ // computer just restarted left the phone on it for close+ // to 90 seconds, read as a launch that hung. [_MachineAway]+ // covers the panel the same way and says why.if (session != null && !session.hasScreen)- Positioned.fill(- child: _Attaching(key: _skeletonKey),- ),+ Positioned.fill(child: placeholder),// The mic and Search, floating in the// terminal's bottom-right corner — see// [TerminalActionColumn].@@ -2266,6 +2279,10 @@ class _TerminalPageState extends State<TerminalPage>daemon: const DaemonChip(margin: EdgeInsets.only(left: 12),),+ // Only over a screen: with none, [_MachineAway] says it+ // in the terminal's place, and saying it twice is noise.+ away:+ machineAway && (session?.hasScreen ?? false),onTap: () {if (agent == null) return;_showActions(@@ -2828,6 +2845,62 @@ class _AgentGone extends StatelessWidget {);}+/// The terminal's body while its machine is away — offline, and the account agrees (see+/// [phoneMachineAway]) — with no screen of it to show.+///+/// ⚠️ **In the skeleton's place, because the skeleton would be a lie.** [_Attaching] promises a+/// keyframe on its way; a machine that is away sends none until Harness runs there again, and a+/// computer just restarted held the phone on that promise for close to 90 seconds with nothing on+/// screen saying why. This says what the machines list says of it, and that the page comes back by+/// itself: the machine's return already reattaches the agent on screen.+///+/// Drawn as the chrome is (see `tty.dart`): the terminal's own ground and face, no icon. Opaque, as+/// it lies over an empty panel, and it lets taps through to that panel, as the skeleton does.+class _MachineAway extends StatelessWidget {+ const _MachineAway({required this.name});++ /// The machine as the account names it.+ final String name;++ @override+ Widget build(BuildContext context) {+ final tty = Tty.of(context);+ return IgnorePointer(+ child: ColoredBox(+ color: tty.ground,+ child: Center(+ child: Padding(+ padding: const EdgeInsets.symmetric(horizontal: 32),+ child: Semantics(+ liveRegion: true,+ child: Column(+ mainAxisSize: MainAxisSize.min,+ children: [+ Text(+ '$name is asleep',+ textAlign: TextAlign.center,+ style: tty.style(+ size: TtySize.row,+ weight: FontWeight.w600,+ ),+ ),+ const SizedBox(height: 8),+ Text(+ 'turn it on, or run harness start there'+ ' · this opens by itself when it’s back',+ textAlign: TextAlign.center,+ style: tty.style(size: TtySize.meta, color: tty.faint),+ ),+ ],+ ),+ ),+ ),+ ),+ ),+ );+ }+}+/// The terminal's body while its first keyframe is still crossing the network.////// ⚠️ **A skeleton here, not a spinner, because the shape IS known** — that isdiff --git a/mobile/lib/phone/terminal_title.dart b/mobile/lib/phone/terminal_title.dartindex 4f4d4a454..962118630 100644--- a/mobile/lib/phone/terminal_title.dart+++ b/mobile/lib/phone/terminal_title.dart@@ -2,6 +2,8 @@ import 'package:flutter/material.dart';import 'package:flutter/services.dart';import 'package:lucide_icons_flutter/lucide_icons.dart';+import 'package:harness_mobile/shared/theme/app_theme.dart';+import 'tty.dart';import 'tty_controls.dart';@@ -19,6 +21,10 @@ import 'tty_controls.dart';/// you — is the one word that opens it from here. The paired daemon, when there is one, sits at the/// right end ([daemon]): a tap on it opens its own sheet, not the menu.///+/// ⚠️ **One state word, by the owner's call (2026-10-08): the machine being away ([away]).** The+/// terminal cannot say that one — what is on screen is the last thing the machine sent, and it reads+/// as live. It was said on the line above the mic first, and moved up here, at the right end.+////// It floats over the terminal's top rows only while the output is followed at its end, and slides/// away while the history is read back (see `TerminalChromeScroll`) — so it can afford three rows.class TerminalTitle extends StatelessWidget {@@ -32,6 +38,7 @@ class TerminalTitle extends StatelessWidget {this.asking,this.onHold,this.daemon,+ this.away = false,this.sample = false,});@@ -60,6 +67,12 @@ class TerminalTitle extends StatelessWidget {/// room — outside the signed-in shell or with daemons off.final Widget? daemon;+ /// The harness's machine is away (`phoneMachineAway`) and the screen under the title is the last+ /// one it sent: `computer asleep` at the right end, under [asking] when there is one (see+ /// [_notes]). Two words and no more, by the owner's call (2026-10-08) — `reconnects when back`+ /// under it went. Not a button of its own — the page comes back by itself.+ final bool away;+/// Four terminal rows: three lines of text and half a row of air above and below.static double heightOf(Tty tty) => 4 * tty.row;@@ -75,6 +88,74 @@ class TerminalTitle extends StatelessWidget {: '${characters.take(14)}…${characters.skip(characters.length - 14)}';}+ /// The words at the right end — [asking], then [away] — one under another from the name's row+ /// down, as the names on the left are.+ ///+ /// ⚠️ **Stacked, not side by side, and under one width.** Side by side the two added up, and with+ /// the daemon chip beside them they took the whole row: the harness's own name, the title, was cut+ /// to nothing. Stacked they share the 170pt `asking` always had, so the name keeps the room it+ /// had before the machine's word existed.+ ///+ /// With [asking] the whole stack is its button — a tap opens Find, which is also the way off an+ /// agent whose machine is away. Without it the words are the title's, like the rest of it.+ Widget? _notes(Tty tty, double height) {+ final asking = this.asking;+ if (asking == null && !away) return null;+ Text note(String text, Color color, {Key? key}) => Text(+ text,+ key: key,+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: tty.style(color: color, size: TtySize.meta),+ );+ final words = ConstrainedBox(+ constraints: BoxConstraints(+ minHeight: height,+ minWidth: asking == null ? 0 : 44,+ maxWidth: 170,+ ),+ child: Padding(+ padding: const EdgeInsets.only(left: 12),+ child: Align(+ alignment: Alignment.topRight,+ widthFactor: 1,+ child: Padding(+ padding: EdgeInsets.only(top: tty.row * 0.6),+ child: Column(+ mainAxisSize: MainAxisSize.min,+ crossAxisAlignment: CrossAxisAlignment.end,+ children: [+ if (asking != null) note(asking, tty.yellow),+ // The app's warning amber, not the terminal's red: a machine asleep is something+ // to know, not an error — and the 16 ANSI colours have no orange.+ if (away)+ note(+ 'computer asleep',+ AppPalette.warn,+ key: const ValueKey('terminal-title-away'),+ ),+ ],+ ),+ ),+ ),+ ),+ );+ if (asking == null) return words;+ return Semantics(+ button: true,+ label: ['$asking — open Find', if (away) 'computer asleep'].join('. '),+ excludeSemantics: true,+ child: GestureDetector(+ behavior: HitTestBehavior.opaque,+ onTap: () {+ HapticFeedback.selectionClick();+ onFind();+ },+ child: words,+ ),+ );+ }+@overrideWidget build(BuildContext context) {final tty = Tty.of(context);@@ -164,45 +245,7 @@ class TerminalTitle extends StatelessWidget {size: TtySize.meta,),),- if (asking case final asking?)- Semantics(- button: true,- label: '$asking — open Find',- excludeSemantics: true,- child: GestureDetector(- behavior: HitTestBehavior.opaque,- onTap: () {- HapticFeedback.selectionClick();- onFind();- },- child: ConstrainedBox(- constraints: BoxConstraints(- minHeight: height,- minWidth: 44,- maxWidth: 170,- ),- child: Padding(- padding: const EdgeInsets.only(left: 12),- child: Align(- alignment: Alignment.topRight,- widthFactor: 1,- child: Padding(- padding: EdgeInsets.only(top: tty.row * 0.6),- child: Text(- asking,- maxLines: 1,- overflow: TextOverflow.ellipsis,- style: tty.style(- color: tty.yellow,- size: TtySize.meta,- ),- ),- ),- ),- ),- ),- ),- ),+ ?_notes(tty, height),?daemon,],),