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
Merge batch 11-05 i2310: #3182 (#3196)
0xken152c5ac721fd52
diff --git a/desktop/lib/super_tabs/profile_actions.dart b/desktop/lib/super_tabs/profile_actions.dartindex ca94db5ca..d49bfdcbf 100644--- a/desktop/lib/super_tabs/profile_actions.dart+++ b/desktop/lib/super_tabs/profile_actions.dart@@ -88,7 +88,7 @@ extension SuperTabProfileActions on SuperTabController {return failure;}- /// Whether the reader may edit or delete [message]: their own plain post+ /// Whether the reader may edit [message]: their own plain post/// (no `source`: no task line, route or note the server wrote in their/// name), not deleted, in a conversation they may write in. The server/// decides (backend messageEdits.ts); this only offers the choices.@@ -104,6 +104,22 @@ extension SuperTabProfileActions on SuperTabController {!message.deleted;}+ /// Deletion also permits the reader's own Buddy proposal. Both its+ /// attribution and source owner must agree; the server authorizes again.+ bool canDelete(SuperTabMessage message) {+ final group = snapshot?.conversation(message.conversationId);+ return canWrite &&+ group != null &&+ !group.archived &&+ !isEarlierBuddyChat(group) &&+ message.author['kind'] == 'person' &&+ message.authorId == accountId &&+ (message.source.isEmpty ||+ (message.source['kind'] == 'buddy-proposal' &&+ message.source['personId'] == accountId)) &&+ !message.deleted;+ }+/// Replaces [message]'s text with [text], trimmed. The same text sends/// nothing; empty text only goes for a message with files.Future<String?> editMessage(SuperTabMessage message, String text) async {diff --git a/desktop/lib/super_tabs/view.dart b/desktop/lib/super_tabs/view.dartindex 31a728ba3..5cc542e2c 100644--- a/desktop/lib/super_tabs/view.dart+++ b/desktop/lib/super_tabs/view.dart@@ -4291,7 +4291,7 @@ class _SuperTabViewState extends State<SuperTabView>onEdit: c.canChange(message)? (text) => _editMessage(message, text): null,- onDelete: c.canChange(message)+ onDelete: c.canDelete(message)? () => unawaited(_deleteMessage(message)): null,// A message with a thread is answered there; one from before threadsdiff --git a/desktop/test/super_tab_message_edit_test.dart b/desktop/test/super_tab_message_edit_test.dartindex c3819dbbf..beff1edaa 100644--- a/desktop/test/super_tab_message_edit_test.dart+++ b/desktop/test/super_tab_message_edit_test.dart@@ -1,5 +1,10 @@+import 'dart:convert';+import 'dart:io';+import 'dart:ui' as ui;+import 'package:flutter/gestures.dart';import 'package:flutter/material.dart';+import 'package:flutter/rendering.dart';import 'package:flutter/services.dart';import 'package:flutter_test/flutter_test.dart';import 'package:harness/shared/theme/app_theme.dart' as grid;@@ -14,6 +19,48 @@ import 'support/super_tab_fixture.dart';/// an edit shows "(edited)", a delete with replies leaves "This message was/// deleted." and one without replies goes.void main() {+ setUpAll(() async {+ if (Platform.environment['BUDDY_DELETE_SHOTS'] == null) return;+ final sf = ByteData.sublistView(+ await File('/System/Library/Fonts/SFNS.ttf').readAsBytes(),+ );+ for (final family in {+ '.AppleSystemUIFont',+ 'Roboto',+ grid.AppFont.sans,+ ...grid.AppFont.sansFallback,+ }) {+ await (FontLoader(family)..addFont(Future.value(sf))).load();+ }+ final manifest =+ jsonDecode(await rootBundle.loadString('FontManifest.json')) as List;+ for (final entry in manifest.cast<Map>()) {+ final loader = FontLoader(entry['family'] as String);+ for (final font in (entry['fonts'] as List).cast<Map>()) {+ loader.addFont(rootBundle.load(font['asset'] as String));+ }+ await loader.load();+ }+ });++ final picture = GlobalKey();+ var brightness = Brightness.dark;++ Future<void> shot(WidgetTester tester, String platform) async {+ final folder = Platform.environment['BUDDY_DELETE_SHOTS'];+ if (folder == null) return;+ await tester.runAsync(() async {+ final boundary =+ picture.currentContext!.findRenderObject()! as RenderRepaintBoundary;+ final image = await boundary.toImage(pixelRatio: 1.5);+ final bytes = await image.toByteData(format: ui.ImageByteFormat.png);+ await Directory(folder).create(recursive: true);+ await File('$folder/$platform-buddy-delete-${brightness.name}.png')+ .writeAsBytes(bytes!.buffer.asUint8List());+ image.dispose();+ });+ }+late SuperTabController c;Future<void> show(@@ -27,7 +74,9 @@ void main() {await c.refresh();await tester.pumpWidget(MaterialApp(- theme: grid.buildAppTheme(brightness: Brightness.dark),+ theme: grid.buildAppTheme(brightness: brightness),+ builder: (context, child) =>+ RepaintBoundary(key: picture, child: child),home: Scaffold(body: SuperTabView(controller: c,@@ -117,6 +166,62 @@ void main() {);});+ for (final appearance in Brightness.values) {+ testWidgets(+ 'your Buddy proposal offers Delete without Edit (${appearance.name})',+ (tester) async {+ brightness = appearance;+ grid.AppTheme.brightness.value = appearance;+ addTearDown(() => grid.AppTheme.brightness.value = Brightness.light);+ final server = ConversationServer()..append('Please fix the menu');+ server.messages.single['source'] = {+ 'kind': 'buddy-proposal',+ 'personId': 'owner',+ };+ await show(tester, server);+ await openMore(tester, 'message-1');+ expect(find.text('Delete message'), findsOneWidget);+ expect(find.text('Edit message'), findsNothing);+ await shot(tester, 'desktop');+ },+ );+ }++ for (final entry in <String, Map<String, dynamic>>{+ 'another person': {'kind': 'person', 'id': 'huy', 'name': 'Huy'},+ 'an agent': {'kind': 'agent', 'id': 'owner', 'name': 'Buddy'},+ }.entries) {+ testWidgets('${entry.key} cannot delete an owner Buddy proposal', (+ tester,+ ) async {+ final server = ConversationServer()..append('Please fix the menu');+ server.messages.single+ ..['author'] = entry.value+ ..['source'] = {'kind': 'buddy-proposal', 'personId': 'owner'};+ await show(tester, server);+ await openMore(tester, 'message-1');+ expect(find.text('Delete message'), findsNothing);+ expect(find.text('Edit message'), findsNothing);+ });+ }++ for (final source in [+ {'kind': 'buddy-proposal', 'personId': 'huy'},+ {'kind': 'buddy-proposal'},+ {'kind': 'task-line', 'personId': 'owner'},+ ]) {+ testWidgets('a source that does not authorize owner deletion: $source', (+ tester,+ ) async {+ final server = ConversationServer()..append('Please fix the menu');+ server.messages.single['source'] = source;+ await show(tester, server);+ await openMore(tester, 'message-1');+ expect(find.text('Delete message'), findsNothing);+ expect(find.text('Edit message'), findsNothing);+ });+ }+testWidgets('an agent’s and another person’s message offer neither', (tester,) async {diff --git a/docs/plans/2026-11-05-buddy-post-delete-plan.md b/docs/plans/2026-11-05-buddy-post-delete-plan.mdnew file mode 100644index 000000000..f0b62db4d--- /dev/null+++ b/docs/plans/2026-11-05-buddy-post-delete-plan.md@@ -0,0 +1,59 @@+# Buddy post deletion implementation plan++> Implement task by task in this Engineer session, test first, followed by independent review and testing.++**Goal:** Let the attributed owner delete their Buddy proposal on Desktop and phone without offering Edit.++**Architecture:** Keep plain-message edit eligibility intact. Add a delete-only predicate matching the server's person attribution and buddy-proposal personId checks, and use it in both apps' existing menus, including phone threads.++**Tech Stack:** Dart, Flutter, flutter_test.++**Spec:** Swarm task #3330; backend contract in PR #3180 (`messageEdits.ts`).++## Global Constraints++- Separate branch based on `super-tab/8439eda0e00391dac310b817`; no backend changes.+- Only the attributed person with write access sees Delete. Edit remains hidden for proposals.+- Keep existing confirmation, request and failure handling; no real CLI sign-in or persistent state in tests.+- Desktop, web, iOS and Android share their existing menu paths; no process changes.+- Two security reviews shared with #3322, plus independent UI testing before merge.++## Review Focus++- A mismatched or missing source personId must not expose Delete.+- Agent attribution must never qualify, even with a matching source personId.+- Archived/read-only/deleted messages must retain their existing restrictions.+- Phone thread menus must use the same deletion eligibility as the main chat.+- Plain messages retain both actions; system sources retain neither.++## Design++No new storage, synchronization, identity, query or migration. Growth, concurrency, read cost, scale, compatibility, migration and rollback: N/A because this only offers an existing command. Audience: server independently authorizes deletion. Identity: current signed-in account only. Failure: existing refusal UI. Platforms: Desktop/web and phone use their existing menus.++## Task 1: Desktop owner deletion++**Files:** `desktop/lib/super_tabs/profile_actions.dart`, `desktop/lib/super_tabs/view.dart`, `desktop/test/super_tab_message_edit_test.dart`, `desktop/test/super_tab_profile_actions_test.dart`.++**Interfaces:** Consume SuperTabMessage author/source and current controller access. Produce `bool canDelete(SuperTabMessage message)`; preserve `canChange` for Edit.++- [x] Commit widget tests asserting owner proposal offers Delete but no Edit; another person's and agent-authored proposals offer neither. Add eligibility coverage for mismatched source ownership and restricted messages.+- [x] Run affected tests and record the expected missing Delete failure.+- [x] Add delete-only eligibility and wire the existing menu; run affected tests green and commit.++## Task 2: Phone owner deletion++**Files:** `mobile/lib/swarm/swarm_conversation.dart`, `mobile/lib/swarm/swarm_conversation_page.dart`, `mobile/test/swarm/swarm_message_edit_test.dart`.++**Interfaces:** Consume SuperTabMessage and SwarmConversation access. Produce `bool mayDelete(SuperTabMessage message)`; preserve `mayChange` for Edit; use in chat and thread menus.++- [x] Commit widget tests for owner Delete/no Edit and denial for other-person, agent and mismatched source proposals, including thread menu.+- [x] Run affected tests and record expected missing Delete failure.+- [x] Implement and wire delete-only eligibility, run affected tests green and commit.++## Validation and handoff++- [x] Run affected Desktop profile/message tests and phone message edit tests with Flutter 3.47.2/Dart 3.13.2; run `python3 scripts/check-ui-style.py`.+- [x] Capture light/dark menus in both apps with in-memory/fake sign-in fixtures.+- [ ] Add red/green evidence to PR comment, mark Ready and hand off to Integrator for shared security reviews and independent UI testing. CI supplies touched component suites.++Evidence: Desktop red at 5bca9b57 (Delete absent); phone chat and thread red at 5e769b79 (Delete absent). Green at cc261e22: 29 Desktop and 23 phone tests, with light/dark menu captures. The inherited backend plan-only update was merged; no backend code changed here. Screenshot fixture initially failed compilation due to an unqualified font name; corrected before the final green runs.diff --git a/mobile/lib/swarm/swarm_conversation.dart b/mobile/lib/swarm/swarm_conversation.dartindex e97c7be78..5905c39ed 100644--- a/mobile/lib/swarm/swarm_conversation.dart+++ b/mobile/lib/swarm/swarm_conversation.dart@@ -1203,7 +1203,7 @@ class SwarmConversation extends ChangeNotifierreturn refused == null;}- /// The person may edit and delete [message]: their own plain post (no+ /// The person may edit [message]: their own plain post (no/// note the server wrote in their name), not deleted, where they may post./// The backend decides again (messageEdits.ts); this only hides the menu.bool mayChange(SuperTabMessage message) =>@@ -1213,6 +1213,17 @@ class SwarmConversation extends ChangeNotifiermessage.source.isEmpty &&!message.deleted;+ /// Buddy proposals are delete-only, for the attributed person whose id+ /// also matches their source. The backend independently authorizes this.+ bool mayDelete(SuperTabMessage message) =>+ canPost &&+ message.author['kind'] == 'person' &&+ message.authorId == reader.accountId &&+ (message.source.isEmpty ||+ (message.source['kind'] == 'buddy-proposal' &&+ message.source['personId'] == reader.accountId)) &&+ !message.deleted;+/// Puts [text], trimmed, in place of [message]'s (backend `message.edit`):/// the chat shows it, "(edited)", once the backend has it. Answers why it/// was refused, the old text staying; null once done, or when nothingdiff --git a/mobile/lib/swarm/swarm_conversation_page.dart b/mobile/lib/swarm/swarm_conversation_page.dartindex 777c1c19d..aaba99252 100644--- a/mobile/lib/swarm/swarm_conversation_page.dart+++ b/mobile/lib/swarm/swarm_conversation_page.dart@@ -1867,7 +1867,9 @@ class _SwarmConversationPageState extends State<SwarmConversationPage>onEdit: mine && !_isVoice(message)? () => unawaited(_edit(shown, (m, text) => t.editMessage(m, text))): null,- onDelete: mine ? () => unawaited(_delete(shown, t.deleteMessage)) : null,+ onDelete: c.mayDelete(message)+ ? () => unawaited(_delete(shown, t.deleteMessage))+ : null,);if (emoji == null || !mounted) return;if (shown() case final now?) await t.react(now, emoji);@@ -1940,7 +1942,9 @@ class _SwarmConversationPageState extends State<SwarmConversationPage>onEdit: mine && !_isVoice(message)? () => unawaited(_edit(shown, c.editMessage)): null,- onDelete: mine ? () => unawaited(_delete(shown, c.deleteMessage)) : null,+ onDelete: link && c.mayDelete(message)+ ? () => unawaited(_delete(shown, c.deleteMessage))+ : null,);if (emoji == null || !mounted) return;if (shown() case final now?) await c.react(now, emoji);diff --git a/mobile/lib/swarm/swarm_reactions.dart b/mobile/lib/swarm/swarm_reactions.dartindex 7fff85044..d19929dc9 100644--- a/mobile/lib/swarm/swarm_reactions.dart+++ b/mobile/lib/swarm/swarm_reactions.dart@@ -408,7 +408,9 @@ class _Action extends StatelessWidget {children: [Icon(icon, size: 20, color: ink),const SizedBox(width: AppSpace.m),- Text(label, style: AppType.body(color: ink)),+ Expanded(+ child: Text(label, style: AppType.body(color: ink)),+ ),],),),diff --git a/mobile/test/swarm/swarm_message_edit_test.dart b/mobile/test/swarm/swarm_message_edit_test.dartindex ae070ffa6..e6bc938af 100644--- a/mobile/test/swarm/swarm_message_edit_test.dart+++ b/mobile/test/swarm/swarm_message_edit_test.dart@@ -1,4 +1,9 @@+import 'dart:convert';+import 'dart:io';+import 'dart:ui' as ui;+import 'package:flutter/material.dart';+import 'package:flutter/rendering.dart';import 'package:flutter/services.dart';import 'package:flutter_test/flutter_test.dart';import 'package:harness_mobile/notify/system_notices.dart';@@ -21,6 +26,48 @@ import 'swarm_fixture.dart';/// asks first, and the chat shows "(edited)" and "This message was deleted."/// as the backend's rows say (`editedAt`, `deletedAt`).void main() {+ setUpAll(() async {+ if (Platform.environment['BUDDY_DELETE_SHOTS'] == null) return;+ final sf = ByteData.sublistView(+ await File('/System/Library/Fonts/SFNS.ttf').readAsBytes(),+ );+ for (final family in {+ '.AppleSystemUIFont',+ 'Roboto',+ grid.AppFont.sans,+ ...grid.AppFont.sansFallback,+ }) {+ await (FontLoader(family)..addFont(Future.value(sf))).load();+ }+ final manifest =+ jsonDecode(await rootBundle.loadString('FontManifest.json')) as List;+ for (final entry in manifest.cast<Map>()) {+ final loader = FontLoader(entry['family'] as String);+ for (final font in (entry['fonts'] as List).cast<Map>()) {+ loader.addFont(rootBundle.load(font['asset'] as String));+ }+ await loader.load();+ }+ });++ final picture = GlobalKey();+ var brightness = Brightness.dark;++ Future<void> shot(WidgetTester tester, String platform) async {+ final folder = Platform.environment['BUDDY_DELETE_SHOTS'];+ if (folder == null) return;+ await tester.runAsync(() async {+ final boundary =+ picture.currentContext!.findRenderObject()! as RenderRepaintBoundary;+ final image = await boundary.toImage(pixelRatio: 1.5);+ final bytes = await image.toByteData(format: ui.ImageByteFormat.png);+ await Directory(folder).create(recursive: true);+ await File('$folder/$platform-buddy-delete-${brightness.name}.png')+ .writeAsBytes(bytes!.buffer.asUint8List());+ image.dispose();+ });+ }+const messages = '/api/super-tabs/$tab/conversations/g1/messages';const commands = '/api/super-tabs/$tab/commands';const deleted = 'This message was deleted.';@@ -143,8 +190,11 @@ void main() {addTearDown(host.dispose);await tester.pumpWidget(MaterialApp(- theme: grid.buildAppTheme(brightness: Brightness.dark),- builder: (context, child) => SwarmScope(notifier: host, child: child!),+ theme: grid.buildAppTheme(brightness: brightness),+ builder: (context, child) => RepaintBoundary(+ key: picture,+ child: SwarmScope(notifier: host, child: child!),+ ),home: const SwarmConversationPage(swarmId: tab, conversationId: 'g1'),),);@@ -266,6 +316,115 @@ void main() {});});+ for (final appearance in Brightness.values) {+ testWidgets(+ 'your Buddy proposal offers Delete without Edit (${appearance.name})',+ (tester) async {+ await tester.binding.setSurfaceSize(const Size(390, 844));+ addTearDown(() => tester.binding.setSurfaceSize(null));+ brightness = appearance;+ grid.AppTheme.brightness.value = appearance;+ addTearDown(() => grid.AppTheme.brightness.value = Brightness.light);+ await pump(+ tester,+ backend([+ message(+ 'm1',+ 1,+ text: 'Please fix the menu',+ source: {'kind': 'buddy-proposal', 'personId': me},+ ),+ ]),+ );+ await tester.longPress(find.text('Please fix the menu'));+ await tester.pumpAndSettle();+ expect(delete, findsOneWidget);+ expect(edit, findsNothing);+ await shot(tester, 'phone');+ },+ );+ }++ for (final author in ['person-ann', 'agent-builder']) {+ testWidgets('$author Buddy proposal offers neither action', (tester) async {+ await pump(+ tester,+ backend([+ message(+ 'm1',+ 1,+ text: 'Please fix the menu',+ author: author,+ source: {'kind': 'buddy-proposal', 'personId': me},+ ),+ ]),+ );+ await tester.longPress(find.text('Please fix the menu'));+ await tester.pumpAndSettle();+ expect(delete, findsNothing);+ expect(edit, findsNothing);+ });+ }++ for (final source in [+ {'kind': 'buddy-proposal', 'personId': 'person-ann'},+ {'kind': 'buddy-proposal'},+ {'kind': 'task-line', 'personId': me},+ ]) {+ testWidgets('source cannot authorize owner deletion: $source', (+ tester,+ ) async {+ await pump(+ tester,+ backend([+ message('m1', 1, text: 'Please fix the menu', source: source),+ ]),+ );+ await tester.longPress(find.text('Please fix the menu'));+ await tester.pumpAndSettle();+ expect(delete, findsNothing);+ expect(edit, findsNothing);+ });+ }++ testWidgets('your Buddy proposal in a thread offers Delete without Edit', (+ tester,+ ) async {+ final root = message(+ 'm1',+ 1,+ author: 'agent-lead',+ text: 'Root',+ thread: 'm1',+ );+ final reply = message(+ 'm2',+ 2,+ text: 'Please fix the menu',+ thread: 'm1',+ replyTo: 'm1',+ source: {'kind': 'buddy-proposal', 'personId': me},+ );+ final fake = backend([root, reply], threads: [line('m1', 1, 2)]);+ fake.routes['$messages?thread=m1'] = (_) => {+ 'messages': [reply, root],+ 'next': null,+ 'threads': <Object>[],+ };+ await pump(tester, fake);+ await tester.tap(key('swarm-thread-line-m1'));+ await tester.pumpAndSettle();+ await tester.longPress(+ find.descendant(+ of: key('swarm-thread-messages'),+ matching: find.text('Please fix the menu'),+ ),+ );+ await tester.pumpAndSettle();+ expect(delete, findsOneWidget);+ expect(edit, findsNothing);+ });+group('Edit message', () {testWidgets('opens the text in a field; Save sends message.edit and the ''chat shows the new text, edited', (tester) async {diff --git a/mobile/test/swarm/swarm_reactions_test.dart b/mobile/test/swarm/swarm_reactions_test.dartindex 876598021..4e640b013 100644--- a/mobile/test/swarm/swarm_reactions_test.dart+++ b/mobile/test/swarm/swarm_reactions_test.dart@@ -4,6 +4,7 @@ import 'package:flutter_test/flutter_test.dart';import 'package:harness_mobile/shared/theme/app_theme.dart' as grid;import 'package:harness_mobile/swarm/model.dart';import 'package:harness_mobile/swarm/parts.dart';+import 'package:harness_mobile/swarm/swarm_message_link.dart';import 'package:harness_mobile/swarm/swarm_reactions.dart';import 'swarm_fixture.dart';@@ -336,6 +337,54 @@ void main() {expect(await picked, SuperTabReactionEmoji.check);});+ for (final scale in [1.0, 2.0]) {+ testWidgets('menu actions fit a 390-point phone at ${scale}x text', (+ tester,+ ) async {+ tester.view.physicalSize = const Size(390, 844);+ tester.view.devicePixelRatio = 1;+ addTearDown(tester.view.reset);+ tester.platformDispatcher.textScaleFactorTestValue = scale;+ addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue);+ late BuildContext context;+ await show(+ tester,+ Builder(+ builder: (value) {+ context = value;+ return const SizedBox();+ },+ ),+ );+ var deleted = false;+ final picked = showSwarmReactionPicker(+ context,+ reactions: const [],+ readerId: me,+ link: const SwarmMessageLink(+ tabId: tab,+ conversationId: 'g1',+ messageId: 'm1',+ ),+ onDelete: () => deleted = true,+ );+ await tester.pumpAndSettle();++ expect(tester.takeException(), isNull);+ for (final label in ['Copy link to message', 'Delete message']) {+ final bounds = tester.getRect(find.text(label));+ expect(bounds.left, greaterThanOrEqualTo(0));+ expect(bounds.right, lessThanOrEqualTo(390));+ }+ final action = find.byKey(const ValueKey('swarm-delete-message'));+ expect(tester.getSize(action).height, greaterThanOrEqualTo(44));+ await tester.tap(action);+ await tester.pumpAndSettle();+ expect(deleted, isTrue);+ expect(await picked, isNull);+ });+ }+testWidgets('dims the page as every sheet does, and draws each emoji at '"an icon's size, 24 points", (tester) async {final picked = await open(tester, const []);