Skip to content

Commit 4080031

Browse files
committed
Implement an automatic fix setting for failed files in response previews and rename the intelligent update status field to applied_with_intelligent_update
1 parent 0b1326c commit 4080031

34 files changed

Lines changed: 216 additions & 82 deletions

‎apps/editor/package.json‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,11 @@
711711
"type": "string",
712712
"scope": "resource"
713713
},
714+
"codeWebChat.fixAllAutomatically": {
715+
"type": "boolean",
716+
"scope": "resource",
717+
"default": false
718+
},
714719
"codeWebChat.chatPresetsForAskAboutContext": {
715720
"type": "array",
716721
"scope": "resource",

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,8 @@ export const apply_chat_response_command = (params: {
263263
is_checked: true,
264264
apply_failed: state.apply_failed,
265265
ai_content: state.ai_content,
266-
fixed_with_intelligent_update:
267-
state.fixed_with_intelligent_update
266+
applied_with_intelligent_update:
267+
state.applied_with_intelligent_update
268268
})
269269

270270
if (state.file_path_to_restore) {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ export const process_chat_response = async (
7373
proposed_content: file_in_preview?.proposed_content,
7474
is_checked: file_in_preview?.is_checked,
7575
apply_failed: file_in_preview?.apply_failed,
76-
fixed_with_intelligent_update:
77-
file_in_preview?.fixed_with_intelligent_update
76+
applied_with_intelligent_update:
77+
file_in_preview?.applied_with_intelligent_update
7878
}
7979
})
8080
update_undo_button_state({

‎apps/editor/src/commands/apply-chat-response-command/types/original-file-state.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ export type OriginalFileState = {
1111
ai_content?: string
1212
proposed_content?: string
1313
apply_failed?: boolean
14-
fixed_with_intelligent_update?: boolean
14+
applied_with_intelligent_update?: boolean
1515
}

‎apps/editor/src/commands/apply-chat-response-command/utils/preview/file-preparer.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export const prepare_files_from_original_states = async (params: {
8686
is_checked: state.is_checked ?? true,
8787
apply_failed: state.apply_failed,
8888
ai_content: state.ai_content,
89-
fixed_with_intelligent_update: state.fixed_with_intelligent_update
89+
applied_with_intelligent_update: state.applied_with_intelligent_update
9090
}
9191

9292
prepared_files.push({

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { ItemInPreview } from '@shared/types/file-in-preview'
1616
export { response_preview_promise_resolve } from './vscode-ui'
1717
export { toggle_file_preview_state } from './workspace-listener'
1818
export { discard_user_changes_in_preview } from './workspace-listener'
19-
export { set_file_fixed_with_intelligent_update } from './workspace-listener'
19+
export { set_file_applied_with_intelligent_update } from './workspace-listener'
2020

2121
export const preview = async (params: {
2222
original_states: OriginalFileState[]
@@ -123,12 +123,19 @@ export const preview = async (params: {
123123
items_for_preview.push(...prepared_files.map((p) => p.previewable_file))
124124
}
125125

126+
const config = vscode.workspace.getConfiguration('codeWebChat')
127+
const fix_all_automatically = config.get<boolean>(
128+
'fixAllAutomatically',
129+
false
130+
)
131+
126132
if (params.panel_provider) {
127133
params.panel_provider.send_message({
128134
command: 'RESPONSE_PREVIEW_STARTED',
129135
items: items_for_preview,
130136
raw_instructions: params.raw_instructions,
131-
created_at: params.created_at
137+
created_at: params.created_at,
138+
fix_all_automatically
132139
})
133140
}
134141

‎apps/editor/src/commands/apply-chat-response-command/utils/preview/workspace-listener.ts‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export let discard_user_changes_in_preview:
2323
| ((file: { file_path: string; workspace_name?: string }) => Promise<void>)
2424
| undefined
2525

26-
export let set_file_fixed_with_intelligent_update:
26+
export let set_file_applied_with_intelligent_update:
2727
| ((file: { file_path: string; workspace_name?: string }) => void)
2828
| undefined
2929

@@ -657,8 +657,8 @@ export const setup_workspace_listeners = (
657657
return
658658
}
659659

660-
if (file_to_discard.previewable_file.fixed_with_intelligent_update) {
661-
file_to_discard.previewable_file.fixed_with_intelligent_update = false
660+
if (file_to_discard.previewable_file.applied_with_intelligent_update) {
661+
file_to_discard.previewable_file.applied_with_intelligent_update = false
662662
update_response_history(
663663
panel_provider,
664664
created_at,
@@ -769,14 +769,17 @@ export const setup_workspace_listeners = (
769769
}
770770
}
771771

772-
set_file_fixed_with_intelligent_update = ({ file_path, workspace_name }) => {
772+
set_file_applied_with_intelligent_update = ({
773+
file_path,
774+
workspace_name
775+
}) => {
773776
const file = prepared_files.find(
774777
(f) =>
775778
f.previewable_file.file_path == file_path &&
776779
f.previewable_file.workspace_name == workspace_name
777780
)
778781
if (file) {
779-
file.previewable_file.fixed_with_intelligent_update = true
782+
file.previewable_file.applied_with_intelligent_update = true
780783
update_response_history(panel_provider, created_at, file.previewable_file)
781784
}
782785
}
@@ -789,7 +792,7 @@ export const setup_workspace_listeners = (
789792
file_renamed_listener.dispose()
790793
toggle_file_preview_state = undefined
791794
discard_user_changes_in_preview = undefined
792-
set_file_fixed_with_intelligent_update = undefined
795+
set_file_applied_with_intelligent_update = undefined
793796
}
794797

795798
return { dispose }

‎apps/editor/src/views/panel/backend/message-handlers/handle-fix-all-failed-files.ts‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
import { PROVIDERS } from '@shared/constants/providers'
1717
import { create_safe_path } from '@/utils/path-sanitizer'
1818
import { Logger } from '@shared/utils/logger'
19-
import { set_file_fixed_with_intelligent_update } from '@/commands/apply-chat-response-command/utils/preview'
19+
import { set_file_applied_with_intelligent_update } from '@/commands/apply-chat-response-command/utils/preview'
2020

2121
export const handle_fix_all_failed_files = async (
2222
panel_provider: PanelProvider,
@@ -74,8 +74,6 @@ export const handle_fix_all_failed_files = async (
7474
endpoint_url = api_provider.base_url
7575
}
7676

77-
const max_concurrency = intelligent_update_config.max_concurrency ?? 4
78-
7977
const default_workspace_path =
8078
vscode.workspace.workspaceFolders?.[0]?.uri.fsPath
8179

@@ -125,6 +123,10 @@ export const handle_fix_all_failed_files = async (
125123
})
126124
.filter((item) => item.instructions && item.safe_path)
127125

126+
const max_concurrency =
127+
intelligent_update_config.max_concurrency ??
128+
(files_to_process.length > 0 ? files_to_process.length : 1)
129+
128130
// Process in batches
129131
for (let i = 0; i < files_to_process.length; i += max_concurrency) {
130132
const batch = files_to_process.slice(i, i + max_concurrency)
@@ -244,8 +246,8 @@ export const handle_fix_all_failed_files = async (
244246
final_content = updated_content.slice(0, -1)
245247
}
246248

247-
if (set_file_fixed_with_intelligent_update) {
248-
set_file_fixed_with_intelligent_update({
249+
if (set_file_applied_with_intelligent_update) {
250+
set_file_applied_with_intelligent_update({
249251
file_path,
250252
workspace_name
251253
})

‎apps/editor/src/views/panel/backend/message-handlers/handle-intelligent-update-file-in-preview.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
import { create_safe_path } from '@/utils/path-sanitizer'
1919
import { dictionary } from '@shared/constants/dictionary'
2020
import axios from 'axios'
21-
import { set_file_fixed_with_intelligent_update } from '@/commands/apply-chat-response-command/utils/preview'
21+
import { set_file_applied_with_intelligent_update } from '@/commands/apply-chat-response-command/utils/preview'
2222

2323
export const handle_intelligent_update_file_in_preview = async (
2424
panel_provider: PanelProvider,
@@ -236,8 +236,8 @@ export const handle_intelligent_update_file_in_preview = async (
236236
final_content = updated_content.slice(0, -1)
237237
}
238238

239-
if (set_file_fixed_with_intelligent_update) {
240-
set_file_fixed_with_intelligent_update({
239+
if (set_file_applied_with_intelligent_update) {
240+
set_file_applied_with_intelligent_update({
241241
file_path,
242242
workspace_name
243243
})

‎apps/editor/src/views/panel/frontend/Panel.tsx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ export const Panel = () => {
109109
handle_discard_user_changes_in_preview,
110110
handle_task_forward,
111111
prune_context_instructions_prefix,
112-
handle_prune_context_instructions_prefix_change
112+
handle_prune_context_instructions_prefix_change,
113+
fix_all_automatically
113114
} = use_panel(vscode)
114115

115116
const [checkpoint_to_edit, set_checkpoint_to_edit] = useState<
@@ -548,6 +549,7 @@ export const Panel = () => {
548549
>
549550
<UiResponsePreview
550551
items={items_to_preview}
552+
fix_all_automatically={fix_all_automatically}
551553
raw_instructions={raw_instructions}
552554
has_multiple_workspaces={workspace_folder_count > 1}
553555
on_focus_file={(file) => {

0 commit comments

Comments
 (0)