Skip to content

Commit 4f77264

Browse files
committed
Trigger target-specific apply actions directly instead of showing a quick pick
- 'apply' footer button in the prompt view should always apply from clipboard on WEB target, from terminal in CLI target, and not be shown at all in API target. - rename 'handle apply response' to 'handle apply' ├── apps │ └── editor │ └── src │ ├── constants │ │ └── state-keys.ts │ ├── i18n │ │ └── translations │ │ └── views │ │ ├── index.ts │ │ └── prompt │ │ ├── handlers │ │ │ └── index.ts │ │ └── index.ts │ └── views │ └── prompt │ ├── backend │ │ ├── message-handlers │ │ │ ├── handle-apply-from.ts │ │ │ ├── handle-apply.ts │ │ │ ├── handle-get-mode.ts │ │ │ └── index.ts │ │ └── prompt-view-provider.ts │ ├── frontend │ │ ├── Prompt.tsx │ │ ├── components │ │ │ └── Layout │ │ │ ├── Footer │ │ │ │ ├── Footer.module.scss │ │ │ │ ├── Footer.tsx │ │ │ │ └── index.ts │ │ │ ├── Layout.module.scss │ │ │ └── Layout.tsx │ │ ├── contexts │ │ │ └── LayoutContext.tsx │ │ └── hooks │ │ └── use-prompt │ │ └── use-prompt.ts │ └── types │ └── messages.ts └── packages ├── shared │ └── src │ ├── hooks │ │ ├── index.ts │ │ └── use-compacting.ts │ └── types │ └── target.ts └── ui └── src └── components └── editor └── prompt-view └── CompactableActionButton ├── CompactableActionButton.module.scss ├── CompactableActionButton.tsx └── index.ts
1 parent 2326ad3 commit 4f77264

15 files changed

Lines changed: 80 additions & 269 deletions

File tree

‎apps/editor/src/commands/apply-from-terminal-command.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ export const apply_from_terminal_command = (): vscode.Disposable => {
8787

8888
const active_terminal = vscode.window.activeTerminal
8989
if (!active_terminal) {
90-
vscode.window.showInformationMessage(
91-
t('command.apply-from-terminal-command.info.no-active-terminal')
90+
vscode.window.showWarningMessage(
91+
t('command.apply-from-terminal-command.warning.no-active-terminal')
9292
)
9393
return
9494
}
@@ -176,8 +176,8 @@ export const apply_from_terminal_command = (): vscode.Disposable => {
176176
)
177177
}
178178
} else {
179-
vscode.window.showInformationMessage(
180-
t('command.apply-from-terminal-command.info.not-cwc-cli')
179+
vscode.window.showWarningMessage(
180+
t('command.apply-from-terminal-command.warning.not-cwc-cli')
181181
)
182182
}
183183
}

‎apps/editor/src/constants/state-keys.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ export const LAST_APPLIED_RAW_INSTRUCTIONS_STATE_KEY =
77
'last-applied-raw-instructions'
88
export const LAST_RANGES_SAVE_LOCATION_STATE_KEY = 'last-ranges-save-location'
99
export const LAST_APPLY_CONTEXT_OPTION_STATE_KEY = 'last-apply-context-option'
10-
export const LAST_APPLY_FROM_STATE_KEY = 'last-apply-from'
1110
export const CONTEXT_SELECTED_PATHS_STATE_KEY = 'context-selected-paths'
1211
export const LAST_SELECTED_SYMBOL_STATE_KEY = 'last-selected-symbol'
1312
export const LAST_SELECTED_CONTEXT_SOURCE_IN_SYMBOLS_QUICK_PICK_STATE_KEY =

‎apps/editor/src/i18n/translations/commands/apply-from-terminal-command.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const translations = {
1818
hu: 'A terminálból való alkalmazás letiltva van aktív válasz előnézet közben.',
1919
bg: 'Прилагането от терминала е деактивирано по време на активен преглед на отговор.'
2020
},
21-
'command.apply-from-terminal-command.info.no-active-terminal': {
21+
'command.apply-from-terminal-command.warning.no-active-terminal': {
2222
en: 'No active terminal session.',
2323
pl: 'Brak aktywnej sesji terminala.',
2424
'zh-cn': '没有活动的终端会话。',
@@ -36,7 +36,7 @@ export const translations = {
3636
hu: 'Nincs aktív terminál munkamenet.',
3737
bg: 'Няма активна терминална сесия.'
3838
},
39-
'command.apply-from-terminal-command.info.not-cwc-cli': {
39+
'command.apply-from-terminal-command.warning.not-cwc-cli': {
4040
en: 'Active terminal is not a CLI edit session.',
4141
pl: 'Aktywny terminal nie jest sesją edycji z CLI.',
4242
'zh-cn': '活动终端不是 CLI 编辑会话。',

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

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -54,23 +54,22 @@ export const translations = {
5454
bg: 'Потвърдете файловете за включване в контекста'
5555
},
5656
'command.apply-response-command.warning.no-valid-response': {
57-
en: 'No valid response to apply. See its contents in the output pane.',
58-
pl: 'Brak prawidłowej odpowiedzi do zastosowania. Zobacz jej treść w panelu Dane Wyjściowe.',
59-
'zh-cn': '没有可应用的有效响应。请在输出窗格中查看其内容。',
60-
ja: '適用する有効な応答がありません。出力ペインで内容を確認してください。',
61-
'zh-tw': '沒有可應用的有效回應。請在輸出窗格中查看其內容。',
62-
de: 'Keine gültige Antwort zum Anwenden vorhanden. Sehen Sie sich den Inhalt im Ausgabebereich an.',
63-
es: 'No hay una respuesta válida para aplicar. Vea su contenido en el panel de salida.',
64-
fr: 'Aucune réponse valide à appliquer. Consultez son contenu dans le volet de sortie.',
65-
'pt-br':
66-
'Nenhuma resposta válida para aplicar. Veja seu conteúdo no painel de saída.',
67-
ru: 'Нет допустимого ответа для применения. Посмотрите его содержимое на панели вывода.',
68-
ko: '적용할 유효한 응답이 없습니다. 출력 창에서 내용을 확인하세요.',
69-
it: 'Nessuna risposta valida da applicare. Visualizza il suo contenuto nel riquadro di output.',
70-
tr: 'Uygulanacak geçerli bir yanıt yok. İçeriğini çıktı bölmesinde görün.',
71-
cs: 'Žádná platná odpověď k použití. Její obsah zobrazíte v podokně výstupu.',
72-
hu: 'Nincs alkalmazható érvényes válasz. Tekintse meg a tartalmát a kimeneti ablaktáblán.',
73-
bg: 'Няма валиден отговор за прилагане. Вижте съдържанието му в панела за изход.'
57+
en: 'No valid clipboard contents to apply.',
58+
pl: 'Brak prawidłowej zawartości schowka do zastosowania.',
59+
'zh-cn': '没有可应用的有效剪贴板内容。',
60+
ja: '適用する有効なクリップボードの内容がありません。',
61+
'zh-tw': '沒有可應用的有效剪貼簿內容。',
62+
de: 'Keine gültigen Inhalte in der Zwischenablage zum Anwenden vorhanden.',
63+
es: 'No hay contenido válido en el portapapeles para aplicar.',
64+
fr: 'Aucun contenu valide du presse-papiers à appliquer.',
65+
'pt-br': 'Nenhum conteúdo válido da área de transferência para aplicar.',
66+
ru: 'Нет допустимого содержимого буфера обмена для применения.',
67+
ko: '적용할 유효한 클립보드 내용이 없습니다.',
68+
it: 'Nessun contenuto valido negli appunti da applicare.',
69+
tr: 'Uygulanacak geçerli pano içeriği yok.',
70+
cs: 'Žádný platný obsah schránky k použití.',
71+
hu: 'Nincs alkalmazható érvényes vágólap-tartalom.',
72+
bg: 'Няма валидно съдържание в клипборда за прилагане.'
7473
},
7574
'command.apply-response-command.error.no-workspace-folder': {
7675
en: 'No workspace folder open.',

‎apps/editor/src/i18n/translations/views/prompt/handlers/handle-apply-from.ts‎

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

‎apps/editor/src/i18n/translations/views/prompt/handlers/index.ts‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import { translations as handle_save_completed_tasks } from './handle-save-compl
1313
import { translations as handle_clear_completed_tasks } from './handle-clear-completed-tasks'
1414
import { translations as handle_show_accuracy_boost_info } from './handle-show-accuracy-boost-info'
1515
import { translations as handle_select_terminal_interactivity } from './handle-select-terminal-interactivity'
16-
import { translations as handle_apply_from } from './handle-apply-from'
1716
export const translations = {
1817
...handle_delete_task,
1918
...handle_make_api_call,
@@ -29,6 +28,5 @@ export const translations = {
2928
...handle_save_completed_tasks,
3029
...handle_clear_completed_tasks,
3130
...handle_show_accuracy_boost_info,
32-
...handle_select_terminal_interactivity,
33-
...handle_apply_from
31+
...handle_select_terminal_interactivity
3432
}

‎apps/editor/src/views/prompt/backend/message-handlers/handle-apply-from.ts‎

Lines changed: 0 additions & 114 deletions
This file was deleted.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import * as vscode from 'vscode'
2+
import { PromptViewProvider } from '@/views/prompt/backend/prompt-view-provider'
3+
import { ApplyMessage } from '@/views/prompt/types/messages'
4+
5+
export const handle_apply = async (
6+
prompt_view_provider: PromptViewProvider,
7+
_: ApplyMessage
8+
): Promise<void> => {
9+
const target = prompt_view_provider.target
10+
11+
if (target === 'WEB') {
12+
await vscode.commands.executeCommand('codeWebChat.applyFromClipboard')
13+
} else if (target === 'CLI') {
14+
await vscode.commands.executeCommand('codeWebChat.applyFromTerminal')
15+
}
16+
}

‎apps/editor/src/views/prompt/backend/message-handlers/index.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,6 @@ export * from './handle-clear-completed-tasks'
7070
export * from './handle-show-accuracy-boost-info'
7171
export * from './handle-update-extension'
7272
export * from './handle-save-targets-order'
73-
export * from './handle-apply-from'
73+
export * from './handle-apply'
7474
export * from './handle-get-notes'
7575
export * from './handle-save-notes'

‎apps/editor/src/views/prompt/backend/prompt-view-provider.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -717,8 +717,8 @@ export class PromptViewProvider implements vscode.WebviewViewProvider {
717717
this.send_token_count()
718718
} else if (message.command === 'EXECUTE_COMMAND') {
719719
await vscode.commands.executeCommand(message.command_id)
720-
} else if (message.command === 'SHOW_APPLY_FROM_QUICK_PICK') {
721-
await handlers.handle_apply_from(this, message)
720+
} else if (message.command === 'APPLY') {
721+
await handlers.handle_apply(this, message)
722722
} else if (message.command === 'MAKE_API_CALL') {
723723
await handlers.handle_make_api_call(this, message)
724724
} else if (message.command === 'SHOW_TEMPLATE_QUICK_PICK') {

0 commit comments

Comments
 (0)