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.

Merge remote-tracking branch 'origin/main' into feat/mobile-ios-android

Dev jacob7d1a815601cd
diff --cc .gitignore
index 090ce73de,0e19c9d5d..583fe0103
--- a/.gitignore
+++ b/.gitignore
@@@ -18,81 -19,4 +19,82 @@@ provider/example-provider/sessions.jso
.env.*
!.env.example
+# ---------------------------------------------------------------------------
+# Local / personal — machine- or developer-specific, never pushed
+# ---------------------------------------------------------------------------
+
+# AI coding assistants (chat history, local rules, per-dev config).
+# .claude/ contents are ignored by default; whitelist below anything the team
+# should actually share (drop the leading "#" to start tracking it).
+.claude/*
+#!.claude/settings.json
+#!.claude/commands/
+#!.claude/agents/
+#!.claude/skills/
+.claude/settings.local.json
+CLAUDE.local.md
+AGENTS.local.md
+
+.cursor/
+.cursorignore
+.windsurf/
+.codeium/
+.continue/
+.cline/
+.roo/
+.kilocode/
+.trae/
+.junie/
+.gemini/
+.opencode/
+.crush/
+.amp/
+.qodo/
+.specstory/
+.serena/
+.aider*
+.mcp.local.json
+
+# Editors / IDEs — personal workspace state
+.vscode/*
+!.vscode/launch.json
+!.vscode/tasks.json
+!.vscode/extensions.json
+*.code-workspace
+.fleet/
+.zed/
+.nova/
+*.sublime-project
+*.sublime-workspace
+
+# Xcode per-user state (macOS runner)
+**/xcuserdata/
+**/*.xcuserdatad
+**/DerivedData/
+
+# OS junk
+._*
+.Spotlight-V100
+.Trashes
+Thumbs.db
+Desktop.ini
+
+# Secrets & signing material
+*.pem
+*.p8
+*.p12
+*.key
+*.jks
+*.keystore
+key.properties
+secrets/
+ .secrets
+service-account*.json
+
+# Local scratch — notes, experiments, throwaway scripts
+scratch/
+tmp/
+notes/
+*.local
+*.local.*
+TODO.local.md
diff --cc desktop/lib/api/api_client.dart
index 00e8d3d23,3ecd444c0..cd17ca6a5
--- a/desktop/lib/api/api_client.dart
+++ b/desktop/lib/api/api_client.dart
@@@ -95,20 -93,35 +95,53 @@@ bool isUnauthorizedError(Object error)
error is DioException && error.response?.statusCode == 401 ||
error is ApiException && error.status == 401;
+/// Unwraps the backend's `{success, data, error}` envelope, which both legs
+/// speak: the CLI's loopback server mirrors it, and the viewer's own auth calls
+/// (`viewer/direct_auth_api.dart`) read it straight from the backend.
+dynamic unwrapApiResponse(Response res) {
+ final body = res.data;
+ if (body is Map && body['success'] == true) {
+ return body['data'];
+ }
+ final error = body is Map ? body['error'] : null;
+ final serverMessage = error is Map ? error['message'] : null;
+ throw ApiException(
+ serverMessage is String && serverMessage.isNotEmpty
+ ? serverMessage
+ : 'Request failed (${res.statusCode})',
+ status: res.statusCode,
+ );
+}
++
+ /// The sentence a failed local-CLI call earns on an error strip. A raw
+ /// `DioException` is a paragraph about `RequestOptions.receiveTimeout` — true,
+ /// and useless to the person reading it: what they need is which leg failed.
+ /// The daemon not listening, the daemon not answering (it proxies to the
+ /// backend, so that is nearly always the backend being slow), or the backend
+ /// answering with a sentence of its own, which the daemon forwards verbatim.
+ String describeApiError(Object error) {
+ if (error is ApiException) return error.message;
+ if (error is DioException) {
+ switch (error.type) {
+ case DioExceptionType.connectionError:
+ return 'the local Harness service is not answering on its port. '
+ 'It usually restarts on its own; retry in a moment.';
+ case DioExceptionType.connectionTimeout:
+ case DioExceptionType.sendTimeout:
+ case DioExceptionType.receiveTimeout:
+ final limit = error.requestOptions.receiveTimeout?.inSeconds;
+ return 'the local Harness service did not answer'
+ '${limit == null ? '' : ' within ${limit}s'} — the Harness '
+ 'backend is probably slow right now. Retry in a moment.';
+ case DioExceptionType.badResponse:
+ return 'the local Harness service answered '
+ '${error.response?.statusCode ?? 'with an error'}.';
+ case DioExceptionType.badCertificate:
+ case DioExceptionType.cancel:
+ case DioExceptionType.transformTimeout:
+ case DioExceptionType.unknown:
+ return error.message ?? error.error?.toString() ?? 'request failed';
+ }
+ }
+ return '$error';
+ }
diff --cc desktop/lib/screens/swarm_screen.dart
index eb0bfe94b,b60d55de7..f61b43223
--- a/desktop/lib/screens/swarm_screen.dart
+++ b/desktop/lib/screens/swarm_screen.dart
@@@ -1063,17 -1163,25 +1164,33 @@@ class _SwarmScreenState extends State<S
autofocus: app.panes.isNotEmpty,
child: Scaffold(
backgroundColor: grid.AppPalette.swarmField,
+ floatingActionButtonLocation:
+ FloatingActionButtonLocation.endFloat,
+ floatingActionButton: Padding(
+ padding: const EdgeInsets.only(right: 12, bottom: 12),
+ child: FloatingActionButton.small(
+ key: const ValueKey('swarm-add-agent-button'),
+ tooltip: _keymap.hint('agent.add') == null
+ ? 'Add agent'
+ : 'Add agent (${_keymap.hint('agent.add')})',
+ onPressed: () => _openSearch(adding: true),
+ backgroundColor: grid.AppPalette.swarmAccent,
+ foregroundColor: grid.AppPalette.swarmField,
+ shape: const CircleBorder(),
+ child: const Icon(Icons.add, size: 24),
+ ),
+ ),
body: Column(
children: [
- if (!_native) _tabStrip(),
+ if (!_native)
+ SwarmTabStrip(
+ notifier: app,
+ attention: _attention,
+ onRename: _rename,
- onSearch: _jump,
- onNewAgent: _newAgent,
++ onNavigate: _jump,
+ onNotifications: _notifications,
++ onSettings: _settings,
+ ),
if (_keymap.error != null)
Material(
color: grid.AppPalette.panelBg,
diff --cc desktop/lib/state/app_state.dart
index bfd63fb5f,d3b8fba5a..eea53ecd2
--- a/desktop/lib/state/app_state.dart
+++ b/desktop/lib/state/app_state.dart
@@@ -15,10 -12,8 +15,9 @@@ import '../auth/sign_in_client.dart'
import '../auth/cli_link.dart';
import '../auth/cli_login.dart';
import '../bootstrap/environment_provisioner.dart';
+import '../core/viewer_mode.dart';
import '../core/config.dart';
import '../core/agent_preference.dart';
- import '../core/build_identity.dart';
import '../core/engine_availability.dart';
import '../core/local_hostname.dart';
import '../core/local_git_projects.dart';
diff --cc desktop/lib/widgets/swarm_tab_strip.dart
index 3209cf6b3,000000000..e99bd38f3
mode 100644,000000..100644
--- a/desktop/lib/widgets/swarm_tab_strip.dart
+++ b/desktop/lib/widgets/swarm_tab_strip.dart
@@@ -1,228 -1,0 +1,233 @@@
+import 'package:flutter/material.dart';
+
+import '../shared/layouts/window_size.dart';
+import '../shared/theme/app_theme.dart' as grid;
+import '../shortcuts/app_keymap.dart';
+import '../shortcuts/app_shortcuts.dart';
+import '../state/app_state.dart';
+
+/// What the overflow menu can run when the strip is too narrow to show the
+/// actions as buttons.
- enum _StripAction { newSwarm, search, newAgent }
++enum _StripAction { newSwarm, navigate, settings }
+
+/// The swarm tabs, and the shell's global actions beside them.
+///
+/// Split out of `screens/swarm_screen.dart` because it is the one piece of
+/// shell chrome that has to answer for its own width. The grid below it already
+/// measures the window — `_SwarmGeometry` reads the viewport and `auto` picks
+/// its column count from it (`widgets/pane_grid.dart`) — while this strip was
+/// drawn at one fixed size: every tab 186pt whether four or twenty-four were
+/// open, and four icon buttons holding ~176pt of the row no matter how little
+/// was left. Below roughly 700pt that left the tabs a sliver to scroll inside.
+///
+/// Two things move with the width, and nothing else does:
+///
+/// * A tab shrinks, from [maxTabWidth] down to [minTabWidth], before the strip
+/// starts scrolling. A window with room for full-width tabs is laid out
+/// exactly as it was, so nothing changes on the size this was drawn for.
- /// * At [WindowSizeClass.compact] the three actions that are only shortcuts
- /// for something reachable elsewhere fold into one overflow button.
++/// * At [WindowSizeClass.compact] the actions that are only shortcuts for
++/// something reachable elsewhere fold into one overflow button.
+/// Notifications stays out, because its badge is the only part of this strip
+/// that carries state the user cannot see anywhere else.
+class SwarmTabStrip extends StatelessWidget {
+ const SwarmTabStrip({
+ super.key,
+ required this.notifier,
+ required this.attention,
+ required this.onRename,
- required this.onSearch,
- required this.onNewAgent,
++ required this.onNavigate,
+ required this.onNotifications,
++ required this.onSettings,
+ });
+
+ /// Unchanged by width — only what sits in the strip moves, never its height.
+ static const double height = 44;
+
+ /// What a tab is drawn at when the row has room for it.
+ static const double maxTabWidth = 186;
+
+ /// Past this a tab has no room left for a name, so the strip scrolls rather
+ /// than shrinking into a row of identical stubs.
+ static const double minTabWidth = 112;
+
+ final AppNotifier notifier;
+ final int attention;
+ final ValueChanged<String> onRename;
- final VoidCallback onSearch;
- final VoidCallback onNewAgent;
++ final VoidCallback onNavigate;
+ final VoidCallback onNotifications;
++ final VoidCallback onSettings;
+
+ @override
+ Widget build(BuildContext context) => Container(
+ height: height,
+ color: grid.AppPalette.swarmTabBar,
+ child: LayoutBuilder(
+ builder: (context, constraints) => Row(
+ children: [
+ const SizedBox(width: 10),
+ // The tabs measure what is left AFTER the actions have taken theirs,
+ // which is why this is an inner LayoutBuilder and not the outer one.
+ Expanded(child: _tabs()),
+ ..._actions(context, WindowSizeClass.fromWidth(constraints.maxWidth)),
+ const SizedBox(width: 6),
+ ],
+ ),
+ ),
+ );
+
+ Widget _tabs() => LayoutBuilder(
+ builder: (context, constraints) {
+ final count = notifier.swarms.length;
+ final width = count == 0
+ ? maxTabWidth
+ : (constraints.maxWidth / count)
+ .clamp(minTabWidth, maxTabWidth)
+ .toDouble();
+ return ReorderableListView.builder(
+ scrollDirection: Axis.horizontal,
+ shrinkWrap: true,
+ buildDefaultDragHandles: false,
+ itemCount: count,
+ onReorderItem: (old, to) =>
+ notifier.reorderSwarm(notifier.swarms[old].id, to),
+ itemBuilder: (context, index) => _tab(index, width),
+ );
+ },
+ );
+
+ Widget _tab(int index, double width) {
+ final swarm = notifier.swarms[index];
+ final active = notifier.activeSwarmId == swarm.id;
+ return ReorderableDragStartListener(
+ key: ValueKey(swarm.id),
+ index: index,
+ child: GestureDetector(
+ onDoubleTap: () => onRename(swarm.id),
+ child: Container(
+ width: width,
+ margin: const EdgeInsets.only(top: 6, right: 2),
+ decoration: BoxDecoration(
+ color: active ? grid.AppPalette.swarmField : Colors.transparent,
+ borderRadius: const BorderRadius.vertical(top: Radius.circular(9)),
+ ),
+ child: Row(
+ children: [
+ Expanded(
+ child: TextButton(
+ onPressed: () => notifier.selectSwarm(swarm.id),
+ style: TextButton.styleFrom(
+ animationDuration: Duration.zero,
+ foregroundColor: active ? Colors.white : Colors.white70,
+ ),
+ child: Text(
+ swarm.name,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: const TextStyle(fontSize: 13),
+ ),
+ ),
+ ),
+ IconButton(
+ tooltip: 'Close ${swarm.name}',
+ onPressed: () => notifier.closeSwarm(swarm.id),
+ icon: const Icon(Icons.close, size: 13),
+ constraints: const BoxConstraints.tightFor(
+ width: 30,
+ height: 30,
+ ),
+ padding: EdgeInsets.zero,
+ ),
+ ],
+ ),
+ ),
+ ),
+ );
+ }
+
+ List<Widget> _actions(BuildContext context, WindowSizeClass size) => [
+ if (!size.isCompact) ...[
+ IconButton(
+ tooltip: withEffectiveShortcutHint(
+ context,
+ 'New swarm',
+ ShortcutAction.newSwarm,
+ ),
+ onPressed: _canAddSwarm ? notifier.newSwarm : null,
+ icon: const Icon(Icons.add, size: 18),
+ ),
+ IconButton(
+ key: const ValueKey('swarm-search-button'),
+ tooltip: withEffectiveShortcutHint(
+ context,
- 'Search',
++ 'Navigate',
+ ShortcutAction.switchAgent,
+ ),
- onPressed: onSearch,
- icon: const Icon(Icons.search, size: 20),
- ),
- IconButton(
- key: const ValueKey('swarm-new-agent-button'),
- tooltip: withEffectiveShortcutHint(
- context,
- 'New agent',
- ShortcutAction.newAgent,
- ),
- onPressed: onNewAgent,
- icon: const Icon(Icons.add, size: 20),
++ onPressed: onNavigate,
++ icon: const Icon(Icons.explore_outlined, size: 20),
+ ),
+ ],
+ IconButton(
+ key: const ValueKey('swarm-notifications-button'),
+ tooltip: withEffectiveShortcutHint(
+ context,
+ 'Agents needing input',
+ ShortcutAction.showAttention,
+ ),
+ onPressed: onNotifications,
+ icon: Badge(
+ isLabelVisible: attention > 0,
+ child: const Icon(Icons.notifications_none, size: 20),
+ ),
+ ),
++ // Last, after the ones that act on THIS swarm. Settings is the one action
++ // here that leaves the swarm behind, so it keeps the edge rather than
++ // sitting among them — and it folds away with the rest, since the overflow
++ // menu carries it too and two ways to the same screen is one too many.
++ if (!size.isCompact)
++ IconButton(
++ key: const ValueKey('swarm-settings-button'),
++ tooltip: withEffectiveShortcutHint(
++ context,
++ 'Settings',
++ ShortcutAction.showSettings,
++ ),
++ onPressed: onSettings,
++ icon: const Icon(Icons.settings_outlined, size: 20),
++ ),
+ if (size.isCompact) _overflow(),
+ ];
+
+ Widget _overflow() => PopupMenuButton<_StripAction>(
+ key: const ValueKey('swarm-overflow-button'),
+ tooltip: 'More',
+ constraints: const BoxConstraints(minWidth: 180),
+ icon: const Icon(Icons.more_vert, size: 20),
+ itemBuilder: (_) => [
+ PopupMenuItem(
+ value: _StripAction.newSwarm,
+ enabled: _canAddSwarm,
+ child: const Text('New swarm'),
+ ),
+ const PopupMenuItem(
- value: _StripAction.search,
- child: Text('Search'),
++ value: _StripAction.navigate,
++ child: Text('Navigate'),
+ ),
+ const PopupMenuItem(
- value: _StripAction.newAgent,
- child: Text('New agent'),
++ value: _StripAction.settings,
++ child: Text('Settings'),
+ ),
+ ],
+ onSelected: (action) {
+ switch (action) {
+ case _StripAction.newSwarm:
+ notifier.newSwarm();
- case _StripAction.search:
- onSearch();
- case _StripAction.newAgent:
- onNewAgent();
++ case _StripAction.navigate:
++ onNavigate();
++ case _StripAction.settings:
++ onSettings();
+ }
+ },
+ );
+
+ bool get _canAddSwarm => notifier.swarms.length < AppNotifier.maxSwarms;
+}
diff --cc desktop/test/swarm_tab_strip_test.dart
index 1fd3f4418,000000000..45306d3ee
mode 100644,000000..100644
--- a/desktop/test/swarm_tab_strip_test.dart
+++ b/desktop/test/swarm_tab_strip_test.dart
@@@ -1,135 -1,0 +1,132 @@@
+import 'package:flutter/material.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:harness/shared/layouts/window_size.dart';
+import 'package:harness/shared/theme/app_theme.dart' as grid;
+import 'package:harness/state/app_state.dart';
+import 'package:harness/widgets/swarm_tab_strip.dart';
+
+import 'swarm_state_test.dart' show createApp;
+
+/// A tab carries a 2pt right margin inside its own box, so measuring the tab
+/// measures the margin with it.
+const double _margin = 2;
+
+AppNotifier _appWith(int swarms) {
+ final app = createApp();
+ while (app.swarms.length < swarms) {
+ app.newSwarm();
+ }
+ addTearDown(app.dispose);
+ return app;
+}
+
+/// Sizes the WINDOW rather than wrapping the strip in a box: a `SizedBox` wider
+/// than the test surface is silently clamped back to it, which would have every
+/// wide case here quietly measuring 800pt instead.
+Future<void> _mount(
+ WidgetTester tester,
+ AppNotifier app,
+ double width, {
- VoidCallback? onNewAgent,
++ VoidCallback? onSettings,
+}) async {
+ tester.view.devicePixelRatio = 1;
+ tester.view.physicalSize = Size(width, 200);
+ addTearDown(tester.view.resetPhysicalSize);
+ addTearDown(tester.view.resetDevicePixelRatio);
+ await tester.pumpWidget(
+ MaterialApp(
+ theme: grid.buildAppTheme(brightness: Brightness.dark),
+ home: Scaffold(
+ body: Align(
+ alignment: Alignment.topLeft,
+ child: SwarmTabStrip(
+ notifier: app,
+ attention: 0,
+ onRename: (_) {},
- onSearch: () {},
- onNewAgent: onNewAgent ?? () {},
++ onNavigate: () {},
+ onNotifications: () {},
++ onSettings: onSettings ?? () {},
+ ),
+ ),
+ ),
+ ),
+ );
+ await tester.pump();
+}
+
+double _tabWidth(WidgetTester tester, AppNotifier app) =>
+ tester.getSize(find.byKey(ValueKey(app.swarms.first.id)).first).width -
+ _margin;
+
+void main() {
+ testWidgets('a window with room draws every tab at its full width', (
+ tester,
+ ) async {
+ final app = _appWith(2);
+ await _mount(tester, app, 1400);
+
+ expect(_tabWidth(tester, app), SwarmTabStrip.maxTabWidth);
+ });
+
+ testWidgets('tabs give up width before the strip starts scrolling', (
+ tester,
+ ) async {
+ final app = _appWith(8);
+ await _mount(tester, app, 1400);
+
+ final width = _tabWidth(tester, app);
+ expect(width, lessThan(SwarmTabStrip.maxTabWidth));
+ expect(width, greaterThan(SwarmTabStrip.minTabWidth));
+ });
+
+ testWidgets('a tab stops shrinking at the width that still holds a name', (
+ tester,
+ ) async {
+ final app = _appWith(24);
+ await _mount(tester, app, 500);
+
+ expect(_tabWidth(tester, app), SwarmTabStrip.minTabWidth);
+ });
+
- testWidgets('a wide strip keeps all four actions out as buttons', (
++ testWidgets('a wide strip keeps every action out as a button', (
+ tester,
+ ) async {
+ await _mount(tester, _appWith(2), 1400);
+
+ expect(find.byKey(const ValueKey('swarm-search-button')), findsOneWidget);
- expect(
- find.byKey(const ValueKey('swarm-new-agent-button')),
- findsOneWidget,
- );
+ expect(
+ find.byKey(const ValueKey('swarm-notifications-button')),
+ findsOneWidget,
+ );
++ expect(find.byKey(const ValueKey('swarm-settings-button')), findsOneWidget);
+ expect(find.byKey(const ValueKey('swarm-overflow-button')), findsNothing);
+ });
+
+ testWidgets('a compact strip folds the actions away but keeps the badge', (
+ tester,
+ ) async {
+ await _mount(tester, _appWith(2), WindowSizeClass.compactMax - 1);
+
+ expect(find.byKey(const ValueKey('swarm-search-button')), findsNothing);
- expect(find.byKey(const ValueKey('swarm-new-agent-button')), findsNothing);
++ expect(find.byKey(const ValueKey('swarm-settings-button')), findsNothing);
+ expect(
+ find.byKey(const ValueKey('swarm-notifications-button')),
+ findsOneWidget,
+ );
+ expect(find.byKey(const ValueKey('swarm-overflow-button')), findsOneWidget);
+ });
+
+ testWidgets('the folded actions still run from the overflow menu', (
+ tester,
+ ) async {
- var newAgents = 0;
- await _mount(tester, _appWith(2), 420, onNewAgent: () => newAgents++);
++ var settingsOpened = 0;
++ await _mount(tester, _appWith(2), 420, onSettings: () => settingsOpened++);
+
+ await tester.tap(find.byKey(const ValueKey('swarm-overflow-button')));
+ await tester.pumpAndSettle();
- await tester.tap(find.text('New agent'));
++ await tester.tap(find.text('Settings'));
+ await tester.pumpAndSettle();
+
- expect(newAgents, 1);
++ expect(settingsOpened, 1);
+ });
+}