From 86f35755ebf123ae6ced4d92067109cf1a644ddc Mon Sep 17 00:00:00 2001 From: Udhay-Adithya Date: Sat, 27 Sep 2025 18:06:02 +0530 Subject: [PATCH] feat: remove unused openapi action button --- .../core/common/widgets/dashbot_action.dart | 8 +++--- .../dashbot_actions_buttons.dart | 1 - .../core/services/openapi_import_service.dart | 28 ------------------- .../chat/viewmodel/chat_viewmodel.dart | 21 -------------- .../services/openapi_import_service_test.dart | 14 ---------- 5 files changed, 4 insertions(+), 68 deletions(-) diff --git a/lib/dashbot/core/common/widgets/dashbot_action.dart b/lib/dashbot/core/common/widgets/dashbot_action.dart index b5fe7f9e..d54720a7 100644 --- a/lib/dashbot/core/common/widgets/dashbot_action.dart +++ b/lib/dashbot/core/common/widgets/dashbot_action.dart @@ -34,7 +34,10 @@ class DashbotActionWidgetFactory { case ChatActionType.applyCurl: return DashbotApplyCurlButton(action: action); case ChatActionType.applyOpenApi: - return DashbotApplyOpenApiButton(action: action); + if (action.action == 'import_now_openapi') { + return DashbotImportNowButton(action: action); + } + return null; case ChatActionType.downloadDoc: return DashbotDownloadDocButton(action: action); case ChatActionType.noAction: @@ -70,9 +73,6 @@ class DashbotActionWidgetFactory { if (action.action == 'apply_curl') { return DashbotApplyCurlButton(action: action); } - if (action.action == 'apply_openapi') { - return DashbotApplyOpenApiButton(action: action); - } if (action.action.contains('update') || action.action.contains('add') || action.action.contains('delete')) { diff --git a/lib/dashbot/core/common/widgets/dashbot_action_buttons/dashbot_actions_buttons.dart b/lib/dashbot/core/common/widgets/dashbot_action_buttons/dashbot_actions_buttons.dart index 0e6c0f7f..6b8b09b5 100644 --- a/lib/dashbot/core/common/widgets/dashbot_action_buttons/dashbot_actions_buttons.dart +++ b/lib/dashbot/core/common/widgets/dashbot_action_buttons/dashbot_actions_buttons.dart @@ -1,6 +1,5 @@ export 'dashbot_add_test_button.dart'; export 'dashbot_apply_curl_button.dart'; -export 'dashbot_apply_openapi_button.dart'; export 'dashbot_auto_fix_button.dart'; export 'dashbot_download_doc_button.dart'; export 'dashbot_generate_codeblock.dart'; diff --git a/lib/dashbot/core/services/openapi_import_service.dart b/lib/dashbot/core/services/openapi_import_service.dart index 98260064..84755896 100644 --- a/lib/dashbot/core/services/openapi_import_service.dart +++ b/lib/dashbot/core/services/openapi_import_service.dart @@ -233,34 +233,6 @@ class OpenApiImportService { op: op, ); - /// Build an action message asking whether to apply to selected/new - /// for a single chosen operation. - static Map buildActionMessageFromPayload( - Map actionPayload, - {String? title}) { - final buf = StringBuffer( - title ?? 'Parsed the OpenAPI operation. Where should I apply it?'); - return { - 'explnation': buf.toString(), - 'actions': [ - { - 'action': 'apply_openapi', - 'target': 'httpRequestModel', - 'field': 'apply_to_new', - 'path': null, - 'value': actionPayload, - }, - { - 'action': 'apply_openapi', - 'target': 'httpRequestModel', - 'field': 'apply_to_selected', - 'path': null, - 'value': actionPayload, - } - ] - }; - } - static Map buildOperationPicker(OpenApi spec, {String? insights}) { final servers = spec.servers ?? const []; diff --git a/lib/dashbot/features/chat/viewmodel/chat_viewmodel.dart b/lib/dashbot/features/chat/viewmodel/chat_viewmodel.dart index 34112866..57214129 100644 --- a/lib/dashbot/features/chat/viewmodel/chat_viewmodel.dart +++ b/lib/dashbot/features/chat/viewmodel/chat_viewmodel.dart @@ -445,27 +445,6 @@ class ChatViewmodel extends StateNotifier { collection.addRequestModel(model, name: displayName); _appendSystem('Created a new request from the OpenAPI operation.', ChatMessageType.importOpenApi); - } else if (action.field == 'select_operation') { - // Present apply options for the selected operation - final applyMsg = OpenApiImportService.buildActionMessageFromPayload( - payload, - title: 'Selected ${action.path}. Where should I apply it?', - ); - final rqId = _currentRequest?.id ?? 'global'; - _addMessage( - rqId, - ChatMessage( - id: getNewUuid(), - content: jsonEncode(applyMsg), - role: MessageRole.system, - timestamp: DateTime.now(), - messageType: ChatMessageType.importOpenApi, - actions: (applyMsg['actions'] as List) - .whereType>() - .map(ChatAction.fromJson) - .toList(), - ), - ); } } diff --git a/test/dashbot/services/openapi_import_service_test.dart b/test/dashbot/services/openapi_import_service_test.dart index 526771d1..6b1e0caa 100644 --- a/test/dashbot/services/openapi_import_service_test.dart +++ b/test/dashbot/services/openapi_import_service_test.dart @@ -69,20 +69,6 @@ void main() { expect(payload['url'], 'https://api.apidash.dev/users'); expect(payload['headers'], isA()); }); - - test('buildActionMessageFromPayload returns two actions', () { - final op = spec.paths!['/users']!.post!; - final payload = OpenApiImportService.payloadForOperation( - baseUrl: spec.servers!.first.url!, - path: '/users', - method: 'post', - op: op, - ); - final msg = OpenApiImportService.buildActionMessageFromPayload(payload); - final actions = (msg['actions'] as List).cast>(); - expect(actions.length, 2); - expect(actions.first['action'], 'apply_openapi'); - }); }); group('OpenApiImportService extended coverage', () {