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: personal Tasks and approval controls (#3452)
harness-for-autonomous[bot]3932fd2c7f49
diff --git a/desktop/lib/super_tabs/controller.dart b/desktop/lib/super_tabs/controller.dartindex b04f58894..872461f68 100644--- a/desktop/lib/super_tabs/controller.dart+++ b/desktop/lib/super_tabs/controller.dart@@ -23,6 +23,7 @@ import 'task_groups.dart';import 'buddy_chat.dart';import 'project_github.dart';import 'parts.dart';+import 'tasks/personal_tasks.dart';import 'read_marks.dart';import 'reading.dart';import 'linked_tasks.dart';@@ -437,6 +438,8 @@ class SuperTabController extends ChangeNotifier {/// The Swarm's parts as last read: what the next read asks changes for, and what [snapshot] is built from.SuperTabParts? _parts;+ SuperTabPersonalTasks? get personalTasks => _parts?.personalTasks;+/// 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/parts.dart b/desktop/lib/super_tabs/parts.dartindex 0b7b829f2..cb8605ff7 100644--- a/desktop/lib/super_tabs/parts.dart+++ b/desktop/lib/super_tabs/parts.dart@@ -1,6 +1,7 @@import 'package:collection/collection.dart' show DeepCollectionEquality;import 'model.dart';+import 'tasks/personal_tasks.dart';/// The response shape a Swarm read answers in (docs/design/2026-10-26-swarm-state-parts.md, section 4), mirrored by/// hand from backend `superTabs/read/contract.ts` (final at cd004bf5c). A first load of any other format is from a@@ -88,6 +89,7 @@ class SuperTabParts {parts._seen['$kind:${part['key']}'] = _int(part['version']);}}+ parts.personalTasks.apply(answer['personalTasks']);parts._takeReadMarks(marks);// Every one is news to a device whose own mark is higher.parts._takeUnreadMarks(unreadMarks, all: true);@@ -114,6 +116,7 @@ class SuperTabParts {}}}+ parts.personalTasks.restoreVersions(json['personalTaskVersions']);parts._takeReadMarks(json['readMarks']);parts._takeThreadMarks(json['threadMarks']);parts._takeChatSettings(json['chatSettings']);@@ -153,6 +156,8 @@ class SuperTabParts {_ => null,};+ final personalTasks = SuperTabPersonalTasks();+Map<String, dynamic> _head;Map<String, dynamic> _derived;final _live = <String, Map<String, Map<String, dynamic>>>{};@@ -370,6 +375,9 @@ class SuperTabParts {_derived = derived;changed = true;}+ if (personalTasks.apply(changes['personalTasks'])) {+ changed = beyondMachines = true;+ }derivedEtag = etag;cursor = _cursor(changes);epoch = _int(changes['epoch'] ?? epoch);@@ -533,11 +541,13 @@ class SuperTabParts {'lastChangedAt': lastChangedAt,'githubApp': githubApp,'head': _head,+ if (personalTasks.supported) 'personalTasks': personalTasks.toJson(),for (final kind in _lists)kind: (_live[kind] ?? const {}).values.toList(),'derived': _derived,if (derivedEtag != null) 'derivedEtag': derivedEtag,},+ if (personalTasks.supported) 'personalTaskVersions': personalTasks.versions,'dormant': _dormant.values.toList(),'seen': Map<String, int>.of(_seen),'stale': _stale.toList(),diff --git a/desktop/lib/super_tabs/tasks/personal_tasks.dart b/desktop/lib/super_tabs/tasks/personal_tasks.dartnew file mode 100644index 000000000..11b13adf6--- /dev/null+++ b/desktop/lib/super_tabs/tasks/personal_tasks.dart@@ -0,0 +1,90 @@+import '../model.dart';++/// A server-filtered summary, never a local inference about who requested work.+class SuperTabPersonalTask {+ SuperTabPersonalTask(Map<String, dynamic> row) : json = Map.unmodifiable(row);+ final Map<String, dynamic> json;+ String get id => json['id'] as String;+ int get version => (json['version'] as num).toInt();+ int get at => (json['at'] as num).toInt();+ String get projectId => json['projectId'] as String? ?? '';+ String get projectName => json['projectName'] as String? ?? 'Project';+ String get title => json['title'] as String? ?? 'Task';+ String get status => json['status'] as String? ?? 'working';+ 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']);+ String? get agentId => agent['id'] as String?;+}++/// Lives with the parts cursor and is discarded with it on access revocation.+/// No separate timer or request; overlap versions are applied once.+class SuperTabPersonalTasks {+ bool supported = false;+ String mode = 'autoApprove';+ final _rows = <String, SuperTabPersonalTask>{};+ final _versions = <String, int>{};+ List<SuperTabPersonalTask>? _ordered;++ List<SuperTabPersonalTask> get rows => _ordered ??= List.unmodifiable(+ _rows.values.toList()..sort((a, b) {+ final time = b.at.compareTo(a.at);+ return time == 0 ? a.id.compareTo(b.id) : time;+ }),+ );++ bool apply(Object? value) {+ if (value is! Map) return false;+ final nextMode = value['approvalMode'];+ if (nextMode != 'autoApprove' && nextMode != 'review') {+ throw const FormatException('Update Harness to read Tasks.');+ }+ var changed = !supported || mode != nextMode;+ supported = true;+ mode = nextMode as String;+ if (value['reset'] == true) {+ changed = true;+ _rows.clear();+ _versions.clear();+ }+ 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 []) {+ 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.');+ }+ final task = SuperTabPersonalTask(row);+ if ((_versions[task.id] ?? -1) >= task.version) continue;+ _versions[task.id] = task.version;+ _rows[task.id] = task;+ changed = true;+ }+ if (changed) _ordered = null;+ return changed;+ }++ Map<String, int> get versions => Map.unmodifiable(_versions);++ /// Cache tombstones share the cursor's lifetime, so its overlap stays idempotent after restart.+ void restoreVersions(Object? value) {+ if (value is! Map) return;+ for (final entry in value.entries) {+ if (entry.key is String && entry.value is num) {+ final version = (entry.value as num).toInt();+ if ((_versions[entry.key] ?? -1) < version) {+ _versions[entry.key as String] = version;+ }+ }+ }+ }++ Map<String, dynamic> toJson() => {+ 'approvalMode': mode,+ 'reset': true,+ 'upserts': [for (final row in rows) row.json],+ 'removed': <String>[],+ };+}diff --git a/desktop/lib/super_tabs/tasks/personal_tasks_pane.dart b/desktop/lib/super_tabs/tasks/personal_tasks_pane.dartnew file mode 100644index 000000000..7ddd19119--- /dev/null+++ b/desktop/lib/super_tabs/tasks/personal_tasks_pane.dart@@ -0,0 +1,479 @@+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_tasks.dart';++/// The person's active work, from the same authenticated cursor as the chat.+class SuperTabPersonalTasksPane extends StatefulWidget {+ const SuperTabPersonalTasksPane({+ super.key,+ required this.controller,+ required this.onOpenTask,+ });+ final SuperTabController controller;+ final ValueChanged<String> onOpenTask;+ @override+ State<SuperTabPersonalTasksPane> createState() => _TasksPaneState();+}++class _TasksPaneState extends State<SuperTabPersonalTasksPane> {+ String? _expanded, _error, _operationId;+ Map<String, dynamic>? _action;+ bool _sending = false;+ SuperTabController get c => widget.controller;++ @override+ void didUpdateWidget(SuperTabPersonalTasksPane old) {+ super.didUpdateWidget(old);+ if (!identical(old.controller, c)) {+ _expanded = _error = _operationId = null;+ _action = null;+ _sending = false;+ }+ }++ Future<void> _send(Map<String, dynamic> action, {bool retry = false}) async {+ if (_sending ||+ c.saving ||+ !c.canWrite ||+ c.personalTasks?.supported != true) {+ return;+ }+ if (!retry && (c.hasPendingAction || _action != null)) return;+ final owner = c;+ setState(() {+ _sending = true;+ _error = null;+ if (!retry) {+ _action = Map.of(action);+ _operationId = superTabOperationId();+ }+ });+ try {+ final answer = retry && owner.hasPendingAction+ ? await owner.retry()+ : await owner.command(_action!, operationId: _operationId);+ if (!mounted || !identical(owner, c)) return;+ setState(() {+ if (answer != null) {+ _action = null;+ _operationId = null;+ } else {+ _error = owner.operationErrorCode == 'UPDATE_REQUIRED'+ ? 'Update Harness to change Tasks.'+ : 'The change is not confirmed. Retry to check it.';+ }+ });+ } catch (_) {+ if (mounted && identical(owner, c)) {+ setState(+ () => _error = 'The change is not confirmed. Retry to check it.',+ );+ }+ } finally {+ if (mounted && identical(owner, c)) setState(() => _sending = false);+ }+ }++ Future<void> _reject(SuperTabPersonalTask task) async {+ final owner = c;+ final reason = TextEditingController();+ final text = await showDialog<String>(+ context: context,+ builder: (context) => StatefulBuilder(+ builder: (context, update) => AlertDialog(+ title: const Text('Reject task'),+ content: TextField(+ key: const ValueKey('task-reject-reason'),+ controller: reason,+ autofocus: true,+ maxLength: 2000,+ minLines: 2,+ maxLines: 4,+ decoration: const InputDecoration(labelText: 'Reason'),+ onChanged: (_) => update(() {}),+ ),+ actions: [+ TextButton(+ onPressed: () => Navigator.pop(context),+ child: const Text('Cancel'),+ ),+ TextButton(+ onPressed: reason.text.trim().isEmpty+ ? null+ : () => Navigator.pop(context, reason.text.trim()),+ child: const Text('Reject task'),+ ),+ ],+ ),+ ),+ );+ // The closing route can still paint the field during its exit animation.+ WidgetsBinding.instance.addPostFrameCallback((_) => reason.dispose());+ if (text != null && mounted && identical(owner, c)) {+ await _send({+ 'type': 'task.reject',+ 'conversationId': task.id,+ 'reason': text,+ });+ }+ }++ @override+ Widget build(BuildContext context) => AnimatedBuilder(+ animation: c,+ builder: (context, _) {+ final tasks = c.personalTasks;+ final supported = tasks?.supported == true && !c.accessRevoked;+ final enabled =+ supported &&+ c.canWrite &&+ !_sending &&+ !c.saving &&+ !c.hasPendingAction &&+ _action == null;+ final snapshot = c.snapshot;+ final agents = {+ for (final a in snapshot?.agents ?? <SuperTabAgent>[]) a.id: a,+ };+ final projects = {+ for (final p in snapshot?.projects ?? <SuperTabProject>[]) p.id: p,+ };+ return Material(+ 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),+ ),+ ),+ 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,+ ),+ ),+ ],+ ),+ ),+ if (_error != null)+ Padding(+ padding: const EdgeInsets.symmetric(+ horizontal: AppDesktop.groupGap,+ ),+ 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(+ 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,+ ),+ ),+ ],+ ),+ 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),+ ],+ ),+ ],+ ),+ ),+ ),+ 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)+ : null,+ child: const Text('Reject'),+ ),+ FilledButton(+ onPressed: enabled+ ? () => _send({+ 'type': 'task.approve',+ 'conversationId': task.id,+ })+ : null,+ child: const Text('Approve'),+ ),+ ],+ ),+ ],+ ),+ ),+ ],+ );+ },+ ),+ ),+ ],+ ),+ );+ },+ );+}++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/view.dart b/desktop/lib/super_tabs/view.dartindex e1985b3fc..20a0e153b 100644--- a/desktop/lib/super_tabs/view.dart+++ b/desktop/lib/super_tabs/view.dart@@ -113,6 +113,7 @@ import 'visible_tick.dart';import 'buddy_rows.dart';import 'task_groups.dart';import 'tasks_view.dart';+import 'tasks/personal_tasks_pane.dart';import 'voice_length.dart';import '../widgets/dial_list_scroll.dart';import '../widgets/laid_out_list.dart';@@ -6157,7 +6158,9 @@ class _SuperTabViewState extends State<SuperTabView>final agentChat =widget.board && _agentChatId != null && c.selectedId == _agentChatId;// The chat is in the middle, by the reader's choice of an agent or once the right pane is the Tasks slot.- final chatInMiddle = agentChat || widget.rightPane != null;+ final hasTasksPane =+ widget.rightPane != null || c.personalTasks?.supported == true;+ final chatInMiddle = agentChat || hasTasksPane;final boardLayout =widget.board &&(!_projectChatOnly || chatInMiddle) &&@@ -6198,7 +6201,7 @@ class _SuperTabViewState extends State<SuperTabView>);// 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 = widget.rightPane != null && !agentChat+ final impliedBoard = hasTasksPane && !agentChat? c.snapshot?.projects.where((p) => p.leadConversationId == c.selectedId).firstOrNull@@ -6262,7 +6265,12 @@ class _SuperTabViewState extends State<SuperTabView>? null: boardLayout? widget.rightPane?.call(context) ??- (agentChat+ (c.personalTasks?.supported == true+ ? SuperTabPersonalTasksPane(+ controller: c,+ onOpenTask: (id) => unawaited(_openTask(id)),+ )+ : agentChat? const SizedBox.expand(): _boardChat(chat)): thread ??diff --git a/desktop/test/super_tab_personal_tasks_pane_test.dart b/desktop/test/super_tab_personal_tasks_pane_test.dartnew file mode 100644index 000000000..4100b496b--- /dev/null+++ b/desktop/test/super_tab_personal_tasks_pane_test.dart@@ -0,0 +1,386 @@+import 'package:harness/super_tabs/zone_time.dart';++import 'dart:async';++import 'package:flutter/material.dart';+import 'package:flutter_test/flutter_test.dart';+import 'package:harness/super_tabs/controller.dart';+import 'package:harness/super_tabs/view.dart';+import 'package:harness/shared/theme/app_icons.dart';+import 'package:harness/widgets/harness_activity_mark.dart';+import 'package:harness/state/harness_activity.dart';++import 'swarm_state_test.dart' show createApp;++import 'package:harness/super_tabs/tasks/personal_tasks_pane.dart';++import 'super_tab_parts_test.dart' show recorded;+import 'super_tab_personal_tasks_test.dart' show task, feed;+import 'support/memory_key_value_store.dart';++class TasksFixture {+ final store = MemoryKeyValueStore();+ bool supported = true, fail = false;+ Completer<void>? hold;+ String mode = 'autoApprove';+ final rows = [task('old', 1, 10), task('new', 1, 20)];+ final commands = <Map<String, dynamic>>[];+ final operations = <String>[];+ late final controller = SuperTabController(+ tabId: 'c51479bd73b59e58176ad9e4',+ accountId: '6a86',+ initial: {+ 'tabId': 'c51479bd73b59e58176ad9e4',+ 'accountId': '6a86',+ 'selectedId': 'lead5701',+ },+ pollInterval: Duration.zero,+ save: (value) => store.write('controller', value.toString()),+ request: (method, path, {body}) async {+ if (path.contains('/messages')) {+ return {'messages': <dynamic>[], 'next': null};+ }+ if (method == 'POST') {+ operations.add(body!['operationId'] as String);+ final command = Map<String, dynamic>.from(body['command'] as Map);+ commands.add(command);+ await hold?.future;+ if (fail) throw StateError('fixture private payload');+ if (command['type'] == 'member.approvalMode') {+ mode = command['mode'] as String;+ }+ for (final row in rows) {+ if (row['id'] != command['conversationId']) continue;+ row['version'] = (row['version'] as int) + 1;+ if (command['type'] == 'task.approve') row['status'] = 'working';+ if (command['type'] == 'task.reject') {+ row['status'] = 'rejected';+ row['reason'] = command['reason'];+ }+ if (command['type'] == 'task.suggest') {+ row['agent'] = {'id': command['agentId'], 'name': 'Selected agent'};+ }+ }+ return {'result': <String, dynamic>{}};+ }+ final result = path.endsWith('/parts')+ ? recorded('first_load')+ : {+ 'format': 2,+ 'cursor': 'next',+ 'epoch': 3,+ 'derived': recorded('first_load')['derived'],+ };+ if (supported) {+ result['personalTasks'] = feed(+ rows,+ reset: path.endsWith('/parts'),+ mode: mode,+ );+ }+ return result;+ },+ );+}++void main() {+ setUpAll(superTabLoadZones);+ late TasksFixture f;+ Future<void> mount(WidgetTester tester) async {+ f = TasksFixture();+ addTearDown(() => f.controller.dispose());+ await f.controller.refresh();+ expect(+ f.controller.canWrite,+ isTrue,+ reason:+ "${f.controller.error}; ${f.controller.snapshot?.people.map((p) => p.id)}",+ );+ await tester.pumpWidget(+ MaterialApp(+ home: Scaffold(+ body: SizedBox(+ width: 340,+ child: SuperTabPersonalTasksPane(+ controller: f.controller,+ onOpenTask: (_) {},+ ),+ ),+ ),+ ),+ );+ }++ testWidgets('newest task first with project, agent and proposal mark', (+ t,+ ) async {+ await mount(t);+ expect(+ t.getTopLeft(find.text('Task new')).dy,+ lessThan(t.getTopLeft(find.text('Task old')).dy),+ );+ expect(find.text('Tasks'), findsOneWidget);+ expect(find.byTooltip('Proposal'), findsNWidgets(2));+ expect(find.byIcon(AppIcons.circleDashed), findsNWidgets(2));+ f.rows.first['status'] = 'working';+ f.rows.first['version'] = 2;+ await f.controller.refresh();+ await t.pump();+ expect(+ find.byWidgetPredicate(+ (w) => w is ActivityMark && w.activity == HarnessActivity.working,+ ),+ findsOneWidget,+ );+ expect(find.text('Auto approve'), findsOneWidget);+ });+ testWidgets(+ 'ordinary proposals open their conversation without approval controls',+ (t) async {+ await mount(t);+ final opened = <String>[];+ f.rows.last.remove('canApprove');+ f.rows.last['version'] = 2;+ await f.controller.refresh();+ await t.pumpWidget(+ MaterialApp(+ home: Scaffold(+ body: SuperTabPersonalTasksPane(+ controller: f.controller,+ onOpenTask: opened.add,+ ),+ ),+ ),+ );+ await t.tap(find.text('Task new'));+ await t.pump();+ expect(opened, ['new']);+ expect(find.text('Approve'), findsNothing);+ expect(find.text('Reject'), findsNothing);+ expect(find.byType(DropdownButtonFormField<String>), findsNothing);+ expect(f.commands, isEmpty);+ f.rows.last['canApprove'] = false;+ f.rows.last['version'] = 3;+ await f.controller.refresh();+ await t.pump();+ await t.tap(find.text('Task new'));+ await t.pump();+ expect(opened, ['new', 'new']);+ expect(f.commands, isEmpty);+ },+ );+ testWidgets('mode is saved by authenticated command and server read', (+ t,+ ) async {+ await mount(t);+ await t.tap(find.byKey(const ValueKey('tasks-approval-mode')));+ await t.pumpAndSettle();+ await t.tap(find.text('Review').last);+ await t.pumpAndSettle();+ expect(f.commands.single, {+ 'type': 'member.approvalMode',+ 'mode': 'review',+ });+ expect(f.controller.personalTasks!.mode, 'review');+ });+ for (final mode in ['autoApprove', 'review']) {+ testWidgets('waiting task stays actionable in $mode with primary Approve', (+ t,+ ) async {+ await mount(t);+ 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.text('Suggested'), findsNothing);+ await t.tap(find.text('Approve'));+ await t.pumpAndSettle();+ expect(f.commands.single, {+ 'type': 'task.approve',+ 'conversationId': 'new',+ });+ });+ }+ 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.pump();+ await t.tap(find.text('Approve'));+ await t.pump();+ expect(f.commands.length, 1);+ f.hold!.complete();+ await t.pumpAndSettle();+ expect(f.commands.single, {+ 'type': 'task.approve',+ 'conversationId': 'new',+ });+ expect(find.text('Task new'), findsOneWidget);+ });+ 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.pumpAndSettle();+ expect(f.commands, isEmpty);+ await t.enterText(+ find.byKey(const ValueKey('task-reject-reason')),+ 'Too much scope',+ );+ await t.pump();+ await t.tap(find.text('Reject task').last);+ await t.pumpAndSettle();+ expect(f.commands.single, {+ 'type': 'task.reject',+ 'conversationId': 'new',+ 'reason': 'Too much scope',+ });+ expect(find.byTooltip('Rejected'), findsOneWidget);+ });+ testWidgets('retry uses the same receipt and never displays raw error', (+ 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.pumpAndSettle();+ expect(find.textContaining('fixture private'), findsNothing);+ expect(find.text('Retry'), findsOneWidget);+ f.fail = false;+ await t.tap(find.text('Retry'));+ await t.pumpAndSettle();+ expect(f.operations.toSet().length, 1);+ expect(f.commands.length, 2);+ });+ testWidgets('old backend has no approval controls', (t) async {+ await mount(t);+ f.supported = false;+ // A fresh account-bound controller never infers capability from stored mode.+ final old = TasksFixture()..supported = false;+ addTearDown(old.controller.dispose);+ await old.controller.refresh();+ await t.pumpWidget(+ MaterialApp(+ home: SuperTabPersonalTasksPane(+ controller: old.controller,+ onOpenTask: (_) {},+ ),+ ),+ );+ 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.pumpAndSettle();+ await t.enterText(+ find.byKey(const ValueKey('task-reject-reason')),+ 'Decline',+ );+ await t.pump();+ final replacement = TasksFixture();+ addTearDown(replacement.controller.dispose);+ await replacement.controller.refresh();+ await t.pumpWidget(+ MaterialApp(+ home: Scaffold(+ body: SizedBox(+ width: 340,+ child: SuperTabPersonalTasksPane(+ controller: replacement.controller,+ onOpenTask: (_) {},+ ),+ ),+ ),+ ),+ );+ await t.tap(find.text('Reject task').last);+ await t.pumpAndSettle();+ expect(f.commands, isEmpty);+ expect(replacement.commands, isEmpty);+ },+ );++ testWidgets(+ 'the Desktop shell defaults its right slot to Tasks and keeps chat in the middle',+ (t) async {+ await mount(t);+ 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();+ expect(find.byType(SuperTabPersonalTasksPane), findsOneWidget);+ expect(t.getSize(find.byType(SuperTabPersonalTasksPane)).width, 340);+ expect(find.byKey(const ValueKey('super-board-chat')), findsNothing);+ expect(find.text('Task new'), findsOneWidget);+ },+ );+}diff --git a/desktop/test/super_tab_personal_tasks_shots_test.dart b/desktop/test/super_tab_personal_tasks_shots_test.dartnew file mode 100644index 000000000..ddb573c3b--- /dev/null+++ b/desktop/test/super_tab_personal_tasks_shots_test.dart@@ -0,0 +1,105 @@+import 'dart:io';++import 'package:flutter/material.dart';+import 'package:flutter/services.dart';+import 'package:flutter_test/flutter_test.dart';+import 'package:harness/shared/theme/app_theme.dart' as grid;+import 'package:harness/super_tabs/tasks/personal_tasks_pane.dart';++import 'super_tab_personal_tasks_pane_test.dart' show TasksFixture;+import 'super_tab_personal_tasks_test.dart' show task;+import 'support/capture.dart';++void main() {+ final shots = Platform.environment['HARNESS_V3_TASKS_SHOTS'];+ setUpAll(() async {+ await loadCaptureFonts(shots);+ if (shots != null && Platform.isMacOS) {+ for (final (family, path) in [+ ('Menlo', '/System/Library/Fonts/Menlo.ttc'),+ ('Apple Symbols', '/System/Library/Fonts/Apple Symbols.ttf'),+ ]) {+ final bytes = ByteData.sublistView(await File(path).readAsBytes());+ await (FontLoader(family)..addFont(Future.value(bytes))).load();+ }+ }+ });+ for (final brightness in Brightness.values) {+ testWidgets('Tasks pane and decisions fit in ${brightness.name}', (+ t,+ ) async {+ final f = TasksFixture();+ addTearDown(f.controller.dispose);+ f.rows+ ..clear()+ ..addAll([+ {+ ...task('first', 1, 40),+ 'title': 'Keep reconnects quiet',+ 'projectName': 'Harness',+ 'status': 'working',+ 'suggested': false,+ },+ {+ ...task('second', 1, 30),+ 'title': 'Add the project export',+ 'projectName': 'Desktop',+ },+ {+ ...task('third', 1, 20),+ 'title': 'Expand the settings page',+ 'projectName': 'Desktop',+ 'status': 'rejected',+ 'suggested': false,+ 'reason': 'Keep the first release small',+ },+ {+ ...task('fourth', 1, 10),+ 'title': 'Repair the retry state',+ 'projectName': 'Harness',+ 'status': 'done',+ 'suggested': false,+ },+ ]);+ await f.controller.refresh();+ t.view.physicalSize = const Size(440, 760);+ t.view.devicePixelRatio = 1;+ addTearDown(t.view.reset);+ grid.AppTheme.brightness.value = brightness;+ addTearDown(() => grid.AppTheme.brightness.value = Brightness.light);+ await t.pumpWidget(+ MaterialApp(+ debugShowCheckedModeBanner: false,+ theme: grid.buildAppTheme(brightness: brightness),+ home: Scaffold(+ body: SuperTabPersonalTasksPane(+ controller: f.controller,+ onOpenTask: (_) {},+ ),+ ),+ ),+ );+ await t.pumpAndSettle();+ expect(t.takeException(), isNull);+ await captureWindow(t, shots, 'tasks-auto-${brightness.name}');+ f.mode = 'review';+ await f.controller.refresh();+ await t.pump();+ await t.tap(find.text('Add the project export'));+ await t.pumpAndSettle();+ expect(t.takeException(), isNull);+ await captureWindow(t, shots, 'tasks-review-${brightness.name}');+ await t.tap(find.text('Reject'));+ await t.pumpAndSettle();+ await t.enterText(+ find.byKey(const ValueKey('task-reject-reason')),+ 'Keep the first release small',+ );+ await t.pump();+ expect(t.takeException(), isNull);+ await captureWindow(t, shots, 'tasks-reject-${brightness.name}');+ await t.tap(find.text('Cancel'));+ await t.pumpAndSettle();+ });+ }+}diff --git a/desktop/test/super_tab_personal_tasks_test.dart b/desktop/test/super_tab_personal_tasks_test.dartnew file mode 100644index 000000000..1b3d73b5d--- /dev/null+++ b/desktop/test/super_tab_personal_tasks_test.dart@@ -0,0 +1,130 @@+import 'package:flutter_test/flutter_test.dart';+import 'package:harness/super_tabs/parts.dart';++import 'super_tab_parts_test.dart' show recorded;++Map<String, dynamic> task(String id, int version, int at) => {+ 'id': id,+ 'version': version,+ 'at': at,+ 'projectId': 'lead5701',+ 'projectName': 'Old project',+ 'title': 'Task $id',+ 'status': 'proposal',+ 'canApprove': true,+ 'suggested': true,+ 'agent': {'id': '0540', 'name': 'Old name'},+};+Map<String, dynamic> feed(+ List<Map<String, dynamic>> rows, {+ bool reset = false,+ List<String> removed = const [],+ String mode = 'autoApprove',+}) => {+ 'approvalMode': mode,+ 'reset': reset,+ 'upserts': rows,+ 'removed': removed,+};+void main() {+ test('old backend has no capability; first load sorts newest then id', () {+ expect(+ SuperTabParts.firstLoad(recorded('first_load')).personalTasks.supported,+ isFalse,+ );+ final parts = SuperTabParts.firstLoad(+ recorded('first_load')+ ..['personalTasks'] = feed([+ task('b', 2, 10),+ task('a', 1, 20),+ task('c', 1, 10),+ ], reset: true),+ );+ expect(parts.personalTasks.supported, isTrue);+ expect(parts.personalTasks.mode, 'autoApprove');+ expect(parts.personalTasks.rows.map((r) => r.id), ['a', 'b', 'c']);+ });+ test('overlap keeps newest version and marks feed changes as content', () {+ final parts = SuperTabParts.firstLoad(+ recorded('first_load')+ ..['personalTasks'] = feed([task('a', 3, 20)], reset: true),+ );+ final changed = parts.apply(+ recorded('changes')+ ..['personalTasks'] = feed([+ task('a', 2, 5),+ task('b', 1, 30),+ ], mode: 'review'),+ );+ expect(parts.personalTasks.rows.map((r) => r.id), ['b', 'a']);+ expect(parts.personalTasks.rows.last.version, 3);+ expect(parts.personalTasks.mode, 'review');+ expect(changed.changed, isTrue);+ expect(changed.machinesOnly, isFalse);+ expect(changed.readMarksOnly, isFalse);+ });+ test('removals and visibility reset discard old rows', () {+ final parts = SuperTabParts.firstLoad(+ recorded('first_load')+ ..['personalTasks'] = feed([+ task('a', 3, 20),+ task('b', 1, 30),+ ], reset: true),+ );+ parts.apply(+ recorded('changes')..['personalTasks'] = feed([], removed: ['a']),+ );+ expect(parts.personalTasks.rows.map((r) => r.id), ['b']);+ parts.apply(+ recorded('changes')+ ..['personalTasks'] = feed([task('c', 1, 40)], reset: true),+ );+ expect(parts.personalTasks.rows.single.id, 'c');+ });+ test(+ 'cache round trip keeps mode and summaries; omitted delta keeps capability',+ () {+ final parts = SuperTabParts.firstLoad(+ recorded('first_load')+ ..['personalTasks'] = feed(+ [task('a', 3, 20)],+ reset: true,+ mode: 'review',+ ),+ );+ final restored = SuperTabParts.fromJson(parts.toJson());+ restored.apply(recorded('changes'));+ expect(restored.personalTasks.supported, isTrue);+ expect(restored.personalTasks.mode, 'review');+ expect(restored.personalTasks.rows.single.title, 'Task a');+ },+ );+ test('tenfold feed merges one changed summary without losing others', () {+ final parts = SuperTabParts.firstLoad(+ recorded('first_load')+ ..['personalTasks'] = feed([+ for (var i = 0; i < 1000; i++) task('$i', 1, i),+ ], reset: true),+ );+ parts.apply(+ recorded('changes')..['personalTasks'] = feed([task('3', 2, 2000)]),+ );+ expect(parts.personalTasks.rows.length, 1000);+ expect(parts.personalTasks.rows.first.id, '3');+ expect(parts.personalTasks.rows.first.version, 2);+ });+ test('a cached removal cannot be resurrected by the cursor overlap', () {+ final parts = SuperTabParts.firstLoad(+ recorded('first_load')+ ..['personalTasks'] = feed([task('a', 3, 20)], reset: true),+ );+ parts.apply(+ recorded('changes')..['personalTasks'] = feed([], removed: ['a']),+ );+ final restored = SuperTabParts.fromJson(parts.toJson());+ restored.apply(+ recorded('changes')..['personalTasks'] = feed([task('a', 2, 10)]),+ );+ expect(restored.personalTasks.rows, isEmpty);+ });+}diff --git a/docs/plans/2026-11-07-v3-personal-tasks-plan.md b/docs/plans/2026-11-07-v3-personal-tasks-plan.mdnew file mode 100644index 000000000..78ac6db0c--- /dev/null+++ b/docs/plans/2026-11-07-v3-personal-tasks-plan.md@@ -0,0 +1,71 @@+# Personal Tasks pane implementation plan++> Implement natively, task by task, with failing tests committed before production code; one independent review of the pull request.++**Goal:** Show the person's time-ordered Tasks and proposals, with backend-owned Auto approve / Review and explicit task decisions.+**Architecture:** Add the optional personalTasks envelope to the existing parts store, preserving its cursor, cache and revocation lifecycle. A new right-pane widget reads that store through the controller and sends existing authenticated commands; the shell supplies task navigation.+**Tech Stack:** Flutter/Dart; existing controller, parts transport, native controls and memory-store/fake-sign-in tests.+**Spec:** docs/specs/2026-11-07-swarm-v3.md in Fir's backend PR #3449; task #4138. Shell dependency #3445; join dependency #3448.++## Global Constraints++- Backend first. Unsupported servers show Update Harness and no approval controls.+- macOS, Linux and Windows; no process launch, login read or production writes. Phone/web stay as today.+- Newest first, then id; two quiet lines per row, no section headings; proposals and rejected tasks keep their status.+- Auto approve is default; changes apply to future work only. Review approval and suggestion never start work locally.+- Light and dark; memory store and fake sign-in; reuse existing request timeout and operation receipts.++## Review Focus++- Overlap deltas cannot resurrect an old task version; reset/removals clear revoked rows.+- Missing capability cannot present an approval choice that the server cannot keep.+- Account replacement, offline transport and double click must not send the same choice twice or attribute it to another person.+- Agent disappearance and changed roster must not silently select another worker.+- Rejection requires a reason; failures remain visible with a bounded retry and no raw server content.++## Design++- Growth: one in-memory summary per active task in the server's bounded snapshot; existing cache lifecycle deletes it. No history collection or timer.+- Concurrency: existing controller serial requests and operation ids; server is authority for audience, identity, suggestions and decisions.+- Read cost: consume existing parts/change envelopes only; merge only changed rows, lazy list rendering.+- Scale: 10x active task fixture checks delta work and ordering; no whole-state polling.+- Compatibility: optional additive envelope; hide unsupported controls; backend ships first.+- Migration/rollback: no schema migration; previous clients ignore feed; roll Desktop back independently, keep approval backend enforcement.+- Audience/identity: server-filtered personalTasks only; never infer requester from machine owner; account-bound controller.+- Failure: visible safe error and retry; no optimistic approval or mode change; command timeout is existing controller's.+- Platforms: shared Flutter pane on macOS/Linux/Windows; no native process behavior changes.++### Task 1: Feed state and transport++**Files:** Create desktop/lib/super_tabs/tasks/personal_tasks.dart; modify parts.dart and controller.dart; test desktop/test/super_tab_personal_tasks_test.dart.+**Interfaces:** Parts exposes personalTasks store; controller exposes it read-only; rows include id/version/at/project/title/agent/status/suggested/reason.+- [x] Commit failing tests for first load, overlapping versions, removals/reset, serialization, missing capability and roster overlays.+- [x] Run those tests and record red.+- [x] Implement envelope merging and wire it into existing parts first load/change/cache. Feed changes notify as content changes.+- [x] Run affected parts tests and new feed tests; commit green.++### Task 2: Tasks pane and shell++**Files:** Create desktop/lib/super_tabs/tasks/personal_tasks_pane.dart; modify view.dart's existing right-pane default; test desktop/test/super_tab_personal_tasks_pane_test.dart.+**Interfaces:** SuperTabPersonalTasksPane(controller, onOpenTask); authenticated commands member.approvalMode, task.suggest, task.approve, task.reject.+- [x] Commit failing widget tests for newest order, quiet two-line rows, proposal/rejected marks, default/mode persistence, suggestion change, approve/reject/reason, error/retry, double click, account switch and unsupported backend.+- [x] Run widget tests and record red.+- [x] Implement native pane, preserving supplied rightPane override and existing task opener; safe pending/error/retry behavior.+- [x] Run affected widget/shell tests and style/icon checks; capture and inspect light/dark panes; commit green.+- [x] Push draft early.+- [ ] Independent review, platform checks and ci/required at the held head.++## Validation receipt++- Feed red at 7f42f8686, green at a4a26797d; widget red at a7782272c, green at ecf949b13. Cached tombstone regression red at b9059b20e, green at 5e50f13ea. Portable status-mark regression red at 691a9bf8d, green at 0940e2037.+- 73 affected feed, parts, pane and shell tests pass on macOS; two screenshot tests produce six inspected light/dark auto, review and rejection captures. Memory store and fake sign-in only.+- New-file Dart analysis and icon audit pass. The initial style command checked allowlist growth only; CI caught the pane spacing violations. d732846b8 uses shared tokens and the actual UI style scan passes. Linux/Windows platform checks and automatic CI are review gates; native window/IME and live-account launch are not claimed.+- Mac debug microbenchmark, same recorded parts-overlap workload, 2,000 warm-ups then 21 batches of 1,000: baseline d78772f median 4.047 µs / p95 5.179 µs; Tasks branch median 3.903–4.432 µs / p95 4.604–4.961 µs (run variation, no observed p95 regression). A single new version in 1,000 Tasks including sorted list materialization: median 263 µs / p95 519 µs over 100 updates. Temporary benchmark fixtures removed.+- Merged main at 7356cf633 (real #3449 contract), without conflicts. Shell #3445 and join #3448 remain merge-order dependencies.++## Review correction++- Ordinary Buddy proposals are status-only: approval controls require the server's `canApprove: true` and proposal status. Missing/false capability opens the conversation and sends no approval command. Backend owner Fir is adding this field; ship that backend correction before Desktop.+- Regression 9d6832e0d failed because tapping an ordinary proposal did not open it; 0bb8c1777 passes it with two production lines. Existing approval flows remain covered.+- Integrated shell head 2ef2b153c without conflicts; only its date-dependent Board-card fixture changed beyond the already integrated merges. 22 feed/pane/Board-card tests pass; 13 pane/capture tests pass after token correction. Six updated light/dark captures inspected.+- CI run 42270921697 failed shard 1's style scan before tests: six numeric EdgeInsets and one border radius. Corrected at d732846b8; no rerun requested. Automatic CI will run for the corrected pushed head.diff --git a/mobile/lib/swarm/parts.dart b/mobile/lib/swarm/parts.dartindex 0b7b829f2..cb8605ff7 100644--- a/mobile/lib/swarm/parts.dart+++ b/mobile/lib/swarm/parts.dart@@ -1,6 +1,7 @@import 'package:collection/collection.dart' show DeepCollectionEquality;import 'model.dart';+import 'tasks/personal_tasks.dart';/// The response shape a Swarm read answers in (docs/design/2026-10-26-swarm-state-parts.md, section 4), mirrored by/// hand from backend `superTabs/read/contract.ts` (final at cd004bf5c). A first load of any other format is from a@@ -88,6 +89,7 @@ class SuperTabParts {parts._seen['$kind:${part['key']}'] = _int(part['version']);}}+ parts.personalTasks.apply(answer['personalTasks']);parts._takeReadMarks(marks);// Every one is news to a device whose own mark is higher.parts._takeUnreadMarks(unreadMarks, all: true);@@ -114,6 +116,7 @@ class SuperTabParts {}}}+ parts.personalTasks.restoreVersions(json['personalTaskVersions']);parts._takeReadMarks(json['readMarks']);parts._takeThreadMarks(json['threadMarks']);parts._takeChatSettings(json['chatSettings']);@@ -153,6 +156,8 @@ class SuperTabParts {_ => null,};+ final personalTasks = SuperTabPersonalTasks();+Map<String, dynamic> _head;Map<String, dynamic> _derived;final _live = <String, Map<String, Map<String, dynamic>>>{};@@ -370,6 +375,9 @@ class SuperTabParts {_derived = derived;changed = true;}+ if (personalTasks.apply(changes['personalTasks'])) {+ changed = beyondMachines = true;+ }derivedEtag = etag;cursor = _cursor(changes);epoch = _int(changes['epoch'] ?? epoch);@@ -533,11 +541,13 @@ class SuperTabParts {'lastChangedAt': lastChangedAt,'githubApp': githubApp,'head': _head,+ if (personalTasks.supported) 'personalTasks': personalTasks.toJson(),for (final kind in _lists)kind: (_live[kind] ?? const {}).values.toList(),'derived': _derived,if (derivedEtag != null) 'derivedEtag': derivedEtag,},+ if (personalTasks.supported) 'personalTaskVersions': personalTasks.versions,'dormant': _dormant.values.toList(),'seen': Map<String, int>.of(_seen),'stale': _stale.toList(),diff --git a/mobile/lib/swarm/tasks/personal_tasks.dart b/mobile/lib/swarm/tasks/personal_tasks.dartnew file mode 100644index 000000000..11b13adf6--- /dev/null+++ b/mobile/lib/swarm/tasks/personal_tasks.dart@@ -0,0 +1,90 @@+import '../model.dart';++/// A server-filtered summary, never a local inference about who requested work.+class SuperTabPersonalTask {+ SuperTabPersonalTask(Map<String, dynamic> row) : json = Map.unmodifiable(row);+ final Map<String, dynamic> json;+ String get id => json['id'] as String;+ int get version => (json['version'] as num).toInt();+ int get at => (json['at'] as num).toInt();+ String get projectId => json['projectId'] as String? ?? '';+ String get projectName => json['projectName'] as String? ?? 'Project';+ String get title => json['title'] as String? ?? 'Task';+ String get status => json['status'] as String? ?? 'working';+ 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']);+ String? get agentId => agent['id'] as String?;+}++/// Lives with the parts cursor and is discarded with it on access revocation.+/// No separate timer or request; overlap versions are applied once.+class SuperTabPersonalTasks {+ bool supported = false;+ String mode = 'autoApprove';+ final _rows = <String, SuperTabPersonalTask>{};+ final _versions = <String, int>{};+ List<SuperTabPersonalTask>? _ordered;++ List<SuperTabPersonalTask> get rows => _ordered ??= List.unmodifiable(+ _rows.values.toList()..sort((a, b) {+ final time = b.at.compareTo(a.at);+ return time == 0 ? a.id.compareTo(b.id) : time;+ }),+ );++ bool apply(Object? value) {+ if (value is! Map) return false;+ final nextMode = value['approvalMode'];+ if (nextMode != 'autoApprove' && nextMode != 'review') {+ throw const FormatException('Update Harness to read Tasks.');+ }+ var changed = !supported || mode != nextMode;+ supported = true;+ mode = nextMode as String;+ if (value['reset'] == true) {+ changed = true;+ _rows.clear();+ _versions.clear();+ }+ 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 []) {+ 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.');+ }+ final task = SuperTabPersonalTask(row);+ if ((_versions[task.id] ?? -1) >= task.version) continue;+ _versions[task.id] = task.version;+ _rows[task.id] = task;+ changed = true;+ }+ if (changed) _ordered = null;+ return changed;+ }++ Map<String, int> get versions => Map.unmodifiable(_versions);++ /// Cache tombstones share the cursor's lifetime, so its overlap stays idempotent after restart.+ void restoreVersions(Object? value) {+ if (value is! Map) return;+ for (final entry in value.entries) {+ if (entry.key is String && entry.value is num) {+ final version = (entry.value as num).toInt();+ if ((_versions[entry.key] ?? -1) < version) {+ _versions[entry.key as String] = version;+ }+ }+ }+ }++ Map<String, dynamic> toJson() => {+ 'approvalMode': mode,+ 'reset': true,+ 'upserts': [for (final row in rows) row.json],+ 'removed': <String>[],+ };+}diff --git a/mobile/test/swarm/desktop_parity_test.dart b/mobile/test/swarm/desktop_parity_test.dartindex 9fb862e44..4b40ad211 100644--- a/mobile/test/swarm/desktop_parity_test.dart+++ b/mobile/test/swarm/desktop_parity_test.dart@@ -13,6 +13,8 @@ import 'package:harness_mobile/swarm/swarm_buddy.dart';/// until the file leaves this list on purpose.const _copies = {'lib/swarm/parts.dart': 'lib/super_tabs/parts.dart',+ 'lib/swarm/tasks/personal_tasks.dart':+ 'lib/super_tabs/tasks/personal_tasks.dart','lib/swarm/profile_model.dart': 'lib/super_tabs/profile_model.dart',// Live cards (Slack parity, #2212): which messages are cards, and the// linked tasks a card shows. The phone reads no GitHub yet (Lead, 10-29:diff --git a/mobile/test/swarm/personal_tasks_test.dart b/mobile/test/swarm/personal_tasks_test.dartnew file mode 100644index 000000000..5f842f948--- /dev/null+++ b/mobile/test/swarm/personal_tasks_test.dart@@ -0,0 +1,135 @@+import 'package:flutter_test/flutter_test.dart';+import 'package:harness_mobile/swarm/parts.dart';++import 'dart:convert';+import 'dart:io';++Map<String, dynamic> recorded(String name) => jsonDecode(+ File('../desktop/test/super_tab_read_fixtures/$name.json').readAsStringSync(),+) as Map<String, dynamic>;++Map<String, dynamic> task(String id, int version, int at) => {+ 'id': id,+ 'version': version,+ 'at': at,+ 'projectId': 'lead5701',+ 'projectName': 'Old project',+ 'title': 'Task $id',+ 'status': 'proposal',+ 'canApprove': true,+ 'suggested': true,+ 'agent': {'id': '0540', 'name': 'Old name'},+};+Map<String, dynamic> feed(+ List<Map<String, dynamic>> rows, {+ bool reset = false,+ List<String> removed = const [],+ String mode = 'autoApprove',+}) => {+ 'approvalMode': mode,+ 'reset': reset,+ 'upserts': rows,+ 'removed': removed,+};+void main() {+ test('old backend has no capability; first load sorts newest then id', () {+ expect(+ SuperTabParts.firstLoad(recorded('first_load')).personalTasks.supported,+ isFalse,+ );+ final parts = SuperTabParts.firstLoad(+ recorded('first_load')+ ..['personalTasks'] = feed([+ task('b', 2, 10),+ task('a', 1, 20),+ task('c', 1, 10),+ ], reset: true),+ );+ expect(parts.personalTasks.supported, isTrue);+ expect(parts.personalTasks.mode, 'autoApprove');+ expect(parts.personalTasks.rows.map((r) => r.id), ['a', 'b', 'c']);+ });+ test('overlap keeps newest version and marks feed changes as content', () {+ final parts = SuperTabParts.firstLoad(+ recorded('first_load')+ ..['personalTasks'] = feed([task('a', 3, 20)], reset: true),+ );+ final changed = parts.apply(+ recorded('changes')+ ..['personalTasks'] = feed([+ task('a', 2, 5),+ task('b', 1, 30),+ ], mode: 'review'),+ );+ expect(parts.personalTasks.rows.map((r) => r.id), ['b', 'a']);+ expect(parts.personalTasks.rows.last.version, 3);+ expect(parts.personalTasks.mode, 'review');+ expect(changed.changed, isTrue);+ expect(changed.machinesOnly, isFalse);+ expect(changed.readMarksOnly, isFalse);+ });+ test('removals and visibility reset discard old rows', () {+ final parts = SuperTabParts.firstLoad(+ recorded('first_load')+ ..['personalTasks'] = feed([+ task('a', 3, 20),+ task('b', 1, 30),+ ], reset: true),+ );+ parts.apply(+ recorded('changes')..['personalTasks'] = feed([], removed: ['a']),+ );+ expect(parts.personalTasks.rows.map((r) => r.id), ['b']);+ parts.apply(+ recorded('changes')+ ..['personalTasks'] = feed([task('c', 1, 40)], reset: true),+ );+ expect(parts.personalTasks.rows.single.id, 'c');+ });+ test(+ 'cache round trip keeps mode and summaries; omitted delta keeps capability',+ () {+ final parts = SuperTabParts.firstLoad(+ recorded('first_load')+ ..['personalTasks'] = feed(+ [task('a', 3, 20)],+ reset: true,+ mode: 'review',+ ),+ );+ final restored = SuperTabParts.fromJson(parts.toJson());+ restored.apply(recorded('changes'));+ expect(restored.personalTasks.supported, isTrue);+ expect(restored.personalTasks.mode, 'review');+ expect(restored.personalTasks.rows.single.title, 'Task a');+ },+ );+ test('tenfold feed merges one changed summary without losing others', () {+ final parts = SuperTabParts.firstLoad(+ recorded('first_load')+ ..['personalTasks'] = feed([+ for (var i = 0; i < 1000; i++) task('$i', 1, i),+ ], reset: true),+ );+ parts.apply(+ recorded('changes')..['personalTasks'] = feed([task('3', 2, 2000)]),+ );+ expect(parts.personalTasks.rows.length, 1000);+ expect(parts.personalTasks.rows.first.id, '3');+ expect(parts.personalTasks.rows.first.version, 2);+ });+ test('a cached removal cannot be resurrected by the cursor overlap', () {+ final parts = SuperTabParts.firstLoad(+ recorded('first_load')+ ..['personalTasks'] = feed([task('a', 3, 20)], reset: true),+ );+ parts.apply(+ recorded('changes')..['personalTasks'] = feed([], removed: ['a']),+ );+ final restored = SuperTabParts.fromJson(parts.toJson());+ restored.apply(+ recorded('changes')..['personalTasks'] = feed([task('a', 2, 10)]),+ );+ expect(restored.personalTasks.rows, isEmpty);+ });+}