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.

desktop: the Harness Store tab wears the Harness app icon, not an S

deeee48b69b1e14
diff --git a/desktop/lib/screens/swarm_screen.dart b/desktop/lib/screens/swarm_screen.dart
index ebbaa75c8..5ddc15969 100644
--- a/desktop/lib/screens/swarm_screen.dart
+++ b/desktop/lib/screens/swarm_screen.dart
@@ -33,6 +33,7 @@ import '../state/swarm.dart';
import '../widgets/transient_menus.dart';
import '../widgets/layout_palette.dart';
import '../widgets/engine_identity.dart';
+import '../store/store_mark.dart';
import '../store/store_screen.dart';
import '../widgets/harness_start_page.dart';
import '../widgets/link_machine_screen.dart';
@@ -329,9 +330,12 @@ class _SwarmScreenState extends State<SwarmScreen> {
'machineName': entry.machineLabel,
'detail': entry.detail,
'swarm': entry.isSwarm,
+ 'store': entry.isStore,
'agentCount': entry.isSwarm ? entry.members.length : 1,
- 'engine': entry.engine,
- 'iconAsset': engineIdentity(entry.engine).asset,
+ 'engine': entry.isStore ? 'store' : entry.engine,
+ 'iconAsset': entry.isStore
+ ? kStoreMarkAsset
+ : engineIdentity(entry.engine).asset,
'canReopen': app.canReopenClosed(entry.id),
},
],
@@ -344,9 +348,12 @@ class _SwarmScreenState extends State<SwarmScreen> {
'machineName': entry.machineLabel,
'detail': entry.detail,
'swarm': entry.isSwarm,
+ 'store': entry.isStore,
'agentCount': entry.isSwarm ? entry.members.length : 1,
- 'engine': entry.engine,
- 'iconAsset': engineIdentity(entry.engine).asset,
+ 'engine': entry.isStore ? 'store' : entry.engine,
+ 'iconAsset': entry.isStore
+ ? kStoreMarkAsset
+ : engineIdentity(entry.engine).asset,
'current': entry.current,
},
],
@@ -1626,12 +1633,8 @@ class _SwarmScreenState extends State<SwarmScreen> {
child: Row(
children: [
if (swarm.isStore)
- // The Store shares the app's icon.
- Image.asset(
- kStoreMarkAsset,
+ StoreMark(
key: ValueKey('tab-store:${swarm.id}'),
- width: 16,
- height: 16,
)
else if (_tabAgents(swarm).length == 1)
EngineMark(
diff --git a/desktop/lib/state/swarm_navigation.dart b/desktop/lib/state/swarm_navigation.dart
index 59c3e55cd..7e3c415a0 100644
--- a/desktop/lib/state/swarm_navigation.dart
+++ b/desktop/lib/state/swarm_navigation.dart
@@ -112,6 +112,7 @@ class SwarmNavigationHistory {
for (final swarm in app.swarms) ...[
swarm.id,
swarm.name,
+ swarm.kind,
for (final pane in swarm.panes)
(
pane.id,
@@ -171,6 +172,7 @@ class SwarmDestination {
this.projectId,
this.previewKey,
this.members = const {},
+ this.isStore = false,
Iterable<String?> searchFields = const [],
int titleFields = 1,
}) : fields = [
@@ -199,6 +201,10 @@ class SwarmDestination {
final String? projectId;
final SessionPreviewKey? previewKey;
final Set<String> members;
+
+ /// The Harness Store's tab, open or recently closed. It holds no agents, so
+ /// without this it would be drawn as an empty group; it wears the app icon.
+ final bool isStore;
final bool current;
final List<String> fields;
bool get isProject => projectId != null;
@@ -266,6 +272,7 @@ List<Object?> _catalogPresentation(
for (final swarm in app.swarms) ...[
swarm.id,
swarm.name,
+ swarm.kind,
for (final pane in swarm.panes)
(
pane.id,
@@ -429,6 +436,7 @@ class SwarmLocationCatalog {
machineLabel: machineLabel,
swarmId: swarm.id,
swarmName: swarm.name,
+ isStore: swarm.isStore,
current: swarm.id == app.activeSwarmId,
searchFields: [machineLabel],
);
@@ -741,6 +749,7 @@ List<SwarmDestination> closedWorkDestinations(AppNotifier app) => [
closedId: entry.historyId,
title: entry.name,
engine: entry.engine,
+ isStore: entry.kind == 'store',
members: {
for (final pane in entry.panes)
if (pane.agentId != null)
@@ -842,6 +851,7 @@ List<SwarmDestination> swarmDestinations(
if (machines.isNotEmpty) _countLabel(machines.length, 'machine'),
].join(' · '),
members: members,
+ isStore: swarm.isStore,
swarmId: swarm.id,
current: swarm.id == app.activeSwarmId,
searchFields: context.toSet(),
diff --git a/desktop/lib/store/store_mark.dart b/desktop/lib/store/store_mark.dart
new file mode 100644
index 000000000..93acf87f8
--- /dev/null
+++ b/desktop/lib/store/store_mark.dart
@@ -0,0 +1,31 @@
+import 'package:flutter/widgets.dart';
+
+/// The Harness Store wears the app icon — the mark the Dock shows — wherever
+/// its tab is drawn. The native tab strip and History menu are sent this path
+/// and open the same file (`SwarmHistoryIcons` in
+/// macos/Runner/SwarmTitlebar.swift, which must name it or it draws an initial).
+const String kStoreMarkAsset = 'assets/app_icon.png';
+
+/// [kStoreMarkAsset] at a mark's size: the Flutter tab strip, and the store's
+/// row in History. The 256px source is filtered down, so it stays crisp at 2x.
+class StoreMark extends StatelessWidget {
+ const StoreMark({super.key, this.size = 16, this.enabled = true});
+
+ final double size;
+
+ /// Dimmed like `EngineMark` when its row cannot be chosen.
+ final bool enabled;
+
+ @override
+ Widget build(BuildContext context) => Opacity(
+ opacity: enabled ? 1 : 0.45,
+ child: Image.asset(
+ kStoreMarkAsset,
+ width: size,
+ height: size,
+ fit: BoxFit.contain,
+ filterQuality: FilterQuality.high,
+ excludeFromSemantics: true,
+ ),
+ );
+}
diff --git a/desktop/lib/store/store_screen.dart b/desktop/lib/store/store_screen.dart
index 6d7108bac..4c0c4ccaa 100644
--- a/desktop/lib/store/store_screen.dart
+++ b/desktop/lib/store/store_screen.dart
@@ -21,9 +21,6 @@ import 'store_editorial.dart';
import 'store_models.dart';
import 'store_viewers.dart';
-/// Store tabs reuse the app icon.
-const String kStoreMarkAsset = 'assets/app_icon.png';
-
/// The Harness Store, the content of its tab: every harness the registry
/// knows and every built-in engine, as a shelf of cards; one becomes its page
/// — what it is, whose it is, where it is installed, what people think of it —
diff --git a/desktop/lib/widgets/swarm_switcher.dart b/desktop/lib/widgets/swarm_switcher.dart
index 6ab6a64a2..40efed091 100644
--- a/desktop/lib/widgets/swarm_switcher.dart
+++ b/desktop/lib/widgets/swarm_switcher.dart
@@ -13,6 +13,7 @@ import '../shared/widgets/app_dialog.dart';
import '../state/app_state.dart';
import '../state/swarm_navigation.dart';
import '../state/swarm_search.dart';
+import '../store/store_mark.dart';
import 'engine_identity.dart';
import 'swarm_icon.dart';
import 'swarm_search_preview.dart';
@@ -478,6 +479,8 @@ class _SwarmSearchResultsState extends State<SwarmSearchResults> {
size: 20,
color: Colors.white60,
)
+ : row.isStore
+ ? StoreMark(size: 22, enabled: canSubmit)
: row.agentId != null ||
(row.isSwarm &&
row.members.length == 1)
diff --git a/desktop/macos/Runner/SwarmTitlebar.swift b/desktop/macos/Runner/SwarmTitlebar.swift
index 0afb88751..5e87d95cb 100644
--- a/desktop/macos/Runner/SwarmTitlebar.swift
+++ b/desktop/macos/Runner/SwarmTitlebar.swift
@@ -554,7 +554,7 @@ final class SwarmTitlebar: NSObject, NSMenuItemValidation, NSMenuDelegate {
item.target = self
item.representedObject = entry.id
item.state = entry.current ? .on : .off
- item.image = entry.swarm && entry.agentCount != 1
+ item.image = entry.swarm && !entry.store && entry.agentCount != 1
? SwarmIdentity.menuIcon
: historyIcons.image(engine: entry.engine, asset: entry.iconAsset)
historyMenu.addItem(item)
@@ -898,6 +898,8 @@ private struct SwarmHistoryEntry: Equatable {
let detail: String
let machineName: String
let swarm: Bool
+ /// The Harness Store's tab: no agents, but not an empty group either.
+ let store: Bool
let agentCount: Int?
let current: Bool
let engine: String?
@@ -924,6 +926,7 @@ private struct SwarmHistoryEntry: Equatable {
detail = row["detail"] as? String ?? ""
machineName = row["machineName"] as? String ?? ""
swarm = row["swarm"] as? Bool == true
+ store = row["store"] as? Bool == true
agentCount = row["agentCount"] as? Int
current = row["current"] as? Bool == true
engine = (row["engine"] as? String)?.trimmingCharacters(in: .whitespacesAndNewlines).lowercased()
@@ -936,6 +939,15 @@ private struct SwarmHistoryEntry: Equatable {
/// decoded once to at most 32 pixels, rather than retaining a full-size bitmap
/// or reopening assets on every history/focus update.
private final class SwarmHistoryIcons {
+ /// The Flutter assets this opens: engine and harness artwork, and the app
+ /// icon the Harness Store's tab wears (`kStoreMarkAsset` in
+ /// lib/store/store_mark.dart). Any other path draws the engine's initial,
+ /// which is how the store tab once read "S".
+ static func opens(_ asset: String) -> Bool {
+ !asset.contains("..") && (asset == "assets/app_icon.png"
+ || asset.hasPrefix("assets/engine-icons/") && asset.hasSuffix(".png"))
+ }
+
private let cache = NSCache<NSString, NSImage>()
private let assetURL: (String) -> URL?
@@ -957,8 +969,7 @@ private final class SwarmHistoryIcons {
if let image = cache.object(forKey: key) { return image }
let size = NSSize(width: 16, height: 16)
let image: NSImage
- if let asset, asset.hasPrefix("assets/engine-icons/"),
- asset.hasSuffix(".png"), !asset.contains(".."),
+ if let asset, SwarmHistoryIcons.opens(asset),
let url = assetURL(asset),
let source = CGImageSourceCreateWithURL(url as CFURL, nil),
let thumbnail = CGImageSourceCreateThumbnailAtIndex(source, 0, [
@@ -975,6 +986,12 @@ private final class SwarmHistoryIcons {
bitmap.draw(in: NSRect(x: (16 - width) / 2, y: (16 - height) / 2, width: width, height: height))
return true
}
+ } else if id == "store", let appIcon = NSApp.applicationIconImage {
+ // The bundled copy did not load; the Dock's icon is the same mark.
+ image = NSImage(size: size, flipped: false) { _ in
+ appIcon.draw(in: NSRect(origin: .zero, size: size))
+ return true
+ }
} else if id == "claude" {
// Same four round strokes, proportions and orange as EngineMark.
image = NSImage(size: size, flipped: false) { _ in
diff --git a/desktop/test/swarm_history_test.dart b/desktop/test/swarm_history_test.dart
index 88bbc2778..87d134e30 100644
--- a/desktop/test/swarm_history_test.dart
+++ b/desktop/test/swarm_history_test.dart
@@ -7,13 +7,17 @@ import 'package:harness/core/models.dart';
import 'package:harness/screens/swarm_screen.dart';
import 'package:harness/settings/settings_screen.dart';
import 'package:harness/state/app_state.dart';
+import 'package:harness/state/swarm.dart';
import 'package:harness/state/swarm_catalog.dart';
import 'package:harness/state/swarm_navigation.dart';
import 'package:harness/state/terminal_pane.dart';
+import 'package:harness/store/store_mark.dart';
import 'package:harness/terminal/terminal_binary.dart';
+import 'package:harness/widgets/swarm_icon.dart';
import 'package:xterm/xterm.dart';
-import 'swarm_screen_test.dart' show terminal;
+import 'swarm_interactions_test.dart' show chord;
+import 'swarm_screen_test.dart' show mount, terminal;
import 'swarm_state_test.dart' show createApp;
import 'swarm_switcher_test.dart' show jumpField;
@@ -221,6 +225,89 @@ void main() {
},
);
+ for (final native in [false, true]) {
+ testWidgets(
+ 'History lists the store tab by the app icon, visited and closed (native=$native)',
+ (tester) async {
+ const channel = MethodChannel('harness/swarm_tabs');
+ final messenger = tester.binding.defaultBinaryMessenger;
+ final updates = <Map>[];
+ messenger.setMockMethodCallHandler(channel, (call) async {
+ if (call.method == 'update') updates.add(call.arguments as Map);
+ return true;
+ });
+ addTearDown(() => messenger.setMockMethodCallHandler(channel, null));
+ final app = createApp();
+ app.adoptSessionForTest(terminal('a0', []));
+ final work = app.activeSwarm;
+ await mount(tester, app, nativeTabs: native);
+ app.openStore();
+ await tester.pump();
+ final store = app.activeSwarm;
+ expect(store.isStore, isTrue);
+ app.selectSwarm(work.id);
+ await tester.pump();
+
+ // The mark a History row draws for the store, never the group grid.
+ Future<void> expectFlutterRow() async {
+ await chord(tester, LogicalKeyboardKey.keyY);
+ await tester.pump();
+ final row = find.ancestor(
+ of: find.text(Swarm.storeName),
+ matching: find.byType(ListTile),
+ );
+ expect(row, findsOneWidget);
+ expect(
+ find.descendant(of: row, matching: find.byType(SwarmIcon)),
+ findsNothing,
+ );
+ expect(
+ find.descendant(
+ of: row,
+ matching: find.byWidgetPredicate(
+ (w) =>
+ w is Image &&
+ w.image is AssetImage &&
+ (w.image as AssetImage).assetName == kStoreMarkAsset,
+ ),
+ ),
+ findsOneWidget,
+ );
+ await tester.sendKeyEvent(LogicalKeyboardKey.escape);
+ await tester.pump();
+ await tester.pump(const Duration(milliseconds: 100));
+ }
+
+ if (native) {
+ final visited = (updates.last['history'] as List)
+ .cast<Map>()
+ .firstWhere((row) => row['id'] == swarmDestinationId(store.id));
+ expect(visited['store'], isTrue);
+ expect(visited['engine'], 'store');
+ expect(visited['iconAsset'], kStoreMarkAsset);
+ } else {
+ await expectFlutterRow();
+ }
+
+ await app.closeSwarm(store.id);
+ await tester.pump();
+ if (native) {
+ final closed = (updates.last['closedHistory'] as List)
+ .cast<Map>()
+ .single;
+ expect(closed['title'], Swarm.storeName);
+ expect(closed['store'], isTrue);
+ expect(closed['engine'], 'store');
+ expect(closed['iconAsset'], kStoreMarkAsset);
+ } else {
+ await expectFlutterRow();
+ }
+ await tester.pumpWidget(const SizedBox());
+ app.dispose();
+ },
+ );
+ }
+
test('Back and Forward retain exact pane locations and discard a branched future', () async {
final app = createApp();
addTearDown(app.dispose);
diff --git a/desktop/test/swarm_screen_test.dart b/desktop/test/swarm_screen_test.dart
index 992cce492..dcefe3468 100644
--- a/desktop/test/swarm_screen_test.dart
+++ b/desktop/test/swarm_screen_test.dart
@@ -1,4 +1,5 @@
import 'dart:convert';
+import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter/gestures.dart';
@@ -11,6 +12,7 @@ import 'package:harness/state/app_state.dart';
import 'package:harness/state/swarm_catalog.dart';
import 'package:harness/state/swarm_navigation.dart';
import 'package:harness/state/terminal_pane.dart';
+import 'package:harness/store/store_mark.dart';
import 'package:harness/terminal/terminal_binary.dart';
import 'package:harness/terminal/terminal_session.dart';
import 'package:harness/widgets/engine_identity.dart';
@@ -45,6 +47,24 @@ Future<void> mount(
await tester.pump(const Duration(milliseconds: 100));
}
+/// Whether the native icon loader (`SwarmHistoryIcons` in
+/// macos/Runner/SwarmTitlebar.swift) opens [asset]: an exact path it names, or
+/// one under a folder it names. Read from the source because no Dart test can
+/// run the Swift, and the channel carrying a path the loader then refuses is
+/// exactly the break this guards.
+bool nativeIconLoaderOpens(String asset) {
+ final swift = File('macos/Runner/SwarmTitlebar.swift').readAsStringSync();
+ final start = swift.indexOf('class SwarmHistoryIcons');
+ expect(start, isNonNegative, reason: 'SwarmHistoryIcons moved');
+ final body = swift.substring(start, swift.indexOf('\n}\n', start));
+ final exact = RegExp(r'asset == "([^"]+)"').allMatches(body).map((m) => m[1]!);
+ final folders = RegExp(
+ r'hasPrefix\("([^"]+/)"\)',
+ ).allMatches(body).map((m) => m[1]!);
+ return !asset.contains('..') &&
+ (exact.contains(asset) || folders.any(asset.startsWith));
+}
+
TerminalSession terminal(String id, List<TerminalBinaryFrame> input) =>
TerminalSession(
machineId: 'm',
@@ -165,9 +185,31 @@ void main() {
final row = (updates.last['tabs'] as List).single as Map;
expect(row['kind'], 'store');
expect(row['agentCount'], 0);
- expect(row['iconAsset'], 'assets/app_icon.png');
+ expect(row['engine'], 'store');
+ expect(row['iconAsset'], kStoreMarkAsset);
+ // Sending the path is half of it: SwarmTitlebar.swift draws an initial
+ // for any asset its loader does not open, which is how the native
+ // strip came to show an "S" beside Harness Store.
+ expect(
+ nativeIconLoaderOpens(kStoreMarkAsset),
+ isTrue,
+ reason: 'SwarmHistoryIcons must open $kStoreMarkAsset',
+ );
+ expect(nativeIconLoaderOpens('assets/engine-icons/codex.png'), isTrue);
+ expect(nativeIconLoaderOpens('assets/harness_device.png'), isFalse);
} else {
- expect(find.byKey(ValueKey('tab-store:${tab.id}')), findsOneWidget);
+ final mark = find.byKey(ValueKey('tab-store:${tab.id}'));
+ expect(mark, findsOneWidget);
+ final image = tester.widget<Image>(
+ find.descendant(
+ of: mark,
+ matching: find.byType(Image),
+ matchRoot: true,
+ ),
+ );
+ expect((image.image as AssetImage).assetName, kStoreMarkAsset);
+ expect(image.width, 16);
+ expect(image.height, 16);
}
});