Skip to content

Commit 75eed64

Browse files
committed
Simplify file processing logic by removing truncated fragment detection and always defaulting to fast replace mode
1 parent 387bb77 commit 75eed64

5 files changed

Lines changed: 2 additions & 209 deletions

File tree

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

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,11 @@ import { ModelProvidersManager } from '@/services/model-providers-manager'
1313
import { get_intelligent_update_config } from '@/utils/intelligent-update-utils'
1414
import { PROVIDERS } from '@shared/constants/providers'
1515
import { handle_intelligent_update } from './handlers/intelligent-update-handler'
16-
import { check_for_truncated_fragments } from '@/utils/check-for-truncated-fragments'
1716
import { handle_fast_replace } from './handlers/fast-replace-handler'
1817
import { PanelProvider } from '@/views/panel/backend/panel-provider'
1918
import { FileInPreview } from '@shared/types/file-in-preview'
2019
import { update_undo_button_state } from './utils/state-manager'
21-
import {
22-
check_if_all_files_new,
23-
check_for_conflict_markers
24-
} from './utils/file-checks'
20+
import { check_for_conflict_markers } from './utils/file-checks'
2521
import { handle_conflict_markers } from './handlers/conflict-markers-handler'
2622

2723
export type PreviewData = {
@@ -455,38 +451,7 @@ export const process_chat_response = async (
455451
message: 'Selecting conflict markers mode.'
456452
})
457453
} else {
458-
const all_files_new = await check_if_all_files_new(files)
459-
let has_truncated_fragments = false
460-
if (
461-
args?.edit_format === undefined ||
462-
args?.edit_format == 'truncated' // Is undefined when invoked manually
463-
) {
464-
has_truncated_fragments = check_for_truncated_fragments(files)
465-
}
466-
467-
if (all_files_new && !has_truncated_fragments) {
468-
selected_mode_label = 'Fast replace'
469-
Logger.info({
470-
function_name: 'process_chat_response',
471-
message:
472-
'All files are new - automatically selecting fast replace mode'
473-
})
474-
} else if (has_truncated_fragments) {
475-
selected_mode_label = 'Intelligent update'
476-
{
477-
Logger.info({
478-
function_name: 'process_chat_response',
479-
message:
480-
'Auto-selecting intelligent update mode due to detected truncated fragments'
481-
})
482-
}
483-
} else {
484-
selected_mode_label = 'Fast replace'
485-
Logger.info({
486-
function_name: 'process_chat_response',
487-
message: 'Defaulting to Fast replace mode'
488-
})
489-
}
454+
selected_mode_label = 'Fast replace'
490455
}
491456

492457
let final_original_states: OriginalFileState[] | null = null

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

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,4 @@
1-
import * as vscode from 'vscode'
2-
import * as fs from 'fs'
31
import { FileItem } from './clipboard-parser'
4-
import { create_safe_path } from '@/utils/path-sanitizer'
5-
6-
export const check_if_all_files_new = async (
7-
files: FileItem[]
8-
): Promise<boolean> => {
9-
const workspace_map = new Map<string, string>()
10-
vscode.workspace.workspaceFolders!.forEach((folder) => {
11-
workspace_map.set(folder.name, folder.uri.fsPath)
12-
})
13-
const default_workspace = vscode.workspace.workspaceFolders![0].uri.fsPath
14-
15-
for (const file of files) {
16-
let workspace_root = default_workspace
17-
if (file.workspace_name && workspace_map.has(file.workspace_name)) {
18-
workspace_root = workspace_map.get(file.workspace_name)!
19-
}
20-
21-
const safe_path = create_safe_path(workspace_root, file.file_path)
22-
23-
if (safe_path && fs.existsSync(safe_path)) {
24-
return false
25-
}
26-
}
27-
28-
return true
29-
}
302

313
export const check_for_conflict_markers = (files: FileItem[]): boolean => {
324
for (const file of files) {

‎packages/vscode/src/utils/check-for-truncated-fragments/check-for-truncated-fragments.spec.ts‎

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

‎packages/vscode/src/utils/check-for-truncated-fragments/check-for-truncated-fragments.ts‎

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

‎packages/vscode/src/utils/check-for-truncated-fragments/index.ts‎

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)