feat: wipe current request data before making changes

This commit is contained in:
Udhay-Adithya
2025-09-26 02:14:05 +05:30
parent e1481e8d4e
commit bf11c73949
4 changed files with 17 additions and 6 deletions

View File

@@ -107,6 +107,8 @@ class RequestApplyService {
body: body, body: body,
bodyContentType: bodyContentType, bodyContentType: bodyContentType,
formData: formData.isEmpty ? null : formData, formData: formData.isEmpty ? null : formData,
params: const [],
isParamEnabledList: const [],
); );
return const ApplyResult( return const ApplyResult(
systemMessage: 'Applied cURL to the selected request.', systemMessage: 'Applied cURL to the selected request.',
@@ -221,6 +223,9 @@ class RequestApplyService {
body: body, body: body,
bodyContentType: bodyContentType, bodyContentType: bodyContentType,
formData: formData.isEmpty ? null : formData, formData: formData.isEmpty ? null : formData,
// Wipe existing parameters and authentication to ensure clean state
params: const [],
isParamEnabledList: const [],
); );
return const ApplyResult( return const ApplyResult(
systemMessage: 'Applied OpenAPI operation to the selected request.', systemMessage: 'Applied OpenAPI operation to the selected request.',

View File

@@ -29,8 +29,6 @@ import 'package:curl_parser/curl_parser.dart';
/// concern). Not part of request description. /// concern). Not part of request description.
/// - `--globoff`: parsing behavior for the curl CLI; irrelevant post-parse. /// - `--globoff`: parsing behavior for the curl CLI; irrelevant post-parse.
/// Service to parse cURL commands and produce /// Service to parse cURL commands and produce
/// a standard action message map understood by Dashbot. /// a standard action message map understood by Dashbot.
class CurlImportService { class CurlImportService {
@@ -117,14 +115,14 @@ class CurlImportService {
{ {
'action': 'apply_curl', 'action': 'apply_curl',
'target': 'httpRequestModel', 'target': 'httpRequestModel',
'field': 'apply_to_selected', 'field': 'apply_to_new',
'path': null, 'path': null,
'value': actionPayload, 'value': actionPayload,
}, },
{ {
'action': 'apply_curl', 'action': 'apply_curl',
'target': 'httpRequestModel', 'target': 'httpRequestModel',
'field': 'apply_to_new', 'field': 'apply_to_selected',
'path': null, 'path': null,
'value': actionPayload, 'value': actionPayload,
} }

View File

@@ -246,14 +246,14 @@ class OpenApiImportService {
{ {
'action': 'apply_openapi', 'action': 'apply_openapi',
'target': 'httpRequestModel', 'target': 'httpRequestModel',
'field': 'apply_to_selected', 'field': 'apply_to_new',
'path': null, 'path': null,
'value': actionPayload, 'value': actionPayload,
}, },
{ {
'action': 'apply_openapi', 'action': 'apply_openapi',
'target': 'httpRequestModel', 'target': 'httpRequestModel',
'field': 'apply_to_new', 'field': 'apply_to_selected',
'path': null, 'path': null,
'value': actionPayload, 'value': actionPayload,
} }

View File

@@ -417,6 +417,10 @@ class ChatViewmodel extends StateNotifier<ChatState> {
body: body, body: body,
bodyContentType: bodyContentType, bodyContentType: bodyContentType,
formData: formData.isEmpty ? null : formData, 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.', _appendSystem('Applied OpenAPI operation to the selected request.',
ChatMessageType.importOpenApi); ChatMessageType.importOpenApi);
@@ -911,6 +915,10 @@ class ChatViewmodel extends StateNotifier<ChatState> {
body: body, body: body,
bodyContentType: bodyContentType, bodyContentType: bodyContentType,
formData: formData.isEmpty ? null : formData, formData: formData.isEmpty ? null : formData,
// Wipe existing parameters and authentication to ensure clean state
params: const [],
isParamEnabledList: const [],
authModel: null,
); );
_appendSystem( _appendSystem(
'Applied cURL to the selected request.', ChatMessageType.importCurl); 'Applied cURL to the selected request.', ChatMessageType.importCurl);