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 Tasks pane: board-style cards, task opens in the middle, one-row agent chat header (#4204) (#3464)
0xken159ade7cefcaa7
diff --git a/desktop/lib/super_tabs/backend_transport.dart b/desktop/lib/super_tabs/backend_transport.dartindex b36fe0df4..354065c5e 100644--- a/desktop/lib/super_tabs/backend_transport.dart+++ b/desktop/lib/super_tabs/backend_transport.dart@@ -21,6 +21,8 @@ final _swarmRoute = RegExp('|routing-policy|groups|groups/$_id|join|join/preview|native''|activity|activity/read|threads|inbox|proposals''|reminders'+ // The person's older Tasks, a page at a time (#4204, backend #4203).+ '|personal-tasks'// New Project's New Repository asks whether an organization can (#3374).'|github/owners/$_id'// A voice message's clip, read once before it is sent (#2887; the mic, #2665).diff --git a/desktop/lib/super_tabs/buddies.dart b/desktop/lib/super_tabs/buddies.dartindex 9ef8d1549..3c7aacf60 100644--- a/desktop/lib/super_tabs/buddies.dart+++ b/desktop/lib/super_tabs/buddies.dart@@ -524,16 +524,33 @@ class _RenameBuddyDialogState extends State<_RenameBuddyDialog> {/// terminal, and, while it is down, a way to start it again. Before its/// agent is there, how its start is going (backend: the start carries the/// add's progress and failure).+/// The Buddy that [chat] is with: the reader's own main Buddy in the Swarm's one Buddy chat, else its project's.+SuperTabAgent? superTabChatBuddy(+ SuperTabController c,+ SuperTabConversation chat,+) => chat.isSwarmBuddyChat && c.snapshot!.buddyCap != null+ ? chat.agentIds+ .map(c.snapshot!.agent)+ .whereType<SuperTabAgent>()+ .where((a) => a.isMainBuddy && a.buddyOf == c.accountId)+ .firstOrNull+ : c.buddy(chat.projectId);+class SuperTabBuddyBar extends StatelessWidget {const SuperTabBuddyBar({super.key,required this.controller,required this.chat,this.app,+ this.line = true,});final SuperTabController controller;final SuperTabConversation chat;+ /// The bar's line of engine, model, machine and who reads the chat. Off under the middle chat's one-row header,+ /// which carries the pickers and nothing else (anh Dee, #4204); the limit and Start again rows stay.+ final bool line;+/// For the Start bar's Add this Mac, as Add a Buddy has it (#2105).final AppNotifier? app;@@ -692,13 +709,7 @@ class SuperTabBuddyBar extends StatelessWidget {Widget build(BuildContext context) {grid.AppTheme.watch(context);final c = controller;- final agent = chat.isSwarmBuddyChat && c.snapshot!.buddyCap != null- ? chat.agentIds- .map(c.snapshot!.agent)- .whereType<SuperTabAgent>()- .where((a) => a.isMainBuddy && a.buddyOf == c.accountId)- .firstOrNull- : c.buddy(chat.projectId);+ final agent = superTabChatBuddy(c, chat);if (agent == null) return _starting(c);final name = c.snapshot!.agentName(agent.id, fallback: agent.name);final machine = buddyMachineName(c, agent.machineId, app: app);@@ -721,6 +732,17 @@ class SuperTabBuddyBar extends StatelessWidget {final busy = !c.canWrite || c.saving || c.hasPendingAction;final offer = agent.downSince == null && _mustStartAgain(c, agent);final held = offer ? _restartHeld(c, agent, machine) : null;+ final limited =+ chat.isSwarmBuddyChat &&+ agent.gridModel == null &&+ agent.downSince == null &&+ agent.switchRequest == null &&+ agent.modelRequest == null &&+ agent.limitedUntil?.isAfter(DateTime.now()) == true &&+ buddyEngineCapable(c.snapshot!, agent);+ if (!line && !limited && !offer && agent.downSince == null) {+ return const SizedBox.shrink();+ }return Padding(key: const ValueKey('super-buddy-bar'),padding: _padding,@@ -730,7 +752,9 @@ class SuperTabBuddyBar extends StatelessWidget {children: [// The one Buddy switches between its person's subscription and a// model shared in the Swarm (task #2354); a project's Buddy cannot.- if (chat.isSwarmBuddyChat)+ if (!line)+ const SizedBox.shrink()+ else if (chat.isSwarmBuddyChat)BuddyModelLine(controller: c,agent: agent,@@ -760,13 +784,7 @@ class SuperTabBuddyBar extends StatelessWidget {)elseText(where, style: DesktopChrome.metadata()),- if (chat.isSwarmBuddyChat &&- agent.gridModel == null &&- agent.downSince == null &&- agent.switchRequest == null &&- agent.modelRequest == null &&- agent.limitedUntil?.isAfter(DateTime.now()) == true &&- buddyEngineCapable(c.snapshot!, agent))+ if (limited)Row(key: const ValueKey('super-buddy-engine-limit'),children: [diff --git a/desktop/lib/super_tabs/buddy_model.dart b/desktop/lib/super_tabs/buddy_model.dartindex 377c90afd..356e8249e 100644--- a/desktop/lib/super_tabs/buddy_model.dart+++ b/desktop/lib/super_tabs/buddy_model.dart@@ -68,7 +68,7 @@ class BuddyModelLine extends StatefulWidget {required this.controller,required this.agent,required this.machine,- required this.rest,+ this.rest,});final SuperTabController controller;@@ -79,8 +79,8 @@ class BuddyModelLine extends StatefulWidget {/// Its machine's name, for the line that asks to add it to the Swarm.final String machine;- /// The bar's line after the picker.- final String rest;+ /// The bar's line after the picker; null for the pickers alone, as the one-row chat header has them (#4204).+ final String? rest;@overrideState<BuddyModelLine> createState() => _BuddyModelLineState();@@ -128,7 +128,7 @@ class _BuddyModelLineState extends State<BuddyModelLine> {final after = [if (request == null && current != null)on == null ? 'not served now' : _servers(on),- widget.rest,+ ?widget.rest,].join(' · ');final picker = request != null? Text(@@ -143,6 +143,33 @@ class _BuddyModelLineState extends State<BuddyModelLine> {phone: phone,busy: busy,);+ if (widget.rest == null) {+ return Row(+ mainAxisSize: MainAxisSize.min,+ children: [+ if (buddyEngineCapable(snapshot, agent)) ...[+ BuddyEnginePicker(+ key: const ValueKey('super-buddy-engine'),+ controller: c,+ agent: agent,+ ),+ const SizedBox(width: grid.AppDesktop.controlGap),+ ] else ...[+ Text(+ buddyEngineLabel(agent.engine),+ style: DesktopChrome.metadata(color: DesktopChrome.foreground),+ ),+ const SizedBox(width: grid.AppDesktop.controlGap),+ ],+ KeyedSubtree(key: const ValueKey('super-buddy-model'), child: picker),+ // A picked shared model that stopped is a failure the reader acts on, so it stays (review 4 of #3464).+ if (request == null && current != null && on == null) ...[+ const SizedBox(width: grid.AppDesktop.menuInset),+ Text('not served now', style: DesktopChrome.metadata()),+ ],+ ],+ );+ }// Text.rich scales inline widgets as well as the Text they contain.// Ordinary children scale once and wrap naturally on a narrow header.return Wrap(diff --git a/desktop/lib/super_tabs/chat/agent_chat_header.dart b/desktop/lib/super_tabs/chat/agent_chat_header.dartnew file mode 100644index 000000000..3d68f0483--- /dev/null+++ b/desktop/lib/super_tabs/chat/agent_chat_header.dart@@ -0,0 +1,117 @@+import 'package:flutter/material.dart';++import '../../core/runtime_model_name.dart';+import '../../shared/theme/app_theme.dart' as grid;+import '../../state/app_state.dart';+import '../../widgets/desktop_chrome.dart';+import '../../widgets/engine_identity.dart';+import '../buddies.dart';+import '../buddy_model.dart';+import '../controller.dart';+import '../identity.dart';+import '../model.dart';++/// An agent's chat in the middle, under one row (anh Dee, #4204): its avatar and name on the left; its engine, its+/// model and the chat's menu on the right; no other text. The reader's own Buddy switches engine and model there.+/// The server switches no other agent, so theirs are named in the same place.+class SuperTabAgentChatHeader extends StatelessWidget {+ const SuperTabAgentChatHeader({+ super.key,+ required this.controller,+ required this.group,+ this.menu,+ this.app,+ });++ final SuperTabController controller;+ final SuperTabConversation group;++ /// The chat's ⋮ menu.+ final Widget? menu;++ /// For the model picker's line that asks to add the Buddy's machine to the Swarm.+ final AppNotifier? app;++ @override+ Widget build(BuildContext context) {+ grid.AppTheme.watch(context);+ final c = controller;+ final snapshot = c.snapshot;+ final buddy = group.isBuddyChat && snapshot != null+ ? superTabChatBuddy(c, group)+ : null;+ final agent = buddy ?? _agentOf(snapshot, group);+ final name = agent != null+ ? snapshot!.agentName(agent.id, fallback: agent.name)+ : group.isBuddyChat+ ? 'Your Buddy'+ : group.label;+ final model = switch (agent?.configuration['model']) {+ final String id when id.isNotEmpty && id != 'default' => modelDisplayName(+ id,+ ),+ _ => null,+ };+ Widget label(String text) => Text(+ text,+ maxLines: 1,+ style: DesktopChrome.metadata(color: DesktopChrome.foreground),+ );+ return SizedBox(+ key: const ValueKey('super-agent-chat-header'),+ height: 44,+ child: Row(+ children: [+ const SizedBox(width: grid.AppDesktop.controlGap),+ if (agent != null) ...[+ SuperTabAvatar.agent(+ agent,+ size: SuperTabAvatar.rowSize,+ engineBadge: false,+ ),+ const SizedBox(width: grid.AppDesktop.menuInset),+ ],+ Expanded(+ child: Text(+ name,+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: DesktopChrome.control().copyWith(+ fontWeight: grid.AppFont.semibold,+ ),+ ),+ ),+ if (buddy != null && group.isSwarmBuddyChat)+ BuddyModelLine(+ controller: c,+ agent: buddy,+ machine: buddyMachineName(c, buddy.machineId, app: app),+ )+ else if (agent != null) ...[+ label(engineIdentity(agent.engine).label),+ if (model != null) ...[+ const SizedBox(width: grid.AppDesktop.controlGap),+ label(model),+ ],+ ],+ const SizedBox(width: grid.AppDesktop.menuInset),+ ?menu,+ const SizedBox(width: grid.AppDesktop.menuInset),+ ],+ ),+ );+ }+}++/// The agent a chat is with: the one whose own chat it is (#4116), else the agent on its task.+SuperTabAgent? _agentOf(+ SuperTabSnapshot? snapshot,+ SuperTabConversation group,+) {+ if (snapshot == null) return null;+ return snapshot.agents.where((a) => a.chatId == group.id).firstOrNull ??+ switch (group.assignment?['agentId']) {+ final String id => snapshot.agent(id),+ _ => null,+ };+}diff --git a/desktop/lib/super_tabs/controller.dart b/desktop/lib/super_tabs/controller.dartindex eb42c5a48..168de81b1 100644--- a/desktop/lib/super_tabs/controller.dart+++ b/desktop/lib/super_tabs/controller.dart@@ -441,6 +441,30 @@ class SuperTabController extends ChangeNotifier {SuperTabPersonalTasks? get personalTasks => _parts?.personalTasks;+ Future<bool>? _olderPersonalTasks;++ /// Reads the next older page of the person's Tasks (backend #4203), one read at a time. False when it failed.+ Future<bool> loadOlderPersonalTasks() => _olderPersonalTasks ??=+ _readOlderPersonalTasks().whenComplete(() => _olderPersonalTasks = null);++ Future<bool> _readOlderPersonalTasks() async {+ final parts = _parts;+ final cursor = parts?.personalTasks.olderCursor;+ if (parts == null || cursor == null) return true;+ try {+ final page = await request(+ 'GET',+ '$_path/personal-tasks?before=${Uri.encodeComponent(cursor)}',+ );+ if (_disposed || !identical(parts, _parts)) return true;+ if (parts.personalTasks.applyOlder(page, from: cursor)) _changed();+ return true;+ } catch (failure) {+ if (_isUpdateRequired(failure)) _requireUpdate();+ return false;+ }+ }+/// The visibility epoch of the last read: it moves when who may read what changes (backend parts/commit.ts/// `visibilityChanged`). Null before a read.int? get visibilityEpoch => _parts?.epoch;diff --git a/desktop/lib/super_tabs/tasks/personal_task_card.dart b/desktop/lib/super_tabs/tasks/personal_task_card.dartnew file mode 100644index 000000000..267169dea--- /dev/null+++ b/desktop/lib/super_tabs/tasks/personal_task_card.dart@@ -0,0 +1,243 @@+import 'package:flutter/material.dart';++import '../../shared/theme/app_icons.dart';+import '../../shared/theme/app_theme.dart' as grid;+import '../../state/harness_activity.dart';+import '../../widgets/desktop_chrome.dart';+import '../../widgets/harness_activity_mark.dart';+import '../task_card.dart';+import 'personal_tasks.dart';++/// A project's tag colour: one of the roster's hues, which carry white at 5:1 or more in both appearances, picked by+/// its id so a project keeps its colour everywhere and needs no stored field.+Color superTabProjectColor(String projectId) {+ const palette = grid.AppPalette.avatarPalette;+ var hash = 0;+ for (final unit in projectId.codeUnits) {+ hash = (hash * 31 + unit) & 0x7fffffff;+ }+ return palette[hash % palette.length];+}++/// One task in the Tasks pane, as a Board tile, cleaner (anh Dee, 11-07): the project's tag and the status mark on+/// top, the title in up to three lines, then who asked and the agent as two avatars, with Approve and Reject on the+/// right while the task waits for the reader.+class SuperTabPersonalTaskCard extends StatefulWidget {+ const SuperTabPersonalTaskCard({+ super.key,+ required this.task,+ required this.project,+ required this.selected,+ required this.onOpen,+ this.requester,+ this.agent,+ this.waiting = false,+ this.onApprove,+ this.onReject,+ });++ final SuperTabPersonalTask task;++ /// The project's name, as the reader's snapshot or the row says it.+ final String project;+ final bool selected;+ final VoidCallback onOpen;+ final Widget? requester, agent;++ /// The task waits for the reader: Approve and Reject show, disabled while [onApprove] and [onReject] are null.+ final bool waiting;+ final VoidCallback? onApprove, onReject;++ @override+ State<SuperTabPersonalTaskCard> createState() => _CardState();+}++/// Approve and Reject fit beside two avatars in the pane's fixed 340.+const _buttonPadding = EdgeInsets.symmetric(+ horizontal: grid.AppDesktop.controlGap,+ vertical: grid.AppDesktop.menuInset,+);++class _CardState extends State<SuperTabPersonalTaskCard> {+ bool _hovered = false;++ @override+ Widget build(BuildContext context) {+ grid.AppTheme.watch(context);+ final w = widget;+ final radius = BorderRadius.circular(grid.AppCard.insetRadius);+ final waiting = w.waiting;+ final avatars = [?w.requester, ?w.agent];+ return Semantics(+ selected: w.selected ? true : null,+ container: true,+ child: Material(+ type: MaterialType.transparency,+ child: Ink(+ decoration: BoxDecoration(+ color: w.selected+ ? Color.alphaBlend(+ grid.AppSurface.selectedFill,+ grid.AppCard.base,+ )+ : grid.AppCard.base,+ borderRadius: radius,+ border: Border.all(+ color: w.selected ? grid.AppGlass.lift : grid.AppCard.insetHair,+ ),+ boxShadow: _hovered+ ? grid.AppGlass.shadow+ : grid.AppGlass.cardShadow,+ ),+ child: InkWell(+ onTap: w.onOpen,+ onHover: (hovered) {+ if (hovered != _hovered) setState(() => _hovered = hovered);+ },+ hoverColor: grid.AppSurface.hoverFill,+ focusColor: grid.AppSurface.hoverFill,+ borderRadius: radius,+ child: Padding(+ padding: const EdgeInsets.all(SuperTabTaskCard.tilePadding),+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ Row(+ children: [+ // The tag takes the room left, so the mark sits at the right edge: a Flexible beside a Spacer split+ // the free space and left the mark mid-card (as in #3846).+ Expanded(+ child: Align(+ alignment: AlignmentDirectional.centerStart,+ child: _Tag(w.project, w.task.projectId),+ ),+ ),+ const SizedBox(width: grid.AppDesktop.controlGap),+ SuperTabTaskStatusMark(w.task.status),+ ],+ ),+ const SizedBox(height: grid.AppDesktop.controlGap),+ Text(+ w.task.title,+ maxLines: 3,+ overflow: TextOverflow.ellipsis,+ style: DesktopChrome.control(+ color: DesktopChrome.foreground,+ ).copyWith(fontWeight: grid.AppFont.medium, height: 1.35),+ ),+ if (avatars.isNotEmpty || waiting) ...[+ const SizedBox(height: grid.AppDesktop.controlGap),+ Row(+ children: [+ for (final (i, avatar) in avatars.indexed) ...[+ if (i > 0)+ const SizedBox(+ width: grid.AppDesktop.listRowGap * 2,+ ),+ avatar,+ ],+ const Spacer(),+ if (waiting) ...[+ TextButton(+ onPressed: w.onReject,+ style: TextButton.styleFrom(+ visualDensity: VisualDensity.compact,+ tapTargetSize: MaterialTapTargetSize.shrinkWrap,+ padding: _buttonPadding,+ minimumSize: Size.zero,+ ),+ child: const Text('Reject'),+ ),+ const SizedBox(width: grid.AppDesktop.listRowGap * 2),+ FilledButton(+ onPressed: w.onApprove,+ style: FilledButton.styleFrom(+ visualDensity: VisualDensity.compact,+ tapTargetSize: MaterialTapTargetSize.shrinkWrap,+ padding: _buttonPadding,+ minimumSize: Size.zero,+ ),+ child: const Text('Approve'),+ ),+ ],+ ],+ ),+ ],+ ],+ ),+ ),+ ),+ ),+ ),+ );+ }+}++/// The project's name in a capsule of its colour, white on it, as a Board tile labels its lane.+class _Tag extends StatelessWidget {+ const _Tag(this.name, this.projectId);+ final String name, projectId;++ @override+ Widget build(BuildContext context) => DecoratedBox(+ key: const ValueKey('personal-task-tag'),+ decoration: BoxDecoration(+ color: superTabProjectColor(projectId),+ borderRadius: BorderRadius.circular(grid.AppDesktop.paneCloseInset),+ ),+ child: Padding(+ padding: const EdgeInsets.symmetric(+ horizontal: grid.AppDesktop.menuInset,+ vertical: grid.AppDesktop.listRowGap / 2,+ ),+ child: Text(+ name,+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: DesktopChrome.metadata(color: grid.AppDesktop.onSelection)+ .copyWith(fontWeight: grid.AppFont.medium, height: 1.25),+ ),+ ),+ );+}++/// A task's status as the Tasks pane marks it: a proposal and a rejection by their own icons, work by its activity.+class SuperTabTaskStatusMark extends StatelessWidget {+ const SuperTabTaskStatusMark(this.status, {super.key});+ final String status;++ @override+ Widget build(BuildContext context) {+ if (status == 'proposal' || status == 'rejected') {+ final label = superTabTaskStatusLabel(status);+ return Tooltip(+ message: label,+ child: Icon(+ status == 'proposal' ? AppIcons.circleDashed : AppIcons.circleX,+ size: AppIcons.metadataSize,+ semanticLabel: label,+ ),+ );+ }+ return ActivityMark(+ activity: superTabTaskActivity(status),+ color: Theme.of(context).colorScheme.onSurface,+ );+ }+}++HarnessActivity superTabTaskActivity(String status) => switch (status) {+ 'done' || 'shipped' => HarnessActivity.done,+ 'working' => HarnessActivity.working,+ 'needs_human' || 'needs_human_approval' => HarnessActivity.needsInput,+ 'blocked' || 'stuck' => HarnessActivity.failed,+ 'stopped' => HarnessActivity.paused,+ _ => HarnessActivity.starting,+};++/// The status in words, for the task's header and for readers of the mark.+String superTabTaskStatusLabel(String status) => switch (status) {+ 'proposal' => 'Proposal',+ 'rejected' => 'Rejected',+ _ => superTabTaskActivity(status).label,+};diff --git a/desktop/lib/super_tabs/tasks/personal_tasks.dart b/desktop/lib/super_tabs/tasks/personal_tasks.dartindex 29951e74b..403f01bf4 100644--- a/desktop/lib/super_tabs/tasks/personal_tasks.dart+++ b/desktop/lib/super_tabs/tasks/personal_tasks.dart@@ -21,6 +21,12 @@ class SuperTabPersonalTask {Map<String, dynamic> get agent =>json['agent'] == null ? const {} : superTabMap(json['agent']);String? get agentId => agent['id'] as String?;++ /// The person who asked; empty from a backend before #4203.+ Map<String, dynamic> get requester =>+ json['requester'] == null ? const {} : superTabMap(json['requester']);+ String? get requesterId => requester['id'] as String?;+ String? get pullRequestUrl => json['pullRequestUrl'] as String?;}/// Lives with the parts cursor and is discarded with it on access revocation.@@ -28,6 +34,9 @@ class SuperTabPersonalTask {class SuperTabPersonalTasks {bool supported = false;String mode = 'autoApprove';++ /// Where the next older page starts; null when there is none, or the backend pages nothing.+ String? olderCursor;final _rows = <String, SuperTabPersonalTask>{};final _versions = <String, int>{};List<SuperTabPersonalTask>? _ordered;@@ -52,11 +61,29 @@ class SuperTabPersonalTasks {changed = true;_rows.clear();_versions.clear();+ olderCursor = value['olderCursor'] as String?;}for (final id in value['removed'] as List? ?? const []) {if (id is String && _rows.remove(id) != null) changed = true;}- for (final raw in value['upserts'] as List? ?? const []) {+ if (_upsert(value['upserts'])) changed = true;+ if (changed) _ordered = null;+ return changed;+ }++ /// Adds an older page, read [from] a cursor, below the rows held, and moves [olderCursor] past it. A page read+ /// before a reset moved the cursor is dropped: its range may no longer follow the rows held.+ bool applyOlder(Object? page, {required String from}) {+ if (page is! Map || olderCursor != from) return false;+ olderCursor = page['olderCursor'] as String?;+ final changed = _upsert(page['upserts']);+ if (changed) _ordered = null;+ return changed;+ }++ bool _upsert(Object? upserts) {+ var changed = false;+ for (final raw in upserts as List? ?? const []) {final row = superTabMap(raw);if (row['id'] is! String || row['version'] is! num || row['at'] is! num) {throw const FormatException('Could not read a task summary.');@@ -67,10 +94,12 @@ class SuperTabPersonalTasks {_rows[task.id] = task;changed = true;}- if (changed) _ordered = null;return changed;}+ /// The row of task [id], or null when the feed holds none.+ SuperTabPersonalTask? row(String id) => _rows[id];+Map<String, int> get versions => Map.unmodifiable(_versions);/// Cache tombstones share the cursor's lifetime, so its overlap stays idempotent after restart.@@ -91,5 +120,6 @@ class SuperTabPersonalTasks {'reset': true,'upserts': [for (final row in rows) row.json],'removed': <String>[],+ 'olderCursor': ?olderCursor,};}diff --git a/desktop/lib/super_tabs/tasks/personal_tasks_pane.dart b/desktop/lib/super_tabs/tasks/personal_tasks_pane.dartindex bfcd1d504..31ae42eb0 100644--- a/desktop/lib/super_tabs/tasks/personal_tasks_pane.dart+++ b/desktop/lib/super_tabs/tasks/personal_tasks_pane.dart@@ -2,15 +2,12 @@ import 'dart:async';import 'package:flutter/material.dart';-import '../../state/harness_activity.dart';-import '../../shared/theme/app_icons.dart';import '../../shared/theme/app_theme.dart';-import '../../widgets/harness_activity_mark.dart';import '../../widgets/laid_out_list.dart';-import '../../widgets/desktop_chrome.dart';import '../controller.dart';import '../identity.dart';import '../model.dart';+import 'personal_task_card.dart';import 'personal_tasks.dart';/// The person's active work, from the same authenticated cursor as the chat.@@ -19,26 +16,52 @@ class SuperTabPersonalTasksPane extends StatefulWidget {super.key,required this.controller,required this.onOpenTask,+ this.selectedId,});final SuperTabController controller;final ValueChanged<String> onOpenTask;++ /// The task open in the middle, whose card shows as selected.+ final String? selectedId;@overrideState<SuperTabPersonalTasksPane> createState() => _TasksPaneState();}+/// Who asked, a step smaller than the agent beside it, as on a Board tile.+const _requesterSize = 18.0;+class _TasksPaneState extends State<SuperTabPersonalTasksPane> {- String? _expanded, _error, _operationId;+ String? _error, _operationId;Map<String, dynamic>? _action;- bool _sending = false;+ bool _sending = false, _olderFailed = false;SuperTabController get c => widget.controller;+ /// Near the end of the list, the next older page is read; the controller sends one read at a time.+ bool _onScroll(ScrollNotification note) {+ final m = note.metrics;+ if (!_olderFailed &&+ c.personalTasks?.olderCursor != null &&+ m.pixels >= m.maxScrollExtent - m.viewportDimension) {+ unawaited(_loadOlder());+ }+ return false;+ }++ Future<void> _loadOlder() async {+ final owner = c;+ final ok = await owner.loadOlderPersonalTasks();+ if (mounted && identical(owner, c) && ok == _olderFailed) {+ setState(() => _olderFailed = !ok);+ }+ }+@overridevoid didUpdateWidget(SuperTabPersonalTasksPane old) {super.didUpdateWidget(old);if (!identical(old.controller, c)) {- _expanded = _error = _operationId = null;+ _error = _operationId = null;_action = null;- _sending = false;+ _sending = _olderFailed = false;}}@@ -154,6 +177,9 @@ class _TasksPaneState extends State<SuperTabPersonalTasksPane> {final projects = {for (final p in snapshot?.projects ?? <SuperTabProject>[]) p.id: p,};+ final people = {+ for (final p in snapshot?.people ?? <SuperTabPerson>[]) p.id: p,+ };// 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.@@ -249,232 +275,107 @@ class _TasksPaneState extends State<SuperTabPersonalTasksPane> {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(- 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,- ),- ),- ),- const SizedBox(width: 7),- Expanded(- flex: 2,- child: Text(- task.title,- maxLines: 1,- overflow:- TextOverflow.ellipsis,+ : NotificationListener<ScrollNotification>(+ onNotification: _onScroll,+ child: LaidOutListView.builder(+ itemCount: tasks.rows.length,+ itemBuilder: (context, index) {+ final task = tasks.rows[index];+ final agent = agents[task.agentId];+ final person = people[task.requesterId];+ final waiting =+ task.status == 'proposal' &&+ task.canApprove;+ return Padding(+ key: ValueKey('personal-task-${task.id}'),+ padding: const EdgeInsets.fromLTRB(+ AppDesktop.groupGap,+ 0,+ AppDesktop.groupGap,+ AppDesktop.controlGap,+ ),+ child: SuperTabPersonalTaskCard(+ task: task,+ project:+ projects[task.projectId]?.name ??+ task.projectName,+ selected: task.id == widget.selectedId,+ onOpen: () => widget.onOpenTask(task.id),+ requester: task.requesterId == null+ ? null+ : person != null+ ? SuperTabAvatar.person(+ person,+ size: _requesterSize,+ )+ : SuperTabAvatar(+ identity:+ 'person:${task.requesterId}',+ name:+ task.requester['name']+ as String? ??+ 'Person',+ size: _requesterSize,+ picture:+ SuperTabAvatarPicture.fromJson(+ task.requester['avatar'],),- ),- ],),- 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,- ),+ agent: task.agentId == null+ ? null+ : SuperTabAvatar(+ identity: 'agent:${task.agentId}',+ name:+ agent?.displayName ??+ agent?.name ??+ task.agent['name'] as String? ??+ 'Agent',+ size: SuperTabAvatar.rowSize,+ picture:+ agent?.avatar ??+ SuperTabAvatarPicture.fromJson(+ task.agent['avatar'],),- const SizedBox(width: 8),- _TaskMark(task.status),- ],+ pattern: true,),- ],- ),- ),+ waiting: waiting,+ onApprove: waiting && enabled+ ? () => _send({+ 'type': 'task.approve',+ 'conversationId': task.id,+ // The agent shown, null for none: a suggestion changed since is refused+ // (task #4217).+ 'suggestedAgentId': task.agentId,+ })+ : null,+ onReject: waiting && enabled+ ? () => _reject(task)+ : null,),- 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,- // The row's own text size: a dropdown's default is- // larger and bolder than the task titles around it.- style: DefaultTextStyle.of(context)- .style,- 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)- : null,- child: const Text('Reject'),- ),- FilledButton(- onPressed: enabled- ? () => _send({- 'type': 'task.approve',- 'conversationId':- task.id,- // The agent shown, null for none: a suggestion changed- // since is refused (task #4217).- 'suggestedAgentId':- task.agentId,- })- : null,- child: const Text('Approve'),- ),- ],- ),- ],- ),- ),- ],- );- },+ );+ },+ ),),),+ if (supported && _olderFailed)+ Padding(+ padding: const EdgeInsets.all(AppDesktop.groupGap),+ child: Row(+ children: [+ const Expanded(+ child: Text('Could not load older tasks.'),+ ),+ TextButton(+ key: const ValueKey('tasks-older-retry'),+ onPressed: () {+ setState(() => _olderFailed = false);+ unawaited(_loadOlder());+ },+ child: const Text('Retry'),+ ),+ ],+ ),+ ),],),),@@ -483,34 +384,3 @@ class _TasksPaneState extends State<SuperTabPersonalTasksPane> {},);}--class _TaskMark extends StatelessWidget {- const _TaskMark(this.status);- final String status;- @override- Widget build(BuildContext context) {- if (status == 'proposal' || status == 'rejected') {- final label = status == 'proposal' ? 'Proposal' : 'Rejected';- return Tooltip(- message: label,- child: Icon(- status == 'proposal' ? AppIcons.circleDashed : AppIcons.circleX,- size: AppIcons.metadataSize,- semanticLabel: label,- ),- );- }- final activity = switch (status) {- 'done' || 'shipped' => HarnessActivity.done,- 'working' => HarnessActivity.working,- 'needs_human' || 'needs_human_approval' => HarnessActivity.needsInput,- 'blocked' || 'stuck' => HarnessActivity.failed,- 'stopped' => HarnessActivity.paused,- _ => HarnessActivity.starting,- };- return ActivityMark(- activity: activity,- color: Theme.of(context).colorScheme.onSurface,- );- }-}diff --git a/desktop/lib/super_tabs/tasks/task_header.dart b/desktop/lib/super_tabs/tasks/task_header.dartnew file mode 100644index 000000000..c80f4cd8d--- /dev/null+++ b/desktop/lib/super_tabs/tasks/task_header.dart@@ -0,0 +1,158 @@+import 'dart:async';++import 'package:flutter/material.dart';+import 'package:flutter_svg/flutter_svg.dart';++import '../../core/open_in_browser.dart';+import '../../shared/theme/app_theme.dart' as grid;+import '../../shared/theme/pull_request_icon.dart';+import '../../widgets/desktop_chrome.dart';+import '../controller.dart';+import '../identity.dart';+import '../model.dart';+import 'personal_task_card.dart';+import 'personal_tasks.dart';++/// Above a task's chat in the middle, opened from its Tasks card (anh Dee, 11-07): the full title, then its status,+/// who asked, its agent and its pull request.+class SuperTabTaskHeader extends StatelessWidget {+ const SuperTabTaskHeader({+ super.key,+ required this.controller,+ required this.task,+ });++ final SuperTabController controller;+ final SuperTabPersonalTask task;++ @override+ Widget build(BuildContext context) {+ grid.AppTheme.watch(context);+ final snapshot = controller.snapshot;+ final person = snapshot?.people+ .where((p) => p.id == task.requesterId)+ .firstOrNull;+ final agent = snapshot?.agent(task.agentId ?? '');+ final pr = task.pullRequestUrl;+ const avatar = 18.0;+ Widget fact(List<Widget> children) => Row(+ mainAxisSize: MainAxisSize.min,+ children: [+ for (final (i, child) in children.indexed) ...[+ if (i > 0) const SizedBox(width: grid.AppDesktop.menuInset),+ child,+ ],+ ],+ );+ Widget words(String text) => Text(text, style: DesktopChrome.metadata());+ // As wide as the middle, so a short title starts at its left edge instead of centred in its column.+ return Container(+ key: const ValueKey('super-task-header'),+ width: double.infinity,+ padding: const EdgeInsets.fromLTRB(+ grid.AppDesktop.controlGap,+ grid.AppDesktop.controlGap,+ grid.AppDesktop.controlGap,+ grid.AppDesktop.menuInset,+ ),+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ mainAxisSize: MainAxisSize.min,+ children: [+ Text(+ task.title,+ style: DesktopChrome.control(color: DesktopChrome.foreground)+ .copyWith(fontWeight: grid.AppFont.semibold, height: 1.35),+ ),+ const SizedBox(height: grid.AppDesktop.menuInset),+ Wrap(+ spacing: grid.AppDesktop.groupGap,+ runSpacing: grid.AppDesktop.menuInset,+ crossAxisAlignment: WrapCrossAlignment.center,+ children: [+ fact([+ SuperTabTaskStatusMark(task.status),+ words(superTabTaskStatusLabel(task.status)),+ ]),+ if (task.requesterId case final id?)+ fact([+ if (person != null)+ SuperTabAvatar.person(person, size: avatar)+ else+ SuperTabAvatar(+ identity: 'person:$id',+ name: task.requester['name'] as String? ?? 'Person',+ size: avatar,+ picture: SuperTabAvatarPicture.fromJson(+ task.requester['avatar'],+ ),+ ),+ words(+ person?.shownName ??+ task.requester['name'] as String? ??+ 'Person',+ ),+ ]),+ if (task.agentId case final id?)+ fact([+ if (agent != null)+ SuperTabAvatar.agent(+ agent,+ size: avatar,+ engineBadge: false,+ )+ else+ SuperTabAvatar(+ identity: 'agent:$id',+ name: task.agent['name'] as String? ?? 'Agent',+ size: avatar,+ picture: SuperTabAvatarPicture.fromJson(+ task.agent['avatar'],+ ),+ pattern: true,+ ),+ words(+ agent?.displayName ??+ agent?.name ??+ task.agent['name'] as String? ??+ 'Agent',+ ),+ ]),+ if (pr != null)+ InkWell(+ borderRadius: BorderRadius.circular(DesktopChrome.rowRadius),+ onTap: () => unawaited(openInBrowser(Uri.parse(pr))),+ child: fact([+ SvgPicture.asset(+ pullRequestIconAsset('Open'),+ width: 14,+ height: 14,+ colorFilter: ColorFilter.mode(+ DesktopChrome.muted,+ BlendMode.srcIn,+ ),+ ),+ Text(+ _pullRequestLabel(pr),+ style: DesktopChrome.metadata(+ color: DesktopChrome.foreground,+ ),+ ),+ ]),+ ),+ ],+ ),+ ],+ ),+ );+ }+}++/// "#3464" for a GitHub pull request link; "Pull request" for any other.+String _pullRequestLabel(String url) {+ final segments = Uri.tryParse(url)?.pathSegments ?? const <String>[];+ final number = segments.length >= 2 && segments[segments.length - 2] == 'pull'+ ? int.tryParse(segments.last)+ : null;+ return number == null ? 'Pull request' : '#$number';+}diff --git a/desktop/lib/super_tabs/view.dart b/desktop/lib/super_tabs/view.dartindex e1f7dbeba..97127863b 100644--- a/desktop/lib/super_tabs/view.dart+++ b/desktop/lib/super_tabs/view.dart@@ -114,7 +114,9 @@ import 'visible_tick.dart';import 'buddy_rows.dart';import 'task_groups.dart';import 'tasks_view.dart';+import 'chat/agent_chat_header.dart';import 'tasks/personal_tasks_pane.dart';+import 'tasks/task_header.dart';import 'voice_length.dart';import '../widgets/dial_list_scroll.dart';import '../widgets/laid_out_list.dart';@@ -256,6 +258,7 @@ class _SuperTabViewState extends State<SuperTabView>_showManage = _showTasks = _showPullRequests = false;_boardProjectId = null;_agentChatId = id;+ _taskInMiddle = null;});c.select(id);_closeSidebar();@@ -3553,6 +3556,17 @@ class _SuperTabViewState extends State<SuperTabView>_openConversation(id);}+ /// A Tasks card opens its task's chat in the middle under the task's header, never the Board (#4204).+ Future<void> _openPersonalTask(String id) async {+ if (!await c.loadGroup(id) || !mounted) return;+ _openAgentChat(id);+ setState(() => _taskInMiddle = id);+ }++ /// The task opened from its Tasks card, shown under the task's header while it stays the selected chat; the same+ /// chat chosen another way is under its agent's header.+ String? _taskInMiddle;+/// How many of [project]'s tasks need the reader: the Tasks icon's count.int _tasksNeedingYou(SuperTabProject project) => superTabTasksNeedingYouIn(superTabProjectBoard(@@ -3646,33 +3660,27 @@ class _SuperTabViewState extends State<SuperTabView>unawaited(c.select(project.leadConversationId));}- /// The chat of the selected agent in the middle (Swarm v3, task #4118), under its name.+ /// The chat of the selected agent in the middle (Swarm v3, task #4118), under its one-row header; a task opened+ /// from its Tasks card, under the task's header (#4204).Widget _middleChat(Widget chat) {final group = c.selected;+ final task = group != null && group.id == _taskInMiddle+ ? c.personalTasks?.row(group.id)+ : null;return Column(key: const ValueKey('super-middle-chat'),children: [- SizedBox(- height: 44,- child: Row(- children: [- const SizedBox(width: 12),- Expanded(- child: Text(- group?.isBuddyChat == true- ? 'Your Buddy'- : group?.label ?? '',- maxLines: 1,- overflow: TextOverflow.ellipsis,- style: DesktopChrome.control().copyWith(- fontWeight: grid.AppFont.semibold,- ),- ),- ),- const SizedBox(width: 8),- ],- ),- ),+ if (task != null)+ SuperTabTaskHeader(controller: c, task: task)+ else if (group != null)+ SuperTabAgentChatHeader(+ controller: c,+ group: group,+ menu: _options(group),+ app: widget.app,+ )+ else+ const SizedBox(height: 44),Expanded(child: chat),],);@@ -5136,7 +5144,8 @@ class _SuperTabViewState extends State<SuperTabView>),);- Widget _conversation(bool narrow) {+ /// [underHeader]: the chat is under the middle's one-row header, which carries the Buddy's pickers.+ Widget _conversation(bool narrow, {bool underHeader = false}) {// The Desktop keeps an agent's chat open in a Swarm with no projects; with none open, there is nothing to load and// the way to start shows instead (task #4219).if ((!widget.board || c.selected == null) &&@@ -5384,7 +5393,12 @@ class _SuperTabViewState extends State<SuperTabView>crossAxisAlignment: CrossAxisAlignment.stretch,mainAxisSize: MainAxisSize.min,children: [- SuperTabBuddyBar(controller: c, chat: group, app: widget.app),+ SuperTabBuddyBar(+ controller: c,+ chat: group,+ app: widget.app,+ line: !underHeader,+ ),decisions(edge: false),],),@@ -6210,10 +6224,6 @@ class _SuperTabViewState extends State<SuperTabView>!_manageVisible &&!_notificationsVisible &&c.snapshot?.projects.isEmpty != true;- final chat = SuperTabImageGallery(- images: () => _images(_shownMessages(c.selectedId)),- child: _conversation(narrow),- );// With the Tasks slot, a project that is selected shows its Board first, though its chat is the selected// conversation (Swarm v3, task #4118).final impliedBoard = hasTasksPane && !agentChat@@ -6225,6 +6235,16 @@ class _SuperTabViewState extends State<SuperTabView>final boardProject = boardLayout? c.snapshot?.projectById(_boardProjectId ?? impliedBoard ?? '')?.id: null;+ // The chat alone in the middle, under its one-row header (#4204); a project's own chat keeps the full view.+ final fullView =+ !boardLayout ||+ boardProject != null ||+ c.snapshot?.isProjectLead(c.selectedId) == true;+ final underHeader = !fullView && chatInMiddle;+ final chat = SuperTabImageGallery(+ images: () => _images(_shownMessages(c.selectedId)),+ child: _conversation(narrow, underHeader: underHeader),+ );final chatCovered =(narrow && _sidebarOpen) || (!wide && _rosterOpen) || threadDrawer;if (_chatCovered && !chatCovered) {@@ -6283,7 +6303,9 @@ class _SuperTabViewState extends State<SuperTabView>(c.personalTasks?.supported == true? SuperTabPersonalTasksPane(controller: c,- onOpenTask: (id) => unawaited(_openTask(id)),+ selectedId: c.selectedId,+ onOpenTask: (id) =>+ unawaited(_openPersonalTask(id)),): agentChat? const SizedBox.expand()@@ -6305,11 +6327,8 @@ class _SuperTabViewState extends State<SuperTabView>// Over the chat, beside an open thread, as in Slack.over: wide ? viewer : null,// A project's own chat keeps its header and tabs (Project options, Tasks): the full chat view.- center:- boardLayout &&- boardProject == null &&- c.snapshot?.isProjectLead(c.selectedId) != true- ? (chatInMiddle+ center: !fullView+ ? (underHeader? _middleChat(chat): const SizedBox.shrink()): Column(diff --git a/desktop/test/super_tab_agent_chat_header_test.dart b/desktop/test/super_tab_agent_chat_header_test.dartnew file mode 100644index 000000000..a818d6609--- /dev/null+++ b/desktop/test/super_tab_agent_chat_header_test.dart@@ -0,0 +1,158 @@+import 'package:flutter/material.dart';+import 'package:flutter_test/flutter_test.dart';+import 'package:harness/core/runtime_model_name.dart';+import 'package:harness/shared/theme/app_theme.dart' as grid;+import 'package:harness/state/workspace_chrome.dart';+import 'package:harness/super_tabs/controller.dart';+import 'package:harness/super_tabs/identity.dart';+import 'package:harness/super_tabs/view.dart';+import 'package:harness/super_tabs/zone_time.dart';+import 'package:harness/widgets/engine_identity.dart';++import 'super_tab_personal_tasks_pane_test.dart' show TasksFixture;+import 'support/buddy_engine_fixture.dart';++Future<void> show(+ WidgetTester t,+ SuperTabController c, {+ bool tasks = false,+}) async {+ t.view.devicePixelRatio = 1;+ t.view.physicalSize = const Size(1600, 900);+ addTearDown(t.view.reset);+ await t.pumpWidget(+ MaterialApp(+ theme: grid.buildAppTheme(brightness: Brightness.dark),+ home: WorkspaceChromeScope(+ chrome: WorkspaceChrome(compactBelow: 720),+ child: Scaffold(+ body: SuperTabView(+ controller: c,+ board: true,+ // The Desktop's right slot: the chat is in the middle.+ rightPane: tasks ? null : (_) => const SizedBox.expand(),+ onInvite: () {},+ onAddAgent: (_) {},+ onOpenTerminal: (_) {},+ machineName: (_) => 'Kens-MacBook',+ ),+ ),+ ),+ ),+ );+ await t.pumpAndSettle();+}++void main() {+ setUpAll(superTabLoadZones);+ final header = find.descendant(+ of: find.byKey(const ValueKey('super-middle-chat')),+ matching: find.byKey(const ValueKey('super-agent-chat-header')),+ );+ Finder inHeader(Finder f) => find.descendant(of: header, matching: f);+ void oneRow(WidgetTester t, List<Finder> parts) {+ final row = t.getRect(parts.first).center.dy;+ for (final part in parts) {+ expect(part, findsOneWidget);+ expect(t.getRect(part).center.dy, closeTo(row, 4), reason: '$part');+ }+ }++ testWidgets(+ 'the Buddy header is one row: avatar and name, then engine, model and menu',+ (t) async {+ final server = buddyEngineSwarm();+ final c = server.controller(account: 'peer');+ addTearDown(c.dispose);+ await c.refresh();+ await c.select('swarm-buddy-peer');+ await show(t, c);+ expect(header, findsOneWidget);+ final agent = c.snapshot!.agent('wren')!;+ final avatar = inHeader(+ find.byWidgetPredicate(+ (w) => w is SuperTabAvatar && w.identity == 'agent:wren',+ ),+ );+ final name = inHeader(+ find.text(c.snapshot!.agentName('wren', fallback: agent.name)),+ );+ final engine = inHeader(find.byKey(const ValueKey('super-buddy-engine')));+ final model = inHeader(find.byKey(const ValueKey('super-buddy-model')));+ final menu = inHeader(find.byKey(const ValueKey('super-group-options')));+ oneRow(t, [avatar, name, engine, model, menu]);+ expect(t.getRect(avatar).left, lessThan(t.getRect(name).left));+ final middle = t.getRect(header).center.dx;+ expect(t.getRect(engine).left, greaterThan(middle));+ expect(t.getRect(model).left, greaterThan(t.getRect(engine).left));+ expect(t.getRect(menu).left, greaterThan(t.getRect(model).left));+ // No other text, here or on a second line.+ expect(find.textContaining('Kens-MacBook'), findsNothing);+ expect(find.textContaining('reads all your projects'), findsNothing);+ expect(find.textContaining('only you can read this chat'), findsNothing);+ expect(find.text('Your Buddy'), findsNothing);+ },+ );++ testWidgets(+ "a member agent's header shows its engine and model in the same place",+ (t) async {+ final f = TasksFixture();+ addTearDown(f.controller.dispose);+ await f.controller.refresh();+ await f.controller.select('aeef');+ await show(t, f.controller, tasks: true);+ expect(header, findsOneWidget);+ final avatar = inHeader(+ find.byWidgetPredicate(+ (w) => w is SuperTabAvatar && w.identity == 'agent:0540',+ ),+ );+ final engine = inHeader(find.text(engineIdentity('claude').label));+ final model = inHeader(find.text(modelDisplayName('opus')));+ final menu = inHeader(find.byKey(const ValueKey('super-group-options')));+ oneRow(t, [avatar, inHeader(find.text('Hugo')), engine, model, menu]);+ expect(+ inHeader(find.byKey(const ValueKey('super-buddy-engine'))),+ findsNothing,+ );+ expect(t.getRect(engine).left, greaterThan(t.getRect(header).center.dx));+ },+ );++ testWidgets(+ 'with a thread open the Buddy chat is in the full view and keeps its pickers',+ (t) async {+ final server = buddyEngineSwarm();+ server.append('A word', conversationId: 'swarm-buddy-peer');+ (server.state['conversations'] as List).cast<Map>().firstWhere(+ (g) => g['id'] == 'swarm-buddy-peer',+ )['lastMessageSequence'] = 1;+ final c = server.controller(account: 'peer');+ addTearDown(c.dispose);+ await c.refresh();+ await c.select('swarm-buddy-peer');+ await show(t, c);+ c.openThread(c.messages('swarm-buddy-peer').last.id);+ await t.pumpAndSettle();+ expect(header, findsNothing);+ expect(find.byKey(const ValueKey('super-buddy-engine')), findsOneWidget);+ expect(find.byKey(const ValueKey('super-buddy-model')), findsOneWidget);+ },+ );++ testWidgets('the Buddy header says when its shared model is not served', (+ t,+ ) async {+ final server = buddyEngineSwarm();+ (server.state['agents'] as List).cast<Map>().firstWhere(+ (a) => a['id'] == 'wren',+ )['gridModel'] = 'qwen3-coder';+ final c = server.controller(account: 'peer');+ addTearDown(c.dispose);+ await c.refresh();+ await c.select('swarm-buddy-peer');+ await show(t, c);+ expect(inHeader(find.text('not served now')), findsOneWidget);+ });+}diff --git a/desktop/test/super_tab_message_grouping_test.dart b/desktop/test/super_tab_message_grouping_test.dartindex 0c9ba38ff..b5afe1b9d 100644--- a/desktop/test/super_tab_message_grouping_test.dart+++ b/desktop/test/super_tab_message_grouping_test.dart@@ -571,7 +571,16 @@ void main() {'email': '[email protected]','role': 'collaborator',});- final now = DateTime.now().toUtc();+ // The messages span 30 minutes back from now; run within that of local midnight, they fell on two days and a+ // new day starts a new header (CI at 00:29 UTC). Move them back to the day before so they share one day.+ var local = DateTime.now();+ final sinceMidnight = local.difference(+ DateTime(local.year, local.month, local.day),+ );+ if (sinceMidnight < const Duration(minutes: 31)) {+ local = local.subtract(sinceMidnight + const Duration(minutes: 1));+ }+ final now = local.toUtc();void say(String text,Map<String, Object> author,diff --git a/desktop/test/super_tab_personal_tasks_middle_test.dart b/desktop/test/super_tab_personal_tasks_middle_test.dartnew file mode 100644index 000000000..1a67f0577--- /dev/null+++ b/desktop/test/super_tab_personal_tasks_middle_test.dart@@ -0,0 +1,121 @@+import 'package:flutter/material.dart';+import 'package:flutter_test/flutter_test.dart';+import 'package:harness/core/open_in_browser.dart';+import 'package:harness/super_tabs/identity.dart';+import 'package:harness/super_tabs/tasks/personal_task_card.dart';+import 'package:harness/super_tabs/view.dart';+import 'package:harness/super_tabs/zone_time.dart';++import 'super_tab_personal_tasks_pane_test.dart' show TasksFixture;+import 'super_tab_personal_tasks_test.dart' show task;+import 'swarm_state_test.dart' show createApp;++const _title =+ 'Desktop Tasks pane: board-style cards, click opens the task with its chat in the middle; one-row agent chat header';+const _pr = 'https://github.com/autonomous-ai/openharness/pull/3464';++void main() {+ setUpAll(superTabLoadZones);++ testWidgets('a card opens its task with its header and chat in the middle', (+ t,+ ) async {+ final opened = <Uri>[];+ final before = browserOpener;+ browserOpener = (url) async {+ opened.add(url);+ return true;+ };+ addTearDown(() => browserOpener = before);+ final f = TasksFixture()+ ..rows = [+ task('aeef', 1, 20)+ ..['projectId'] = '5701'+ ..['status'] = 'working'+ ..['canApprove'] = false+ ..['title'] = _title+ ..['requester'] = {'id': '6a86', 'name': 'Ken'}+ ..['agent'] = {'id': '0540', 'name': 'Hugo'}+ ..['pullRequestUrl'] = _pr,+ ];+ addTearDown(f.controller.dispose);+ await f.controller.refresh();+ final app = createApp();+ addTearDown(app.dispose);+ t.view.physicalSize = const Size(1600, 1000);+ t.view.devicePixelRatio = 1;+ addTearDown(t.view.reset);+ await t.pumpWidget(+ MaterialApp(+ home: Scaffold(+ body: SuperTabView(+ controller: f.controller,+ app: app,+ board: true,+ machineName: (_) => 'Computer',+ onInvite: () {},+ onAddAgent: (_) {},+ onOpenTerminal: (_) {},+ onNewSwarm: () {},+ ),+ ),+ ),+ );+ await t.pump();+ await t.tap(+ find.descendant(+ of: find.byType(SuperTabPersonalTaskCard),+ matching: find.text(_title),+ ),+ );+ await t.pumpAndSettle();++ expect(f.controller.selectedId, 'aeef');+ expect(find.byKey(const ValueKey('super-board-tab-board')), findsNothing);+ final middle = find.byKey(const ValueKey('super-middle-chat'));+ final header = find.descendant(+ of: middle,+ matching: find.byKey(const ValueKey('super-task-header')),+ );+ expect(header, findsOneWidget);+ Finder inHeader(Finder f) => find.descendant(of: header, matching: f);+ // The full title, never cut.+ final title = t.widget<Text>(inHeader(find.text(_title)));+ expect(title.maxLines, isNull);+ expect(title.overflow, isNot(TextOverflow.ellipsis));+ // It spans the middle from its left edge, never centred in it, a short title too.+ f.rows.single+ ..['title'] = 'Short'+ ..['version'] = 2;+ await f.controller.refresh();+ await t.pump();+ expect(t.getRect(header).left, t.getRect(middle).left);+ expect(t.getRect(header).width, t.getRect(middle).width);+ expect(+ inHeader(find.text(superTabTaskStatusLabel('working'))),+ findsOneWidget,+ );+ expect(inHeader(find.byType(SuperTabTaskStatusMark)), findsOneWidget);+ final person = f.controller.snapshot!.people.single;+ expect(inHeader(find.text(person.shownName)), findsOneWidget);+ expect(inHeader(find.text('Hugo')), findsOneWidget);+ expect(+ t+ .widgetList<SuperTabAvatar>(inHeader(find.byType(SuperTabAvatar)))+ .map((a) => a.identity),+ ['person:6a86', 'agent:0540'],+ );+ await t.tap(inHeader(find.text('#3464')));+ await t.pump();+ expect(opened, [Uri.parse(_pr)]);+ // The card it was opened from stays selected.+ expect(+ t+ .widget<SuperTabPersonalTaskCard>(+ find.byType(SuperTabPersonalTaskCard),+ )+ .selected,+ isTrue,+ );+ });+}diff --git a/desktop/test/super_tab_personal_tasks_pane_test.dart b/desktop/test/super_tab_personal_tasks_pane_test.dartindex 479feef50..6f1e1a5c0 100644--- a/desktop/test/super_tab_personal_tasks_pane_test.dart+++ b/desktop/test/super_tab_personal_tasks_pane_test.dart@@ -12,6 +12,9 @@ import 'package:harness/state/harness_activity.dart';import 'swarm_state_test.dart' show createApp;+import 'package:harness/super_tabs/identity.dart';+import 'package:harness/super_tabs/task_card.dart';+import 'package:harness/super_tabs/tasks/personal_task_card.dart';import 'package:harness/super_tabs/tasks/personal_tasks_pane.dart';import 'super_tab_parts_test.dart' show recorded;@@ -23,7 +26,12 @@ class TasksFixture {bool supported = true, fail = false;Completer<void>? hold;String mode = 'autoApprove';- final rows = [task('old', 1, 10), task('new', 1, 20)];+ var rows = [task('old', 1, 10), task('new', 1, 20)];+ String? olderCursor;+ var olderRows = <Map<String, dynamic>>[];+ final olderReads = <String>[];+ Completer<void>? olderHold;+ bool olderFail = false;final commands = <Map<String, dynamic>>[];final operations = <String>[];late final controller = SuperTabController(@@ -40,6 +48,12 @@ class TasksFixture {if (path.contains('/messages')) {return {'messages': <dynamic>[], 'next': null};}+ if (path.contains('/personal-tasks')) {+ olderReads.add(path);+ await olderHold?.future;+ if (olderFail) throw StateError('fixture private payload');+ return feed(olderRows, mode: mode);+ }if (method == 'POST') {operations.add(body!['operationId'] as String);final command = Map<String, dynamic>.from(body['command'] as Map);@@ -76,6 +90,7 @@ class TasksFixture {rows,reset: path.endsWith('/parts'),mode: mode,+ olderCursor: olderCursor,);}return result;@@ -83,6 +98,9 @@ class TasksFixture {);}+Finder inCard(String id, Finder f) =>+ find.descendant(of: find.byKey(ValueKey('personal-task-$id')), matching: f);+void main() {setUpAll(superTabLoadZones);late TasksFixture f;@@ -155,8 +173,8 @@ void main() {await t.tap(find.text('Task new'));await t.pump();expect(opened, ['new']);- expect(find.text('Approve'), findsNothing);- expect(find.text('Reject'), findsNothing);+ expect(inCard('new', find.text('Approve')), findsNothing);+ expect(inCard('new', find.text('Reject')), findsNothing);expect(find.byType(DropdownButtonFormField<String>), findsNothing);expect(f.commands, isEmpty);f.rows.last['canApprove'] = false;@@ -191,14 +209,17 @@ void main() {f.mode = mode;await f.controller.refresh();await t.pump();- await t.tap(find.text('Task new'));- await t.pump();- expect(find.byType(DropdownButtonFormField<String>), findsOneWidget);- expect(find.widgetWithText(TextButton, 'Reject'), findsOneWidget);- expect(find.widgetWithText(FilledButton, 'Approve'), findsOneWidget);- expect(find.text('Waiting for you'), findsNWidgets(2));+ expect(find.byType(DropdownButtonFormField<String>), findsNothing);+ expect(+ inCard('new', find.widgetWithText(TextButton, 'Reject')),+ findsOneWidget,+ );+ expect(+ inCard('new', find.widgetWithText(FilledButton, 'Approve')),+ findsOneWidget,+ );expect(find.text('Suggested'), findsNothing);- await t.tap(find.text('Approve'));+ await t.tap(inCard('new', find.text('Approve')));await t.pumpAndSettle();expect(f.commands.single, {'type': 'task.approve',@@ -209,12 +230,10 @@ void main() {}testWidgets('approve sends once while waiting and keeps the task', (t) async {await mount(t);- await t.tap(find.text('Task new'));- await t.pump();f.hold = Completer<void>();- await t.tap(find.text('Approve'));+ await t.tap(inCard('new', find.text('Approve')));await t.pump();- await t.tap(find.text('Approve'));+ await t.tap(inCard('new', find.text('Approve')));await t.pump();expect(f.commands.length, 1);f.hold!.complete();@@ -234,9 +253,7 @@ void main() {..['version'] = 2;await f.controller.refresh();await t.pump();- await t.tap(find.text('Task new'));- await t.pump();- await t.tap(find.text('Approve'));+ await t.tap(inCard('new', find.text('Approve')));await t.pumpAndSettle();expect(f.commands.single, {'type': 'task.approve',@@ -246,9 +263,7 @@ void main() {});testWidgets('rejection needs a reason and remains in the list', (t) async {await mount(t);- await t.tap(find.text('Task new'));- await t.pump();- await t.tap(find.text('Reject'));+ await t.tap(inCard('new', find.text('Reject')));await t.pumpAndSettle();expect(f.commands, isEmpty);await t.enterText(@@ -269,10 +284,8 @@ void main() {t,) async {await mount(t);- await t.tap(find.text('Task new'));- await t.pump();f.fail = true;- await t.tap(find.text('Approve'));+ await t.tap(inCard('new', find.text('Approve')));await t.pumpAndSettle();expect(find.textContaining('fixture private'), findsNothing);expect(find.text('Retry'), findsOneWidget);@@ -300,48 +313,12 @@ void main() {expect(find.text('Update Harness to use Tasks.'), findsOneWidget);expect(find.byKey(const ValueKey('tasks-approval-mode')), findsNothing);});- testWidgets(- 'a suggestion changed on another device replaces the displayed choice',- (t) async {- await mount(t);- await t.tap(find.text('Task new'));- await t.pump();- final field = find.byType(DropdownButtonFormField<String>);- expect(t.state<FormFieldState<String>>(field).value, '0540');- f.rows.last['version'] = 2;- f.rows.last['agent'] = {'id': '0fcb', 'name': 'River'};- await f.controller.refresh();- await t.pump();- expect(t.state<FormFieldState<String>>(field).value, '0fcb');- },- );-- testWidgets(- 'a person can change the suggestion without approving or starting work',- (t) async {- await mount(t);- await t.tap(find.text('Task new'));- await t.pump();- await t.tap(find.byType(DropdownButtonFormField<String>));- await t.pumpAndSettle();- await t.tap(find.text('River').last);- await t.pumpAndSettle();- expect(f.commands.single, {- 'type': 'task.suggest',- 'conversationId': 'new',- 'agentId': '0fcb',- });- expect(f.rows.last['status'], 'proposal');- },- );testWidgets('an open rejection cannot be submitted under a replacement account',(t) async {await mount(t);- await t.tap(find.text('Task new'));- await t.pump();- await t.tap(find.text('Reject'));+ await t.tap(inCard('new', find.text('Reject')));await t.pumpAndSettle();await t.enterText(find.byKey(const ValueKey('task-reject-reason')),@@ -403,4 +380,211 @@ void main() {expect(find.text('Task new'), findsOneWidget);},);++ group('older tasks on scroll', () {+ Future<void> many(WidgetTester t, {String? cursor}) async {+ f = TasksFixture()+ ..rows = [for (var i = 0; i < 30; i++) task('t$i', 1, 1000 + i)]+ ..olderCursor = cursor+ ..olderRows = [task('older', 1, 5)];+ addTearDown(() => f.controller.dispose());+ await f.controller.refresh();+ await t.pumpWidget(+ MaterialApp(+ home: Scaffold(+ body: SizedBox(+ width: 340,+ height: 600,+ child: SuperTabPersonalTasksPane(+ controller: f.controller,+ onOpenTask: (_) {},+ ),+ ),+ ),+ ),+ );+ }++ Future<void> toEnd(WidgetTester t) async {+ await t.drag(find.byType(Scrollable).last, const Offset(0, -10000));+ await t.pump();+ }++ testWidgets('reaching the end reads the older page once', (t) async {+ await many(t, cursor: 'c 1');+ f.olderHold = Completer<void>();+ await toEnd(t);+ await toEnd(t);+ expect(f.olderReads, [+ '/api/super-tabs/c51479bd73b59e58176ad9e4/personal-tasks?before=c%201',+ ]);+ f.olderHold!.complete();+ await t.pumpAndSettle();+ await toEnd(t);+ expect(find.text('Task older'), findsOneWidget);+ // The page had no cursor after it: the end was reached, and nothing more is read.+ expect(f.olderReads.length, 1);+ });++ testWidgets('a feed without a cursor never reads older pages', (t) async {+ await many(t);+ await toEnd(t);+ expect(f.olderReads, isEmpty);+ });++ testWidgets('a failed older read says so and retries', (t) async {+ await many(t, cursor: 'c1');+ f.olderFail = true;+ await toEnd(t);+ await t.pumpAndSettle();+ expect(find.text('Could not load older tasks.'), findsOneWidget);+ expect(find.textContaining('fixture private'), findsNothing);+ f.olderFail = false;+ await t.tap(find.byKey(const ValueKey('tasks-older-retry')));+ await t.pumpAndSettle();+ await toEnd(t);+ expect(find.text('Task older'), findsOneWidget);+ expect(f.olderReads.length, 2);+ });+ });++ group('card', () {+ testWidgets(+ 'shows the tag, a three-line title, the mark top right and two avatars without names',+ (t) async {+ f = TasksFixture()+ ..rows = [+ task('new', 1, 20)+ ..['status'] = 'working'+ ..['canApprove'] = false+ ..['title'] = 'A long task title ' * 12+ ..['requester'] = {'id': '6a86', 'name': 'Requester name'},+ ];+ addTearDown(() => f.controller.dispose());+ await f.controller.refresh();+ await t.pumpWidget(+ MaterialApp(+ home: Scaffold(+ body: SizedBox(+ width: 340,+ child: SuperTabPersonalTasksPane(+ controller: f.controller,+ onOpenTask: (_) {},+ ),+ ),+ ),+ ),+ );+ final card = find.byKey(const ValueKey('personal-task-new'));+ final tag = inCard(+ 'new',+ find.byKey(const ValueKey('personal-task-tag')),+ );+ final title = inCard('new', find.textContaining('A long task title'));+ final mark = inCard(+ 'new',+ find.byWidgetPredicate((w) => w is ActivityMark),+ );+ expect(t.widget<Text>(title).maxLines, 3);+ expect(+ t.widget<DecoratedBox>(tag).decoration,+ isA<BoxDecoration>().having(+ (d) => d.color,+ 'color',+ superTabProjectColor('lead5701'),+ ),+ );+ // The mark sits top right: above the title, at the card's right side.+ expect(t.getRect(mark).bottom, lessThanOrEqualTo(t.getRect(title).top));+ expect(+ t.getRect(mark).right,+ closeTo(+ t+ .getRect(+ inCard('new', find.byType(SuperTabPersonalTaskCard)),+ )+ .right -+ SuperTabTaskCard.tilePadding,+ 2,+ ),+ );+ // Two avatars bottom left, who asked first; no names, priority or checks.+ final avatars = inCard('new', find.byType(SuperTabAvatar));+ expect(avatars, findsNWidgets(2));+ final asked = t.getRect(avatars.at(0)),+ agent = t.getRect(avatars.at(1));+ expect(t.widget<SuperTabAvatar>(avatars.at(0)).identity, 'person:6a86');+ expect(asked.left, lessThan(agent.left));+ expect(agent.right, lessThan(t.getRect(card).center.dx));+ expect(asked.top, greaterThan(t.getRect(title).bottom));+ expect(find.text('Requester name'), findsNothing);+ expect(find.text('Old name'), findsNothing);+ expect(find.textContaining('P0'), findsNothing);+ expect(find.textContaining('/'), findsNothing);+ },+ );++ testWidgets('a waiting card opens its task too', (t) async {+ final opened = <String>[];+ await mount(t);+ await t.pumpWidget(+ MaterialApp(+ home: Scaffold(+ body: SizedBox(+ width: 340,+ child: SuperTabPersonalTasksPane(+ controller: f.controller,+ onOpenTask: opened.add,+ ),+ ),+ ),+ ),+ );+ await t.tap(find.text('Task new'));+ await t.pump();+ expect(opened, ['new']);+ expect(f.commands, isEmpty);+ });++ test('a project keeps its colour', () {+ expect(+ superTabProjectColor('lead5701'),+ superTabProjectColor('lead5701'),+ );+ expect(+ {+ for (final id in ['a', 'b', 'c', 'd', 'e', 'f', 'g'])+ superTabProjectColor(id),+ }.length,+ greaterThan(1),+ );+ });+ });++ testWidgets('while a change is sent, Approve and Reject are disabled', (+ t,+ ) async {+ await mount(t);+ f.hold = Completer<void>();+ await t.tap(inCard('new', find.text('Approve')));+ await t.pump();+ for (final id in ['new', 'old']) {+ expect(+ t.widget<FilledButton>(inCard(id, find.byType(FilledButton))).onPressed,+ isNull,+ );+ expect(+ t.widget<TextButton>(inCard(id, find.byType(TextButton))).onPressed,+ isNull,+ );+ }+ f.hold!.complete();+ await t.pumpAndSettle();+ expect(+ t+ .widget<FilledButton>(inCard('old', find.byType(FilledButton)))+ .onPressed,+ isNotNull,+ );+ });}diff --git a/desktop/test/super_tab_personal_tasks_test.dart b/desktop/test/super_tab_personal_tasks_test.dartindex 1b3d73b5d..80c5bca9e 100644--- a/desktop/test/super_tab_personal_tasks_test.dart+++ b/desktop/test/super_tab_personal_tasks_test.dart@@ -20,11 +20,13 @@ Map<String, dynamic> feed(bool reset = false,List<String> removed = const [],String mode = 'autoApprove',+ String? olderCursor,}) => {'approvalMode': mode,'reset': reset,'upserts': rows,'removed': removed,+ 'olderCursor': ?olderCursor,};void main() {test('old backend has no capability; first load sorts newest then id', () {@@ -127,4 +129,84 @@ void main() {);expect(restored.personalTasks.rows, isEmpty);});+ test('rows read who asked and the PR; an older backend sends neither', () {+ final parts = SuperTabParts.firstLoad(+ recorded('first_load')+ ..['personalTasks'] = feed([+ task('a', 1, 20)+ ..['requester'] = {'id': '6a8f', 'name': 'Dee'}+ ..['pullRequestUrl'] =+ 'https://github.com/autonomous-ai/openharness/pull/3464',+ task('b', 1, 10),+ ], reset: true),+ );+ final [a, b] = parts.personalTasks.rows;+ expect(a.requesterId, '6a8f');+ expect(a.requester['name'], 'Dee');+ expect(+ a.pullRequestUrl,+ 'https://github.com/autonomous-ai/openharness/pull/3464',+ );+ expect(b.requester, isEmpty);+ expect(b.requesterId, isNull);+ expect(b.pullRequestUrl, isNull);+ });+ test('an older page adds rows below and moves the cursor', () {+ final parts = SuperTabParts.firstLoad(+ recorded('first_load')+ ..['personalTasks'] = feed(+ [task('a', 2, 40), task('b', 1, 30)],+ reset: true,+ olderCursor: 'c1',+ ),+ );+ final tasks = parts.personalTasks;+ expect(tasks.olderCursor, 'c1');+ final changed = tasks.applyOlder({+ 'upserts': [task('c', 1, 20), task('d', 1, 10), task('a', 1, 5)],+ 'olderCursor': null,+ }, from: 'c1');+ expect(changed, isTrue);+ expect(tasks.rows.map((r) => r.id), ['a', 'b', 'c', 'd']);+ expect(tasks.rows.first.version, 2);+ expect(tasks.olderCursor, isNull);+ // The cache keeps the cursor, so a restart can still load older pages.+ parts.apply(+ recorded('changes')+ ..['personalTasks'] = feed([], reset: true, olderCursor: 'c9'),+ );+ expect(+ SuperTabParts.fromJson(parts.toJson()).personalTasks.olderCursor,+ 'c9',+ );+ });+ test('an older page read before a reset is dropped', () {+ final parts = SuperTabParts.firstLoad(+ recorded('first_load')+ ..['personalTasks'] = feed(+ [task('a', 1, 40)],+ reset: true,+ olderCursor: 'c1',+ ),+ );+ // The feed resets while the read of the page after 'c1' is out.+ parts.apply(+ recorded('changes')+ ..['personalTasks'] = feed(+ [task('n', 1, 50)],+ reset: true,+ olderCursor: 'c2',+ ),+ );+ final tasks = parts.personalTasks;+ expect(+ tasks.applyOlder({+ 'upserts': [task('old', 1, 1)],+ 'olderCursor': null,+ }, from: 'c1'),+ isFalse,+ );+ expect(tasks.rows.map((r) => r.id), ['n']);+ expect(tasks.olderCursor, 'c2');+ });}diff --git a/desktop/test/super_tab_reject_dialog_test.dart b/desktop/test/super_tab_reject_dialog_test.dartindex 0cd0adeed..eb657a21b 100644--- a/desktop/test/super_tab_reject_dialog_test.dart+++ b/desktop/test/super_tab_reject_dialog_test.dart@@ -1,7 +1,6 @@-// Task #4251 (finding 10 of #4211): Reject's dialog names the task, and the open row's agent picker reads at the-// row's own text size.+// Task #4251 (finding 10 of #4211): Reject's dialog names the task. The rows' agent picker it also styled went with+// #4204's cards, which have no agent switch.import 'package:flutter/material.dart';-import 'package:flutter/rendering.dart';import 'package:flutter_test/flutter_test.dart';import 'package:harness/super_tabs/tasks/personal_tasks_pane.dart';import 'package:harness/super_tabs/zone_time.dart';@@ -29,17 +28,18 @@ void main() {),),);- await t.tap(find.text(title));- await t.pump();return f;}- TextStyle drawn(WidgetTester t, Finder text) =>- t.renderObject<RenderParagraph>(text).text.style!;+ // Each waiting card has its own Reject: the one on this task's card.+ final reject = find.descendant(+ of: find.byKey(const ValueKey('personal-task-new')),+ matching: find.text('Reject'),+ );testWidgets('the Reject dialog names the task', (t) async {await mount(t, 'Add the project export');- await t.tap(find.text('Reject'));+ await t.tap(reject);await t.pumpAndSettle();expect(find.descendant(@@ -56,7 +56,7 @@ void main() {) async {final title = 'Add the project export ${'with every column ' * 12}';await mount(t, title);- await t.tap(find.text('Reject'));+ await t.tap(reject);await t.pumpAndSettle();final heading = find.descendant(of: find.byType(AlertDialog),@@ -65,24 +65,4 @@ void main() {expect(heading, findsOneWidget);expect(t.takeException(), isNull);});-- testWidgets("the suggested-agent picker uses the row's text style", (- t,- ) async {- await mount(t, 'Add the project export');- final picker = find.byKey(const ValueKey('task-agent-new'));- final choice = find.descendant(of: picker, matching: find.byType(Text));- final title = drawn(t, find.text('Add the project export'));- // The field's label is its own; the chosen agent's name is the row's size.- final name = choice- .evaluate()- .map((e) => e.widget as Text)- .firstWhere((w) => w.data != 'Suggested agent');- final agent = drawn(- t,- find.descendant(of: picker, matching: find.text(name.data!)).first,- );- expect(agent.fontSize, title.fontSize);- expect(agent.fontWeight, title.fontWeight);- });}diff --git a/desktop/test/super_tab_task_cards_shots_test.dart b/desktop/test/super_tab_task_cards_shots_test.dartnew file mode 100644index 000000000..18b67781f--- /dev/null+++ b/desktop/test/super_tab_task_cards_shots_test.dart@@ -0,0 +1,172 @@+import 'dart:io';++import 'package:flutter/material.dart';+import 'package:flutter_test/flutter_test.dart';+import 'package:harness/shared/theme/app_theme.dart' as grid;+import 'package:harness/state/workspace_chrome.dart';+import 'package:harness/super_tabs/controller.dart';+import 'package:harness/super_tabs/tasks/personal_task_card.dart';+import 'package:harness/super_tabs/tasks/personal_tasks_pane.dart';+import 'package:harness/super_tabs/view.dart';+import 'package:harness/super_tabs/zone_time.dart';++import 'super_tab_personal_tasks_pane_test.dart' show TasksFixture;+import 'super_tab_personal_tasks_test.dart' show task;+import 'support/buddy_engine_fixture.dart';+import 'support/capture.dart';+import 'swarm_state_test.dart' show createApp;++/// Pictures of #4204 for its pull request: HARNESS_TASK_CARDS_SHOTS=<dir> writes them; without it they only lay out.+void main() {+ final shots = Platform.environment['HARNESS_TASK_CARDS_SHOTS'];+ setUpAll(() async {+ await loadCaptureFonts(shots);+ await superTabLoadZones();+ });++ List<Map<String, dynamic>> rows() => [+ {+ ...task('aeef', 1, 50),+ 'projectId': '5701',+ 'title': 'Desktop Tasks pane: board-style cards, click opens the task with its chat in the middle',+ 'status': 'working',+ 'canApprove': false,+ 'requester': {'id': '6a86', 'name': 'Ken'},+ 'agent': {'id': '0540', 'name': 'Hugo'},+ 'pullRequestUrl':+ 'https://github.com/autonomous-ai/openharness/pull/3464',+ },+ {+ ...task('waiting', 1, 40),+ 'projectId': 'desktop',+ 'projectName': 'Desktop',+ 'title': 'Add the project export',+ 'requester': {'id': '6a86', 'name': 'Ken'},+ },+ {+ ...task('rejected', 1, 30),+ 'projectId': 'cli',+ 'projectName': 'CLI',+ 'title': 'Expand the settings page',+ 'status': 'rejected',+ 'canApprove': false,+ },+ {+ ...task('done', 1, 20),+ 'projectId': '5701',+ 'title': 'Repair the retry state after a lost connection, so a dropped read never leaves the pane empty',+ 'status': 'done',+ 'canApprove': false,+ 'requester': {'id': '6a86', 'name': 'Ken'},+ },+ ];++ Widget themed(Brightness brightness, Widget child) => MaterialApp(+ debugShowCheckedModeBanner: false,+ theme: grid.buildAppTheme(brightness: brightness),+ home: WorkspaceChromeScope(+ chrome: WorkspaceChrome(compactBelow: 720),+ child: Scaffold(body: child),+ ),+ );++ void size(WidgetTester t, Size size, Brightness brightness) {+ t.view.physicalSize = size;+ t.view.devicePixelRatio = 1;+ addTearDown(t.view.reset);+ grid.AppTheme.brightness.value = brightness;+ addTearDown(() => grid.AppTheme.brightness.value = Brightness.light);+ }++ Widget view(SuperTabController c, {bool tasksPane = true}) {+ final app = createApp();+ addTearDown(app.dispose);+ return SuperTabView(+ controller: c,+ app: app,+ board: true,+ rightPane: tasksPane ? null : (_) => const SizedBox.expand(),+ machineName: (_) => 'Kens-MacBook',+ onInvite: () {},+ onAddAgent: (_) {},+ onOpenTerminal: (_) {},+ onNewSwarm: () {},+ );+ }++ for (final brightness in Brightness.values) {+ final b = brightness.name;+ testWidgets('Tasks pane cards, $b', (t) async {+ size(t, const Size(340, 760), brightness);+ final empty = TasksFixture()..rows = [];+ addTearDown(empty.controller.dispose);+ await empty.controller.refresh();+ await t.pumpWidget(+ themed(+ brightness,+ SuperTabPersonalTasksPane(+ controller: empty.controller,+ onOpenTask: (_) {},+ ),+ ),+ );+ await t.pumpAndSettle();+ expect(t.takeException(), isNull);+ await captureWindow(t, shots, 'cards-0-$b');+ final f = TasksFixture()+ ..rows = rows()+ ..mode = 'review';+ addTearDown(f.controller.dispose);+ await f.controller.refresh();+ await t.pumpWidget(+ themed(+ brightness,+ SuperTabPersonalTasksPane(+ controller: f.controller,+ onOpenTask: (_) {},+ selectedId: 'aeef',+ ),+ ),+ );+ await t.pumpAndSettle();+ expect(t.takeException(), isNull);+ await captureWindow(t, shots, 'cards-$b');+ });++ testWidgets('a task opened in the middle, $b', (t) async {+ size(t, const Size(1440, 800), brightness);+ final f = TasksFixture()..rows = rows();+ addTearDown(f.controller.dispose);+ await f.controller.refresh();+ await t.pumpWidget(themed(brightness, view(f.controller)));+ await t.pump();+ await t.tap(+ find.descendant(+ of: find.byKey(const ValueKey('personal-task-aeef')),+ matching: find.byType(SuperTabPersonalTaskCard),+ ),+ );+ await t.pumpAndSettle();+ expect(t.takeException(), isNull);+ expect(find.byKey(const ValueKey('super-task-header')), findsOneWidget);+ await captureWindow(t, shots, 'task-middle-$b');+ });++ testWidgets('the Buddy chat header, $b', (t) async {+ size(t, const Size(1440, 500), brightness);+ final server = buddyEngineSwarm();+ final c = server.controller(account: 'peer');+ addTearDown(c.dispose);+ await c.refresh();+ await c.select('swarm-buddy-peer');+ await t.pumpWidget(themed(brightness, view(c, tasksPane: false)));+ await t.pumpAndSettle();+ expect(t.takeException(), isNull);+ expect(+ find.byKey(const ValueKey('super-agent-chat-header')),+ findsOneWidget,+ );+ await captureWindow(t, shots, 'buddy-header-$b');+ });+ }+}diff --git a/desktop/test/super_tab_tasks_pane_surface_test.dart b/desktop/test/super_tab_tasks_pane_surface_test.dartindex c86aadd0a..875db067d 100644--- a/desktop/test/super_tab_tasks_pane_surface_test.dart+++ b/desktop/test/super_tab_tasks_pane_surface_test.dart@@ -5,6 +5,7 @@ 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/identity.dart';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';@@ -159,8 +160,21 @@ void main() {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);+ // The card with no agent is on screen, as the person's own task, with no agent avatar (#4204's cards+ // name nobody).+ if (count > 1) {+ final card = find.byKey(const ValueKey('personal-task-row1'));+ expect(card, findsOneWidget);+ expect(+ find.descendant(+ of: card,+ matching: find.byWidgetPredicate(+ (w) => w is SuperTabAvatar && w.identity.startsWith('agent:'),+ ),+ ),+ findsNothing,+ );+ }}expect(await strayPixels(t), isEmpty);await captureWindow(diff --git a/docs/plans/2026-11-07-tasks-pane-cards-plan.md b/docs/plans/2026-11-07-tasks-pane-cards-plan.mdnew file mode 100644index 000000000..81f275db0--- /dev/null+++ b/docs/plans/2026-11-07-tasks-pane-cards-plan.md@@ -0,0 +1,145 @@+# Tasks pane cards and one-row agent chat header Implementation Plan++> Work this plan task by task, test first: each task's failing test is committed and watched failing before the code+> that passes it. One Engineer implements it in this session; the pull request's review step is the one independent+> review.++**Goal:** The right Tasks pane shows board-style cards, newest first with older ones loaded on scroll; a card opens its+task in the middle with its chat; every agent's chat header is one row (task #4204, anh Dee 2026-11-07 06:20 VN).++**Architecture:** The feed row model (`personal_tasks.dart`) reads the extra fields of the backend feed (#4203) and+keeps an older-page cursor. A new card widget draws one row of the pane. The middle shows a task through the existing+agent-chat path in `view.dart`, under a new task header. A new `chat/agent_chat_header.dart` replaces the middle+chat's name row and the Buddy bar's text line.++**Tech Stack:** Flutter (Desktop), `flutter_test` widget tests, the Harness design tokens (`AppDesktop`, `DesktopChrome`,+`AppPalette`).++**Spec:** the task brief of #4204 and anh Dee's message of 2026-11-07 06:14 VN (proposal #4202), quoted in the task.++## Global Constraints++- Change the delta to today's UI only; builds on #4191 (PR #3461), which merges first.+- Ships in Desktop 1.3.88 with #4192 and #4196; those also touch `view.dart`, so its changes stay small wiring.+- Card: project as a coloured tag, status mark top right, title up to three lines, two avatars and no names bottom left+ (who asked, then the agent); no priority, no check counts. In Review a waiting card shows Approve and Reject bottom+ right, with no agent switch.+- Click: the task opens in the middle (not the board): full title, status, who asked, agent and PR, then its chat; the+ card stays selected; the board stays under Projects.+- Header: one row: avatar and name left; engine picker, model picker and the menu right. No machine name, no+ "reads all your projects", no "only you can read this chat".+- Light and dark pictures; widget tests. Design tokens only (`scripts/check-ui-style.py`).+- Older Desktop rows stay readable: every new feed field is optional.++## Review Focus++- A row without `requester` (older backend or a proposal nobody owns): the card shows the agent avatar alone, no gap.+- A feed without `olderCursor` (backend before #4203): no "load older" request is ever sent.+- Scrolling to the end twice quickly sends one older-page read, not two.+- A non-Buddy agent: the server offers no engine or model switch for it, so its engine and model show as plain labels in+ the same place; a Buddy keeps its working pickers.+- A task the reader opens from a card and then archives: the middle keeps the chat until another is chosen.++---++### Task 1: Feed rows carry who asked, the PR and an older-page cursor++**Files:**+- Modify: `desktop/lib/super_tabs/tasks/personal_tasks.dart`+- Test: `desktop/test/super_tab_personal_tasks_test.dart`++**Interfaces:**+- Produces: `SuperTabPersonalTask.requester` (`Map<String, dynamic>`, empty when absent), `requesterId` (`String?`),+ `pullRequestUrl` (`String?`); `SuperTabPersonalTasks.olderCursor` (`String?`), `bool applyOlder(Object? page)` which+ adds rows of a `{upserts, olderCursor}` page without dropping newer ones.++- [ ] Step 1: tests `rows read who asked and the PR` (requester id/name, pullRequestUrl from a row; absent → empty map+ and null) and `an older page adds rows and moves the cursor` (first load `olderCursor: 'c1'`, `applyOlder` with two+ older rows and `olderCursor: null` → four rows newest first, `olderCursor` null; a stale version is ignored).+- [ ] Step 2: run `flutter test test/super_tab_personal_tasks_test.dart`; expect FAIL (no such getters).+- [ ] Step 3: add the getters; `apply` keeps `olderCursor` from a reset load; `applyOlder` reuses the version check.+- [ ] Step 4: run the same test; expect PASS. Commit test, then code.++### Task 2: Older tasks load on scroll++**Files:**+- Modify: `desktop/lib/super_tabs/controller.dart` (one method), `desktop/lib/super_tabs/tasks/personal_tasks_pane.dart`+- Test: `desktop/test/super_tab_personal_tasks_pane_test.dart`++**Interfaces:**+- Consumes: Task 1's `olderCursor`, `applyOlder`.+- Produces: `Future<void> SuperTabController.loadOlderPersonalTasks()`: one read in flight at most;+ `GET $_path/personal-tasks?before=<olderCursor>` (the read Feedfix names in #4203; this path changes to match it).++- [ ] Step 1: test `scrolling to the end reads the older page once`: a feed of 30 rows with `olderCursor: 'c1'`; drag to+ the end twice → exactly one GET with `before=c1`; its rows appear below. Test `no cursor, no read`.+- [ ] Step 2: run; expect FAIL.+- [ ] Step 3: implement; the pane calls it when the list is within one screen of its end.+- [ ] Step 4: run; expect PASS. Commit test, then code.++### Task 3: The card++**Files:**+- Create: `desktop/lib/super_tabs/tasks/personal_task_card.dart`+- Modify: `desktop/lib/super_tabs/tasks/personal_tasks_pane.dart` (rows use the card; the expanded agent switch goes)+- Test: `desktop/test/super_tab_personal_tasks_pane_test.dart`++**Interfaces:**+- Produces: `SuperTabPersonalTaskCard({task, project, projectColor, requester, agent, selected, onOpen, onApprove,+ onReject})`; `Color superTabProjectColor(String projectId)`, a stable pick from `AppPalette.avatarPalette`.++- [ ] Step 1: tests: `card shows tag, three-line title, mark top right, two avatars and no names` (finds the project+ text, `Text.maxLines == 3`, the mark's top-right lies right of and above the title, two `SuperTabAvatar`s left of+ centre, no agent or requester name text, no priority or check text); `a waiting card shows Approve and Reject and+ no agent switch` (buttons send `task.approve` / the reject dialog; no `task-agent-*` field); `a card opens its+ task` (tap → `onOpenTask(id)`, also for a waiting one).+- [ ] Step 2: run; expect FAIL.+- [ ] Step 3: build the card with the board tile's border, radius and padding (`SuperTabTaskCard.tilePadding`), the tag+ in `superTabProjectColor` with white text like a lane label.+- [ ] Step 4: run; expect PASS. Commit test, then code.++### Task 4: A card opens the task in the middle++**Files:**+- Create: `desktop/lib/super_tabs/tasks/task_header.dart`+- Modify: `desktop/lib/super_tabs/view.dart` (`onOpenTask` and `_middleChat` wiring only)+- Test: `desktop/test/super_tab_personal_tasks_middle_test.dart`++**Interfaces:**+- Consumes: Task 1's row getters; `SuperTabPersonalTasksPane.selectedId` (new, `String?`).+- Produces: `SuperTabTaskHeader({task, controller})`: full title, status mark and word, who asked, agent, PR link.++- [ ] Step 1: test `a card opens the task with its header and chat in the middle`: full view with a feed row; tap the+ card → `super-middle-chat` holds `super-task-header` with the full title, requester and agent names and the PR+ link; no board is shown; the card is selected.+- [ ] Step 2: run; expect FAIL.+- [ ] Step 3: `onOpenTask` loads the group and opens it through `_openAgentChat`; `_middleChat` shows the task header+ for a task; the pane gets `selectedId: c.selectedId`.+- [ ] Step 4: run; expect PASS. Commit test, then code.++### Task 5: One-row agent chat header++**Files:**+- Create: `desktop/lib/super_tabs/chat/agent_chat_header.dart`+- Modify: `desktop/lib/super_tabs/view.dart` (`_middleChat` uses it), `desktop/lib/super_tabs/buddies.dart` (the bar's+ text line goes), `desktop/lib/super_tabs/buddy_model.dart` (pickers only, no trailing text)+- Test: `desktop/test/super_tab_agent_chat_header_test.dart`++**Interfaces:**+- Produces: `SuperTabAgentChatHeader({controller, group, agent, menu})`: avatar and name left; for the reader's own+ Buddy `BuddyEnginePicker` and the model picker, else the engine and model as labels; `menu` (the existing ⋮) right.++- [ ] Step 1: tests: `Buddy header is one row with pickers and menu` (all children share one baseline row; finds+ `super-buddy-engine`, `super-buddy-model`, `super-group-options`; finds no machine name, no "reads all your+ projects", no "only you can read this chat"); `member agent header shows engine and model as labels`.+- [ ] Step 2: run; expect FAIL.+- [ ] Step 3: implement and wire; the Buddy bar keeps its limit and Start again rows.+- [ ] Step 4: run the new test and `super_tab_buddies_test.dart`; expect PASS. Commit test, then code.++### Task 6: Pictures++**Files:**+- Modify: `desktop/test/super_tab_personal_tasks_shots_test.dart`++- [ ] Step 1: capture light and dark pictures of the pane (0, 2, many, one waiting in Review), the middle task view and+ the header; attach them to the PR.diff --git a/mobile/lib/swarm/tasks/personal_tasks.dart b/mobile/lib/swarm/tasks/personal_tasks.dartindex 29951e74b..403f01bf4 100644--- a/mobile/lib/swarm/tasks/personal_tasks.dart+++ b/mobile/lib/swarm/tasks/personal_tasks.dart@@ -21,6 +21,12 @@ class SuperTabPersonalTask {Map<String, dynamic> get agent =>json['agent'] == null ? const {} : superTabMap(json['agent']);String? get agentId => agent['id'] as String?;++ /// The person who asked; empty from a backend before #4203.+ Map<String, dynamic> get requester =>+ json['requester'] == null ? const {} : superTabMap(json['requester']);+ String? get requesterId => requester['id'] as String?;+ String? get pullRequestUrl => json['pullRequestUrl'] as String?;}/// Lives with the parts cursor and is discarded with it on access revocation.@@ -28,6 +34,9 @@ class SuperTabPersonalTask {class SuperTabPersonalTasks {bool supported = false;String mode = 'autoApprove';++ /// Where the next older page starts; null when there is none, or the backend pages nothing.+ String? olderCursor;final _rows = <String, SuperTabPersonalTask>{};final _versions = <String, int>{};List<SuperTabPersonalTask>? _ordered;@@ -52,11 +61,29 @@ class SuperTabPersonalTasks {changed = true;_rows.clear();_versions.clear();+ olderCursor = value['olderCursor'] as String?;}for (final id in value['removed'] as List? ?? const []) {if (id is String && _rows.remove(id) != null) changed = true;}- for (final raw in value['upserts'] as List? ?? const []) {+ if (_upsert(value['upserts'])) changed = true;+ if (changed) _ordered = null;+ return changed;+ }++ /// Adds an older page, read [from] a cursor, below the rows held, and moves [olderCursor] past it. A page read+ /// before a reset moved the cursor is dropped: its range may no longer follow the rows held.+ bool applyOlder(Object? page, {required String from}) {+ if (page is! Map || olderCursor != from) return false;+ olderCursor = page['olderCursor'] as String?;+ final changed = _upsert(page['upserts']);+ if (changed) _ordered = null;+ return changed;+ }++ bool _upsert(Object? upserts) {+ var changed = false;+ for (final raw in upserts as List? ?? const []) {final row = superTabMap(raw);if (row['id'] is! String || row['version'] is! num || row['at'] is! num) {throw const FormatException('Could not read a task summary.');@@ -67,10 +94,12 @@ class SuperTabPersonalTasks {_rows[task.id] = task;changed = true;}- if (changed) _ordered = null;return changed;}+ /// The row of task [id], or null when the feed holds none.+ SuperTabPersonalTask? row(String id) => _rows[id];+Map<String, int> get versions => Map.unmodifiable(_versions);/// Cache tombstones share the cursor's lifetime, so its overlap stays idempotent after restart.@@ -91,5 +120,6 @@ class SuperTabPersonalTasks {'reset': true,'upserts': [for (final row in rows) row.json],'removed': <String>[],+ 'olderCursor': ?olderCursor,};}