From bf11c73949ce89616ae08446e12f86ea157645d2 Mon Sep 17 00:00:00 2001 From: Udhay-Adithya Date: Fri, 26 Sep 2025 02:14:05 +0530 Subject: [PATCH] feat: wipe current request data before making changes --- .../core/services/actions/request_apply_service.dart | 5 +++++ lib/dashbot/core/services/curl_import_service.dart | 6 ++---- lib/dashbot/core/services/openapi_import_service.dart | 4 ++-- lib/dashbot/features/chat/viewmodel/chat_viewmodel.dart | 8 ++++++++ 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/lib/dashbot/core/services/actions/request_apply_service.dart b/lib/dashbot/core/services/actions/request_apply_service.dart index a1969290..91ec167d 100644 --- a/lib/dashbot/core/services/actions/request_apply_service.dart +++ b/lib/dashbot/core/services/actions/request_apply_service.dart @@ -107,6 +107,8 @@ class RequestApplyService { body: body, bodyContentType: bodyContentType, formData: formData.isEmpty ? null : formData, + params: const [], + isParamEnabledList: const [], ); return const ApplyResult( systemMessage: 'Applied cURL to the selected request.', @@ -221,6 +223,9 @@ class RequestApplyService { body: body, bodyContentType: bodyContentType, formData: formData.isEmpty ? null : formData, + // Wipe existing parameters and authentication to ensure clean state + params: const [], + isParamEnabledList: const [], ); return const ApplyResult( systemMessage: 'Applied OpenAPI operation to the selected request.', diff --git a/lib/dashbot/core/services/curl_import_service.dart b/lib/dashbot/core/services/curl_import_service.dart index 2ee4040f..b302d4bd 100644 --- a/lib/dashbot/core/services/curl_import_service.dart +++ b/lib/dashbot/core/services/curl_import_service.dart @@ -29,8 +29,6 @@ import 'package:curl_parser/curl_parser.dart'; /// concern). Not part of request description. /// - `--globoff`: parsing behavior for the curl CLI; irrelevant post-parse. - - /// Service to parse cURL commands and produce /// a standard action message map understood by Dashbot. class CurlImportService { @@ -117,14 +115,14 @@ class CurlImportService { { 'action': 'apply_curl', 'target': 'httpRequestModel', - 'field': 'apply_to_selected', + 'field': 'apply_to_new', 'path': null, 'value': actionPayload, }, { 'action': 'apply_curl', 'target': 'httpRequestModel', - 'field': 'apply_to_new', + 'field': 'apply_to_selected', 'path': null, 'value': actionPayload, } diff --git a/lib/dashbot/core/services/openapi_import_service.dart b/lib/dashbot/core/services/openapi_import_service.dart index 6e707d8c..98260064 100644 --- a/lib/dashbot/core/services/openapi_import_service.dart +++ b/lib/dashbot/core/services/openapi_import_service.dart @@ -246,14 +246,14 @@ class OpenApiImportService { { 'action': 'apply_openapi', 'target': 'httpRequestModel', - 'field': 'apply_to_selected', + 'field': 'apply_to_new', 'path': null, 'value': actionPayload, }, { 'action': 'apply_openapi', 'target': 'httpRequestModel', - 'field': 'apply_to_new', + 'field': 'apply_to_selected', 'path': null, 'value': actionPayload, } diff --git a/lib/dashbot/features/chat/viewmodel/chat_viewmodel.dart b/lib/dashbot/features/chat/viewmodel/chat_viewmodel.dart index d7c08a77..629730cf 100644 --- a/lib/dashbot/features/chat/viewmodel/chat_viewmodel.dart +++ b/lib/dashbot/features/chat/viewmodel/chat_viewmodel.dart @@ -417,6 +417,10 @@ class ChatViewmodel extends StateNotifier { body: body, bodyContentType: bodyContentType, formData: formData.isEmpty ? null : formData, + // Wipe existing parameters and authentication to ensure clean state + params: const [], + isParamEnabledList: const [], + authModel: null, ); _appendSystem('Applied OpenAPI operation to the selected request.', ChatMessageType.importOpenApi); @@ -911,6 +915,10 @@ class ChatViewmodel extends StateNotifier { body: body, bodyContentType: bodyContentType, formData: formData.isEmpty ? null : formData, + // Wipe existing parameters and authentication to ensure clean state + params: const [], + isParamEnabledList: const [], + authModel: null, ); _appendSystem( 'Applied cURL to the selected request.', ChatMessageType.importCurl);