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.

Refine Swarm panes, machine details, and read state (#1513)

Deea541f3866a2a
diff --git a/desktop/integration_test/super_tab_native_test.dart b/desktop/integration_test/super_tab_native_test.dart
index c5d5fdc5c..6cdc7d9b5 100644
--- a/desktop/integration_test/super_tab_native_test.dart
+++ b/desktop/integration_test/super_tab_native_test.dart
@@ -3,6 +3,7 @@ import 'dart:ui' as ui;
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';
@@ -39,6 +40,10 @@ void main() {
await windowManager
.setSize(const Size(1280, 800))
.timeout(const Duration(seconds: 10));
+ // 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);
+ addTearDown(() => windowManager.setAlwaysOnTop(false));
await windowManager.show().timeout(const Duration(seconds: 10));
await windowManager.focus().timeout(const Duration(seconds: 10));
debugPrint('Swarm fixture: create lead');
@@ -148,7 +153,6 @@ void main() {
'kind': 'agent',
'id': 'lead-agent',
'name': 'Lead',
- 'displayName': 'Atlas',
};
server.append(
'Keep changes on the device and sync when the connection returns.',
@@ -207,18 +211,34 @@ void main() {
expect(find.text('CHATS'), findsNothing);
expect(find.text('New group'), findsNothing);
expect(find.text('New project'), findsOneWidget);
+ debugPrint('Swarm fixture: empty project disclosure');
await tester.tap(
find.byKey(const ValueKey('super-project-expand-design')),
);
await tester.pumpAndSettle();
- expect(c!.selectedId, 'design-lead');
- expect(c.expandedProjects.contains('design'), isFalse);
+ expect(c!.selectedId, 'lead');
+ expect(c.expandedProjects.contains('design'), isTrue);
+ expect(find.text('No workgroups yet'), findsOneWidget);
await tester.tap(find.byKey(const ValueKey('super-group-lead')));
await tester.pumpAndSettle();
expect(c.selectedId, 'lead');
+ 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));
+ 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.takeMachinesRequest(), isNull);
+ f.app.selectSwarm(swarmId);
await tester.pumpAndSettle();
- expect(f.app.takeMachinesRequest(), (devicePub: null, phones: false));
+ debugPrint('Swarm fixture: returned from Devices');
final folder = Platform.environment['SUPER_TAB_NATIVE_SHOTS'];
Future<void> shot(String name) async {
if (folder == null) return;
@@ -234,6 +254,17 @@ void main() {
}
await shot('conversation');
+ expect(find.text('Lead'), findsNothing);
+ expect(find.text('Atlas'), findsNWidgets(2));
+ expect(find.text('Available capacity'), findsNothing);
+ await tester.tap(find.byKey(const ValueKey('super-machine-m')));
+ await tester.pumpAndSettle();
+ expect(find.text('Available capacity'), findsOneWidget);
+ expect(find.text('CPU'), findsOneWidget);
+ expect(find.text('86%'), findsOneWidget);
+ await shot('machine-details');
+ await tester.tap(find.text('Close'));
+ await tester.pumpAndSettle();
expect(
tester.getTopLeft(find.text('Routed to Multiply')).dx,
tester.getTopLeft(find.byType(SuperTabMessageText).first).dx,
@@ -286,6 +317,45 @@ void main() {
await tester.pump(const Duration(milliseconds: 100));
debugPrint('Swarm fixture: terminal ready');
await shot('terminal');
+ final liveSession = f.app.activeSwarm.panes.single.session;
+ final nativePanel = tester.element(find.byType(TerminalPanel));
+ final initialMiddle = tester
+ .getSize(find.byKey(const ValueKey('super-center-pane')))
+ .width;
+ await tester.drag(
+ find.byKey(const ValueKey('super-resize-left')),
+ const Offset(30, 0),
+ );
+ await tester.pump(const Duration(milliseconds: 100));
+ await tester.drag(
+ find.byKey(const ValueKey('super-resize-right')),
+ const Offset(-30, 0),
+ );
+ await tester.pump(const Duration(milliseconds: 100));
+ expect(
+ tester.getSize(find.byKey(const ValueKey('super-center-pane'))).width,
+ closeTo(initialMiddle - 60, 1),
+ );
+ expect(f.app.activeSwarm.panes.single.session, same(liveSession));
+ expect(tester.element(find.byType(TerminalPanel)), same(nativePanel));
+ expect(
+ f.app.activeSwarm.panes.single.session?.streamId,
+ SuperTabFixtureConnection.streamId,
+ );
+ await shot('terminal-resized');
+ final focusRequest = f.app.paneFocusRequest;
+ final divider = find.byKey(const ValueKey('super-resize-right'));
+ tester
+ .widget<Focus>(
+ find.descendant(of: divider, matching: find.byType(Focus)),
+ )
+ .focusNode!
+ .requestFocus();
+ await tester.pump(const Duration(milliseconds: 50));
+ await tester.sendKeyEvent(LogicalKeyboardKey.escape);
+ await tester.pump(const Duration(milliseconds: 100));
+ expect(f.app.paneFocusRequest, focusRequest + 1);
+ expect(f.app.activeSwarm.panes.single.session, same(liveSession));
expect(find.byType(PaneGrid), findsOneWidget);
expect(
tester
@@ -410,6 +480,16 @@ void main() {
expect(find.text('#1 Offline editing'), findsWidgets);
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: 200));
+ expect(
+ find.byKey(const ValueKey('super-agent-group-open')),
+ findsOneWidget,
+ );
+ await shot('agent-workgroups');
+ await tester.tap(find.byKey(const ValueKey('super-agent-group-cancel')));
+ await tester.pump(const Duration(milliseconds: 200));
+ expect(c.selectedId, 'offline');
await tester.pumpWidget(const SizedBox());
await c.flush();
diff --git a/desktop/lib/super_tabs/agent_group_picker.dart b/desktop/lib/super_tabs/agent_group_picker.dart
new file mode 100644
index 000000000..a7efd6cc1
--- /dev/null
+++ b/desktop/lib/super_tabs/agent_group_picker.dart
@@ -0,0 +1,289 @@
+import 'package:flutter/material.dart';
+import 'package:flutter/gestures.dart';
+import 'package:flutter/services.dart';
+
+import '../shared/theme/app_icons.dart';
+import '../shared/theme/app_theme.dart' as grid;
+import '../widgets/desktop_chrome.dart';
+import 'controller.dart';
+import 'model.dart';
+
+/// Chooses a conversation context before opening an agent's existing terminal.
+/// Selection is local to this dialog; only Open or a double-click navigates.
+class SuperTabAgentGroupPicker extends StatefulWidget {
+ const SuperTabAgentGroupPicker({
+ super.key,
+ required this.controller,
+ required this.agentId,
+ });
+
+ final SuperTabController controller;
+ final String agentId;
+
+ @override
+ State<SuperTabAgentGroupPicker> createState() =>
+ _SuperTabAgentGroupPickerState();
+}
+
+class _SuperTabAgentGroupPickerState extends State<SuperTabAgentGroupPicker> {
+ final _listFocus = FocusNode(debugLabel: 'Agent workgroups');
+ final _scroll = ScrollController();
+ final _rows = <String, GlobalKey>{};
+ String? _selectedId;
+
+ List<SuperTabConversation> get _groups {
+ final snapshot = widget.controller.snapshot;
+ if (widget.controller.accessRevoked ||
+ snapshot?.agent(widget.agentId) == null) {
+ return const [];
+ }
+ return snapshot!.conversations
+ .where((g) => !g.archived && g.agentIds.contains(widget.agentId))
+ .toList();
+ }
+
+ @override
+ void initState() {
+ super.initState();
+ final groups = _groups;
+ _selectedId = groups.any((g) => g.id == widget.controller.selectedId)
+ ? widget.controller.selectedId
+ : groups.firstOrNull?.id;
+ widget.controller.addListener(_changed);
+ _revealSelection();
+ }
+
+ void _changed() {
+ if (!mounted) return;
+ setState(() {
+ // Never silently replace a choice that lost membership while open.
+ if (!_groups.any((g) => g.id == _selectedId)) _selectedId = null;
+ });
+ }
+
+ @override
+ void dispose() {
+ widget.controller.removeListener(_changed);
+ _listFocus.dispose();
+ _scroll.dispose();
+ super.dispose();
+ }
+
+ bool _select(String id) {
+ if (!_groups.any((g) => g.id == id)) return false;
+ setState(() => _selectedId = id);
+ _listFocus.requestFocus();
+ _revealSelection();
+ return true;
+ }
+
+ void _revealSelection() {
+ WidgetsBinding.instance.addPostFrameCallback((_) {
+ if (!mounted) return;
+ final row = _rows[_selectedId]?.currentContext;
+ if (row != null) Scrollable.ensureVisible(row);
+ });
+ }
+
+ void _open() {
+ final selected = _selectedId;
+ if (selected != null && _groups.any((g) => g.id == selected)) {
+ Navigator.pop(context, selected);
+ }
+ }
+
+ KeyEventResult _onKey(FocusNode node, KeyEvent event) {
+ if (event is! KeyDownEvent && event is! KeyRepeatEvent) {
+ return KeyEventResult.ignored;
+ }
+ final key = event.logicalKey;
+ if (key == LogicalKeyboardKey.enter ||
+ key == LogicalKeyboardKey.numpadEnter) {
+ if (event is KeyDownEvent) _open();
+ return KeyEventResult.handled;
+ }
+ if (key != LogicalKeyboardKey.arrowUp &&
+ key != LogicalKeyboardKey.arrowDown) {
+ return KeyEventResult.ignored;
+ }
+ final groups = _groups;
+ if (groups.isNotEmpty) {
+ final index = groups.indexWhere((g) => g.id == _selectedId);
+ final up = key == LogicalKeyboardKey.arrowUp;
+ final next = index < 0
+ ? (up ? groups.length - 1 : 0)
+ : (index + (up ? -1 : 1)).clamp(0, groups.length - 1);
+ _select(groups[next].id);
+ }
+ return KeyEventResult.handled;
+ }
+
+ Widget _row(SuperTabConversation group) {
+ final snapshot = widget.controller.snapshot!;
+ final selected = group.id == _selectedId;
+ final project = snapshot.projectFor(group.id);
+ final label = snapshot.isProjectLead(group.id)
+ ? 'Product Manager'
+ : group.label;
+ final ink = selected ? DesktopChrome.onSelection : DesktopChrome.foreground;
+ return Padding(
+ key: _rows.putIfAbsent(group.id, GlobalKey.new),
+ padding: const EdgeInsets.only(bottom: 4),
+ child: Semantics(
+ selected: selected,
+ inMutuallyExclusiveGroup: true,
+ child: Material(
+ color: selected ? DesktopChrome.activeSelection : Colors.transparent,
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(DesktopChrome.rowRadius),
+ side: BorderSide(
+ width: grid.AppDesktop.focusWidth,
+ color: selected && _listFocus.hasFocus
+ ? DesktopChrome.onSelection
+ : Colors.transparent,
+ ),
+ ),
+ clipBehavior: Clip.antiAlias,
+ child: Listener(
+ // Double-click recognition waits before dispatching onTap. Select
+ // immediately, so a quick click on Open never uses the old row.
+ onPointerDown: (event) {
+ if (event.buttons == kPrimaryMouseButton) _select(group.id);
+ },
+ child: InkWell(
+ key: ValueKey('super-agent-group-${group.id}'),
+ canRequestFocus: false,
+ mouseCursor: SystemMouseCursors.click,
+ hoverColor: ink.withValues(alpha: .08),
+ onTap: () => _select(group.id),
+ onDoubleTap: () {
+ if (_select(group.id)) _open();
+ },
+ child: Padding(
+ padding: const EdgeInsets.symmetric(
+ horizontal: 12,
+ vertical: 10,
+ ),
+ child: Row(
+ children: [
+ Expanded(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(
+ label,
+ style: DesktopChrome.text(color: ink, medium: true),
+ ),
+ if (project != null) ...[
+ const SizedBox(height: 2),
+ Text(
+ project.name,
+ style: DesktopChrome.metadata(
+ color: selected
+ ? DesktopChrome.selectionDetail
+ : DesktopChrome.muted,
+ ),
+ ),
+ ],
+ ],
+ ),
+ ),
+ const SizedBox(width: 12),
+ SizedBox(
+ width: AppIcons.inlineSize,
+ child: selected
+ ? Icon(
+ AppIcons.check,
+ size: AppIcons.inlineSize,
+ color: ink,
+ )
+ : null,
+ ),
+ ],
+ ),
+ ),
+ ),
+ ),
+ ),
+ ),
+ );
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final groups = _groups;
+ final available = groups.any((g) => g.id == _selectedId);
+ return Dialog(
+ backgroundColor: Colors.transparent,
+ elevation: 0,
+ shape: DesktopChrome.bareDialogShape,
+ child: DesktopDialogSurface(
+ child: SizedBox(
+ width: grid.AppDesktop.formWidth,
+ child: Padding(
+ padding: const EdgeInsets.all(DesktopChrome.panelPadding),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ DesktopDialogHeader(
+ title:
+ 'Open ${widget.controller.snapshot?.agentName(widget.agentId) ?? 'agent'}',
+ detail: 'Choose a workgroup to open its terminal.',
+ padding: EdgeInsets.zero,
+ ),
+ const SizedBox(height: DesktopChrome.groupGap),
+ Flexible(
+ child: ConstrainedBox(
+ constraints: const BoxConstraints(maxHeight: 320),
+ child: Focus(
+ key: const ValueKey('super-agent-group-list'),
+ focusNode: _listFocus,
+ autofocus: true,
+ onFocusChange: (_) => setState(() {}),
+ onKeyEvent: _onKey,
+ child: Scrollbar(
+ controller: _scroll,
+ child: SingleChildScrollView(
+ controller: _scroll,
+ child: groups.isEmpty
+ ? Text(
+ 'No available workgroups for this agent.',
+ style: DesktopChrome.text(),
+ )
+ : Column(
+ crossAxisAlignment:
+ CrossAxisAlignment.stretch,
+ children: groups.map(_row).toList(),
+ ),
+ ),
+ ),
+ ),
+ ),
+ ),
+ const SizedBox(height: DesktopChrome.groupGap),
+ OverflowBar(
+ alignment: MainAxisAlignment.end,
+ spacing: DesktopChrome.controlGap,
+ overflowSpacing: DesktopChrome.controlGap,
+ children: [
+ TextButton(
+ key: const ValueKey('super-agent-group-cancel'),
+ onPressed: () => Navigator.pop(context),
+ child: const Text('Cancel'),
+ ),
+ FilledButton(
+ key: const ValueKey('super-agent-group-open'),
+ onPressed: available ? _open : null,
+ child: const Text('Open'),
+ ),
+ ],
+ ),
+ ],
+ ),
+ ),
+ ),
+ ),
+ );
+ }
+}
diff --git a/desktop/lib/super_tabs/controller.dart b/desktop/lib/super_tabs/controller.dart
index 808737e09..b1b889c53 100644
--- a/desktop/lib/super_tabs/controller.dart
+++ b/desktop/lib/super_tabs/controller.dart
@@ -226,8 +226,15 @@ class SuperTabController extends ChangeNotifier {
),
);
bool hasOlder(String id) => _before[id] != null;
+ int _loadedMessageSequence(String id) =>
+ _messages[id]?.reversed
+ .where((m) => m.source['kind'] != 'update-request')
+ .firstOrNull
+ ?.sequence ??
+ 0;
bool unread(SuperTabConversation group) =>
- group.lastMessageSequence > (_readAt[group.id] ?? 0);
+ max(group.lastMessageSequence, _loadedMessageSequence(group.id)) >
+ (_readAt[group.id] ?? 0);
void start() {
if (_disposed) return;
@@ -325,11 +332,14 @@ class SuperTabController extends ChangeNotifier {
unawaited(loadMessages(id));
}
- /// A visible transcript passes its loaded boundary: a newer snapshot may
- /// already advertise messages that have not arrived on this client yet.
+ /// A visible transcript passes the boundary it displayed. The loaded messages
+ /// are authoritative: snapshots can arrive either before or after their tail.
void markRead(String id, {int? through}) {
- final advertised = snapshot?.conversation(id)?.lastMessageSequence ?? 0;
- final last = through == null ? advertised : min(through, advertised);
+ if (_disposed || accessRevoked || snapshot?.conversation(id) == null) {
+ return;
+ }
+ final loaded = _loadedMessageSequence(id);
+ final last = min(through ?? loaded, loaded);
if ((_readAt[id] ?? 0) >= last) return;
_readAt[id] = last;
_saveSoon();
diff --git a/desktop/lib/super_tabs/machine_details.dart b/desktop/lib/super_tabs/machine_details.dart
new file mode 100644
index 000000000..ac10ea0ab
--- /dev/null
+++ b/desktop/lib/super_tabs/machine_details.dart
@@ -0,0 +1,196 @@
+import 'package:flutter/material.dart';
+
+import '../core/machine_resources.dart';
+import '../shared/theme/app_theme.dart' as grid;
+import '../widgets/desktop_chrome.dart';
+import '../widgets/desktop_prompt_surface.dart';
+import '../widgets/engine_identity.dart';
+import '../widgets/workspace_subscription_usage.dart';
+
+/// Full machine context behind the sidebar's compact, live readings.
+class SuperTabMachineDetails extends StatelessWidget {
+ const SuperTabMachineDetails({
+ super.key,
+ required this.name,
+ required this.status,
+ required this.accounts,
+ this.owner,
+ this.resources,
+ this.cwd,
+ this.engines,
+ });
+
+ final String name, status;
+ final String? owner, cwd;
+ final MachineResources? resources;
+ final List<String>? engines;
+ final List<Map<String, Object?>> accounts;
+
+ Widget _row(String label, String value, {required bool stacked}) => Padding(
+ padding: const EdgeInsets.symmetric(vertical: 5),
+ child: stacked
+ ? Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ Text(label, style: DesktopChrome.metadata()),
+ const SizedBox(height: 2),
+ Text(value, style: DesktopChrome.control()),
+ ],
+ )
+ : Row(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ SizedBox(
+ width: 104,
+ child: Text(label, style: DesktopChrome.metadata()),
+ ),
+ const SizedBox(width: 16),
+ Expanded(child: Text(value, style: DesktopChrome.control())),
+ ],
+ ),
+ );
+
+ Widget _section(String title, List<Widget> children) => Padding(
+ padding: const EdgeInsets.only(top: 24),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ Text(title, style: DesktopChrome.control(medium: true)),
+ const SizedBox(height: 8),
+ ...children,
+ ],
+ ),
+ );
+
+ Widget _allowance(
+ WorkspaceSubscriptionAccount account,
+ Map<String, Object?> row,
+ bool stacked,
+ ) {
+ final details = (row['details'] as List? ?? const []).whereType<String>();
+ final accountName = row['account'] as String?;
+ final figure = Text(
+ '${account.figure} left',
+ style: DesktopChrome.control(
+ medium: true,
+ color: account.ink(DesktopChrome.foreground, DesktopChrome.surface),
+ ),
+ );
+ return Padding(
+ padding: const EdgeInsets.only(bottom: 12),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ Row(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ EngineMark(engine: account.engine, size: 16),
+ const SizedBox(width: 8),
+ Expanded(
+ child: Text(account.name, style: DesktopChrome.control()),
+ ),
+ if (!stacked) ...[const SizedBox(width: 12), figure],
+ ],
+ ),
+ if (stacked)
+ Padding(padding: const EdgeInsets.only(top: 4), child: figure),
+ if (accountName?.isNotEmpty == true)
+ Padding(
+ padding: const EdgeInsets.only(top: 4),
+ child: Text(accountName!, style: DesktopChrome.metadata()),
+ ),
+ for (final detail in details)
+ Padding(
+ padding: const EdgeInsets.only(top: 6),
+ child: Text(
+ detail.replaceAll(' · resets in ', '\nResets in '),
+ style: DesktopChrome.metadata(),
+ ),
+ ),
+ ],
+ ),
+ );
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ grid.AppTheme.watch(context);
+ final value = resources;
+ final diskTotal = value?.projectDiskTotalBytes ?? value?.diskTotalBytes;
+ final diskFree = value?.projectDiskTotalBytes == null
+ ? value?.diskFreeBytes
+ : value?.projectDiskFreeBytes;
+ final memoryFree =
+ value?.memoryTotalBytes == null || value?.memoryUsedBytes == null
+ ? null
+ : (value!.memoryTotalBytes! - value.memoryUsedBytes!).clamp(
+ 0,
+ value.memoryTotalBytes!,
+ );
+ String free(double used) => resourcePercent((100 - used).clamp(0, 100));
+ String capacity(double available, double? total) =>
+ '${resourceBytes(available)}${total == null ? '' : ' of ${resourceBytes(total)}'}';
+ final readings = [
+ if (value?.cpuPercent case final cpu?) ('CPU', free(cpu)),
+ if (value?.busiestGpu?.utilizationPercent case final gpu?)
+ ('GPU', free(gpu)),
+ if (memoryFree != null)
+ ('RAM', capacity(memoryFree.toDouble(), value?.memoryTotalBytes)),
+ if (diskFree != null) ('SSD', capacity(diskFree, diskTotal)),
+ ];
+ final knownAccounts = [
+ for (final row in accounts)
+ for (final account in WorkspaceSubscriptionUsage.fromRows([
+ row,
+ ]).accounts)
+ if (account.figure != '—') (account, row),
+ ];
+ final hardware = [
+ ('Computer', name),
+ if (value?.deviceType case final device?) ('Device', device),
+ if (value?.chip case final chip?) ('Chip', chip),
+ if (value?.os case final os?) ('System', os),
+ for (final gpu in value?.gpus ?? const <MachineGpu>[])
+ if (gpu.id != 'observed') ('Graphics', gpu.name),
+ if (cwd case final path?) ('Project folder', path),
+ if (engines?.isNotEmpty == true)
+ ('Engines', engines!.map((e) => engineIdentity(e).label).join(', ')),
+ ];
+ return SizedBox(
+ width: 400,
+ child: LayoutBuilder(
+ builder: (context, constraints) {
+ final stacked =
+ constraints.maxWidth < 320 ||
+ MediaQuery.textScalerOf(context).scale(13) > 20;
+ return DesktopPromptScrollBody(
+ child: SelectionArea(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ if (owner case final email?)
+ _row('Owner', email, stacked: stacked),
+ _row('Status', status, stacked: stacked),
+ if (readings.isNotEmpty)
+ _section('Available capacity', [
+ for (final reading in readings)
+ _row(reading.$1, reading.$2, stacked: stacked),
+ ]),
+ if (knownAccounts.isNotEmpty)
+ _section('Model allowances', [
+ for (final entry in knownAccounts)
+ _allowance(entry.$1, entry.$2, stacked),
+ ]),
+ _section('Details', [
+ for (final detail in hardware)
+ _row(detail.$1, detail.$2, stacked: stacked),
+ ]),
+ ],
+ ),
+ ),
+ );
+ },
+ ),
+ );
+ }
+}
diff --git a/desktop/lib/super_tabs/machines.dart b/desktop/lib/super_tabs/machines.dart
index 65614dd75..a2e1a042e 100644
--- a/desktop/lib/super_tabs/machines.dart
+++ b/desktop/lib/super_tabs/machines.dart
@@ -18,6 +18,7 @@ import '../widgets/workspace_subscription_usage.dart';
import 'controller.dart';
import 'dialog_scope.dart';
import 'identity.dart';
+import 'machine_details.dart';
import 'model.dart';
import 'section_heading.dart';
@@ -643,19 +644,12 @@ class _SuperTabMachinesState extends State<SuperTabMachines> {
];
}
final usage = WorkspaceSubscriptionUsage.fromRows(online ? accounts : []);
- final running = fresh
- ? (observation['runningHarnessIds'] as List? ?? []).length
- : agents
- .where(
- (a) =>
- state?.agents
- .where((n) => n.id == a.harnessId && !n.isStopped)
- .isNotEmpty ==
- true,
- )
- .length;
final paused = shared?['paused'] == true;
- final diskTotal = value?.projectDiskTotalBytes ?? value?.diskTotalBytes;
+ final status = !online
+ ? 'Offline'
+ : paused
+ ? 'New work paused'
+ : 'Online';
final diskFree = value?.projectDiskTotalBytes == null
? value?.diskFreeBytes
: value?.projectDiskFreeBytes;
@@ -666,187 +660,160 @@ class _SuperTabMachinesState extends State<SuperTabMachines> {
0,
value.memoryTotalBytes!,
);
- String available(double? used) =>
- resourcePercent(used == null ? null : (100 - used).clamp(0, 100));
+ String available(double used) =>
+ resourcePercent((100 - used).clamp(0, 100));
final metrics = [
- if (value?.cpuPercent != null) 'CPU ${available(value!.cpuPercent)}',
- if (value?.busiestGpu?.utilizationPercent != null)
- 'GPU ${available(value!.busiestGpu!.utilizationPercent)}',
- if (memoryFree != null) 'RAM ${resourceBytes(memoryFree.toDouble())}',
- if (diskFree != null) 'SSD ${resourceBytes(diskFree)}',
+ if (value?.cpuPercent case final cpu?) ('CPU', available(cpu)),
+ if (value?.busiestGpu?.utilizationPercent case final gpu?)
+ ('GPU', available(gpu)),
+ if (memoryFree != null) ('RAM', resourceBytes(memoryFree.toDouble())),
+ if (diskFree != null) ('SSD', resourceBytes(diskFree)),
];
final visibleAccounts = usage.accounts
.where((a) => a.figure != '—')
.toList();
- return Padding(
- key: ValueKey('super-machine-row-$id'),
- padding: const EdgeInsets.fromLTRB(16, 0, 16, 8),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- InkWell(
- key: ValueKey('super-machine-$id'),
- borderRadius: BorderRadius.circular(8),
- onTap: () => showAppDialog<void>(
- context: context,
- builder: (context) => AlertDialog(
- title: Text(name),
- content: Text(
- [
- if (person != null) person.email,
- paused
- ? 'New work paused'
- : online
- ? 'Online'
- : 'Offline',
- if (value?.deviceType != null) value!.deviceType!,
- if (value?.chip != null) value!.chip!,
- if (value?.os != null) value!.os!,
- if (shared?['cwd'] != null) shared!['cwd'] as String,
- if (allowed != null) 'Engines: ${allowed.join(', ')}',
- 'RAM: ${resourceBytes(value?.memoryTotalBytes)}',
- 'Disk: ${resourceBytes(value?.diskTotalBytes)}',
- for (final gpu in value?.gpus ?? const <MachineGpu>[])
- 'GPU: ${gpu.name}',
- if (usage.accounts.isNotEmpty) usage.detail,
- ].join('\n'),
- ),
- actions: [
- if (shared != null && contributor == c.accountId)
- TextButton(
- onPressed: () async {
- final result = await c.command({
- 'type': 'machine.pause',
- 'machineId': id,
- 'paused': !paused,
- });
- if (context.mounted && result != null) {
- Navigator.pop(context);
- }
- },
- child: Text(
- paused ? 'Resume new work' : 'Pause new work',
- ),
- ),
- if (contributor == c.accountId)
- TextButton(
- onPressed: () {
- Navigator.pop(context);
- unawaited(
- _contribute(existing: shared ?? {'machineId': id}),
- );
- },
- child: const Text('Configure'),
- ),
- if (c.canWrite && c.selected != null)
- TextButton(
- onPressed: () {
- final group = c.selected!;
- Navigator.pop(context);
- WidgetsBinding.instance.addPostFrameCallback((_) {
- if (mounted) widget.onAddAgent(group);
- });
- },
- child: const Text('Attach running agent'),
- ),
- TextButton(
- onPressed: () => Navigator.pop(context),
- child: const Text('Close'),
- ),
- ],
- ),
+ return ListTile(
+ key: ValueKey('super-machine-$id'),
+ dense: true,
+ minTileHeight: 48,
+ minVerticalPadding: 8,
+ contentPadding: const EdgeInsets.symmetric(horizontal: 16),
+ title: _MachineHeader(
+ key: ValueKey('super-machine-header-$id'),
+ name: name,
+ owner: person,
+ agents: [
+ for (final agent in agents)
+ (
+ id: agent.id,
+ name: c.snapshot!.agentName(agent.id),
+ role: c.snapshot!.isLead(agent.id)
+ ? 'Product Manager'
+ : 'Engineer',
),
- child: Tooltip(
- message: [name, if (person != null) person.email].join('\n'),
- child: ConstrainedBox(
- constraints: const BoxConstraints(minHeight: 32),
- child: Wrap(
- spacing: 8,
- runSpacing: 2,
- crossAxisAlignment: WrapCrossAlignment.center,
- children: [
- Text(
- superTabMachineName(name),
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: DesktopChrome.control(
- medium: true,
- color: online ? null : DesktopChrome.muted,
- ),
- ),
- Row(
- mainAxisSize: MainAxisSize.min,
+ ],
+ online: online,
+ paused: paused,
+ ),
+ subtitle: metrics.isEmpty && visibleAccounts.isEmpty
+ ? null
+ : Padding(
+ padding: const EdgeInsets.only(top: 6),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ if (metrics.isNotEmpty)
+ Wrap(
+ spacing: 8,
+ runSpacing: 4,
children: [
- if (person != null) ...[
- Flexible(
+ for (final metric in metrics)
+ Tooltip(
+ message: '${metric.$1} ${metric.$2} available',
child: Text(
- superTabPersonName(person.email),
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
+ '${metric.$1} ${metric.$2}',
style: DesktopChrome.metadata(),
),
),
- const SizedBox(width: 8),
- ],
- Text(
- paused
- ? 'Paused'
- : !online
- ? 'Offline'
- : '$running ${running == 1 ? 'agent' : 'agents'}',
- style: DesktopChrome.metadata(),
- ),
],
),
- ],
- ),
- ),
- ),
- ),
- if (metrics.isNotEmpty) ...[
- Tooltip(
- message:
- 'Available capacity\nCPU and GPU: idle percentage at the latest reading\nRAM: ${resourceBytes(memoryFree?.toDouble())} free of ${resourceBytes(value?.memoryTotalBytes)}\nSSD: ${resourceBytes(diskFree)} free of ${resourceBytes(diskTotal)}',
- child: Wrap(
- spacing: 8,
- runSpacing: 4,
- children: [
- for (final metric in metrics)
- Text(metric, style: DesktopChrome.metadata()),
- ],
- ),
- ),
- ],
- if (visibleAccounts.isNotEmpty) ...[
- const SizedBox(height: 4),
- Wrap(
- spacing: 16,
- runSpacing: 8,
- children: [
- for (final account in visibleAccounts)
- Tooltip(
- message: account.detail,
- child: Row(
- mainAxisSize: MainAxisSize.min,
+ if (metrics.isNotEmpty && visibleAccounts.isNotEmpty)
+ const SizedBox(height: 6),
+ if (visibleAccounts.isNotEmpty)
+ Wrap(
+ spacing: 16,
+ runSpacing: 6,
children: [
- EngineMark(engine: account.engine, size: 16),
- const SizedBox(width: 6),
- Text(
- account.figure,
- style: DesktopChrome.control(
- medium: true,
- color: account.tone == WorkspaceUsageTone.exhausted
- ? grid.AppPalette.warn
- : null,
+ for (final account in visibleAccounts)
+ Tooltip(
+ message: account.detail,
+ child: Semantics(
+ label:
+ '${account.name} ${account.figure} remaining',
+ excludeSemantics: true,
+ child: Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ EngineMark(engine: account.engine, size: 16),
+ const SizedBox(width: 6),
+ Text(
+ account.figure,
+ style: DesktopChrome.control(
+ medium: true,
+ color: account.ink(
+ DesktopChrome.foreground,
+ DesktopChrome.surface,
+ ),
+ ),
+ ),
+ ],
+ ),
+ ),
),
- ),
],
),
- ),
- ],
+ ],
+ ),
),
- ],
- ],
+ onTap: () => showAppDialog<void>(
+ context: context,
+ builder: (context) => SuperTabDialogScope(
+ controller: c,
+ requireWrite: false,
+ child: AlertDialog(
+ title: Text(superTabMachineName(name)),
+ content: SuperTabMachineDetails(
+ name: name,
+ owner: person?.email,
+ status: paused && !online ? 'Offline, new work paused' : status,
+ resources: value,
+ cwd: shared?['cwd'] as String?,
+ engines: allowed,
+ accounts: online ? accounts : const [],
+ ),
+ actions: [
+ if (shared != null && contributor == c.accountId)
+ TextButton(
+ onPressed: () async {
+ final result = await c.command({
+ 'type': 'machine.pause',
+ 'machineId': id,
+ 'paused': !paused,
+ });
+ if (context.mounted && result != null) {
+ Navigator.pop(context);
+ }
+ },
+ child: Text(paused ? 'Resume new work' : 'Pause new work'),
+ ),
+ if (contributor == c.accountId)
+ TextButton(
+ onPressed: () {
+ Navigator.pop(context);
+ unawaited(
+ _contribute(existing: shared ?? {'machineId': id}),
+ );
+ },
+ child: const Text('Configure'),
+ ),
+ if (c.canWrite && c.selected != null)
+ TextButton(
+ onPressed: () {
+ final group = c.selected!;
+ Navigator.pop(context);
+ WidgetsBinding.instance.addPostFrameCallback((_) {
+ if (mounted) widget.onAddAgent(group);
+ });
+ },
+ child: const Text('Attach running agent'),
+ ),
+ TextButton(
+ onPressed: () => Navigator.pop(context),
+ child: const Text('Close'),
+ ),
+ ],
+ ),
+ ),
),
);
}
@@ -881,3 +848,136 @@ class _SuperTabMachinesState extends State<SuperTabMachines> {
: ListView(children: children);
}
}
+
+/// The same identities as the roster, with full names available on hover.
+/// The row stays one line; only agents that cannot fit become a compact +N.
+class _MachineHeader extends StatelessWidget {
+ const _MachineHeader({
+ super.key,
+ required this.name,
+ required this.owner,
+ required this.agents,
+ required this.online,
+ required this.paused,
+ });
+
+ final String name;
+ final SuperTabPerson? owner;
+ final List<({String id, String name, String role})> agents;
+ final bool online, paused;
+
+ Widget _avatar(String identity, String name, String label) => Tooltip(
+ message: label,
+ child: Semantics(
+ label: label,
+ excludeSemantics: true,
+ child: Builder(
+ builder: (context) => MediaQuery.withClampedTextScaling(
+ maxScaleFactor: 1,
+ child: SuperTabAvatar(identity: identity, name: name, size: 24),
+ ),
+ ),
+ ),
+ );
+
+ @override
+ Widget build(BuildContext context) => LayoutBuilder(
+ builder: (context, constraints) {
+ final style = DesktopChrome.control(
+ medium: true,
+ color: online ? null : DesktopChrome.muted,
+ );
+ double width(String text, TextStyle style) {
+ final painter = TextPainter(
+ text: TextSpan(text: text, style: style),
+ textDirection: Directionality.of(context),
+ textScaler: MediaQuery.textScalerOf(context),
+ )..layout();
+ final result = painter.width;
+ painter.dispose();
+ return result;
+ }
+
+ final readableName = superTabMachineName(name);
+ final nameWidth = width(
+ readableName,
+ style,
+ ).clamp(0.0, constraints.maxWidth * .55);
+ final room =
+ constraints.maxWidth -
+ nameWidth -
+ (owner == null ? 0 : 32) -
+ (!online || paused ? 24 : 0);
+ var count = agents.length;
+ while (count > 0 &&
+ count * 28 +
+ (count < agents.length
+ ? width(
+ '+${agents.length - count}',
+ DesktopChrome.metadata(),
+ ) +
+ 8
+ : 0) >
+ room) {
+ count--;
+ }
+ return Row(
+ children: [
+ Flexible(
+ child: Tooltip(
+ message: name,
+ child: Text(
+ readableName,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: style,
+ ),
+ ),
+ ),
+ if (owner case final person?) ...[
+ const SizedBox(width: 8),
+ _avatar(
+ 'person:${person.id}',
+ superTabPersonName(person.email),
+ '${person.email}\nMachine owner',
+ ),
+ ],
+ for (final agent in agents.take(count)) ...[
+ const SizedBox(width: 4),
+ _avatar(
+ 'agent:${agent.id}',
+ agent.name,
+ '${agent.name}\n${agent.role}',
+ ),
+ ],
+ if (count < agents.length) ...[
+ const SizedBox(width: 8),
+ Tooltip(
+ message: agents
+ .skip(count)
+ .map((a) => '${a.name} — ${a.role}')
+ .join('\n'),
+ child: Text(
+ '+${agents.length - count}',
+ style: DesktopChrome.metadata(),
+ ),
+ ),
+ ],
+ if (!online || paused) ...[
+ const SizedBox(width: 8),
+ Tooltip(
+ message: !online
+ ? (paused ? 'Offline, new work paused' : 'Offline')
+ : 'New work paused',
+ child: Icon(
+ !online ? AppIcons.monitorOff : AppIcons.pause,
+ size: 16,
+ color: DesktopChrome.muted,
+ ),
+ ),
+ ],
+ ],
+ );
+ },
+ );
+}
diff --git a/desktop/lib/super_tabs/model.dart b/desktop/lib/super_tabs/model.dart
index 7ffee58ea..d1204c868 100644
--- a/desktop/lib/super_tabs/model.dart
+++ b/desktop/lib/super_tabs/model.dart
@@ -170,7 +170,11 @@ class SuperTabSnapshot {
String agentName(String id, {String fallback = 'Agent'}) =>
agent(id)?.displayName ?? agent(id)?.name ?? fallback;
- String authorName(SuperTabMessage message) => message.authorName;
+ // Resolve the person shown in chat from the same identity as the roster.
+ // Recorded labels remain the fallback for agents no longer in the Swarm.
+ String authorName(SuperTabMessage message) => message.fromAgent
+ ? agentName(message.authorId, fallback: message.authorName)
+ : message.authorName;
}
class SuperTabRouteChoice {
@@ -289,8 +293,8 @@ class SuperTabMessage {
final DateTime? createdAt;
final List<SuperTabAttachment> attachments;
final List<Map<String, dynamic>> deliveries;
- // History and message grouping use the identity recorded at send time, even
- // after removal. Legacy messages retain their original author label.
+ // Preserve the recorded identity for history and for removed agents. Views
+ // with a current roster resolve the visible name through Snapshot.authorName.
String get authorName =>
(fromAgent ? author['displayName'] as String? : null) ??
author['name'] as String? ??
diff --git a/desktop/lib/super_tabs/pane_layout.dart b/desktop/lib/super_tabs/pane_layout.dart
new file mode 100644
index 000000000..17aed2032
--- /dev/null
+++ b/desktop/lib/super_tabs/pane_layout.dart
@@ -0,0 +1,188 @@
+import 'dart:async';
+import 'dart:convert';
+import 'dart:math' as math;
+
+import 'package:flutter/material.dart';
+
+import '../core/local_key_value_store.dart';
+import '../state/pane_arrangement.dart';
+import '../widgets/desktop_chrome.dart';
+import '../widgets/pane_resize_handle.dart';
+
+/// Navigation and people keep their preferred widths as the window changes;
+/// the conversation takes the remaining space. Resizing never replaces a pane.
+class SuperTabPaneLayout extends StatefulWidget {
+ const SuperTabPaneLayout({
+ super.key,
+ required this.center,
+ required this.onLeave,
+ this.left,
+ this.right,
+ this.storage,
+ });
+
+ static const storageKey = 'super-tab-pane-widths';
+ static const rightWidth = 380.0;
+ final Widget? left, right;
+ final Widget center;
+ final VoidCallback onLeave;
+ final LocalKeyValueStore? storage;
+
+ @override
+ State<SuperTabPaneLayout> createState() => _SuperTabPaneLayoutState();
+}
+
+class _SuperTabPaneLayoutState extends State<SuperTabPaneLayout> {
+ double _left = 220, _right = SuperTabPaneLayout.rightWidth;
+ int _edit = 0;
+ Future<void> _writing = Future.value();
+
+ @override
+ void initState() {
+ super.initState();
+ unawaited(_restore());
+ }
+
+ @override
+ void didUpdateWidget(SuperTabPaneLayout oldWidget) {
+ super.didUpdateWidget(oldWidget);
+ if (oldWidget.storage != widget.storage) unawaited(_restore());
+ }
+
+ Future<void> _restore() async {
+ final edit = ++_edit, store = widget.storage;
+ try {
+ final raw = await store?.read(SuperTabPaneLayout.storageKey);
+ if (!mounted || edit != _edit || raw == null) return;
+ final value = jsonDecode(raw);
+ double width(String key, double fallback) =>
+ value is Map &&
+ value[key] is num &&
+ (value[key] as num).isFinite &&
+ (value[key] as num) > 0
+ ? (value[key] as num).toDouble()
+ : fallback;
+ setState(() {
+ _left = width('left', _left);
+ _right = width('right', _right);
+ });
+ } catch (_) {
+ // A missing or old preference must not prevent opening the workspace.
+ }
+ }
+
+ void _save() {
+ final store = widget.storage;
+ if (store == null) return;
+ final value = jsonEncode({'left': _left, 'right': _right});
+ _writing = _writing
+ .then((_) => store.write(SuperTabPaneLayout.storageKey, value))
+ .catchError((Object _) {});
+ }
+
+ @override
+ Widget build(BuildContext context) => LayoutBuilder(
+ builder: (context, constraints) {
+ final width = constraints.maxWidth;
+ final scale = MediaQuery.textScalerOf(context);
+ final hasLeft = widget.left != null, hasRight = widget.right != null;
+ final centerMin = math.min(scale.scale(360), width);
+ final leftMin = hasLeft ? scale.scale(180) : 0.0;
+ final rightMin = hasRight ? scale.scale(280) : 0.0;
+ double limit(double value, double floor, double ceiling) => value
+ .clamp(math.min(floor, ceiling), math.max(0, ceiling))
+ .toDouble();
+ final left = hasLeft
+ ? limit(_left, leftMin, width - centerMin - rightMin)
+ : 0.0;
+ final right = hasRight
+ ? limit(_right, rightMin, width - centerMin - left)
+ : 0.0;
+ final arrangement = PaneArrangement([
+ if (hasLeft) Rect.fromLTRB(0, 0, left / width, 1),
+ Rect.fromLTRB(left / width, 0, 1 - right / width, 1),
+ if (hasRight) Rect.fromLTRB(1 - right / width, 0, 1, 1),
+ ]);
+ return Stack(
+ fit: StackFit.expand,
+ children: [
+ Row(
+ children: [
+ if (hasLeft)
+ SizedBox(
+ key: const ValueKey('super-left-pane'),
+ width: left,
+ child: widget.left,
+ ),
+ Expanded(
+ key: const ValueKey('super-center-pane'),
+ child: widget.center,
+ ),
+ if (hasRight)
+ SizedBox(
+ key: const ValueKey('super-right-pane'),
+ width: right,
+ child: widget.right,
+ ),
+ ],
+ ),
+ for (final (index, divider) in arrangement.dividers.indexed)
+ Positioned(
+ left: divider.position * width - 4,
+ top: 0,
+ bottom: 0,
+ width: 8,
+ child: Stack(
+ fit: StackFit.expand,
+ children: [
+ Center(
+ child: SizedBox(
+ width: 1,
+ height: double.infinity,
+ child: ColoredBox(color: DesktopChrome.rim),
+ ),
+ ),
+ PaneResizeHandle(
+ key: ValueKey(
+ 'super-resize-${hasLeft && index == 0 ? 'left' : 'right'}',
+ ),
+ arrangement: arrangement,
+ divider: divider,
+ extent: constraints.biggest,
+ minimum: Size(
+ math.min(
+ leftMin == 0 ? rightMin : leftMin,
+ rightMin == 0 ? leftMin : rightMin,
+ ) /
+ width,
+ 0,
+ ),
+ onLeave: widget.onLeave,
+ onChanged: (next, persist) {
+ ++_edit;
+ setState(() {
+ if (hasLeft && index == 0) {
+ _left = limit(
+ next.tiles.first.width * width,
+ leftMin,
+ width - centerMin - right,
+ );
+ } else {
+ _right = limit(
+ next.tiles.last.width * width,
+ rightMin,
+ width - centerMin - left,
+ );
+ }
+ });
+ if (persist) _save();
+ },
+ ),
+ ],
+ ),
+ ),
+ ],
+ );
+ },
+ );
+}
diff --git a/desktop/lib/super_tabs/project_sidebar.dart b/desktop/lib/super_tabs/project_sidebar.dart
index 831047d9f..bd26f6c70 100644
--- a/desktop/lib/super_tabs/project_sidebar.dart
+++ b/desktop/lib/super_tabs/project_sidebar.dart
@@ -34,11 +34,8 @@ class ProjectSidebar extends StatelessWidget {
);
final waiting = groups.any((g) => needsHuman(g) > 0);
final unread = groups.any(controller.unread);
- final hasChildren =
- project != null &&
- groups.any((g) => g.id != project.leadConversationId);
final expanded =
- hasChildren && controller.expandedProjects.contains(project.id);
+ project != null && controller.expandedProjects.contains(project.id);
return Padding(
padding: const EdgeInsets.only(bottom: 2),
child: Material(
@@ -71,12 +68,9 @@ class ProjectSidebar extends StatelessWidget {
overlayColor: WidgetStatePropertyAll(Colors.transparent),
backgroundColor: WidgetStatePropertyAll(Colors.transparent),
),
- tooltip: hasChildren
- ? '${expanded ? 'Collapse' : 'Expand'} ${project.name}'
- : 'Chat with ${project.name} product manager',
- onPressed: () => hasChildren
- ? controller.toggleProject(project.id)
- : onSelect(group.id),
+ tooltip:
+ '${expanded ? 'Collapse' : 'Expand'} ${project.name}',
+ onPressed: () => controller.toggleProject(project.id),
)
else
const SizedBox(width: _iconColumn),
@@ -197,6 +191,34 @@ class ProjectSidebar extends StatelessWidget {
),
);
+ List<Widget> _workgroups(SuperTabProject project) {
+ final groups = controller.snapshot!.conversations.where(
+ (g) =>
+ g.projectId == project.id &&
+ g.id != project.leadConversationId &&
+ !g.archived,
+ );
+ return groups.isEmpty
+ ? [
+ Padding(
+ padding: const EdgeInsets.fromLTRB(
+ _iconColumn + _textGap,
+ 8,
+ 12,
+ 10,
+ ),
+ child: Align(
+ alignment: Alignment.centerLeft,
+ child: Text(
+ 'No workgroups yet',
+ style: DesktopChrome.metadata(),
+ ),
+ ),
+ ),
+ ]
+ : [for (final group in groups) _row(group)];
+ }
+
@override
Widget build(BuildContext context) {
final snapshot = controller.snapshot;
@@ -238,11 +260,7 @@ class ProjectSidebar extends StatelessWidget {
children: [
_row(lead, project: project),
if (controller.expandedProjects.contains(project.id))
- for (final group in snapshot!.conversations)
- if (group.projectId == project.id &&
- group.id != project.leadConversationId &&
- !group.archived)
- _row(group),
+ ..._workgroups(project),
],
),
],
diff --git a/desktop/lib/super_tabs/view.dart b/desktop/lib/super_tabs/view.dart
index 3c824f79a..02e5bf6e7 100644
--- a/desktop/lib/super_tabs/view.dart
+++ b/desktop/lib/super_tabs/view.dart
@@ -23,6 +23,7 @@ import 'route_row.dart';
import 'work_details.dart';
import 'project_sidebar.dart';
import 'project_options.dart';
+import 'pane_layout.dart';
typedef _ComposerChoice = ({String label, String? detail, VoidCallback choose});
@@ -60,9 +61,11 @@ class SuperTabView extends StatefulWidget {
State<SuperTabView> createState() => _SuperTabViewState();
}
-class _SuperTabViewState extends State<SuperTabView> {
+class _SuperTabViewState extends State<SuperTabView>
+ with WidgetsBindingObserver {
final _composer = TextEditingController();
final _focus = FocusNode(debugLabel: 'Swarm message');
+ final _pullRequestsFocus = FocusNode(debugLabel: 'Project pull requests');
final _scroll = <String, ScrollController>{};
final _latest = <String, int>{};
final _following = <String, bool>{};
@@ -74,6 +77,8 @@ class _SuperTabViewState extends State<SuperTabView> {
bool _sidebarOpen = false;
bool _rosterOpen = false;
bool _showPullRequests = false;
+ bool _viewEnabled = true;
+ bool _chatCovered = false;
final _loadingOlder = <String>{};
int _mentionIndex = 0;
String? _dismissedMention;
@@ -96,11 +101,26 @@ class _SuperTabViewState extends State<SuperTabView> {
@override
void initState() {
super.initState();
+ WidgetsBinding.instance.addObserver(this);
_composer.addListener(_composerMoved);
c.addListener(_changed);
_changed();
}
+ @override
+ void didChangeDependencies() {
+ super.didChangeDependencies();
+ _viewEnabled =
+ TickerMode.valuesOf(context).enabled &&
+ ModalRoute.isCurrentOf(context) != false;
+ _readVisibleTailAfterFrame();
+ }
+
+ @override
+ void didChangeAppLifecycleState(AppLifecycleState state) {
+ if (state == AppLifecycleState.resumed) _readVisibleTailAfterFrame();
+ }
+
@override
void didUpdateWidget(SuperTabView oldWidget) {
super.didUpdateWidget(oldWidget);
@@ -117,6 +137,10 @@ class _SuperTabViewState extends State<SuperTabView> {
_replies.clear();
_selected = null;
_changed();
+ } else {
+ // The cached transcript is laid out even while a terminal is in front.
+ // Returning to Chat need not fetch or append a message to make it read.
+ _readVisibleTailAfterFrame();
}
}
@@ -155,11 +179,14 @@ class _SuperTabViewState extends State<SuperTabView> {
setState(() {});
if (firstView || (grew && atEnd)) {
_followEnd(id);
+ } else if (atEnd) {
+ _readVisibleTailAfterFrame();
}
}
void _followEnd(String id) {
final request = ++_scrollRequest;
+ final sequence = _latest[id] ?? 0;
_jumpingToEnd = true;
void advance(int attempt) {
WidgetsBinding.instance.addPostFrameCallback((_) {
@@ -186,7 +213,7 @@ class _SuperTabViewState extends State<SuperTabView> {
} else {
_jumpingToEnd = false;
if (scroll.position.extentAfter < 40) {
- _readToEnd(id, _latest[id] ?? 0);
+ _readToEnd(id, sequence);
}
}
});
@@ -198,12 +225,57 @@ class _SuperTabViewState extends State<SuperTabView> {
advance(0);
}
+ bool get _chatIsVisible {
+ if (!mounted ||
+ !_viewEnabled ||
+ _chatCovered ||
+ c.accessRevoked ||
+ _terminalsVisible ||
+ _showPullRequests) {
+ return false;
+ }
+ final lifecycle = WidgetsBinding.instance.lifecycleState;
+ if (lifecycle != null && lifecycle != AppLifecycleState.resumed) {
+ return false;
+ }
+ final app = widget.app;
+ if (app != null &&
+ (!app.inForeground ||
+ app.currentUser?.id != c.accountId ||
+ app.activeSwarm.superTabId != c.tabId)) {
+ return false;
+ }
+ var hidden = false;
+ context.visitAncestorElements((element) {
+ if (element.widget case Offstage(offstage: true)) hidden = true;
+ return !hidden;
+ });
+ return !hidden;
+ }
+
+ void _readVisibleTailAfterFrame() {
+ final id = c.selectedId;
+ final sequence = c.messages(id).lastOrNull?.sequence ?? 0;
+ WidgetsBinding.instance.addPostFrameCallback((_) {
+ if (mounted && !_jumpingToEnd) _readToEnd(id, sequence);
+ });
+ // Widget updates already have a frame in progress. Reuse it so routine
+ // polling does not request an otherwise unnecessary frame after each build.
+ WidgetsBinding.instance.ensureVisualUpdate();
+ }
+
void _readToEnd(String id, int sequence) {
+ final scroll = _scroll[id];
+ if (c.selectedId != id ||
+ !_chatIsVisible ||
+ scroll == null ||
+ !scroll.hasClients ||
+ scroll.position.extentAfter >= 40) {
+ return;
+ }
_following[id] = true;
if (_newAfter.containsKey(id)) setState(() => _newAfter.remove(id));
- if (!_terminalsVisible && !_showPullRequests) {
- c.markRead(id, through: sequence);
- }
+ c.markRead(id, through: sequence);
}
void _jumpToLatest() {
@@ -213,9 +285,11 @@ class _SuperTabViewState extends State<SuperTabView> {
@override
void dispose() {
+ WidgetsBinding.instance.removeObserver(this);
c.removeListener(_changed);
_composer.dispose();
_focus.dispose();
+ _pullRequestsFocus.dispose();
for (final scroll in _scroll.values) {
scroll.dispose();
}
@@ -610,11 +684,11 @@ class _SuperTabViewState extends State<SuperTabView> {
Widget _sidebar() => ProjectSidebar(
controller: c,
onNewProject: widget.onNewProject,
- onYourDevices: widget.app == null
+ onYourDevices: widget.app?.devicesEnabled != true
? null
: () {
_closeSidebar();
- widget.app!.requestMachines();
+ widget.app!.openDevices();
},
needsHuman: (group) => _needsHuman(group).length,
onSelect: (id) {
@@ -644,6 +718,18 @@ class _SuperTabViewState extends State<SuperTabView> {
widget.onOpenTerminal(agent);
}
+ void _leaveResize() {
+ if (_terminalsVisible) {
+ FocusManager.instance.primaryFocus?.unfocus();
+ final app = widget.app, paneId = widget.app?.focusedPaneId;
+ if (app != null && paneId != null) app.focusPane(paneId, reveal: true);
+ } else if (_showPullRequests) {
+ _pullRequestsFocus.requestFocus();
+ } else {
+ _focus.requestFocus();
+ }
+ }
+
bool get _terminalsVisible =>
widget.terminalsVisible || widget.terminal != null;
@@ -692,6 +778,7 @@ class _SuperTabViewState extends State<SuperTabView> {
onPressed: () {
setState(() => _showPullRequests = false);
widget.onCloseTerminal?.call();
+ _readVisibleTailAfterFrame();
WidgetsBinding.instance.addPostFrameCallback((_) {
if (mounted) _focus.requestFocus();
});
@@ -717,6 +804,7 @@ class _SuperTabViewState extends State<SuperTabView> {
const SizedBox(width: 4),
AppIconButton(
key: const ValueKey('super-pull-requests'),
+ focusNode: _pullRequestsFocus,
icon: AppIcons.gitPullRequest,
size: AppIcons.inlineSize,
tooltip: 'Pull requests',
@@ -1484,6 +1572,14 @@ class _SuperTabViewState extends State<SuperTabView> {
constraints.maxWidth < MediaQuery.textScalerOf(context).scale(720);
final showRoster =
constraints.maxWidth >= MediaQuery.textScalerOf(context).scale(1080);
+ final chatCovered =
+ (narrow && _sidebarOpen) || (!showRoster && _rosterOpen);
+ if (_chatCovered && !chatCovered) {
+ // Both dismissing a drawer and widening the window reveal the cached
+ // transcript without loading another message.
+ _readVisibleTailAfterFrame();
+ }
+ _chatCovered = chatCovered;
final roster = SuperTabRoster(
controller: c,
app: widget.app,
@@ -1503,46 +1599,38 @@ class _SuperTabViewState extends State<SuperTabView> {
return Stack(
children: [
ExcludeFocus(
- excluding: (narrow && _sidebarOpen) || (!showRoster && _rosterOpen),
- child: Row(
- children: [
- if (!narrow) ...[
- SizedBox(width: 220, child: _sidebar()),
- VerticalDivider(width: 1, color: DesktopChrome.rim),
- ],
- Expanded(
- child: Column(
- children: [
- _header(c.selected, narrow, showRoster),
- Expanded(
- child: IndexedStack(
- index: c.snapshot?.projects.isEmpty == true
- ? 0
- : _terminalsVisible
- ? 1
- : _showPullRequests
- ? 2
- : 0,
- children: [
- _conversation(narrow),
- terminal ?? const SizedBox.shrink(),
- _showPullRequests
- ? SuperTabPullRequests(
- controller: c,
- app: widget.app,
- )
- : const SizedBox.shrink(),
- ],
- ),
- ),
- ],
+ excluding: chatCovered,
+ child: SuperTabPaneLayout(
+ storage: widget.app?.localStore,
+ onLeave: _leaveResize,
+ left: narrow ? null : _sidebar(),
+ right: showRoster ? roster : null,
+ center: Column(
+ children: [
+ _header(c.selected, narrow, showRoster),
+ Expanded(
+ child: IndexedStack(
+ index: c.snapshot?.projects.isEmpty == true
+ ? 0
+ : _terminalsVisible
+ ? 1
+ : _showPullRequests
+ ? 2
+ : 0,
+ children: [
+ _conversation(narrow),
+ terminal ?? const SizedBox.shrink(),
+ _showPullRequests
+ ? SuperTabPullRequests(
+ controller: c,
+ app: widget.app,
+ )
+ : const SizedBox.shrink(),
+ ],
+ ),
),
- ),
- if (showRoster) ...[
- VerticalDivider(width: 1, color: DesktopChrome.rim),
- SizedBox(width: 288, child: roster),
],
- ],
+ ),
),
),
if (!showRoster && _rosterOpen)
@@ -1564,7 +1652,12 @@ class _SuperTabViewState extends State<SuperTabView> {
color: grid.AppDesktop.veil(Theme.of(context).brightness),
child: Align(
alignment: Alignment.centerRight,
- child: SizedBox(width: 288, child: roster),
+ child: SizedBox(
+ width: constraints.maxWidth
+ .clamp(0, SuperTabPaneLayout.rightWidth)
+ .toDouble(),
+ child: roster,
+ ),
),
),
),
diff --git a/desktop/lib/super_tabs/workspace.dart b/desktop/lib/super_tabs/workspace.dart
index 639a2f968..f9ed37b7d 100644
--- a/desktop/lib/super_tabs/workspace.dart
+++ b/desktop/lib/super_tabs/workspace.dart
@@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
import '../shared/widgets/app_dialog.dart';
import '../state/app_state.dart';
import '../state/terminal_pane.dart';
+import 'agent_group_picker.dart';
import 'controller.dart';
import 'dialog_scope.dart';
import 'model.dart';
@@ -314,13 +315,15 @@ class _SuperTabWorkspaceState extends State<SuperTabWorkspace> {
String groupId, {
bool resume = false,
}) {
+ final group = controller.snapshot?.conversation(groupId);
if (!mounted ||
app.activeSwarmId != tabId ||
- controller.snapshot
- ?.conversation(groupId)
- ?.agentIds
- .contains(agent.id) !=
- true) {
+ controller.accountId != app.currentUser?.id ||
+ controller.accessRevoked ||
+ controller.snapshot?.agent(agent.id) == null ||
+ group == null ||
+ group.archived ||
+ !group.agentIds.contains(agent.id)) {
return;
}
controller.select(groupId);
@@ -352,40 +355,9 @@ class _SuperTabWorkspaceState extends State<SuperTabWorkspace> {
controller: controller,
requireWrite: false,
projectId: agent.projectId,
- child: AlertDialog(
- title: Text(
- 'Open ${controller.snapshot?.agentName(agent.id) ?? agent.name}',
- ),
- content: SizedBox(
- width: 360,
- child: ListenableBuilder(
- listenable: controller,
- builder: (context, _) => ListView(
- shrinkWrap: true,
- children: [
- for (final group
- in controller.snapshot?.conversations ??
- <SuperTabConversation>[])
- if (!group.archived && group.agentIds.contains(agent.id))
- ListTile(
- key: ValueKey('super-agent-group-${group.id}'),
- title: Text(
- controller.snapshot!.isProjectLead(group.id)
- ? '${controller.snapshot!.projectFor(group.id)!.name} product manager'
- : group.label,
- ),
- onTap: () => Navigator.pop(context, group.id),
- ),
- ],
- ),
- ),
- ),
- actions: [
- TextButton(
- onPressed: () => Navigator.pop(context),
- child: const Text('Cancel'),
- ),
- ],
+ child: SuperTabAgentGroupPicker(
+ controller: controller,
+ agentId: agent.id,
),
),
);
diff --git a/desktop/test/super_tab_agent_group_picker_test.dart b/desktop/test/super_tab_agent_group_picker_test.dart
new file mode 100644
index 000000000..7d6f4d471
--- /dev/null
+++ b/desktop/test/super_tab_agent_group_picker_test.dart
@@ -0,0 +1,307 @@
+import 'dart:io';
+
+import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:harness/shared/theme/app_theme.dart' as grid;
+import 'package:harness/shared/widgets/app_dialog.dart';
+import 'package:harness/super_tabs/agent_group_picker.dart';
+import 'package:harness/super_tabs/controller.dart';
+import 'package:harness/super_tabs/dialog_scope.dart';
+import 'package:harness/widgets/desktop_chrome.dart';
+
+import 'support/capture.dart';
+import 'support/super_tab_fixture.dart';
+
+void main() {
+ final captures = Platform.environment['HARNESS_AGENT_GROUP_CAPTURE_DIR'];
+ setUpAll(() => loadCaptureFonts(captures));
+
+ late ConversationServer server;
+ late SuperTabController controller;
+ String? opened;
+ var dismissed = false;
+
+ setUp(() {
+ server = ConversationServer();
+ server.state['projects'] = [
+ projectFixture('lead', 'sample-project', 'lead'),
+ ];
+ server.state['agents'] = [
+ {
+ 'id': 'agent',
+ 'projectId': 'lead',
+ 'name': 'Lead',
+ 'displayName': 'Nova',
+ 'machineId': 'm',
+ 'harnessId': 'native',
+ 'contributorId': 'owner',
+ 'configuration': {'engine': 'codex'},
+ },
+ ];
+ for (final group in server.state['conversations'] as List) {
+ group['agentIds'] = ['agent'];
+ }
+ (server.state['conversations'] as List)[1]['number'] = 12;
+ opened = null;
+ dismissed = false;
+ });
+
+ Future<void> show(
+ WidgetTester tester, {
+ Brightness brightness = Brightness.dark,
+ double scale = 1,
+ Size size = const Size(900, 700),
+ String initialGroup = 'lead',
+ }) async {
+ await tester.binding.setSurfaceSize(size);
+ addTearDown(() => tester.binding.setSurfaceSize(null));
+ final previous = grid.AppTheme.brightness.value;
+ grid.AppTheme.brightness.value = brightness;
+ addTearDown(() => grid.AppTheme.brightness.value = previous);
+ controller = server.controller();
+ await controller.refresh();
+ controller.select(initialGroup);
+ await tester.pumpWidget(
+ MaterialApp(
+ debugShowCheckedModeBanner: false,
+ theme: grid.buildAppTheme(brightness: brightness),
+ builder: (context, child) => MediaQuery(
+ data: MediaQuery.of(context).copyWith(
+ textScaler: TextScaler.linear(scale),
+ disableAnimations: true,
+ ),
+ child: child!,
+ ),
+ home: Builder(
+ builder: (context) => Scaffold(
+ body: TextButton(
+ onPressed: () async {
+ opened = await showAppDialog<String>(
+ context: context,
+ builder: (_) => SuperTabDialogScope(
+ controller: controller,
+ requireWrite: false,
+ projectId: 'lead',
+ child: SuperTabAgentGroupPicker(
+ controller: controller,
+ agentId: 'agent',
+ ),
+ ),
+ );
+ dismissed = true;
+ },
+ child: const Text('Choose agent'),
+ ),
+ ),
+ ),
+ ),
+ );
+ await tester.tap(find.text('Choose agent'));
+ await tester.pumpAndSettle();
+ }
+
+ Future<void> close(WidgetTester tester) async {
+ await tester.pumpWidget(const SizedBox());
+ await controller.flush();
+ controller.dispose();
+ await tester.pump();
+ }
+
+ Finder row(String id) => find.byKey(ValueKey('super-agent-group-$id'));
+ final open = find.byKey(const ValueKey('super-agent-group-open'));
+ final cancel = find.byKey(const ValueKey('super-agent-group-cancel'));
+ bool selected(WidgetTester tester, String id) =>
+ tester
+ .widget<Semantics>(
+ find.ancestor(of: row(id), matching: find.byType(Semantics)).first,
+ )
+ .properties
+ .selected ==
+ true;
+
+ testWidgets('selection waits for Open and uses the current group initially', (
+ tester,
+ ) async {
+ await show(tester, initialGroup: 'offline');
+ expect(find.text('Open Nova'), findsOneWidget);
+ expect(selected(tester, 'offline'), isTrue);
+ expect(find.text('#12 Offline editing'), findsOneWidget);
+ expect(find.text('Product Manager'), findsOneWidget);
+ await tester.tap(row('lead'));
+ await tester.pump();
+ expect(selected(tester, 'lead'), isTrue);
+ expect(controller.selectedId, 'offline');
+ expect(opened, isNull);
+ expect(dismissed, isFalse);
+ await tester.tap(open);
+ await tester.pumpAndSettle();
+ expect(opened, 'lead');
+ expect(server.posts, isEmpty);
+ await close(tester);
+ });
+
+ testWidgets('arrow keys select, Enter opens and Tab reaches the actions', (
+ tester,
+ ) async {
+ await show(tester);
+ expect(selected(tester, 'lead'), isTrue);
+ await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown);
+ await tester.pump();
+ expect(selected(tester, 'offline'), isTrue);
+ expect(dismissed, isFalse);
+ await tester.sendKeyEvent(LogicalKeyboardKey.arrowUp);
+ await tester.pump();
+ expect(selected(tester, 'lead'), isTrue);
+ await tester.sendKeyEvent(LogicalKeyboardKey.tab);
+ await tester.pump();
+ expect(
+ Focus.of(
+ tester.element(
+ find.descendant(of: cancel, matching: find.text('Cancel')),
+ ),
+ ).hasFocus,
+ isTrue,
+ );
+ await tester.sendKeyEvent(LogicalKeyboardKey.tab);
+ await tester.pump();
+ expect(
+ Focus.of(
+ tester.element(find.descendant(of: open, matching: find.text('Open'))),
+ ).hasFocus,
+ isTrue,
+ );
+ await tester.sendKeyDownEvent(LogicalKeyboardKey.shiftLeft);
+ await tester.sendKeyEvent(LogicalKeyboardKey.tab);
+ await tester.sendKeyEvent(LogicalKeyboardKey.tab);
+ await tester.sendKeyUpEvent(LogicalKeyboardKey.shiftLeft);
+ await tester.pump();
+ await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown);
+ await tester.sendKeyEvent(LogicalKeyboardKey.enter);
+ await tester.pumpAndSettle();
+ expect(opened, 'offline');
+ await close(tester);
+ });
+
+ testWidgets('double-click opens; Cancel leaves navigation alone', (
+ tester,
+ ) async {
+ await show(tester);
+ await tester.tap(row('offline'));
+ await tester.pump(const Duration(milliseconds: 60));
+ await tester.tap(row('offline'));
+ await tester.pumpAndSettle();
+ expect(opened, 'offline');
+ opened = null;
+ await tester.tap(find.text('Choose agent'));
+ await tester.pumpAndSettle();
+ await tester.tap(cancel);
+ await tester.pumpAndSettle();
+ expect(opened, isNull);
+ expect(controller.selectedId, 'lead');
+ expect(server.posts, isEmpty);
+ await close(tester);
+ });
+
+ testWidgets(
+ 'removed selection disables Open without choosing another group',
+ (tester) async {
+ await show(tester);
+ (server.state['conversations'] as List)[0]['agentIds'] = <String>[];
+ server.revision++;
+ await controller.refresh();
+ await tester.pumpAndSettle();
+ expect(row('lead'), findsNothing);
+ expect(selected(tester, 'offline'), isFalse);
+ expect(tester.widget<FilledButton>(open).onPressed, isNull);
+ await tester.sendKeyEvent(LogicalKeyboardKey.enter);
+ await tester.pumpAndSettle();
+ expect(dismissed, isFalse);
+ await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown);
+ await tester.pump();
+ expect(selected(tester, 'offline'), isTrue);
+ await tester.tap(open);
+ await tester.pumpAndSettle();
+ expect(opened, 'offline');
+ await close(tester);
+ },
+ );
+
+ testWidgets('removed agents and archived groups cannot be opened', (
+ tester,
+ ) async {
+ await show(tester);
+ for (final group in server.state['conversations'] as List) {
+ group['archived'] = true;
+ }
+ server.revision++;
+ await controller.refresh();
+ await tester.pumpAndSettle();
+ expect(
+ find.text('No available workgroups for this agent.'),
+ findsOneWidget,
+ );
+ expect(tester.widget<FilledButton>(open).onPressed, isNull);
+ for (final group in server.state['conversations'] as List) {
+ group['archived'] = false;
+ }
+ server.state['agents'] = <Object>[];
+ server.revision++;
+ await controller.refresh();
+ await tester.pumpAndSettle();
+ expect(row('lead'), findsNothing);
+ expect(tester.widget<FilledButton>(open).onPressed, isNull);
+ expect(opened, isNull);
+ await close(tester);
+ });
+
+ testWidgets('revocation removes the captured choices and confirmation', (
+ tester,
+ ) async {
+ await show(tester);
+ controller.revokeAccess('Signed out');
+ await tester.pumpAndSettle();
+ expect(find.text('Open Nova'), findsNothing);
+ expect(open, findsNothing);
+ expect(find.text('This action is no longer available.'), findsOneWidget);
+ expect(opened, isNull);
+ await close(tester);
+ });
+
+ for (final brightness in Brightness.values) {
+ for (final scale in [1.0, 2.0]) {
+ testWidgets('chooser fits ${brightness.name} at ${scale}x', (
+ tester,
+ ) async {
+ (server.state['conversations'] as List).add({
+ ...conversationFixture(
+ 'long',
+ 'Verify offline recovery and restore the shared workspace',
+ ),
+ 'agentIds': ['agent'],
+ 'number': 123,
+ });
+ await show(tester, brightness: brightness, scale: scale);
+ await captureWindow(
+ tester,
+ captures,
+ 'agent-groups-${brightness.name}-${scale}x',
+ );
+ expect(tester.takeException(), isNull);
+ expect(open.hitTestable(), findsOneWidget);
+ expect(
+ tester.getSize(find.byType(DesktopDialogSurface)).height,
+ lessThan(600),
+ );
+ await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown);
+ await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown);
+ await tester.pumpAndSettle();
+ expect(row('long').hitTestable(), findsOneWidget);
+ await tester.sendKeyEvent(LogicalKeyboardKey.enter);
+ await tester.pumpAndSettle();
+ expect(opened, 'long');
+ await close(tester);
+ });
+ }
+ }
+}
diff --git a/desktop/test/super_tab_chat_test.dart b/desktop/test/super_tab_chat_test.dart
index eacb66fe3..33f2b4331 100644
--- a/desktop/test/super_tab_chat_test.dart
+++ b/desktop/test/super_tab_chat_test.dart
@@ -48,8 +48,292 @@ void main() {
return c;
}
+ Future<void> showReadView(
+ WidgetTester tester,
+ SuperTabController c, {
+ bool terminals = false,
+ bool hidden = false,
+ }) async {
+ await tester.pumpWidget(
+ MaterialApp(
+ theme: grid.buildAppTheme(brightness: Brightness.dark),
+ home: Scaffold(
+ body: TickerMode(
+ enabled: !hidden,
+ child: Offstage(
+ offstage: hidden,
+ child: SuperTabView(
+ controller: c,
+ onInvite: () {},
+ onAddAgent: (_) {},
+ onOpenTerminal: (_) {},
+ machineName: (_) => 'Team Mac',
+ terminalsVisible: terminals,
+ ),
+ ),
+ ),
+ ),
+ ),
+ );
+ await tester.pumpAndSettle();
+ }
+
+ Future<void> closeReadView(WidgetTester tester, SuperTabController c) async {
+ await tester.pumpWidget(const SizedBox());
+ await c.flush();
+ }
+
+ testWidgets('polling a displayed transcript does not keep requesting frames', (
+ tester,
+ ) async {
+ final server = ConversationServer()..append('Already read');
+ final c = SuperTabController(
+ tabId: 'tab',
+ accountId: 'owner',
+ request: server.request,
+ save: server.save,
+ );
+ try {
+ await c.refresh();
+ await tester.pumpWidget(
+ MaterialApp(
+ theme: grid.buildAppTheme(brightness: Brightness.dark),
+ home: Scaffold(
+ body: ListenableBuilder(
+ listenable: c,
+ builder: (context, _) => SuperTabView(
+ controller: c,
+ onInvite: () {},
+ onAddAgent: (_) {},
+ onOpenTerminal: (_) {},
+ machineName: (_) => 'Team Mac',
+ ),
+ ),
+ ),
+ ),
+ );
+ await tester.pumpAndSettle();
+ c.start();
+ server.append('New polled update');
+ // Polling rebuilds the view during each frame. Reading its already-laid-out
+ // tail must reuse that frame, rather than perpetually requesting another.
+ await tester.pumpAndSettle(
+ const Duration(seconds: 10),
+ EnginePhase.sendSemanticsUpdate,
+ const Duration(minutes: 1),
+ );
+ expect(find.text('New polled update'), findsOneWidget);
+ expect(c.unread(c.selected!), isFalse);
+ } finally {
+ await closeReadView(tester, c);
+ c.dispose();
+ }
+ });
+
+ testWidgets('returning from terminals reads the already loaded transcript', (
+ tester,
+ ) async {
+ final server = ConversationServer()..append('The result is ready.');
+ final c = server.controller();
+ addTearDown(c.dispose);
+ await c.refresh();
+ await showReadView(tester, c, terminals: true);
+ expect(c.unread(c.selected!), isTrue);
+ await showReadView(tester, c);
+ expect(find.text('The result is ready.'), findsOneWidget);
+ expect(c.unread(c.selected!), isFalse);
+ expect(tester.takeException(), isNull);
+ await closeReadView(tester, c);
+ });
+
+ testWidgets(
+ 'revisiting a cached conversation acknowledges its visible tail',
+ (tester) async {
+ final server = ConversationServer()
+ ..append('The lead has an update.')
+ ..append('Workgroup result.', conversationId: 'offline');
+ final c = server.controller();
+ addTearDown(c.dispose);
+ await c.refresh();
+ await showReadView(tester, c, terminals: true);
+ expect(c.unread(c.selected!), isTrue);
+ c.select('offline');
+ await tester.pumpAndSettle();
+ await showReadView(tester, c);
+ expect(c.unread(c.selected!), isFalse);
+ expect(c.unread(c.snapshot!.conversation('lead')!), isTrue);
+ c.select('lead');
+ await tester.pumpAndSettle();
+ expect(find.text('The lead has an update.'), findsOneWidget);
+ expect(c.unread(c.selected!), isFalse);
+ await closeReadView(tester, c);
+ },
+ );
+
+ testWidgets(
+ 'returning from pull requests reads only the displayed messages',
+ (tester) async {
+ final server = ConversationServer()..append('First update');
+ final c = await show(tester, server);
+ await tester.tap(find.byKey(const ValueKey('super-pull-requests')));
+ await tester.pumpAndSettle();
+ server.append('The review is ready.');
+ await c.refresh();
+ await tester.pumpAndSettle();
+ expect(c.unread(c.selected!), isTrue);
+ await tester.tap(find.byKey(const ValueKey('super-chat')));
+ await tester.pumpAndSettle();
+ expect(find.text('The review is ready.'), findsOneWidget);
+ expect(c.unread(c.selected!), isFalse);
+ await closeReadView(tester, c);
+ },
+ );
+
+ testWidgets(
+ 'a read message does not become unread when its snapshot arrives',
+ (tester) async {
+ final server = ConversationServer()..append('First update');
+ final c = await show(tester, server);
+ server.append('Loaded before the snapshot');
+ await c.loadMessages('lead');
+ await tester.pumpAndSettle();
+ expect(find.text('Loaded before the snapshot'), findsOneWidget);
+ expect(c.selected!.lastMessageSequence, 1);
+ await c.refresh();
+ await tester.pumpAndSettle();
+ expect(c.selected!.lastMessageSequence, 2);
+ expect(c.unread(c.selected!), isFalse);
+ await closeReadView(tester, c);
+ },
+ );
+
+ testWidgets('a newer snapshot stays unread until its message is fetched', (
+ tester,
+ ) async {
+ final server = ConversationServer()..append('Visible update');
+ final c = await show(tester, server);
+ await tester.tap(find.byKey(const ValueKey('super-pull-requests')));
+ await tester.pumpAndSettle();
+ server.append('Not yet fetched');
+ c.snapshot = SuperTabSnapshot.fromJson(server.state);
+ await tester.tap(find.byKey(const ValueKey('super-chat')));
+ await tester.pumpAndSettle();
+ expect(find.text('Not yet fetched'), findsNothing);
+ expect(c.unread(c.selected!), isTrue);
+ await c.loadMessages('lead');
+ await tester.pumpAndSettle();
+ expect(find.text('Not yet fetched'), findsOneWidget);
+ expect(c.unread(c.selected!), isFalse);
+ await closeReadView(tester, c);
+ });
+
+ testWidgets('a hidden transcript does not consume a queued read callback', (
+ tester,
+ ) async {
+ final server = ConversationServer()..append('Already read');
+ final c = server.controller();
+ addTearDown(c.dispose);
+ await c.refresh();
+ await showReadView(tester, c);
+ expect(c.unread(c.selected!), isFalse);
+ server.append('Arrived as the tab was hidden');
+ await c.refresh();
+ // Hide before the callback scheduled by the message load can run.
+ await showReadView(tester, c, hidden: true);
+ expect(c.unread(c.selected!), isTrue);
+ await showReadView(tester, c);
+ expect(c.unread(c.selected!), isFalse);
+ await closeReadView(tester, c);
+ });
+
+ testWidgets('background windows keep messages unread until foregrounded', (
+ tester,
+ ) async {
+ final server = ConversationServer()..append('Already read');
+ final c = await show(tester, server);
+ addTearDown(
+ () => tester.binding.handleAppLifecycleStateChanged(
+ AppLifecycleState.resumed,
+ ),
+ );
+ tester.binding.handleAppLifecycleStateChanged(AppLifecycleState.inactive);
+ server.append('Arrived behind another window');
+ await c.refresh();
+ await tester.pumpAndSettle();
+ expect(c.unread(c.selected!), isTrue);
+ tester.binding.handleAppLifecycleStateChanged(AppLifecycleState.resumed);
+ await tester.pumpAndSettle();
+ expect(c.unread(c.selected!), isFalse);
+ await closeReadView(tester, c);
+ });
+
+ for (final drawer in ['Conversations', 'Members and machines']) {
+ testWidgets('$drawer keeps covered messages unread until revealed', (
+ tester,
+ ) async {
+ await tester.binding.setSurfaceSize(const Size(600, 700));
+ addTearDown(() => tester.binding.setSurfaceSize(null));
+ final server = ConversationServer()..append('Already read');
+ final c = await show(tester, server);
+ expect(c.unread(c.selected!), isFalse);
+
+ await tester.tap(find.byTooltip(drawer));
+ await tester.pumpAndSettle();
+ server.append('Arrived behind the drawer');
+ await c.refresh();
+ await tester.pumpAndSettle();
+ expect(c.unread(c.selected!), isTrue);
+
+ await tester.sendKeyEvent(LogicalKeyboardKey.escape);
+ await tester.pumpAndSettle();
+ expect(find.text('Arrived behind the drawer'), findsOneWidget);
+ expect(c.unread(c.selected!), isFalse);
+
+ await tester.tap(find.byTooltip(drawer));
+ await tester.pumpAndSettle();
+ server.append('Arrived before widening the window');
+ await c.refresh();
+ await tester.pumpAndSettle();
+ expect(c.unread(c.selected!), isTrue);
+
+ // Responsive side panes stop covering the chat even while their drawer
+ // flags remain set, so this also needs to acknowledge the visible tail.
+ await tester.binding.setSurfaceSize(const Size(1200, 700));
+ await tester.pumpAndSettle();
+ expect(find.text('Arrived before widening the window'), findsOneWidget);
+ expect(c.unread(c.selected!), isFalse);
+ await closeReadView(tester, c);
+ });
+ }
+
+ testWidgets('a project stays unread until its unread workgroup is visited', (
+ tester,
+ ) async {
+ final server = ConversationServer()
+ ..append('The lead update')
+ ..append('An unread workgroup update', conversationId: 'offline');
+ final c = await show(tester, server);
+ Finder projectDot() => find.descendant(
+ of: find.byKey(const ValueKey('super-group-lead')),
+ matching: find.byWidgetPredicate(
+ (widget) =>
+ widget is Semantics && widget.properties.label == 'Unread messages',
+ ),
+ );
+ expect(c.unread(c.selected!), isFalse);
+ expect(projectDot(), findsOneWidget);
+ await tester.tap(find.byKey(const ValueKey('super-project-expand-lead')));
+ await tester.pumpAndSettle();
+ await tester.tap(find.byKey(const ValueKey('super-group-offline')));
+ await tester.pumpAndSettle();
+ expect(find.text('An unread workgroup update'), findsOneWidget);
+ expect(c.unread(c.selected!), isFalse);
+ expect(projectDot(), findsNothing);
+ await closeReadView(tester, c);
+ });
+
testWidgets(
- 'an agent keeps its individual name in messages, replies and participants',
+ 'legacy messages resolve the same agent name in chat, replies and participants',
(tester) async {
final server = ConversationServer();
(server.state['agents'] as List).add({
@@ -68,8 +352,7 @@ void main() {
server.messages.last['author'] = {
'kind': 'agent',
'id': 'lead-agent',
- 'name': 'hi',
- 'displayName': 'Atlas',
+ 'name': 'Lead',
};
final c = await show(tester, server);
final row = find.byKey(const ValueKey('super-message-message-1'));
@@ -78,6 +361,7 @@ void main() {
findsOneWidget,
);
expect(find.text('hi'), findsNothing);
+ expect(find.text('Lead'), findsNothing);
tester
.widget<Focus>(
find.descendant(of: row, matching: find.byType(Focus)).first,
@@ -147,33 +431,57 @@ void main() {
expect(find.text('Builder'), findsNothing);
});
- test('legacy author labels stay the same before and after removal', () {
- final server = ConversationServer()..append('An older message');
- (server.state['agents'] as List).add({
- 'id': 'old-agent',
- 'name': 'Builder',
- 'displayName': 'Sage',
- 'machineId': 'm',
- 'harnessId': 'native',
- 'contributorId': 'owner',
- 'configuration': {'engine': 'codex'},
- });
- server.messages.last['author'] = {
- 'kind': 'agent',
- 'id': 'old-agent',
- 'name': 'Builder',
- };
- final message = SuperTabMessage.fromJson(server.messages.last);
- expect(
- SuperTabSnapshot.fromJson(server.state).authorName(message),
- 'Builder',
- );
- server.state['agents'] = <Object>[];
- expect(
- SuperTabSnapshot.fromJson(server.state).authorName(message),
- 'Builder',
- );
- });
+ test(
+ 'current agent identities resolve by ID; removed agents use recorded names',
+ () {
+ final server = ConversationServer()..append('An older message');
+ (server.state['agents'] as List).add({
+ 'id': 'old-agent',
+ 'name': 'Builder',
+ 'displayName': 'Sage',
+ 'machineId': 'm',
+ 'harnessId': 'native',
+ 'contributorId': 'owner',
+ 'configuration': {'engine': 'codex'},
+ });
+ server.messages.last['author'] = {
+ 'kind': 'agent',
+ 'id': 'old-agent',
+ 'name': 'Builder',
+ };
+ final message = SuperTabMessage.fromJson(server.messages.last);
+ expect(
+ SuperTabSnapshot.fromJson(server.state).authorName(message),
+ 'Sage',
+ );
+ final renamed = SuperTabMessage.fromJson({
+ ...server.messages.last,
+ 'author': {...message.author, 'displayName': 'Former name'},
+ });
+ expect(
+ SuperTabSnapshot.fromJson(server.state).authorName(renamed),
+ 'Sage',
+ );
+ final human = SuperTabMessage.fromJson({
+ ...server.messages.last,
+ 'author': {'kind': 'human', 'id': 'old-agent', 'name': 'Owner'},
+ });
+ expect(
+ SuperTabSnapshot.fromJson(server.state).authorName(human),
+ 'Owner',
+ );
+ server.state['agents'] = <Object>[];
+ expect(
+ SuperTabSnapshot.fromJson(server.state).authorName(message),
+ 'Builder',
+ );
+ expect(
+ SuperTabSnapshot.fromJson(server.state).authorName(renamed),
+ 'Former name',
+ );
+ expect(message.authorName, 'Builder');
+ },
+ );
testWidgets(
'a keyboard reply keeps its quoted context after sending and refreshing',
@@ -252,6 +560,18 @@ void main() {
expect(scroll().offset, reading);
expect(find.text('2 new messages'), findsOneWidget);
expect(c.unread(c.selected!), isTrue);
+ await tester.tap(find.byKey(const ValueKey('super-pull-requests')));
+ await tester.pumpAndSettle();
+ await tester.tap(find.byKey(const ValueKey('super-chat')));
+ await tester.pumpAndSettle();
+ expect(scroll().offset, reading);
+ expect(c.unread(c.selected!), isTrue);
+ c.select('offline');
+ await tester.pumpAndSettle();
+ c.select('lead');
+ await tester.pumpAndSettle();
+ expect(scroll().offset, reading);
+ expect(c.unread(c.selected!), isTrue);
await tester.tap(find.byKey(const ValueKey('super-new-messages')));
await tester.pumpAndSettle();
expect(find.text('2 new messages'), findsNothing);
@@ -259,6 +579,7 @@ void main() {
expect(c.unread(c.selected!), isFalse);
expect(find.text('The restart check passed too.'), findsOneWidget);
expect(tester.takeException(), isNull);
+ await closeReadView(tester, c);
},
);
diff --git a/desktop/test/super_tab_controller_test.dart b/desktop/test/super_tab_controller_test.dart
index 7c18a8a67..cab2314f7 100644
--- a/desktop/test/super_tab_controller_test.dart
+++ b/desktop/test/super_tab_controller_test.dart
@@ -137,6 +137,7 @@ void main() {
controller.unread(controller.snapshot!.conversation('lead')!),
isTrue,
);
+ await controller.loadMessages('lead');
controller.markRead('lead');
expect(
controller.unread(controller.snapshot!.conversation('lead')!),
@@ -145,6 +146,69 @@ void main() {
},
);
+ test(
+ 'a displayed tail stays read when an older snapshot catches up',
+ () async {
+ final server = ConversationServer()..append('First visible update');
+ final c = await open(server);
+ c.markRead('lead', through: 1);
+ server.append('Arrived before the snapshot');
+ await c.loadMessages('lead');
+ expect(c.selected!.lastMessageSequence, 1);
+ expect(c.unread(c.selected!), isTrue);
+ c.markRead('lead', through: 2);
+ await c.flush();
+ expect(server.saved!['readAt'], {'lead': 2});
+ await c.refresh();
+ expect(c.selected!.lastMessageSequence, 2);
+ expect(c.unread(c.selected!), isFalse);
+ },
+ );
+
+ test(
+ 'read boundaries cannot acknowledge messages that were never loaded',
+ () async {
+ final server = ConversationServer()..append('Loaded update');
+ final c = await open(server);
+ server.append('A newer lead message');
+ server.append('A workgroup never opened', conversationId: 'offline');
+ c.select('offline');
+ // The selected-group request has not returned. No snapshot-only boundary
+ // can acknowledge either the missing workgroup or the missing lead tail.
+ c.markRead('offline', through: 999);
+ c.markRead('lead', through: 999);
+ await c.flush();
+ expect(server.saved!['readAt'], {'lead': 1});
+ await c.refresh();
+ c.markRead('lead', through: 999);
+ expect(c.unread(c.snapshot!.conversation('lead')!), isTrue);
+ expect(c.unread(c.snapshot!.conversation('offline')!), isTrue);
+ c.markRead('offline', through: 3);
+ expect(c.unread(c.snapshot!.conversation('offline')!), isFalse);
+ expect(c.unread(c.snapshot!.conversation('lead')!), isTrue);
+ },
+ );
+
+ test('read markers persist for their Swarm and account only', () async {
+ final server = ConversationServer()..append('Seen update');
+ final c = await open(server);
+ c.markRead('lead', through: 1);
+ await c.flush();
+ final saved = server.saved!;
+ final restored = server.controller(initial: saved);
+ final other = server.controller(initial: saved, account: 'other');
+ addTearDown(restored.dispose);
+ addTearDown(other.dispose);
+ await restored.refresh();
+ await other.refresh();
+ expect(restored.unread(restored.selected!), isFalse);
+ expect(other.unread(other.selected!), isTrue);
+ restored.revokeAccess('Removed');
+ restored.markRead('lead', through: 99);
+ await restored.flush();
+ expect(server.saved!['readAt'], {'lead': 1});
+ });
+
test(
'a lost send reply reuses its durable receipt after closing and reopening',
() async {
diff --git a/desktop/test/super_tab_machines_test.dart b/desktop/test/super_tab_machines_test.dart
index af7c8fa54..1e412176c 100644
--- a/desktop/test/super_tab_machines_test.dart
+++ b/desktop/test/super_tab_machines_test.dart
@@ -1,17 +1,21 @@
+import 'dart:io';
import 'dart:ui' show PointerDeviceKind;
import 'package:flutter/material.dart';
+import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:harness/core/models.dart';
import 'package:harness/state/app_state.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/shared/theme/app_theme.dart' as grid;
import 'package:harness/widgets/engine_identity.dart';
import 'super_tab_launch_test.dart' show SuperTabLaunchFixture, tabId;
+import 'support/capture.dart';
import 'support/super_tab_fixture.dart';
Future<void> _openAddMachineDialog(
@@ -54,6 +58,8 @@ final _picker = find.byKey(const ValueKey('swarm-machine-picker'));
Finder _option(String id) => find.byKey(ValueKey('swarm-machine-option-$id'));
void main() {
+ final capture = Platform.environment['HARNESS_SUPER_TAB_CAPTURE'];
+ setUpAll(() => loadCaptureFonts(capture));
test(
'generated computer names are readable and custom names stay intact',
() {
@@ -77,7 +83,7 @@ void main() {
},
);
testWidgets(
- 'offline machines have one row and only available readings are shown',
+ 'machine rows show known capacity and allowances while stale readings stay hidden',
(tester) async {
await tester.binding.setSurfaceSize(const Size(280, 700));
addTearDown(() => tester.binding.setSurfaceSize(null));
@@ -122,9 +128,9 @@ void main() {
),
);
await tester.pumpAndSettle();
- final offline = find.byKey(const ValueKey('super-machine-row-offline'));
+ final offline = find.byKey(const ValueKey('super-machine-offline'));
expect(
- find.descendant(of: offline, matching: find.text('Offline')),
+ find.descendant(of: offline, matching: find.byTooltip('Offline')),
findsOneWidget,
);
expect(
@@ -135,21 +141,57 @@ void main() {
find.descendant(of: offline, matching: find.textContaining('CPU')),
findsNothing,
);
- expect(tester.getSize(offline).height, lessThanOrEqualTo(40));
+ final online = find.byKey(const ValueKey('super-machine-online'));
+ expect(
+ tester.getSize(online).height,
+ greaterThan(tester.getSize(offline).height),
+ );
expect(find.text('CPU 100%'), findsOneWidget);
expect(find.text('RAM 0 GB'), findsOneWidget);
expect(find.text('SSD 141 GB'), findsOneWidget);
+ expect(find.byType(EngineMark), findsOneWidget);
+ // The entire row opens its details, including keyboard activation.
+ Focus.of(tester.element(find.text('Studio Mac'))).requestFocus();
+ await tester.pump();
+ await tester.sendKeyEvent(LogicalKeyboardKey.enter);
+ await tester.pumpAndSettle();
+ expect(find.text('Available capacity'), findsOneWidget);
+ expect(find.text('CPU'), findsOneWidget);
+ expect(
+ find.descendant(
+ of: find.byType(SuperTabMachineDetails),
+ matching: find.text('100%'),
+ ),
+ findsOneWidget,
+ );
+ expect(find.text('0 GB of 32 GB'), findsOneWidget);
+ expect(find.text('141 GB of 1000 GB'), findsOneWidget);
expect(find.textContaining('GPU'), findsNothing);
expect(find.text('—'), findsNothing);
- expect(find.text('100%'), findsOneWidget);
+ expect(find.text('100% left'), findsOneWidget);
expect(
- tester.widget<EngineMark>(find.byType(EngineMark)).engine,
+ tester
+ .widget<EngineMark>(
+ find.descendant(
+ of: find.byType(AlertDialog),
+ matching: find.byType(EngineMark),
+ ),
+ )
+ .engine,
'codex',
);
- // The complete identity and actions remain accessible from the compact row.
+ await tester.tap(find.text('Close'));
+ await tester.pumpAndSettle();
await tester.tap(find.byKey(const ValueKey('super-machine-offline')));
await tester.pumpAndSettle();
- expect(find.widgetWithText(AlertDialog, 'M2'), findsOneWidget);
+ expect(find.byType(AlertDialog), findsOneWidget);
+ expect(
+ (tester.widget<AlertDialog>(find.byType(AlertDialog)).title! as Text)
+ .data,
+ 'M2',
+ );
+ expect(find.text('Available capacity'), findsNothing);
+ expect(find.text('Model allowances'), findsNothing);
expect(tester.takeException(), isNull);
await tester.pumpWidget(const SizedBox());
await c.flush();
@@ -157,6 +199,281 @@ void main() {
},
);
+ for (final brightness in [Brightness.dark, Brightness.light]) {
+ for (final textScale in [1.0, 2.0]) {
+ for (final width in [280.0, 380.0]) {
+ testWidgets(
+ 'machine identity, full-row target and details fit ${brightness.name} ${textScale}x at $width',
+ (tester) async {
+ await tester.binding.setSurfaceSize(const Size(900, 850));
+ addTearDown(() => tester.binding.setSurfaceSize(null));
+ final previousBrightness = grid.AppTheme.brightness.value;
+ grid.AppTheme.brightness.value = brightness;
+ addTearDown(
+ () => grid.AppTheme.brightness.value = previousBrightness,
+ );
+ final server = ConversationServer();
+ server.state['people'] = [
+ {'id': 'owner', 'email': '[email protected]', 'role': 'owner'},
+ ];
+ server.state['agents'] = [
+ for (var i = 0; i < 8; i++)
+ {
+ 'id': 'agent-$i',
+ 'name': 'Harness $i',
+ 'displayName': i == 0 ? 'Atlas' : 'Engineer $i',
+ 'machineId': 'm',
+ 'harnessId': 'native-$i',
+ 'contributorId': 'owner',
+ 'configuration': {'engine': 'codex'},
+ },
+ ];
+ (server.state['conversations'] as List)[0]
+ ..['leadId'] = 'agent-0'
+ ..['agentIds'] = ['agent-0'];
+ server.state['machines'] = [
+ {
+ 'machineId': 'm',
+ 'name': 'M2',
+ 'contributorId': 'owner',
+ 'paused': true,
+ 'engines': ['claude', 'codex'],
+ 'cwd': '/work/a-very-long-project-folder-without-spaces/checked-out-project',
+ 'observation': {
+ 'receivedAt': DateTime.now().millisecondsSinceEpoch,
+ 'resources': {
+ 'deviceType': 'MacBook Pro',
+ 'chip': 'Apple M2 Max',
+ 'os': 'macOS',
+ 'cpuPercent': 27,
+ 'gpuPercent': 7,
+ 'memoryTotalBytes': 64000000000,
+ 'memoryUsedBytes': 36000000000,
+ 'diskTotalBytes': 1000000000000,
+ 'diskFreeBytes': 141000000000,
+ },
+ 'quotas': [
+ {'engine': 'claude', 'known': false, 'windows': []},
+ {
+ 'engine': 'codex',
+ 'known': true,
+ 'windows': [
+ {
+ 'name': '5-hour',
+ 'usedPercent': 30,
+ 'resetsAt': DateTime.now()
+ .add(const Duration(hours: 2))
+ .millisecondsSinceEpoch,
+ },
+ {
+ 'name': 'Weekly',
+ 'usedPercent': 10,
+ 'resetsAt': DateTime.now()
+ .add(const Duration(days: 3))
+ .millisecondsSinceEpoch,
+ },
+ ],
+ },
+ ],
+ },
+ },
+ ];
+ final c = server.controller();
+ await c.refresh();
+ final machineBoundary = GlobalKey();
+ await tester.pumpWidget(
+ MaterialApp(
+ debugShowCheckedModeBanner: false,
+ theme: grid.buildAppTheme(brightness: brightness),
+ builder: (context, child) => MediaQuery(
+ data: MediaQuery.of(context)
+ .copyWith(textScaler: TextScaler.linear(textScale)),
+ child: child!,
+ ),
+ home: Scaffold(
+ body: Align(
+ alignment: Alignment.topLeft,
+ child: RepaintBoundary(
+ key: machineBoundary,
+ child: Material(
+ color: grid.AppDesktop.surface,
+ child: SizedBox(
+ width: width,
+ child: SuperTabMachines(
+ controller: c,
+ embedded: true,
+ onAddAgent: (_) {},
+ ),
+ ),
+ ),
+ ),
+ ),
+ ),
+ ),
+ );
+ await tester.pumpAndSettle();
+ if (capture != null) {
+ // A frame can settle before asynchronous bitmap decoding has
+ // finished. Wait for the real asset before photographing it.
+ await tester.runAsync(
+ () => precacheImage(
+ AssetImage(engineIdentity('codex').asset!),
+ tester.element(find.byType(EngineMark).first),
+ ).timeout(const Duration(seconds: 10)),
+ );
+ await tester.pumpAndSettle();
+ }
+ final row = find.byKey(const ValueKey('super-machine-m'));
+ final header = find.byKey(const ValueKey('super-machine-header-m'));
+ final avatars = tester
+ .widgetList<SuperTabAvatar>(
+ find.descendant(
+ of: header,
+ matching: find.byType(SuperTabAvatar),
+ ),
+ )
+ .toList();
+ expect(avatars.first.identity, 'person:owner');
+ expect(avatars.first.name, 'dee');
+ expect(avatars[1].identity, 'agent:agent-0');
+ expect(avatars[1].name, 'Atlas');
+ expect(
+ find.byTooltip('[email protected]\nMachine owner'),
+ findsOneWidget,
+ );
+ expect(find.byTooltip('Atlas\nProduct Manager'), findsOneWidget);
+ expect(find.byTooltip('New work paused'), findsOneWidget);
+ expect(find.textContaining('agents'), findsNothing);
+ expect(find.text('dee'), findsNothing);
+ final hiddenAgents = 8 - (avatars.length - 1);
+ expect(
+ find.text('+$hiddenAgents'),
+ hiddenAgents == 0 ? findsNothing : findsOneWidget,
+ );
+ if (width == 280) expect(hiddenAgents, greaterThan(0));
+ for (final value in [
+ 'CPU 73%',
+ 'GPU 93%',
+ 'RAM 28 GB',
+ 'SSD 141 GB',
+ '70%',
+ ]) {
+ expect(find.text(value), findsOneWidget);
+ }
+ final rowRect = tester.getRect(row);
+ final ink = find.descendant(
+ of: row,
+ matching: find.byType(InkWell),
+ );
+ expect(tester.getRect(ink), rowRect);
+ expect(rowRect.width, width);
+ final headerRect = tester.getRect(header);
+ for (final avatar
+ in find
+ .descendant(
+ of: header,
+ matching: find.byType(SuperTabAvatar),
+ )
+ .evaluate()) {
+ final rect = tester.getRect(find.byWidget(avatar.widget));
+ expect(rect.center.dy, closeTo(headerRect.center.dy, .1));
+ expect(rect.right, lessThanOrEqualTo(rowRect.right - 16));
+ }
+ 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.
+ final mouse = await tester.createGesture(
+ kind: PointerDeviceKind.mouse,
+ );
+ await mouse.addPointer(
+ location: Offset(rowRect.right + 20, rowRect.center.dy),
+ );
+ await tester.pump();
+ await mouse.moveTo(Offset(rowRect.right - 2, rowRect.center.dy));
+ await tester.pumpAndSettle();
+ final captureName =
+ '${brightness.name}-${textScale}x-${width.toInt()}';
+ await captureBoundary(
+ tester,
+ machineBoundary.currentContext!.findRenderObject()!
+ as RenderRepaintBoundary,
+ capture,
+ 'machine-hover-$captureName',
+ );
+ await tester.tapAt(Offset(rowRect.right - 2, rowRect.center.dy));
+ await mouse.removePointer();
+ await tester.pumpAndSettle();
+ final dialog = find.byType(AlertDialog);
+ final details = find.byType(SuperTabMachineDetails);
+ expect(dialog, findsOneWidget);
+ expect(details, findsOneWidget);
+ expect(
+ find.descendant(
+ of: details,
+ matching: find.text('28 GB of 64 GB'),
+ ),
+ findsOneWidget,
+ );
+ expect(
+ find.descendant(
+ of: details,
+ matching: find.text('141 GB of 1000 GB'),
+ ),
+ findsOneWidget,
+ );
+ expect(
+ find.descendant(
+ of: details,
+ matching: find.textContaining(
+ '5-hour: 70% remaining\nResets in ',
+ ),
+ ),
+ findsOneWidget,
+ );
+ expect(
+ find.descendant(
+ of: details,
+ matching: find.textContaining(
+ 'Weekly: 90% remaining\nResets in ',
+ ),
+ ),
+ findsOneWidget,
+ );
+ expect(
+ find.descendant(of: details, matching: find.text('—')),
+ findsNothing,
+ );
+ expect(tester.takeException(), isNull);
+ await captureWindow(
+ tester,
+ capture,
+ 'machine-details-$captureName',
+ );
+ if (capture != null && textScale > 1) {
+ await Scrollable.ensureVisible(
+ tester.element(find.text('Model allowances')),
+ alignment: 0,
+ );
+ await tester.pumpAndSettle();
+ await captureWindow(
+ tester,
+ capture,
+ 'machine-details-more-$captureName',
+ );
+ }
+ await tester.tap(find.widgetWithText(TextButton, 'Close'));
+ await tester.pumpAndSettle();
+ expect(tester.takeException(), isNull);
+ await tester.pumpWidget(const SizedBox());
+ await c.flush();
+ c.dispose();
+ },
+ );
+ }
+ }
+ }
+
test('shared repository metadata excludes embedded credentials', () {
expect(
superTabRepositoryUrl('https://[email protected]/example/project'),
@@ -604,7 +921,7 @@ void main() {
);
}
- testWidgets('A machine card omits unknown subscription allowances', (
+ testWidgets('Machine details omit unknown subscription allowances', (
tester,
) async {
final f = SuperTabLaunchFixture();
@@ -646,6 +963,10 @@ void main() {
),
);
await tester.pumpAndSettle();
+ expect(find.byType(EngineMark), findsOneWidget);
+ expect(tester.widget<EngineMark>(find.byType(EngineMark)).engine, 'claude');
+ await tester.tap(find.byKey(const ValueKey('super-machine-m')));
+ await tester.pumpAndSettle();
expect(
tester
.widgetList<EngineMark>(find.byType(EngineMark))
diff --git a/desktop/test/super_tab_pane_layout_test.dart b/desktop/test/super_tab_pane_layout_test.dart
new file mode 100644
index 000000000..bd38056e1
--- /dev/null
+++ b/desktop/test/super_tab_pane_layout_test.dart
@@ -0,0 +1,174 @@
+import 'dart:async';
+import 'dart:convert';
+
+import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:harness/shared/theme/app_theme.dart' as grid;
+import 'package:harness/super_tabs/pane_layout.dart';
+import 'package:harness/widgets/pane_resize_handle.dart';
+
+import 'swarm_state_test.dart' show MemoryStore;
+
+class _SlowStore extends MemoryStore {
+ final readResult = Completer<String?>();
+ @override
+ Future<String?> read(String key) => readResult.future;
+}
+
+void main() {
+ final left = find.byKey(const ValueKey('super-left-pane'));
+ final center = find.byKey(const ValueKey('super-center-pane'));
+ final right = find.byKey(const ValueKey('super-right-pane'));
+ final leftHandle = find.byKey(const ValueKey('super-resize-left'));
+ final rightHandle = find.byKey(const ValueKey('super-resize-right'));
+
+ Future<void> mount(
+ WidgetTester tester,
+ MemoryStore store, {
+ bool sides = true,
+ double scale = 1,
+ }) async {
+ 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: SuperTabPaneLayout(
+ storage: store,
+ onLeave: () {},
+ left: sides ? const ColoredBox(color: Colors.black) : null,
+ right: sides ? const ColoredBox(color: Colors.black) : null,
+ center: const TextField(key: ValueKey('draft')),
+ ),
+ ),
+ ),
+ );
+ await tester.pumpAndSettle();
+ }
+
+ testWidgets(
+ 'both dividers resize and persist without replacing the conversation',
+ (tester) async {
+ await tester.binding.setSurfaceSize(const Size(1400, 800));
+ addTearDown(() => tester.binding.setSurfaceSize(null));
+ final store = MemoryStore();
+ await mount(tester, store);
+ expect(tester.getSize(left).width, 220);
+ expect(tester.getSize(right).width, 380);
+ 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(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.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));
+
+ // Responsive overlays do not forget the preferred sizes or edit state.
+ await mount(tester, store, sides: false);
+ expect(find.byType(PaneResizeHandle), findsNothing);
+ expect(
+ tester.state<EditableTextState>(find.byType(EditableText)),
+ same(editor),
+ );
+ await mount(tester, store);
+ expect(tester.getSize(left).width, closeTo(320, 1));
+ expect(tester.getSize(right).width, closeTo(440, 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.takeException(), isNull);
+ },
+ );
+
+ testWidgets(
+ 'resize limits protect all panes, support keys and survive a smaller window',
+ (tester) async {
+ await tester.binding.setSurfaceSize(const Size(1400, 800));
+ addTearDown(() => tester.binding.setSurfaceSize(null));
+ final store = MemoryStore();
+ await mount(tester, store);
+ await tester.drag(leftHandle, const Offset(-1000, 0));
+ await tester.pumpAndSettle();
+ expect(tester.getSize(left).width, closeTo(180, 1));
+ await tester.drag(rightHandle, const Offset(1000, 0));
+ await tester.pumpAndSettle();
+ expect(tester.getSize(right).width, closeTo(280, 1));
+ await tester.drag(leftHandle, const Offset(1000, 0));
+ await tester.pumpAndSettle();
+ expect(tester.getSize(center).width, closeTo(360, 1));
+ final preferred = tester.getSize(left).width;
+ await tester.binding.setSurfaceSize(const Size(1080, 800));
+ await tester.pumpAndSettle();
+ expect(tester.getSize(center).width, greaterThanOrEqualTo(360));
+ expect(tester.getSize(right).width, greaterThanOrEqualTo(280));
+ await tester.binding.setSurfaceSize(const Size(1400, 800));
+ await tester.pumpAndSettle();
+ expect(tester.getSize(left).width, preferred);
+
+ final focus = tester
+ .widget<Focus>(
+ find.descendant(of: leftHandle, matching: find.byType(Focus)),
+ )
+ .focusNode!;
+ focus.requestFocus();
+ await tester.pump();
+ await tester.sendKeyEvent(LogicalKeyboardKey.arrowLeft);
+ await tester.pumpAndSettle();
+ expect(tester.getSize(left).width, closeTo(preferred - 28, 1));
+ await tester.tap(leftHandle);
+ await tester.pump(const Duration(milliseconds: 70));
+ await tester.tap(leftHandle);
+ await tester.pumpAndSettle();
+ expect(
+ tester.getSize(left).width,
+ closeTo(tester.getSize(center).width, 1),
+ );
+ expect(tester.takeException(), isNull);
+ },
+ );
+
+ testWidgets('a late saved preference cannot undo a resize', (tester) async {
+ await tester.binding.setSurfaceSize(const Size(1400, 800));
+ addTearDown(() => tester.binding.setSurfaceSize(null));
+ final store = _SlowStore();
+ await mount(tester, store);
+ await tester.drag(rightHandle, const Offset(-60, 0));
+ await tester.pumpAndSettle();
+ store.readResult.complete('{"left":200,"right":300}');
+ await tester.pumpAndSettle();
+ expect(tester.getSize(right).width, closeTo(440, 1));
+ });
+
+ testWidgets('large text and invalid saved sizes retain usable panes', (
+ tester,
+ ) async {
+ await tester.binding.setSurfaceSize(const Size(2400, 900));
+ addTearDown(() => tester.binding.setSurfaceSize(null));
+ final store = MemoryStore()
+ ..values[SuperTabPaneLayout.storageKey] = '{"left":-2,"right":"bad"}';
+ await mount(tester, store, scale: 2);
+ expect(tester.getSize(left).width, 360);
+ expect(tester.getSize(right).width, 560);
+ expect(tester.getSize(center).width, greaterThanOrEqualTo(720));
+ expect(tester.takeException(), isNull);
+ });
+}
diff --git a/desktop/test/super_tab_polish_test.dart b/desktop/test/super_tab_polish_test.dart
index c9fa000d9..b46be3dd3 100644
--- a/desktop/test/super_tab_polish_test.dart
+++ b/desktop/test/super_tab_polish_test.dart
@@ -132,7 +132,6 @@ ConversationServer polishFixture() {
'kind': 'agent',
'id': 'lead-agent',
'name': 'Lead',
- 'displayName': 'Atlas',
};
}
diff --git a/desktop/test/super_tab_sidebar_test.dart b/desktop/test/super_tab_sidebar_test.dart
index c9c8709ae..3252c9f42 100644
--- a/desktop/test/super_tab_sidebar_test.dart
+++ b/desktop/test/super_tab_sidebar_test.dart
@@ -109,20 +109,27 @@ void main() {
expect(c.selectedId, 'offline');
await tester.tap(empty);
await tester.pumpAndSettle();
- expect(c.selectedId, 'empty-lead');
- expect(c.expandedProjects, isNot(contains('empty')));
+ expect(c.selectedId, 'offline');
+ expect(c.expandedProjects, contains('empty'));
+ expect(inside(find.text('No workgroups yet')), findsOneWidget);
expect(
- find.byTooltip('Chat with sample-project product manager'),
- findsOneWidget,
+ tester.getTopLeft(inside(find.text('No workgroups yet'))).dx,
+ projectX,
);
+ expect(find.byTooltip('Collapse sample-project'), findsOneWidget);
expect(
find.descendant(
of: empty,
- matching: find.byIcon(AppIcons.chevronRight),
+ matching: find.byIcon(AppIcons.chevronDown),
),
findsOneWidget,
);
+ await tester.tap(empty);
+ await tester.pumpAndSettle();
+ expect(inside(find.text('No workgroups yet')), findsNothing);
+ expect(c.selectedId, 'offline');
+
// Both navigation actions retain keyboard activation.
final newProject = find.byKey(const ValueKey('super-new-project'));
Focus.of(
@@ -136,8 +143,16 @@ void main() {
expect(created, 1);
await tester.tap(find.byKey(const ValueKey('super-your-devices')));
await tester.pumpAndSettle();
- expect(app.machinesRequest, (devicePub: null, phones: false));
- expect(c.selectedId, 'empty-lead');
+ 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();
diff --git a/desktop/test/super_tab_workspace_test.dart b/desktop/test/super_tab_workspace_test.dart
index 4338bcad4..9879676f6 100644
--- a/desktop/test/super_tab_workspace_test.dart
+++ b/desktop/test/super_tab_workspace_test.dart
@@ -229,6 +229,10 @@ void main() {
);
await tester.tap(find.byKey(const ValueKey('super-agent-group-lead')));
await tester.pumpAndSettle();
+ expect(c.selectedId, 'offline');
+ expect(f.app.activeSwarm.panes, hasLength(4));
+ await tester.tap(find.byKey(const ValueKey('super-agent-group-open')));
+ await tester.pumpAndSettle();
expect(c.selectedId, 'lead');
expect(f.app.activeSwarm.panes.single.agentId, 'native-b');
expect(f.connection.calls.where((c) => c.$1 == 'agent_create'), isEmpty);
diff --git a/docs/naming-system.md b/docs/naming-system.md
index b81e05829..021fbeec7 100644
--- a/docs/naming-system.md
+++ b/docs/naming-system.md
@@ -85,8 +85,14 @@ A pane is a view, so closing a pane or tab closes views. **Stop Harness** ends t
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.
Agents have individual display names and the same avatar treatment as people. Their role badges
are **PM** and **Dev**; project context appears underneath. 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 reuse the owner's and agents' avatars, keep known capacity and allowances visible,
+and open labeled details. Offline machines omit stale readings.
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