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.

Store: ask a machine for its harnesses when it connects, not only when the tab opens

dee40c6b404df37
diff --git a/desktop/lib/store/store_screen.dart b/desktop/lib/store/store_screen.dart
index 0fba0cf2a..c879024f1 100644
--- a/desktop/lib/store/store_screen.dart
+++ b/desktop/lib/store/store_screen.dart
@@ -6,6 +6,7 @@ import 'package:url_launcher/url_launcher.dart';
import '../analytics/analytics.dart';
import '../core/dsh_catalog.dart';
+import '../core/models.dart' show ConnectionStatus;
import '../core/test_run.dart';
import '../shared/layouts/widgets/sidebar_item.dart';
import '../shared/theme/app_theme.dart' as grid;
@@ -113,17 +114,57 @@ class _StoreTabState extends State<StoreTab> {
// per-machine fact, and an install started from a terminal is exactly
// what a stored answer misses.
for (final machine in widget.notifier.machineStates.values) {
- final id = machine.machine.machineId;
- unawaited(widget.notifier.probeDsh(id, force: true));
- // The engine rows read the same probe the New Harness dialog does; a
- // machine that has never been asked would show Claude Code as absent.
- unawaited(widget.notifier.probeEngines(id, force: true));
+ _ask(machine);
+ }
+ widget.notifier.addListener(_onAppChanged);
+ });
+ }
+
+ /// Machines asked since they last connected.
+ ///
+ /// A store tab restored when the app launches is built before any machine
+ /// has connected: the first ask fails, and nothing asked again — the shelf
+ /// showed the three engines, each offering Get, over a machine with 21
+ /// harnesses installed. So a machine is asked again each time it connects.
+ final _askedWhileConnected = <String>{};
+
+ void _ask(MachineState machine) {
+ final id = machine.machine.machineId;
+ if (machine.connectionStatus == ConnectionStatus.connected) {
+ _askedWhileConnected.add(id);
+ }
+ unawaited(widget.notifier.probeDsh(id, force: true));
+ // The engine rows read the same probe the New Harness dialog does; a
+ // machine that has never been asked would show Claude Code as absent.
+ unawaited(widget.notifier.probeEngines(id, force: true));
+ }
+
+ void _onAppChanged() {
+ final connecting = <MachineState>[];
+ for (final machine in widget.notifier.machineStates.values) {
+ final id = machine.machine.machineId;
+ if (machine.connectionStatus != ConnectionStatus.connected) {
+ _askedWhileConnected.remove(id);
+ } else if (!_askedWhileConnected.contains(id)) {
+ connecting.add(machine);
+ }
+ }
+ if (connecting.isEmpty) return;
+ // Out of the notification: asking notifies the same listeners again.
+ scheduleMicrotask(() {
+ if (!mounted) return;
+ for (final machine in connecting) {
+ if (machine.connectionStatus == ConnectionStatus.connected &&
+ !_askedWhileConnected.contains(machine.machine.machineId)) {
+ _ask(machine);
+ }
}
});
}
@override
void dispose() {
+ widget.notifier.removeListener(_onAppChanged);
_search.dispose();
_store.dispose();
super.dispose();
diff --git a/desktop/test/store_screen_test.dart b/desktop/test/store_screen_test.dart
index d0bee2121..cbf1b56b3 100644
--- a/desktop/test/store_screen_test.dart
+++ b/desktop/test/store_screen_test.dart
@@ -244,6 +244,38 @@ void main() {
},
);
+ testWidgets(
+ 'a machine that connects after the store opened is asked for its harnesses then',
+ (tester) async {
+ final (notifier, _) = await open(tester);
+ final state = notifier.machineStates['machine-1']!;
+ expect(state.connectionStatus, ConnectionStatus.disconnected);
+ expect(notifier.probes, 1, reason: 'asked once on open, before it connected');
+
+ // The launch race: the store tab was restored first, the machine connects later.
+ state.connectionStatus = ConnectionStatus.connected;
+ notifier.notifyListeners();
+ await tester.pump();
+ expect(notifier.probes, 2);
+ expect(notifier.engineProbes, 2);
+
+ // Once per connection, not on every change while it stays connected.
+ notifier.notifyListeners();
+ await tester.pump();
+ expect(notifier.probes, 2);
+
+ // A reconnect asks again.
+ state.connectionStatus = ConnectionStatus.reconnecting;
+ notifier.notifyListeners();
+ await tester.pump();
+ state.connectionStatus = ConnectionStatus.connected;
+ notifier.notifyListeners();
+ await tester.pump();
+ expect(notifier.probes, 3);
+ expect(tester.takeException(), isNull);
+ },
+ );
+
testWidgets('the catalog keeps real ratings and hides viewer dependencies', (
tester,
) async {