Skip to content

Commit 7a657e3

Browse files
committed
Enable silent checkpoint creation and add progress subtitles during response processing
- move [Fragment] to common translations - translate [Fragment] in `apps/editor/src/i18n/translations/commands/apply-response.ts` - add missing translations [Fragment] - when creating checkpoint by [Fragment], don't show 'creating checkpoint' notification └── apps └── editor └── src ├── commands │ ├── apply-response-command │ │ ├── apply-response-command.ts │ │ └── response-processor.ts │ ├── copy-paths-command.ts │ ├── duplicate-workspace-command.ts │ ├── generate-commit-message-commands │ │ └── actions │ │ └── run-generate-action.ts │ └── history-command │ ├── actions │ │ └── restore-checkpoint.ts │ └── history-command.ts ├── context │ └── context-initialization.ts ├── features │ ├── checkpoints │ │ ├── actions │ │ │ ├── create-checkpoint.ts │ │ │ ├── delete-checkpoint.ts │ │ │ ├── get-checkpoints.ts │ │ │ └── index.ts │ │ ├── types │ │ │ ├── checkpoint.ts │ │ │ └── index.ts │ │ └── utils │ │ ├── copy-optimised-recursively.ts │ │ ├── get-checkpoint-path.ts │ │ ├── get-incremented-description.ts │ │ ├── git-utils.ts │ │ └── index.ts │ └── context-restoration │ └── utils │ └── source-selector.ts ├── i18n │ └── translations │ ├── commands │ │ └── apply-response.ts │ └── common.ts └── views └── prompt ├── backend │ └── message-handlers │ ├── handle-autofill.ts │ ├── handle-paste-url.ts │ ├── handle-template-quick-pick.ts │ ├── handle-update-last-used-web-configuration.ts │ └── handle-voice-input.ts ├── frontend │ ├── Prompt.tsx │ └── hooks │ ├── use-modal-manager.ts │ └── use-prompt │ ├── hooks │ │ └── use-instructions.ts │ ├── index.ts │ └── use-prompt.ts └── types └── messages.ts
1 parent b01cb0a commit 7a657e3

7 files changed

Lines changed: 175 additions & 136 deletions

File tree

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,15 +240,17 @@ export const apply_response_command = (params: {
240240
if (has_valid_blocks && !is_code_at_cursor) {
241241
params.prompt_view_provider.send_message({
242242
command: 'SHOW_PROGRESS',
243-
title: t('common.progress.preparing-preview')
243+
title: t('common.progress.response-preview'),
244+
subtitle: t('command.apply-response.progress.creating-checkpoint')
244245
})
245246

246247
before_checkpoint = await create_checkpoint({
247248
workspace_provider: params.workspace_provider,
248249
extension_context: params.extension_context,
249250
prompt_view_provider: params.prompt_view_provider,
250251
trigger: 'before-response-previewed',
251-
description: args?.raw_instructions
252+
description: args?.raw_instructions,
253+
hide_notification: true
252254
})
253255
}
254256
}
@@ -353,8 +355,7 @@ export const apply_response_command = (params: {
353355
is_checked: true,
354356
apply_failed: state.apply_failed,
355357
ai_content: state.ai_content,
356-
applied_with_patch_repair:
357-
state.applied_with_patch_repair
358+
applied_with_patch_repair: state.applied_with_patch_repair
358359
})
359360

360361
if (state.file_path_to_restore) {

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

Lines changed: 103 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ export const process_response = async (params: {
6060
const on_progress = (progress: number) => {
6161
params.prompt_view_provider.send_message({
6262
command: 'SHOW_PROGRESS',
63-
title: t('common.progress.preparing-preview'),
63+
title: t('common.progress.response-preview'),
64+
subtitle: t('command.apply-response.progress.applying-edits'),
6465
progress
6566
})
6667
}
@@ -302,53 +303,53 @@ export const process_response = async (params: {
302303
try {
303304
for (let i = 0; i < total_patches; i++) {
304305
on_progress(Math.round((i / total_patches) * 100))
305-
const patch = patches[i]
306-
let workspace_path = default_workspace
306+
const patch = patches[i]
307+
let workspace_path = default_workspace
307308

308-
if (patch.workspace_name && workspace_map.has(patch.workspace_name)) {
309-
workspace_path = workspace_map.get(patch.workspace_name)!
310-
}
309+
if (patch.workspace_name && workspace_map.has(patch.workspace_name)) {
310+
workspace_path = workspace_map.get(patch.workspace_name)!
311+
}
311312

312-
const sanitized_patch_content = sanitize_patch_content(
313-
patch.content,
314-
patch.workspace_name
315-
)
316-
const result = await apply_git_patch(
317-
sanitized_patch_content,
318-
workspace_path,
319-
patch.workspace_name,
320-
patch
321-
)
313+
const sanitized_patch_content = sanitize_patch_content(
314+
patch.content,
315+
patch.workspace_name
316+
)
317+
const result = await apply_git_patch(
318+
sanitized_patch_content,
319+
workspace_path,
320+
patch.workspace_name,
321+
patch
322+
)
322323

323-
if (result.success) {
324-
if (result.diff_application_method && result.original_states) {
325-
for (const state of result.original_states) {
326-
state.diff_application_method = result.diff_application_method
327-
state.ai_content = sanitized_patch_content
324+
if (result.success) {
325+
if (result.diff_application_method && result.original_states) {
326+
for (const state of result.original_states) {
327+
state.diff_application_method = result.diff_application_method
328+
state.ai_content = sanitized_patch_content
329+
}
328330
}
329-
}
330-
if (result.original_states) {
331-
all_original_states = all_original_states.concat(
332-
result.original_states
333-
)
334-
applied_patches.push({
335-
patch,
336-
original_states: result.original_states,
337-
diff_application_method: result.diff_application_method
338-
})
339-
}
340-
} else {
341-
if (result.original_states) {
342-
for (const state of result.original_states) {
343-
state.apply_failed = true
344-
state.ai_content = sanitized_patch_content
331+
if (result.original_states) {
332+
all_original_states = all_original_states.concat(
333+
result.original_states
334+
)
335+
applied_patches.push({
336+
patch,
337+
original_states: result.original_states,
338+
diff_application_method: result.diff_application_method
339+
})
340+
}
341+
} else {
342+
if (result.original_states) {
343+
for (const state of result.original_states) {
344+
state.apply_failed = true
345+
state.ai_content = sanitized_patch_content
346+
}
347+
all_original_states = all_original_states.concat(
348+
result.original_states
349+
)
345350
}
346-
all_original_states = all_original_states.concat(
347-
result.original_states
348-
)
349351
}
350352
}
351-
}
352353

353354
if (all_original_states.length > 0) {
354355
all_original_states =
@@ -430,72 +431,72 @@ export const process_response = async (params: {
430431
data: { success: result.success }
431432
})
432433
} else if (selected_mode_label == 'Truncated') {
433-
const result = await handle_truncated_edit({ files, on_progress })
434-
const successful_states = result.original_states || []
435-
const failed_files = result.failed_files || []
436-
437-
if (failed_files.length > 0) {
438-
const workspace_map = new Map<string, string>()
439-
vscode.workspace.workspaceFolders!.forEach((folder) => {
440-
workspace_map.set(folder.name, folder.uri.fsPath)
441-
})
442-
const default_workspace =
443-
vscode.workspace.workspaceFolders![0].uri.fsPath
444-
445-
failed_files.forEach((file) => {
446-
successful_states.push(
447-
create_failed_file_state({
448-
file,
449-
default_workspace,
450-
workspace_map
451-
})
452-
)
434+
const result = await handle_truncated_edit({ files, on_progress })
435+
const successful_states = result.original_states || []
436+
const failed_files = result.failed_files || []
437+
438+
if (failed_files.length > 0) {
439+
const workspace_map = new Map<string, string>()
440+
vscode.workspace.workspaceFolders!.forEach((folder) => {
441+
workspace_map.set(folder.name, folder.uri.fsPath)
442+
})
443+
const default_workspace =
444+
vscode.workspace.workspaceFolders![0].uri.fsPath
445+
446+
failed_files.forEach((file) => {
447+
successful_states.push(
448+
create_failed_file_state({
449+
file,
450+
default_workspace,
451+
workspace_map
452+
})
453+
)
454+
})
455+
}
456+
457+
if (successful_states.length > 0) {
458+
final_original_states = successful_states
459+
operation_success = true
460+
}
461+
Logger.info({
462+
function_name: 'process_response',
463+
message: 'Truncated handler finished.',
464+
data: { success: result.success }
453465
})
454-
}
466+
} else if (selected_mode_label == 'Conflict markers') {
467+
const result = await handle_search_replace({ files, on_progress })
455468

456-
if (successful_states.length > 0) {
457-
final_original_states = successful_states
458-
operation_success = true
459-
}
460-
Logger.info({
461-
function_name: 'process_response',
462-
message: 'Truncated handler finished.',
463-
data: { success: result.success }
464-
})
465-
} else if (selected_mode_label == 'Conflict markers') {
466-
const result = await handle_search_replace({ files, on_progress })
469+
const successful_states = result.original_states || []
470+
const failed_files: FileItem[] = result.failed_files || []
467471

468-
const successful_states = result.original_states || []
469-
const failed_files: FileItem[] = result.failed_files || []
472+
if (failed_files.length > 0) {
473+
const workspace_map = new Map<string, string>()
474+
vscode.workspace.workspaceFolders!.forEach((folder) => {
475+
workspace_map.set(folder.name, folder.uri.fsPath)
476+
})
477+
const default_workspace =
478+
vscode.workspace.workspaceFolders![0].uri.fsPath
479+
480+
failed_files.forEach((file) => {
481+
successful_states.push(
482+
create_failed_file_state({
483+
file,
484+
default_workspace,
485+
workspace_map
486+
})
487+
)
488+
})
489+
}
470490

471-
if (failed_files.length > 0) {
472-
const workspace_map = new Map<string, string>()
473-
vscode.workspace.workspaceFolders!.forEach((folder) => {
474-
workspace_map.set(folder.name, folder.uri.fsPath)
475-
})
476-
const default_workspace =
477-
vscode.workspace.workspaceFolders![0].uri.fsPath
478-
479-
failed_files.forEach((file) => {
480-
successful_states.push(
481-
create_failed_file_state({
482-
file,
483-
default_workspace,
484-
workspace_map
485-
})
486-
)
491+
if (successful_states.length > 0) {
492+
final_original_states = successful_states
493+
operation_success = true
494+
}
495+
Logger.info({
496+
function_name: 'process_response',
497+
message: 'Conflict markers handler finished.',
498+
data: { success: result.success }
487499
})
488-
}
489-
490-
if (successful_states.length > 0) {
491-
final_original_states = successful_states
492-
operation_success = true
493-
}
494-
Logger.info({
495-
function_name: 'process_response',
496-
message: 'Conflict markers handler finished.',
497-
data: { success: result.success }
498-
})
499500
} else {
500501
Logger.error({
501502
function_name: 'process_response',

‎apps/editor/src/features/checkpoints/actions/create-checkpoint.ts‎

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export const create_checkpoint = async (params: {
2929
prompt_view_provider: PromptViewProvider
3030
trigger?: CheckpointTrigger
3131
description?: string
32+
hide_notification?: boolean
3233
}): Promise<Checkpoint | undefined> => {
3334
try {
3435
const trigger = params.trigger ?? 'manual'
@@ -215,14 +216,18 @@ export const create_checkpoint = async (params: {
215216
new_checkpoint = checkpoint_object
216217
}
217218

218-
await vscode.window.withProgress(
219-
{
220-
location: vscode.ProgressLocation.Notification,
221-
title: t('feature.checkpoints.progress.creating'),
222-
cancellable: false
223-
},
224-
create_checkpoint_task
225-
)
219+
if (params.hide_notification) {
220+
await create_checkpoint_task()
221+
} else {
222+
await vscode.window.withProgress(
223+
{
224+
location: vscode.ProgressLocation.Notification,
225+
title: t('feature.checkpoints.progress.creating'),
226+
cancellable: false
227+
},
228+
create_checkpoint_task
229+
)
230+
}
226231

227232
return new_checkpoint
228233
} catch (err: any) {

‎apps/editor/src/i18n/translations/commands/apply-response.ts‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,5 +327,41 @@ export const translations = {
327327
cs: 'Chybí text odpovědi k použití.',
328328
hu: 'A hiányzó válaszszöveg hiányzik.',
329329
bg: 'Липсва текст на отговор за прилагане.'
330+
},
331+
'command.apply-response.progress.applying-edits': {
332+
en: 'Applying edits...',
333+
pl: 'Wprowadzam zmiany...',
334+
'zh-cn': '正在应用编辑...',
335+
ja: '編集を適用しています...',
336+
'zh-tw': '正在應用編輯...',
337+
de: 'Änderungen werden angewendet...',
338+
es: 'Aplicando ediciones...',
339+
fr: 'Application des modifications...',
340+
'pt-br': 'Aplicando edições...',
341+
ru: 'Применение изменений...',
342+
ko: '편집 적용 중...',
343+
it: 'Applicazione delle modifiche...',
344+
tr: 'Düzenlemeler uygulanıyor...',
345+
cs: 'Aplikují se úpravy...',
346+
hu: 'Szerkesztések alkalmazása...',
347+
bg: 'Прилагане на редакциите...'
348+
},
349+
'command.apply-response.progress.creating-checkpoint': {
350+
en: 'Creating checkpoint...',
351+
pl: 'Tworzę punkt kontrolny...',
352+
'zh-cn': '正在创建检查点...',
353+
ja: 'チェックポイントを作成しています...',
354+
'zh-tw': '正在建立檢查點...',
355+
de: 'Prüfpunkt wird erstellt...',
356+
es: 'Creando punto de control...',
357+
fr: 'Création du point de contrôle...',
358+
'pt-br': 'Criando ponto de verificação...',
359+
ru: 'Создание контрольной точки...',
360+
ko: '체크포인트 생성 중...',
361+
it: 'Creazione punto di controllo...',
362+
tr: 'Denetim noktası oluşturuluyor...',
363+
cs: 'Vytváření kontrolního bodu...',
364+
hu: 'Ellenőrzőpont létrehozása...',
365+
bg: 'Създаване на контролна точка...'
330366
}
331367
} as const

‎apps/editor/src/i18n/translations/common.ts‎

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -161,23 +161,23 @@ export const translations = {
161161
hu: 'gondolkodás...',
162162
bg: 'мислене...'
163163
},
164-
'common.progress.preparing-preview': {
165-
en: 'Preparing response preview...',
166-
pl: 'Przygotowywanie podglądu zmian...',
167-
'zh-cn': '正在准备更改预览...',
168-
ja: '変更のプレビューを準備中...',
169-
'zh-tw': '正在準備回應預覽...',
170-
de: 'Vorschau der Änderungen wird vorbereitet...',
171-
es: 'Preparando vista previa de los cambios...',
172-
fr: "Préparation de l'aperçu des modifications...",
173-
'pt-br': 'Preparando a prévia das alterações...',
174-
ru: 'Подготовка предпросмотра изменений...',
175-
ko: '변경 사항 미리보기 준비 중...',
176-
it: "Preparazione dell'anteprima delle modifiche...",
177-
tr: 'Değişikliklerin önizlemesi hazırlanıyor...',
178-
cs: 'Příprava náhledu změn...',
179-
hu: 'Változtatások előnézetének előkészítése...',
180-
bg: 'Подготовка за преглед на промените...'
164+
'common.progress.response-preview': {
165+
en: 'Response Preview',
166+
pl: 'Podgląd odpowiedzi',
167+
'zh-cn': '响应预览',
168+
ja: '応答プレビュー',
169+
'zh-tw': '回應預覽',
170+
de: 'Antwortvorschau',
171+
es: 'Vista previa de respuesta',
172+
fr: 'Aperçu de la réponse',
173+
'pt-br': 'Visualização da resposta',
174+
ru: 'Предпросмотр ответа',
175+
ko: '응답 미리보기',
176+
it: 'Anteprima della risposta',
177+
tr: 'Yanıt Önizlemesi',
178+
cs: 'Náhled odpovědi',
179+
hu: 'Válasz előnézete',
180+
bg: 'Преглед на отговора'
181181
},
182182
'common.separator.recently-used': {
183183
en: 'recently used',

‎apps/editor/src/views/prompt/frontend/hooks/use-modal-manager.ts‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@ export const use_modal_manager = () => {
5151
title: message.title,
5252
subtitle: message.subtitle,
5353
progress: message.progress,
54-
tokens_per_second: message.tokens_per_second,
55-
cancellable: message.cancellable ?? false,
56-
delay_visibility: message.delay_visibility
54+
cancellable: message.cancellable ?? false
5755
})
5856
} else if (message.command == 'HIDE_PROGRESS') {
5957
set_progress_state(undefined)

0 commit comments

Comments
 (0)