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: a task with no agent no longer breaks the Tasks pane (#3461)
0xken153babaac6855e
diff --git a/desktop/lib/super_tabs/tasks/personal_tasks.dart b/desktop/lib/super_tabs/tasks/personal_tasks.dartindex 11b13adf6..29951e74b 100644--- a/desktop/lib/super_tabs/tasks/personal_tasks.dart+++ b/desktop/lib/super_tabs/tasks/personal_tasks.dart@@ -14,7 +14,12 @@ class SuperTabPersonalTask {bool get suggested => json['suggested'] == true;bool get canApprove => json['canApprove'] == true;String? get reason => json['reason'] as String?;- Map<String, dynamic> get agent => superTabMap(json['agent']);++ /// A task nobody works on yet is sent with `agent: null`: no agent, not a+ /// malformed reply (building its row threw, and a release build drew the+ /// error as a grey box over the rest of the list).+ Map<String, dynamic> get agent =>+ json['agent'] == null ? const {} : superTabMap(json['agent']);String? get agentId => agent['id'] as String?;}diff --git a/desktop/lib/super_tabs/tasks/personal_tasks_pane.dart b/desktop/lib/super_tabs/tasks/personal_tasks_pane.dartindex 7ddd19119..2d5b82b13 100644--- a/desktop/lib/super_tabs/tasks/personal_tasks_pane.dart+++ b/desktop/lib/super_tabs/tasks/personal_tasks_pane.dart@@ -149,298 +149,322 @@ class _TasksPaneState extends State<SuperTabPersonalTasksPane> {final projects = {for (final p in snapshot?.projects ?? <SuperTabProject>[]) p.id: p,};- return Material(+ // One filled box as large as the slot, under a see-through Material that+ // only carries the rows' ink: a Material's own surface was drawn only as+ // far as the rows, and the window's backing showed below them.+ return ColoredBox(color: Theme.of(context).colorScheme.surface,- child: Column(- crossAxisAlignment: CrossAxisAlignment.stretch,- children: [- Padding(- padding: const EdgeInsets.symmetric(- horizontal: AppDesktop.groupGap,- vertical: AppDesktop.controlGap,- ),- child: Row(- children: [- const Expanded(- child: Text(- 'Tasks',- style: TextStyle(fontWeight: FontWeight.w600),- ),+ child: SizedBox.expand(+ child: Material(+ type: MaterialType.transparency,+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.stretch,+ children: [+ Padding(+ padding: const EdgeInsets.symmetric(+ horizontal: AppDesktop.groupGap,+ vertical: AppDesktop.controlGap,),- if (supported)- DropdownButtonHideUnderline(- child: DropdownButton<String>(- key: const ValueKey('tasks-approval-mode'),- value: tasks!.mode,- style: Theme.of(context).textTheme.bodySmall,- items: const [- DropdownMenuItem(- value: 'autoApprove',- child: Text('Auto approve'),- ),- DropdownMenuItem(- value: 'review',- child: Text('Review'),- ),- ],- onChanged: enabled- ? (value) {- if (value != null) {- unawaited(- _send({- 'type': 'member.approvalMode',- 'mode': value,- }),- );- }- }- : null,+ child: Row(+ children: [+ const Expanded(+ child: Text(+ 'Tasks',+ style: TextStyle(fontWeight: FontWeight.w600),+ ),),- ),- ],- ),- ),- if (_error != null)- Padding(- padding: const EdgeInsets.symmetric(- horizontal: AppDesktop.groupGap,+ if (supported)+ DropdownButtonHideUnderline(+ child: DropdownButton<String>(+ key: const ValueKey('tasks-approval-mode'),+ value: tasks!.mode,+ style: Theme.of(context).textTheme.bodySmall,+ items: const [+ DropdownMenuItem(+ value: 'autoApprove',+ child: Text('Auto approve'),+ ),+ DropdownMenuItem(+ value: 'review',+ child: Text('Review'),+ ),+ ],+ onChanged: enabled+ ? (value) {+ if (value != null) {+ unawaited(+ _send({+ 'type': 'member.approvalMode',+ 'mode': value,+ }),+ );+ }+ }+ : null,+ ),+ ),+ ],+ ),),- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- Text(- _error!,- style: TextStyle(- color: Theme.of(context).colorScheme.error,- ),+ if (_error != null)+ Padding(+ padding: const EdgeInsets.symmetric(+ horizontal: AppDesktop.groupGap,),- TextButton(- onPressed: _sending- ? null- : () => _send(_action!, retry: true),- child: const Text('Retry'),+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ Text(+ _error!,+ style: TextStyle(+ color: Theme.of(context).colorScheme.error,+ ),+ ),+ TextButton(+ onPressed: _sending+ ? null+ : () => _send(_action!, retry: true),+ child: const Text('Retry'),+ ),+ ],),- ],- ),- ),- if (!supported)- Padding(- padding: const EdgeInsets.all(AppDesktop.groupGap),- child: Text(- c.accessRevoked- ? 'Tasks are unavailable.'- : c.snapshot == null- ? 'Loading Tasks…'- : 'Update Harness to use Tasks.',- ),- )- else- Expanded(- child: tasks!.rows.isEmpty- ? const Center(child: Text('No tasks yet'))- : LaidOutListView.builder(- itemCount: tasks.rows.length,- itemBuilder: (context, index) {- final task = tasks.rows[index];- final agent = agents[task.agentId];- final name =- agent?.displayName ??- agent?.name ??- task.agent['name'] as String? ??- 'Not assigned';- final project =- projects[task.projectId]?.name ??- task.projectName;- final pending =- task.status == 'proposal' && task.canApprove;- return Column(- key: ValueKey('personal-task-${task.id}'),- children: [- InkWell(- onTap: () {- if (pending) {- setState(- () => _expanded = _expanded == task.id- ? null- : task.id,- );- } else {- widget.onOpenTask(task.id);- }- },- child: Padding(- padding: const EdgeInsets.symmetric(- horizontal: AppDesktop.groupGap,- vertical: AppDesktop.controlGap,- ),- child: Column(- children: [- Row(+ ),+ if (!supported)+ Padding(+ padding: const EdgeInsets.all(AppDesktop.groupGap),+ child: Text(+ c.accessRevoked+ ? 'Tasks are unavailable.'+ : c.snapshot == null+ ? 'Loading Tasks…'+ : 'Update Harness to use Tasks.',+ ),+ )+ else+ Expanded(+ child: tasks!.rows.isEmpty+ ? const Center(child: Text('No tasks yet'))+ : LaidOutListView.builder(+ itemCount: tasks.rows.length,+ itemBuilder: (context, index) {+ final task = tasks.rows[index];+ final agent = agents[task.agentId];+ final name =+ agent?.displayName ??+ agent?.name ??+ task.agent['name'] as String? ??+ 'Not assigned';+ final project =+ projects[task.projectId]?.name ??+ task.projectName;+ final pending =+ task.status == 'proposal' && task.canApprove;+ return Column(+ key: ValueKey('personal-task-${task.id}'),+ children: [+ InkWell(+ onTap: () {+ if (pending) {+ setState(+ () => _expanded = _expanded == task.id+ ? null+ : task.id,+ );+ } else {+ widget.onOpenTask(task.id);+ }+ },+ child: Padding(+ padding: const EdgeInsets.symmetric(+ horizontal: AppDesktop.groupGap,+ vertical: AppDesktop.controlGap,+ ),+ child: Column(children: [- Flexible(- child: Container(- padding:- const EdgeInsets.symmetric(- horizontal:- AppDesktop.badgeInset,- vertical:- AppDesktop.listRowGap,+ Row(+ children: [+ Flexible(+ child: Container(+ padding:+ const EdgeInsets.symmetric(+ horizontal: AppDesktop+ .badgeInset,+ vertical: AppDesktop+ .listRowGap,+ ),+ decoration: BoxDecoration(+ color: Theme.of(context)+ .colorScheme+ .surfaceContainerHighest,+ borderRadius:+ BorderRadius.circular(+ AppDesktop.rowRadius,+ ),+ ),+ child: Text(+ project,+ maxLines: 1,+ overflow:+ TextOverflow.ellipsis,+ style: Theme.of(context)+ .textTheme+ .labelSmall,),- decoration: BoxDecoration(- color: Theme.of(context)- .colorScheme- .surfaceContainerHighest,- borderRadius:- BorderRadius.circular(- AppDesktop.rowRadius,- ),+ ),),- child: Text(- project,- maxLines: 1,- overflow: TextOverflow.ellipsis,- style: Theme.of(context)- .textTheme- .labelSmall,+ const SizedBox(width: 7),+ Expanded(+ flex: 2,+ child: Text(+ task.title,+ maxLines: 1,+ overflow:+ TextOverflow.ellipsis,+ ),),- ),+ ],),- const SizedBox(width: 7),- Expanded(- flex: 2,- child: Text(- task.title,- maxLines: 1,- overflow: TextOverflow.ellipsis,- ),+ const SizedBox(height: 5),+ Row(+ children: [+ if (task.agentId != null) ...[+ SuperTabAvatar(+ identity:+ 'agent:${task.agentId}',+ name: name,+ size: 20,+ picture:+ agent?.avatar ??+ SuperTabAvatarPicture.fromJson(+ task.agent['avatar'],+ ),+ pattern: true,+ ),+ const SizedBox(width: 6),+ ],+ Expanded(+ child: Text(+ name,+ maxLines: 1,+ overflow:+ TextOverflow.ellipsis,+ style: Theme.of(context)+ .textTheme+ .bodySmall+ ?.copyWith(+ color:+ DesktopChrome.muted,+ ),+ ),+ ),+ if (pending)+ Text(+ 'Waiting for you',+ style: Theme.of(context)+ .textTheme+ .bodySmall+ ?.copyWith(+ color:+ DesktopChrome.muted,+ ),+ ),+ const SizedBox(width: 8),+ _TaskMark(task.status),+ ],),],),- const SizedBox(height: 5),- Row(+ ),+ ),+ if (_expanded == task.id && pending)+ Padding(+ padding: const EdgeInsets.fromLTRB(+ AppDesktop.groupGap,+ 0,+ AppDesktop.groupGap,+ AppDesktop.controlGap,+ ),+ child: Column(children: [- if (task.agentId != null) ...[- SuperTabAvatar(- identity: 'agent:${task.agentId}',- name: name,- size: 20,- picture:- agent?.avatar ??- SuperTabAvatarPicture.fromJson(- task.agent['avatar'],- ),- pattern: true,+ DropdownButtonFormField<String>(+ key: ValueKey(+ 'task-agent-${task.id}',),- const SizedBox(width: 6),- ],- Expanded(- child: Text(- name,- maxLines: 1,- overflow: TextOverflow.ellipsis,- style: Theme.of(context)- .textTheme- .bodySmall- ?.copyWith(- color: DesktopChrome.muted,- ),+ initialValue:+ agents.containsKey(+ task.agentId,+ ) &&+ !agents[task.agentId]!+ .isBuddy+ ? task.agentId+ : null,+ decoration: const InputDecoration(+ labelText: 'Suggested agent',+ isDense: true,),- ),- if (pending)- Text(- 'Waiting for you',- style: Theme.of(context)- .textTheme- .bodySmall- ?.copyWith(- color: DesktopChrome.muted,+ items: [+ for (final a+ in agents.values.where(+ (a) => !a.isBuddy,+ ))+ DropdownMenuItem(+ value: a.id,+ child: Text(+ a.displayName ?? a.name,+ overflow:+ TextOverflow.ellipsis,),- ),- const SizedBox(width: 8),- _TaskMark(task.status),- ],- ),- ],- ),- ),- ),- if (_expanded == task.id && pending)- Padding(- padding: const EdgeInsets.fromLTRB(- AppDesktop.groupGap,- 0,- AppDesktop.groupGap,- AppDesktop.controlGap,- ),- child: Column(- children: [- DropdownButtonFormField<String>(- key: ValueKey('task-agent-${task.id}'),- initialValue:- agents.containsKey(task.agentId) &&- !agents[task.agentId]!.isBuddy- ? task.agentId- : null,- decoration: const InputDecoration(- labelText: 'Suggested agent',- isDense: true,- ),- items: [- for (final a in agents.values.where(- (a) => !a.isBuddy,- ))- DropdownMenuItem(- value: a.id,- child: Text(- a.displayName ?? a.name,- overflow: TextOverflow.ellipsis,- ),- ),- ],- onChanged: enabled- ? (id) {- if (id != null) {- unawaited(- _send({- 'type': 'task.suggest',- 'conversationId': task.id,- 'agentId': id,- }),- );- }- }- : null,- ),- Row(- mainAxisAlignment:- MainAxisAlignment.end,- children: [- TextButton(- onPressed: enabled- ? () => _reject(task)+ ),+ ],+ onChanged: enabled+ ? (id) {+ if (id != null) {+ unawaited(+ _send({+ 'type':+ 'task.suggest',+ 'conversationId':+ task.id,+ 'agentId': id,+ }),+ );+ }+ }: null,- child: const Text('Reject'),),- FilledButton(- onPressed: enabled- ? () => _send({- 'type': 'task.approve',- 'conversationId': task.id,- })- : null,- child: const Text('Approve'),+ Row(+ mainAxisAlignment:+ MainAxisAlignment.end,+ children: [+ TextButton(+ onPressed: enabled+ ? () => _reject(task)+ : null,+ child: const Text('Reject'),+ ),+ FilledButton(+ onPressed: enabled+ ? () => _send({+ 'type': 'task.approve',+ 'conversationId':+ task.id,+ })+ : null,+ child: const Text('Approve'),+ ),+ ],),],),- ],- ),- ),- ],- );- },- ),- ),- ],+ ),+ ],+ );+ },+ ),+ ),+ ],+ ),+ ),),);},diff --git a/desktop/test/super_tab_tasks_pane_surface_test.dart b/desktop/test/super_tab_tasks_pane_surface_test.dartnew file mode 100644index 000000000..c86aadd0a--- /dev/null+++ b/desktop/test/super_tab_tasks_pane_surface_test.dart@@ -0,0 +1,198 @@+import 'dart:io';+import 'dart:ui' as ui;++import 'package:flutter/material.dart';+import 'package:flutter/rendering.dart';+import 'package:flutter_test/flutter_test.dart';+import 'package:harness/shared/theme/app_theme.dart' as grid;+import 'package:harness/super_tabs/tasks/personal_tasks.dart';+import 'package:harness/super_tabs/tasks/personal_tasks_pane.dart';+import 'package:harness/super_tabs/view.dart';++import 'super_tab_personal_tasks_pane_test.dart' show TasksFixture;+import 'super_tab_personal_tasks_test.dart' show task;+import 'support/capture.dart';+import 'swarm_state_test.dart' show createApp;++/// The Tasks pane is one surface from its top to its bottom (anh Dee,+/// 2026-11-07). In Desktop 1.3.87 its dark background ended where its rows+/// ended and a light grey filled the rest.+///+/// The grey was Flutter's release-build error box (a 0xF0C0C0C0 square over the+/// dark surface reads 181, as in his screenshot): a task with no agent yet, such+/// as a Buddy's proposal nobody was assigned, sends `agent: null`, and building+/// its row threw "Invalid Swarm response". The error box then took the whole+/// rest of the list. A pixel test cannot tell a failed row from a good one+/// unless the data has that row, so these tests feed it.+void main() {+ final shots = Platform.environment['HARNESS_TASKS_SURFACE_SHOTS'];+ setUpAll(() => loadCaptureFonts(shots));++ const windowWidth = 1600.0, windowHeight = 1000.0;+ // Nothing in the app is this colour, so a pixel left unpainted shows it.+ const behind = Color(0xFFFF00FF);++ /// Tasks as the server sends them: every third one has no agent yet.+ List<Map<String, dynamic>> rowsOf(int count) => [+ for (var i = 0; i < count; i++)+ {+ ...task('row$i', 1, 1000 - i),+ 'title': 'Task number $i',+ 'projectName': i.isEven ? 'Harness' : 'Desktop',+ 'status': 'proposal',+ 'suggested': false,+ if (i % 3 == 1) 'agent': null,+ },+ ];++ Future<TasksFixture> mount(+ WidgetTester t,+ Brightness brightness,+ int count,+ ) async {+ final f = TasksFixture();+ addTearDown(f.controller.dispose);+ f.rows+ ..clear()+ ..addAll(rowsOf(count));+ await f.controller.refresh();+ final app = createApp();+ addTearDown(app.dispose);+ t.view.physicalSize = const Size(windowWidth, windowHeight);+ t.view.devicePixelRatio = 1;+ addTearDown(t.view.reset);+ grid.AppTheme.brightness.value = brightness;+ addTearDown(() => grid.AppTheme.brightness.value = Brightness.light);+ await t.pumpWidget(+ MaterialApp(+ color: behind,+ debugShowCheckedModeBanner: false,+ theme: grid.buildAppTheme(brightness: brightness),+ // The real Desktop shell, over a window of a colour of its own.+ home: ColoredBox(+ color: behind,+ child: Material(+ type: MaterialType.transparency,+ child: SuperTabView(+ controller: f.controller,+ app: app,+ board: true,+ machineName: (_) => 'Computer',+ onInvite: () {},+ onAddAgent: (_) {},+ onOpenTerminal: (_) {},+ onNewSwarm: () {},+ ),+ ),+ ),+ ),+ );+ await t.pump();+ await t.pump(const Duration(seconds: 1));+ return f;+ }++ Color surface(WidgetTester t) =>+ Theme.of(t.element(find.byType(SuperTabPersonalTasksPane)))+ .colorScheme+ .surface;++ /// The pane's pixels down a strip no row reaches: every one must be the+ /// pane's surface, fully opaque.+ Future<List<String>> strayPixels(WidgetTester t) async {+ final pane = t.getRect(find.byType(SuperTabPersonalTasksPane));+ final want = surface(t);+ final stray = <String>[];+ await t.runAsync(() async {+ final view = t.binding.renderViews.first;+ final image = await (view.debugLayer! as OffsetLayer).toImage(+ Offset.zero & view.size,+ pixelRatio: 1,+ );+ final data = (await image.toByteData(+ format: ui.ImageByteFormat.rawRgba,+ ))!;+ int byte(double channel) => (channel * 255).round();+ final x = pane.left.round() + 3;+ for (var y = pane.top.round(); y < pane.bottom.round(); y++) {+ final i = (y * image.width + x) * 4;+ final got = [for (var k = 0; k < 4; k++) data.getUint8(i + k)];+ final expected = [byte(want.r), byte(want.g), byte(want.b), 255];+ if (got.join(',') != expected.join(',')) {+ stray.add('y=$y got $got, the pane surface is $expected');+ }+ }+ image.dispose();+ });+ return stray;+ }++ test('a task with no agent yet has no agent and no error', () {+ final noAgent = SuperTabPersonalTask({...task('a', 1, 1), 'agent': null});+ expect(noAgent.agentId, isNull);+ expect(noAgent.agent, isEmpty);+ final missing = SuperTabPersonalTask(+ Map.of(task('a', 1, 1))..remove('agent'),+ );+ expect(missing.agentId, isNull);+ });++ for (final brightness in Brightness.values) {+ for (final count in [0, 2, 40]) {+ final name =+ '${brightness.name}, ${count == 0+ ? 'no tasks'+ : count == 2+ ? 'two tasks'+ : 'many tasks, scrolling'}';++ testWidgets('every row of the Tasks pane is its surface: $name', (+ t,+ ) async {+ await mount(t, brightness, count);+ // A row that failed to build is an exception, and in a release build+ // a grey box that fills the rest of the list.+ expect(t.takeException(), isNull);+ final pane = t.getRect(find.byType(SuperTabPersonalTasksPane));+ expect(pane.size, const Size(340, windowHeight));+ if (count == 0) {+ expect(find.text('No tasks yet'), findsOneWidget);+ } else {+ expect(find.text('Task number 0'), findsOneWidget);+ // The row with no agent is on screen, as the person's own task.+ if (count > 1) expect(find.text('Not assigned'), findsWidgets);+ }+ expect(await strayPixels(t), isEmpty);+ await captureWindow(+ t,+ shots,+ 'tasks-surface-${brightness.name}-$count',+ );+ });+ }+ }++ testWidgets('the pane draws its own filled surface under its list', (+ t,+ ) async {+ await mount(t, Brightness.dark, 2);+ final pane = t.getRect(find.byType(SuperTabPersonalTasksPane));+ // A plain filled box the size of the slot, whatever the list is, so the+ // pane never shows what is behind it if its list is short or fails.+ final fills = t+ .widgetList<ColoredBox>(+ find.descendant(+ of: find.byType(SuperTabPersonalTasksPane),+ matching: find.byType(ColoredBox),+ ),+ )+ .where((box) => box.color == surface(t));+ expect(+ fills.where((box) {+ final size = t.getSize(find.byWidget(box));+ return size.width == pane.width && size.height == pane.height;+ }),+ isNotEmpty,+ );+ });+}diff --git a/mobile/lib/swarm/tasks/personal_tasks.dart b/mobile/lib/swarm/tasks/personal_tasks.dartindex 11b13adf6..29951e74b 100644--- a/mobile/lib/swarm/tasks/personal_tasks.dart+++ b/mobile/lib/swarm/tasks/personal_tasks.dart@@ -14,7 +14,12 @@ class SuperTabPersonalTask {bool get suggested => json['suggested'] == true;bool get canApprove => json['canApprove'] == true;String? get reason => json['reason'] as String?;- Map<String, dynamic> get agent => superTabMap(json['agent']);++ /// A task nobody works on yet is sent with `agent: null`: no agent, not a+ /// malformed reply (building its row threw, and a release build drew the+ /// error as a grey box over the rest of the list).+ Map<String, dynamic> get agent =>+ json['agent'] == null ? const {} : superTabMap(json['agent']);String? get agentId => agent['id'] as String?;}