Skip to content

Commit 32e52b8

Browse files
committed
Remove active editor intelligent update fallback when no code blocks are found
- Remove the fature of intelligently updating just the active editor. At the point this flow is reached, the command should be cancelled. - if the response text doesn't have anything valid to apply, checkpoint creation should not be attempted - rename 'no valid file content found in clipboard' to 'no valid response found in clipboard'. Use i18n instead of dictionary. - add missing translations to [Pasted text] - `apps/editor/src/utils/intelligent-update-utils.ts` is not shared by any other handler so doesn't have to be placed in global utils
1 parent f41df45 commit 32e52b8

8 files changed

Lines changed: 37 additions & 381 deletions

File tree

‎apps/editor/src/commands/apply-response-command/apply-response-command.ts‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -210,15 +210,15 @@ export const apply_response_command = (params: {
210210
command: 'SHOW_PROGRESS',
211211
title: t('common.progress.preparing-preview')
212212
})
213-
}
214213

215-
before_checkpoint = await create_checkpoint({
216-
workspace_provider: params.workspace_provider,
217-
extension_context: params.extension_context,
218-
prompt_view_provider: params.prompt_view_provider,
219-
trigger: 'before-response-previewed',
220-
description: args?.raw_instructions
221-
})
214+
before_checkpoint = await create_checkpoint({
215+
workspace_provider: params.workspace_provider,
216+
extension_context: params.extension_context,
217+
prompt_view_provider: params.prompt_view_provider,
218+
trigger: 'before-response-previewed',
219+
description: args?.raw_instructions
220+
})
221+
}
222222
}
223223

224224
const preview_data = await process_response({

‎apps/editor/src/commands/apply-response-command/handlers/active-editor-intelligent-update-handler.ts‎

Lines changed: 0 additions & 228 deletions
This file was deleted.

‎apps/editor/src/commands/apply-response-command/response-processor.ts‎

Lines changed: 3 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ import {
1818
sanitize_patch_content
1919
} from './handlers/diff-handler'
2020
import { apply_file_relocations } from './utils/file-operations'
21-
import { ModelProvidersManager } from '@/services/model-providers-manager'
22-
import { get_intelligent_update_config } from '@/utils/intelligent-update-utils'
23-
import { handle_active_editor_intelligent_update } from './handlers/active-editor-intelligent-update-handler'
2421
import { handle_fast_replace } from './handlers/fast-replace-handler'
2522
import { PromptViewProvider } from '@/views/prompt/backend/prompt-view-provider'
2623
import { FileInPreview } from '@shared/types/file-in-preview'
@@ -115,9 +112,6 @@ export const process_response = async (params: {
115112
}
116113
}
117114

118-
const is_single_root_folder_workspace =
119-
vscode.workspace.workspaceFolders?.length == 1
120-
121115
if (params.response_items.some((item) => item.type == 'relevant-files')) {
122116
const current_checked_files =
123117
params.workspace_provider.get_export_state().regular.checked_files
@@ -513,80 +507,9 @@ export const process_response = async (params: {
513507
)
514508

515509
if (files.length == 0) {
516-
const editor = vscode.window.activeTextEditor
517-
518-
if (editor) {
519-
const choice = await vscode.window.showWarningMessage(
520-
t('command.apply-response.warning.no-code-blocks.title'),
521-
{
522-
modal: true,
523-
detail: t('command.apply-response.warning.no-code-blocks.detail')
524-
},
525-
t('command.apply-response.warning.no-code-blocks.action')
526-
)
527-
528-
if (
529-
choice == t('command.apply-response.warning.no-code-blocks.action')
530-
) {
531-
const document = editor.document
532-
const file_path_for_block = vscode.workspace
533-
.asRelativePath(document.uri, !is_single_root_folder_workspace)
534-
.replace(/\\/g, '/')
535-
536-
const markdown_response_for_active_editor = `\`\`\`\n// ${file_path_for_block}\n${params.response}\n\`\`\``
537-
538-
const model_providers_manager = new ModelProvidersManager(
539-
params.extension_context
540-
)
541-
const api_configuration_result = await get_intelligent_update_config(
542-
model_providers_manager,
543-
false,
544-
params.extension_context
545-
)
546-
547-
if (!api_configuration_result) {
548-
return null
549-
}
550-
551-
const {
552-
model_provider,
553-
api_configuration: intelligent_update_api_configuration
554-
} = api_configuration_result
555-
const base_url = model_provider.base_url
556-
557-
const intelligent_update_states =
558-
await handle_active_editor_intelligent_update({
559-
base_url,
560-
api_key: model_provider.api_key,
561-
api_configuration: intelligent_update_api_configuration,
562-
chat_response: markdown_response_for_active_editor,
563-
extension_context: params.extension_context,
564-
is_single_root_folder_workspace,
565-
prompt_view_provider: params.prompt_view_provider
566-
})
567-
568-
if (intelligent_update_states) {
569-
update_undo_button_state({
570-
extension_context: params.extension_context,
571-
prompt_view_provider: params.prompt_view_provider,
572-
states: intelligent_update_states,
573-
applied_content: markdown_response_for_active_editor,
574-
original_editor_state: params.args?.original_editor_state
575-
})
576-
577-
return {
578-
original_states: intelligent_update_states,
579-
response: markdown_response_for_active_editor
580-
}
581-
}
582-
return null
583-
}
584-
} else {
585-
vscode.window.showInformationMessage(
586-
dictionary.information_message.NO_ACTIVE_EDITOR_FOUND
587-
)
588-
}
589-
510+
vscode.window.showErrorMessage(
511+
t('command.apply-response.error.no-valid-response')
512+
)
590513
return null
591514
}
592515

0 commit comments

Comments
 (0)