The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
Desktop: a send error shows only under the chat it belongs to (#2224)
0xken151b1c17b779e9
diff --git a/desktop/lib/super_tabs/controller.dart b/desktop/lib/super_tabs/controller.dartindex 7a32dfa8a..1094f548d 100644--- a/desktop/lib/super_tabs/controller.dart+++ b/desktop/lib/super_tabs/controller.dart@@ -210,7 +210,10 @@ class SuperTabController extends ChangeNotifier {final value = superTabMap(initial['pending']);if (value['operationId'] is String && value['command'] is Map) {_pending = value;- operationError = 'Check the pending action before sending it again.';+ _failOperation(+ 'Check the pending action before sending it again.',+ command: superTabMap(value['command']),+ );}}}@@ -270,10 +273,36 @@ class SuperTabController extends ChangeNotifier {/// from [operationError] so it shows only under its own conversation.final _uploadErrors = <String, String>{};+ /// The conversation the last action that set [operationError] was for, or+ /// null when it was for none (a machine, a member, the Swarm).+ String? _operationErrorFor;+/// What the composer of [conversationId] says went wrong: the last action's- /// [operationError], else its own upload failure.- String? composerError(String conversationId) =>- operationError ?? _uploadErrors[conversationId];+ /// [operationError] when it was for this conversation or for none, else its+ /// own upload failure. An action still unconfirmed blocks every composer's+ /// send, so its error shows in each, with Retry.+ String? composerError(String conversationId) {+ final failure = operationError;+ if (failure != null &&+ (_operationErrorFor == null ||+ _operationErrorFor == conversationId ||+ _pending != null)) {+ return failure;+ }+ return _uploadErrors[conversationId];+ }++ /// Sets [operationError] for [command], remembering its conversation.+ void _failOperation(+ String message, {+ required Map<String, dynamic> command,+ String? code,+ }) {+ operationError = message;+ operationErrorCode = code;+ final id = command['conversationId'];+ _operationErrorFor = id is String ? id : null;+ }/// One line for the sender after a command succeeds, from the backend: that a/// credential was removed from what they sent and should be revoked.@@ -2943,8 +2972,11 @@ class SuperTabController extends ChangeNotifier {} catch (failure) {if (!_disposed && _isUpdateRequired(failure)) {_requireUpdate();- operationError = updateMessage;- operationErrorCode = 'UPDATE_REQUIRED';+ _failOperation(+ updateMessage,+ command: superTabMap(pending['command']),+ code: 'UPDATE_REQUIRED',+ );// Refused by the backend: nothing was done, nothing to retry._refuse(pending, operationError!);_pending = null;@@ -2954,10 +2986,13 @@ class SuperTabController extends ChangeNotifier {_pending = pending;}} else if (!_disposed) {- operationError = failure is SuperTabFailure- ? failure.message- : 'The action is not confirmed. Retry to check it.';- operationErrorCode = failure is SuperTabFailure ? failure.code : null;+ _failOperation(+ failure is SuperTabFailure+ ? failure.message+ : 'The action is not confirmed. Retry to check it.',+ command: superTabMap(pending['command']),+ code: failure is SuperTabFailure ? failure.code : null,+ );if (failure is SuperTabFailure &&failure.statusCode >= 400 &&failure.statusCode < 500 &&@@ -3054,7 +3089,10 @@ class SuperTabController extends ChangeNotifier {? said.where((id) => !isPerson(id)).toList(): recipients;if (addressed.any((id) => !selected!.agentIds.contains(id))) {- operationError = 'A mentioned agent is no longer in this conversation. Remove its mention or choose another agent.';+ _failOperation(+ 'A mentioned agent is no longer in this conversation. Remove its mention or choose another agent.',+ command: {'conversationId': selectedId},+ );_changed();return null;}diff --git a/desktop/lib/super_tabs/view.dart b/desktop/lib/super_tabs/view.dartindex 835522f59..4c2dbc47e 100644--- a/desktop/lib/super_tabs/view.dart+++ b/desktop/lib/super_tabs/view.dart@@ -2747,12 +2747,15 @@ class _SuperTabViewState extends State<SuperTabView>.outgoing(c.selectedId).where((sent) => sent.inMainStream).toList();- // A failed message says so in its own row, with what can be done.+ // A failed message says so in its own row, with what can be done. Only+ // this conversation's own error is said there; another's never hides it.+ final composerError = c.composerError(c.selectedId);final errorInRow = outgoing.any((sent) => switch (sent.state) {SuperTabOutgoingState.sending => false,SuperTabOutgoingState.unconfirmed => c.hasPendingAction,- SuperTabOutgoingState.refused => sent.error == c.operationError,+ SuperTabOutgoingState.refused =>+ composerError != null && sent.error == composerError,},);final finding = _finding?.conversationId == c.selectedId ? _finding : null;@@ -3013,14 +3016,14 @@ class _SuperTabViewState extends State<SuperTabView>],),),- if (c.composerError(c.selectedId) != null && !errorInRow)+ if (composerError != null && !errorInRow)Padding(padding: const EdgeInsets.symmetric(horizontal: 24),child: Row(children: [Expanded(child: Text(- c.composerError(c.selectedId)!,+ composerError,style: DesktopChrome.control(),),),diff --git a/desktop/test/super_tab_composer_error_test.dart b/desktop/test/super_tab_composer_error_test.dartindex 61b5f1d8d..d8055f00a 100644--- a/desktop/test/super_tab_composer_error_test.dart+++ b/desktop/test/super_tab_composer_error_test.dart@@ -90,6 +90,77 @@ void main() {expect(c.composerError('lead'), c.operationError);});+ test('a refused send shows only under its own conversation, and the '+ 'other keeps its upload error', () async {+ await c.select('offline');+ server.failUpload = 'a.png';+ c.attachments('offline').add([HarnessAttachment('a.png', _png)]);+ await c.send();+ expect(c.composerError('offline'), 'The file is too large.');++ await c.select('lead');+ server.failUpload = null;+ server.reject = true;+ c.setDraft('lead', 'Hello');+ expect(await c.send(), isNull);+ expect(c.hasPendingAction, isFalse);+ expect(c.composerError('lead'), 'Choose an agent in this conversation.');++ await c.select('offline');+ expect(c.composerError('offline'), 'The file is too large.');++ await c.select('lead');+ expect(c.composerError('lead'), 'Choose an agent in this conversation.');+ });++ test('a send forbidden in one conversation is not said in another',+ () async {+ server+ ..refuse = {'code': 'FORBIDDEN', 'message': 'You can’t write here.'}+ ..refuseStatus = 403;+ c.setDraft('lead', 'Hello');+ expect(await c.send(), isNull);+ expect(c.composerError('lead'), 'You can’t write here.');++ server.refuse = null;+ await c.select('offline');+ expect(c.composerError('offline'), isNull);+ });++ test('a mention that is gone says so only in its own conversation',+ () async {+ c.setDraft('lead', 'Hello');+ await c.send(recipients: ['no-longer-present']);+ expect(c.composerError('lead'), contains('mentioned agent'));++ await c.select('offline');+ expect(c.composerError('offline'), isNull);+ });++ test('a send still unconfirmed blocks every composer, so each says why',+ () async {+ server.loseReply = true;+ c.setDraft('lead', 'Hello');+ expect(await c.send(), isNull);+ expect(c.hasPendingAction, isTrue);++ await c.select('offline');+ expect(+ c.composerError('offline'),+ 'The action is not confirmed. Retry to check it.',+ );+ });++ test('a refusal outside any conversation still shows where the person '+ 'is', () async {+ server.refuse = {'code': 'NOPE', 'message': 'Not allowed.'};+ expect(+ await c.command({'type': 'agent.release', 'agentId': 'a'}),+ isNull,+ );+ expect(c.composerError('lead'), 'Not allowed.');+ });+test('an upload still running at a switch fails into its own ''conversation, not the one now shown', () async {final gate = Completer<Map<String, dynamic>>();diff --git a/desktop/test/super_tab_composer_flow_test.dart b/desktop/test/super_tab_composer_flow_test.dartindex 92377d14a..6a4d95af2 100644--- a/desktop/test/super_tab_composer_flow_test.dart+++ b/desktop/test/super_tab_composer_flow_test.dart@@ -5,6 +5,7 @@ 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/state/harness_attachments.dart';import 'package:harness/super_tabs/controller.dart';import 'package:harness/super_tabs/message_row.dart';import 'package:harness/super_tabs/view.dart';@@ -271,6 +272,34 @@ void main() {await tester.pump(const Duration(seconds: 1));}, variant: TargetPlatformVariant.only(TargetPlatform.macOS));+ testWidgets('another conversation\'s refusal never hides this one\'s '+ 'upload error, even with the same words in a row here', (tester) async {+ final server = ConversationServer();+ final c = await show(tester, server);+ // This conversation: a refused message, then its own refused file.+ await c.select('offline');+ server.reject = true;+ c.setDraft('offline', 'First');+ await c.send();+ server.reject = false;+ server.failUpload = 'a.png';+ c.attachments('offline').add([+ HarnessAttachment('a.png', Uint8List.fromList([1, 2, 3])),+ ]);+ await c.send();+ // Another conversation is refused with the same words.+ await c.select('lead');+ server.failUpload = null;+ server.reject = true;+ c.setDraft('lead', 'Second');+ await c.send();++ await c.select('offline');+ await tester.pumpAndSettle();+ expect(find.text('The file is too large.'), findsOneWidget);+ await tester.pump(const Duration(seconds: 1));+ }, variant: TargetPlatformVariant.only(TargetPlatform.macOS));+for (final failure in ['refused', 'unanswered']) {testWidgets('Delete removes a $failure message from the chat', (tester,diff --git a/desktop/test/support/super_tab_fixture.dart b/desktop/test/support/super_tab_fixture.dartindex 0b1d04450..c8152e41c 100644--- a/desktop/test/support/super_tab_fixture.dart+++ b/desktop/test/support/super_tab_fixture.dart@@ -409,8 +409,10 @@ class ConversationServer {Map<String, dynamic>? saved;// While set, every read waits for it: a slow server.Completer<void>? holdReads;- // Makes every command answer with this refusal: {code, message}.+ // Makes every command answer with this refusal: {code, message}, with+ // [refuseStatus] as its HTTP status.Map<String, String>? refuse;+ int refuseStatus = 409;// Added to every successful command's result, as a newer backend adds// fields such as `credentialNotice`.final commandResult = <String, dynamic>{};@@ -746,7 +748,7 @@ class ConversationServer {throw SuperTabFailure(refusal['code']!,refusal['message']!,- statusCode: 409,+ statusCode: refuseStatus,);}final operationId = body['operationId'] as String;