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.

Polish Swarm navigation, team status, and embedded Devices (#1595)

Dee669e65df92a1
diff --git a/desktop/AGENTS.md b/desktop/AGENTS.md
index d36422966..87839a002 100644
--- a/desktop/AGENTS.md
+++ b/desktop/AGENTS.md
@@ -2,10 +2,13 @@
Use [CLAUDE.md](CLAUDE.md) for architecture, build commands, and testing.
-For every DSH dashboard, follow the [DSH workspace contract](design/dsh-workspace.md):
+For DSH dashboards, follow the [DSH workspace contract](design/dsh-workspace.md):
70% viewer on the left, 30% real agent chat on the right, including loading,
missing dependencies, failures, retries, and restoration. Reserve the chat slot
before startup; never let an unavailable conversation become a full-width viewer.
+The Swarm's **Your devices** is a dashboard-only exception: fill its center pane,
+keep the sidebars visible, and do not start or reserve a Devices conversation.
+Standalone Devices retains its existing viewer/chat workspace.
For all UI outside terminal panes, follow the
[desktop design system](design/desktop-design-system.md). The user's current
diff --git a/desktop/CLAUDE.md b/desktop/CLAUDE.md
index 504c5564a..d40648d27 100644
--- a/desktop/CLAUDE.md
+++ b/desktop/CLAUDE.md
@@ -76,6 +76,15 @@ FLUTTER_TEST=1 flutter test -d macos --no-pub integration_test/native_terminal_e
FLUTTER_TEST=1 flutter test -d macos --no-pub integration_test/native_workspace_e2e_test.dart
```
+`integration_test/flutter_test_config.dart` installs the production accessibility guard before
+Flutter's launcher initializes its binding. A fixture launched directly for manual review must
+call `ensureNativeTestBinding()` too; an unguarded fixture can reproduce the engine's known
+disconnected-semantics crash even though the normal app already protects that boundary.
+Pin macOS-only cases with `TargetPlatformVariant({TargetPlatform.macOS})`: Flutter's debug
+`FLUTTER_TEST` default is Android, which bypasses desktop-specific behavior. Native accessibility
+review must also exercise activation after the framework tree exists; retaining a test semantics
+handle while AppKit reconnects requires replaying the complete tree and custom actions.
+
`integration_test/sign_in_native_test.dart` walks a new computer from the tour to the sign-in page
and on to the workspace, in the real window. AppKit draws the tab row, so no Flutter test can see
or press it: run `python3 tool/native_driver.py <dir> <shots> &` beside it and pass
diff --git a/desktop/design/dsh-workspace.md b/desktop/design/dsh-workspace.md
index 7307e42a9..fe7bff93d 100644
--- a/desktop/design/dsh-workspace.md
+++ b/desktop/design/dsh-workspace.md
@@ -6,6 +6,13 @@ native utility harnesses such as Devices and companions, not just Store web
viewers. The chat is the real agent terminal, with its existing input, approval,
session, and resume behavior. Do not build a second chat implementation.
+In a Swarm, **Your devices** is a dashboard-only exception. It fills the center
+area of the current tab, keeping the Swarm sidebar and roster visible. It does
+not start, resume, attach, or reserve a Devices agent or chat pane. Returning to a
+project restores its draft and conversation choice. Saved embedded viewer/chat
+layouts normalize to this single dashboard; no new top-level tab is opened.
+Standalone Devices outside a Swarm retains the viewer/chat workspace below.
+
Use the shared `PaneGrid` and `PaneArrangement.viewerBesideTerminal`. Reserve
both slots before asynchronous setup starts. Keep the chat slot visible while
loading, when its package or engine is missing, when launch fails, and while
@@ -27,8 +34,12 @@ instruction. A failed edit stays beside the affected device control.
Verify the actual workspace, not a dashboard rendered alone:
+- For Your devices inside a Swarm, verify one dashboard fills the center at narrow
+ and wide sizes, no conversation is created, and returning to a project preserves
+ its draft, selected workgroup, and any existing viewers.
- Measure left/right placement and the 70/30 split before startup, after failure,
- after a successful retry, and after restore. Check user-resized layouts too.
+ after a successful retry, and after restore for standalone DSH workspaces.
+ Check user-resized layouts too.
- Test a missing bundled package and an unavailable engine. A ready-agent-only
preview misses the failure that previously removed Devices chat.
- Check disconnected hosts disappear without messages, and reconnect with their
diff --git a/desktop/integration_test/flutter_test_config.dart b/desktop/integration_test/flutter_test_config.dart
new file mode 100644
index 000000000..76cb18836
--- /dev/null
+++ b/desktop/integration_test/flutter_test_config.dart
@@ -0,0 +1,20 @@
+import 'dart:async';
+
+import 'package:harness/core/connected_semantics.dart';
+import 'package:integration_test/integration_test.dart';
+
+/// Native fixtures must keep the production accessibility boundary. Flutter's
+/// test launcher initializes its binding before calling a test's main, so this
+/// hook installs the guarded binding before that automatic initialization.
+class HarnessIntegrationTestBinding extends IntegrationTestWidgetsFlutterBinding
+ with ConnectedSemanticsBinding {}
+
+HarnessIntegrationTestBinding? _binding;
+
+HarnessIntegrationTestBinding ensureNativeTestBinding() =>
+ _binding ??= HarnessIntegrationTestBinding();
+
+Future<void> testExecutable(FutureOr<void> Function() testMain) async {
+ ensureNativeTestBinding();
+ await testMain();
+}
diff --git a/desktop/integration_test/super_tab_native_test.dart b/desktop/integration_test/super_tab_native_test.dart
index f46f0a6a6..2ace9c5d7 100644
--- a/desktop/integration_test/super_tab_native_test.dart
+++ b/desktop/integration_test/super_tab_native_test.dart
@@ -1,14 +1,15 @@
import 'dart:io';
import 'dart:ui' as ui;
+import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
-import 'package:integration_test/integration_test.dart';
import 'package:window_manager/window_manager.dart';
import 'package:harness/core/test_run.dart';
import 'package:harness/core/models.dart';
+import 'package:harness/devices/devices_screen.dart';
import 'package:harness/shared/theme/app_theme.dart' as grid;
import 'package:harness/state/new_harness.dart';
import 'package:harness/super_tabs/workspace.dart';
@@ -19,20 +20,34 @@ import 'package:harness/widgets/terminal_panel.dart';
import 'package:harness/ws/local_cli_discovery.dart';
import '../test/super_tab_launch_test.dart'
- show SuperTabFixtureConnection, SuperTabLaunchFixture, tabId;
+ show SuperTabFixtureConnection, tabId;
+import '../test/support/super_tab_devices_fixture.dart';
import '../test/super_tab_route_test.dart' show routeRow, decision;
import '../test/support/super_tab_fixture.dart'
show projectFixture, conversationFixture;
+import 'flutter_test_config.dart';
/// A real Flutter/macOS surface with in-memory accounts and native protocol
/// fixtures. It never opens a production daemon, account, harness or database.
void main() {
if (!kUnderTest) throw StateError('Requires FLUTTER_TEST=1');
- final binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized()
+ final binding = ensureNativeTestBinding()
..framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.onlyPumps;
testWidgets(
'native Swarm keeps group context, people and terminal in one workspace',
(tester) async {
+ // FLUTTER_TEST makes Flutter's debug default Android, even on a real
+ // macOS window. This native fixture must exercise the desktop guard.
+ expect(defaultTargetPlatform, TargetPlatform.macOS);
+ final semantics = binding.ensureSemantics();
+ var semanticsDisposed = false;
+ void disposeSemantics() {
+ if (semanticsDisposed) return;
+ semanticsDisposed = true;
+ semantics.dispose();
+ }
+
+ addTearDown(disposeSemantics);
debugPrint('Swarm fixture: initialize window');
await windowManager.ensureInitialized().timeout(
const Duration(seconds: 10),
@@ -40,6 +55,7 @@ void main() {
await windowManager
.setSize(const Size(1280, 800))
.timeout(const Duration(seconds: 10));
+ await windowManager.setTitle('Swarm review — test data');
// macOS stops delivering frames to a fully occluded native test window.
// Keep only this isolated fixture above other running Harness builds.
await windowManager.setAlwaysOnTop(true);
@@ -47,7 +63,8 @@ void main() {
await windowManager.show().timeout(const Duration(seconds: 10));
await windowManager.focus().timeout(const Duration(seconds: 10));
debugPrint('Swarm fixture: create lead');
- final f = SuperTabLaunchFixture();
+ final f = superTabDevicesFixture();
+ (f.connection as SuperTabDevicesConnection).hasDevice = true;
f.connection.nativeName = 'hi';
f.connection.nativeSurface = true;
f.app.machineStates['m']!
@@ -252,7 +269,11 @@ void main() {
listenable: f.app,
builder: (context, _) => SuperTabWorkspace(
app: f.app,
- canvas: PaneGrid(notifier: f.app, swarmMode: true),
+ canvas: PaneGrid(
+ notifier: f.app,
+ swarmMode: true,
+ devicesViewer: (_) => DevicesTab(notifier: f.app),
+ ),
onAddAgent: (_) {},
onNewProject: () {},
),
@@ -286,71 +307,21 @@ void main() {
expect(find.text('CHATS'), findsNothing);
expect(find.text('New group'), findsNothing);
expect(find.byTooltip('New project'), findsOneWidget);
- // Left sidebar: both Projects and Machines groups start open, one line a machine: its name, its Claude and
- // Codex allowances and its agents, never its owner, and the offline machine under its closed disclosure.
- // Both Studio Macs are online rows. A busy one's name may be shortened to
- // keep its allowance on the line; it then carries its whole name on hover.
- for (final id in ['m', 'm-twin']) {
- final row = find.byKey(ValueKey('super-machine-$id'));
- expect(row, findsOneWidget, reason: id);
- final shown = tester
- .widget<RichText>(
- find.descendant(of: row, matching: find.byType(RichText)).first,
- )
- .text
- .toPlainText();
- expect(
- shown == 'Studio Mac' ||
- (shown.endsWith('…') &&
- 'Studio Mac'.startsWith(
- shown.substring(0, shown.length - 1),
- ) &&
- find
- .descendant(
- of: row,
- matching: find.byTooltip('Studio Mac'),
- )
- .evaluate()
- .isNotEmpty),
- isTrue,
- reason: '$id shows "$shown"',
- );
- // Never its owner.
- for (final who in ['owner', 'person0']) {
- expect(
- find.descendant(of: row, matching: find.textContaining(who)),
- findsNothing,
- reason: '$id names $who',
- );
- }
- }
- // Claude's chip always shows here; Codex's is the first to give way when the sidebar is narrow.
- Finder chip(String engine, String figure) => find.descendant(
- of: find.byKey(ValueKey('super-machine-allowance-m-$engine')),
- matching: find.text(figure),
- );
- expect(chip('claude', '50%'), findsOneWidget);
- if (find
- .byKey(const ValueKey('super-machine-allowance-m-codex'))
- .evaluate()
- .isNotEmpty) {
- expect(chip('codex', '88%'), findsOneWidget);
- // The Codex-only machine's figure lines up with Studio Mac's.
- double figureLeft(String id) => tester
- .getTopLeft(find.byKey(ValueKey('super-machine-figure-$id-codex')))
- .dx;
- expect(figureLeft('m-codex'), closeTo(figureLeft('m'), .01));
+ expect(find.byKey(const ValueKey('super-new-project')), findsOneWidget);
+ for (final id in ['m', 'm-twin', 'm-old']) {
+ expect(find.byKey(ValueKey('super-machine-$id')), findsOneWidget);
}
+ expect(find.text('Offline · 1'), findsNothing);
+ await shot('sidebar-groups');
+ await tester.tap(find.byKey(const ValueKey('super-machine-toggle-m')));
+ await tester.pumpAndSettle();
expect(
- find.byKey(const ValueKey('super-machine-figure-m-codex-claude')),
- findsNothing,
+ find.byKey(const ValueKey('super-machine-allowance-m-claude')),
+ findsOneWidget,
);
- expect(find.text('Offline · 1'), findsOneWidget);
- expect(find.byKey(const ValueKey('super-machine-m-old')), findsNothing);
- expect(find.textContaining('CPU'), findsNothing);
- await shot('sidebar-groups');
- debugPrint(
- 'Swarm fixture: open the tree: a workgroup and the offline machines',
+ expect(
+ find.byKey(const ValueKey('super-machine-allowance-m-codex')),
+ findsOneWidget,
);
final leadWasOpen = c!.expandedProjects.contains('lead');
if (!leadWasOpen) {
@@ -358,11 +329,8 @@ void main() {
find.byKey(const ValueKey('super-project-expand-lead')),
);
}
- await tester.tap(find.byKey(const ValueKey('super-machines-offline')));
await tester.pumpAndSettle();
expect(find.text('#20 Sidebar polish'), findsOneWidget);
- expect(find.byKey(const ValueKey('super-machine-m-old')), findsOneWidget);
- // Each level one step further in than the one above it.
double textX(String row, String label) => tester
.getTopLeft(
find.descendant(
@@ -373,15 +341,22 @@ void main() {
.dx;
expect(
textX('super-group-polish', '#20 Sidebar polish'),
- greaterThan(textX('super-group-lead', 'Lamp OS')),
+ closeTo(textX('super-group-lead', 'Lamp OS'), .01),
);
await shot('sidebar-tree');
+ // Clicking the label itself collapses the whole section.
+ await tester.tap(find.text('Machines'));
+ await tester.pumpAndSettle();
+ expect(find.byKey(const ValueKey('super-machine-m')), findsNothing);
+ await tester.tap(find.text('Machines'));
+ await tester.pumpAndSettle();
+ expect(find.byKey(const ValueKey('super-machine-m')), findsOneWidget);
+ await tester.tap(find.byKey(const ValueKey('super-machine-toggle-m')));
if (!leadWasOpen) {
await tester.tap(
find.byKey(const ValueKey('super-project-expand-lead')),
);
}
- await tester.tap(find.byKey(const ValueKey('super-machines-offline')));
await tester.pumpAndSettle();
debugPrint('Swarm fixture: empty project disclosure');
await tester.tap(
@@ -397,18 +372,34 @@ void main() {
final swarmId = f.app.activeSwarmId;
debugPrint('Swarm fixture: open Devices');
await tester.tap(find.byKey(const ValueKey('super-your-devices')));
- // This fixture reserves the utility's conversation pane without a machine.
- // Assert navigation while that pane waits for a connection instead of
- // waiting for its indeterminate progress animation to settle.
- await tester
- .pump(const Duration(milliseconds: 100))
- .timeout(const Duration(seconds: 10));
+ // Attachment is scheduled after the navigation frame. Wait for the
+ // actual viewer, rather than assuming a single native pump mounted it.
+ for (
+ var i = 0;
+ i < 60 && find.byType(DevicesScreen).evaluate().isEmpty;
+ i++
+ ) {
+ await tester.pump(const Duration(milliseconds: 50));
+ }
debugPrint('Swarm fixture: Devices frame painted');
- expect(f.app.activeSwarm.isDevices, isTrue);
- expect(f.app.activeSwarm.panes.first.isDevices, isTrue);
- expect(f.app.activeSwarm.panes.last.isViewer, isFalse);
+ expect(f.app.activeSwarm.isSuperTab, isTrue);
+ expect(f.app.activeSwarmId, swarmId);
+ expect(c.devicesSelected, isTrue);
+ expect(f.app.activeSwarm.panes, hasLength(1));
+ expect(f.app.activeSwarm.panes.single.isDevices, isTrue);
+ expect(find.text('Devices chat'), findsNothing);
expect(f.app.takeMachinesRequest(), isNull);
- f.app.selectSwarm(swarmId);
+ expect(find.byType(DevicesScreen), findsOneWidget);
+ for (
+ var i = 0;
+ i < 60 && find.text('Brightness').evaluate().isEmpty;
+ i++
+ ) {
+ await tester.pump(const Duration(milliseconds: 50));
+ }
+ expect(find.text('Brightness'), findsOneWidget);
+ await shot('embedded-devices');
+ await tester.tap(find.byKey(const ValueKey('super-group-lead')));
await tester.pumpAndSettle();
debugPrint('Swarm fixture: returned from Devices');
await shot('conversation');
@@ -497,11 +488,22 @@ void main() {
await tester.tap(
find.byKey(ValueKey('super-member-${c.snapshot!.agents.single.id}')),
);
+ await tester.pump(const Duration(milliseconds: 250));
+ await tester.tap(find.text('Open terminal'));
debugPrint('Swarm fixture: terminal requested');
for (var i = 0; i < 30 && f.app.activeSwarm.panes.isEmpty; i++) {
await tester.pump(const Duration(milliseconds: 50));
}
- expect(f.app.activeSwarm.panes, hasLength(1));
+ await shot('terminal-requested');
+ expect(
+ f.app.activeSwarm.panes,
+ hasLength(1),
+ reason:
+ 'Selected ${c.selectedId}; Devices ${c.devicesSelected}; '
+ 'terminals ${c.terminalAgents(c.selectedId).map((a) => a.id).toList()}; '
+ 'groups ${c.snapshot!.conversations.map((g) => '${g.id}:${g.agentIds}').toList()}; '
+ 'visible ${tester.widgetList<Text>(find.byType(Text)).map((t) => t.data).whereType<String>().join(" | ")}',
+ );
final machine = f.app.machineStates['m']!;
debugPrint(
'Swarm fixture: native prerequisites '
@@ -555,16 +557,40 @@ void main() {
await shot('terminal-resized');
final focusRequest = f.app.paneFocusRequest;
final divider = find.byKey(const ValueKey('super-resize-right'));
- tester
+ final resizeFocus = tester
.widget<Focus>(
find.descendant(of: divider, matching: find.byType(Focus)),
)
- .focusNode!
- .requestFocus();
+ .focusNode!;
+ resizeFocus.requestFocus();
await tester.pump(const Duration(milliseconds: 50));
+ FocusManager.instance.applyFocusChangesIfNeeded();
+ expect(
+ resizeFocus.hasPrimaryFocus,
+ isTrue,
+ reason:
+ 'Keyboard resize needs focus before Escape: '
+ '${FocusManager.instance.primaryFocus}',
+ );
+ // A native window also receives the reviewer's physical modifier keys.
+ // Keep this synthetic Escape assertion independent of that host input.
+ final keyboard = HardwareKeyboard.instance;
+ for (final physical in keyboard.physicalKeysPressed.toList()) {
+ final logical = keyboard.lookUpLayout(physical);
+ if (logical != null) {
+ await tester.sendKeyUpEvent(logical, physicalKey: physical);
+ }
+ }
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
await tester.pump(const Duration(milliseconds: 100));
- expect(f.app.paneFocusRequest, focusRequest + 1);
+ expect(
+ f.app.paneFocusRequest,
+ focusRequest + 1,
+ reason:
+ 'Focus after Escape: ${FocusManager.instance.primaryFocus}; '
+ 'pressed keys: ${HardwareKeyboard.instance.logicalKeysPressed}; '
+ 'focused pane: ${f.app.focusedPaneId}',
+ );
expect(f.app.activeSwarm.panes.single.session, same(liveSession));
expect(find.byType(PaneGrid), findsOneWidget);
expect(
@@ -609,6 +635,8 @@ void main() {
await tester.tap(
find.byKey(ValueKey('super-member-${c.snapshot!.agents.single.id}')),
);
+ await tester.pump(const Duration(milliseconds: 250));
+ await tester.tap(find.text('Open terminal'));
for (var i = 0; i < 40 && find.text('Resume').evaluate().isEmpty; i++) {
await tester.pump(const Duration(milliseconds: 50));
}
@@ -691,6 +719,8 @@ void main() {
expect(tester.takeException(), isNull);
await shot('group-terminals');
await tester.tap(find.byKey(const ValueKey('super-member-lead-agent')));
+ await tester.pump(const Duration(milliseconds: 250));
+ await tester.tap(find.text('Open terminal'));
await tester.pump(const Duration(milliseconds: 200));
expect(
find.byKey(const ValueKey('super-agent-group-open')),
@@ -701,11 +731,50 @@ void main() {
await tester.pump(const Duration(milliseconds: 200));
expect(c.selectedId, 'offline');
+ // Optional manual inspection of this same isolated native fixture. The
+ // file is supplied by the reviewer; no production account or daemon is
+ // connected, and the automated acceptance above has already completed.
+ final reviewDone =
+ const String.fromEnvironment('SUPER_TAB_NATIVE_REVIEW_DONE')
+ .isNotEmpty
+ ? const String.fromEnvironment('SUPER_TAB_NATIVE_REVIEW_DONE')
+ : Platform.environment['SUPER_TAB_NATIVE_REVIEW_DONE'];
+ if (reviewDone != null) {
+ c.select('lead');
+ c.selectTerminal('lead', null);
+ await tester.pump(const Duration(milliseconds: 200));
+ binding.framePolicy =
+ LiveTestWidgetsFlutterBindingFramePolicy.fullyLive;
+ debugPrint('Swarm fixture: ready for manual review');
+ await tester.runAsync(() async {
+ await File('$reviewDone.ready').writeAsString('ready');
+ final deadline = DateTime.now().add(const Duration(minutes: 10));
+ while (!await File(reviewDone).exists() &&
+ DateTime.now().isBefore(deadline)) {
+ await Future<void>.delayed(const Duration(milliseconds: 200));
+ }
+ });
+ binding.framePolicy =
+ LiveTestWidgetsFlutterBindingFramePolicy.onlyPumps;
+ }
+
await tester.pumpWidget(const SizedBox());
await c.flush();
f.app.superTabs.dispose();
await tester.pump();
+ // Flutter verifies handles before addTearDown runs on the success path.
+ disposeSemantics();
},
- timeout: const Timeout(Duration(minutes: 2)),
+ variant: const TargetPlatformVariant({TargetPlatform.macOS}),
+ timeout: Timeout(
+ Duration(
+ minutes:
+ Platform.environment['SUPER_TAB_NATIVE_REVIEW_DONE'] != null ||
+ const String.fromEnvironment('SUPER_TAB_NATIVE_REVIEW_DONE')
+ .isNotEmpty
+ ? 12
+ : 2,
+ ),
+ ),
);
}
diff --git a/desktop/lib/core/connected_semantics.dart b/desktop/lib/core/connected_semantics.dart
index 3857b5103..7be356ecb 100644
--- a/desktop/lib/core/connected_semantics.dart
+++ b/desktop/lib/core/connected_semantics.dart
@@ -20,7 +20,52 @@ import '../logging/app_log.dart';
mixin ConnectedSemanticsBinding on RendererBinding {
bool _reportedDisconnectedSemantics = false;
final _updates = <int, _NodeUpdate>{};
+ final _customActions = <int, void Function(ui.SemanticsUpdateBuilder)>{};
final _previousConnected = <int>{};
+ bool _nativeReplayScheduled = false;
+
+ bool get _guardsPlatform =>
+ !kIsWeb &&
+ (defaultTargetPlatform == TargetPlatform.macOS ||
+ defaultTargetPlatform == TargetPlatform.windows);
+
+ @override
+ void initInstances() {
+ super.initInstances();
+ final frameworkCallback = platformDispatcher.onSemanticsEnabledChanged;
+ platformDispatcher.onSemanticsEnabledChanged = () {
+ // AppKit replaces its AX bridge on disable/enable. A debugger or test
+ // can retain a framework handle, so its clean tree outlives that bridge.
+ // The new native tree needs a root and all children, not a leaf delta.
+ if (_guardsPlatform && platformDispatcher.semanticsEnabled) {
+ _previousConnected.clear();
+ }
+ frameworkCallback?.call();
+ if (!_guardsPlatform ||
+ !platformDispatcher.semanticsEnabled ||
+ _nativeReplayScheduled) {
+ return;
+ }
+ _nativeReplayScheduled = true;
+ addPostFrameCallback((_) {
+ _nativeReplayScheduled = false;
+ if (!_guardsPlatform || !platformDispatcher.semanticsEnabled) return;
+ // Harness has one FlutterView per engine. Do not send the shared
+ // root-0 cache to several views if that architecture changes.
+ final view = renderViews.singleOrNull;
+ if (view == null ||
+ !view.attached ||
+ view.owner?.semanticsOwner?.rootSemanticsNode == null) {
+ return;
+ }
+ // An unchanged frame does not invoke SemanticsOwner's builder. Replay
+ // explicitly after layout so even a completely clean tree is restored.
+ _previousConnected.clear();
+ view.updateSemantics(createSemanticsUpdateBuilder().build());
+ });
+ ensureVisualUpdate();
+ };
+ }
@protected
ui.SemanticsUpdateBuilder createPlatformSemanticsUpdateBuilder() =>
@@ -29,9 +74,7 @@ mixin ConnectedSemanticsBinding on RendererBinding {
@override
ui.SemanticsUpdateBuilder createSemanticsUpdateBuilder() {
final delegate = createPlatformSemanticsUpdateBuilder();
- if (kIsWeb ||
- (defaultTargetPlatform != TargetPlatform.macOS &&
- defaultTargetPlatform != TargetPlatform.windows)) {
+ if (!_guardsPlatform) {
return delegate;
}
final connected = <int>{};
@@ -83,6 +126,7 @@ mixin ConnectedSemanticsBinding on RendererBinding {
delegate,
connected: connected,
updates: _updates,
+ customActions: _customActions,
previousConnected: _previousConnected,
onDiscard: (id) {
if (_reportedDisconnectedSemantics) return;
@@ -101,18 +145,23 @@ mixin ConnectedSemanticsBinding on RendererBinding {
class HarnessWidgetsBinding extends WidgetsFlutterBinding
with ConnectedSemanticsBinding {}
-typedef _NodeUpdate = void Function(ui.SemanticsUpdateBuilder, Set<int>);
+typedef _NodeUpdate = ({
+ void Function(ui.SemanticsUpdateBuilder, Set<int>) write,
+ Set<int> actions,
+});
class _ConnectedSemanticsUpdateBuilder implements ui.SemanticsUpdateBuilder {
_ConnectedSemanticsUpdateBuilder(
this._delegate, {
required this.connected,
required this.updates,
+ required this.customActions,
required this.previousConnected,
this.onDiscard,
});
final Map<int, _NodeUpdate> updates;
+ final Map<int, void Function(ui.SemanticsUpdateBuilder)> customActions;
final Set<int> previousConnected;
final _changed = <int>{};
final ui.SemanticsUpdateBuilder _delegate;
@@ -193,56 +242,59 @@ class _ConnectedSemanticsUpdateBuilder implements ui.SemanticsUpdateBuilder {
hintAttributes = List.of(hintAttributes);
controlsNodes = controlsNodes == null ? null : List.of(controlsNodes);
_changed.add(id);
- updates[id] = (delegate, currentConnected) => delegate.updateNode(
- id: id,
- flags: flags,
- actions: actions,
- maxValueLength: maxValueLength,
- currentValueLength: currentValueLength,
- textSelectionBase: textSelectionBase,
- textSelectionExtent: textSelectionExtent,
- platformViewId: platformViewId,
- scrollChildren: scrollChildren,
- scrollIndex: scrollIndex,
- traversalParent: traversalParent,
- scrollPosition: scrollPosition,
- scrollExtentMax: scrollExtentMax,
- scrollExtentMin: scrollExtentMin,
- rect: rect,
- identifier: identifier,
- label: label,
- labelAttributes: labelAttributes,
- value: value,
- valueAttributes: valueAttributes,
- increasedValue: increasedValue,
- increasedValueAttributes: increasedValueAttributes,
- decreasedValue: decreasedValue,
- decreasedValueAttributes: decreasedValueAttributes,
- hint: hint,
- hintAttributes: hintAttributes,
- tooltip: tooltip,
- textDirection: textDirection,
- transform: transform,
- hitTestTransform: hitTestTransform,
- childrenInTraversalOrder: _children(
- childrenInTraversalOrder,
- currentConnected,
- ),
- childrenInHitTestOrder: _children(
- childrenInHitTestOrder,
- currentConnected,
+ updates[id] = (
+ actions: additionalActions.toSet(),
+ write: (delegate, currentConnected) => delegate.updateNode(
+ id: id,
+ flags: flags,
+ actions: actions,
+ maxValueLength: maxValueLength,
+ currentValueLength: currentValueLength,
+ textSelectionBase: textSelectionBase,
+ textSelectionExtent: textSelectionExtent,
+ platformViewId: platformViewId,
+ scrollChildren: scrollChildren,
+ scrollIndex: scrollIndex,
+ traversalParent: traversalParent,
+ scrollPosition: scrollPosition,
+ scrollExtentMax: scrollExtentMax,
+ scrollExtentMin: scrollExtentMin,
+ rect: rect,
+ identifier: identifier,
+ label: label,
+ labelAttributes: labelAttributes,
+ value: value,
+ valueAttributes: valueAttributes,
+ increasedValue: increasedValue,
+ increasedValueAttributes: increasedValueAttributes,
+ decreasedValue: decreasedValue,
+ decreasedValueAttributes: decreasedValueAttributes,
+ hint: hint,
+ hintAttributes: hintAttributes,
+ tooltip: tooltip,
+ textDirection: textDirection,
+ transform: transform,
+ hitTestTransform: hitTestTransform,
+ childrenInTraversalOrder: _children(
+ childrenInTraversalOrder,
+ currentConnected,
+ ),
+ childrenInHitTestOrder: _children(
+ childrenInHitTestOrder,
+ currentConnected,
+ ),
+ additionalActions: additionalActions,
+ headingLevel: headingLevel,
+ linkUrl: linkUrl ?? '',
+ role: role,
+ controlsNodes: controlsNodes,
+ validationResult: validationResult,
+ hitTestBehavior: hitTestBehavior,
+ inputType: inputType,
+ locale: locale,
+ minValue: minValue,
+ maxValue: maxValue,
),
- additionalActions: additionalActions,
- headingLevel: headingLevel,
- linkUrl: linkUrl ?? '',
- role: role,
- controlsNodes: controlsNodes,
- validationResult: validationResult,
- hitTestBehavior: hitTestBehavior,
- inputType: inputType,
- locale: locale,
- minValue: minValue,
- maxValue: maxValue,
);
}
@@ -252,12 +304,17 @@ class _ConnectedSemanticsUpdateBuilder implements ui.SemanticsUpdateBuilder {
String? label,
String? hint,
int overrideId = -1,
- }) => _delegate.updateCustomAction(
- id: id,
- label: label,
- hint: hint,
- overrideId: overrideId,
- );
+ }) {
+ void write(ui.SemanticsUpdateBuilder delegate) =>
+ delegate.updateCustomAction(
+ id: id,
+ label: label,
+ hint: hint,
+ overrideId: overrideId,
+ );
+ customActions[id] = write;
+ write(_delegate);
+ }
@override
ui.SemanticsUpdate build() {
@@ -267,8 +324,19 @@ class _ConnectedSemanticsUpdateBuilder implements ui.SemanticsUpdateBuilder {
..._changed,
...connected.difference(previousConnected),
};
+ final retainedActions = updates.values
+ .expand((node) => node.actions)
+ .toSet();
+ customActions.removeWhere((id, _) => !retainedActions.contains(id));
+ final replayedActions = <int>{};
for (final id in pending) {
- if (connected.contains(id)) updates[id]?.call(_delegate, connected);
+ if (!connected.contains(id)) continue;
+ final node = updates[id];
+ if (node == null) continue;
+ for (final action in node.actions) {
+ if (replayedActions.add(action)) customActions[action]?.call(_delegate);
+ }
+ node.write(_delegate, connected);
}
previousConnected
..clear()
diff --git a/desktop/lib/devices/devices_harness_controller.dart b/desktop/lib/devices/devices_harness_controller.dart
index 0afaca5b8..cf7259459 100644
--- a/desktop/lib/devices/devices_harness_controller.dart
+++ b/desktop/lib/devices/devices_harness_controller.dart
@@ -16,11 +16,37 @@ class DevicesHarnessController extends ChangeNotifier {
AgentCreationAttempt? _creation;
ProjectFolderRequest? _folder;
bool _disposed = false;
+ String? _workspaceId;
+ String? _openingAccount;
String? error;
bool get opening => _opening != null;
- Future<void> open() {
- if (_opening != null) return _opening!;
+ Future<void> open({String? swarmId}) {
+ final workspaceId =
+ swarmId ?? app.swarms.where((tab) => tab.isDevices).firstOrNull?.id;
+ // Swarm's Your devices is a dashboard only. Even a stale retry from its
+ // former chat pane must not probe, create, resume or attach an agent.
+ if (!app.swarms.any((tab) => tab.id == workspaceId && tab.isDevices)) {
+ return Future.value();
+ }
+ final account = app.currentUser?.id;
+ if (_opening case final pending?) {
+ if (_workspaceId == workspaceId && _openingAccount == account) {
+ return pending;
+ }
+ // Finish the existing creation receipt before handling a new account or
+ // destination. Its result must never be retargeted halfway through.
+ return pending.then<void>((_) async {
+ if (_disposed ||
+ app.currentUser?.id != account ||
+ !app.swarms.any((tab) => tab.id == workspaceId && tab.isDevices)) {
+ return;
+ }
+ await open(swarmId: workspaceId);
+ });
+ }
+ _workspaceId = workspaceId;
+ _openingAccount = account;
error = null;
_opening = _open().whenComplete(() {
_opening = null;
@@ -35,10 +61,10 @@ class DevicesHarnessController extends ChangeNotifier {
app.devicesEnabled &&
app.currentUser?.id == _account &&
identical(app.stateOf(owner.machine.machineId), owner) &&
- app.swarms.any((tab) => tab.isDevices);
+ app.swarms.any((tab) => tab.id == _workspaceId && tab.isDevices);
Future<void> _open() async {
- if (!app.devicesEnabled) return;
+ if (!app.devicesEnabled || _workspaceId == null) return;
final owner = app.machineStates.values
.where((machine) => machine.isLocalMachine && !machine.machine.isShared)
.firstOrNull;
@@ -131,7 +157,7 @@ class DevicesHarnessController extends ChangeNotifier {
}
}
if (!_current(owner)) return;
- await app.showDevicesTerminal(machineId, agent.id);
+ await app.showDevicesTerminal(machineId, agent.id, swarmId: _workspaceId);
} catch (_) {
if (_current(owner)) error = 'Couldn’t open Devices. Update Harness on this computer and try again.';
}
diff --git a/desktop/lib/screens/swarm_screen.dart b/desktop/lib/screens/swarm_screen.dart
index f3a6325e5..a08b137be 100644
--- a/desktop/lib/screens/swarm_screen.dart
+++ b/desktop/lib/screens/swarm_screen.dart
@@ -4608,7 +4608,8 @@ class _SwarmScreenState extends State<SwarmScreen> {
String? _devicesAttemptedKey;
Widget _devicesViewer(BuildContext context) {
- final key = '${app.currentUser?.id}:${app.activeSwarmId}';
+ final viewerId = app.panes.where((pane) => pane.isDevices).firstOrNull?.id;
+ final key = '${app.currentUser?.id}:${app.activeSwarmId}:$viewerId';
if (app.activeSwarm.isDevices &&
app.devicesEnabled &&
_devicesAttemptedKey != key) {
@@ -4617,8 +4618,9 @@ class _SwarmScreenState extends State<SwarmScreen> {
if (mounted &&
app.activeSwarm.isDevices &&
app.devicesEnabled &&
- key == '${app.currentUser?.id}:${app.activeSwarmId}') {
- unawaited(_devicesHarness.open());
+ key ==
+ '${app.currentUser?.id}:${app.activeSwarmId}:${app.panes.where((pane) => pane.isDevices).firstOrNull?.id}') {
+ unawaited(_devicesHarness.open(swarmId: app.activeSwarmId));
}
});
}
@@ -4635,7 +4637,8 @@ class _SwarmScreenState extends State<SwarmScreen> {
name: 'Devices',
opening: _devicesHarness.opening,
error: _devicesHarness.error,
- onRetry: () => unawaited(_devicesHarness.open()),
+ onRetry: () =>
+ unawaited(_devicesHarness.open(swarmId: app.activeSwarmId)),
),
);
@@ -4656,7 +4659,7 @@ class _SwarmScreenState extends State<SwarmScreen> {
_closeSearch(restoreFocus: false);
dismissTransientMenus();
app.openDevices();
- unawaited(_devicesHarness.open());
+ if (app.activeSwarm.isDevices) unawaited(_devicesHarness.open());
}
Widget _devicesButton(BuildContext context) => WorkspaceStoreButton(
diff --git a/desktop/lib/state/app_state.dart b/desktop/lib/state/app_state.dart
index 8adab1ebd..7d7103c18 100644
--- a/desktop/lib/state/app_state.dart
+++ b/desktop/lib/state/app_state.dart
@@ -2862,9 +2862,38 @@ class AppNotifier extends ChangeNotifier {
}
}
- /// One utility tab for physical devices.
+ /// Devices stays inside an active Swarm; ordinary workspaces keep their
+ /// existing utility tab. Opening it never changes the Swarm's membership.
void openDevices() {
if (!devicesEnabled) return;
+ final swarm = activeSwarm;
+ if (swarm.isSuperTab && swarm.superTabId != null) {
+ final account = currentUser?.id;
+ final controller = superTabs.peek(swarm.superTabId!);
+ if (controller != null) {
+ controller.selectDevices();
+ } else {
+ unawaited(
+ superTabs
+ .open(swarm.superTabId!)
+ .then((controller) {
+ if (!_disposed &&
+ currentUser?.id == account &&
+ identical(activeSwarm, swarm)) {
+ controller.selectDevices();
+ }
+ })
+ .catchError((Object error) {
+ if (!_disposed &&
+ currentUser?.id == account &&
+ identical(activeSwarm, swarm)) {
+ debugPrint('Could not open Devices in the Swarm: $error');
+ }
+ }),
+ );
+ }
+ return;
+ }
final existing = swarms.where((s) => s.isDevices).firstOrNull;
if (existing != null) {
_ensureDevicesViewer(existing);
@@ -2908,6 +2937,23 @@ class AppNotifier extends ChangeNotifier {
tab.panes.insert(0, pane);
tab.focusedPaneId ??= pane.id;
}
+ if (tab.isSuperTab) {
+ // Your devices is a dashboard in the Swarm, without its own agent.
+ // Clear ownership left by an earlier embedded conversation so closing
+ // that old agent elsewhere cannot remove this independent viewer.
+ final viewer = tab.panes.firstWhere((pane) => pane.isDevices)
+ ..machineId = ''
+ ..ownerAgentId = null
+ ..fixedWidth = null;
+ tab
+ ..focusedPaneId = viewer.id
+ ..previousPaneId = null
+ ..zoomedPaneId = null
+ ..arranged = null
+ ..arrangedKey = null
+ ..arrangedMinimum = null;
+ return;
+ }
// Reserve the conversation before any network or launch work. Setup and
// failures belong in this same right-hand pane, never above the dashboard.
if (!tab.panes.any((pane) => !pane.isViewer)) {
@@ -2919,9 +2965,33 @@ class AppNotifier extends ChangeNotifier {
);
}
- Future<void> showDevicesTerminal(String machineId, String agentId) async {
+ bool isDevicesWorkspace(Swarm tab) =>
+ tab.isDevices ||
+ (tab.isSuperTab &&
+ tab.superTabId != null &&
+ superTabs.peek(tab.superTabId!)?.devicesSelected == true);
+
+ /// Called only after the Swarm has detached its previous group's views.
+ void prepareSuperTabDevices(String swarmId) {
+ final tab = swarms.where((tab) => tab.id == swarmId).firstOrNull;
+ if (tab == null || !tab.isSuperTab || !isDevicesWorkspace(tab)) return;
+ _ensureDevicesViewer(tab);
+ notifyListeners();
+ }
+
+ Future<void> showDevicesTerminal(
+ String machineId,
+ String agentId, {
+ String? swarmId,
+ }) async {
if (!devicesEnabled) return;
- final tab = swarms.where((tab) => tab.isDevices).firstOrNull;
+ final tab = swarms
+ .where(
+ (tab) =>
+ (swarmId == null ? tab.isDevices : tab.id == swarmId) &&
+ tab.isDevices,
+ )
+ .firstOrNull;
if (tab == null) return;
_ensureDevicesViewer(tab);
final viewer = tab.panes.firstWhere((pane) => pane.isDevices);
diff --git a/desktop/lib/super_tabs/agent_details.dart b/desktop/lib/super_tabs/agent_details.dart
index beae8b6fd..b6cd8b8dd 100644
--- a/desktop/lib/super_tabs/agent_details.dart
+++ b/desktop/lib/super_tabs/agent_details.dart
@@ -28,7 +28,10 @@ class SuperTabAgentInfo {
controller,
app,
agent,
- activity,
+ activity ??
+ (app == null
+ ? null
+ : harnessActivity(app, agent.machineId, agent.harnessId)),
app
?.stateOf(agent.machineId)
?.agents
@@ -39,7 +42,11 @@ class SuperTabAgentInfo {
(g) =>
!g.archived &&
g.assignment?['agentId'] == agent.id &&
- !const {'done', 'stopped'}.contains(g.assignment?['status']),
+ !const {
+ 'done',
+ 'stopped',
+ 'cancelled',
+ }.contains(g.assignment?['status']),
)
.firstOrNull,
);
@@ -120,7 +127,11 @@ class SuperTabAgentInfo {
'blocked' => 'Stuck on "${group.title}"',
'review' => 'Waiting for review on "${group.title}"',
'reconciling' => 'Checking "${group.title}"',
- _ => 'Working on "${group.title}"',
+ 'working' when activity == HarnessActivity.working =>
+ 'Working on "${group.title}"',
+ // An assignment can outlive a native turn or connection. Keep the
+ // known task as context without claiming the agent is still working.
+ _ => 'Assigned to "${group.title}"',
};
}
return switch (activity) {
diff --git a/desktop/lib/super_tabs/controller.dart b/desktop/lib/super_tabs/controller.dart
index 494af83e1..3ea16df33 100644
--- a/desktop/lib/super_tabs/controller.dart
+++ b/desktop/lib/super_tabs/controller.dart
@@ -49,6 +49,10 @@ class SuperTabController extends ChangeNotifier {
expandedProjects.addAll(
(initial['expandedProjects'] as List? ?? const []).whereType<String>(),
);
+ expandedMachines.addAll(
+ (initial['expandedMachines'] as List? ?? const []).whereType<String>(),
+ );
+ devicesSelected = initial['devicesSelected'] == true;
projectsGroupOpen = initial['projectsGroupOpen'] as bool? ?? true;
machinesGroupOpen = initial['machinesGroupOpen'] as bool? ?? true;
offlineMachinesOpen = initial['offlineMachinesOpen'] as bool? ?? false;
@@ -149,8 +153,27 @@ class SuperTabController extends ChangeNotifier {
final _before = <String, int?>{};
final _reading = <String>{};
final expandedProjects = <String>{};
+ final expandedMachines = <String>{};
+ bool devicesSelected = false;
bool projectsGroupOpen = true, machinesGroupOpen = true;
+ bool isMachineExpanded(String id) => expandedMachines.contains(id);
+
+ void toggleMachineExpanded(String id) {
+ if (!expandedMachines.remove(id)) expandedMachines.add(id);
+ _saveSoon();
+ _changed();
+ }
+
+ /// Devices is personal navigation inside this Swarm. The selected workgroup,
+ /// its draft and terminal choice stay available when the person returns.
+ void selectDevices() {
+ if (_disposed || accessRevoked || devicesSelected) return;
+ devicesSelected = true;
+ _saveSoon();
+ _changed();
+ }
+
/// Whether the Machines group's "Offline · N" disclosure is open; it starts closed.
bool offlineMachinesOpen = false;
@@ -232,7 +255,7 @@ class SuperTabController extends ChangeNotifier {
}
List<SuperTabAgent> terminalAgents(String conversationId) {
- if (accessRevoked) return const [];
+ if (accessRevoked || devicesSelected) return const [];
final id = _terminals[conversationId];
final group = snapshot?.conversation(conversationId);
if (id == null || group == null) return const [];
@@ -248,6 +271,7 @@ class SuperTabController extends ChangeNotifier {
return;
}
_terminals[conversationId] = '*';
+ devicesSelected = false;
_saveSoon();
_changed();
}
@@ -259,9 +283,10 @@ class SuperTabController extends ChangeNotifier {
true) {
return;
}
- if (_terminals[conversationId] == agentId) {
+ if (_terminals[conversationId] == agentId && !devicesSelected) {
return;
}
+ devicesSelected = false;
if (agentId == null) {
_terminals.remove(conversationId);
} else {
@@ -323,6 +348,7 @@ class SuperTabController extends ChangeNotifier {
void revokeAccess(String message) {
if (_disposed) return;
accessRevoked = true;
+ devicesSelected = false;
error = message;
snapshot = null;
_messages.clear();
@@ -335,6 +361,8 @@ class SuperTabController extends ChangeNotifier {
'accountId': accountId,
'selectedId': selectedId,
'expandedProjects': expandedProjects.toList(),
+ 'expandedMachines': expandedMachines.toList(),
+ 'devicesSelected': devicesSelected,
'projectsGroupOpen': projectsGroupOpen,
'machinesGroupOpen': machinesGroupOpen,
'offlineMachinesOpen': offlineMachinesOpen,
@@ -394,7 +422,11 @@ class SuperTabController extends ChangeNotifier {
Map.unmodifiable(_mentions[conversationId] ?? const {});
void select(String id) {
- if (snapshot?.conversation(id) == null || id == selectedId) return;
+ if (snapshot?.conversation(id) == null ||
+ (id == selectedId && !devicesSelected)) {
+ return;
+ }
+ devicesSelected = false;
if (!snapshot!.isProjectLead(id)) {
final group = snapshot!.conversation(id)!;
expandedProjects.add(group.projectId);
@@ -509,6 +541,7 @@ class SuperTabController extends ChangeNotifier {
failure is SuperTabFailure &&
const {'FORBIDDEN', 'NOT_FOUND'}.contains(failure.code)) {
accessRevoked = true;
+ devicesSelected = false;
snapshot = null;
_messages.clear();
_poll?.cancel();
diff --git a/desktop/lib/super_tabs/identity.dart b/desktop/lib/super_tabs/identity.dart
index 5a84f086c..5c5df3df9 100644
--- a/desktop/lib/super_tabs/identity.dart
+++ b/desktop/lib/super_tabs/identity.dart
@@ -44,6 +44,7 @@ class SuperTabAvatar extends StatelessWidget {
),
child: Text(
initial,
+ textScaler: TextScaler.noScaling,
style: DesktopChrome.control(
medium: true,
color: color,
diff --git a/desktop/lib/super_tabs/machines.dart b/desktop/lib/super_tabs/machines.dart
index 833236441..0bdd2c0d7 100644
--- a/desktop/lib/super_tabs/machines.dart
+++ b/desktop/lib/super_tabs/machines.dart
@@ -1,5 +1,4 @@
import 'dart:async';
-import 'dart:math' as math;
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
@@ -9,20 +8,26 @@ import '../core/models.dart';
import '../core/test_run.dart';
import '../shared/theme/app_icons.dart';
import '../shared/theme/app_theme.dart' as grid;
+import '../shared/theme/appearance_prefs_store.dart';
import '../shared/theme/status_line_style.dart';
import '../shared/widgets/app_dialog.dart';
import '../shared/widgets/app_icon_button.dart';
import '../shared/widgets/app_menu.dart';
import '../state/app_state.dart';
+import '../state/harness_activity.dart';
+import '../terminal/terminal_theme.dart';
+import '../terminal/terminal_theme_store.dart';
import '../usage/models_menu_controller.dart';
import '../widgets/desktop_chrome.dart';
import '../widgets/engine_identity.dart';
+import '../widgets/harness_activity_mark.dart';
import '../widgets/workspace_subscription_usage.dart';
+import 'agent_details.dart';
import 'controller.dart';
import 'dialog_scope.dart';
import 'identity.dart';
-import 'machine_status.dart';
import 'machine_details.dart';
+import 'machine_status.dart';
import 'model.dart';
import 'section_heading.dart';
@@ -62,20 +67,19 @@ class SuperTabMachines extends StatefulWidget {
this.readLocal,
this.collapsed = false,
this.onToggleCollapsed,
- this.onYourDevices,
+ this.onOpenAgent,
});
final SuperTabController controller;
final AppNotifier? app;
final bool embedded;
/// Whether the body below the heading is hidden. The heading itself, and
- /// its Your devices and Add machine actions, remain visible so the group
- /// stays reachable.
+ /// its Add machine action, remain visible so the group stays reachable.
final bool collapsed;
final VoidCallback? onToggleCollapsed;
- /// The heading's Your devices action, just before Add machine; absent when null.
- final VoidCallback? onYourDevices;
+ /// Opens an existing agent using the workspace's membership and account guards.
+ final ValueChanged<SuperTabAgent>? onOpenAgent;
final ValueChanged<SuperTabConversation> onAddAgent;
/// The clock the readings' ages are counted against.
@@ -354,9 +358,10 @@ class _MachinePickerState extends State<_MachinePicker> {
class _SuperTabMachinesState extends State<SuperTabMachines> {
final _samples = <String, (MachineResources, DateTime)>{};
+ String? _selectedMachineId;
- /// Machines whose sample in [_samples] was taken before the app last came back to the front: it is shown, dimmed,
- /// as "refreshing…" until the read that follows replaces it.
+ /// Samples from before foreground return stay cached, but their readings are
+ /// hidden behind the refreshing state until the next read answers.
final _awaiting = <String>{};
/// How many reads of the Swarm's state had been answered when the app came back to the front; the machines
@@ -412,8 +417,8 @@ class _SuperTabMachinesState extends State<SuperTabMachines> {
_revision++;
_timer?.cancel();
if (widget.app?.foreground.value == true) {
- // Back in front: what was read before stays on the screen, dimmed, as refreshing — it used to vanish and
- // come back a second later. The Swarm is read again at once, and so are this computer's readings.
+ // Keep machine identity stable while refreshing, without presenting the
+ // previous foreground session's readings as current capacity.
_awaiting.addAll(_samples.keys);
_swarmReadsAtReturn = c.stateReads;
unawaited(c.refresh());
@@ -929,7 +934,7 @@ class _SuperTabMachinesState extends State<SuperTabMachines> {
: _swarmReadsAtReturn != null && c.stateReads <= _swarmReadsAtReturn!,
connected: direct ? connected : null,
);
- // Every state but live or late reads old numbers: kept in the tooltip, never blanked, but not taken as now.
+ // Cached samples remain available to the refresh logic, but stale numbers are not presented as current.
final dim =
status == SuperTabMachineStatus.offline ||
status == SuperTabMachineStatus.unknown ||
@@ -1000,9 +1005,7 @@ class _SuperTabMachinesState extends State<SuperTabMachines> {
resourcePercent((100 - used).clamp(0, 100));
// Each engine with a known, unexpired allowance, Claude first. Offline or out of reach, an allowance is an
// old reading and no chip shows it as now.
- final allowances =
- status == SuperTabMachineStatus.offline ||
- status == SuperTabMachineStatus.unknown
+ final allowances = dim
? const <_Allowance>[]
: [
for (final engine in _chipEngines)
@@ -1041,14 +1044,7 @@ class _SuperTabMachinesState extends State<SuperTabMachines> {
owner: person,
contributor: contributor,
shared: shared,
- agents: [
- for (final agent in agents)
- (
- id: agent.id,
- name: c.snapshot!.agentName(agent.id),
- role: c.snapshot!.isLead(agent.id) ? 'Product Manager' : 'Engineer',
- ),
- ],
+ agents: agents,
status: status,
readingAt: readingAt,
arrived: age != null && age < const Duration(milliseconds: 1200),
@@ -1060,17 +1056,18 @@ class _SuperTabMachinesState extends State<SuperTabMachines> {
engines: allowed,
allowances: allowances,
// What the line leaves out, for hover, focus and a screen reader: whose machine it is and its hardware,
- // after its state when that is not online. Never an age. Old numbers are kept here, never blanked.
+ // after its state when that is not online. Never an age. Only current readings are included.
tip: [
?superTabMachineTip(status),
if (person != null) 'Owned by ${superTabPersonName(person.email)}',
if (paused) 'New work paused',
- if (value?.cpuPercent case final cpu?) 'CPU ${available(cpu)} free',
- if (value?.busiestGpu?.utilizationPercent case final gpu?)
- 'GPU ${available(gpu)} free',
- if (memoryFree != null)
+ if (!dim && value?.cpuPercent != null)
+ 'CPU ${available(value!.cpuPercent!)} free',
+ if (!dim && value?.busiestGpu?.utilizationPercent != null)
+ 'GPU ${available(value!.busiestGpu!.utilizationPercent!)} free',
+ if (!dim && memoryFree != null)
'RAM ${resourceBytes(memoryFree.toDouble())} free',
- if (diskFree != null) 'SSD ${resourceBytes(diskFree)} free',
+ if (!dim && diskFree != null) 'SSD ${resourceBytes(diskFree)} free',
].join(' · '),
);
}
@@ -1091,7 +1088,7 @@ class _SuperTabMachinesState extends State<SuperTabMachines> {
name: name,
owner: person?.email,
status: details,
- // The row's tooltip keeps old numbers, aged; the details do not present them as capacity to use.
+ // Details follow the same freshness rule as the row and its disclosure.
resources: dim ? null : value,
cwd: shared?['cwd'] as String?,
engines: allowed,
@@ -1141,119 +1138,241 @@ class _SuperTabMachinesState extends State<SuperTabMachines> {
);
}
- /// Where the trailing marks of a row center: on the heading's +, as the project rows' dots do.
- double get _anchor =>
- SuperTabSectionHeading.actionWidth / 2 + (widget.embedded ? 0 : 12);
-
- /// One machine on one line: its state's dot in the icon column, its name on the text column, its agents at
- /// the end. Everything else is in its tooltip and its details.
- Widget _machine(_MachineView v, _Columns columns, {int level = 1}) {
- final tipKey = _tips.putIfAbsent(v.id, GlobalKey<TooltipState>.new);
- final name = superTabMachineName(v.name);
- final row = Padding(
- padding: const EdgeInsets.only(bottom: 2),
- child: Material(
- color: Colors.transparent,
+ Future<void> _openDetails(_MachineView view) async {
+ setState(() => _selectedMachineId = view.id);
+ try {
+ await _details(view);
+ } finally {
+ if (mounted) setState(() => _selectedMachineId = null);
+ }
+ }
+
+ Widget _machine(_MachineView view) {
+ final tipKey = _tips.putIfAbsent(view.id, GlobalKey<TooltipState>.new);
+ final expanded = c.isMachineExpanded(view.id);
+ final selected = _selectedMachineId == view.id;
+ final row = Material(
+ color: selected ? grid.AppSurface.selectedFill : Colors.transparent,
+ borderRadius: BorderRadius.circular(DesktopChrome.rowRadius),
+ clipBehavior: Clip.antiAlias,
+ child: InkWell(
+ key: ValueKey('super-machine-${view.id}'),
+ onTap: () => unawaited(_openDetails(view)),
+ hoverColor: grid.AppSurface.hoverFill,
+ focusColor: grid.AppSurface.hoverFill,
borderRadius: BorderRadius.circular(DesktopChrome.rowRadius),
- clipBehavior: Clip.antiAlias,
- child: InkWell(
- key: ValueKey('super-machine-${v.id}'),
- onTap: () => unawaited(_details(v)),
- hoverColor: grid.AppSurface.hoverFill,
- focusColor: grid.AppSurface.hoverFill,
- borderRadius: BorderRadius.circular(DesktopChrome.rowRadius),
- // Hover shows the row's tooltip; so does keyboard focus, which a Tooltip does not do by itself.
- onFocusChange: (focused) {
- if (focused &&
- FocusManager.instance.highlightMode ==
- FocusHighlightMode.traditional) {
- tipKey.currentState?.ensureTooltipVisible();
- } else if (!focused) {
- Tooltip.dismissAllToolTips();
- }
+ onFocusChange: (focused) {
+ if (focused &&
+ FocusManager.instance.highlightMode ==
+ FocusHighlightMode.traditional) {
+ tipKey.currentState?.ensureTooltipVisible();
+ } else if (!focused) {
+ Tooltip.dismissAllToolTips();
+ }
+ },
+ child: _MachineLine(
+ view: view,
+ expanded: expanded,
+ onToggle: () {
+ c.toggleMachineExpanded(view.id);
+ _changed();
},
- child: _MachineLine(view: v, columns: columns, level: level),
),
),
);
- // One label for the row, so that colour is never the only signal: the machine, its state in words, and
- // what hovering it says. Its allowances and agents follow, each in its own words.
- return Semantics(
- // Rows move as states change; each keeps its own element, tooltip and all.
- key: ValueKey('super-machine-entry-${v.id}'),
- container: true,
- label: [
- name,
- superTabMachineStateLabel(v.status),
- if (v.tip.isNotEmpty) v.tip,
- ].join(', '),
- child: Tooltip(
- key: tipKey,
- message: v.tip.isEmpty ? superTabMachineStateLabel(v.status) : v.tip,
- excludeFromSemantics: true,
- child: row,
- ),
+ return Column(
+ key: ValueKey('super-machine-entry-${view.id}'),
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Padding(
+ padding: const EdgeInsets.only(bottom: 2),
+ child: Semantics(
+ container: true,
+ selected: selected,
+ label: [
+ superTabMachineName(view.name),
+ superTabMachineStateLabel(view.status),
+ if (view.tip.isNotEmpty) view.tip,
+ ].join(', '),
+ child: Tooltip(
+ key: tipKey,
+ message: view.tip.isEmpty
+ ? superTabMachineStateLabel(view.status)
+ : view.tip,
+ excludeFromSemantics: true,
+ child: row,
+ ),
+ ),
+ ),
+ if (expanded) ...[
+ for (final agent in view.agents) _agent(view, agent),
+ _MachineReadings(view: view),
+ if (view.agents.isEmpty)
+ Padding(
+ padding: const EdgeInsets.fromLTRB(36, 4, 32, 8),
+ child: Text(
+ view.status == SuperTabMachineStatus.offline
+ ? 'Offline'
+ : view.status == SuperTabMachineStatus.unknown
+ ? "Can't reach Harness"
+ : view.status == SuperTabMachineStatus.refreshing
+ ? 'Refreshing…'
+ : 'No agents yet',
+ style: DesktopChrome.metadata(),
+ ),
+ ),
+ ],
+ ],
);
}
- /// "Offline · N": the disclosure the offline machines sit under, closed until opened.
- Widget _offlineToggle(int count) {
- final open = c.offlineMachinesOpen;
- return Padding(
- padding: const EdgeInsets.only(bottom: 2),
+ HarnessActivity _activity(_MachineView view, SuperTabAgent agent) {
+ final app = widget.app;
+ final native = app == null
+ ? null
+ : harnessActivity(app, agent.machineId, agent.harnessId);
+ if (native == HarnessActivity.offline ||
+ native == HarnessActivity.paused ||
+ native == HarnessActivity.starting ||
+ native == HarnessActivity.failed ||
+ native == HarnessActivity.needsInput) {
+ return native!;
+ }
+ // A direct session is better evidence than a missing capacity sample.
+ // When no native lifecycle is available, stale remote work cannot imply
+ // that an offline machine is still waiting for input.
+ if (native == null || native == HarnessActivity.unknown) {
+ if (view.status == SuperTabMachineStatus.offline) {
+ return HarnessActivity.offline;
+ }
+ if (view.status == SuperTabMachineStatus.unknown) {
+ return HarnessActivity.unknown;
+ }
+ }
+ if (c.snapshot?.conversations.any(
+ (group) =>
+ !group.archived &&
+ group.assignment?['agentId'] == agent.id &&
+ superTabWorkWaits(group.assignment?['status']),
+ ) ==
+ true) {
+ return HarnessActivity.needsInput;
+ }
+ return native ?? HarnessActivity.unknown;
+ }
+
+ Widget _agent(_MachineView view, SuperTabAgent agent) {
+ final name = c.snapshot!.agentName(agent.id);
+ final activity = _activity(view, agent);
+ final lead = c.snapshot!.isLead(agent.id);
+ final role = lead
+ ? 'Product Manager'
+ : agent.isReviewer
+ ? 'Reviewer'
+ : 'Engineer';
+ final badge = lead
+ ? 'PM'
+ : agent.isReviewer
+ ? 'Rev'
+ : 'Dev';
+ final info = SuperTabAgentInfo(c, widget.app, agent, activity: activity);
+ final theme = terminalThemeFor(
+ grid.AppTheme.surfacePalette,
+ terminalThemeStore.value,
+ );
+ return Tooltip(
+ message: info.tooltip,
child: Material(
color: Colors.transparent,
borderRadius: BorderRadius.circular(DesktopChrome.rowRadius),
clipBehavior: Clip.antiAlias,
child: InkWell(
- key: const ValueKey('super-machines-offline'),
- // The sidebar rebuilds on the controller; a list shown on its own does not.
- onTap: () {
- c.toggleOfflineMachines();
- _changed();
- },
+ key: ValueKey('super-machine-agent-${view.id}-${agent.id}'),
+ borderRadius: BorderRadius.circular(DesktopChrome.rowRadius),
hoverColor: grid.AppSurface.hoverFill,
focusColor: grid.AppSurface.hoverFill,
- borderRadius: BorderRadius.circular(DesktopChrome.rowRadius),
- child: Semantics(
- button: true,
- expanded: open,
- label: 'Offline machines, $count',
- excludeSemantics: true,
- child: Row(
- children: [
- SizedBox(width: SuperTabSectionHeading.indentFor(1)),
- SizedBox(
- width: _MachineLine.iconColumn,
- child: Icon(
- open ? AppIcons.chevronDown : AppIcons.chevronRight,
- size: AppIcons.inlineSize,
- color: DesktopChrome.muted,
- ),
- ),
- Expanded(
- child: ConstrainedBox(
- constraints: const BoxConstraints(minHeight: 36),
- child: Padding(
- padding: EdgeInsets.fromLTRB(
- 0,
- 8,
- _anchor - _MachineLine.dotHalf,
- 8,
+ onTap: widget.onOpenAgent == null
+ ? null
+ : () {
+ final current = c.snapshot?.agent(agent.id);
+ if (current != null) widget.onOpenAgent!(current);
+ },
+ child: ConstrainedBox(
+ constraints: const BoxConstraints(minHeight: 36),
+ child: Padding(
+ padding: const EdgeInsets.symmetric(vertical: 6),
+ child: Row(
+ children: [
+ const SizedBox(width: 4),
+ SizedBox(
+ width: 32,
+ child: Center(
+ child: SuperTabAvatar(
+ identity: 'agent:${agent.id}',
+ name: name,
+ size: 22,
),
- child: Align(
- alignment: Alignment.centerLeft,
- child: Text(
- 'Offline · $count',
+ ),
+ ),
+ Expanded(
+ child: LayoutBuilder(
+ builder: (context, constraints) {
+ final label = Text(
+ name,
maxLines: 1,
overflow: TextOverflow.ellipsis,
- style: DesktopChrome.metadata(),
+ style: DesktopChrome.control(),
+ );
+ final roleBadge = Semantics(
+ label: role,
+ excludeSemantics: true,
+ child: Container(
+ padding: const EdgeInsets.symmetric(
+ horizontal: 5,
+ vertical: 1,
+ ),
+ decoration: BoxDecoration(
+ color: grid.AppSurface.hoverFill,
+ borderRadius: BorderRadius.circular(4),
+ ),
+ child: Text(badge, style: DesktopChrome.metadata()),
+ ),
+ );
+ if (constraints.maxWidth <
+ MediaQuery.textScalerOf(context).scale(100)) {
+ return Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ mainAxisSize: MainAxisSize.min,
+ children: [label, roleBadge],
+ );
+ }
+ return Row(
+ children: [
+ Flexible(child: label),
+ const SizedBox(width: 6),
+ roleBadge,
+ ],
+ );
+ },
+ ),
+ ),
+ SizedBox(
+ width: 32,
+ child: Center(
+ child: ActivityMark(
+ activity: activity,
+ color: activityColor(
+ activity,
+ theme,
+ color: appearancePrefsStore.value.prompt.color,
),
),
),
),
- ),
- ],
+ const SizedBox(width: 32),
+ ],
+ ),
),
),
),
@@ -1261,107 +1380,12 @@ class _SuperTabMachinesState extends State<SuperTabMachines> {
);
}
- /// The right side of every row, decided once for the whole list from its [width], so each column lines up:
- /// Claude's allowance, Codex's, then the agents. A column no machine uses is left out. When the name would
- /// have less than its minimum, the agents column becomes a count first, then the Codex column goes, then
- /// Claude's, for every row at once.
- _Columns _columns(
- BuildContext context,
- double width,
- List<_MachineView> views,
- ) {
- final scaler = MediaQuery.textScalerOf(context);
- final direction = Directionality.of(context);
- double measure(String text, TextStyle style) {
- final painter = TextPainter(
- text: TextSpan(text: text, style: style),
- textDirection: direction,
- textScaler: scaler,
- maxLines: 1,
- )..layout();
- final result = painter.width;
- painter.dispose();
- return result;
- }
-
- final count = _MachineLine.countStyle;
- final chip =
- _MachineLine.gap +
- _MachineLine.mark +
- _MachineLine.markGap +
- measure('100%', count);
- bool uses(String engine) =>
- views.any((v) => v.allowances.any((a) => a.engine == engine));
- final most = views.fold(0, (n, v) => math.max(n, v.agents.length));
- final stacked = math.min(most, _MachineLine.maxAvatars);
- final rest = most - stacked;
- final ringed = _MachineLine.ringed;
- final full = most == 0
- ? 0.0
- : _MachineLine.avatarsGap +
- ringed +
- (ringed - _MachineLine.overlap) * (stacked - 1) +
- (rest > 0 ? 4 + measure('+$rest', count) : 0);
- final counted = most == 0
- ? 0.0
- : _MachineLine.countGap + measure('+$most', count);
- // With agents, their last avatar centers on the heading +; without, the row ends where project dots do.
- final end = most == 0
- ? _anchor - _MachineLine.dotHalf
- : (_anchor - ringed / 2).clamp(0.0, _anchor);
- final style = DesktopChrome.control();
- final wanted = math.min(
- views.fold(
- 0.0,
- (w, v) => math.max(w, measure(superTabMachineName(v.name), style)),
- ),
- scaler.scale(_MachineLine.minName),
- );
- // Decided for the online rows, so opening "Offline · N" never moves a column; the offline rows' names,
- // one step further in, give way a little sooner.
- final text =
- width -
- SuperTabSectionHeading.indentFor(1) -
- _MachineLine.iconColumn -
- end;
- final steps = [
- (
- agents: full,
- counted: false,
- claude: uses('claude'),
- codex: uses('codex'),
- ),
- (
- agents: counted,
- counted: true,
- claude: uses('claude'),
- codex: uses('codex'),
- ),
- (agents: counted, counted: true, claude: uses('claude'), codex: false),
- (agents: counted, counted: true, claude: false, codex: false),
- ];
- final pick = steps.firstWhere(
- (s) =>
- text - s.agents - (s.claude ? chip : 0) - (s.codex ? chip : 0) >=
- wanted,
- orElse: () => steps.last,
- );
- return _Columns(
- claude: pick.claude,
- codex: pick.codex,
- chip: chip,
- agents: pick.agents,
- counted: pick.counted,
- end: end,
- );
- }
-
- /// Online machines first, then "Offline · N" with the offline ones under it; each part by name.
- List<Widget> _machines(BuildContext context, double width) {
+ /// Keep offline machines in the same list and on the same columns.
+ List<Widget> _machines() {
final views = [for (final id in _ids) _view(id)];
- String key(_MachineView v) => superTabMachineName(v.name).toLowerCase();
- // A machine being refreshed keeps its place; one whose state cannot be read follows the ones that report.
- int rank(_MachineView v) => switch (v.status) {
+ String key(_MachineView view) =>
+ superTabMachineName(view.name).toLowerCase();
+ int rank(_MachineView view) => switch (view.status) {
SuperTabMachineStatus.unknown => 1,
SuperTabMachineStatus.offline => 2,
_ => 0,
@@ -1373,24 +1397,7 @@ class _SuperTabMachinesState extends State<SuperTabMachines> {
? key(a).compareTo(key(b))
: a.id.compareTo(b.id),
);
- final offline = views
- .where((v) => v.status == SuperTabMachineStatus.offline)
- .toList();
- final open = offline.isNotEmpty && c.offlineMachinesOpen;
- final shown = [
- for (final v in views)
- if (v.status != SuperTabMachineStatus.offline || open) v,
- ];
- final columns = _columns(context, width, shown);
- return [
- for (final v in views)
- if (v.status != SuperTabMachineStatus.offline) _machine(v, columns),
- if (offline.isNotEmpty) ...[
- _offlineToggle(offline.length),
- if (open)
- for (final v in offline) _machine(v, columns, level: 2),
- ],
- ];
+ return [for (final view in views) _machine(view)];
}
@override
@@ -1411,15 +1418,6 @@ class _SuperTabMachinesState extends State<SuperTabMachines> {
: widget.now().difference(failingSince),
)
: null,
- actions: [
- if (widget.onYourDevices != null)
- AppIconButton(
- key: const ValueKey('super-your-devices'),
- icon: AppIcons.monitorSmartphone,
- tooltip: 'Your devices',
- onPressed: widget.onYourDevices,
- ),
- ],
endInset: widget.embedded ? 0 : 12,
collapsed: widget.onToggleCollapsed == null ? null : widget.collapsed,
onToggleCollapsed: widget.onToggleCollapsed,
@@ -1427,20 +1425,17 @@ class _SuperTabMachinesState extends State<SuperTabMachines> {
if (!widget.collapsed) ...[
if (_ids.isEmpty)
Padding(
- padding: const EdgeInsets.fromLTRB(16, 8, 16, 16),
+ padding: const EdgeInsets.fromLTRB(36, 8, 16, 16),
child: Text(
'Add a machine for the product manager to use.',
style: DesktopChrome.metadata(),
),
)
else
- // The rows share their columns, which depend on the list's width.
- LayoutBuilder(
- builder: (context, constraints) => Column(
- crossAxisAlignment: CrossAxisAlignment.stretch,
- mainAxisSize: MainAxisSize.min,
- children: _machines(context, constraints.maxWidth),
- ),
+ Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ mainAxisSize: MainAxisSize.min,
+ children: _machines(),
),
],
];
@@ -1480,7 +1475,7 @@ class _MachineView {
final SuperTabPerson? owner;
final String? contributor;
final Map<String, dynamic>? shared;
- final List<({String id, String name, String role})> agents;
+ final List<SuperTabAgent> agents;
final SuperTabMachineStatus status;
/// When the reading shown was taken, and whether that is just now (the dot pings once).
@@ -1523,284 +1518,227 @@ class _Allowance {
);
}
-/// The right side every machine row shares: which columns show, and how wide each one is.
-class _Columns {
- const _Columns({
- required this.claude,
- required this.codex,
- required this.chip,
- required this.agents,
- required this.counted,
- required this.end,
- });
-
- /// Whether the Claude and Codex allowance columns show.
- final bool claude, codex;
-
- /// The width of an allowance column: a gap, the mark, and room for "100%".
- final double chip;
-
- /// The width of the agents column; 0 when no machine has an agent.
- final double agents;
-
- /// Whether the agents column only counts them ("+3") rather than stacking their avatars.
- final bool counted;
-
- /// The space after the last column, from the row's right edge.
- final double end;
-}
-
-/// A machine's line, at the height and on the columns of a project row: the dot centered in the icon column,
-/// the name on the text column, then the list's shared [columns]: Claude's allowance, Codex's, and the agents.
-/// A machine without an allowance leaves its column blank, so every row's figures line up.
+/// The same leading icon/name and trailing status/disclosure columns as projects.
class _MachineLine extends StatelessWidget {
const _MachineLine({
required this.view,
- required this.columns,
- required this.level,
+ required this.expanded,
+ required this.onToggle,
});
final _MachineView view;
- final _Columns columns;
-
- /// 1 under the Machines heading, 2 under "Offline · N".
- final int level;
-
- static const iconColumn = SuperTabSectionHeading.actionWidth;
-
- /// Half the project rows' dot, so that a list without agents stops where their rows do.
- static const dotHalf = 3.0;
- static const _avatar = 16.0;
- static const _ring = 1.0;
- static const overlap = 5.0;
- static const maxAvatars = 3;
- static const mark = 14.0;
- static const markGap = 3.0;
-
- /// Before each column, and between the name and the first.
- static const gap = 6.0;
-
- /// Before the agents column when it shows their avatars, so the avatars stand apart from the figures. A count
- /// is a figure like the others and keeps their [gap], which leaves Claude's column room in the default 204 px
- /// sidebar.
- static const avatarsGap = 16.0;
- static const countGap = gap;
-
- /// What the name keeps, at the default text size, before a column gives way: a readable start of it, small
- /// enough that Claude's allowance still fits beside it in the default 204 px sidebar.
- static const minName = 48.0;
-
- static double get ringed => _avatar + 2 * _ring;
-
- /// The allowance figures and the agent count, in tabular figures, at the scale of the 16 px avatars beside
- /// them.
- static TextStyle get countStyle => DesktopChrome.metadata().copyWith(
- fontSize: 11,
- fontFeatures: const [FontFeature.tabularFigures()],
- );
+ final bool expanded;
+ final VoidCallback onToggle;
@override
Widget build(BuildContext context) {
- final v = view;
final muted =
- v.status == SuperTabMachineStatus.offline ||
- v.status == SuperTabMachineStatus.unknown;
- final style = DesktopChrome.control(
- color: muted ? DesktopChrome.muted : DesktopChrome.foreground,
- );
- final count = countStyle;
- final agents = v.agents.length;
- final shown = columns.counted ? 0 : math.min(agents, maxAvatars);
- final hidden = agents - shown;
- final roles = v.agents.map((a) => '${a.name} — ${a.role}').join('\n');
-
- Widget allowance(String engine) {
- final a = v.allowances.where((a) => a.engine == engine).firstOrNull;
- return SizedBox(
- width: columns.chip,
- child: a == null
- ? null
- : Tooltip(
- message: a.detail,
- child: Semantics(
- label: '${a.name} ${a.figure} remaining',
- excludeSemantics: true,
- child: Row(
- key: ValueKey('super-machine-allowance-${v.id}-$engine'),
- children: [
- const SizedBox(width: gap),
- EngineMark(engine: engine, size: mark),
- const SizedBox(width: markGap),
- // Right after its mark, so every row's figure starts at the same x.
- Expanded(
- child: Text(
- a.figure,
- key: ValueKey('super-machine-figure-${v.id}-$engine'),
- maxLines: 1,
- softWrap: false,
- overflow: TextOverflow.clip,
- style: count.copyWith(color: a.ink),
- ),
- ),
- ],
- ),
+ view.status == SuperTabMachineStatus.offline ||
+ view.status == SuperTabMachineStatus.unknown;
+ final name = superTabMachineName(view.name);
+ final owner = view.owner;
+ return ConstrainedBox(
+ constraints: const BoxConstraints(minHeight: 36),
+ child: Row(
+ children: [
+ const SizedBox(width: 4),
+ SizedBox(
+ width: 32,
+ child: Icon(
+ AppIcons.monitor,
+ size: AppIcons.inlineSize,
+ color: DesktopChrome.muted,
+ ),
+ ),
+ Expanded(
+ child: Padding(
+ padding: const EdgeInsets.symmetric(vertical: 8),
+ child: LayoutBuilder(
+ builder: (context, constraints) {
+ final style = DesktopChrome.control(
+ color: muted
+ ? DesktopChrome.muted
+ : DesktopChrome.foreground,
+ );
+ final text = Text(
+ name,
+ key: ValueKey('super-machine-name-${view.id}'),
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: style,
+ );
+ final painter = TextPainter(
+ text: TextSpan(text: name, style: style),
+ textDirection: Directionality.of(context),
+ textScaler: MediaQuery.textScalerOf(context),
+ maxLines: 1,
+ )..layout(maxWidth: constraints.maxWidth);
+ final truncated = painter.didExceedMaxLines;
+ painter.dispose();
+ return truncated
+ ? Tooltip(
+ message: [
+ name,
+ if (view.tip.isNotEmpty) view.tip,
+ ].join('\n'),
+ excludeFromSemantics: true,
+ child: text,
+ )
+ : text;
+ },
+ ),
+ ),
+ ),
+ if (owner != null)
+ Padding(
+ padding: const EdgeInsets.only(left: 6),
+ child: Tooltip(
+ message: 'Owned by ${superTabPersonName(owner.email)}',
+ child: SuperTabAvatar(
+ identity: 'person:${owner.id}',
+ name: superTabPersonName(owner.email),
+ size: 20,
),
),
- );
- }
-
- return Row(
- children: [
- SizedBox(width: SuperTabSectionHeading.indentFor(level)),
- SizedBox(
- width: iconColumn,
- child: Center(
- child: KeyedSubtree(
- key: ValueKey('super-machine-state-${v.id}-${v.status.name}'),
- child: SuperTabMachineDot(
- status: v.status,
- readingAt: v.readingAt,
- arrived: v.arrived,
+ ),
+ SizedBox(
+ width: 32,
+ child: Center(
+ child: KeyedSubtree(
+ key: ValueKey(
+ 'super-machine-state-${view.id}-${view.status.name}',
+ ),
+ child: SuperTabMachineDot(
+ status: view.status,
+ readingAt: view.readingAt,
+ arrived: view.arrived,
+ ),
),
),
),
- ),
- Expanded(
- child: ConstrainedBox(
- constraints: const BoxConstraints(minHeight: 36),
- child: Padding(
- padding: const EdgeInsets.symmetric(vertical: 8),
- child: Row(
- children: [
- Expanded(
- child: LayoutBuilder(
- builder: (context, constraints) => Align(
- alignment: Alignment.centerLeft,
- child: _name(
- context,
- superTabMachineName(v.name),
- style,
- constraints.maxWidth,
- ),
- ),
- ),
- ),
- if (columns.claude) allowance('claude'),
- if (columns.codex) allowance('codex'),
- if (columns.agents > 0)
- SizedBox(
- key: ValueKey('super-machine-agents-slot-${v.id}'),
- width: columns.agents,
- child: agents == 0
- ? null
- : Align(
- alignment: Alignment.centerRight,
- child: Tooltip(
- message: roles,
- child: Semantics(
- label: v.agents
- .map((a) => '${a.name}, ${a.role}')
- .join('; '),
- excludeSemantics: true,
- child: Row(
- key: ValueKey(
- 'super-machine-agents-${v.id}',
- ),
- mainAxisSize: MainAxisSize.min,
- children: [
- if (shown > 0) _stack(context, shown),
- if (hidden > 0) ...[
- if (shown > 0) const SizedBox(width: 4),
- Text('+$hidden', style: count),
- ],
- ],
- ),
- ),
- ),
- ),
- ),
- SizedBox(width: columns.end),
- ],
+ Semantics(
+ expanded: expanded,
+ button: true,
+ child: IconButton(
+ key: ValueKey('super-machine-toggle-${view.id}'),
+ icon: Icon(
+ expanded ? AppIcons.chevronDown : AppIcons.chevronRight,
+ size: AppIcons.inlineSize,
),
+ color: DesktopChrome.muted,
+ style: const ButtonStyle(
+ minimumSize: WidgetStatePropertyAll(Size.square(32)),
+ padding: WidgetStatePropertyAll(EdgeInsets.all(6)),
+ tapTargetSize: MaterialTapTargetSize.shrinkWrap,
+ visualDensity: VisualDensity.standard,
+ overlayColor: WidgetStatePropertyAll(Colors.transparent),
+ backgroundColor: WidgetStatePropertyAll(Colors.transparent),
+ ),
+ tooltip: '${expanded ? 'Collapse' : 'Expand'} $name',
+ onPressed: onToggle,
),
),
- ),
- ],
+ ],
+ ),
);
}
+}
- /// The name, fitted to [room]; a name cut short shows itself whole on hover.
- Widget _name(
- BuildContext context,
- String name,
- TextStyle style,
- double room,
- ) {
- double measure(String text) {
- final painter = TextPainter(
- text: TextSpan(text: text, style: style),
- textDirection: Directionality.of(context),
- textScaler: MediaQuery.textScalerOf(context),
- maxLines: 1,
- )..layout();
- final result = painter.width;
- painter.dispose();
- return result;
- }
+/// The expanded reading block wraps complete values, without filling missing slots.
+class _MachineReadings extends StatelessWidget {
+ const _MachineReadings({required this.view});
+ final _MachineView view;
- var shown = name;
- if (measure(name) > room) {
- final chars = name.characters.toList();
- var keep = 0;
- for (var lo = 1, hi = chars.length - 1; lo <= hi;) {
- final mid = (lo + hi) ~/ 2;
- if (measure('${chars.take(mid).join().trimRight()}…') <= room) {
- keep = mid;
- lo = mid + 1;
- } else {
- hi = mid - 1;
- }
- }
- shown = '${chars.take(keep).join().trimRight()}…';
- }
- final text = Text(
- shown,
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: style,
+ @override
+ Widget build(BuildContext context) {
+ if (view.dim) return const SizedBox.shrink();
+ final resources = view.resources;
+ final usage = <(String, String)>[
+ if (resources?.cpuPercent case final cpu?)
+ ('CPU ${resourcePercent(cpu)}', 'CPU utilization'),
+ if (resources?.busiestGpu?.utilizationPercent case final gpu?)
+ ('GPU ${resourcePercent(gpu)}', 'GPU utilization'),
+ ];
+ final memoryFree =
+ resources?.memoryTotalBytes == null ||
+ resources?.memoryUsedBytes == null
+ ? null
+ : (resources!.memoryTotalBytes! - resources.memoryUsedBytes!).clamp(
+ 0,
+ resources.memoryTotalBytes!,
+ );
+ final diskFree = resources?.projectDiskTotalBytes == null
+ ? resources?.diskFreeBytes
+ : resources?.projectDiskFreeBytes;
+ final capacity = <(String, String)>[
+ if (memoryFree != null)
+ ('RAM ${resourceBytes(memoryFree.toDouble())}', 'Memory available'),
+ if (diskFree != null)
+ ('SSD ${resourceBytes(diskFree)}', 'Storage available'),
+ ];
+ final style = DesktopChrome.metadata().copyWith(
+ fontFeatures: const [FontFeature.tabularFigures()],
);
- return shown == name ? text : Tooltip(message: name, child: text);
- }
-
- /// The first [shown] agents, overlapping, each on a ring of the surface so the one behind reads as behind.
- Widget _stack(BuildContext context, int shown) {
- final step = ringed - overlap;
- return MediaQuery.withClampedTextScaling(
- maxScaleFactor: 1,
- child: SizedBox(
- width: ringed + step * (shown - 1),
- height: ringed,
- child: Stack(
- children: [
- // The first agent is drawn last, on top.
- for (var i = shown - 1; i >= 0; i--)
- Positioned(
- left: step * i,
- child: Container(
- padding: const EdgeInsets.all(_ring),
- decoration: BoxDecoration(
- color: DesktopChrome.surface,
- shape: BoxShape.circle,
- ),
- child: SuperTabAvatar(
- identity: 'agent:${view.agents[i].id}',
- name: view.agents[i].name,
- size: _avatar,
- ),
- ),
+ Widget readings(List<(String, String)> readings) => Wrap(
+ spacing: 10,
+ runSpacing: 2,
+ children: [
+ for (final (label, meaning) in readings)
+ Tooltip(
+ message: meaning,
+ child: Text(label, style: style),
+ ),
+ ],
+ );
+ if (usage.isEmpty && capacity.isEmpty && view.allowances.isEmpty) {
+ return const SizedBox.shrink();
+ }
+ return Padding(
+ key: ValueKey('super-machine-readings-${view.id}'),
+ padding: const EdgeInsets.fromLTRB(36, 4, 32, 10),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ if (usage.isNotEmpty) readings(usage),
+ if (capacity.isNotEmpty) readings(capacity),
+ if (view.allowances.isNotEmpty)
+ Padding(
+ padding: const EdgeInsets.only(top: 4),
+ child: Wrap(
+ spacing: 12,
+ runSpacing: 4,
+ children: [
+ for (final allowance in view.allowances)
+ Tooltip(
+ message: allowance.detail,
+ child: Semantics(
+ label:
+ '${allowance.name} ${allowance.figure} remaining',
+ excludeSemantics: true,
+ child: Row(
+ key: ValueKey(
+ 'super-machine-allowance-${view.id}-${allowance.engine}',
+ ),
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ EngineMark(engine: allowance.engine, size: 14),
+ const SizedBox(width: 4),
+ Text(
+ allowance.figure,
+ key: ValueKey(
+ 'super-machine-figure-${view.id}-${allowance.engine}',
+ ),
+ style: style.copyWith(color: allowance.ink),
+ ),
+ ],
+ ),
+ ),
+ ),
+ ],
),
- ],
- ),
+ ),
+ ],
),
);
}
diff --git a/desktop/lib/super_tabs/pane_layout.dart b/desktop/lib/super_tabs/pane_layout.dart
index 17aed2032..f379ba62b 100644
--- a/desktop/lib/super_tabs/pane_layout.dart
+++ b/desktop/lib/super_tabs/pane_layout.dart
@@ -22,7 +22,8 @@ class SuperTabPaneLayout extends StatefulWidget {
});
static const storageKey = 'super-tab-pane-widths';
- static const rightWidth = 380.0;
+ static const leftWidth = 300.0;
+ static const rightWidth = 280.0;
final Widget? left, right;
final Widget center;
final VoidCallback onLeave;
@@ -33,7 +34,8 @@ class SuperTabPaneLayout extends StatefulWidget {
}
class _SuperTabPaneLayoutState extends State<SuperTabPaneLayout> {
- double _left = 220, _right = SuperTabPaneLayout.rightWidth;
+ double _left = SuperTabPaneLayout.leftWidth,
+ _right = SuperTabPaneLayout.rightWidth;
int _edit = 0;
Future<void> _writing = Future.value();
diff --git a/desktop/lib/super_tabs/project_sidebar.dart b/desktop/lib/super_tabs/project_sidebar.dart
index 1727fb235..b4ab5d150 100644
--- a/desktop/lib/super_tabs/project_sidebar.dart
+++ b/desktop/lib/super_tabs/project_sidebar.dart
@@ -4,6 +4,7 @@ import '../core/machine_resources.dart';
import '../shared/theme/app_icons.dart';
import '../shared/theme/app_theme.dart' as grid;
import '../shared/theme/appearance_prefs_store.dart';
+import '../shared/widgets/app_icon_button.dart';
import '../state/app_state.dart';
import '../terminal/terminal_theme_store.dart';
import '../widgets/desktop_chrome.dart';
@@ -22,6 +23,8 @@ class ProjectSidebar extends StatelessWidget {
this.app,
this.onNewProject,
this.onYourDevices,
+ this.devicesSelected = false,
+ this.onOpenAgent,
this.readLocal,
this.now = DateTime.now,
});
@@ -32,6 +35,8 @@ class ProjectSidebar extends StatelessWidget {
final AppNotifier? app;
final VoidCallback? onNewProject;
final VoidCallback? onYourDevices;
+ final bool devicesSelected;
+ final ValueChanged<SuperTabAgent>? onOpenAgent;
/// Forwarded to the embedded [SuperTabMachines]; a test gives it to have
/// the Machines group's readings taken without a real machine.
@@ -43,23 +48,73 @@ class ProjectSidebar extends StatelessWidget {
@visibleForTesting
final DateTime Function() now;
- /// A row's chevron (or the room for one), at its level's indent; its name starts right after.
+ /// Projects and workgroups share a text column. Only projects use its icon.
static const _iconColumn = SuperTabSectionHeading.actionWidth;
static const _dotSize = 6.0;
- /// The space after a row's trailing unread dot: it centers the dot on the
- /// headings' + ([SuperTabSectionHeading.endInset] 0), whatever the width.
- static const markerInset =
- SuperTabSectionHeading.actionWidth / 2 - _dotSize / 2;
+ Widget _navigationRow({
+ required String key,
+ required String label,
+ required IconData icon,
+ required VoidCallback? onTap,
+ bool selected = false,
+ }) => Padding(
+ padding: const EdgeInsets.only(bottom: 2),
+ child: Material(
+ color: selected ? grid.AppSurface.selectedFill : Colors.transparent,
+ borderRadius: BorderRadius.circular(DesktopChrome.rowRadius),
+ clipBehavior: Clip.antiAlias,
+ child: Semantics(
+ button: true,
+ selected: selected,
+ child: InkWell(
+ key: ValueKey(key),
+ onTap: onTap,
+ hoverColor: grid.AppSurface.hoverFill,
+ focusColor: grid.AppSurface.hoverFill,
+ borderRadius: BorderRadius.circular(DesktopChrome.rowRadius),
+ child: Row(
+ children: [
+ SizedBox(width: SuperTabSectionHeading.indentFor(0)),
+ SizedBox(
+ width: _iconColumn,
+ child: Icon(
+ icon,
+ size: AppIcons.inlineSize,
+ color: onTap == null
+ ? DesktopChrome.muted
+ : DesktopChrome.foreground,
+ ),
+ ),
+ Expanded(
+ child: ConstrainedBox(
+ constraints: const BoxConstraints(minHeight: 36),
+ child: Padding(
+ padding: const EdgeInsets.fromLTRB(0, 8, 12, 8),
+ child: Text(
+ label,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: DesktopChrome.control(
+ medium: selected,
+ color: onTap == null
+ ? DesktopChrome.muted
+ : DesktopChrome.foreground,
+ ),
+ ),
+ ),
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
+ ),
+ );
- /// A project's lead row (level 1, under the heading) or a workgroup (level 2, under its project).
- Widget _row(
- SuperTabConversation group, {
- SuperTabProject? project,
- bool closed = false,
- }) {
- final level = project != null ? 1 : (closed ? 3 : 2);
- final selected = controller.selectedId == group.id;
+ /// Project names open their PM chat; only the trailing control expands them.
+ Widget _row(SuperTabConversation group, {SuperTabProject? project}) {
+ final selected = !devicesSelected && controller.selectedId == group.id;
final groups = project == null
? [group]
: controller.snapshot!.conversations.where(
@@ -83,31 +138,17 @@ class ProjectSidebar extends StatelessWidget {
borderRadius: BorderRadius.circular(DesktopChrome.rowRadius),
child: Row(
children: [
- SizedBox(width: SuperTabSectionHeading.indentFor(level)),
- if (project != null)
- IconButton(
- key: ValueKey('super-project-expand-${project.id}'),
- icon: Icon(
- expanded ? AppIcons.chevronDown : AppIcons.chevronRight,
- size: AppIcons.inlineSize,
- ),
- color: DesktopChrome.muted,
- // The row owns hover/press feedback. Keep the themed focus
- // boundary for this independent disclosure action.
- style: const ButtonStyle(
- minimumSize: WidgetStatePropertyAll(Size.square(32)),
- padding: WidgetStatePropertyAll(EdgeInsets.all(6)),
- tapTargetSize: MaterialTapTargetSize.shrinkWrap,
- visualDensity: VisualDensity.standard,
- overlayColor: WidgetStatePropertyAll(Colors.transparent),
- backgroundColor: WidgetStatePropertyAll(Colors.transparent),
- ),
- tooltip:
- '${expanded ? 'Collapse' : 'Expand'} ${project.name}',
- onPressed: () => controller.toggleProject(project.id),
- )
- else
- const SizedBox(width: _iconColumn),
+ SizedBox(width: SuperTabSectionHeading.indentFor(0)),
+ SizedBox(
+ width: _iconColumn,
+ child: project == null
+ ? null
+ : Icon(
+ expanded ? AppIcons.folderOpen : AppIcons.folder,
+ size: AppIcons.inlineSize,
+ color: DesktopChrome.muted,
+ ),
+ ),
Expanded(
child: Semantics(
label: project?.isPrivate == true ? 'Private project' : null,
@@ -117,12 +158,7 @@ class ProjectSidebar extends StatelessWidget {
child: ConstrainedBox(
constraints: const BoxConstraints(minHeight: 36),
child: Padding(
- padding: const EdgeInsets.fromLTRB(
- 0,
- 8,
- markerInset,
- 8,
- ),
+ padding: const EdgeInsets.symmetric(vertical: 8),
child: Row(
children: [
Expanded(
@@ -149,32 +185,6 @@ class ProjectSidebar extends StatelessWidget {
),
),
],
- if (waiting) ...[
- const SizedBox(width: 8),
- Tooltip(
- message: 'Needs a human',
- child: Text(
- '?',
- style: DesktopChrome.control(
- color: grid.AppPalette.warn,
- medium: true,
- ),
- ),
- ),
- ] else if (unread) ...[
- const SizedBox(width: 8),
- Semantics(
- label: 'Unread messages',
- child: Container(
- width: _dotSize,
- height: _dotSize,
- decoration: BoxDecoration(
- shape: BoxShape.circle,
- color: DesktopChrome.accent,
- ),
- ),
- ),
- ],
],
),
),
@@ -182,6 +192,52 @@ class ProjectSidebar extends StatelessWidget {
),
),
),
+ SizedBox(
+ width: _iconColumn,
+ child: Center(
+ child: waiting
+ ? Tooltip(
+ message: 'Needs a human',
+ child: Text(
+ '?',
+ style: DesktopChrome.control(
+ color: grid.AppPalette.warn,
+ medium: true,
+ ),
+ ),
+ )
+ : unread
+ ? Semantics(
+ label: 'Unread messages',
+ child: Container(
+ width: _dotSize,
+ height: _dotSize,
+ decoration: BoxDecoration(
+ shape: BoxShape.circle,
+ color: DesktopChrome.accent,
+ ),
+ ),
+ )
+ : null,
+ ),
+ ),
+ if (project != null)
+ Semantics(
+ expanded: expanded,
+ child: AppIconButton(
+ key: ValueKey('super-project-expand-${project.id}'),
+ icon: expanded
+ ? AppIcons.chevronDown
+ : AppIcons.chevronRight,
+ color: DesktopChrome.muted,
+ hoverFill: Colors.transparent,
+ tooltip:
+ '${expanded ? 'Collapse' : 'Expand'} ${project.name}',
+ onPressed: () => controller.toggleProject(project.id),
+ ),
+ )
+ else
+ const SizedBox(width: _iconColumn),
],
),
),
@@ -219,15 +275,8 @@ class ProjectSidebar extends StatelessWidget {
borderRadius: BorderRadius.circular(DesktopChrome.rowRadius),
child: Row(
children: [
- SizedBox(width: SuperTabSectionHeading.indentFor(2)),
- SizedBox(
- width: _iconColumn,
- child: Icon(
- open ? AppIcons.chevronDown : AppIcons.chevronRight,
- size: AppIcons.inlineSize,
- color: DesktopChrome.muted,
- ),
- ),
+ SizedBox(width: SuperTabSectionHeading.indentFor(0)),
+ const SizedBox(width: _iconColumn),
Expanded(
child: ConstrainedBox(
constraints: const BoxConstraints(minHeight: 36),
@@ -244,6 +293,14 @@ class ProjectSidebar extends StatelessWidget {
),
),
),
+ SizedBox(
+ width: _iconColumn,
+ child: Icon(
+ open ? AppIcons.chevronDown : AppIcons.chevronRight,
+ size: AppIcons.inlineSize,
+ color: DesktopChrome.muted,
+ ),
+ ),
],
),
),
@@ -251,7 +308,7 @@ class ProjectSidebar extends StatelessWidget {
),
),
if (open)
- for (final group in groups) _row(group, closed: true),
+ for (final group in groups) _row(group),
];
}
@@ -266,7 +323,7 @@ class ProjectSidebar extends StatelessWidget {
? [
Padding(
padding: EdgeInsets.fromLTRB(
- SuperTabSectionHeading.indentFor(2) + _iconColumn,
+ SuperTabSectionHeading.indentFor(0) + _iconColumn,
8,
12,
10,
@@ -291,6 +348,23 @@ class ProjectSidebar extends StatelessWidget {
child: ListView(
padding: const EdgeInsets.all(8),
children: [
+ if (onNewProject != null)
+ _navigationRow(
+ key: 'super-new-project',
+ label: 'New project',
+ icon: AppIcons.plus,
+ onTap: controller.canWrite ? onNewProject : null,
+ ),
+ if (onYourDevices != null)
+ _navigationRow(
+ key: 'super-your-devices',
+ label: 'Your devices',
+ icon: AppIcons.circle,
+ onTap: onYourDevices,
+ selected: devicesSelected,
+ ),
+ if (onNewProject != null || onYourDevices != null)
+ const SizedBox(height: 20),
SuperTabSectionHeading(
'Projects',
onAdd: controller.canWrite ? onNewProject : null,
@@ -332,10 +406,10 @@ class ProjectSidebar extends StatelessWidget {
controller: controller,
app: app,
onAddAgent: onAddAgent,
+ onOpenAgent: onOpenAgent,
embedded: true,
collapsed: !controller.machinesGroupOpen,
onToggleCollapsed: controller.toggleMachinesGroup,
- onYourDevices: onYourDevices,
readLocal: readLocal,
now: now,
);
diff --git a/desktop/lib/super_tabs/roster.dart b/desktop/lib/super_tabs/roster.dart
index 5a2d17071..94a2d84df 100644
--- a/desktop/lib/super_tabs/roster.dart
+++ b/desktop/lib/super_tabs/roster.dart
@@ -18,7 +18,7 @@ import 'identity.dart';
import 'model.dart';
import 'section_heading.dart';
-/// Tab-wide people and capacity, with agents from the selected project.
+/// The current Swarm's authorized people and agents, independent of navigation.
class SuperTabRoster extends StatefulWidget {
const SuperTabRoster({
super.key,
@@ -190,18 +190,116 @@ class _SuperTabRosterState extends State<SuperTabRoster> {
widget.onOpenAgent,
);
+ Widget _agentIdentity(
+ String name,
+ String role,
+ String badge,
+ String? project,
+ ) => LayoutBuilder(
+ builder: (context, constraints) {
+ final nameStyle = DesktopChrome.control();
+ final tagStyle = DesktopChrome.metadata();
+ final scale = MediaQuery.textScalerOf(context);
+ double measure(String text, TextStyle style) {
+ final painter = TextPainter(
+ text: TextSpan(text: text, style: style),
+ textDirection: Directionality.of(context),
+ textScaler: scale,
+ maxLines: 1,
+ )..layout();
+ final width = painter.width;
+ painter.dispose();
+ return width;
+ }
+
+ final badgeWidth = (measure(badge, tagStyle) + 10).clamp(
+ 0.0,
+ constraints.maxWidth,
+ );
+ final nameWidth = measure(name, nameStyle).clamp(
+ 0.0,
+ (constraints.maxWidth - badgeWidth - 6).clamp(0.0, double.infinity),
+ );
+ final projectWidth = project == null
+ ? 0.0
+ : (measure(project, tagStyle) + 10).clamp(
+ 0.0,
+ (constraints.maxWidth - nameWidth - badgeWidth - 12).clamp(
+ 0.0,
+ double.infinity,
+ ),
+ );
+ Widget tag(String text) => Container(
+ padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 1),
+ decoration: BoxDecoration(
+ color: grid.AppSurface.hoverFill,
+ borderRadius: BorderRadius.circular(4),
+ ),
+ child: Text(
+ text,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: tagStyle,
+ ),
+ );
+ return Row(
+ children: [
+ if (nameWidth > 0) ...[
+ SizedBox(
+ width: nameWidth,
+ child: Text(
+ name,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: nameStyle,
+ ),
+ ),
+ const SizedBox(width: 6),
+ ],
+ Semantics(
+ label: role,
+ excludeSemantics: true,
+ child: SizedBox(width: badgeWidth, child: tag(badge)),
+ ),
+ // Give the name and role their space first. The full project remains
+ // in the row's tooltip when a narrow pane cannot fit a readable tag.
+ if (project != null && projectWidth >= scale.scale(24) + 10) ...[
+ const SizedBox(width: 6),
+ SizedBox(width: projectWidth, child: tag(project)),
+ ],
+ ],
+ );
+ },
+ );
+
Widget _agent(SuperTabAgent agent) {
final name = c.snapshot!.agentName(agent.id), activity = _activity(agent);
final info = SuperTabAgentInfo(c, widget.app, agent, activity: activity);
final project = c.snapshot!.projects
.where((p) => p.id == _agentProjectId(agent))
.firstOrNull;
+ final role = c.snapshot!.isLead(agent.id)
+ ? 'Product Manager'
+ : agent.isReviewer
+ ? 'Reviewer'
+ : 'Engineer';
+ final badge = c.snapshot!.isLead(agent.id)
+ ? 'PM'
+ : agent.isReviewer
+ ? 'Rev'
+ : 'Dev';
+ final status = info.status ?? 'Status unavailable';
+ final tooltip = [
+ [name, role, ?project?.name].join(' · '),
+ if (info.tooltip.isNotEmpty) info.tooltip,
+ if (!info.tooltip.contains(status)) status,
+ ].join('\n');
final theme = terminalThemeFor(
grid.AppTheme.surfacePalette,
terminalThemeStore.value,
);
return Tooltip(
- message: info.tooltip,
+ message: tooltip,
constraints: const BoxConstraints(maxWidth: 820),
child: GestureDetector(
onSecondaryTapUp: (event) async {
@@ -242,70 +340,35 @@ class _SuperTabRosterState extends State<SuperTabRoster> {
size: 24,
),
const SizedBox(width: 8),
- Expanded(
- child: Row(
- children: [
- Flexible(
- child: Text(
- name,
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: DesktopChrome.control(),
- ),
- ),
- const SizedBox(width: 6),
- Semantics(
- label: c.snapshot!.isLead(agent.id)
- ? 'Product Manager'
- : agent.isReviewer
- ? 'Reviewer'
- : 'Engineer',
- excludeSemantics: true,
- child: Container(
- padding: const EdgeInsets.symmetric(
- horizontal: 5,
- vertical: 1,
- ),
- decoration: BoxDecoration(
- color: grid.AppSurface.hoverFill,
- borderRadius: BorderRadius.circular(4),
- ),
- child: Text(
- c.snapshot!.isLead(agent.id)
- ? 'PM'
- : agent.isReviewer
- ? 'Rev'
- : 'Dev',
- style: DesktopChrome.metadata(),
- ),
- ),
- ),
- ],
- ),
- ),
- const SizedBox(width: 8),
- ActivityMark(
- activity: activity,
- tooltip: false,
- color: activityColor(
- activity,
- theme,
- color: appearancePrefsStore.value.prompt.color,
- ),
- ),
+ Expanded(child: _agentIdentity(name, role, badge, project?.name)),
],
),
- subtitle: project == null
- ? null
- : Padding(
- padding: const EdgeInsets.only(left: 32),
+ subtitle: Padding(
+ padding: const EdgeInsets.only(left: 32),
+ child: Row(
+ children: [
+ ActivityMark(
+ activity: activity,
+ tooltip: false,
+ showIdle: true,
+ color: activityColor(
+ activity,
+ theme,
+ color: appearancePrefsStore.value.prompt.color,
+ ),
+ ),
+ const SizedBox(width: 6),
+ Expanded(
child: Text(
- project.name,
+ status,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: DesktopChrome.metadata(),
),
),
+ ],
+ ),
+ ),
onTap: () => unawaited(_details(agent)),
onLongPress: () => unawaited(_details(agent)),
),
@@ -315,15 +378,9 @@ class _SuperTabRosterState extends State<SuperTabRoster> {
List<Widget> _members() {
final state = c.snapshot;
- final projectId = c.selected?.projectId;
- final members =
- state?.agents
- .where(
- (agent) =>
- projectId != null && _agentProjectId(agent) == projectId,
- )
- .toList() ??
- const <SuperTabAgent>[];
+ // The backend already scopes this snapshot to projects the person can
+ // access. Local machine inventory is not membership in this Swarm.
+ final members = state?.agents ?? const <SuperTabAgent>[];
final leads = members.where((a) => state!.isLead(a.id)).toList();
final agents = members.where((a) => !state!.isLead(a.id)).toList();
return [
diff --git a/desktop/lib/super_tabs/section_heading.dart b/desktop/lib/super_tabs/section_heading.dart
index 0eb4ac920..406f41eec 100644
--- a/desktop/lib/super_tabs/section_heading.dart
+++ b/desktop/lib/super_tabs/section_heading.dart
@@ -26,20 +26,19 @@ class SuperTabSectionHeading extends StatelessWidget {
final Widget? trailing;
/// Compact actions right before the add action, each an [AppIconButton]
- /// the size of the add action itself, such as Machines' Your devices.
+ /// the size of the add action itself.
final List<Widget> actions;
- /// The space after the last action. The left sidebar passes 0, so that
- /// its + is centered on the column of its rows' trailing dots
- /// ([ProjectSidebar.markerInset]).
+ /// The space after the last action. The left sidebar passes 0 to align +
+ /// with its rows' trailing disclosure controls.
final double endInset;
/// Whether a collapsible group's body is currently hidden. Ignored unless
/// [onToggleCollapsed] is set.
final bool? collapsed;
- /// Set on a heading that collapses a sidebar group; draws a leading chevron
- /// that toggles it, aligned with the icon column project/machine rows share.
+ /// Set on a heading that collapses a sidebar group; its label and an adjacent
+ /// trailing chevron form one button on the left of the heading.
final VoidCallback? onToggleCollapsed;
/// The chevron and every action are a fixed 32 px square; the gap
@@ -47,19 +46,17 @@ class SuperTabSectionHeading extends StatelessWidget {
/// much room, even when the trailing pill is at its widest.
static const actionWidth = 32.0;
- /// One step of the sidebar's tree: a group's rows sit one step in from its heading, and the rows under one
- /// of those (a project's workgroups, the offline machines) two.
+ /// Indentation for nested content outside the sidebar's flat navigation rows.
static const indentStep = 16.0;
- /// Where a collapsible heading's chevron column starts.
+ /// Shared left inset of sidebar icon columns and section labels.
static const _leadingInset = 4.0;
- /// Where the icon column of a row at [level] starts, from the row's leading edge; its text starts right
- /// after that 32 px column, as the heading's does. Level 0 is the heading's own.
+ /// The sidebar uses level 0 for every row, so names remain aligned. Higher
+ /// levels remain available for other nested content.
static double indentFor(int level) => _leadingInset + level * indentStep;
static const _trailingGap = 4.0;
- static const _minTitleWidth = 40.0;
@override
Widget build(BuildContext context) {
@@ -75,55 +72,76 @@ class SuperTabSectionHeading extends StatelessWidget {
constraints: const BoxConstraints(minHeight: 32),
child: LayoutBuilder(
builder: (context, constraints) {
- // A plain (non-flex) child, so it keeps its natural width right
- // before the add action instead of splitting the row's free
- // space with the title — capped only so a narrow drawer at a
- // large text scale ellipsizes it instead of overflowing.
+ final titleStyle = DesktopChrome.metadata().copyWith(
+ fontWeight: FontWeight.w600,
+ );
+ final titleMeasure = TextPainter(
+ text: TextSpan(text: title, style: titleStyle),
+ textDirection: Directionality.of(context),
+ textScaler: MediaQuery.textScalerOf(context),
+ maxLines: 1,
+ )..layout();
+ final titleWidth =
+ titleMeasure.width +
+ (collapsible ? AppIcons.inlineSize + _trailingGap : 0);
+ titleMeasure.dispose();
+ // Keep the heading readable before allowing a status pill to grow.
+ // At narrow widths the pill can reduce to its icon and tooltip.
final pillMaxWidth = trailing == null
? 0.0
: (constraints.maxWidth -
- (collapsible ? actionWidth : 0) -
actions.length * actionWidth -
(onAdd != null ? actionWidth : 0) -
_trailingGap -
- _minTitleWidth)
+ titleWidth)
.clamp(0.0, double.infinity);
+ final titleLabel = Text(
+ title,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: titleStyle,
+ );
return Row(
children: [
- if (collapsible)
- IconButton(
- icon: Icon(
- collapsed == true
- ? AppIcons.chevronRight
- : AppIcons.chevronDown,
- size: AppIcons.inlineSize,
- ),
- color: DesktopChrome.muted,
- // The row owns hover/press feedback. Keep the themed
- // focus boundary for this independent disclosure action.
- style: const ButtonStyle(
- minimumSize: WidgetStatePropertyAll(Size.square(32)),
- padding: WidgetStatePropertyAll(EdgeInsets.all(6)),
- tapTargetSize: MaterialTapTargetSize.shrinkWrap,
- visualDensity: VisualDensity.standard,
- overlayColor: WidgetStatePropertyAll(Colors.transparent),
- backgroundColor: WidgetStatePropertyAll(
- Colors.transparent,
- ),
- ),
- tooltip:
- '${collapsed == true ? 'Expand' : 'Collapse'} $title',
- onPressed: onToggleCollapsed,
- ),
Expanded(
- child: Text(
- title,
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: DesktopChrome.metadata().copyWith(
- fontWeight: FontWeight.w600,
- ),
- ),
+ child: collapsible
+ ? Align(
+ alignment: Alignment.centerLeft,
+ child: Semantics(
+ button: true,
+ expanded: collapsed != true,
+ child: Tooltip(
+ message:
+ '${collapsed == true ? 'Expand' : 'Collapse'} $title',
+ child: InkWell(
+ onTap: onToggleCollapsed,
+ borderRadius: BorderRadius.circular(
+ DesktopChrome.rowRadius,
+ ),
+ child: ConstrainedBox(
+ constraints: const BoxConstraints(
+ minHeight: 32,
+ ),
+ child: Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Flexible(child: titleLabel),
+ const SizedBox(width: _trailingGap),
+ Icon(
+ collapsed == true
+ ? AppIcons.chevronRight
+ : AppIcons.chevronDown,
+ size: AppIcons.inlineSize,
+ color: DesktopChrome.muted,
+ ),
+ ],
+ ),
+ ),
+ ),
+ ),
+ ),
+ )
+ : titleLabel,
),
if (trailing != null) ...[
ConstrainedBox(
diff --git a/desktop/lib/super_tabs/view.dart b/desktop/lib/super_tabs/view.dart
index c73b9f46e..2f423de18 100644
--- a/desktop/lib/super_tabs/view.dart
+++ b/desktop/lib/super_tabs/view.dart
@@ -86,6 +86,10 @@ class _SuperTabViewState extends State<SuperTabView>
String? _completionPrefix;
final _completionKeys = List.generate(6, (_) => GlobalKey());
SuperTabController get c => widget.controller;
+ bool get _devicesVisible =>
+ c.devicesSelected &&
+ widget.app?.devicesEnabled == true &&
+ !c.accessRevoked;
String _agentName(SuperTabAgent agent) =>
c.snapshot?.agentName(agent.id, fallback: agent.name) ?? agent.name;
@@ -231,6 +235,7 @@ class _SuperTabViewState extends State<SuperTabView>
!_viewEnabled ||
_chatCovered ||
c.accessRevoked ||
+ _devicesVisible ||
_terminalsVisible ||
_showPullRequests) {
return false;
@@ -453,13 +458,19 @@ class _SuperTabViewState extends State<SuperTabView>
void _closeRoster() {
setState(() => _rosterOpen = false);
- if (!_terminalsVisible) _focus.requestFocus();
+ if (!_terminalsVisible && !_devicesVisible) _focus.requestFocus();
}
void _closeSidebar() {
setState(() => _sidebarOpen = false);
WidgetsBinding.instance.addPostFrameCallback((_) {
- if (mounted && !_sidebarOpen) _focus.requestFocus();
+ if (mounted &&
+ !_sidebarOpen &&
+ !_devicesVisible &&
+ !_terminalsVisible &&
+ !_showPullRequests) {
+ _focus.requestFocus();
+ }
});
}
@@ -687,6 +698,12 @@ class _SuperTabViewState extends State<SuperTabView>
app: widget.app,
onAddAgent: widget.onAddAgent,
onNewProject: widget.onNewProject,
+ devicesSelected: _devicesVisible,
+ onOpenAgent: (agent) {
+ _closeSidebar();
+ setState(() => _showPullRequests = false);
+ (widget.onChooseAgentTerminal ?? widget.onOpenTerminal)(agent);
+ },
onYourDevices: widget.app?.devicesEnabled != true
? null
: () {
@@ -722,7 +739,7 @@ class _SuperTabViewState extends State<SuperTabView>
}
void _leaveResize() {
- if (_terminalsVisible) {
+ if (_terminalsVisible || _devicesVisible) {
FocusManager.instance.primaryFocus?.unfocus();
final app = widget.app, paneId = widget.app?.focusedPaneId;
if (app != null && paneId != null) app.focusPane(paneId, reveal: true);
@@ -734,7 +751,7 @@ class _SuperTabViewState extends State<SuperTabView>
}
bool get _terminalsVisible =>
- widget.terminalsVisible || widget.terminal != null;
+ !_devicesVisible && (widget.terminalsVisible || widget.terminal != null);
Widget _header(SuperTabConversation? group, bool narrow, bool showRoster) =>
Container(
@@ -759,7 +776,9 @@ class _SuperTabViewState extends State<SuperTabView>
mainAxisSize: MainAxisSize.min,
children: [
Text(
- group == null
+ _devicesVisible
+ ? 'Your devices'
+ : group == null
? c.snapshot?.projects.isEmpty == true
? c.snapshot!.name
: 'Choose a project'
@@ -770,19 +789,20 @@ class _SuperTabViewState extends State<SuperTabView>
overflow: TextOverflow.ellipsis,
style: DesktopChrome.text(medium: true),
),
- if (c.reviewLine(group) case final line?)
- Text(
- line,
- key: const ValueKey('super-review-line'),
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: DesktopChrome.metadata(),
- ),
+ if (!_devicesVisible)
+ if (c.reviewLine(group) case final line?)
+ Text(
+ line,
+ key: const ValueKey('super-review-line'),
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: DesktopChrome.metadata(),
+ ),
],
),
),
),
- if (group != null) ...[
+ if (group != null && !_devicesVisible) ...[
AppIconButton(
key: const ValueKey('super-chat'),
icon: AppIcons.messageSquare,
@@ -1596,7 +1616,9 @@ class _SuperTabViewState extends State<SuperTabView>
_header(c.selected, narrow, showRoster),
Expanded(
child: IndexedStack(
- index: c.snapshot?.projects.isEmpty == true
+ index: _devicesVisible
+ ? 1
+ : c.snapshot?.projects.isEmpty == true
? 0
: _terminalsVisible
? 1
diff --git a/desktop/lib/super_tabs/workspace.dart b/desktop/lib/super_tabs/workspace.dart
index 19180b0e2..e8473391a 100644
--- a/desktop/lib/super_tabs/workspace.dart
+++ b/desktop/lib/super_tabs/workspace.dart
@@ -75,10 +75,14 @@ class _SuperTabWorkspaceState extends State<SuperTabWorkspace> {
}
void _syncTerminal(SuperTabController controller, String swarmId) {
+ final devices =
+ controller.devicesSelected &&
+ app.devicesEnabled &&
+ !controller.accessRevoked;
final agents = controller.terminalAgents(controller.selectedId);
final request = (
swarmId,
- controller.selectedId,
+ devices ? r'$devices' : controller.selectedId,
agents.isEmpty
? null
: agents
@@ -87,7 +91,7 @@ class _SuperTabWorkspaceState extends State<SuperTabWorkspace> {
final native = machine?.agents
.where((n) => n.id == a.harnessId)
.firstOrNull;
- return '${a.id}:${native?.isStopped}:${machine?.connectionStatus}:${native != null}';
+ return '${a.id}:${a.harnessId}:${native?.isStopped}:${machine?.connectionStatus}:${native != null}';
})
.join(','),
controller.accountId,
@@ -105,6 +109,10 @@ class _SuperTabWorkspaceState extends State<SuperTabWorkspace> {
mounted &&
_terminalRequest == request &&
app.activeSwarmId == swarmId &&
+ (controller.devicesSelected &&
+ app.devicesEnabled &&
+ !controller.accessRevoked) ==
+ devices &&
app.currentUser?.id == controller.accountId &&
controller.canWrite == request.$5;
// Native attachment may wait for machine discovery. Serialize replacements
@@ -115,7 +123,16 @@ class _SuperTabWorkspaceState extends State<SuperTabWorkspace> {
) async {
if (!current()) return;
final tab = app.swarms.where((s) => s.id == swarmId).firstOrNull;
- for (final pane in tab?.panes.toList() ?? const <TerminalPane>[]) {
+ // Closing a terminal also removes its owned viewer. Do that first so
+ // navigation never records a web/Finder preview as manually dismissed.
+ final oldPanes = tab?.panes.toList() ?? <TerminalPane>[];
+ oldPanes.sort(
+ (a, b) => (a.isViewer ? 1 : 0).compareTo(b.isViewer ? 1 : 0),
+ );
+ for (final pane in oldPanes) {
+ // Keep only the dashboard when revisiting Devices, also removing
+ // the chat slot or session restored from its former split layout.
+ if (devices && pane.isDevices) continue;
if (!agents.any(
(a) => a.machineId == pane.machineId && a.harnessId == pane.agentId,
)) {
@@ -123,6 +140,12 @@ class _SuperTabWorkspaceState extends State<SuperTabWorkspace> {
await app.closePane(pane.id, swarmId: swarmId);
}
}
+ if (devices) {
+ if (!current()) return;
+ app.prepareSuperTabDevices(swarmId);
+ setState(() => _readyRequest = request);
+ return;
+ }
for (final agent in agents) {
if (!current()) return;
await _open(
@@ -397,9 +420,13 @@ class _SuperTabWorkspaceState extends State<SuperTabWorkspace> {
builder: (context, _) {
_syncTerminal(controller, tab.id);
final agents = controller.terminalAgents(controller.selectedId);
+ final devices =
+ controller.devicesSelected &&
+ app.devicesEnabled &&
+ !controller.accessRevoked;
final showTerminal =
_readyRequest == _terminalRequest &&
- agents.isNotEmpty &&
+ (devices || agents.isNotEmpty) &&
tab.panes.isNotEmpty;
// The terminal canvas is mounted either way; whether a person can see it is this.
WidgetsBinding.instance.addPostFrameCallback((_) {
@@ -476,7 +503,7 @@ class _SuperTabWorkspaceState extends State<SuperTabWorkspace> {
'Offline machine',
terminal: showTerminal
? terminal
- : agents.isNotEmpty
+ : devices || agents.isNotEmpty
? const Center(child: CircularProgressIndicator())
: null,
onCloseTerminal: () {
diff --git a/desktop/lib/widgets/harness_activity_mark.dart b/desktop/lib/widgets/harness_activity_mark.dart
index 93f2fc0e8..7b888af54 100644
--- a/desktop/lib/widgets/harness_activity_mark.dart
+++ b/desktop/lib/widgets/harness_activity_mark.dart
@@ -110,11 +110,14 @@ class ActivityMark extends StatefulWidget {
this.visible = true,
this.emphasized = false,
this.tooltip = true,
+ this.showIdle = false,
this.clock,
});
final HarnessActivity activity;
final Color color;
final bool visible, emphasized, tooltip;
+ // Rows with an explicit status line need a visible mark for every state.
+ final bool showIdle;
final ActivityClock? clock;
@override
@@ -170,6 +173,8 @@ class _ActivityMarkState extends State<ActivityMark> {
Widget build(BuildContext context) {
final mark = _listening
? activitySpinnerFrames[clock.frame]
+ : widget.showIdle && widget.activity == HarnessActivity.idle
+ ? '○'
: widget.activity.mark;
final cell = workspaceBarCellSizeOf(context);
final style =
diff --git a/desktop/test/devices_harness_test.dart b/desktop/test/devices_harness_test.dart
index e8fc7acb1..eae8ba035 100644
--- a/desktop/test/devices_harness_test.dart
+++ b/desktop/test/devices_harness_test.dart
@@ -5,22 +5,25 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:harness/core/engine_availability.dart';
import 'package:harness/core/models.dart';
import 'package:harness/devices/devices_harness_controller.dart';
-import 'package:harness/settings/experimental_features.dart';
import 'package:harness/state/app_state.dart';
import 'package:harness/state/pane_arrangement.dart';
+import 'package:harness/state/swarm.dart';
+import 'package:harness/super_tabs/controller.dart';
import 'package:harness/ws/ws_conn.dart';
import 'experimental_features_test.dart' show AccountSettings;
import 'support/model_manager.dart';
+import 'support/super_tab_fixture.dart';
+import 'swarm_state_test.dart' show MemoryStore;
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
late _DevicesConnection connection;
- late ModelManagerTestApp app;
+ late _DevicesTestApp app;
late DevicesHarnessController devices;
setUp(() async {
connection = _DevicesConnection();
- app = ModelManagerTestApp(connection);
+ app = _DevicesTestApp(connection);
app.stateOf('m')!.engines.replace([
const EngineAvailability(engine: 'codex', installed: true),
]);
@@ -38,6 +41,20 @@ void main() {
app.dispose();
});
+ Future<({Swarm tab, SuperTabController controller})> embeddedDevices() async {
+ const id = '0123456789abcdef01234567';
+ connection.server.state['id'] = id;
+ final tab = Swarm(id: 'embedded', name: 'Team', kind: 'superTab')
+ ..superTabId = id;
+ app.swarms.add(tab);
+ app.selectSwarm(tab.id);
+ final controller = await app.superTabs.open(id);
+ await controller.refresh();
+ controller.selectDevices();
+ app.prepareSuperTabDevices(tab.id);
+ return (tab: tab, controller: controller);
+ }
+
test(
'missing bundle keeps chat at 30 percent and recovers in the same tab',
() async {
@@ -149,36 +166,165 @@ void main() {
expect(app.panes, hasLength(2));
},
);
+ test('an account switch during creation cannot attach the old conversation', () async {
+ connection.holdCreation = Completer<void>();
+ final opening = devices.open();
+ await Future<void>.delayed(Duration.zero);
+ app.currentUser = const CurrentUserProfile(
+ id: 'b',
+ email: '[email protected]',
+ );
+ connection.holdCreation!.complete();
+ await opening;
+ // Devices is not an account opt-in, so its tab may stay; the old account's
+ // conversation must not be attached to it.
+ expect(app.allPanes.where((pane) => pane.agentId == 'manager'), isEmpty);
+ await devices.open();
+ expect(connection.creations.length, lessThanOrEqualTo(1));
+ });
+
test(
- 'an account switch during creation cannot attach the old conversation',
+ 'an open requested for a new account while creation is pending completes '
+ 'without attaching the old receipt',
() async {
+ connection.uniqueAgentIds = true;
connection.holdCreation = Completer<void>();
- final opening = devices.open();
+ final previousTab = app.activeSwarm;
+ final first = devices.open();
await Future<void>.delayed(Duration.zero);
+ expect(connection.creations, hasLength(1));
+
app.currentUser = const CurrentUserProfile(
id: 'b',
);
+ // A newly signed-in computer has its own inventory. The old in-flight
+ // creation is still waiting on its original MachineState and receipt.
+ final previousMachine = app.stateOf('m')!;
+ app.machineStates['m'] = MachineState(previousMachine.machine)
+ ..localOnly = true
+ ..connectionStatus = ConnectionStatus.connected
+ ..agentLoadStatus = AgentLoadStatus.loaded
+ ..engines.replace([
+ const EngineAvailability(engine: 'codex', installed: true),
+ ]);
+ final second = devices.open(swarmId: previousTab.id);
connection.holdCreation!.complete();
- await opening;
- // Devices is not an account opt-in, so its tab may stay; the old account's
- // conversation must not be attached to it.
- expect(app.allPanes.where((pane) => pane.agentId == 'manager'), isEmpty);
- await devices.open();
- expect(connection.creations.length, lessThanOrEqualTo(1));
+ await Future.wait([first, second]);
+
+ expect(devices.error, isNull);
+ expect(devices.opening, isFalse);
+ expect(connection.creations, hasLength(2));
+ expect(
+ connection.creations.map((request) => request['creationId']).toSet(),
+ hasLength(2),
+ );
+ expect(app.attachments, [
+ (account: 'b', workspace: previousTab.id, agent: 'manager-2'),
+ ]);
+ expect(previousTab.panes.last.agentId, 'manager-2');
+ expect(
+ app.allPanes.where((pane) => pane.agentId == 'manager-1'),
+ isEmpty,
+ );
},
);
+
+ test('embedded Devices ignores a launch already pending for standalone '
+ 'Devices without retargeting its receipt', () async {
+ connection.holdCreation = Completer<void>();
+ final previousTab = app.activeSwarm;
+ final first = devices.open();
+ await Future<void>.delayed(Duration.zero);
+ expect(connection.creations, hasLength(1));
+ final next = await embeddedDevices();
+ var finished = false;
+ final second = devices
+ .open(swarmId: next.tab.id)
+ .then((_) => finished = true);
+ await Future<void>.delayed(Duration.zero);
+ expect(finished, isTrue);
+ connection.holdCreation!.complete();
+ await Future.wait([first, second]);
+
+ expect(devices.error, isNull);
+ expect(connection.creations, hasLength(1));
+ expect(app.attachments, [
+ (account: 'a', workspace: previousTab.id, agent: 'manager'),
+ ]);
+ expect(previousTab.panes.last.agentId, 'manager');
+ expect(next.tab.panes, hasLength(1));
+ expect(next.tab.panes.single.isDevices, isTrue);
+ expect(next.tab.panes.single.ownerAgentId, isNull);
+ expect(app.activeSwarm, same(next.tab));
+ });
+
+ for (final existingConversation in [false, true]) {
+ test('embedded Devices never probes, starts or reuses a conversation '
+ '(existing standalone conversation: $existingConversation)', () async {
+ final standalone = app.activeSwarm;
+ if (existingConversation) await devices.open();
+ final next = await embeddedDevices();
+ connection.requests.clear();
+ final before = app.attachments.toList();
+ await devices.open(swarmId: next.tab.id);
+ expect(connection.requests, isEmpty);
+ expect(connection.creations, hasLength(existingConversation ? 1 : 0));
+ expect(app.resumes, 0);
+ expect(app.attachments, before);
+ expect(next.tab.panes, hasLength(1));
+ expect(next.tab.panes.single.isDevices, isTrue);
+ expect(next.tab.panes.single.ownerAgentId, isNull);
+ await app.showDevicesTerminal('m', 'manager', swarmId: next.tab.id);
+ expect(next.tab.panes, hasLength(1));
+ expect(next.tab.panes.single.agentId, isNull);
+ expect(next.tab.panes.single.ownerAgentId, isNull);
+ expect(standalone.panes, hasLength(2));
+ expect(
+ standalone.panes.last.agentId,
+ existingConversation ? 'manager' : null,
+ );
+ expect(app.activeSwarm, same(next.tab));
+ });
+ }
+}
+
+class _DevicesTestApp extends ModelManagerTestApp {
+ _DevicesTestApp(super.connection);
+
+ @override
+ final localStore = MemoryStore();
+
+ final attachments = <({String? account, String? workspace, String agent})>[];
+
+ @override
+ Future<void> showDevicesTerminal(
+ String machineId,
+ String agentId, {
+ String? swarmId,
+ }) async {
+ attachments.add((
+ account: currentUser?.id,
+ workspace: swarmId,
+ agent: agentId,
+ ));
+ await super.showDevicesTerminal(machineId, agentId, swarmId: swarmId);
+ }
}
class _DevicesConnection extends ModelManagerConnection {
String? refusal;
+ bool uniqueAgentIds = false;
+ final requests = <String>[];
+ final server = ConversationServer();
@override
Future<Map<String, dynamic>> request(
String type, {
Map<String, dynamic> payload = const {},
Duration timeout = const Duration(seconds: 20),
- }) {
+ }) async {
+ requests.add(type);
if (type == 'agent_create' && refusal != null) {
throw WsRequestFailure(
responseType: 'agent_create_result',
@@ -186,6 +332,26 @@ class _DevicesConnection extends ModelManagerConnection {
detail: 'autonomous/devices is not installed on this machine',
);
}
- return super.request(type, payload: payload, timeout: timeout);
+ if (type == 'super_tabs') {
+ return {
+ 'ok': true,
+ 'value': await server.request(
+ payload['method'] as String,
+ payload['path'] as String,
+ body: payload['body'] as Map<String, dynamic>?,
+ ),
+ };
+ }
+ final reply = await super.request(type, payload: payload, timeout: timeout);
+ if (uniqueAgentIds && reply['agent'] is Map) {
+ final index = creations.indexWhere(
+ (request) => request['creationId'] == payload['creationId'],
+ );
+ return {
+ ...reply,
+ 'agent': {...reply['agent'] as Map, 'id': 'manager-${index + 1}'},
+ };
+ }
+ return reply;
}
}
diff --git a/desktop/test/own_binding/connected_semantics_test.dart b/desktop/test/own_binding/connected_semantics_test.dart
index 924af3216..21ec883df 100644
--- a/desktop/test/own_binding/connected_semantics_test.dart
+++ b/desktop/test/own_binding/connected_semantics_test.dart
@@ -2,6 +2,7 @@ import 'dart:ui' as ui;
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
+import 'package:flutter/semantics.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:harness/core/connected_semantics.dart';
@@ -9,10 +10,11 @@ class _Binding extends AutomatedTestWidgetsFlutterBinding
with ConnectedSemanticsBinding {
bool guarded = true;
final batches = <Map<int, Map<Symbol, dynamic>>>[];
+ final customActions = <int, Map<Symbol, dynamic>>{};
@override
ui.SemanticsUpdateBuilder createPlatformSemanticsUpdateBuilder() =>
- _RecordingBuilder(batches);
+ _RecordingBuilder(batches, customActions);
@override
ui.SemanticsUpdateBuilder createSemanticsUpdateBuilder() => guarded
@@ -21,8 +23,9 @@ class _Binding extends AutomatedTestWidgetsFlutterBinding
}
class _RecordingBuilder implements ui.SemanticsUpdateBuilder {
- _RecordingBuilder(this.batches);
+ _RecordingBuilder(this.batches, this.customActions);
final List<Map<int, Map<Symbol, dynamic>>> batches;
+ final Map<int, Map<Symbol, dynamic>> customActions;
final nodes = <int, Map<Symbol, dynamic>>{};
final delegate = ui.SemanticsUpdateBuilder();
@@ -33,6 +36,9 @@ class _RecordingBuilder implements ui.SemanticsUpdateBuilder {
nodes[call.namedArguments[#id] as int] = Map.of(call.namedArguments);
return Function.apply(delegate.updateNode, [], call.namedArguments);
case #updateCustomAction:
+ customActions[call.namedArguments[#id] as int] = Map.of(
+ call.namedArguments,
+ );
return Function.apply(
delegate.updateCustomAction,
[],
@@ -111,6 +117,7 @@ void main() {
setUp(() {
binding.guarded = true;
binding.batches.clear();
+ binding.customActions.clear();
});
tearDown(() {
debugDefaultTargetPlatformOverride = null;
@@ -260,6 +267,135 @@ void main() {
}
});
+ for (final (changeWhileDisabled, disableBeforeFrame) in [
+ (false, false),
+ (true, false),
+ (false, true),
+ ]) {
+ axTest('a fresh native bridge receives the retained semantics tree '
+ '(change while disabled: $changeWhileDisabled, '
+ 'disable before frame: $disableBeforeFrame)', (tester) async {
+ final semantics = tester.ensureSemantics();
+ final label = ValueNotifier('Initial activity');
+ const activityKey = ValueKey('retained-activity');
+ const controlKey = ValueKey('retained-control');
+ try {
+ tester.platformDispatcher.semanticsEnabledTestValue = true;
+ await tester.pumpWidget(
+ MaterialApp(
+ home: Scaffold(
+ body: Column(
+ children: [
+ Semantics(
+ key: controlKey,
+ container: true,
+ label: 'Unchanged control',
+ button: true,
+ onTap: () {},
+ customSemanticsActions: {
+ const CustomSemanticsAction(label: 'Inspect task'): () {},
+ },
+ child: const SizedBox(width: 100, height: 40),
+ ),
+ ValueListenableBuilder(
+ valueListenable: label,
+ builder: (context, value, _) => Semantics(
+ key: activityKey,
+ container: true,
+ label: value,
+ child: const SizedBox(width: 100, height: 40),
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
+ );
+ await tester.pumpAndSettle();
+ expect(_disconnectedUpdates(binding.batches), isEmpty);
+ final root =
+ binding.renderViews.single.owner!.semanticsOwner!.rootSemanticsNode;
+ final controlId = tester.getSemantics(find.byKey(controlKey)).id;
+ final activityId = tester.getSemantics(find.byKey(activityKey)).id;
+
+ // Native disable destroys the bridge, but an outstanding framework
+ // handle keeps its owner, IDs and clean nodes alive. Any updates in
+ // this interval are dropped by native and must not count as delivered.
+ tester.platformDispatcher.semanticsEnabledTestValue = false;
+ if (changeWhileDisabled) label.value = 'Changed while disabled';
+ await tester.pumpAndSettle();
+ expect(binding.semanticsEnabled, isTrue);
+ expect(
+ binding.renderViews.single.owner!.semanticsOwner!.rootSemanticsNode,
+ same(root),
+ );
+ expect(tester.getSemantics(find.byKey(controlKey)).id, controlId);
+ expect(tester.getSemantics(find.byKey(activityKey)).id, activityId);
+
+ // Model a newly created, empty native tree. No widget changes are
+ // needed to trigger a full replay when the platform enables semantics.
+ binding.batches.clear();
+ binding.customActions.clear();
+ if (disableBeforeFrame) {
+ tester.platformDispatcher.semanticsEnabledTestValue = true;
+ tester.platformDispatcher.semanticsEnabledTestValue = false;
+ await tester.pumpAndSettle();
+ expect(
+ binding.batches,
+ isEmpty,
+ reason:
+ 'A scheduled replay must not target a bridge disabled again',
+ );
+ }
+ tester.platformDispatcher.semanticsEnabledTestValue = true;
+ await tester.pumpAndSettle();
+ expect(
+ binding.batches,
+ isNotEmpty,
+ reason: 'A new native bridge needs the retained root and clean nodes',
+ );
+ expect(binding.batches.first, contains(0));
+ expect(_disconnectedUpdates(binding.batches), isEmpty);
+ final replayed = {for (final batch in binding.batches) ...batch};
+ expect(replayed[controlId]?[#label], 'Unchanged control');
+ expect(
+ replayed[controlId]?[#actions] & ui.SemanticsAction.tap.index,
+ isNonZero,
+ );
+ final customActionIds =
+ replayed[controlId]![#additionalActions] as List<int>;
+ expect(customActionIds, hasLength(1));
+ expect(
+ binding.customActions[customActionIds.single]?[#label],
+ 'Inspect task',
+ reason: 'A new native bridge needs the custom action definition too',
+ );
+ expect(
+ replayed[activityId]?[#label],
+ changeWhileDisabled ? 'Changed while disabled' : 'Initial activity',
+ );
+
+ // A later partial leaf update must attach to the replayed tree,
+ // rather than become a substitute native root.
+ label.value = 'Changed after enable';
+ await tester.pumpAndSettle();
+ expect(_disconnectedUpdates(binding.batches), isEmpty);
+ expect(
+ binding.batches.last[activityId]?[#label],
+ 'Changed after enable',
+ );
+ expect(binding.batches.last, isNot(contains(0)));
+ expect(binding.batches.last, isNot(contains(controlId)));
+ expect(tester.takeException(), isNull);
+ } finally {
+ tester.platformDispatcher.clearSemanticsEnabledTestValue();
+ semantics.dispose();
+ await tester.pumpWidget(const SizedBox());
+ label.dispose();
+ }
+ });
+ }
+
testWidgets('unaffected platforms retain the standard builder', (
tester,
) async {
diff --git a/desktop/test/super_tab_devices_geometry_test.dart b/desktop/test/super_tab_devices_geometry_test.dart
new file mode 100644
index 000000000..266e613a6
--- /dev/null
+++ b/desktop/test/super_tab_devices_geometry_test.dart
@@ -0,0 +1,126 @@
+import 'package:flutter/material.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:harness/state/app_state.dart';
+import 'package:harness/state/pane_arrangement.dart';
+import 'package:harness/widgets/pane_grid.dart';
+import 'package:harness/widgets/pane_resize_handle.dart';
+
+import 'super_tab_launch_test.dart' show SuperTabLaunchFixture, tabId;
+import 'support/super_tab_devices_fixture.dart';
+import 'swarm_screen_test.dart' show terminal;
+import 'swarm_state_test.dart' show createApp;
+
+const _viewportKey = ValueKey('devices-center-viewport');
+
+Future<void> _mount(WidgetTester tester, AppNotifier app) async {
+ await tester.binding.setSurfaceSize(const Size(700, 700));
+ addTearDown(() => tester.binding.setSurfaceSize(null));
+ await tester.pumpWidget(
+ MaterialApp(
+ home: Scaffold(
+ body: SizedBox.expand(
+ key: _viewportKey,
+ child: PaneGrid(
+ notifier: app,
+ swarmMode: true,
+ devicesViewer: (_) => const Center(child: Text('Devices')),
+ devicesConversation: (_) =>
+ const Center(child: Text('Device conversation')),
+ ),
+ ),
+ ),
+ ),
+ );
+ await tester.pumpAndSettle();
+}
+
+Future<SuperTabLaunchFixture> _embedded(WidgetTester tester) async {
+ final f = superTabDevicesFixture();
+ f.app.bindSuperTab(f.app.activeSwarmId, tabId, 'Company');
+ final c = await f.app.superTabs.open(tabId);
+ await c.refresh();
+ c.selectDevices();
+ f.app.prepareSuperTabDevices(f.app.activeSwarmId);
+ await _mount(tester, f.app);
+ return f;
+}
+
+ScrollController _horizontal(WidgetTester tester) => tester
+ .widgetList<SingleChildScrollView>(find.byType(SingleChildScrollView))
+ .singleWhere((view) => view.scrollDirection == Axis.horizontal)
+ .controller!;
+
+void _expectFits(WidgetTester tester, AppNotifier app) {
+ final viewport = tester.getRect(find.byKey(_viewportKey));
+ final frames = [
+ for (final pane in app.panes)
+ tester.getRect(find.byKey(ValueKey('pane-frame:${pane.id}'))),
+ ];
+ expect(frames, hasLength(1));
+ expect(frames.single, viewport);
+ expect(app.panes.single.isDevices, isTrue);
+ expect(find.byType(PaneResizeHandle), findsNothing);
+ expect(find.text('Device conversation'), findsNothing);
+ expect(_horizontal(tester).position.maxScrollExtent, closeTo(0, .01));
+ expect(_horizontal(tester).offset, closeTo(0, .01));
+ expect(tester.takeException(), isNull);
+}
+
+void main() {
+ testWidgets(
+ 'embedded Devices fills the center at narrow and wide sizes without a chat slot',
+ (tester) async {
+ final f = await _embedded(tester);
+ final panes = List.of(f.app.panes);
+ for (final width in [4000.0, 1000.0, 700.0, 500.0, 360.0]) {
+ await tester.binding.setSurfaceSize(Size(width, 700));
+ await tester.pumpAndSettle();
+ _expectFits(tester, f.app);
+ f.app.focusPane(panes.single.id, reveal: true);
+ await tester.pumpAndSettle();
+ _expectFits(tester, f.app);
+ }
+ expect(f.app.panes, panes);
+ await tester.pumpWidget(const SizedBox());
+ f.app.superTabs.dispose();
+ await tester.pump();
+ },
+ );
+
+ testWidgets('regular terminal splits retain their minimum and scroll', (
+ tester,
+ ) async {
+ final app = createApp(connected: true);
+ addTearDown(app.dispose);
+ for (var i = 0; i < 2; i++) {
+ app.adoptSessionForTest(terminal('a$i', []));
+ }
+ app.activeSwarm.savePaneSizes(
+ '2:manual',
+ PaneArrangement.viewerBesideTerminal,
+ );
+ await _mount(tester, app);
+ expect(app.activeSwarm.isSuperTab, isFalse);
+ expect(_horizontal(tester).position.maxScrollExtent, greaterThan(0));
+ final right = tester.getRect(
+ find.byKey(ValueKey('pane-frame:${app.panes.last.id}')),
+ );
+ expect(right.width, greaterThan(700 * .3));
+ expect(tester.takeException(), isNull);
+ await tester.pumpWidget(const SizedBox());
+ });
+
+ testWidgets('standalone Devices keeps the existing terminal floor', (
+ tester,
+ ) async {
+ final app = createApp();
+ addTearDown(app.dispose);
+ app.openDevices();
+ await _mount(tester, app);
+ expect(app.activeSwarm.isDevices, isTrue);
+ expect(app.activeSwarm.isSuperTab, isFalse);
+ expect(_horizontal(tester).position.maxScrollExtent, greaterThan(0));
+ expect(tester.takeException(), isNull);
+ await tester.pumpWidget(const SizedBox());
+ });
+}
diff --git a/desktop/test/super_tab_devices_preview_test.dart b/desktop/test/super_tab_devices_preview_test.dart
new file mode 100644
index 000000000..068ca3b6c
--- /dev/null
+++ b/desktop/test/super_tab_devices_preview_test.dart
@@ -0,0 +1,233 @@
+import 'package:flutter/material.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:harness/core/models.dart';
+import 'package:harness/finder/finder_roots.dart';
+import 'package:harness/state/pane_arrangement.dart';
+import 'package:harness/state/terminal_pane.dart';
+import 'package:harness/super_tabs/controller.dart';
+import 'package:harness/super_tabs/workspace.dart';
+
+import 'super_tab_launch_test.dart' show SuperTabLaunchFixture, tabId;
+import 'support/super_tab_devices_fixture.dart';
+
+const _viewerUrl = 'http://127.0.0.1:19679/project-preview';
+const _finderRoot = '/work/project/assets';
+
+Future<(SuperTabLaunchFixture, SuperTabController)> _mount(
+ WidgetTester tester, {
+ bool web = false,
+ bool finder = false,
+ int agents = 1,
+ bool legacyDevices = false,
+}) async {
+ await tester.binding.setSurfaceSize(const Size(1440, 900));
+ addTearDown(() => tester.binding.setSurfaceSize(null));
+ final f = superTabDevicesFixture();
+ f.app.bindSuperTab(f.app.activeSwarmId, tabId, 'Company');
+ final state = f.connection.server.state;
+ state['agents'] = [
+ for (var i = 0; i < agents; i++)
+ {
+ 'id': 'agent-$i',
+ 'name': 'Engineer $i',
+ 'machineId': 'm',
+ 'harnessId': 'native-$i',
+ 'contributorId': 'owner',
+ 'configuration': {'engine': 'codex'},
+ },
+ ];
+ (state['conversations'] as List)[0]['agentIds'] = [
+ for (var i = 0; i < agents; i++) 'agent-$i',
+ ];
+ f.app.machineStates['m']!.agents = [
+ for (var i = 0; i < agents; i++)
+ Agent.fromJson({
+ 'id': 'native-$i',
+ 'name': 'Engineer $i',
+ 'engine': 'codex',
+ // Navigation must preserve a viewer without restarting its agent.
+ 'status': 'stopped',
+ 'sessionId': 'saved-$i',
+ 'terminal': {'available': false},
+ if (web && i == 0) ...{
+ 'dsh': 'autonomous/web-viewer',
+ 'viewerUrl': _viewerUrl,
+ },
+ }),
+ ];
+ if (finder) f.app.finderRoots.set('m', 'native-0', _finderRoot);
+ final c = await f.app.superTabs.open(tabId);
+ await c.refresh();
+ c.selectGroupTerminals('lead');
+ if (legacyDevices) {
+ final tab = f.app.activeSwarm;
+ tab.panes
+ ..clear()
+ ..addAll([
+ TerminalPane(
+ id: 10001,
+ machineId: 'm',
+ kind: PaneKind.devices,
+ ownerAgentId: 'old-devices-chat',
+ ),
+ TerminalPane(id: 10002, machineId: 'm', agentId: 'old-devices-chat'),
+ ]);
+ tab
+ ..focusedPaneId = 10002
+ ..zoomedPaneId = 10002;
+ tab.paneSizes['2:manual'] = PaneArrangement.viewerBesideTerminal;
+ c.selectDevices();
+ }
+ await tester.pumpWidget(
+ MaterialApp(
+ home: Scaffold(
+ body: ListenableBuilder(
+ listenable: f.app,
+ builder: (_, _) => SuperTabWorkspace(
+ app: f.app,
+ onAddAgent: (_) {},
+ // These are navigation/lifetime checks: avoid creating a platform
+ // webview or terminal renderer, while exercising real pane state.
+ canvas: const SizedBox.expand(),
+ ),
+ ),
+ ),
+ ),
+ );
+ await tester.pumpAndSettle();
+ return (f, c);
+}
+
+Future<void> _dispose(
+ WidgetTester tester,
+ SuperTabLaunchFixture f,
+ SuperTabController c,
+) async {
+ await tester.pumpWidget(const SizedBox());
+ await c.flush();
+ f.app.superTabs.dispose();
+ await tester.pump();
+}
+
+void main() {
+ for (final kind in ['web', 'Finder']) {
+ testWidgets('$kind viewer survives repeated Devices round trips', (
+ tester,
+ ) async {
+ final finder = kind == 'Finder';
+ final (f, c) = await _mount(tester, web: !finder, finder: finder);
+ final tab = f.app.activeSwarm;
+ final tabs = f.app.swarms.map((tab) => tab.id).toList();
+ void expectPreview() {
+ expect(tab.panes, hasLength(2));
+ final preview = tab.panes.singleWhere((pane) => pane.isViewer);
+ final terminal = tab.panes.singleWhere((pane) => !pane.isViewer);
+ expect(preview.viewsAgent('m', 'native-0'), isTrue);
+ expect(terminal.agentId, 'native-0');
+ if (finder) {
+ expect(preview.isFinder, isTrue);
+ expect(preview.finderRoot, _finderRoot);
+ expect(f.app.finderRoots.rootOf('m', 'native-0'), _finderRoot);
+ } else {
+ expect(preview.isWeb, isTrue);
+ expect(preview.url, _viewerUrl);
+ }
+ }
+
+ expectPreview();
+ for (var visit = 0; visit < 2; visit++) {
+ await tester.tap(find.byKey(const ValueKey('super-your-devices')));
+ await tester.pumpAndSettle();
+ expect(c.devicesSelected, isTrue);
+ expect(f.app.activeSwarm, same(tab));
+ expect(tab.panes, hasLength(1));
+ expect(tab.panes.where((pane) => pane.isDevices), hasLength(1));
+ expect(tab.panes.where((pane) => pane.isWeb || pane.isFinder), isEmpty);
+ if (finder) {
+ // Closing a Finder itself forgets this. Visiting Devices must not.
+ expect(f.app.finderRoots.rootOf('m', 'native-0'), _finderRoot);
+ final persisted = FinderRoots(() => f.store);
+ await persisted.load();
+ expect(persisted.rootOf('m', 'native-0'), _finderRoot);
+ }
+ await tester.tap(find.byKey(const ValueKey('super-group-lead')));
+ await tester.pumpAndSettle();
+ expect(c.devicesSelected, isFalse);
+ expectPreview();
+ expect(f.app.swarms.map((tab) => tab.id), tabs);
+ }
+ expect(
+ f.connection.calls.where(
+ (call) => call.$1 == 'agent_create' || call.$1 == 'agent_resume',
+ ),
+ isEmpty,
+ );
+ expect(tester.takeException(), isNull);
+ await _dispose(tester, f, c);
+ });
+ }
+
+ testWidgets(
+ 'Devices stays one pane after visiting a resized two-agent workgroup',
+ (tester) async {
+ final (f, c) = await _mount(tester, agents: 2);
+ final tab = f.app.activeSwarm;
+ final resized = PaneArrangement(const [
+ Rect.fromLTRB(0, 0, .58, 1),
+ Rect.fromLTRB(.58, 0, 1, 1),
+ ]);
+ for (var visit = 0; visit < 2; visit++) {
+ tab.arrangedKey = '2:manual';
+ expect(f.app.resizePanes(tab.id, '2:manual', resized), isTrue);
+ expect(tab.manualLayout!.tiles, resized.tiles);
+ c.selectDevices();
+ await tester.pumpAndSettle();
+ expect(tab.panes, hasLength(1));
+ expect(tab.panes.single.isDevices, isTrue);
+ expect(tab.panes.single.ownerAgentId, isNull);
+ expect(tab.manualLayout, isNull);
+ c.select('lead');
+ await tester.pumpAndSettle();
+ expect(tab.panes.map((pane) => pane.agentId), ['native-0', 'native-1']);
+ }
+ expect(
+ f.connection.calls.where(
+ (call) => call.$1 == 'agent_create' || call.$1 == 'agent_resume',
+ ),
+ isEmpty,
+ );
+ await _dispose(tester, f, c);
+ },
+ );
+
+ testWidgets('a saved embedded chat split becomes one independent dashboard', (
+ tester,
+ ) async {
+ final (f, c) = await _mount(tester, agents: 2, legacyDevices: true);
+ final tab = f.app.activeSwarm;
+ expect(c.devicesSelected, isTrue);
+ expect(tab.panes, hasLength(1));
+ expect(tab.panes.single.isDevices, isTrue);
+ expect(tab.panes.single.agentId, isNull);
+ expect(tab.panes.single.ownerAgentId, isNull);
+ expect(tab.panes.single.machineId, isEmpty);
+ expect(tab.focusedPaneId, tab.panes.single.id);
+ expect(tab.zoomedPaneId, isNull);
+ expect(tab.manualLayout, isNull);
+ c.select('lead');
+ await tester.pumpAndSettle();
+ expect(tab.panes.map((pane) => pane.agentId), ['native-0', 'native-1']);
+ c.selectDevices();
+ await tester.pumpAndSettle();
+ expect(tab.panes, hasLength(1));
+ expect(tab.panes.single.isDevices, isTrue);
+ expect(
+ f.connection.calls.where(
+ (call) => call.$1 == 'agent_create' || call.$1 == 'agent_resume',
+ ),
+ isEmpty,
+ );
+ expect(tester.takeException(), isNull);
+ await _dispose(tester, f, c);
+ });
+}
diff --git a/desktop/test/super_tab_devices_test.dart b/desktop/test/super_tab_devices_test.dart
new file mode 100644
index 000000000..bb40f8a8e
--- /dev/null
+++ b/desktop/test/super_tab_devices_test.dart
@@ -0,0 +1,302 @@
+import 'dart:async';
+
+import 'package:flutter/material.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:harness/core/models.dart';
+import 'package:harness/devices/devices_harness_controller.dart';
+import 'package:harness/devices/devices_screen.dart';
+import 'package:harness/state/pane_arrangement.dart';
+import 'package:harness/super_tabs/controller.dart';
+import 'package:harness/super_tabs/workspace.dart';
+import 'package:harness/widgets/pane_grid.dart';
+
+import 'super_tab_launch_test.dart' show SuperTabLaunchFixture, tabId;
+import 'support/super_tab_fixture.dart';
+import 'support/super_tab_devices_fixture.dart';
+
+void main() {
+ test(
+ 'Devices and expanded machines restore only for their account and Swarm',
+ () async {
+ final server = ConversationServer();
+ server.state['agents'] = [
+ {
+ 'id': 'pm',
+ 'name': 'Atlas',
+ 'machineId': 'm',
+ 'harnessId': 'native-pm',
+ 'contributorId': 'owner',
+ 'configuration': {'engine': 'codex'},
+ },
+ ];
+ (server.state['conversations'] as List)[0]['agentIds'] = ['pm'];
+ final c = server.controller();
+ await c.refresh();
+ c.setDraft('lead', 'Keep discussing this project.');
+ c.selectGroupTerminals('lead');
+ c.selectDevices();
+ c.toggleMachineExpanded('m');
+ await c.flush();
+ c.dispose();
+ final restored = server.controller(
+ initial: {
+ ...server.saved!,
+ // A preference from the former embedded chat must be ignored.
+ 'devicesLayout': PaneArrangement(const [
+ Rect.fromLTRB(0, 0, .6, 1),
+ Rect.fromLTRB(.6, 0, 1, 1),
+ ]).toJson(),
+ },
+ );
+ await restored.refresh();
+ expect(restored.devicesSelected, isTrue);
+ expect(restored.isMachineExpanded('m'), isTrue);
+ expect(restored.terminalAgents('lead'), isEmpty);
+ expect(restored.draft('lead'), 'Keep discussing this project.');
+ restored.select('lead');
+ expect(restored.devicesSelected, isFalse);
+ expect(restored.selectedId, 'lead');
+ expect(restored.terminalAgents('lead'), isNotEmpty);
+ await restored.flush();
+ expect(server.saved, isNot(contains('devicesLayout')));
+ final other = server.controller(initial: server.saved, account: 'other');
+ expect(other.devicesSelected, isFalse);
+ expect(other.isMachineExpanded('m'), isFalse);
+ expect(other.draft('lead'), isEmpty);
+ other.dispose();
+ restored.dispose();
+ },
+ );
+
+ Future<(SuperTabLaunchFixture, SuperTabController)> mount(
+ WidgetTester tester, {
+ bool hasDevice = false,
+ }) async {
+ await tester.binding.setSurfaceSize(const Size(1440, 900));
+ addTearDown(() => tester.binding.setSurfaceSize(null));
+ final f = superTabDevicesFixture();
+ (f.connection as SuperTabDevicesConnection).hasDevice = hasDevice;
+ f.app.bindSuperTab(f.app.activeSwarmId, tabId, 'Company');
+ final c = await f.app.superTabs.open(tabId);
+ await c.refresh();
+ await tester.pumpWidget(
+ MaterialApp(
+ home: Scaffold(
+ body: ListenableBuilder(
+ listenable: f.app,
+ builder: (_, _) => SuperTabWorkspace(
+ app: f.app,
+ onAddAgent: (_) {},
+ canvas: PaneGrid(
+ notifier: f.app,
+ swarmMode: true,
+ devicesViewer: (_) => DevicesTab(notifier: f.app),
+ devicesConversation: (_) => const Text('Devices chat setup'),
+ ),
+ ),
+ ),
+ ),
+ ),
+ );
+ await tester.pumpAndSettle();
+ return (f, c);
+ }
+
+ testWidgets(
+ 'Devices opens in the center, keeps the same tab and preserves the project draft',
+ (tester) async {
+ final (f, c) = await mount(tester);
+ final tab = f.app.activeSwarm;
+ final before = f.app.swarms.map((s) => s.id).toList();
+ final field = find.descendant(
+ of: find.byKey(const ValueKey('super-composer')),
+ matching: find.byType(TextField),
+ );
+ // Use the view's composer rather than any search field in the Devices page.
+ final composer = field.evaluate().isEmpty
+ ? find.byType(TextField).last
+ : field;
+ await tester.enterText(composer, 'An unfinished project message');
+ await tester.tap(find.byKey(const ValueKey('super-your-devices')));
+ await tester.pumpAndSettle();
+ expect(f.app.activeSwarm, same(tab));
+ expect(f.app.swarms.map((s) => s.id), before);
+ expect(c.devicesSelected, isTrue);
+ expect(find.byType(DevicesScreen), findsOneWidget);
+ expect(find.text('Add your first device'), findsOneWidget);
+ expect(find.text('Devices chat setup'), findsNothing);
+ expect(find.byKey(const ValueKey('super-chat')), findsNothing);
+ expect(tab.panes, hasLength(1));
+ final viewer = tab.panes.single;
+ expect(viewer.isDevices, isTrue);
+ expect(viewer.ownerAgentId, isNull);
+ final bounds = tester.getRect(
+ find.byKey(ValueKey('pane-frame:${viewer.id}')),
+ );
+ final center = tester.getRect(find.byType(PaneGrid));
+ expect(bounds.left, closeTo(center.left, 2));
+ expect(bounds.right, closeTo(center.right, 2));
+ await tester.tap(find.byKey(const ValueKey('super-your-devices')));
+ await tester.pumpAndSettle();
+ expect(tab.panes.single, same(viewer));
+ await tester.tap(find.byKey(const ValueKey('super-group-lead')));
+ await tester.pumpAndSettle();
+ expect(c.devicesSelected, isFalse);
+ expect(f.app.activeSwarm, same(tab));
+ expect(find.byType(DevicesScreen), findsNothing);
+ expect(find.text('An unfinished project message'), findsOneWidget);
+ expect(
+ f.connection.calls.where(
+ (call) => call.$1 == 'agent_create' || call.$1 == 'agent_resume',
+ ),
+ isEmpty,
+ );
+ expect(tester.takeException(), isNull);
+ await tester.pumpWidget(const SizedBox());
+ await c.flush();
+ f.app.superTabs.dispose();
+ await tester.pump();
+ },
+ );
+
+ testWidgets(
+ 'stale embedded chat startup and attachment do nothing before or after navigation',
+ (tester) async {
+ final (f, c) = await mount(tester);
+ final tab = f.app.activeSwarm;
+ final devices = DevicesHarnessController(f.app);
+ addTearDown(devices.dispose);
+ final loading = Completer<void>();
+ final owner = f.app.stateOf('m')!;
+ owner.agentsLoadInFlight = loading.future;
+ owner.agents = [
+ const Agent(
+ id: 'devices-chat',
+ name: 'Devices',
+ engine: 'codex',
+ dsh: devicesHarnessId,
+ terminalAvailable: false,
+ ),
+ ];
+ c.selectDevices();
+ await tester.pumpAndSettle();
+ var finished = false;
+ final opening = devices
+ .open(swarmId: tab.id)
+ .then((_) => finished = true);
+ await tester.pump();
+ expect(
+ finished,
+ isTrue,
+ reason: 'Embedded Devices must not wait for agent inventory',
+ );
+ await f.app.showDevicesTerminal('m', 'devices-chat', swarmId: tab.id);
+ expect(tab.panes, hasLength(1));
+ expect(tab.panes.single.isDevices, isTrue);
+ expect(tab.panes.single.ownerAgentId, isNull);
+ c.select('lead');
+ await tester.pumpAndSettle();
+ loading.complete();
+ await opening;
+ await tester.pumpAndSettle();
+ expect(c.devicesSelected, isFalse);
+ expect(
+ tab.panes.where((pane) => pane.agentId == 'devices-chat'),
+ isEmpty,
+ );
+ expect(tab.panes.where((pane) => pane.isDevices), isEmpty);
+ c.selectDevices();
+ await tester.pumpAndSettle();
+ await devices.open(swarmId: tab.id);
+ await f.app.showDevicesTerminal('m', 'devices-chat', swarmId: tab.id);
+ await tester.pumpAndSettle();
+ expect(
+ tab.panes.where((pane) => pane.agentId == 'devices-chat'),
+ isEmpty,
+ );
+ expect(tab.panes, hasLength(1));
+ expect(find.text('Devices chat setup'), findsNothing);
+ expect(f.app.activeSwarm, same(tab));
+ expect(
+ f.connection.calls.where(
+ (call) => call.$1 == 'agent_create' || call.$1 == 'agent_resume',
+ ),
+ isEmpty,
+ );
+ await tester.pumpWidget(const SizedBox());
+ await c.flush();
+ f.app.superTabs.dispose();
+ await tester.pump();
+ },
+ );
+
+ testWidgets('embedded device controls update the selected device in place', (
+ tester,
+ ) async {
+ final (f, c) = await mount(tester, hasDevice: true);
+ final tab = f.app.activeSwarm;
+ c.selectDevices();
+ await tester.pumpAndSettle();
+ final sound = find.byWidgetPredicate(
+ (widget) =>
+ widget is Switch && widget.key.toString().contains('devices-sound-'),
+ );
+ await tester.ensureVisible(sound);
+ expect(tester.widget<Switch>(sound).value, isFalse);
+ await tester.tap(sound);
+ await tester.pumpAndSettle();
+ expect(tester.widget<Switch>(sound).value, isTrue);
+ expect(f.app.activeSwarm, same(tab));
+ expect(
+ f.connection.calls
+ .where((call) => call.$1 == 'harness_device_settings')
+ .single
+ .$2['patch'],
+ {'muted': false},
+ );
+ expect(tester.takeException(), isNull);
+ await tester.pumpWidget(const SizedBox());
+ await c.flush();
+ f.app.superTabs.dispose();
+ await tester.pump();
+ });
+
+ testWidgets('revoking a Swarm while Devices is open removes its workspace', (
+ tester,
+ ) async {
+ final (f, c) = await mount(tester);
+ c.selectDevices();
+ await tester.pumpAndSettle();
+ c.revokeAccess('Access to this Swarm was removed.');
+ await tester.pumpAndSettle();
+ expect(c.devicesSelected, isFalse);
+ expect(find.byType(DevicesScreen), findsNothing);
+ expect(find.text('Access to this Swarm was removed.'), findsOneWidget);
+ expect(f.app.activeSwarm.panes, isEmpty);
+ expect(tester.takeException(), isNull);
+ await tester.pumpWidget(const SizedBox());
+ f.app.superTabs.dispose();
+ await tester.pump();
+ });
+
+ testWidgets(
+ 'messages arriving while Devices is visible stay unread until chat is shown',
+ (tester) async {
+ final (f, c) = await mount(tester);
+ c.selectDevices();
+ await tester.pumpAndSettle();
+ f.connection.server.append('Please review the next change.');
+ await c.refresh();
+ await tester.pumpAndSettle();
+ expect(c.unread(c.snapshot!.conversation('lead')!), isTrue);
+ c.select('lead');
+ await tester.pumpAndSettle();
+ expect(find.text('Please review the next change.'), findsOneWidget);
+ expect(c.unread(c.snapshot!.conversation('lead')!), isFalse);
+ await tester.pumpWidget(const SizedBox());
+ await c.flush();
+ f.app.superTabs.dispose();
+ await tester.pump();
+ },
+ );
+}
diff --git a/desktop/test/super_tab_identity_test.dart b/desktop/test/super_tab_identity_test.dart
new file mode 100644
index 000000000..41fb492ac
--- /dev/null
+++ b/desktop/test/super_tab_identity_test.dart
@@ -0,0 +1,83 @@
+import 'package:flutter/material.dart';
+import 'package:flutter/rendering.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:harness/super_tabs/identity.dart';
+import 'package:harness/widgets/desktop_chrome.dart';
+
+void main() {
+ for (final size in [20.0, 24.0, 30.0]) {
+ testWidgets(
+ 'a $size pixel avatar keeps its initial inside while names scale',
+ (tester) async {
+ for (final name in ['Atlas', 'Sage', 'Quinn']) {
+ Size? initialSize;
+ double? nameHeight;
+ for (final scale in [1.0, 2.0, 3.0]) {
+ await tester.pumpWidget(
+ MaterialApp(
+ builder: (context, child) => MediaQuery(
+ data: MediaQuery.of(context)
+ .copyWith(textScaler: TextScaler.linear(scale)),
+ child: child!,
+ ),
+ home: Scaffold(
+ body: Center(
+ child: Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ SuperTabAvatar(
+ identity: 'agent:$name',
+ name: name,
+ size: size,
+ ),
+ const SizedBox(width: 8),
+ Text(name, style: DesktopChrome.control()),
+ ],
+ ),
+ ),
+ ),
+ ),
+ );
+ final avatar = find.byType(SuperTabAvatar);
+ final bounds = tester.getRect(avatar);
+ final initial = find.descendant(
+ of: avatar,
+ matching: find.byType(Text),
+ );
+ final paragraph = tester.renderObject<RenderParagraph>(initial);
+ final box = paragraph
+ .getBoxesForSelection(
+ const TextSelection(baseOffset: 0, extentOffset: 1),
+ )
+ .single
+ .toRect();
+ final glyph = box.shift(paragraph.localToGlobal(Offset.zero));
+ expect(bounds.size, Size.square(size));
+ // Check the painted glyph's bounds, not only the constrained Text
+ // widget: a larger line can otherwise be clipped inside that box.
+ for (final corner in [
+ glyph.topLeft,
+ glyph.topRight,
+ glyph.bottomLeft,
+ glyph.bottomRight,
+ ]) {
+ expect(
+ (corner - bounds.center).distance,
+ lessThanOrEqualTo(size / 2),
+ reason: '$name at ${scale}x must fit its fixed identity circle',
+ );
+ }
+ initialSize ??= glyph.size;
+ expect(glyph.size, initialSize);
+
+ final fullName = tester.getRect(find.text(name));
+ nameHeight ??= fullName.height;
+ expect(fullName.height, closeTo(nameHeight * scale, 1));
+ expect(fullName.left, greaterThan(bounds.right));
+ expect(tester.takeException(), isNull);
+ }
+ }
+ },
+ );
+ }
+}
diff --git a/desktop/test/super_tab_launch_test.dart b/desktop/test/super_tab_launch_test.dart
index 09ada0b27..9beea1cca 100644
--- a/desktop/test/super_tab_launch_test.dart
+++ b/desktop/test/super_tab_launch_test.dart
@@ -335,8 +335,13 @@ class SuperTabFixtureConnection extends WsConn {
}
class SuperTabLaunchFixture {
- SuperTabLaunchFixture({bool local = false}) {
- connection = SuperTabFixtureConnection(store, local: local);
+ SuperTabLaunchFixture({
+ bool local = false,
+ SuperTabFixtureConnection Function(MemoryStore)? connectionFactory,
+ }) {
+ connection =
+ connectionFactory?.call(store) ??
+ SuperTabFixtureConnection(store, local: local);
app = createApp(
store: store,
connectionForTest: (_) => connection,
diff --git a/desktop/test/super_tab_machine_freshness_test.dart b/desktop/test/super_tab_machine_freshness_test.dart
index 9013f8546..1c8568a51 100644
--- a/desktop/test/super_tab_machine_freshness_test.dart
+++ b/desktop/test/super_tab_machine_freshness_test.dart
@@ -15,10 +15,8 @@ import 'package:harness/widgets/desktop_chrome.dart';
import 'super_tab_launch_test.dart' show SuperTabLaunchFixture, tabId;
import 'support/super_tab_fixture.dart';
-/// The Machines list's freshness (first approved at https://claude.ai/artifact/3b4f1ZqbxwSDqL7QKq39S2, since
-/// calmed to one line a machine): a status dot in each row's icon column, the age and old numbers in the row's
-/// tooltip and label, a pill by the heading while the Swarm cannot be read — and the readings behind them: how
-/// old each is, what the Swarm not being readable does to them, and what this computer reads itself.
+/// Machine connection freshness stays independent of disclosure state. Offline,
+/// unknown and refreshing rows keep their identity but do not expose old readings.
void main() {
final base = DateTime.utc(2026, 10, 22, 12);
DateTime now = base;
@@ -102,8 +100,7 @@ void main() {
)
.message!;
Color? nameInkOf(WidgetTester tester, String id) => tester
- .widget<RichText>(inRow(id, find.byType(RichText)).first)
- .text
+ .widget<Text>(find.byKey(ValueKey('super-machine-name-$id')))
.style
?.color;
@@ -114,8 +111,8 @@ void main() {
/// The list's own text, which never carries a number or an age.
Iterable<String> textsOf(String id) => inRow(
id,
- find.byType(RichText),
- ).evaluate().map((e) => (e.widget as RichText).text.toPlainText());
+ find.byType(Text),
+ ).evaluate().map((e) => (e.widget as Text).data!);
Finder pill(String text) => find.descendant(
of: find.byType(SuperTabMachinesPill),
matching: find.text(text),
@@ -223,38 +220,35 @@ void main() {
});
group('a machine that contributes', () {
- testWidgets(
- 'live: a green dot, and a tooltip and label that say "4s ago" and the numbers',
- (tester) async {
- final server = ConversationServer();
- server.state['machines'] = [
- contributed('m', const Duration(seconds: 4)),
- ];
- final c = server.controller();
- await c.refresh();
- final semantics = tester.ensureSemantics();
- await show(tester, c);
+ testWidgets('live: a green dot and current numbers in the tooltip', (
+ tester,
+ ) async {
+ final server = ConversationServer();
+ server.state['machines'] = [contributed('m', const Duration(seconds: 4))];
+ final c = server.controller();
+ await c.refresh();
+ final semantics = tester.ensureSemantics();
+ await show(tester, c);
- expect(statusOf(tester, 'm'), SuperTabMachineStatus.live);
- expect(
- find.byKey(const ValueKey('super-machine-state-m-live')),
- findsOneWidget,
- );
- const tip =
- 'Owned by owner · CPU 80% free · RAM 16 GB free · SSD 500 GB free';
- expect(tipOf(tester, 'm'), tip);
- expect(labelOf(tester, 'm'), 'Studio Mac, Live, $tip');
- // One line: the name and its Codex allowance; no hardware number, no age.
- expect(textsOf('m'), ['Studio Mac', '90%']);
- expect(nameInkOf(tester, 'm'), isNot(DesktopChrome.muted));
- expect(find.byType(SuperTabMachinesPill), findsNothing);
+ expect(statusOf(tester, 'm'), SuperTabMachineStatus.live);
+ expect(
+ find.byKey(const ValueKey('super-machine-state-m-live')),
+ findsOneWidget,
+ );
+ const tip =
+ 'Owned by owner · CPU 80% free · RAM 16 GB free · SSD 500 GB free';
+ expect(tipOf(tester, 'm'), tip);
+ expect(labelOf(tester, 'm'), 'Studio Mac, Live, $tip');
+ // Collapsed: name and owner avatar, with readings reserved for disclosure.
+ expect(textsOf('m'), ['Studio Mac', 'O']);
+ expect(nameInkOf(tester, 'm'), isNot(DesktopChrome.muted));
+ expect(find.byType(SuperTabMachinesPill), findsNothing);
- semantics.dispose();
- await tester.pumpWidget(const SizedBox());
- },
- );
+ semantics.dispose();
+ await tester.pumpWidget(const SizedBox());
+ });
- testWidgets('late: an amber dot, and "28s ago" on hover', (tester) async {
+ testWidgets('late: an amber dot with current readings', (tester) async {
final server = ConversationServer();
server.state['machines'] = [
contributed('m', const Duration(seconds: 28)),
@@ -270,7 +264,7 @@ void main() {
labelOf(tester, 'm'),
startsWith('Studio Mac, Late, Owned by owner'),
);
- expect(textsOf('m'), ['Studio Mac', '90%']);
+ expect(textsOf('m'), ['Studio Mac', 'O']);
semantics.dispose();
await tester.pumpWidget(const SizedBox());
@@ -283,7 +277,6 @@ void main() {
server.state['machines'] = [contributed('m', Duration.zero)];
final c = server.controller();
await c.refresh();
- c.offlineMachinesOpen = true;
for (final (seconds, status) in [
(0, SuperTabMachineStatus.live),
(19, SuperTabMachineStatus.live),
@@ -301,7 +294,7 @@ void main() {
);
testWidgets(
- 'offline: under the closed "Offline · 1", a hollow ring, a muted name, and its last numbers kept in its tooltip',
+ 'offline: a direct row with a hollow ring, muted name, and no stale readings',
(tester) async {
final server = ConversationServer();
server.state['machines'] = [
@@ -311,24 +304,28 @@ void main() {
await c.refresh();
final semantics = tester.ensureSemantics();
await show(tester, c);
- expect(rowOf('m'), findsNothing);
- expect(find.text('Offline · 1'), findsOneWidget);
- await tester.tap(find.byKey(const ValueKey('super-machines-offline')));
+ expect(rowOf('m'), findsOneWidget);
+ await tester.tap(find.byKey(const ValueKey('super-machine-toggle-m')));
await tester.pump();
+ expect(
+ find.byKey(const ValueKey('super-machine-readings-m')),
+ findsNothing,
+ );
expect(statusOf(tester, 'm'), SuperTabMachineStatus.offline);
expect(nameInkOf(tester, 'm'), DesktopChrome.muted);
- // Never blanked: its last numbers stay. Its allowance is old, so it has no chip.
- const tip =
- 'Offline · Owned by owner · CPU 80% free · RAM 16 GB free · SSD 500 GB free';
+ // Old capacity and allowances are absent while offline.
+ const tip = 'Offline · Owned by owner';
expect(tipOf(tester, 'm'), tip);
expect(labelOf(tester, 'm'), 'Studio Mac, Offline, $tip');
- expect(textsOf('m'), ['Studio Mac']);
+ expect(textsOf('m'), ['Studio Mac', 'O']);
expect(find.byType(SuperTabMachinesPill), findsNothing);
// Opened, it stays open: saved with the Swarm's other sidebar state.
await c.flush();
- expect(server.saved!['offlineMachinesOpen'], isTrue);
+ final reopened = server.controller(initial: server.saved!);
+ expect(reopened.isMachineExpanded('m'), isTrue);
+ reopened.dispose();
semantics.dispose();
await tester.pumpWidget(const SizedBox());
@@ -336,7 +333,7 @@ void main() {
);
testWidgets(
- 'unknown while the Swarm cannot be read: not offline, its last numbers kept in its tooltip',
+ 'unknown while the Swarm cannot be read: not offline, without stale capacity',
(tester) async {
final server = ConversationServer();
server.state['machines'] = [
@@ -361,15 +358,13 @@ void main() {
find.byKey(const ValueKey('super-machines-offline')),
findsNothing,
);
- const tip =
- "Can't reach Harness · Owned by owner · CPU 80% free · RAM 16 GB free · SSD 500 GB free";
+ const tip = "Can't reach Harness · Owned by owner";
expect(tipOf(tester, 'm'), tip);
expect(labelOf(tester, 'm'), 'Studio Mac, Status unknown, $tip');
// Read again, what the machine reports decides again: this one was silent.
server.failReads = false;
await c.refresh();
- c.offlineMachinesOpen = true;
await show(tester, c);
expect(statusOf(tester, 'm'), SuperTabMachineStatus.offline);
@@ -401,7 +396,7 @@ void main() {
);
testWidgets(
- 'refreshing back from the background: grey, "Refreshing…" with the old numbers — until the Swarm is read',
+ 'refreshing back from the background hides old numbers until the Swarm is read',
(tester) async {
final f = SuperTabLaunchFixture();
f.app.bindSuperTab(f.app.activeSwarmId, tabId, 'Pilot');
@@ -431,11 +426,10 @@ void main() {
await tester.pump();
await show(tester, c, app: f.app, readLocal: (_) async => null);
expect(statusOf(tester, 'far'), SuperTabMachineStatus.refreshing);
- const tip =
- 'Refreshing… · Owned by owner · CPU 80% free · RAM 16 GB free · SSD 500 GB free';
+ const tip = 'Refreshing… · Owned by owner';
expect(tipOf(tester, 'far'), tip);
expect(labelOf(tester, 'far'), 'Far Mac, Refreshing, $tip');
- expect(textsOf('far'), ['Far Mac', '90%']);
+ expect(textsOf('far'), ['Far Mac', 'O']);
gate.complete();
await landed(tester);
@@ -511,14 +505,14 @@ void main() {
server.state['machines'] = [contributed('m', const Duration(minutes: 3))];
final c = server.controller();
await c.refresh();
- c.offlineMachinesOpen = true;
await show(tester, c);
- const tip =
- 'Offline · Owned by owner · CPU 80% free · RAM 16 GB free · SSD 500 GB free';
+ const tip = 'Offline · Owned by owner';
expect(find.text(tip), findsNothing);
- // The disclosure first, then the machine under it.
- await tester.sendKeyEvent(LogicalKeyboardKey.tab);
- await tester.sendKeyEvent(LogicalKeyboardKey.tab);
+ // Focus the machine name; the independent disclosure is next.
+ Focus.of(
+ tester.element(find.byKey(const ValueKey('super-machine-name-m'))),
+ ).requestFocus();
+ await tester.sendKeyEvent(LogicalKeyboardKey.arrowRight);
await tester.pump();
await tester.pump(const Duration(milliseconds: 800));
expect(find.text(tip), findsOneWidget);
@@ -670,7 +664,7 @@ void main() {
}
testWidgets(
- 'keeps its last sample on coming back, as refreshing and dimmed, until the new read lands',
+ 'hides its last sample on coming back until the new read lands',
(tester) async {
final (f, c) = await local(['m']);
final reads = <Completer<MachineResources?>>[];
@@ -689,7 +683,7 @@ void main() {
);
expect(statusOf(tester, 'm'), SuperTabMachineStatus.live);
- // Away for a while, then back: the numbers stay, and the row says it is refreshing.
+ // Away for a while, then back: hide old numbers while the row is refreshing.
now = base.add(const Duration(seconds: 50));
f.app.foreground.value = false;
await tester.pump();
@@ -697,10 +691,7 @@ void main() {
await tester.pump();
expect(reads, hasLength(2));
expect(statusOf(tester, 'm'), SuperTabMachineStatus.refreshing);
- expect(
- tipOf(tester, 'm'),
- 'Refreshing… · Owned by owner · CPU 70% free · RAM 0 MB free',
- );
+ expect(tipOf(tester, 'm'), 'Refreshing… · Owned by owner');
reads.last.complete(cpu(90));
await landed(tester);
@@ -748,7 +739,7 @@ void main() {
});
testWidgets(
- 'is offline, its numbers kept in its tooltip, when its connection is down',
+ 'is offline without stale numbers when its connection is down',
(tester) async {
final (f, c) = await local(['m']);
Future<MachineResources?> read(String id) async => cpu(30);
@@ -757,13 +748,9 @@ void main() {
expect(statusOf(tester, 'm'), SuperTabMachineStatus.live);
f.app.stateOf('m')!.connectionStatus = ConnectionStatus.disconnected;
- c.offlineMachinesOpen = true;
await show(tester, c, app: f.app, readLocal: read);
expect(statusOf(tester, 'm'), SuperTabMachineStatus.offline);
- expect(
- tipOf(tester, 'm'),
- 'Offline · Owned by owner · CPU 70% free · RAM 0 MB free',
- );
+ expect(tipOf(tester, 'm'), 'Offline · Owned by owner');
await done(tester, f, c);
},
@@ -773,8 +760,7 @@ void main() {
tester,
) async {
final (f, c) = await local(['m', 'second']);
- // Unread, a machine is offline: open the disclosure it waits under.
- c.offlineMachinesOpen = true;
+ // Each machine is visible before its own first sample arrives.
final reads = <String, Completer<MachineResources?>>{};
Future<MachineResources?> read(String id) =>
(reads[id] = Completer<MachineResources?>()).future;
diff --git a/desktop/test/super_tab_machines_test.dart b/desktop/test/super_tab_machines_test.dart
index cde8752dc..c940793eb 100644
--- a/desktop/test/super_tab_machines_test.dart
+++ b/desktop/test/super_tab_machines_test.dart
@@ -1,5 +1,4 @@
import 'dart:io';
-import 'dart:math' as math;
import 'dart:ui' show PointerDeviceKind;
import 'package:flutter/material.dart';
@@ -11,11 +10,12 @@ import 'package:harness/core/models.dart';
import 'package:harness/shared/theme/app_icons.dart';
import 'package:harness/shared/theme/status_line_style.dart';
import 'package:harness/state/app_state.dart';
+import 'package:harness/state/harness_activity.dart';
+import 'package:harness/widgets/harness_activity_mark.dart';
import 'package:harness/super_tabs/machines.dart';
import 'package:harness/super_tabs/machine_details.dart';
import 'package:harness/super_tabs/identity.dart';
import 'package:harness/super_tabs/model.dart';
-import 'package:harness/super_tabs/section_heading.dart';
import 'package:harness/shared/theme/app_theme.dart' as grid;
import 'package:harness/shared/widgets/app_icon_button.dart';
import 'package:harness/widgets/desktop_chrome.dart';
@@ -95,13 +95,7 @@ Future<void> _openConfigureDialog(
),
);
await tester.pumpAndSettle();
- // A machine that has not reported reads as offline and waits under "Offline · 1",
- // which is closed until the owner opens it.
final card = find.byKey(const ValueKey('super-machine-m'));
- if (card.evaluate().isEmpty) {
- await tester.tap(find.byKey(const ValueKey('super-machines-offline')));
- await tester.pumpAndSettle();
- }
await tester.tap(card);
await tester.pumpAndSettle();
await tester.tap(find.widgetWithText(TextButton, 'Configure'));
@@ -118,14 +112,8 @@ String _tipOf(WidgetTester tester, Finder row) => tester
.message!;
/// The words on a machine's line: its name, and its owner's when the name is shared.
-String _lineOf(WidgetTester tester, String id) => find
- .descendant(
- of: find.byKey(ValueKey('super-machine-$id')),
- matching: find.byType(RichText),
- )
- .evaluate()
- .map((e) => (e.widget as RichText).text.toPlainText())
- .join();
+String _lineOf(WidgetTester tester, String id) =>
+ tester.widget<Text>(find.byKey(ValueKey('super-machine-name-$id'))).data!;
Finder _option(String id) => find.byKey(ValueKey('swarm-machine-option-$id'));
@@ -176,7 +164,7 @@ void main() {
}
});
testWidgets(
- 'a machine is one line; its numbers and age are in its tooltip, and an offline one waits under "Offline · 1"',
+ 'machine rows disclose readings separately from details, and offline rows stay visible without stale data',
(tester) async {
await tester.binding.setSurfaceSize(const Size(280, 700));
addTearDown(() => tester.binding.setSurfaceSize(null));
@@ -223,21 +211,21 @@ void main() {
await tester.pumpAndSettle();
final offline = find.byKey(const ValueKey('super-machine-offline'));
final online = find.byKey(const ValueKey('super-machine-online'));
- // The line shows the one known allowance, Codex's, and no hardware number or age; the row's tooltip
- // says whose machine it is and its hardware.
expect(find.textContaining('CPU'), findsNothing);
expect(find.textContaining('GB'), findsNothing);
expect(find.textContaining('ago'), findsNothing);
- expect(
- tester
- .widget<EngineMark>(
- find.descendant(of: online, matching: find.byType(EngineMark)),
- )
- .engine,
- 'codex',
+ expect(offline, findsOneWidget);
+ expect(find.text('Offline · 1'), findsNothing);
+ await tester.tap(
+ find.byKey(const ValueKey('super-machine-toggle-online')),
);
+ await tester.pumpAndSettle();
+ expect(find.byType(AlertDialog), findsNothing);
+ expect(find.text('CPU 0%'), findsOneWidget);
+ expect(find.text('RAM 0 GB'), findsOneWidget);
+ expect(find.text('SSD 141 GB'), findsOneWidget);
expect(
- find.descendant(of: online, matching: find.text('100%')),
+ find.byKey(const ValueKey('super-machine-allowance-online-codex')),
findsOneWidget,
);
expect(
@@ -245,17 +233,8 @@ void main() {
'Owned by owner · CPU 100% free · RAM 0 GB free · SSD 141 GB free',
);
expect(tester.getSize(online).height, 36);
- // Offline machines start out of sight, under their disclosure.
- expect(offline, findsNothing);
- expect(find.text('Offline · 1'), findsOneWidget);
- await tester.tap(find.byKey(const ValueKey('super-machines-offline')));
- await tester.pumpAndSettle();
- expect(c.offlineMachinesOpen, isTrue);
// Offline: its state in words, never when it was last seen, and no allowance chip.
- expect(
- _tipOf(tester, offline),
- 'Offline · Owned by owner · CPU 100% free · RAM 0 GB free · SSD 141 GB free',
- );
+ expect(_tipOf(tester, offline), 'Offline · Owned by owner');
expect(
find.descendant(of: offline, matching: find.byType(EngineMark)),
findsNothing,
@@ -314,7 +293,7 @@ void main() {
);
testWidgets(
- 'online machines come first by name; offline ones follow under a closed, saved "Offline · N"',
+ 'online machines sort first, offline rows remain direct, and expansion survives reopening',
(tester) async {
final server = ConversationServer();
final now = DateTime.now().millisecondsSinceEpoch;
@@ -332,55 +311,40 @@ void main() {
];
final c = server.controller();
await c.refresh();
- Future<void> show() async {
- await tester.pumpWidget(
- MaterialApp(
- home: Scaffold(
- body: ListenableBuilder(
- listenable: c,
- builder: (context, _) => SuperTabMachines(
- controller: c,
- embedded: true,
- onAddAgent: (_) {},
- ),
- ),
+ await tester.pumpWidget(
+ MaterialApp(
+ home: Scaffold(
+ body: SuperTabMachines(
+ controller: c,
+ embedded: true,
+ onAddAgent: (_) {},
),
),
- );
- await tester.pumpAndSettle();
- }
-
- double y(String key) => tester.getTopLeft(find.byKey(ValueKey(key))).dy;
- await show();
- // Late is online too; case does not decide the order.
- expect(y('super-machine-a'), lessThan(y('super-machine-z')));
- expect(y('super-machine-z'), lessThan(y('super-machines-offline')));
- expect(find.text('Offline · 2'), findsOneWidget);
- expect(find.byKey(const ValueKey('super-machine-b')), findsNothing);
- expect(find.byKey(const ValueKey('super-machine-g')), findsNothing);
-
- await tester.tap(find.byKey(const ValueKey('super-machines-offline')));
+ ),
+ );
await tester.pumpAndSettle();
- expect(y('super-machines-offline'), lessThan(y('super-machine-b')));
- expect(y('super-machine-b'), lessThan(y('super-machine-g')));
-
- // Saved, and read back by the next controller for this Swarm.
- await c.flush();
- expect(server.saved!['offlineMachinesOpen'], isTrue);
- final reopened = server.controller(initial: server.saved!);
- expect(reopened.offlineMachinesOpen, isTrue);
- reopened.dispose();
- expect(server.controller().offlineMachinesOpen, isFalse);
-
- // Nothing offline, no disclosure.
- server.state['machines'] = [machine('z', 'Zed Mac', 0)];
- await c.refresh();
- await show();
+ double y(String id) =>
+ tester.getTopLeft(find.byKey(ValueKey('super-machine-$id'))).dy;
+ expect(y('a'), lessThan(y('z')));
+ expect(y('z'), lessThan(y('b')));
+ expect(y('b'), lessThan(y('g')));
expect(
find.byKey(const ValueKey('super-machines-offline')),
findsNothing,
);
-
+ expect(c.isMachineExpanded('a'), isFalse);
+ await tester.tap(find.byKey(const ValueKey('super-machine-toggle-a')));
+ await tester.pumpAndSettle();
+ expect(c.isMachineExpanded('a'), isTrue);
+ expect(find.text('No agents yet'), findsOneWidget);
+ await c.flush();
+ final reopened = server.controller(initial: server.saved!);
+ expect(reopened.isMachineExpanded('a'), isTrue);
+ expect(reopened.isMachineExpanded('b'), isFalse);
+ reopened.dispose();
+ await tester.tap(find.byKey(const ValueKey('super-machine-toggle-a')));
+ await tester.pumpAndSettle();
+ expect(find.text('No agents yet'), findsNothing);
await tester.pumpWidget(const SizedBox());
await c.flush();
c.dispose();
@@ -388,7 +352,7 @@ void main() {
);
testWidgets(
- 'two machines of one model keep their real names, and a row never names its owner; its tooltip does',
+ 'two machines of one model keep their names, and each has its owner avatar and tooltip',
(tester) async {
final server = ConversationServer();
final now = DateTime.now().millisecondsSinceEpoch;
@@ -436,106 +400,156 @@ void main() {
);
testWidgets(
- 'agents: up to three overlapping avatars then +N, centered on the + column; none shows nothing',
+ 'expanded agents keep roster identities, roles and lifecycle status and open the selected agent',
(tester) async {
- await tester.binding.setSurfaceSize(const Size(320, 700));
- addTearDown(() => tester.binding.setSurfaceSize(null));
final server = ConversationServer();
- final now = DateTime.now().millisecondsSinceEpoch;
+ final at = DateTime.now().millisecondsSinceEpoch;
server.state['agents'] = [
- for (final (machine, count) in [('five', 5), ('two', 2)])
- for (var i = 0; i < count; i++)
- {
- 'id': '$machine-$i',
- 'name': 'Harness $i',
- 'displayName': '${machine == 'five' ? 'Five' : 'Two'} $i',
- 'machineId': machine,
- 'harnessId': 'native-$machine-$i',
- 'contributorId': 'owner',
- 'configuration': {'engine': 'codex'},
- },
- ];
- server.state['machines'] = [
- for (final id in ['five', 'two', 'none'])
+ for (final (id, name) in [('pm', 'Quinn'), ('dev', 'Nova')])
{
- 'machineId': id,
- 'name': id,
+ 'id': id,
+ 'name': name,
+ 'displayName': name,
+ 'machineId': 'm',
+ 'harnessId': 'native-$id',
'contributorId': 'owner',
- 'observation': {'receivedAt': now},
+ 'configuration': {'engine': 'codex'},
},
];
+ (server.state['conversations'] as List)[0]
+ ..['leadId'] = 'pm'
+ ..['agentIds'] = ['pm', 'dev']
+ ..['assignment'] = {'agentId': 'dev', 'status': 'needs_human'};
+ server.state['machines'] = [
+ {
+ 'machineId': 'm',
+ 'name': 'Studio Mac',
+ 'contributorId': 'owner',
+ 'observation': {'receivedAt': at},
+ },
+ ];
final c = server.controller();
await c.refresh();
- await tester.pumpWidget(
+ final opened = <String>[];
+ Future<void> show() => tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: SuperTabMachines(
controller: c,
embedded: true,
onAddAgent: (_) {},
+ onOpenAgent: (agent) => opened.add(agent.id),
),
),
),
);
+ await show();
await tester.pumpAndSettle();
- Finder inRow(String id, Finder finder) => find.descendant(
- of: find.byKey(ValueKey('super-machine-$id')),
- matching: finder,
+ expect(find.text('Quinn'), findsNothing);
+ await tester.tap(find.byKey(const ValueKey('super-machine-toggle-m')));
+ await tester.pumpAndSettle();
+ final pm = find.byKey(const ValueKey('super-machine-agent-m-pm'));
+ final dev = find.byKey(const ValueKey('super-machine-agent-m-dev'));
+ expect(
+ find.descendant(of: pm, matching: find.text('PM')),
+ findsOneWidget,
);
- List<Rect> avatars(String id) => [
- for (final e in inRow(id, find.byType(SuperTabAvatar)).evaluate())
- tester.getRect(find.byWidget(e.widget)),
- ]..sort((a, b) => a.left.compareTo(b.left));
-
- final five = avatars('five');
- expect(five, hasLength(3));
- expect(inRow('five', find.text('+2')), findsOneWidget);
- for (var i = 1; i < five.length; i++) {
- expect(five[i].left - five[i - 1].left, closeTo(13, .01));
- }
- expect(five.first.width, 16);
- final rowFive = tester.getRect(
- find.byKey(const ValueKey('super-machine-five')),
+ expect(
+ find.descendant(of: dev, matching: find.text('Dev')),
+ findsOneWidget,
);
- for (final a in five) {
- expect(a.center.dy, closeTo(rowFive.center.dy, .5));
- }
- // The agents column ends half an avatar past the heading's + (embedded: 16 from the edge), so +2 ends there.
expect(
- tester.getRect(inRow('five', find.text('+2'))).right,
- closeTo(rowFive.right - 16 + 9, .5),
+ tester
+ .widget<SuperTabAvatar>(
+ find.descendant(of: dev, matching: find.byType(SuperTabAvatar)),
+ )
+ .identity,
+ 'agent:dev',
);
expect(
- find.descendant(
- of: find.byKey(const ValueKey('super-machine-agents-five')),
- matching: find.byType(SuperTabAvatar),
- ),
- findsNWidgets(3),
+ tester
+ .widget<ActivityMark>(
+ find.descendant(of: dev, matching: find.byType(ActivityMark)),
+ )
+ .activity,
+ HarnessActivity.needsInput,
);
+ await tester.tap(dev);
+ await tester.pumpAndSettle();
+ expect(opened, ['dev']);
+ expect(find.byType(AlertDialog), findsNothing);
+ (server.state['machines'] as List)[0]['observation']['receivedAt'] =
+ at - 600000;
+ await c.refresh();
+ await show();
+ await tester.pumpAndSettle();
expect(
- find.byTooltip(
- [for (var i = 0; i < 5; i++) 'Five $i — Engineer'].join('\n'),
- ),
- findsOneWidget,
+ tester
+ .widget<ActivityMark>(
+ find.descendant(of: dev, matching: find.byType(ActivityMark)),
+ )
+ .activity,
+ HarnessActivity.offline,
);
+ await tester.pumpWidget(const SizedBox());
+ await c.flush();
+ c.dispose();
+ },
+ );
- final two = avatars('two');
- expect(two, hasLength(2));
- expect(inRow('two', find.textContaining('+')), findsNothing);
- final rowTwo = tester.getRect(
- find.byKey(const ValueKey('super-machine-two')),
+ testWidgets(
+ 'a live agent keeps its observed status before the first machine capacity sample',
+ (tester) async {
+ final f = SuperTabLaunchFixture();
+ f.app.bindSuperTab(f.app.activeSwarmId, tabId, 'Pilot');
+ f.connection.server.state['agents'] = [
+ {
+ 'id': 'dev',
+ 'name': 'Nova',
+ 'displayName': 'Nova',
+ 'machineId': 'm',
+ 'harnessId': 'native-dev',
+ 'contributorId': 'owner',
+ 'configuration': {'engine': 'codex'},
+ },
+ ];
+ f.app.machineStates['m']!
+ ..agents = [
+ Agent.fromJson({
+ 'id': 'native-dev',
+ 'name': 'Nova',
+ 'engine': 'codex',
+ }),
+ ]
+ ..processingAgentIds.add('native-dev');
+ final c = await f.app.superTabs.open(tabId);
+ await c.refresh();
+ c.toggleMachineExpanded('m');
+ await tester.pumpWidget(
+ MaterialApp(
+ home: Scaffold(
+ body: SuperTabMachines(
+ controller: c,
+ app: f.app,
+ onAddAgent: (_) {},
+ onOpenAgent: (_) {},
+ ),
+ ),
+ ),
);
- expect(two.last.center.dx, closeTo(rowTwo.right - 16, .5));
-
- expect(avatars('none'), isEmpty);
+ await tester.pump();
+ final row = find.byKey(const ValueKey('super-machine-agent-m-dev'));
expect(
- find.byKey(const ValueKey('super-machine-agents-none')),
- findsNothing,
+ tester
+ .widget<ActivityMark>(
+ find.descendant(of: row, matching: find.byType(ActivityMark)),
+ )
+ .activity,
+ HarnessActivity.working,
);
- expect(tester.takeException(), isNull);
await tester.pumpWidget(const SizedBox());
await c.flush();
- c.dispose();
+ f.app.superTabs.dispose();
},
);
@@ -589,7 +603,9 @@ void main() {
];
final c = server.controller();
await c.refresh();
- c.offlineMachinesOpen = true;
+ for (final id in ['both', 'fine', 'expired', 'unknown', 'gone']) {
+ c.toggleMachineExpanded(id);
+ }
final semantics = tester.ensureSemantics();
await tester.pumpWidget(
MaterialApp(
@@ -690,196 +706,45 @@ void main() {
);
testWidgets(
- 'every row shares the Claude, Codex and agents columns: their right edges line up, an empty slot keeps '
- 'its place, and a narrow list hides a column for every row at once',
- (tester) async {
- final server = ConversationServer();
- final at = DateTime.now().millisecondsSinceEpoch;
- Map<String, dynamic> quota(String engine, int used) => {
- 'engine': engine,
- 'known': true,
- 'windows': [
- {'name': '5-hour', 'usedPercent': used},
- ],
- };
- // Quota sets: both, Claude only, Codex only, none; agents: 7, 3, 1, 0; and one offline.
- final machines = [
- ('both', [quota('claude', 0), quota('codex', 57)], 7, 0),
- ('claude', [quota('claude', 91)], 3, 0),
- ('codex', [quota('codex', 100)], 1, 0),
- ('none', <Map<String, dynamic>>[], 0, 0),
- ('gone', [quota('claude', 50)], 1, 600000),
- ];
- server.state['machines'] = [
- for (final (id, quotas, _, age) in machines)
- {
- 'machineId': id,
- 'name': '$id machine',
- 'contributorId': 'owner',
- 'observation': {'receivedAt': at - age, 'quotas': quotas},
- },
- ];
- server.state['agents'] = [
- for (final (id, _, agents, _) in machines)
- for (var i = 0; i < agents; i++)
- {
- 'id': '$id-$i',
- 'name': 'Harness $i',
- 'displayName': 'Agent $i',
- 'machineId': id,
- 'harnessId': 'native-$id-$i',
- 'contributorId': 'owner',
- 'configuration': {'engine': 'claude'},
- },
- ];
- final c = server.controller();
- await c.refresh();
- c.offlineMachinesOpen = true;
- final ids = [for (final m in machines) m.$1];
- Finder key(String k) => find.byKey(ValueKey(k));
- bool has(String k) => key(k).evaluate().isNotEmpty;
- double right(String k) => tester.getRect(key(k)).right;
-
- // The sidebar's widths, less its 8 px padding on each side, and a wide one.
- for (final width in [164.0, 188.0, 224.0, 264.0, 420.0]) {
- for (final scale in [1.0, 2.0]) {
- await tester.pumpWidget(
- MaterialApp(
- builder: (context, child) => MediaQuery(
- data: MediaQuery.of(context)
- .copyWith(textScaler: TextScaler.linear(scale)),
- child: child!,
- ),
- home: Scaffold(
- body: Align(
- alignment: Alignment.topLeft,
- child: SizedBox(
- width: width,
- child: SuperTabMachines(
- controller: c,
- embedded: true,
- onAddAgent: (_) {},
- ),
- ),
- ),
- ),
- ),
- );
- final reason = 'at width $width, scale $scale';
- expect(tester.takeException(), isNull, reason: reason);
-
- // Each allowance column shows for every row that has the quota, or for none.
- for (final (engine, owners) in [
- ('claude', ['both', 'claude']),
- ('codex', ['both', 'codex']),
- ]) {
- final shown = [
- for (final id in owners) has('super-machine-figure-$id-$engine'),
- ];
- expect(shown.toSet(), hasLength(1), reason: '$engine $reason');
- if (shown.first) {
- // The figures start at one x, right after the mark, whichever rows leave the other column blank.
- final edges = {
- for (final id in owners)
- tester
- .getTopLeft(key('super-machine-figure-$id-$engine'))
- .dx
- .toStringAsFixed(2),
- };
- expect(edges, hasLength(1), reason: '$engine $reason');
- }
- // Offline: never a chip.
- expect(
- has('super-machine-figure-gone-$engine'),
- isFalse,
- reason: reason,
- );
- }
- // The agents column: one right edge for every row, those without agents too,
- // and either avatars on every row that has agents or a count on all of them.
- final slots = {
- for (final id in ids)
- if (has('super-machine-agents-slot-$id'))
- right('super-machine-agents-slot-$id').toStringAsFixed(2),
- };
- expect(slots, hasLength(1), reason: reason);
- final stacked = {
- for (final id in ['both', 'claude', 'codex', 'gone'])
- find
- .descendant(
- of: key('super-machine-$id'),
- matching: find.byType(SuperTabAvatar),
- )
- .evaluate()
- .isNotEmpty,
- };
- expect(stacked, hasLength(1), reason: reason);
- if (width == 420 && scale == 1) {
- expect(stacked.single, isTrue, reason: reason);
- expect(has('super-machine-figure-both-claude'), isTrue);
- expect(has('super-machine-figure-both-codex'), isTrue);
- // The avatars stand 16 px clear of the figures before them.
- final stackLeft = find
- .descendant(
- of: key('super-machine-agents-both'),
- matching: find.byType(SuperTabAvatar),
- )
- .evaluate()
- .map((e) => tester.getTopLeft(find.byWidget(e.widget)).dx)
- .reduce(math.min);
- expect(
- stackLeft - right('super-machine-figure-both-codex'),
- greaterThanOrEqualTo(16 - .01),
- );
- // Claude's column comes before Codex's, and the agents after both.
- expect(
- right('super-machine-figure-both-claude'),
- lessThan(right('super-machine-figure-both-codex')),
- );
- expect(
- right('super-machine-figure-both-codex'),
- lessThan(slots.single.isEmpty ? 0 : double.parse(slots.single)),
- );
- }
- }
- }
- await tester.pumpWidget(const SizedBox());
- await c.flush();
- c.dispose();
- },
- );
-
- testWidgets(
- 'as the list narrows the names keep their minimum: agents become a count, then Codex goes, then Claude',
+ 'main rows and expanded readings retain their controls at narrow widths and larger text',
(tester) async {
+ await tester.binding.setSurfaceSize(const Size(900, 1800));
+ addTearDown(() => tester.binding.setSurfaceSize(null));
final server = ConversationServer();
- final now = DateTime.now();
+ final now = DateTime.now().millisecondsSinceEpoch;
server.state['agents'] = [
- for (var i = 0; i < 5; i++)
- {
- 'id': 'agent-$i',
- 'name': 'Harness $i',
- 'displayName': 'Engineer $i',
- 'machineId': 'm',
- 'harnessId': 'native-$i',
- 'contributorId': 'owner',
- 'configuration': {'engine': 'claude'},
- },
+ {
+ 'id': 'dev',
+ 'name': 'A long engineer name',
+ 'displayName': 'A long engineer name',
+ 'machineId': 'm',
+ 'harnessId': 'native',
+ 'contributorId': 'owner',
+ 'configuration': {'engine': 'codex'},
+ },
];
server.state['machines'] = [
{
'machineId': 'm',
- 'name': "Diego's Mac Studio",
+ 'name': 'A long machine name.local',
'contributorId': 'owner',
'observation': {
- 'receivedAt': now.millisecondsSinceEpoch,
+ 'receivedAt': now,
+ 'resources': {
+ 'cpuPercent': 71,
+ 'gpuPercent': 100,
+ 'memoryTotalBytes': 32000000000,
+ 'memoryUsedBytes': 15000000000,
+ 'diskTotalBytes': 1000000000000,
+ 'diskFreeBytes': 207000000000,
+ },
'quotas': [
- for (final (engine, used) in [('claude', 52), ('codex', 8)])
+ for (final engine in ['claude', 'codex'])
{
'engine': engine,
'known': true,
'windows': [
- {'name': '5-hour', 'usedPercent': used},
+ {'name': '5-hour', 'usedPercent': 0},
],
},
],
@@ -888,12 +753,9 @@ void main() {
];
final c = server.controller();
await c.refresh();
- for (final scale in [1.0, 2.0]) {
- // What the end shows at each width, widest first: avatars, then the chips.
- final states = <(int, bool, bool)>[];
- // The 11 px figures keep Claude visible at 180 px. Sweep narrower so
- // both text scales still reach the count-only stage.
- for (var width = 460.0; width >= 160; width -= 10) {
+ c.toggleMachineExpanded('m');
+ for (final width in [164.0, 188.0, 224.0, 284.0, 420.0]) {
+ for (final scale in [1.0, 2.0]) {
await tester.pumpWidget(
MaterialApp(
builder: (context, child) => MediaQuery(
@@ -910,81 +772,54 @@ void main() {
controller: c,
embedded: true,
onAddAgent: (_) {},
+ onOpenAgent: (_) {},
),
),
),
),
),
);
- final reason = 'at width $width, scale $scale';
+ await tester.pumpAndSettle();
+ final reason = 'width $width, scale $scale';
expect(tester.takeException(), isNull, reason: reason);
- final row = find.byKey(const ValueKey('super-machine-m'));
- final avatars = find
- .descendant(of: row, matching: find.byType(SuperTabAvatar))
- .evaluate()
- .length;
- bool shows(String engine) => find
- .byKey(ValueKey('super-machine-allowance-m-$engine'))
- .evaluate()
- .isNotEmpty;
- final state = (avatars, shows('claude'), shows('codex'));
- states.add(state);
- // The count always stays; with fewer avatars it says the rest.
+ final row = tester.getRect(
+ find.byKey(const ValueKey('super-machine-m')),
+ );
+ final toggle = tester.getRect(
+ find.byKey(const ValueKey('super-machine-toggle-m')),
+ );
+ final dot = tester.getRect(
+ find.byKey(const ValueKey('super-machine-state-m-live')),
+ );
+ expect(row.width, width, reason: reason);
+ expect(toggle.right, row.right, reason: reason);
expect(
- find.descendant(of: row, matching: find.text('+${5 - avatars}')),
- avatars == 5 ? findsNothing : findsOneWidget,
+ dot.center.dx,
+ closeTo(toggle.center.dx - 32, .01),
reason: reason,
);
- // A chip goes only once the avatars have, Codex before Claude.
- if (!state.$3) expect(avatars, 0, reason: reason);
- if (!state.$2) expect(state.$3, isFalse, reason: reason);
- // The name's room, from where it starts to the first column, keeps its
- // minimum while any column but the count remains.
- final nameLeft = tester
- .getTopLeft(
- find.descendant(of: row, matching: find.byType(RichText)).first,
- )
- .dx;
- final firstColumn = [
- for (final key in [
- 'super-machine-allowance-m-claude',
- 'super-machine-allowance-m-codex',
- 'super-machine-agents-slot-m',
- ])
- if (find.byKey(ValueKey(key)).evaluate().isNotEmpty)
- tester.getTopLeft(find.byKey(ValueKey(key))).dx,
- ].reduce(math.min);
- if (state.$2 || avatars > 0) {
- expect(
- firstColumn - nameLeft,
- greaterThanOrEqualTo(48 * scale - 1),
- reason: reason,
- );
- }
- }
- // Widest: everything; and every step after only takes away.
- expect(states.first, (3, true, true), reason: 'scale $scale');
- int rank((int, bool, bool) s) =>
- s.$1 * 4 + (s.$2 ? 2 : 0) + (s.$3 ? 1 : 0);
- for (var i = 1; i < states.length; i++) {
expect(
- rank(states[i]),
- lessThanOrEqualTo(rank(states[i - 1])),
- reason: 'scale $scale, step $i',
+ tester
+ .getTopLeft(find.byKey(const ValueKey('super-machine-name-m')))
+ .dx,
+ row.left + 36,
+ reason: reason,
+ );
+ expect(find.text('CPU 71%'), findsOneWidget, reason: reason);
+ expect(find.text('GPU 100%'), findsOneWidget, reason: reason);
+ expect(find.text('RAM 17 GB'), findsOneWidget, reason: reason);
+ expect(find.text('SSD 207 GB'), findsOneWidget, reason: reason);
+ expect(
+ find.byKey(const ValueKey('super-machine-allowance-m-claude')),
+ findsOneWidget,
+ reason: reason,
+ );
+ expect(
+ find.byKey(const ValueKey('super-machine-allowance-m-codex')),
+ findsOneWidget,
+ reason: reason,
);
}
- // Each stage is reached on the way down.
- expect(
- states.any((s) => s == (0, true, true)),
- isTrue,
- reason: 'scale $scale',
- );
- expect(
- states.any((s) => s == (0, true, false)),
- isTrue,
- reason: 'scale $scale',
- );
- expect(states.last, (0, false, false), reason: 'scale $scale');
}
await tester.pumpWidget(const SizedBox());
await c.flush();
@@ -993,7 +828,7 @@ void main() {
);
testWidgets(
- 'an offline machine is reached through "Offline · N", and its details still attach a running agent',
+ 'an offline machine opens directly and its details still attach a running agent',
(tester) async {
final server = ConversationServer();
server.state['machines'] = [
@@ -1023,9 +858,7 @@ void main() {
);
await tester.pumpAndSettle();
final row = find.byKey(const ValueKey('super-machine-gone'));
- expect(row, findsNothing);
- await tester.tap(find.byKey(const ValueKey('super-machines-offline')));
- await tester.pumpAndSettle();
+ expect(row, findsOneWidget);
await tester.tap(row);
await tester.pumpAndSettle();
await tester.tap(find.widgetWithText(TextButton, 'Attach running agent'));
@@ -1161,59 +994,25 @@ void main() {
matching: find.byType(SuperTabMachineDot),
),
);
- // Level 1, one indent step in from the heading's columns.
- final indent = SuperTabSectionHeading.indentFor(1);
- expect(dot.center.dx, closeTo(rowRect.left + indent + 16, .01));
+ final toggle = tester.getRect(
+ find.byKey(const ValueKey('super-machine-toggle-m')),
+ );
+ expect(dot.center.dx, closeTo(toggle.center.dx - 32, .01));
expect(dot.center.dy, closeTo(rowRect.center.dy, .5));
expect(
tester
.getTopLeft(
- find
- .descendant(of: row, matching: find.byType(RichText))
- .first,
+ find.byKey(const ValueKey('super-machine-name-m')),
)
.dx,
- rowRect.left + indent + 32,
+ rowRect.left + 36,
);
- // Left to right, as they read: the first agent is drawn last, on top.
- final avatars =
- tester
- .widgetList<SuperTabAvatar>(
- find.descendant(
- of: row,
- matching: find.byType(SuperTabAvatar),
- ),
- )
- .toList()
- ..sort(
- (a, b) => tester
- .getTopLeft(find.byWidget(a))
- .dx
- .compareTo(tester.getTopLeft(find.byWidget(b)).dx),
- );
- // No owner avatar; the PM first, at most three agents, the rest as +N.
- expect(
- avatars.map((a) => a.identity),
- isNot(contains('person:owner')),
- );
- expect(avatars.first.identity, 'agent:agent-0');
- expect(avatars.first.name, 'Atlas');
- expect(avatars.length, lessThanOrEqualTo(3));
- expect(find.text('+${8 - avatars.length}'), findsOneWidget);
- if (width == 380 && textScale == 1) expect(avatars, hasLength(3));
- expect(
- find.textContaining('Atlas — Product Manager'),
- findsNothing,
- );
- expect(
- find.byTooltip(
- [
- 'Atlas — Product Manager',
- for (var i = 1; i < 8; i++) 'Engineer $i — Engineer',
- ].join('\n'),
- ),
- findsOneWidget,
+ final owner = tester.widget<SuperTabAvatar>(
+ find.descendant(of: row, matching: find.byType(SuperTabAvatar)),
);
+ expect(owner.identity, 'person:owner');
+ expect(owner.name, 'dee');
+ expect(find.text('Atlas'), findsNothing);
// The owner, paused and the numbers are in the row's tooltip, not on the line, and never an age.
expect(
_tipOf(tester, row),
@@ -1245,8 +1044,32 @@ void main() {
expect(tester.getRect(ink.first), rowRect);
expect(tester.takeException(), isNull);
- // The blank right edge and all capacity/allowance lines belong to
- // the same hover and click target as the machine's name.
+ if (capture != null && textScale == 1) {
+ await tester.tap(
+ find.byKey(const ValueKey('super-machine-toggle-m')),
+ );
+ await tester.pumpAndSettle();
+ await tester.runAsync(
+ () => precacheImage(
+ AssetImage(engineIdentity('codex').asset!),
+ tester.element(find.byType(EngineMark).first),
+ ).timeout(const Duration(seconds: 10)),
+ );
+ await tester.pumpAndSettle();
+ await captureBoundary(
+ tester,
+ machineBoundary.currentContext!.findRenderObject()!
+ as RenderRepaintBoundary,
+ capture,
+ 'machine-expanded-${brightness.name}-${width.toInt()}',
+ );
+ await tester.tap(
+ find.byKey(const ValueKey('super-machine-toggle-m')),
+ );
+ await tester.pumpAndSettle();
+ }
+ // The full row owns hover; its name opens details while the
+ // rightmost disclosure remains an independent action.
final mouse = await tester.createGesture(
kind: PointerDeviceKind.mouse,
);
@@ -1265,7 +1088,9 @@ void main() {
capture,
'machine-hover-$captureName',
);
- await tester.tapAt(Offset(rowRect.right - 2, rowRect.center.dy));
+ await tester.tap(
+ find.byKey(const ValueKey('super-machine-name-m')),
+ );
await mouse.removePointer();
await tester.pumpAndSettle();
if (capture != null) {
@@ -1855,6 +1680,8 @@ void main() {
),
);
await tester.pumpAndSettle();
+ await tester.tap(find.byKey(const ValueKey('super-machine-toggle-m')));
+ await tester.pumpAndSettle();
// Only the known allowance of the two the list shows, Claude's, has a chip; so do the details.
expect(
tester
@@ -1889,7 +1716,6 @@ void main() {
final c = await f.app.superTabs.open(tabId);
await c.refresh();
// Never reported, so offline: under the disclosure.
- c.offlineMachinesOpen = true;
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
diff --git a/desktop/test/super_tab_pane_layout_test.dart b/desktop/test/super_tab_pane_layout_test.dart
index bd38056e1..b79e4b23f 100644
--- a/desktop/test/super_tab_pane_layout_test.dart
+++ b/desktop/test/super_tab_pane_layout_test.dart
@@ -58,28 +58,28 @@ void main() {
addTearDown(() => tester.binding.setSurfaceSize(null));
final store = MemoryStore();
await mount(tester, store);
- expect(tester.getSize(left).width, 220);
- expect(tester.getSize(right).width, 380);
+ expect(tester.getSize(left).width, 300);
+ expect(tester.getSize(right).width, 280);
await tester.enterText(find.byType(TextField), 'Keep this draft');
final editor = tester.state<EditableTextState>(find.byType(EditableText));
final focus = editor.widget.focusNode;
await tester.drag(leftHandle, const Offset(100, 0));
await tester.pumpAndSettle();
- expect(tester.getSize(left).width, closeTo(320, 1));
- expect(tester.getSize(right).width, 380);
+ expect(tester.getSize(left).width, closeTo(400, 1));
+ expect(tester.getSize(right).width, 280);
expect(focus.hasFocus, isTrue);
await tester.drag(rightHandle, const Offset(-60, 0));
await tester.pumpAndSettle();
- expect(tester.getSize(right).width, closeTo(440, 1));
- expect(tester.getSize(center).width, closeTo(640, 1));
+ expect(tester.getSize(right).width, closeTo(340, 1));
+ expect(tester.getSize(center).width, closeTo(660, 1));
expect(
tester.state<EditableTextState>(find.byType(EditableText)),
same(editor),
);
expect(find.text('Keep this draft'), findsOneWidget);
final saved = jsonDecode(store.values[SuperTabPaneLayout.storageKey]!);
- expect(saved['left'], closeTo(320, 1));
- expect(saved['right'], closeTo(440, 1));
+ expect(saved['left'], closeTo(400, 1));
+ expect(saved['right'], closeTo(340, 1));
// Responsive overlays do not forget the preferred sizes or edit state.
await mount(tester, store, sides: false);
@@ -89,12 +89,12 @@ void main() {
same(editor),
);
await mount(tester, store);
- expect(tester.getSize(left).width, closeTo(320, 1));
- expect(tester.getSize(right).width, closeTo(440, 1));
+ expect(tester.getSize(left).width, closeTo(400, 1));
+ expect(tester.getSize(right).width, closeTo(340, 1));
await tester.pumpWidget(const SizedBox());
await mount(tester, store);
- expect(tester.getSize(left).width, closeTo(320, 1));
- expect(tester.getSize(right).width, closeTo(440, 1));
+ expect(tester.getSize(left).width, closeTo(400, 1));
+ expect(tester.getSize(right).width, closeTo(340, 1));
expect(tester.takeException(), isNull);
},
);
@@ -155,7 +155,7 @@ void main() {
await tester.pumpAndSettle();
store.readResult.complete('{"left":200,"right":300}');
await tester.pumpAndSettle();
- expect(tester.getSize(right).width, closeTo(440, 1));
+ expect(tester.getSize(right).width, closeTo(340, 1));
});
testWidgets('large text and invalid saved sizes retain usable panes', (
diff --git a/desktop/test/super_tab_roster_navigation_test.dart b/desktop/test/super_tab_roster_navigation_test.dart
new file mode 100644
index 000000000..610ff716d
--- /dev/null
+++ b/desktop/test/super_tab_roster_navigation_test.dart
@@ -0,0 +1,124 @@
+import 'package:flutter/material.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:harness/core/models.dart';
+import 'package:harness/super_tabs/workspace.dart';
+
+import 'super_tab_launch_test.dart' show SuperTabLaunchFixture, tabId;
+import 'support/super_tab_fixture.dart';
+
+void main() {
+ testWidgets(
+ 'roster opens another project from Devices only through current workgroup membership',
+ (tester) async {
+ await tester.binding.setSurfaceSize(const Size(1440, 900));
+ addTearDown(() => tester.binding.setSurfaceSize(null));
+ final f = SuperTabLaunchFixture();
+ f.app.bindSuperTab(f.app.activeSwarmId, tabId, 'Company');
+ final state = f.connection.server.state;
+ state['projects'] = [
+ projectFixture('lead', 'Web', 'lead'),
+ projectFixture('mobile', 'Mobile', 'mobile-lead'),
+ ];
+ state['agents'] = [
+ {
+ 'id': 'nova',
+ 'displayName': 'Nova',
+ 'name': 'Engineer',
+ 'projectId': 'mobile',
+ 'machineId': 'm',
+ 'harnessId': 'native-nova',
+ 'contributorId': 'owner',
+ 'configuration': {'engine': 'codex'},
+ },
+ ];
+ final mobileLead = {
+ ...conversationFixture('mobile-lead', 'Product Manager'),
+ 'projectId': 'mobile',
+ 'agentIds': ['nova'],
+ };
+ final mobileWork = {
+ ...conversationFixture('mobile-work', 'Build the mobile app'),
+ 'projectId': 'mobile',
+ 'agentIds': ['nova'],
+ };
+ (state['conversations'] as List).addAll(<Map<String, dynamic>>[
+ mobileLead,
+ mobileWork,
+ ]);
+ f.app.stateOf('m')!.agents = [
+ Agent.fromJson({
+ 'id': 'native-nova',
+ 'name': 'Nova',
+ 'engine': 'codex',
+ 'status': 'stopped',
+ 'sessionId': 'saved-nova',
+ 'terminal': {'available': false},
+ }),
+ ];
+ final c = await f.app.superTabs.open(tabId);
+ await c.refresh();
+ c.selectDevices();
+ await tester.pumpWidget(
+ MaterialApp(
+ home: Scaffold(
+ body: ListenableBuilder(
+ listenable: f.app,
+ builder: (_, _) => SuperTabWorkspace(
+ app: f.app,
+ canvas: const SizedBox.expand(),
+ onAddAgent: (_) {},
+ ),
+ ),
+ ),
+ ),
+ );
+ await tester.pumpAndSettle();
+ expect(c.devicesSelected, isTrue);
+ expect(c.selectedId, 'lead');
+ await tester.tap(find.byKey(const ValueKey('super-member-nova')));
+ await tester.pumpAndSettle();
+ await tester.tap(find.widgetWithText(FilledButton, 'Open terminal'));
+ await tester.pumpAndSettle();
+ await tester.tap(
+ find.byKey(const ValueKey('super-agent-group-mobile-work')),
+ );
+ await tester.pumpAndSettle();
+ expect(c.devicesSelected, isTrue);
+
+ // Losing membership while this chooser is open cannot open a stale
+ // conversation or silently substitute the agent's other workgroup.
+ mobileWork['agentIds'] = <String>[];
+ await c.refresh();
+ await tester.pumpAndSettle();
+ final open = find.byKey(const ValueKey('super-agent-group-open'));
+ expect(tester.widget<FilledButton>(open).onPressed, isNull);
+ await tester.tap(open);
+ await tester.pumpAndSettle();
+ expect(c.devicesSelected, isTrue);
+ expect(c.selectedId, 'lead');
+ expect(f.app.panes.any((pane) => pane.agentId == 'native-nova'), isFalse);
+
+ await tester.tap(
+ find.byKey(const ValueKey('super-agent-group-mobile-lead')),
+ );
+ await tester.pumpAndSettle();
+ await tester.tap(open);
+ await tester.pumpAndSettle();
+ expect(c.devicesSelected, isFalse);
+ expect(c.selectedId, 'mobile-lead');
+ expect(f.app.panes.single.agentId, 'native-nova');
+ expect(c.terminalAgents('mobile-lead').single.id, 'nova');
+ expect(
+ f.connection.calls.where(
+ (call) => call.$1 == 'agent_create' || call.$1 == 'agent_resume',
+ ),
+ isEmpty,
+ );
+ expect(tester.takeException(), isNull);
+ await tester.pumpWidget(const SizedBox());
+ await c.flush();
+ f.app.superTabs.dispose();
+ await tester.pump();
+ },
+ );
+}
diff --git a/desktop/test/super_tab_roster_test.dart b/desktop/test/super_tab_roster_test.dart
index 6889630d6..e95e674f4 100644
--- a/desktop/test/super_tab_roster_test.dart
+++ b/desktop/test/super_tab_roster_test.dart
@@ -10,6 +10,7 @@ import 'package:harness/core/relative_time.dart';
import 'package:harness/notify/alert_sounds.dart';
import 'package:harness/shared/theme/app_theme.dart' as grid;
import 'package:harness/state/harness_activity.dart';
+import 'package:harness/super_tabs/agent_details.dart';
import 'package:harness/super_tabs/model.dart';
import 'package:harness/super_tabs/identity.dart';
import 'package:harness/super_tabs/roster.dart';
@@ -187,11 +188,22 @@ void main() {
lastActivityAt: lastActive,
),
];
+ f.app.stateOf('m')!.processingAgentIds.add('a1');
await f.controller.refresh();
await f.show(tester);
expect(
rowTooltip(tester, f, 1),
- 'Claude opus · Test host · Working on "Offline editing" · Last active 2 hours ago',
+ contains(
+ 'Claude opus · Test host · Working on "Offline editing" · Last active 2 hours ago',
+ ),
+ );
+ expect(
+ rowTooltip(tester, f, 1),
+ contains('Sage · Engineer · openharness'),
+ );
+ expect(
+ f.inRow(1, find.text('Working on "Offline editing"')),
+ findsOneWidget,
);
final mouse = await tester.createGesture(kind: PointerDeviceKind.mouse);
await mouse.addPointer(location: Offset.zero);
@@ -208,7 +220,13 @@ void main() {
) async {
final f = await fixture(tester);
await f.show(tester, nativeState: false);
- expect(rowTooltip(tester, f, 0), 'Codex');
+ expect(
+ rowTooltip(tester, f, 0),
+ contains('Atlas · Product Manager · openharness'),
+ );
+ expect(rowTooltip(tester, f, 0), contains('Codex'));
+ expect(f.inRow(0, find.text('Status unavailable')), findsOneWidget);
+ expect(rowTooltip(tester, f, 0), isNot(contains('Last active')));
await tester.tap(f.row(0));
await tester.pumpAndSettle();
for (final absent in [
@@ -246,35 +264,40 @@ void main() {
await f.controller.refresh();
await f.show(tester);
expect(f.activity(tester, 1), HarnessActivity.needsInput);
+ expect(f.inRow(1, find.text('Needs input')), findsOneWidget);
expect(rowTooltip(tester, f, 1), contains('Needs input'));
expect(rowTooltip(tester, f, 1), isNot(contains('Working on')));
await f.close(tester);
});
- testWidgets('agent tooltip shortens a long task title to one line', (
- tester,
- ) async {
- final f = await fixture(tester);
- await tester.binding.setSurfaceSize(const Size(1000, 700));
- final title = 'A long task title ' * 12;
- (f.server.state['conversations'] as List)[1]
- ..['title'] = title
- ..['assignment'] = {'agentId': 'agent-1', 'status': 'working'};
- await f.controller.refresh();
- await f.show(tester);
- final tooltip = rowTooltip(tester, f, 1);
- expect(tooltip, contains('…'));
- expect(tooltip, isNot(contains(title)));
- final mouse = await tester.createGesture(kind: PointerDeviceKind.mouse);
- await mouse.addPointer(location: Offset.zero);
- await mouse.moveTo(tester.getCenter(f.row(1)));
- await tester.pumpAndSettle(const Duration(milliseconds: 800));
- final text = find.text(tooltip);
- expect(text, findsOneWidget);
- expect(tester.getSize(text).height, lessThan(30));
- await mouse.removePointer();
- await f.close(tester);
- });
+ testWidgets(
+ 'a one-line activity keeps its full task title available on hover',
+ (tester) async {
+ final f = await fixture(tester);
+ await tester.binding.setSurfaceSize(const Size(1000, 700));
+ final title = 'A long task title ' * 12;
+ (f.server.state['conversations'] as List)[1]
+ ..['title'] = title
+ ..['assignment'] = {'agentId': 'agent-1', 'status': 'working'};
+ f.app.stateOf('m')!.processingAgentIds.add('a1');
+ await f.controller.refresh();
+ await f.show(tester);
+ final tooltip = rowTooltip(tester, f, 1);
+ expect(tooltip, contains(title));
+ final activity = f.inRow(1, find.text('Working on "$title"'));
+ expect(activity, findsOneWidget);
+ expect(tester.getSize(activity).height, lessThan(30));
+ final mouse = await tester.createGesture(kind: PointerDeviceKind.mouse);
+ await mouse.addPointer(location: Offset.zero);
+ await mouse.moveTo(tester.getCenter(f.row(1)));
+ await tester.pumpAndSettle(const Duration(milliseconds: 800));
+ final text = find.text(tooltip);
+ expect(text, findsOneWidget);
+ expect(tester.getSize(text).width, lessThanOrEqualTo(820));
+ await mouse.removePointer();
+ await f.close(tester);
+ },
+ );
testWidgets('agent details link the held task and latest group PR', (
tester,
@@ -715,68 +738,92 @@ void main() {
await f.close(tester);
});
- testWidgets('agents follow project selection', (tester) async {
- final f = await fixture(tester);
- f.app.stateOf('m')!.agents = const [
- Agent(
- id: 'a0',
- name: 'native',
- engine: 'codex',
- title: 'Join Super Tab roster',
- ),
- ];
- await f.show(tester);
- expect(f.row(2), findsNothing);
- for (final i in [0, 1, 3]) {
- expect(f.inRow(i, find.byType(SuperTabAvatar)), findsOneWidget);
- expect(f.inRow(i, find.text(i == 0 ? 'PM' : 'Dev')), findsOneWidget);
- expect(f.inRow(i, find.text('openharness')), findsOneWidget);
- }
- expect(find.text('Join Super Tab roster'), findsNothing);
- expect(find.text('Ready'), findsNothing);
- final nameX = tester.getTopLeft(f.inRow(0, find.text('Atlas'))).dx;
- final projectX = tester.getTopLeft(f.inRow(0, find.text('openharness'))).dx;
- expect(projectX, nameX);
- expect(
- tester.getCenter(f.inRow(0, find.text('Atlas'))).dy,
- lessThan(tester.getCenter(f.inRow(0, find.text('openharness'))).dy),
- );
- expect(tester.getSize(f.row(0)).height, lessThanOrEqualTo(60));
- expect(
- tester.getTopLeft(find.text('owner').first).dx,
- projectX,
- reason: 'People and agent identity use the same text column',
- );
- f.controller.select('os-lead');
- await tester.pumpAndSettle();
- for (final i in [0, 1, 3]) {
- expect(f.row(i), findsNothing);
- }
- expect(f.inRow(2, find.text('autonomous-os')), findsOneWidget);
- expect(find.text('owner'), findsOneWidget);
- await tester.tap(find.byTooltip('Add agent'));
- expect(f.added?.id, 'os-lead');
- f.controller.select('offline');
- await tester.pumpAndSettle();
- expect(f.row(2), findsNothing);
- expect(
- tester.getTopLeft(f.row(0)).dy,
- lessThan(tester.getTopLeft(f.row(1)).dy),
- );
- expect(
- tester.getTopLeft(f.row(1)).dy,
- lessThan(tester.getTopLeft(f.row(3)).dy),
- );
- await tester.tap(f.row(1));
- await tester.pumpAndSettle();
- expect(find.byType(AlertDialog), findsOneWidget);
- await tester.tap(find.widgetWithText(FilledButton, 'Open terminal'));
- await tester.pumpAndSettle();
- expect(f.opened?.harnessId, 'a1');
- expect(f.controller.selectedId, 'offline');
- expect(f.server.posts, isEmpty);
- await f.close(tester);
- });
+ testWidgets(
+ 'authorized roster stays stable across projects, workgroups and Devices',
+ (tester) async {
+ final f = await fixture(tester);
+ f.app.stateOf('m')!.agents = const [
+ Agent(
+ id: 'a0',
+ name: 'native',
+ engine: 'codex',
+ title: 'Join Super Tab roster',
+ ),
+ Agent(id: 'outside', name: 'Not in this Swarm', engine: 'codex'),
+ ];
+ (f.server.state['conversations'] as List).add({
+ ...conversationFixture('os-work', 'OS work'),
+ 'projectId': 'os',
+ 'agentIds': ['agent-2'],
+ });
+ await f.controller.refresh();
+ await f.show(tester);
+ expect(f.inRow(2, find.text('autonomous-os')), findsOneWidget);
+ for (final i in [0, 1, 3]) {
+ expect(f.inRow(i, find.byType(SuperTabAvatar)), findsOneWidget);
+ expect(f.inRow(i, find.text(i == 0 ? 'PM' : 'Dev')), findsOneWidget);
+ expect(f.inRow(i, find.text('openharness')), findsOneWidget);
+ }
+ expect(find.text('Join Super Tab roster'), findsNothing);
+ expect(find.text('Not in this Swarm'), findsNothing);
+ expect(find.text('Ready'), findsNothing);
+ final nameX = tester.getTopLeft(f.inRow(0, find.text('Atlas'))).dx;
+ final project = tester.getRect(f.inRow(0, find.text('openharness')));
+ final name = tester.getRect(f.inRow(0, find.text('Atlas')));
+ final status = tester.getRect(f.inRow(0, find.text('Idle')));
+ final mark = tester.getRect(f.inRow(0, find.byType(ActivityMark)));
+ expect(project.left, greaterThan(name.right));
+ expect(project.center.dy, closeTo(name.center.dy, 2));
+ expect(mark.left, nameX);
+ expect(status.left, greaterThan(mark.right));
+ expect(status.top, greaterThanOrEqualTo(name.bottom));
+ expect(tester.getSize(f.row(0)).height, lessThanOrEqualTo(60));
+ expect(
+ tester.getTopLeft(find.text('owner').first).dx,
+ nameX,
+ reason: 'People and agent identity use the same text column',
+ );
+ final rows = [for (var i = 0; i < 4; i++) tester.getRect(f.row(i))];
+ final people = tester.getRect(find.text('owner'));
+ for (final selected in ['os-lead', 'offline', 'os-work']) {
+ f.controller.select(selected);
+ await tester.pumpAndSettle();
+ for (var i = 0; i < 4; i++) {
+ expect(tester.getRect(f.row(i)), rows[i]);
+ expect(f.inRow(i, find.byType(ActivityMark)), findsOneWidget);
+ }
+ expect(tester.getRect(find.text('owner')), people);
+ await tester.tap(find.byTooltip('Add agent'));
+ expect(f.added?.id, selected);
+ }
+ f.controller.selectDevices();
+ await tester.pumpAndSettle();
+ expect(f.controller.devicesSelected, isTrue);
+ for (var i = 0; i < 4; i++) {
+ expect(tester.getRect(f.row(i)), rows[i]);
+ }
+ expect(tester.getRect(find.text('owner')), people);
+ f.controller.select('offline');
+ await tester.pumpAndSettle();
+ expect(
+ tester.getTopLeft(f.row(0)).dy,
+ lessThan(tester.getTopLeft(f.row(1)).dy),
+ );
+ expect(
+ tester.getTopLeft(f.row(1)).dy,
+ lessThan(tester.getTopLeft(f.row(3)).dy),
+ );
+ await tester.tap(f.row(1));
+ await tester.pumpAndSettle();
+ expect(find.byType(AlertDialog), findsOneWidget);
+ await tester.tap(find.widgetWithText(FilledButton, 'Open terminal'));
+ await tester.pumpAndSettle();
+ expect(f.opened?.harnessId, 'a1');
+ expect(f.controller.selectedId, 'offline');
+ expect(f.server.posts, isEmpty);
+ await f.close(tester);
+ },
+ );
for (final legacyAgent in [1, 2]) {
testWidgets(
@@ -798,7 +845,10 @@ void main() {
'lead',
);
await f.show(tester);
- expect(f.row(legacyAgent), findsNothing);
+ expect(
+ f.inRow(legacyAgent, find.text('autonomous-os')),
+ findsOneWidget,
+ );
f.controller.select('os-lead');
await tester.pumpAndSettle();
expect(
@@ -821,31 +871,287 @@ void main() {
});
await f.controller.refresh();
await f.show(tester);
- expect(f.row(1), findsOneWidget);
+ expect(f.inRow(1, find.text('openharness')), findsOneWidget);
f.controller.select('os-lead');
await tester.pumpAndSettle();
- expect(f.row(1), findsNothing);
+ expect(f.inRow(1, find.text('openharness')), findsOneWidget);
await f.close(tester);
});
- testWidgets('no selected project shows no agent rows', (tester) async {
+ testWidgets('no selected project still shows the authorized directory', (
+ tester,
+ ) async {
final f = await fixture(tester);
f.controller.selectedId = 'missing';
await f.show(tester);
for (var i = 0; i < 4; i++) {
- expect(f.row(i), findsNothing);
+ expect(f.row(i), findsOneWidget);
}
expect(find.text('owner'), findsOneWidget);
expect(find.byTooltip('Add agent'), findsNothing);
await f.close(tester);
});
+ testWidgets('assigned work is visible without invented activity durations', (
+ tester,
+ ) async {
+ final f = await fixture(tester);
+ (f.server.state['conversations'] as List)[1]
+ ..['title'] = 'Polish navigation'
+ ..['assignment'] = {'agentId': 'agent-1', 'status': 'planned'};
+ await f.controller.refresh();
+ await f.show(tester, nativeState: false);
+ expect(
+ f.inRow(1, find.text('Assigned to "Polish navigation"')),
+ findsOneWidget,
+ );
+ expect(f.inRow(0, find.text('Status unavailable')), findsOneWidget);
+ expect(f.activity(tester, 1), HarnessActivity.unknown);
+ final copy = tester
+ .widgetList<Text>(
+ find.descendant(of: f.row(1), matching: find.byType(Text)),
+ )
+ .map((text) => text.data ?? '')
+ .join(' ');
+ expect(
+ copy,
+ isNot(matches(RegExp(r'\b\d+\s*(seconds?|minutes?|hours?|tokens?)\b'))),
+ );
+ expect(rowTooltip(tester, f, 1), isNot(contains('Last active')));
+ await f.close(tester);
+ });
+
+ testWidgets(
+ 'retained working tasks need native activity before claiming work',
+ (tester) async {
+ final f = await fixture(tester);
+ (f.server.state['conversations'] as List)[1]
+ ..['title'] = 'Polish navigation'
+ ..['assignment'] = {'agentId': 'agent-1', 'status': 'working'};
+ await f.controller.refresh();
+ final machine = f.app.stateOf('m')!;
+ for (final activity in [
+ HarnessActivity.idle,
+ HarnessActivity.done,
+ HarnessActivity.unknown,
+ HarnessActivity.working,
+ ]) {
+ machine.processingAgentIds.clear();
+ machine.unknownActivityAgentIds.clear();
+ f.app.markAgentSeen('m', 'a1');
+ switch (activity) {
+ case HarnessActivity.done:
+ f.app.agentUnread.mark('m', 'a1', AlertKind.done);
+ case HarnessActivity.unknown:
+ machine.unknownActivityAgentIds.add('a1');
+ case HarnessActivity.working:
+ machine.processingAgentIds.add('a1');
+ default:
+ break;
+ }
+ await f.show(tester);
+ final status = activity == HarnessActivity.working
+ ? 'Working on "Polish navigation"'
+ : 'Assigned to "Polish navigation"';
+ expect(f.activity(tester, 1), activity);
+ expect(f.inRow(1, find.text(status)), findsOneWidget);
+ expect(rowTooltip(tester, f, 1), contains(status));
+ if (activity != HarnessActivity.working) {
+ expect(rowTooltip(tester, f, 1), isNot(contains('Working on')));
+ }
+ }
+ await f.show(tester, nativeState: false);
+ expect(f.activity(tester, 1), HarnessActivity.unknown);
+ expect(
+ f.inRow(1, find.text('Assigned to "Polish navigation"')),
+ findsOneWidget,
+ );
+ await f.close(tester);
+ },
+ );
+
+ testWidgets('cancelled work cannot hide a later current assignment', (
+ tester,
+ ) async {
+ final f = await fixture(tester);
+ (f.server.state['conversations'] as List)[1]
+ ..['title'] = 'Cancelled task'
+ ..['assignment'] = {'agentId': 'agent-1', 'status': 'cancelled'};
+ final currentTask = {
+ ...conversationFixture('current-task', 'Polish navigation'),
+ 'assignment': {'agentId': 'agent-1', 'status': 'planned'},
+ };
+ (f.server.state['conversations'] as List).add(currentTask);
+ await f.controller.refresh();
+ await f.show(tester, nativeState: false);
+ expect(
+ f.inRow(1, find.text('Assigned to "Polish navigation"')),
+ findsOneWidget,
+ );
+ expect(rowTooltip(tester, f, 1), isNot(contains('Cancelled task')));
+
+ (currentTask['assignment'] as Map)['status'] = 'cancelled';
+ await f.controller.refresh();
+ await tester.pumpAndSettle();
+ expect(f.inRow(1, find.text('Status unavailable')), findsOneWidget);
+ expect(rowTooltip(tester, f, 1), isNot(contains('Polish navigation')));
+ expect(rowTooltip(tester, f, 1), isNot(contains('Working on')));
+ await f.close(tester);
+ });
+
+ testWidgets('explicit task states remain visible without a native turn', (
+ tester,
+ ) async {
+ final f = await fixture(tester);
+ for (final (status, activity, label) in [
+ ('blocked', HarnessActivity.needsInput, 'Needs input'),
+ (
+ 'review',
+ HarnessActivity.idle,
+ 'Waiting for review on "Polish navigation"',
+ ),
+ ('reconciling', HarnessActivity.idle, 'Checking "Polish navigation"'),
+ ]) {
+ (f.server.state['conversations'] as List)[1]
+ ..['title'] = 'Polish navigation'
+ ..['assignment'] = {'agentId': 'agent-1', 'status': status};
+ await f.controller.refresh();
+ await f.show(tester);
+ expect(f.activity(tester, 1), activity);
+ expect(f.inRow(1, find.text(label)), findsOneWidget);
+ expect(rowTooltip(tester, f, 1), isNot(contains('Working on')));
+ }
+ await f.close(tester);
+ });
+
+ testWidgets('agent facts use native activity when no override is supplied', (
+ tester,
+ ) async {
+ final f = await fixture(tester);
+ (f.server.state['conversations'] as List)[1]
+ ..['title'] = 'Polish navigation'
+ ..['assignment'] = {'agentId': 'agent-1', 'status': 'working'};
+ await f.controller.refresh();
+ final machine = f.app.stateOf('m')!;
+ final agent = f.controller.snapshot!.agent('agent-1')!;
+ String? status() => SuperTabAgentInfo(f.controller, f.app, agent).status;
+ expect(status(), 'Assigned to "Polish navigation"');
+ machine.processingAgentIds.add('a1');
+ expect(status(), 'Working on "Polish navigation"');
+ machine.agents = const [
+ Agent(id: 'a1', name: 'Sage', engine: 'claude', status: 'stopped'),
+ ];
+ expect(status(), 'Stopped');
+ machine.connectionStatus = ConnectionStatus.disconnected;
+ expect(status(), 'Offline');
+ await f.close(tester);
+ });
+
+ testWidgets(
+ 'lifecycle status takes precedence over a retained working task',
+ (tester) async {
+ final f = await fixture(tester);
+ (f.server.state['conversations'] as List)[1]['assignment'] = {
+ 'agentId': 'agent-1',
+ 'status': 'working',
+ };
+ await f.controller.refresh();
+ final machine = f.app.stateOf('m')!;
+ for (final (activity, status, data) in [
+ (HarnessActivity.offline, 'Offline', <String, dynamic>{}),
+ (HarnessActivity.paused, 'Stopped', {'status': 'stopped'}),
+ (HarnessActivity.starting, 'Starting', {'launchState': 'starting'}),
+ (HarnessActivity.failed, 'Failed', {'launchState': 'failed'}),
+ (
+ HarnessActivity.needsInput,
+ 'Needs input',
+ {'launchState': 'failed', 'launchError': 'RESUME_UNCONFIRMED'},
+ ),
+ ]) {
+ machine
+ ..connectionStatus = activity == HarnessActivity.offline
+ ? ConnectionStatus.disconnected
+ : ConnectionStatus.connected
+ ..agents = [
+ Agent(
+ id: 'a1',
+ name: 'Sage',
+ engine: 'claude',
+ status: data['status'] as String? ?? 'active',
+ launchState: data['launchState'] as String? ?? 'ready',
+ launchError: data['launchError'] as String?,
+ ),
+ ];
+ await f.show(tester);
+ expect(f.activity(tester, 1), activity);
+ expect(f.inRow(1, find.text(status)), findsOneWidget);
+ expect(f.inRow(1, find.textContaining('Working on')), findsNothing);
+ expect(rowTooltip(tester, f, 1), isNot(contains('Working on')));
+ }
+ await f.close(tester);
+ },
+ );
+
+ for (final width in [220.0, 280.0]) {
+ for (final scale in [1.0, 2.0]) {
+ testWidgets('agent identity and status fit $width pixels at ${scale}x', (
+ tester,
+ ) async {
+ final f = await fixture(tester);
+ await tester.binding.setSurfaceSize(Size(width, 700));
+ const longName = 'Alexandria Montgomery';
+ const longProject = 'an-extremely-long-project-identifier';
+ (f.server.state['agents'] as List)[0]['displayName'] = longName;
+ (f.server.state['projects'] as List)[0]['name'] = longProject;
+ await f.controller.refresh();
+ await f.show(tester, nativeState: false, scale: scale);
+ final row = tester.getRect(f.row(0));
+ final name = tester.getRect(f.inRow(0, find.text(longName)));
+ final badgeFinder = f.inRow(0, find.text('PM'));
+ final badge = tester.getRect(badgeFinder);
+ final status = tester.getRect(
+ f.inRow(0, find.text('Status unavailable')),
+ );
+ final mark = tester.getRect(f.inRow(0, find.byType(ActivityMark)));
+ expect(name.left, tester.getTopLeft(find.text('owner')).dx);
+ expect(mark.left, name.left);
+ expect(name.right, lessThan(badge.left));
+ expect(status.top, greaterThanOrEqualTo(name.bottom));
+ for (final bounds in [name, badge, status, mark]) {
+ expect(bounds.left, greaterThanOrEqualTo(row.left));
+ expect(bounds.right, lessThanOrEqualTo(row.right));
+ expect(bounds.bottom, lessThanOrEqualTo(row.bottom));
+ }
+ expect(
+ tester.renderObject<RenderParagraph>(badgeFinder).didExceedMaxLines,
+ isFalse,
+ );
+ expect(
+ tester.widget<Text>(badgeFinder).style!.fontSize,
+ greaterThanOrEqualTo(12),
+ );
+ final tooltip = rowTooltip(tester, f, 0);
+ for (final fact in [
+ longName,
+ 'Product Manager',
+ longProject,
+ 'Status unavailable',
+ ]) {
+ expect(tooltip, contains(fact));
+ }
+ expect(tester.takeException(), isNull);
+ await f.close(tester);
+ });
+ }
+ }
+
testWidgets('live turns and unread changes update the same status cell', (
tester,
) async {
final f = await fixture(tester);
await f.show(tester);
expect(f.activity(tester, 0), HarnessActivity.idle);
+ expect(f.inRow(0, find.text('○')), findsOneWidget);
final mark = f.inRow(0, find.byType(ActivityMark));
final position = tester.getTopLeft(mark);
await f.app.handleEventForTest('m', {
@@ -854,6 +1160,7 @@ void main() {
});
await tester.pump();
expect(f.activity(tester, 0), HarnessActivity.working);
+ expect(f.inRow(0, find.text('○')), findsNothing);
f.app.agentUnread.mark('m', 'a0', AlertKind.done);
await tester.pump();
expect(f.activity(tester, 0), HarnessActivity.working);
@@ -863,11 +1170,14 @@ void main() {
});
await tester.pump();
expect(f.activity(tester, 0), HarnessActivity.done);
+ expect(f.inRow(0, find.text('✓')), findsOneWidget);
+ expect(f.inRow(0, find.text('○')), findsNothing);
expect(rowTooltip(tester, f, 0), contains('Finished'));
expect(f.inRow(0, find.byType(Tooltip)), findsNothing);
f.app.markAgentSeen('m', 'a0');
await tester.pump();
expect(f.activity(tester, 0), HarnessActivity.idle);
+ expect(f.inRow(0, find.text('○')), findsOneWidget);
expect(tester.getTopLeft(mark), position);
f.app.agentUnread.mark('m', 'a0', AlertKind.done);
await tester.pump();
@@ -916,7 +1226,9 @@ void main() {
'roster marks remain legible in ${brightness.name} at ${scale}x',
(tester) async {
final f = await fixture(tester);
- (f.server.state['agents'] as List)[2]['projectId'] = 'lead';
+ (f.server.state['conversations'] as List)[0]
+ ..['title'] = 'Polish sidebar navigation'
+ ..['assignment'] = {'agentId': 'agent-0', 'status': 'working'};
await f.controller.refresh();
final previous = grid.AppTheme.brightness.value;
grid.AppTheme.brightness.value = brightness;
diff --git a/desktop/test/super_tab_sidebar_test.dart b/desktop/test/super_tab_sidebar_test.dart
index 767dcb246..0b722ed12 100644
--- a/desktop/test/super_tab_sidebar_test.dart
+++ b/desktop/test/super_tab_sidebar_test.dart
@@ -6,648 +6,352 @@ import 'package:harness/shared/theme/app_icons.dart';
import 'package:harness/shared/theme/app_theme.dart' as grid;
import 'package:harness/state/app_state.dart';
import 'package:harness/super_tabs/controller.dart';
-import 'package:harness/super_tabs/identity.dart';
import 'package:harness/super_tabs/machine_status.dart';
-import 'package:harness/super_tabs/machines.dart';
import 'package:harness/super_tabs/project_sidebar.dart';
import 'package:harness/super_tabs/section_heading.dart';
-import 'package:harness/super_tabs/view.dart';
import 'support/super_tab_fixture.dart';
import 'swarm_state_test.dart' show createApp;
-/// The Machines group's heading, wherever the sidebar is mounted.
-Finder machinesHeading() => find.ancestor(
- of: find.text('Machines'),
- matching: find.byType(SuperTabSectionHeading),
-);
+Finder inRow(String key, Finder finder) =>
+ find.descendant(of: find.byKey(ValueKey(key)), matching: finder);
-/// The unread mark at the right end of a project or workgroup row.
-Finder unreadDot(String groupId) => find.descendant(
- of: find.byKey(ValueKey('super-group-$groupId')),
- matching: find.byWidgetPredicate(
+Finder unreadDot(String groupId) => inRow(
+ 'super-group-$groupId',
+ find.byWidgetPredicate(
(w) => w is Semantics && w.properties.label == 'Unread messages',
),
);
-void main() {
- for (final scale in [1.0, 2.0]) {
- testWidgets(
- 'sidebar shares text alignment and preserves lead navigation at ${scale}x',
- (tester) async {
- await tester.binding.setSurfaceSize(const Size(1600, 700));
- addTearDown(() => tester.binding.setSurfaceSize(null));
- final app = createApp(connected: true);
- addTearDown(app.dispose);
- final server = ConversationServer();
- server.state['projects'] = [
- projectFixture('lead', 'web-project', 'lead'),
- projectFixture(
- 'empty',
- 'sample-project',
- 'empty-lead',
- visibility: 'private',
- ),
- ];
- (server.state['conversations'] as List)[1]
- ..['projectId'] = 'lead'
- ..['number'] = 12;
- (server.state['conversations'] as List).add({
- ...conversationFixture('empty-lead', 'Lead'),
- 'projectId': 'empty',
- });
- final c = server.controller();
- await c.refresh();
- var created = 0;
- await tester.pumpWidget(
- MaterialApp(
- theme: grid.buildAppTheme(brightness: Brightness.dark),
- builder: (context, child) => MediaQuery(
- data: MediaQuery.of(context)
- .copyWith(textScaler: TextScaler.linear(scale)),
- child: child!,
- ),
- home: Scaffold(
- body: SuperTabView(
- controller: c,
- app: app,
- onInvite: () {},
- onAddAgent: (_) {},
- onOpenTerminal: (_) {},
- onNewProject: () => created++,
- machineName: (_) => 'Test Mac',
- ),
- ),
- ),
- );
- await tester.pumpAndSettle();
- final sidebar = find.byType(ProjectSidebar);
- Finder inside(Finder finder) =>
- find.descendant(of: sidebar, matching: finder);
- final expand = find.byKey(const ValueKey('super-project-expand-lead'));
- final empty = find.byKey(const ValueKey('super-project-expand-empty'));
- expect(expand, findsOneWidget);
- expect(empty, findsOneWidget);
- expect(inside(find.byType(OutlinedButton)), findsNothing);
- expect(inside(find.text('Projects')), findsOneWidget);
- expect(inside(find.text('Machines')), findsOneWidget);
+Material rowMaterial(WidgetTester tester, String key) => tester.widget(
+ find
+ .ancestor(of: find.byKey(ValueKey(key)), matching: find.byType(Material))
+ .first,
+);
- // Project names always select the lead; disclosure never switches chats.
- await tester.tap(inside(find.text('sample-project')));
- await tester.pumpAndSettle();
- expect(c.selectedId, 'empty-lead');
- await tester.tap(expand);
- await tester.pumpAndSettle();
- expect(c.selectedId, 'empty-lead');
- final work = find.byKey(const ValueKey('super-group-offline'));
- expect(work, findsOneWidget);
- // Projects share a column; their workgroups sit one step further in.
- final projectX = tester.getTopLeft(inside(find.text('web-project'))).dx;
- const step = SuperTabSectionHeading.indentStep;
- expect(
- tester.getTopLeft(inside(find.text('sample-project'))).dx,
- projectX,
- );
- expect(
- tester.getTopLeft(inside(find.text('#12 Offline editing'))).dx,
- projectX + step,
- );
- // Your devices is a heading action beside Add machine, not a row.
- expect(inside(find.text('Your devices')), findsNothing);
- final yourDevices = find.byKey(const ValueKey('super-your-devices'));
- expect(
- find.descendant(of: machinesHeading(), matching: yourDevices),
- findsOneWidget,
- );
- expect(
- find.descendant(
- of: yourDevices,
- matching: find.byTooltip('Your devices'),
+Future<void> pumpSidebar(
+ WidgetTester tester,
+ SuperTabController controller,
+ AppNotifier app, {
+ double width = 280,
+ double scale = 1,
+ bool devices = true,
+ VoidCallback? onNewProject,
+ VoidCallback? onYourDevices,
+ DateTime Function()? now,
+ Future<MachineResources?> Function(String)? readLocal,
+}) async {
+ await tester.binding.setSurfaceSize(Size(width, 1000));
+ await tester.pumpWidget(
+ MaterialApp(
+ theme: grid.buildAppTheme(brightness: Brightness.dark),
+ builder: (context, child) => MediaQuery(
+ data: MediaQuery.of(context)
+ .copyWith(textScaler: TextScaler.linear(scale)),
+ child: child!,
+ ),
+ home: Scaffold(
+ body: ListenableBuilder(
+ listenable: controller,
+ builder: (context, _) => ProjectSidebar(
+ controller: controller,
+ app: app,
+ onAddAgent: (_) {},
+ needsHuman: (_) => 0,
+ onSelect: controller.select,
+ onNewProject: onNewProject ?? () {},
+ onYourDevices: devices
+ ? () {
+ onYourDevices?.call();
+ controller.selectDevices();
+ }
+ : null,
+ devicesSelected: controller.devicesSelected,
+ readLocal: readLocal,
+ now: now ?? DateTime.now,
),
- findsOneWidget,
- );
- final projectRect = tester.getRect(
- find.byKey(const ValueKey('super-group-lead')),
- );
- final workRect = tester.getRect(work);
- expect(workRect.left, projectRect.left);
- expect(workRect.right, projectRect.right);
+ ),
+ ),
+ ),
+ );
+ await tester.pumpAndSettle();
+}
- await tester.tap(work);
- await tester.pumpAndSettle();
- expect(c.selectedId, 'offline');
- await tester.tap(empty);
- await tester.pumpAndSettle();
- expect(c.selectedId, 'offline');
- expect(c.expandedProjects, contains('empty'));
- expect(inside(find.text('No workgroups yet')), findsOneWidget);
- expect(
- tester.getTopLeft(inside(find.text('No workgroups yet'))).dx,
- projectX + step,
- );
- expect(find.byTooltip('Collapse sample-project'), findsOneWidget);
- expect(
- find.descendant(
- of: empty,
- matching: find.byIcon(AppIcons.chevronDown),
- ),
- findsOneWidget,
- );
+Future<void> disposeSidebar(
+ WidgetTester tester,
+ SuperTabController controller,
+) async {
+ await tester.pumpWidget(const SizedBox());
+ await controller.flush();
+ controller.dispose();
+}
- await tester.tap(empty);
- await tester.pumpAndSettle();
- expect(inside(find.text('No workgroups yet')), findsNothing);
- expect(c.selectedId, 'offline');
+Future<SuperTabController> projectSidebar(ConversationServer server) async {
+ server.state['projects'] = [
+ projectFixture('lead', 'web-project', 'lead'),
+ projectFixture(
+ 'empty',
+ 'sample-project',
+ 'empty-lead',
+ visibility: 'private',
+ ),
+ ];
+ (server.state['conversations'] as List)[1]
+ ..['projectId'] = 'lead'
+ ..['number'] = 12
+ ..['lastMessageSequence'] = 5;
+ (server.state['conversations'] as List).add({
+ ...conversationFixture('empty-lead', 'Lead'),
+ 'projectId': 'empty',
+ });
+ final controller = server.controller();
+ await controller.refresh();
+ return controller;
+}
- // Both navigation actions retain keyboard activation.
- final newProject = find.byTooltip('New project');
- Focus.of(
- tester.element(
- find.descendant(
- of: newProject,
- matching: find.byIcon(AppIcons.plus),
- ),
- ),
- ).requestFocus();
- await tester.pump();
- await tester.sendKeyEvent(LogicalKeyboardKey.enter);
- await tester.pumpAndSettle();
- expect(created, 1);
- await tester.tap(find.byKey(const ValueKey('super-your-devices')));
- await tester.pumpAndSettle();
- expect(app.activeSwarm.isDevices, isTrue);
- expect(app.activeSwarm.panes.first.isDevices, isTrue);
- expect(app.activeSwarm.panes.last.isViewer, isFalse);
- expect(app.machinesRequest, isNull);
- final devicesId = app.activeSwarmId;
- await tester.tap(find.byKey(const ValueKey('super-your-devices')));
- await tester.pumpAndSettle();
- expect(app.activeSwarmId, devicesId);
- expect(app.swarms.where((s) => s.isDevices), hasLength(1));
- expect(c.selectedId, 'offline');
- expect(tester.takeException(), isNull);
- await tester.pumpWidget(const SizedBox());
- await c.flush();
- c.dispose();
- },
- );
- }
+void main() {
+ for (final scale in [1.0, 2.0]) {
+ testWidgets('flat navigation shares text and selection bounds; disclosure does not '
+ 'switch chats at ${scale}x', (tester) async {
+ addTearDown(() => tester.binding.setSurfaceSize(null));
+ final app = createApp(connected: true);
+ addTearDown(app.dispose);
+ final server = ConversationServer();
+ final controller = await projectSidebar(server);
+ var created = 0;
+ var openedDevices = 0;
+ await pumpSidebar(
+ tester,
+ controller,
+ app,
+ scale: scale,
+ onNewProject: () => created++,
+ onYourDevices: () => openedDevices++,
+ );
+ final expand = find.byKey(const ValueKey('super-project-expand-lead'));
+ final empty = find.byKey(const ValueKey('super-project-expand-empty'));
+ final devices = find.byKey(const ValueKey('super-your-devices'));
+ final newProject = find.byKey(const ValueKey('super-new-project'));
+ expect(find.byType(OutlinedButton), findsNothing);
+ expect(
+ tester.getBottomLeft(devices).dy,
+ lessThan(tester.getTopLeft(find.text('Projects')).dy),
+ );
+ expect(
+ tester.getBottomLeft(newProject).dy,
+ lessThan(tester.getTopLeft(devices).dy),
+ );
+ expect(
+ inRow('super-group-lead', find.byIcon(AppIcons.folder)),
+ findsOneWidget,
+ );
- /// A sidebar whose second project has an unread message, so its row draws
- /// the dot the headings' actions line up with.
- Future<SuperTabController> unreadSidebar(ConversationServer server) async {
- server.state['projects'] = [
- projectFixture('lead', 'web-project', 'lead'),
- projectFixture('other', 'other-project', 'other-lead'),
- ];
- (server.state['conversations'] as List).add({
- ...conversationFixture('other-lead', 'Lead'),
- 'projectId': 'other',
- 'lastMessageSequence': 5,
- });
- // Machines at their busiest: a long name with five agents and an allowance running out, two that share a
- // name, and one offline under its open disclosure.
- (server.state['people'] as List).add({
- 'id': 'tony',
- 'email': '[email protected]',
- 'role': 'collaborator',
- });
- final at = DateTime.now().millisecondsSinceEpoch;
- Map<String, dynamic> machine(
- String id,
- String name, {
- String owner = 'owner',
- int age = 0,
- int used = 20,
- }) => {
- 'machineId': id,
- 'name': name,
- 'contributorId': owner,
- 'observation': {
- 'receivedAt': at - age,
- 'resources': {'cpuPercent': 37, 'gpuPercent': 4},
- 'quotas': [
- {
- 'engine': 'claude',
- 'known': true,
- 'windows': [
- {'name': '5-hour', 'usedPercent': used},
- ],
- },
- ],
- },
- };
- server.state['machines'] = [
- machine('studio', 'Design Studio’s long-named Mac Studio', used: 98),
- machine('mbp-a', 'MacBook Pro'),
- machine('mbp-b', 'MacBooks-MacBook-Pro-9.local', owner: 'tony'),
- machine('old', 'Old Mini', age: 600000),
- ];
- server.state['agents'] = [
- for (var i = 0; i < 5; i++)
- {
- 'id': 'agent-$i',
- 'name': 'Harness $i',
- 'displayName': 'Engineer $i',
- 'machineId': 'studio',
- 'harnessId': 'native-$i',
- 'contributorId': 'owner',
- 'configuration': {'engine': 'claude'},
- },
- ];
- final c = server.controller();
- await c.refresh();
- c.offlineMachinesOpen = true;
- return c;
- }
+ await tester.tap(find.text('sample-project'));
+ await tester.pumpAndSettle();
+ expect(controller.selectedId, 'empty-lead');
+ await tester.tap(expand);
+ await tester.pumpAndSettle();
+ expect(controller.selectedId, 'empty-lead');
+ expect(
+ inRow('super-group-lead', find.byIcon(AppIcons.folderOpen)),
+ findsOneWidget,
+ );
+ final work = find.byKey(const ValueKey('super-group-offline'));
+ expect(work, findsOneWidget);
+ final textX = tester.getTopLeft(find.text('web-project')).dx;
+ for (final label in [
+ 'New project',
+ 'Your devices',
+ 'sample-project',
+ '#12 Offline editing',
+ ]) {
+ expect(tester.getTopLeft(find.text(label)).dx, textX, reason: label);
+ }
+ expect(
+ tester.getCenter(unreadDot('offline')).dx,
+ tester.getCenter(unreadDot('lead')).dx,
+ );
+ expect(
+ tester.getCenter(unreadDot('lead')).dx,
+ lessThan(tester.getTopLeft(expand).dx),
+ );
+ for (final row in [newProject, devices, work]) {
+ final bounds = tester.getRect(row);
+ final projectBounds = tester.getRect(
+ find.byKey(const ValueKey('super-group-lead')),
+ );
+ expect(bounds.left, projectBounds.left);
+ expect(bounds.right, projectBounds.right);
+ }
- Future<void> pumpSidebar(
- WidgetTester tester,
- SuperTabController c,
- AppNotifier app, {
- required double width,
- double scale = 1,
- bool devices = true,
- DateTime Function()? now,
- }) async {
- await tester.binding.setSurfaceSize(Size(width, 700));
- await tester.pumpWidget(
- MaterialApp(
- theme: grid.buildAppTheme(brightness: Brightness.dark),
- builder: (context, child) => MediaQuery(
- data: MediaQuery.of(context)
- .copyWith(textScaler: TextScaler.linear(scale)),
- child: child!,
- ),
- home: Scaffold(
- body: SizedBox(
- width: width,
- child: ProjectSidebar(
- controller: c,
- app: app,
- onAddAgent: (_) {},
- needsHuman: (_) => 0,
- onSelect: (_) {},
- onNewProject: () {},
- onYourDevices: devices ? () {} : null,
- now: now ?? DateTime.now,
- ),
- ),
- ),
- ),
- );
- await tester.pumpAndSettle();
- }
+ await tester.tap(work);
+ await tester.pumpAndSettle();
+ expect(controller.selectedId, 'offline');
+ await tester.tap(empty);
+ await tester.pumpAndSettle();
+ expect(controller.selectedId, 'offline');
+ expect(find.text('No workgroups yet'), findsOneWidget);
+ expect(tester.getTopLeft(find.text('No workgroups yet')).dx, textX);
+ expect(find.byTooltip('Collapse sample-project'), findsOneWidget);
+ await tester.tap(empty);
+ await tester.pumpAndSettle();
+ expect(find.text('No workgroups yet'), findsNothing);
- /// Both headings' + are centered on the column of the project rows' dots,
- /// with Your devices right before the Machines +.
- void expectHeadingActionsAligned(WidgetTester tester, String reason) {
- final dot = tester.getCenter(unreadDot('other-lead')).dx;
- final projectAdd = tester.getRect(find.byTooltip('New project'));
- final machinesAdd = tester.getRect(find.byTooltip('Add machine'));
- expect(projectAdd.center.dx, closeTo(dot, 0.01), reason: reason);
- expect(machinesAdd.center.dx, closeTo(dot, 0.01), reason: reason);
- final devices = tester.getRect(
- find.byKey(const ValueKey('super-your-devices')),
- );
- expect(devices.size, machinesAdd.size, reason: reason);
- expect(devices.center.dy, machinesAdd.center.dy, reason: reason);
- expect(devices.right, closeTo(machinesAdd.left, 0.01), reason: reason);
- // Every machine's agents column ends half an avatar past the + column, so a
- // trailing avatar centers under the + and a +N count ends with it.
- final more = find.descendant(
- of: find.byKey(const ValueKey('super-machine-studio')),
- matching: find.textContaining('+'),
- );
- expect(more, findsOneWidget, reason: reason);
- expect(tester.getRect(more).right, closeTo(dot + 9, 0.5), reason: reason);
- // The row never names the owner, even when another machine shares the name; a name cut short shows itself
- // whole on hover.
- final shared = find
- .descendant(
- of: find.byKey(const ValueKey('super-machine-mbp-b')),
- matching: find.byType(RichText),
- )
- .evaluate()
- .map((e) => (e.widget as RichText).text.toPlainText())
- .join();
- expect(shared, isNot(contains('tony')), reason: reason);
- // Its real hostname, without .local; cut short, it shows itself whole on hover.
- if (shared != 'MacBooks-MacBook-Pro-9') {
+ // The plain top actions retain keyboard operation and do not create tabs.
+ Focus.of(tester.element(find.text('New project'))).requestFocus();
+ await tester.pump();
+ await tester.sendKeyEvent(LogicalKeyboardKey.enter);
+ await tester.pumpAndSettle();
+ expect(created, 1);
+ await tester.tap(find.byTooltip('New project'));
+ await tester.pumpAndSettle();
+ expect(created, 2);
+ final tabsBefore = app.swarms.length;
+ Focus.of(tester.element(find.text('Your devices'))).requestFocus();
+ await tester.pump();
+ await tester.sendKeyEvent(LogicalKeyboardKey.enter);
+ await tester.pumpAndSettle();
+ expect(openedDevices, 1);
+ expect(controller.devicesSelected, isTrue);
+ expect(controller.selectedId, 'offline');
+ expect(app.swarms, hasLength(tabsBefore));
expect(
- find.descendant(
- of: find.byKey(const ValueKey('super-machine-mbp-b')),
- matching: find.byTooltip('MacBooks-MacBook-Pro-9'),
- ),
- findsOneWidget,
- reason: reason,
+ rowMaterial(tester, 'super-your-devices').color,
+ grid.AppSurface.selectedFill,
);
- }
- // Every machine is one line, as tall as a project row at this text size.
- final projectRow = tester.getSize(
- find.byKey(const ValueKey('super-group-other-lead')),
- );
- for (final id in ['studio', 'mbp-a', 'mbp-b', 'old']) {
expect(
- tester.getSize(find.byKey(ValueKey('super-machine-$id'))).height,
- closeTo(projectRow.height, 0.01),
- reason: '$id $reason',
+ rowMaterial(tester, 'super-group-offline').color,
+ Colors.transparent,
);
- }
+
+ // Returning to the already selected workgroup still leaves Devices.
+ await tester.tap(work);
+ await tester.pumpAndSettle();
+ expect(controller.devicesSelected, isFalse);
+ expect(controller.selectedId, 'offline');
+ expect(
+ rowMaterial(tester, 'super-group-offline').color,
+ grid.AppSurface.selectedFill,
+ );
+ expect(
+ rowMaterial(tester, 'super-your-devices').color,
+ Colors.transparent,
+ );
+ expect(tester.takeException(), isNull);
+ await disposeSidebar(tester, controller);
+ });
}
- testWidgets(
- "both headings' + are centered on the project rows' dot column, with "
- 'Your devices just before the Machines +, and no pill while live',
- (tester) async {
- addTearDown(() => tester.binding.setSurfaceSize(null));
- final app = createApp(connected: true);
- addTearDown(app.dispose);
- final server = ConversationServer();
- final c = await unreadSidebar(server);
- for (final width in [240.0, 420.0]) {
- await pumpSidebar(tester, c, app, width: width);
- final reason = 'at width $width';
- expect(unreadDot('other-lead'), findsOneWidget, reason: reason);
- expectHeadingActionsAligned(tester, reason);
- expect(find.byType(SuperTabMachinesPill), findsNothing, reason: reason);
- expect(find.text('Live'), findsNothing, reason: reason);
+ testWidgets('section disclosure follows its label and + aligns with the '
+ 'right disclosure column', (tester) async {
+ addTearDown(() => tester.binding.setSurfaceSize(null));
+ final app = createApp(connected: true);
+ addTearDown(app.dispose);
+ final controller = await projectSidebar(ConversationServer());
+ for (final width in [180.0, 280.0, 420.0]) {
+ await pumpSidebar(tester, controller, app, width: width);
+ for (final title in ['Projects', 'Machines']) {
+ final heading = find.ancestor(
+ of: find.text(title),
+ matching: find.byType(SuperTabSectionHeading),
+ );
+ final label = tester.getRect(find.text(title));
+ final chevron = tester.getRect(
+ find.descendant(
+ of: heading,
+ matching: find.byIcon(AppIcons.chevronDown),
+ ),
+ );
+ expect(chevron.left, closeTo(label.right + 4, .01));
+ expect(
+ tester.getCenter(find.byTooltip('New project')).dx,
+ tester.getCenter(find.byTooltip('Add machine')).dx,
+ );
}
-
- // Hidden when the devices view is unavailable.
- await pumpSidebar(tester, c, app, width: 240, devices: false);
- expect(find.byKey(const ValueKey('super-your-devices')), findsNothing);
- expect(find.byTooltip('Add machine'), findsOneWidget);
-
- await tester.pumpWidget(const SizedBox());
- await c.flush();
- c.dispose();
- },
- );
+ expect(
+ tester.getCenter(find.byTooltip('New project')).dx,
+ tester
+ .getCenter(find.byKey(const ValueKey('super-project-expand-lead')))
+ .dx,
+ );
+ expect(tester.takeException(), isNull);
+ }
+ await disposeSidebar(tester, controller);
+ });
testWidgets(
- 'the narrow drawer and minimum pane do not overflow, live or with a wide '
- 'reconnecting pill, and the heading actions stay aligned',
+ 'narrow panes and large text retain top navigation and a readable '
+ 'heading while machines reconnect',
(tester) async {
addTearDown(() => tester.binding.setSurfaceSize(null));
final app = createApp(connected: true);
addTearDown(app.dispose);
final server = ConversationServer();
- final c = await unreadSidebar(server);
-
+ final controller = await projectSidebar(server);
for (final unreachable in [false, true]) {
DateTime Function()? now;
if (unreachable) {
server.failReads = true;
- await c.refresh();
- expect(c.backendUnreachable, isTrue);
- // "Reconnecting · 12m" is close to the pill's widest normal content.
- final pinned = c.unreachableSince!.add(const Duration(minutes: 12));
+ await controller.refresh();
+ final pinned = controller.unreachableSince!.add(
+ const Duration(minutes: 12),
+ );
now = () => pinned;
}
for (final width in [180.0, 240.0]) {
for (final scale in [1.0, 2.0]) {
await pumpSidebar(
tester,
- c,
+ controller,
app,
width: width,
scale: scale,
now: now,
);
- final reason =
- 'at width $width, scale $scale, unreachable $unreachable';
+ final reason = '$width px, ${scale}x, unreachable=$unreachable';
expect(tester.takeException(), isNull, reason: reason);
+ expect(find.text('Your devices'), findsOneWidget, reason: reason);
expect(
- find.byType(SuperTabMachinesPill),
- unreachable ? findsOneWidget : findsNothing,
- reason: reason,
- );
- // The minimum pane leaves the pill only its dot, which says the
- // same on hover; anything wider spells it out.
- final words = width >= 240;
- expect(
- find.textContaining('Reconnecting'),
- unreachable && words ? findsOneWidget : findsNothing,
+ find.byTooltip('Add machine'),
+ findsOneWidget,
reason: reason,
);
expect(
- find.byTooltip('Reconnecting · 12m'),
- unreachable && !words ? findsOneWidget : findsNothing,
+ find.byType(SuperTabMachinesPill),
+ unreachable ? findsOneWidget : findsNothing,
reason: reason,
);
- expectHeadingActionsAligned(tester, reason);
if (unreachable) {
final pill = tester.getRect(find.byType(SuperTabMachinesPill));
- final devices = tester.getRect(
- find.byKey(const ValueKey('super-your-devices')),
- );
+ final add = tester.getRect(find.byTooltip('Add machine'));
+ expect(pill.right, lessThanOrEqualTo(add.left), reason: reason);
expect(
- pill.right,
- lessThanOrEqualTo(devices.left),
+ find.byTooltip('Reconnecting · 12m').evaluate().isNotEmpty ||
+ find.text('Reconnecting · 12m').evaluate().isNotEmpty,
+ isTrue,
reason: reason,
);
- expect(
- devices.left - pill.right,
- lessThan(20),
- reason: 'the pill sits flush before the actions, $reason',
- );
}
}
}
}
- await tester.pumpWidget(const SizedBox());
- await c.flush();
- c.dispose();
- },
- );
-
- testWidgets(
- 'one indent step makes a tree: headings, then projects, machines and '
- '"Offline · N", then workgroups and offline machines; the trailing column stays',
- (tester) async {
- addTearDown(() => tester.binding.setSurfaceSize(null));
- final app = createApp(connected: true);
- addTearDown(app.dispose);
- final server = ConversationServer();
- server.state['projects'] = [
- projectFixture('lead', 'web-project', 'lead'),
- projectFixture('empty', 'sample-project', 'empty-lead'),
- ];
- (server.state['conversations'] as List)[1]
- ..['projectId'] = 'lead'
- ..['number'] = 12
- ..['lastMessageSequence'] = 5;
- (server.state['conversations'] as List).add({
- ...conversationFixture('empty-lead', 'Lead'),
- 'projectId': 'empty',
- });
- final at = DateTime.now().millisecondsSinceEpoch;
- server.state['machines'] = [
- for (final (id, name, age) in [
- ('on', 'Studio Mac', 0),
- ('off', 'Old Mini', 600000),
- ])
- {
- 'machineId': id,
- 'name': name,
- 'contributorId': 'owner',
- 'observation': {'receivedAt': at - age},
- },
- ];
- server.state['agents'] = [
- {
- 'id': 'agent-0',
- 'name': 'Lead',
- 'displayName': 'Atlas',
- 'machineId': 'on',
- 'harnessId': 'a0',
- 'contributorId': 'owner',
- 'configuration': {'engine': 'claude'},
- },
- ];
- final c = server.controller();
- await c.refresh();
- c.expandedProjects.addAll(['lead', 'empty']);
- c.offlineMachinesOpen = true;
- const step = SuperTabSectionHeading.indentStep;
- for (final width in [180.0, 280.0]) {
- for (final scale in [1.0, 2.0]) {
- await pumpSidebar(tester, c, app, width: width, scale: scale);
- final reason = 'at width $width, scale $scale';
- expect(tester.takeException(), isNull, reason: reason);
- double centerX(Finder f) => tester.getCenter(f).dx;
- double leftX(Finder f) => tester.getTopLeft(f).dx;
- Finder inRow(String key, Finder f) =>
- find.descendant(of: find.byKey(ValueKey(key)), matching: f);
- Finder nameOf(String id) =>
- inRow('super-machine-$id', find.byType(RichText)).first;
-
- // Level 0: both headings share one chevron column and one text column.
- final icon = centerX(find.byTooltip('Collapse Projects'));
- final text = leftX(find.text('Projects'));
- expect(
- centerX(find.byTooltip('Collapse Machines')),
- icon,
- reason: reason,
- );
- expect(leftX(find.text('Machines')), text, reason: reason);
-
- // Level 1: one step in.
- for (final (what, mark, name) in [
- (
- 'project',
- find.byKey(const ValueKey('super-project-expand-lead')),
- find.text('web-project'),
- ),
- (
- 'machine',
- inRow('super-machine-on', find.byType(SuperTabMachineDot)),
- nameOf('on'),
- ),
- (
- 'offline disclosure',
- inRow('super-machines-offline', find.byType(Icon)),
- find.text('Offline · 1'),
- ),
- ]) {
- expect(
- centerX(mark),
- closeTo(icon + step, .01),
- reason: '$what $reason',
- );
- expect(
- leftX(name),
- closeTo(text + step, .01),
- reason: '$what $reason',
- );
- }
-
- // Level 2: two steps in.
- expect(
- leftX(find.text('#12 Offline editing')),
- closeTo(text + 2 * step, .01),
- reason: reason,
- );
- expect(
- leftX(find.text('No workgroups yet')),
- closeTo(text + 2 * step, .01),
- reason: reason,
- );
- expect(
- centerX(
- inRow('super-machine-off', find.byType(SuperTabMachineDot)),
- ),
- closeTo(icon + 2 * step, .01),
- reason: reason,
- );
- expect(
- leftX(nameOf('off')),
- closeTo(text + 2 * step, .01),
- reason: reason,
- );
-
- // The trailing column does not move with the level: a workgroup's
- // unread dot and a machine's last avatar center on the heading +.
- final add = centerX(find.byTooltip('New project'));
- expect(centerX(find.byTooltip('Add machine')), add, reason: reason);
- expect(
- centerX(
- inRow(
- 'super-group-offline',
- find.byWidgetPredicate(
- (w) =>
- w is Semantics && w.properties.label == 'Unread messages',
- ),
- ),
- ),
- closeTo(add, .01),
- reason: reason,
- );
- // The last agent mark, the avatar or +1 once the list counts agents, ends
- // half an avatar past the + column: an avatar centers under it.
- final more = inRow('super-machine-on', find.text('+1'));
- final avatar = inRow('super-machine-on', find.byType(SuperTabAvatar));
- if (more.evaluate().isNotEmpty) {
- expect(
- tester.getRect(more).right,
- closeTo(add + 9, .5),
- reason: reason,
- );
- } else {
- expect(centerX(avatar), closeTo(add, .5), reason: reason);
- }
-
- // Every row's fill spans the full row, whatever its level.
- final rows = [
- 'super-group-lead',
- 'super-group-offline',
- 'super-machine-on',
- 'super-machines-offline',
- 'super-machine-off',
- ].map((k) => tester.getRect(find.byKey(ValueKey(k))));
- for (final r in rows) {
- expect(r.left, rows.first.left, reason: reason);
- expect(r.right, rows.first.right, reason: reason);
- }
- }
- }
- await tester.pumpWidget(const SizedBox());
- await c.flush();
- c.dispose();
+ await pumpSidebar(tester, controller, app, devices: false);
+ expect(find.byKey(const ValueKey('super-your-devices')), findsNothing);
+ expect(find.byTooltip('Add machine'), findsOneWidget);
+ await disposeSidebar(tester, controller);
},
);
testWidgets('the left Machines group repaints on a live app change alone', (
tester,
) async {
+ addTearDown(() => tester.binding.setSurfaceSize(null));
final app = createApp(connected: true);
addTearDown(app.dispose);
final server = ConversationServer();
server.state['agents'] = [
{
'id': 'agent-0',
- 'projectId': null,
'name': 'Lead',
'displayName': 'Atlas',
'machineId': 'm',
@@ -656,108 +360,57 @@ void main() {
'configuration': {'engine': 'claude'},
},
];
- final c = server.controller();
- await c.refresh();
- await tester.pumpWidget(
- MaterialApp(
- theme: grid.buildAppTheme(brightness: Brightness.dark),
- home: Scaffold(
- body: ProjectSidebar(
- controller: c,
- app: app,
- onAddAgent: (_) {},
- needsHuman: (_) => 0,
- onSelect: (_) {},
- // This computer reads its own machine; a sample gives the row a
- // non-null age, so its status reflects `connected` immediately.
- readLocal: (_) async => const MachineResources(cpuPercent: 10),
- ),
- ),
- ),
+ final controller = server.controller();
+ await controller.refresh();
+ await pumpSidebar(
+ tester,
+ controller,
+ app,
+ readLocal: (_) async => const MachineResources(cpuPercent: 10),
);
- await tester.pumpAndSettle();
- // Let the first local read land.
await tester.pump();
await tester.pump();
- Finder statusDot() => find.descendant(
- of: find.byKey(const ValueKey('super-machine-m')),
- matching: find.byType(SuperTabMachineDot),
- );
+ final dot = inRow('super-machine-m', find.byType(SuperTabMachineDot));
expect(
- tester.widget<SuperTabMachineDot>(statusDot()).status,
+ tester.widget<SuperTabMachineDot>(dot).status,
isNot(SuperTabMachineStatus.offline),
);
- // The Machines group has no listener of its own on the controller the
- // rest of this sidebar rebuilds on, so a bare app event (no controller
- // change, no re-pump) must still repaint it.
await app.handleEventForTest('m', {'type': 'node_status', 'online': false});
await tester.pump();
- // Offline, it moves under the closed "Offline · 1"; opened, its dot says so.
- expect(statusDot(), findsNothing);
- expect(find.text('Offline · 1'), findsOneWidget);
- await tester.tap(find.byKey(const ValueKey('super-machines-offline')));
- await tester.pump();
+ expect(find.byKey(const ValueKey('super-machine-m')), findsOneWidget);
expect(
- tester.widget<SuperTabMachineDot>(statusDot()).status,
+ tester.widget<SuperTabMachineDot>(dot).status,
SuperTabMachineStatus.offline,
);
-
- await tester.pumpWidget(const SizedBox());
- await c.flush();
- c.dispose();
+ await disposeSidebar(tester, controller);
});
- testWidgets('Projects and Machines groups collapse and persist', (
+ testWidgets('section collapse persists and keeps top navigation available', (
tester,
) async {
+ addTearDown(() => tester.binding.setSurfaceSize(null));
final app = createApp(connected: true);
addTearDown(app.dispose);
final server = ConversationServer();
- server.state['projects'] = [projectFixture('lead', 'web-project', 'lead')];
- final c = server.controller();
- await c.refresh();
- await tester.pumpWidget(
- MaterialApp(
- theme: grid.buildAppTheme(brightness: Brightness.dark),
- home: Scaffold(
- body: SuperTabView(
- controller: c,
- app: app,
- onInvite: () {},
- onAddAgent: (_) {},
- onOpenTerminal: (_) {},
- onNewProject: () {},
- machineName: (_) => 'Test Mac',
- ),
- ),
- ),
- );
- await tester.pumpAndSettle();
- final sidebar = find.byType(ProjectSidebar);
- Finder inside(Finder finder) =>
- find.descendant(of: sidebar, matching: finder);
-
+ final controller = await projectSidebar(server);
+ await pumpSidebar(tester, controller, app);
const machinesBody = 'Add a machine for the product manager to use.';
- final yourDevices = find.byKey(const ValueKey('super-your-devices'));
- expect(inside(find.text('web-project')), findsOneWidget);
- expect(inside(find.text(machinesBody)), findsOneWidget);
- expect(inside(yourDevices), findsOneWidget);
+ expect(find.text('web-project'), findsOneWidget);
+ expect(find.text(machinesBody), findsOneWidget);
await tester.tap(find.byTooltip('Collapse Projects'));
await tester.pumpAndSettle();
- expect(inside(find.text('web-project')), findsNothing);
- expect(c.projectsGroupOpen, isFalse);
-
+ expect(find.text('web-project'), findsNothing);
+ expect(controller.projectsGroupOpen, isFalse);
await tester.tap(find.byTooltip('Collapse Machines'));
await tester.pumpAndSettle();
- expect(inside(find.text(machinesBody)), findsNothing);
- // A heading action, so it stays reachable while the group is collapsed.
- expect(inside(yourDevices), findsOneWidget);
- expect(c.machinesGroupOpen, isFalse);
+ expect(find.text(machinesBody), findsNothing);
+ expect(controller.machinesGroupOpen, isFalse);
+ expect(find.text('New project'), findsOneWidget);
+ expect(find.text('Your devices'), findsOneWidget);
- // Persisted state survives a restart of the sidebar's controller.
- await c.flush();
+ await controller.flush();
final saved = server.saved!;
expect(saved['projectsGroupOpen'], isFalse);
expect(saved['machinesGroupOpen'], isFalse);
@@ -766,12 +419,12 @@ void main() {
expect(reopened.projectsGroupOpen, isFalse);
expect(reopened.machinesGroupOpen, isFalse);
- await tester.tap(find.byTooltip('Expand Projects'));
+ Focus.of(tester.element(find.text('Projects'))).requestFocus();
+ await tester.pump();
+ await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pumpAndSettle();
- expect(inside(find.text('web-project')), findsOneWidget);
- await tester.pumpWidget(const SizedBox());
- await c.flush();
- c.dispose();
+ expect(find.text('web-project'), findsOneWidget);
+ await disposeSidebar(tester, controller);
await reopened.flush();
reopened.dispose();
});
diff --git a/desktop/test/super_tab_workspace_test.dart b/desktop/test/super_tab_workspace_test.dart
index 9879676f6..8bac67e4e 100644
--- a/desktop/test/super_tab_workspace_test.dart
+++ b/desktop/test/super_tab_workspace_test.dart
@@ -105,6 +105,85 @@ void main() {
},
);
+ testWidgets(
+ 'a ready replacement refreshes the terminal without changing member identity',
+ (tester) async {
+ final f = SuperTabLaunchFixture();
+ f.app.bindSuperTab(f.app.activeSwarmId, tabId, 'Pilot');
+ final member = {
+ 'id': 'stable-member',
+ 'name': 'Engineer',
+ 'displayName': 'Sage',
+ 'machineId': 'm',
+ 'harnessId': 'native-original',
+ 'contributorId': 'owner',
+ 'configuration': {'engine': 'codex'},
+ };
+ f.connection.server.state['agents'] = [member];
+ (f.connection.server.state['conversations'] as List)[0]['agentIds'] = [
+ 'stable-member',
+ ];
+ f.app.machineStates['m']!.agents = const [
+ Agent(
+ id: 'native-original',
+ name: 'Original',
+ engine: 'codex',
+ terminalAvailable: true,
+ ),
+ Agent(
+ id: 'native-replacement',
+ name: 'Replacement',
+ engine: 'claude',
+ terminalAvailable: true,
+ ),
+ ];
+ final c = await f.app.superTabs.open(tabId);
+ await c.refresh();
+ c.selectGroupTerminals('lead');
+ await tester.pumpWidget(
+ MaterialApp(
+ home: Scaffold(
+ body: ListenableBuilder(
+ listenable: f.app,
+ builder: (_, _) => SuperTabWorkspace(
+ app: f.app,
+ canvas: const Text('Native terminals'),
+ onAddAgent: (_) {},
+ ),
+ ),
+ ),
+ ),
+ );
+ await tester.pumpAndSettle();
+ expect(f.app.panes.single.agentId, 'native-original');
+
+ // A replacement from another client updates the binding while both
+ // native inventories remain ready, with the same stable member ID.
+ member['harnessId'] = 'native-replacement';
+ member['configuration'] = {'engine': 'claude'};
+ await c.refresh();
+ await tester.pumpAndSettle();
+ expect(c.snapshot!.agents.single.id, 'stable-member');
+ expect(c.snapshot!.agentName('stable-member'), 'Sage');
+ expect(c.selectedId, 'lead');
+ expect(f.app.panes.single.agentId, 'native-replacement');
+ expect(
+ f.connection.calls.where(
+ (call) =>
+ call.$1 == 'agent_resume' ||
+ call.$1 == 'agent_create' ||
+ call.$1 == 'agent_close',
+ ),
+ isEmpty,
+ );
+ expect(tester.takeException(), isNull);
+ await tester.pumpWidget(const SizedBox());
+ await c.flush();
+ f.app.superTabs.dispose();
+ await tester.pump();
+ },
+ );
+
testWidgets(
'group terminals keep all members when opening one and ignore pane close',
(tester) async {
diff --git a/desktop/test/support/super_tab_devices_fixture.dart b/desktop/test/support/super_tab_devices_fixture.dart
new file mode 100644
index 000000000..87a923ba1
--- /dev/null
+++ b/desktop/test/support/super_tab_devices_fixture.dart
@@ -0,0 +1,58 @@
+import 'package:harness/state/dial_status.dart';
+
+import '../devices_controller_test.dart' show deviceStatus;
+import '../super_tab_launch_test.dart';
+
+/// A connected, in-memory daemon: Devices reads never wait on a real socket.
+class SuperTabDevicesConnection extends SuperTabFixtureConnection {
+ SuperTabDevicesConnection(super.store);
+ bool hasDevice = false;
+ var device = deviceStatus('fixture-device');
+ int deviceRevision = 1;
+
+ Map<String, dynamic> get deviceSnapshot => {
+ 'revision': deviceRevision,
+ 'status': {
+ 'attached': hasDevice,
+ 'devices': [
+ if (hasDevice)
+ {
+ 'id': device.id,
+ 'mac': device.mac,
+ 'attached': true,
+ 'settings': device.settings!.toJson(),
+ },
+ ],
+ },
+ };
+
+ @override
+ Future<void> waitUntilReady({required Duration timeout}) async {}
+
+ @override
+ Future<Map<String, dynamic>> request(
+ String type, {
+ Map<String, dynamic> payload = const {},
+ Duration timeout = const Duration(seconds: 20),
+ }) {
+ if (type == 'harness_devices_list') {
+ calls.add((type, Map.of(payload)));
+ return Future.value(deviceSnapshot);
+ }
+ if (type == 'harness_device_settings') {
+ calls.add((type, Map.of(payload)));
+ device = DialStatus.fromJson({
+ 'id': device.id,
+ 'mac': device.mac,
+ 'attached': true,
+ 'settings': {...device.settings!.toJson(), ...payload['patch'] as Map},
+ });
+ deviceRevision++;
+ return Future.value({'ok': true, ...deviceSnapshot});
+ }
+ return super.request(type, payload: payload, timeout: timeout);
+ }
+}
+
+SuperTabLaunchFixture superTabDevicesFixture() =>
+ SuperTabLaunchFixture(connectionFactory: SuperTabDevicesConnection.new);
diff --git a/desktop/test/swarm_projects_test.dart b/desktop/test/swarm_projects_test.dart
index cabb71c4b..eedf60c93 100644
--- a/desktop/test/swarm_projects_test.dart
+++ b/desktop/test/swarm_projects_test.dart
@@ -5,7 +5,6 @@ import 'package:harness/shared/theme/app_icons.dart';
import 'package:harness/super_tabs/view.dart';
import 'package:harness/super_tabs/controller.dart';
import 'package:harness/super_tabs/project_visibility.dart';
-import 'package:harness/super_tabs/section_heading.dart';
import 'support/super_tab_fixture.dart';
@@ -126,11 +125,10 @@ void main() {
of: project,
matching: find.text('Lamp OS'),
);
- // A workgroup sits one indent step in from its project.
+ // Workgroups share the project name column in the compact sidebar.
expect(
- tester.getTopLeft(find.text('#12 Offline editing')).dx -
- tester.getTopLeft(projectName).dx,
- SuperTabSectionHeading.indentStep,
+ tester.getTopLeft(find.text('#12 Offline editing')).dx,
+ tester.getTopLeft(projectName).dx,
);
// A child row's formerly empty inset is part of its one click target.
diff --git a/docs/naming-system.md b/docs/naming-system.md
index 107992eb2..871142838 100644
--- a/docs/naming-system.md
+++ b/docs/naming-system.md
@@ -97,18 +97,29 @@ no CLI keeps its maker's name (Fo).
A pane is a view, so closing a pane or tab closes views. **Stop Harness** ends the
running harness. Adding harnesses to a tab groups them without a separate team
setup. A **Swarm** occupies one tab in that same tab bar. A person can belong to several Swarms.
-Its project names open their product manager chats; a separate chevron reveals each project's workgroups.
-An expanded project without workgroups says **No workgroups yet**. **Your devices** opens the
-existing Devices tab. The navigation, conversation and people panes have draggable dividers.
+Its sidebar starts with **New project** and **Your devices**. Projects and Machines have
+section headings with disclosure after the label and an add action at the right. Project rows
+show their project icon at the left, then their name, status and a right-hand disclosure.
+Project names open their product manager chats; disclosure reveals workgroups whose names
+align with the project name. An expanded project without workgroups says **No workgroups yet**.
+**Your devices** opens the Devices dashboard and its existing agent conversation inside the
+current Swarm, preserving project drafts and the selected workgroup. Ordinary tabs retain
+their standalone Devices workspace. The navigation, conversation and people panes have
+draggable dividers; their default side widths are 300 and 280 pixels, respecting saved resizes.
+The right pane is a stable directory of all humans and agents in the current Swarm that the
+viewer can access. Selecting a project, workgroup or Devices does not filter that directory;
+local machine inventory does not add people or agents to it.
Agents have individual display names and the same avatar treatment as people. Their role badges
-are **PM**, **Dev** and **Rev**; project context appears underneath. Engine names belong in details.
+are **PM**, **Dev** and **Rev**. The name, role badge and compact project tag share the first line;
+the existing status icon and activity or assigned task appear underneath. Shortened names and
+tags retain their full text on hover. Reuse observed status and assignment data; do not generate
+activity summaries or infer a work timer from the session's age. Engine names belong in details.
Chat headings and quoted replies use the same current agent identity as the roster, including
older messages. When an agent has left, its recorded author name remains available in history.
-Machine rows are one line: a status dot, the name, a chip for each known model allowance
-(the engine's mark and the share left, amber below 20% and red below 10%) and the agents'
-avatars. The owner and hardware are in the row's tooltip, never the reading's age, and the
-row opens labeled details. Offline machines are listed under **Offline · N**, without chips,
-and omit stale readings from their details.
+Machine rows show a computer icon, name, owner avatar, status and right-hand disclosure.
+Clicking the name opens labeled details; disclosure shows agents with their names, role badges
+and status, followed by known resources and model allowances. Offline machines stay in the
+same list and omit stale readings. Rows share the projects' alignment and full-width highlight.
The stored `lead` and `builder` routing roles and native harness names remain compatible.
People, agents and machines belong to the Swarm. A project's **Public** visibility means everyone
in that Swarm; **Private** means its owner and explicitly invited project members. Swarms are