Skip to content

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

fix(web): show machine setup only when disconnected

deeda04c80bcad5
diff --git a/desktop/lib/screens/swarm_screen.dart b/desktop/lib/screens/swarm_screen.dart
index 8e71370cb..0dc5b3803 100644
--- a/desktop/lib/screens/swarm_screen.dart
+++ b/desktop/lib/screens/swarm_screen.dart
@@ -241,6 +241,7 @@ class _SwarmScreenState extends State<SwarmScreen> {
bool _newHarnessHidden = false;
bool _routeIsCurrent = true;
String? _linkDialogMachineId;
+ bool _browserMachineSetupHandled = false;
String? _nativeState;
List<Object?>? _machinesPresentation;
ModelsMenuController? _modelsMenu;
@@ -1748,6 +1749,7 @@ class _SwarmScreenState extends State<SwarmScreen> {
}
Future<void> _openMachines({String? initialMachineId}) async {
+ _browserMachineSetupHandled = true;
_onboarding.acknowledge(OnboardingStep.machines);
_openResourcePicker('@');
if (initialMachineId != null && _search?.isMachineMode == true) {
@@ -3592,7 +3594,13 @@ class _SwarmScreenState extends State<SwarmScreen> {
}
void _maybeLink() {
- final machine = app.stateOf(app.selectedMachineId ?? '');
+ if (kIsWeb && app.requestedMachineLink == null) {
+ _maybeInitialBrowserMachines();
+ return;
+ }
+ final machine = app.stateOf(
+ app.requestedMachineLink ?? app.selectedMachineId ?? '',
+ );
if (machine == null ||
!machine.needsLink ||
machine.isLocalMachine ||
@@ -3607,6 +3615,7 @@ class _SwarmScreenState extends State<SwarmScreen> {
_linkDialogMachineId = machine.machine.machineId;
WidgetsBinding.instance.addPostFrameCallback((_) async {
if (mounted) {
+ app.acknowledgeMachineLinkRequest(machine.machine.machineId);
await _openMachines(initialMachineId: machine.machine.machineId);
}
// Keep the prompt's identity until the picker closes. Otherwise Escape
@@ -3615,6 +3624,62 @@ class _SwarmScreenState extends State<SwarmScreen> {
});
}
+ bool get _hasConnectedBrowserMachine => app.machineStates.values.any(
+ (machine) =>
+ !machine.machine.isShared &&
+ !machine.needsLink &&
+ machine.nodeOnline != false &&
+ machine.connectionStatus == ConnectionStatus.connected,
+ );
+
+ bool get _browserMachineSetupReady =>
+ app.machineInventoryLoaded &&
+ !app.machinesLoading &&
+ !app.machinesAreStale &&
+ app.machineListError == null &&
+ !app.machineStates.values.any(
+ (machine) =>
+ !machine.machine.isShared &&
+ !machine.needsLink &&
+ machine.nodeOnline != false &&
+ (machine.connectionStatus == ConnectionStatus.connecting ||
+ machine.connectionStatus == ConnectionStatus.reconnecting),
+ ) &&
+ !_dialogOpen &&
+ !_commandBarOpen &&
+ !_spokenPaletteOpen &&
+ _newHarness == null &&
+ _search == null &&
+ _routeIsCurrent;
+
+ void _maybeInitialBrowserMachines() {
+ if (_browserMachineSetupHandled) return;
+ if (_hasConnectedBrowserMachine) {
+ _browserMachineSetupHandled = true;
+ return;
+ }
+ // Discovery and saved links restore asynchronously. An unlinked row must
+ // not cover the workspace while another machine is still reconnecting.
+ if (!_browserMachineSetupReady) return;
+ _browserMachineSetupHandled = true;
+ WidgetsBinding.instance.addPostFrameCallback((_) {
+ // A connection or a deliberate user action may have won this frame.
+ if (!mounted ||
+ _hasConnectedBrowserMachine ||
+ !_browserMachineSetupReady) {
+ return;
+ }
+ final selected = app.stateOf(app.selectedMachineId ?? '');
+ unawaited(
+ _openMachines(
+ initialMachineId: selected?.needsLink == true
+ ? selected!.machine.machineId
+ : null,
+ ),
+ );
+ });
+ }
+
void _dismissMachinePrompt() {
final id = _linkDialogMachineId;
_linkDialogMachineId = null;
diff --git a/desktop/lib/state/app_state.dart b/desktop/lib/state/app_state.dart
index cc6989397..31b1cedba 100644
--- a/desktop/lib/state/app_state.dart
+++ b/desktop/lib/state/app_state.dart
@@ -2393,12 +2393,22 @@ class AppNotifier extends ChangeNotifier {
/// Held in memory, not on disk, and cleared the moment the machine is chosen
/// again: someone who clicks that row is asking to see it.
final Set<String> _dismissedLinkPrompts = {};
+ String? _requestedMachineLink;
+
+ /// Explicit setup navigation must remain available even when a browser has
+ /// another connected machine and suppresses its automatic startup picker.
+ String? get requestedMachineLink => _requestedMachineLink;
+
+ void acknowledgeMachineLinkRequest(String machineId) {
+ if (_requestedMachineLink == machineId) _requestedMachineLink = null;
+ }
bool isLinkPromptDismissed(String machineId) =>
_dismissedLinkPrompts.contains(machineId);
void dismissLinkPrompt(String machineId) {
if (_disposed) return;
+ acknowledgeMachineLinkRequest(machineId);
if (_dismissedLinkPrompts.add(machineId)) notifyListeners();
}
@@ -3581,6 +3591,7 @@ class AppNotifier extends ChangeNotifier {
_draftSwarmReturns.clear();
_localMismatchReported.clear();
_dismissedLinkPrompts.clear();
+ _requestedMachineLink = null;
for (final controller in _orchestratorProjects.values) {
controller.dispose();
}
@@ -9680,6 +9691,7 @@ class AppNotifier extends ChangeNotifier {
_dismissedLinkPrompts.remove(machineId);
selectedMachineId = machineId;
if (machine.isRemote && !machine.isLocalMachine && machine.needsLink) {
+ _requestedMachineLink = machineId;
notifyListeners();
return;
}
diff --git a/desktop/test/web/browser_workspace_test.dart b/desktop/test/web/browser_workspace_test.dart
index f238ff22c..44b5e7237 100644
--- a/desktop/test/web/browser_workspace_test.dart
+++ b/desktop/test/web/browser_workspace_test.dart
@@ -21,7 +21,176 @@ import 'package:harness/widgets/web_download_button.dart';
import 'package:harness/widgets/swarm_switcher.dart';
import 'package:web/web.dart' as web;
+class _StartupApp extends AppNotifier {
+ _StartupApp()
+ : super(
+ config: AppConfig.dev,
+ authSession: AuthSession(),
+ configStore: null,
+ );
+
+ bool inventoryLoaded = false;
+ @override
+ bool get machineInventoryLoaded => inventoryLoaded;
+}
+
+MachineState _startupMachine(
+ _StartupApp app,
+ String id, {
+ ConnectionStatus status = ConnectionStatus.disconnected,
+ bool needsLink = false,
+}) {
+ final machine = Machine(
+ machineId: id,
+ name: id,
+ authMode: MachineAuthMode.remote,
+ );
+ app.machines.add(machine);
+ final state = MachineState(machine)
+ ..nodeOnline = true
+ ..connectionStatus = status
+ ..needsLink = needsLink;
+ app.machineStates[id] = state;
+ return state;
+}
+
+Future<void> _mountStartup(WidgetTester tester, _StartupApp app) async {
+ app.currentUser = const CurrentUserProfile(email: '[email protected]');
+ final selected = app.selectedMachineId;
+ app.newSwarm(newTabPage: true);
+ app.selectedMachineId = selected;
+ tester.view.physicalSize = const Size(1280, 800);
+ tester.view.devicePixelRatio = 1;
+ addTearDown(tester.view.reset);
+ await tester.pumpWidget(
+ MaterialApp(
+ theme: grid.buildAppTheme(brightness: Brightness.dark),
+ home: SwarmScreen(notifier: app),
+ ),
+ );
+ await tester.pump(const Duration(milliseconds: 200));
+ await tester.pump();
+}
+
void main() {
+ testWidgets('a connected machine keeps the startup picker closed', (
+ tester,
+ ) async {
+ final app = _StartupApp()..inventoryLoaded = true;
+ _startupMachine(app, 'Unlinked machine', needsLink: true);
+ final connected = _startupMachine(
+ app,
+ 'Saved machine',
+ status: ConnectionStatus.connected,
+ );
+ app.selectedMachineId = 'Unlinked machine';
+ await _mountStartup(tester, app);
+ final picker = find.byType(SwarmSearchResults);
+ expect(picker, findsNothing);
+
+ // A later network interruption must not turn into a surprise startup dialog.
+ connected.connectionStatus = ConnectionStatus.disconnected;
+ connected.nodeOnline = false;
+ app.notifyListeners();
+ await tester.pump(const Duration(milliseconds: 200));
+ expect(picker, findsNothing);
+
+ // Deliberately selecting an unlinked machine still opens its setup.
+ connected.connectionStatus = ConnectionStatus.connected;
+ connected.nodeOnline = true;
+ app.showMachinePane('Unlinked machine');
+ await tester.pump(const Duration(milliseconds: 200));
+ await tester.pump();
+ expect(picker, findsOneWidget);
+ expect(
+ tester.widget<SwarmSearchResults>(picker).search.selected?.machineId,
+ 'Unlinked machine',
+ );
+ await tester.sendKeyEvent(LogicalKeyboardKey.escape);
+ await tester.pump();
+ app.notifyListeners();
+ await tester.pump();
+ expect(picker, findsNothing);
+ expect(tester.takeException(), isNull);
+ await tester.pumpWidget(const SizedBox.shrink());
+ app.dispose();
+ });
+
+ for (final pending in [
+ ConnectionStatus.connecting,
+ ConnectionStatus.reconnecting,
+ ]) {
+ testWidgets('startup waits for a saved machine that is $pending', (
+ tester,
+ ) async {
+ final app = _StartupApp()..inventoryLoaded = true;
+ _startupMachine(app, 'Unlinked machine', needsLink: true);
+ final saved = _startupMachine(app, 'Saved machine', status: pending);
+ app.selectedMachineId = 'Unlinked machine';
+ await _mountStartup(tester, app);
+ expect(find.byType(SwarmSearchResults), findsNothing);
+ saved.connectionStatus = ConnectionStatus.connected;
+ app.notifyListeners();
+ await tester.pump(const Duration(milliseconds: 200));
+ expect(find.byType(SwarmSearchResults), findsNothing);
+
+ await tester.sendKeyDownEvent(LogicalKeyboardKey.altLeft);
+ await tester.sendKeyEvent(LogicalKeyboardKey.keyM);
+ await tester.sendKeyUpEvent(LogicalKeyboardKey.altLeft);
+ await tester.pump(const Duration(milliseconds: 200));
+ expect(
+ tester
+ .widget<SwarmSearchResults>(find.byType(SwarmSearchResults))
+ .search
+ .scopePrefix,
+ '@',
+ );
+ expect(tester.takeException(), isNull);
+ await tester.pumpWidget(const SizedBox.shrink());
+ app.dispose();
+ });
+ }
+
+ testWidgets('first visit offers machines once after discovery is complete', (
+ tester,
+ ) async {
+ final app = _StartupApp();
+ await _mountStartup(tester, app);
+ final picker = find.byType(SwarmSearchResults);
+ expect(picker, findsNothing);
+ app.inventoryLoaded = true;
+ app.notifyListeners();
+ await tester.pump(const Duration(milliseconds: 200));
+ await tester.pump();
+ expect(picker, findsOneWidget);
+ expect(
+ tester.widget<SwarmSearchResults>(picker).search.rows.last.title,
+ 'Add machine',
+ );
+ await tester.sendKeyEvent(LogicalKeyboardKey.escape);
+ await tester.pump();
+ app.notifyListeners();
+ await tester.pump(const Duration(milliseconds: 200));
+ expect(picker, findsNothing);
+ expect(tester.takeException(), isNull);
+ await tester.pumpWidget(const SizedBox.shrink());
+ app.dispose();
+ });
+
+ testWidgets('startup offers machines when saved connections are offline', (
+ tester,
+ ) async {
+ final app = _StartupApp()..inventoryLoaded = true;
+ final machine = _startupMachine(app, 'Offline machine');
+ machine.nodeOnline = false;
+ app.selectedMachineId = machine.machine.machineId;
+ await _mountStartup(tester, app);
+ expect(find.byType(SwarmSearchResults), findsOneWidget);
+ expect(tester.takeException(), isNull);
+ await tester.pumpWidget(const SizedBox.shrink());
+ app.dispose();
+ });
+
test(
'a late model response cannot cross an account change in JavaScript',
() {
diff --git a/docs/plans/2026-09-27-009-download-and-machine-startup.md b/docs/plans/2026-09-27-009-download-and-machine-startup.md
new file mode 100644
index 000000000..791d67e34
--- /dev/null
+++ b/docs/plans/2026-09-27-009-download-and-machine-startup.md
@@ -0,0 +1,44 @@
+# Download page and browser startup
+
+Requested: match the download page to the current terminal UI and open the machine picker automatically only when there is no connected machine.
+
+## Download page
+
+The website source is in the separate `autonomous-ai/autonomous-code` repository. The download changes were merged into `deploy/flutter-web` in [PR #6](https://github.com/autonomous-ai/autonomous-code/pull/6), commit `b8b4abb9f997418258f4cbdbac5f26971d13fb6c`, and deployed as `v1.2.19_web`. The local worktree is `/private/tmp/harness-download-ui-20260927`.
+
+- Replaced the old amber buttons and rounded card with the terminal palette, monospace text, flat sections, workspace navigation and bracketed actions.
+- Kept the existing manifest-backed macOS/Linux download routes.
+- Shortened the CLI install command to `curl -fsSL https://harness.autonomous.ai/install.sh | bash`. The new `/install.sh` route redirects to the existing CDN installer, and all website install surfaces use the shared constant.
+- Kept commands visible when copied; provided keyboard-accessible copy controls, success feedback and a manual-copy fallback.
+- Stacked the sections on narrow screens and truncated long commands with an ellipsis; hovering reveals the full command and Copy keeps the complete value.
+- Workspace links use full document navigation because `/` is served by Flutter, not the Next.js router.
+
+Local production preview: <http://127.0.0.1:54873/download>.
+Screenshots: `/private/tmp/harness-download-ui-desktop.png` and `/private/tmp/harness-download-ui-mobile.png`.
+
+## Machine picker
+
+The Flutter changes remain in this checkout on `harness-web-release-readiness`.
+
+- Wait for discovery and saved connections to finish connecting or reconnecting.
+- Suppress the automatic picker if an owned machine is connected, even if another selected machine needs linking.
+- Offer the picker once when discovery finishes with no connection, including an empty machine list or offline machines.
+- Dismissal stays dismissed for the visit. Later connection loss does not interrupt the workspace.
+- Alt-M and explicit machine setup navigation still work. Native startup behavior is preserved.
+
+## Verification
+
+- Chrome workspace/startup tests: 10 passed.
+- Native machine-picker, link-prompt and first-workspace regressions: 31 passed.
+- Focused Flutter analysis: no issues. Production Flutter web build passed (`desktop/build/web-machine-startup`).
+- Download, connect and installer command tests: 9 passed. Focused ESLint has no errors (two existing warnings in `next.config.js`); the standard Next.js production build/typecheck passed.
+- The local `/install.sh` route follows one redirect to HTTP 200. Its response matches the CDN installer byte-for-byte and passes `bash -n`; the script was not executed. The existing `/cli/install.sh` redirect still works.
+- Standalone `tsc` also reads the repository's `.spec` files and reports missing test declarations and mock typing errors. Next.js excludes test files from its production diagnostics; no build check was disabled or configuration changed for this work.
+- Reviewed the production page in Chrome at desktop, 390 px and 320 px widths, including keyboard copying, readable commands, zero horizontal overflow, and full navigation into the Flutter web app. No browser console errors.
+
+## Deployment
+
+- Website release `v1.2.19_web`: [production build passed](https://github.com/autonomous-ai/autonomous-code/actions/runs/36364667119).
+- Verified the live `/download` page shows the redesigned layout and short install command. Screenshot: `/private/tmp/harness-download-live-v1.2.19.png`.
+- Verified `https://harness.autonomous.ai/install.sh` follows one redirect to HTTP 200 and returns the published installer byte-for-byte; `bash -n` passes without executing it.
+- The machine-picker startup changes above remain local in the openharness checkout. The website release keeps the previously published Flutter bundle (`0.1.3`); sharing PR #394 and readiness PR #395 are separate pending releases.