Skip to content

Commit 1c5d3fb

Browse files
committed
Refactor chat response input handling to acquire and validate the content immediately upon command execution
1 parent c64232f commit 1c5d3fb

2 files changed

Lines changed: 17 additions & 18 deletions

File tree

‎packages/shared/src/constants/dictionary.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ export const dictionary = {
198198
GIT_EXTENSION_NOT_FOUND: 'Git extension not found.',
199199
NO_GIT_REPOSITORY_FOUND: 'No Git repository found.',
200200
REPOSITORY_NOT_FOUND: 'Repository not found.',
201+
RESPONSE_TEXT_MISSING: 'Response text to apply is missing.',
201202
APPLYING_CHANGES_FAILED_EMPTY_RESPONSE: (file_path: string) =>
202203
`Applying changes to ${file_path} failed. Empty response from API.`,
203204
ERROR_DURING_REFACTORING: (file_path: string) =>
@@ -248,7 +249,6 @@ export const dictionary = {
248249
`Model provider "${name}" not found.`,
249250
API_PROVIDER_NOT_FOUND:
250251
'API provider for the selected API tool configuration was not found.',
251-
NO_RESPONSE_TEXT: 'No response text provided and clipboard is empty.',
252252
NO_WORKSPACE_FOLDER_OPEN: 'No workspace folder open.',
253253
CANNOT_PROCESS_MULTIPLE_FILES_WITHOUT_WORKSPACE:
254254
'Cannot process multiple files without an open workspace folder.',

‎packages/vscode/src/commands/apply-chat-response-command/apply-chat-response-command.ts‎

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,22 @@ export const apply_chat_response_command = (
405405
}
406406
}
407407

408+
let chat_response = args?.response
409+
if (chat_response === undefined) {
410+
chat_response = await vscode.env.clipboard.readText()
411+
if (!chat_response) {
412+
vscode.window.showInformationMessage(
413+
dictionary.information_message.CLIPBOARD_IS_EMPTY
414+
)
415+
return
416+
}
417+
} else if (!chat_response) {
418+
vscode.window.showErrorMessage(
419+
dictionary.error_message.RESPONSE_TEXT_MISSING
420+
)
421+
return
422+
}
423+
408424
const temp_checkpoint = await create_temporary_checkpoint(
409425
workspace_provider
410426
)
@@ -415,23 +431,6 @@ export const apply_chat_response_command = (
415431
}
416432

417433
const review_data = await (async (): Promise<ReviewData | null> => {
418-
let chat_response = args?.response
419-
420-
if (!chat_response) {
421-
chat_response = await vscode.env.clipboard.readText()
422-
}
423-
424-
if (!chat_response) {
425-
vscode.window.showErrorMessage(
426-
dictionary.error_message.NO_RESPONSE_TEXT
427-
)
428-
Logger.warn({
429-
function_name: 'apply_chat_response_command',
430-
message: 'Clipboard is empty.'
431-
})
432-
return null
433-
}
434-
435434
const is_single_root_folder_workspace =
436435
vscode.workspace.workspaceFolders?.length == 1
437436

0 commit comments

Comments
 (0)