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 switched-off machines as Offline, and keep Unlink from marking them so
bubu-dudu6dfa38f5d3a8
diff --git a/mobile/lib/phone/machine_tile.dart b/mobile/lib/phone/machine_tile.dartindex b7ba4f15b..9bcc65d62 100644--- a/mobile/lib/phone/machine_tile.dart+++ b/mobile/lib/phone/machine_tile.dart@@ -3,6 +3,7 @@ import 'package:lucide_icons_flutter/lucide_icons.dart';import 'package:harness_mobile/shared/theme/app_theme.dart';import 'package:harness_mobile/state/app_state.dart';+import 'phone_card.dart';import 'phone_status.dart';import 'status_pill.dart';@@ -13,7 +14,9 @@ class MachineTile extends StatelessWidget {const MachineTile({super.key, required this.machine, required this.onTap});final MachineState machine;- final VoidCallback onTap;++ /// Null for a row that does not open — an offline machine — which then has no trailing glyph.+ final VoidCallback? onTap;@overrideWidget build(BuildContext context) {@@ -52,14 +55,16 @@ class MachineTile extends StatelessWidget {],),),- const SizedBox(width: 8),- Icon(- status == PhoneMachineStatus.needsPassword- ? LucideIcons.lockKeyhole300- : LucideIcons.chevronRight300,- size: 22,- color: AppPalette.textFaint,- ),+ if (onTap != null) ...[+ const SizedBox(width: 8),+ Icon(+ status == PhoneMachineStatus.needsPassword+ ? LucideIcons.lockKeyhole300+ : LucideIcons.chevronRight300,+ size: 22,+ color: AppPalette.textFaint,+ ),+ ],],),);diff --git a/mobile/lib/phone/machines_tab.dart b/mobile/lib/phone/machines_tab.dartindex 8e7c94ca3..c5e9fdfd8 100644--- a/mobile/lib/phone/machines_tab.dart+++ b/mobile/lib/phone/machines_tab.dart@@ -14,6 +14,7 @@ import 'phone_card.dart';import 'phone_header.dart';import 'phone_navigation.dart';import 'phone_search_button.dart';+import 'phone_status.dart';import 'phone_sheet.dart';import 'unlink_machine.dart';@@ -111,7 +112,14 @@ class _Body extends StatelessWidget {Widget _tile(BuildContext context, MachineState state) => Padding(padding: const EdgeInsets.only(bottom: kPhoneCardGap),- child: MachineTile(machine: state, onTap: () => _open(context, state)),+ // An offline machine has nothing to connect to and nothing to unlink from here that would+ // change anything, so its row does not open — see [PhoneCard], which dims a row with no tap.+ child: MachineTile(+ machine: state,+ onTap: phoneMachineStatusOf(state) == PhoneMachineStatus.offline+ ? null+ : () => _open(context, state),+ ),);/// This screen connects and disconnects, and does nothing else.diff --git a/mobile/lib/phone/phone_navigation.dart b/mobile/lib/phone/phone_navigation.dartindex df4eb492a..f7de169e3 100644--- a/mobile/lib/phone/phone_navigation.dart+++ b/mobile/lib/phone/phone_navigation.dart@@ -3,6 +3,7 @@ import 'dart:async';import 'package:flutter/cupertino.dart';import 'package:harness_mobile/state/app_state.dart';+import 'agent_index.dart';import 'agent_swipe.dart';import 'agents_page.dart';@@ -52,7 +53,8 @@ void openMachine(MachineSwipeList? swipeNeighbours,}) {final machine = notifier.stateOf(machineId);- if (machine == null) return;+ // Offline: no password form to show and no agents to list — every caller also draws the row inert.+ if (machine == null || machine.nodeOnline == false) return;// A pager decides page by page which of the two screens a machine needs, because that answer// changes under the finger — linking one mid-swipe turns its page into the agents list. Opened on// its own, the old pair of routes is kept: [LinkPage] then walks forward to [AgentsPage] itself,@@ -137,7 +139,14 @@ void openAgent(} else {navigator.push(route);}- unawaited(_openPane(notifier, machineId, agentId, keepOthers: swipeNeighbours != null));+ unawaited(+ _openPane(+ notifier,+ machineId,+ agentId,+ keepOthers: swipeNeighbours != null,+ ),+ );}/// Opens one agent as a PAGER over [entries]: the page it lands on is the agent tapped, and adiff --git a/mobile/lib/phone/phone_search_page.dart b/mobile/lib/phone/phone_search_page.dartindex 7b18afd16..9a3268082 100644--- a/mobile/lib/phone/phone_search_page.dart+++ b/mobile/lib/phone/phone_search_page.dart@@ -8,6 +8,7 @@ import 'package:harness_mobile/widgets/engine_identity.dart';import 'phone_navigation.dart';import 'phone_search_index.dart';+import 'phone_status.dart';import 'search_result_text.dart';import 'status_pill.dart';@@ -425,11 +426,15 @@ class _ResultRowState extends State<_ResultRow> {bool _pressed = false;/// An agent whose terminal has gone cannot be opened, the same rule- /// [AgentRow] applies. A machine can always be opened — a locked one opens on- /// its password form, which is the thing to do about it.+ /// [AgentRow] applies. A machine opens unless it is offline — a locked one+ /// opens on its password form, which is the thing to do about it, but a+ /// switched-off one has nothing to take a password.bool get _openable => switch (widget.row.kind) {PhoneSearchKind.agent => widget.row.entry?.agent.terminalAvailable ?? false,- PhoneSearchKind.machine => true,+ PhoneSearchKind.machine =>+ widget.row.machine == null ||+ phoneMachineStatusOf(widget.row.machine!) !=+ PhoneMachineStatus.offline,};void _press(bool pressed) {@@ -581,12 +586,21 @@ class _Action extends StatelessWidget {/// Null where the row says nothing — an agent that opens, which is every/// agent row bar the ones with no terminal left.+ ///+ /// A machine always says something, and an offline one says so rather than+ /// "No terminal": it is dimmed for a different reason, and the word is the+ /// only place that reason is given.String? get _label {- if (!openable) return 'No terminal';+ final machine = row.machine;return switch (row.kind) {- PhoneSearchKind.agent => null,- PhoneSearchKind.machine =>- row.machine?.needsLink ?? false ? 'Unlock' : 'View',+ PhoneSearchKind.agent => openable ? null : 'No terminal',+ PhoneSearchKind.machine => switch (machine == null+ ? null+ : phoneMachineStatusOf(machine)) {+ PhoneMachineStatus.offline => 'Offline',+ PhoneMachineStatus.needsPassword => 'Unlock',+ _ => 'View',+ },};}diff --git a/mobile/lib/phone/phone_status.dart b/mobile/lib/phone/phone_status.dartindex 96a169065..66cc6f344 100644--- a/mobile/lib/phone/phone_status.dart+++ b/mobile/lib/phone/phone_status.dart@@ -26,8 +26,13 @@ enum PhoneMachineStatus {}PhoneMachineStatus phoneMachineStatusOf(MachineState machine) {- if (machine.needsLink) return PhoneMachineStatus.needsPassword;+ // ⚠️ Offline FIRST. A machine that is switched off is almost always also unlinked from here — the+ // relay refuses the dial before the other computer is ever reached — so asking about the link+ // first called a powered-down machine "Needs its password" and offered a form that could only+ // fail. The password is worth asking for once there is something to give it to, which is what the+ // desktop's "Offline · Link required" already says.if (machine.nodeOnline == false) return PhoneMachineStatus.offline;+ if (machine.needsLink) return PhoneMachineStatus.needsPassword;final answering =machine.connectionStatus == ConnectionStatus.connected &&machine.agentLoadStatus != AgentLoadStatus.loading;@@ -114,9 +119,7 @@ PhoneSummary? phoneReclaimAction(TerminalSession? session) =>label: 'Take control',tone: PhoneTone.attention,),- TerminalSessionStatus.error || TerminalSessionStatus.closed => (- label: 'Reconnect',- tone: PhoneTone.bad,- ),+ TerminalSessionStatus.error ||+ TerminalSessionStatus.closed => (label: 'Reconnect', tone: PhoneTone.bad),_ => null,};diff --git a/mobile/lib/state/app_state.dart b/mobile/lib/state/app_state.dartindex 4aff73f94..b0efefee8 100644--- a/mobile/lib/state/app_state.dart+++ b/mobile/lib/state/app_state.dart@@ -2947,11 +2947,15 @@ class AppNotifier extends ChangeNotifier {await refreshLinkedMachines();final machine = machineStates[machineId];if (machine == null) return null;- // Closed first: the state below says this machine wants a password, and a live socket still- // answering underneath would make that a lie for as long as it lasted.- await _pool?.closeMachine(machineId);+ // ⚠️ Marked unlinked BEFORE the socket is closed, not after. Closing reports `disconnected`, and+ // the status handler reads a disconnect from a LINKED machine as the machine going away — it+ // sets `nodeOnline = false`. Closed first, a computer that is still switched on came out of+ // Unlink labelled "Offline" and unopenable, and stayed that way until the next machine refresh.+ // Flagged first, the handler skips that (see the `!machine.needsLink` guard in `_ensurePool`) and+ // presence stays whatever `/api/machines` last said: on → "Needs its password", off → "Offline".machine.needsLink = true;machine.agentLoadStatus = AgentLoadStatus.needsLink;+ await _pool?.closeMachine(machineId);_markSessionsUnreachable(machine,'This phone is no longer linked. Enter the password again to reconnect.',