From 468a2ff0887ea99f471f7d89bb3af531e47901fd Mon Sep 17 00:00:00 2001 From: Cowork 3P Date: Fri, 5 Jun 2026 07:40:25 +0800 Subject: [PATCH] feat(xworkmate): optimize desktop thread actions and Go task service client --- ...app_controller_desktop_thread_actions.dart | 1 - lib/runtime/go_task_service_client.dart | 3 +- .../assistant_execution_target_test.dart | 112 +----------------- 3 files changed, 3 insertions(+), 113 deletions(-) diff --git a/lib/app/app_controller_desktop_thread_actions.dart b/lib/app/app_controller_desktop_thread_actions.dart index b7926eec..3dd7c92f 100644 --- a/lib/app/app_controller_desktop_thread_actions.dart +++ b/lib/app/app_controller_desktop_thread_actions.dart @@ -1546,7 +1546,6 @@ extension AppControllerDesktopThreadActions on AppController { normalized == 'OPENCLAW_GATEWAY_QUEUE_FULL' || normalized == 'OPENCLAW_AGENT_FAILED_BEFORE_REPLY' || normalized == 'OPENCLAW_NO_DISPLAYABLE_OUTPUT' || - normalized == 'OPENCLAW_REQUIRED_ARTIFACT_MISSING' || normalized == 'OPENCLAW_NO_EXPORTED_ARTIFACTS' || normalized == 'OPENCLAW_ARTIFACT_MISSING' || normalized == 'ARTIFACT_MISSING') { diff --git a/lib/runtime/go_task_service_client.dart b/lib/runtime/go_task_service_client.dart index 892c3d23..f5e7b63c 100644 --- a/lib/runtime/go_task_service_client.dart +++ b/lib/runtime/go_task_service_client.dart @@ -892,8 +892,7 @@ bool _inferGoTaskSuccess(Map result) { ['result', 'code'], ], ).toUpperCase(); - if (code == 'OPENCLAW_REQUIRED_ARTIFACT_MISSING' || - code == 'OPENCLAW_ARTIFACT_MISSING' || + if (code == 'OPENCLAW_ARTIFACT_MISSING' || code == 'OPENCLAW_NO_EXPORTED_ARTIFACTS' || code == 'ARTIFACT_MISSING') { return false; diff --git a/test/runtime/assistant_execution_target_test.dart b/test/runtime/assistant_execution_target_test.dart index 7df9b00c..9940cb3e 100644 --- a/test/runtime/assistant_execution_target_test.dart +++ b/test/runtime/assistant_execution_target_test.dart @@ -1903,7 +1903,7 @@ void main() { turnId: 'turn-1', raw: { 'status': 'failed', - 'code': 'OPENCLAW_REQUIRED_ARTIFACT_MISSING', + 'code': 'OPENCLAW_NO_EXPORTED_ARTIFACTS', }, errorMessage: 'openclaw returned partial artifacts without required final deliverables', @@ -1938,7 +1938,7 @@ void main() { ); expect( failedThread?.lifecycleState.lastResultCode, - 'OPENCLAW_REQUIRED_ARTIFACT_MISSING', + 'OPENCLAW_NO_EXPORTED_ARTIFACTS', ); expect(failedThread?.lastArtifactSyncStatus, 'failed'); @@ -1953,114 +1953,6 @@ void main() { }, ); - test( - 'sendChatMessage rejects partial OpenClaw artifacts on terminal artifact failure', - () async { - final fakeGoTaskService = _RecordingGoTaskServiceClient() - ..outcomes.add( - const GoTaskServiceResult( - success: false, - message: 'OpenClaw completed without required final artifacts.', - turnId: 'turn-1', - raw: { - 'status': 'failed', - 'code': 'OPENCLAW_REQUIRED_ARTIFACT_MISSING', - 'artifacts': >[ - { - 'relativePath': 'stages/chapter.md', - 'content': 'partial chapter', - 'contentType': 'text/markdown', - }, - ], - }, - errorMessage: - 'openclaw returned partial artifacts without required final deliverables', - resolvedModel: '', - route: GoTaskServiceRoute.externalAcpSingle, - ), - ); - final controller = _connectedController(fakeGoTaskService); - addTearDown(controller.dispose); - - await controller.sessionsController.switchSession( - 'unit-fixture-task-a', - ); - - await controller.sendChatMessage('first turn'); - - final failedThread = controller.taskThreadForSessionInternal( - 'unit-fixture-task-a', - ); - expect( - failedThread?.lifecycleState.lastResultCode, - 'OPENCLAW_REQUIRED_ARTIFACT_MISSING', - ); - expect(failedThread?.lastArtifactSyncStatus, 'failed'); - expect(failedThread?.lastTaskArtifactRelativePaths, isEmpty); - }, - ); - - test( - 'sendChatMessage treats nested OpenClaw artifact errors as terminal failures', - () async { - final fakeGoTaskService = _RecordingGoTaskServiceClient() - ..outcomes.add( - goTaskServiceResultFromAcpResponse( - const { - 'jsonrpc': '2.0', - 'id': 'nested-openclaw-artifact-error', - 'result': { - 'status': 'failed', - 'error': { - 'code': 'OPENCLAW_REQUIRED_ARTIFACT_MISSING', - 'message': - 'openclaw returned partial artifacts without required final deliverables', - }, - }, - }, - route: GoTaskServiceRoute.externalAcpSingle, - ), - ) - ..outcomes.add( - const GoTaskServiceResult( - success: true, - message: 'new OpenClaw session delivered final artifacts', - turnId: 'turn-2', - raw: {}, - errorMessage: '', - resolvedModel: '', - route: GoTaskServiceRoute.externalAcpSingle, - ), - ); - final controller = _connectedController(fakeGoTaskService); - addTearDown(controller.dispose); - - await controller.sessionsController.switchSession( - 'unit-fixture-task-a', - ); - - await controller.sendChatMessage('first turn'); - - expect(fakeGoTaskService.requests, hasLength(1)); - final failedThread = controller.taskThreadForSessionInternal( - 'unit-fixture-task-a', - ); - expect( - failedThread?.lifecycleState.lastResultCode, - 'OPENCLAW_REQUIRED_ARTIFACT_MISSING', - ); - expect(failedThread?.lastArtifactSyncStatus, 'failed'); - - await controller.sendChatMessage('retry final artifact'); - - expect(fakeGoTaskService.requests, hasLength(2)); - expect(fakeGoTaskService.requests.last.resumeSession, isFalse); - await _waitForLastChatMessageText( - controller, - 'new OpenClaw session delivered final artifacts', - ); - }, - ); test( 'sendChatMessage hides OpenClaw artifact guard text from failed results and streaming',