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.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
Desktop: an expanded machine shows its agents as one count, with the list a tap away (#1824)
0xken15b312f466a14e
diff --git a/desktop/lib/super_tabs/machines.dart b/desktop/lib/super_tabs/machines.dartindex 67484fa1c..52dd2a09b 100644--- a/desktop/lib/super_tabs/machines.dart+++ b/desktop/lib/super_tabs/machines.dart@@ -1626,7 +1626,7 @@ class _SuperTabMachinesState extends State<SuperTabMachines> {),),if (expanded) ...[- for (final agent in view.agents) _agent(view, agent),+ if (view.agents.isNotEmpty) _agentCount(view),_MachineReadings(view: view),if (view.agents.isEmpty)Padding(@@ -1682,9 +1682,128 @@ class _SuperTabMachinesState extends State<SuperTabMachines> {return native ?? HarnessActivity.unknown;}- Widget _agent(_MachineView view, SuperTabAgent agent) {+ /// One line for all of [view]'s agents, however many: a busy machine is not a+ /// screen of rows. The list opens over the sidebar, grouped by what each is doing.+ Widget _agentCount(_MachineView view) {+ final count = view.agents.length;+ final label = count == 1 ? '1 agent' : '$count agents';+ return LayoutBuilder(+ builder: (context, constraints) {+ final width = constraints.maxWidth.clamp(240.0, 320.0);+ return MenuAnchor(+ consumeOutsideTap: true,+ alignmentOffset: const Offset(0, grid.AppControl.menuGap),+ style: grid.AppMenu.style(minWidth: width, maxWidth: width),+ menuChildren: [+ KeyedSubtree(+ key: ValueKey('super-machine-agent-list-${view.id}'),+ child: SizedBox(+ width: width,+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.stretch,+ mainAxisSize: MainAxisSize.min,+ children: _agentGroups(view),+ ),+ ),+ ),+ ],+ builder: (context, menu, _) => Material(+ color: Colors.transparent,+ borderRadius: BorderRadius.circular(DesktopChrome.rowRadius),+ clipBehavior: Clip.antiAlias,+ child: InkWell(+ key: ValueKey('super-machine-agents-${view.id}'),+ borderRadius: BorderRadius.circular(DesktopChrome.rowRadius),+ hoverColor: grid.AppSurface.hoverFill,+ focusColor: grid.AppSurface.hoverFill,+ onTap: () => menu.isOpen ? menu.close() : menu.open(),+ child: Semantics(+ button: true,+ expanded: menu.isOpen,+ label: label,+ hint: 'Shows this machine’s agents',+ excludeSemantics: true,+ child: ConstrainedBox(+ constraints: const BoxConstraints(minHeight: 32),+ child: Padding(+ padding: const EdgeInsets.fromLTRB(36, 6, 10, 6),+ child: Row(+ children: [+ Expanded(+ child: Text(+ label,+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: DesktopChrome.control(),+ ),+ ),+ Icon(+ AppIcons.chevronRight,+ size: grid.AppControl.iconSize,+ color: DesktopChrome.muted,+ ),+ ],+ ),+ ),+ ),+ ),+ ),+ ),+ );+ },+ );+ }++ /// [view]'s agents under Working, Waiting and Idle, each by name; a group with none is left out.+ List<Widget> _agentGroups(_MachineView view) {+ final groups = <String, List<(SuperTabAgent, HarnessActivity)>>{+ 'Working': [],+ 'Waiting': [],+ 'Idle': [],+ };+ for (final agent in view.agents) {+ final activity = _activity(view, agent);+ groups[switch (activity) {+ HarnessActivity.working || HarnessActivity.starting => 'Working',+ HarnessActivity.needsInput || HarnessActivity.failed => 'Waiting',+ _ => 'Idle',+ }]!+ .add((agent, activity));+ }+ final snapshot = c.snapshot!;+ return [+ for (final MapEntry(key: title, value: members) in groups.entries)+ if (members.isNotEmpty) ...[+ Padding(+ padding: const EdgeInsets.fromLTRB(12, 8, 12, 4),+ child: Text(+ title,+ style: DesktopChrome.text(+ size: 11,+ medium: true,+ height: 1.3,+ color: DesktopChrome.muted,+ ).copyWith(fontWeight: FontWeight.w600),+ ),+ ),+ for (final (agent, activity)+ in members..sort(+ (a, b) => snapshot+ .agentName(a.$1.id)+ .toLowerCase()+ .compareTo(snapshot.agentName(b.$1.id).toLowerCase()),+ ))+ _agent(view, agent, activity),+ ],+ ];+ }++ Widget _agent(+ _MachineView view,+ SuperTabAgent agent,+ HarnessActivity activity,+ ) {final name = c.snapshot!.agentName(agent.id);- final activity = _activity(view, agent);final lead = c.snapshot!.isLead(agent.id);final customRole = c.snapshot!.activeRoleForAgent(agent);final role =@@ -1712,87 +1831,75 @@ class _SuperTabMachinesState extends State<SuperTabMachines> {color: Colors.transparent,borderRadius: BorderRadius.circular(DesktopChrome.rowRadius),clipBehavior: Clip.antiAlias,- child: InkWell(- key: ValueKey('super-machine-agent-${view.id}-${agent.id}'),- borderRadius: BorderRadius.circular(DesktopChrome.rowRadius),- hoverColor: grid.AppSurface.hoverFill,- focusColor: grid.AppSurface.hoverFill,- onTap: widget.onOpenAgent == null- ? null- : () {- final current = c.snapshot?.agent(agent.id);- if (current != null) widget.onOpenAgent!(current);- },- child: ConstrainedBox(- constraints: const BoxConstraints(minHeight: 36),- child: Padding(- padding: const EdgeInsets.symmetric(vertical: 6),- child: Row(- children: [- const SizedBox(width: 4),- SizedBox(- width: 32,- child: Center(- child: SuperTabAvatar.agent(agent, name: name, size: 22),- ),- ),- Expanded(- child: LayoutBuilder(- builder: (context, constraints) {- final label = Text(- name,- maxLines: 1,- overflow: TextOverflow.ellipsis,- style: DesktopChrome.control(),- );- final roleBadge = Semantics(- label: role,- excludeSemantics: true,- child: Container(- padding: const EdgeInsets.symmetric(- horizontal: 5,- vertical: 1,+ child: Builder(+ builder: (context) => InkWell(+ key: ValueKey('super-machine-agent-${view.id}-${agent.id}'),+ borderRadius: BorderRadius.circular(DesktopChrome.rowRadius),+ hoverColor: grid.AppSurface.hoverFill,+ focusColor: grid.AppSurface.hoverFill,+ onTap: widget.onOpenAgent == null+ ? null+ : () {+ MenuController.maybeOf(context)?.close();+ final current = c.snapshot?.agent(agent.id);+ if (current != null) widget.onOpenAgent!(current);+ },+ child: ConstrainedBox(+ constraints: const BoxConstraints(minHeight: 36),+ child: Padding(+ padding: const EdgeInsets.symmetric(vertical: 6),+ child: Row(+ children: [+ const SizedBox(width: 12),+ Expanded(+ child: Row(+ children: [+ Flexible(+ child: Text(+ name,+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: DesktopChrome.control(),),- decoration: BoxDecoration(- color: grid.AppSurface.hoverFill,- borderRadius: BorderRadius.circular(4),+ ),+ const SizedBox(width: 6),+ Semantics(+ label: role,+ excludeSemantics: true,+ child: Container(+ padding: const EdgeInsets.symmetric(+ horizontal: 5,+ vertical: 1,+ ),+ decoration: BoxDecoration(+ color: grid.AppSurface.hoverFill,+ borderRadius: BorderRadius.circular(4),+ ),+ child: Text(+ badge,+ style: DesktopChrome.metadata(),+ ),),- child: Text(badge, style: DesktopChrome.metadata()),),- );- if (constraints.maxWidth <- MediaQuery.textScalerOf(context).scale(100)) {- return Column(- crossAxisAlignment: CrossAxisAlignment.start,- mainAxisSize: MainAxisSize.min,- children: [label, roleBadge],- );- }- return Row(- children: [- Flexible(child: label),- const SizedBox(width: 6),- roleBadge,- ],- );- },+ ],+ ),),- ),- SizedBox(- width: 32,- child: Center(- child: ActivityMark(- activity: activity,- color: activityColor(- activity,- theme,- color: appearancePrefsStore.value.prompt.color,+ SizedBox(+ width: 32,+ child: Center(+ child: ActivityMark(+ activity: activity,+ color: activityColor(+ activity,+ theme,+ color: appearancePrefsStore.value.prompt.color,+ ),),),),- ),- const SizedBox(width: 32),- ],+ const SizedBox(width: 4),+ ],+ ),),),),diff --git a/desktop/test/super_tab_machines_test.dart b/desktop/test/super_tab_machines_test.dartindex 774807679..c134b4a47 100644--- a/desktop/test/super_tab_machines_test.dart+++ b/desktop/test/super_tab_machines_test.dart@@ -491,6 +491,248 @@ void main() {},);+ group('an expanded machine shows its agents as one count', () {+ Future<dynamic> mount(WidgetTester tester, int agents) async {+ final server = ConversationServer();+ server.state['agents'] = [+ for (var i = 0; i < agents; i++)+ {+ 'id': 'a$i',+ 'name': 'Agent $i',+ 'displayName': 'Agent $i',+ 'machineId': 'm',+ 'harnessId': 'native-a$i',+ 'contributorId': 'owner',+ 'configuration': {'engine': 'codex'},+ },+ ];+ server.state['machines'] = [+ {+ 'machineId': 'm',+ 'name': 'Studio Mac',+ 'contributorId': 'owner',+ 'observation': {+ 'receivedAt': DateTime.now().millisecondsSinceEpoch,+ 'resources': {'cpuPercent': 12},+ },+ },+ ];+ final c = server.controller();+ await c.refresh();+ c.toggleMachineExpanded('m');+ await tester.pumpWidget(+ MaterialApp(+ home: Scaffold(+ body: SuperTabMachines(controller: c, onAddAgent: (_) {}),+ ),+ ),+ );+ await tester.pumpAndSettle();+ return c;+ }++ Future<void> unmount(WidgetTester tester, dynamic c) async {+ await tester.pumpWidget(const SizedBox());+ await c.flush();+ c.dispose();+ }++ final line = find.byKey(const ValueKey('super-machine-agents-m'));+ final entry = find.byKey(const ValueKey('super-machine-entry-m'));+ // The machine row keeps its owner's avatar; no agent has one here.+ final agentAvatar = find.byWidgetPredicate(+ (w) => w is SuperTabAvatar && w.identity.startsWith('agent:'),+ );++ testWidgets('none: no count line, and the machine says it has none', (+ tester,+ ) async {+ final c = await mount(tester, 0);+ expect(line, findsNothing);+ expect(find.text('No agents yet'), findsOneWidget);+ expect(+ find.byKey(const ValueKey('super-machine-readings-m')),+ findsOneWidget,+ );+ await unmount(tester, c);+ });++ testWidgets('one: "1 agent" with a chevron, no avatar and no agent row', (+ tester,+ ) async {+ final c = await mount(tester, 1);+ expect(+ find.descendant(of: line, matching: find.text('1 agent')),+ findsOneWidget,+ );+ expect(+ find.descendant(of: line, matching: find.byIcon(AppIcons.chevronRight)),+ findsOneWidget,+ );+ expect(find.descendant(of: entry, matching: agentAvatar), findsNothing);+ expect(find.text('Agent 0'), findsNothing);+ expect(find.text('No agents yet'), findsNothing);+ expect(+ find.byKey(const ValueKey('super-machine-readings-m')),+ findsOneWidget,+ );+ await unmount(tester, c);+ });++ testWidgets('twenty: one "20 agents" line, not twenty rows', (+ tester,+ ) async {+ final c = await mount(tester, 20);+ expect(line, findsOneWidget);+ expect(+ find.descendant(of: line, matching: find.text('20 agents')),+ findsOneWidget,+ );+ for (var i = 0; i < 20; i++) {+ expect(find.byKey(ValueKey('super-machine-agent-m-a$i')), findsNothing);+ }+ expect(find.descendant(of: entry, matching: agentAvatar), findsNothing);+ await unmount(tester, c);+ });++ testWidgets('twenty: the list scrolls to the last agent', (tester) async {+ final c = await mount(tester, 20);+ await tester.tap(line);+ await tester.pumpAndSettle();+ final last = find.byKey(const ValueKey('super-machine-agent-m-a19'));+ await tester.ensureVisible(last);+ await tester.pumpAndSettle();+ expect(last.hitTestable(), findsOneWidget);+ await unmount(tester, c);+ });++ testWidgets(+ 'tapping the line lists every agent, Working, Waiting, then Idle, with name, role and status',+ (tester) async {+ final f = SuperTabLaunchFixture();+ f.app.bindSuperTab(f.app.activeSwarmId, tabId, 'Pilot');+ final server = f.connection.server;+ Map<String, dynamic> agent(String id, String name) => {+ 'id': id,+ 'name': name,+ 'displayName': name,+ 'machineId': 'm',+ 'harnessId': 'native-$id',+ 'contributorId': 'owner',+ 'configuration': {'engine': 'codex'},+ };+ server.state['agents'] = [+ agent('pm', 'Quinn'),+ agent('dev', 'Nova'),+ agent('rev', 'Sage'),+ agent('idle', 'Iris'),+ ];+ (server.state['agents'] as List)[2]['role'] = 'reviewer';+ (server.state['conversations'] as List)[0]+ ..['leadId'] = 'pm'+ ..['agentIds'] = ['pm', 'dev', 'rev', 'idle']+ ..['assignment'] = {'agentId': 'rev', 'status': 'needs_human'};+ f.app.machineStates['m']!+ ..agents = [+ for (final id in ['pm', 'dev', 'rev', 'idle'])+ Agent.fromJson({+ 'id': 'native-$id',+ 'name': id,+ 'engine': 'codex',+ }),+ ]+ ..processingAgentIds.addAll(['native-pm', 'native-dev']);+ final c = await f.app.superTabs.open(tabId);+ await c.refresh();+ c.toggleMachineExpanded('m');+ final opened = <String>[];+ await tester.pumpWidget(+ MaterialApp(+ home: Scaffold(+ body: SuperTabMachines(+ controller: c,+ app: f.app,+ onAddAgent: (_) {},+ onOpenAgent: (agent) => opened.add(agent.id),+ ),+ ),+ ),+ );+ await tester.pump();+ expect(+ find.descendant(of: line, matching: find.text('4 agents')),+ findsOneWidget,+ );+ expect(find.text('Nova'), findsNothing);++ await tester.tap(line);+ await tester.pump();+ await tester.pump();+ final list = find.byKey(const ValueKey('super-machine-agent-list-m'));+ expect(list, findsOneWidget);+ double top(Finder finder) => tester.getTopLeft(finder).dy;+ final headings = [+ for (final group in ['Working', 'Waiting', 'Idle'])+ find.descendant(of: list, matching: find.text(group)),+ ];+ for (final heading in headings) {+ expect(heading, findsOneWidget);+ }+ Finder row(String id) =>+ find.byKey(ValueKey('super-machine-agent-m-$id'));+ // Working: Nova and Quinn, by name; Waiting: Sage; Idle: Iris.+ final order = [+ headings[0],+ row('dev'),+ row('pm'),+ headings[1],+ row('rev'),+ headings[2],+ row('idle'),+ ];+ for (var i = 1; i < order.length; i++) {+ expect(top(order[i]), greaterThan(top(order[i - 1])));+ }+ for (final (id, name, badge, activity) in [+ ('pm', 'Quinn', 'PM', HarnessActivity.working),+ ('dev', 'Nova', 'Dev', HarnessActivity.working),+ ('rev', 'Sage', 'Rev', HarnessActivity.needsInput),+ ('idle', 'Iris', 'Dev', HarnessActivity.idle),+ ]) {+ expect(+ find.descendant(of: row(id), matching: find.text(name)),+ findsOneWidget,+ );+ expect(+ find.descendant(of: row(id), matching: find.text(badge)),+ findsOneWidget,+ );+ expect(+ tester+ .widget<ActivityMark>(+ find.descendant(+ of: row(id),+ matching: find.byType(ActivityMark),+ ),+ )+ .activity,+ activity,+ );+ }+ expect(find.descendant(of: list, matching: agentAvatar), findsNothing);++ await tester.tap(row('rev'));+ await tester.pump();+ await tester.pump();+ expect(opened, ['rev']);+ expect(list, findsNothing);+ await tester.pumpWidget(const SizedBox());+ await c.flush();+ f.app.superTabs.dispose();+ },+ );+ });+testWidgets('expanded agents keep roster identities, roles and lifecycle status and open the selected agent',(tester) async {@@ -540,6 +782,9 @@ void main() {expect(find.text('Quinn'), findsNothing);await tester.tap(find.byKey(const ValueKey('super-machine-m')));await tester.pumpAndSettle();+ final count = find.byKey(const ValueKey('super-machine-agents-m'));+ await tester.tap(count);+ await tester.pumpAndSettle();final pm = find.byKey(const ValueKey('super-machine-agent-m-pm'));final dev = find.byKey(const ValueKey('super-machine-agent-m-dev'));expect(@@ -555,8 +800,18 @@ void main() {...projectFixture('lead', 'Pilot', 'lead'),'skillSet': 'custom','roles': [- {'id': 'lead', 'name': 'Product Manager', 'kind': 'lead', 'version': 'v1'},- {'id': 'research', 'name': 'Research Engineer', 'kind': 'builder', 'version': 'v1'},+ {+ 'id': 'lead',+ 'name': 'Product Manager',+ 'kind': 'lead',+ 'version': 'v1',+ },+ {+ 'id': 'research',+ 'name': 'Research Engineer',+ 'kind': 'builder',+ 'version': 'v1',+ },],},];@@ -568,14 +823,6 @@ void main() {find.descendant(of: dev, matching: find.text('Research Engineer')),findsOneWidget,);- expect(- tester- .widget<SuperTabAvatar>(- find.descendant(of: dev, matching: find.byType(SuperTabAvatar)),- )- .identity,- 'agent:dev',- );expect(tester.widget<ActivityMark>(@@ -593,6 +840,8 @@ void main() {await c.refresh();await show();await tester.pumpAndSettle();+ await tester.tap(count);+ await tester.pumpAndSettle();expect(tester.widget<ActivityMark>(@@ -648,6 +897,9 @@ void main() {),);await tester.pump();+ await tester.tap(find.byKey(const ValueKey('super-machine-agents-m')));+ await tester.pump();+ await tester.pump();final row = find.byKey(const ValueKey('super-machine-agent-m-dev'));expect(testerdiff --git a/desktop/test/super_tab_team_machine_test.dart b/desktop/test/super_tab_team_machine_test.dartindex a84fb1464..4de30314b 100644--- a/desktop/test/super_tab_team_machine_test.dart+++ b/desktop/test/super_tab_team_machine_test.dart@@ -108,6 +108,13 @@ void main() {expect(find.text('MacBook Pro · Team'), findsNothing);await tester.tap(find.byKey(const ValueKey('super-machine-mac')));await tester.pumpAndSettle();+ final count = find.byKey(const ValueKey('super-machine-agents-mac'));+ expect(+ find.descendant(of: count, matching: find.text('2 agents')),+ findsOneWidget,+ );+ await tester.tap(count);+ await tester.pumpAndSettle();expect(find.byKey(const ValueKey('super-machine-agent-mac-a1')),findsOneWidget,@@ -147,6 +154,13 @@ void main() {expect(c.snapshot!.teamPoolOf('mac')!['machineId'], 'mac-team-new');await tester.tap(find.byKey(const ValueKey('super-machine-mac')));await tester.pumpAndSettle();+ final count = find.byKey(const ValueKey('super-machine-agents-mac'));+ expect(+ find.descendant(of: count, matching: find.text('2 agents')),+ findsOneWidget,+ );+ await tester.tap(count);+ await tester.pumpAndSettle();for (final agent in ['a1', 'a2']) {expect(find.byKey(ValueKey('super-machine-agent-mac-$agent')),