Skip to content

Commit f5f4a71

Browse files
committed
Add notification and apply action when agent starts sandbox edits
- CLI > edit. watch the temp directory for changes. Whenever something changes, show notification 'Agent started making edits. Wait or apply now.' [Apply] -> runs command CodeWebChat.applyFromTerminal. dispose watcher with terminal closure. └── apps └── editor ├── package.json └── src ├── commands │ ├── apply-from-terminal-command.ts │ └── index.ts ├── extension.ts ├── i18n │ └── translations │ └── commands │ ├── apply-from-terminal-command.ts │ └── index.ts ├── utils │ └── agentic-cli-invocation │ ├── index.ts │ ├── invoke-agentic-cli.ts │ └── utils │ └── generate-diff-markdown.ts └── views └── prompt ├── backend │ ├── message-handlers │ │ ├── handle-invoke-agentic-cli.ts │ │ └── index.ts │ └── prompt-view-provider.ts └── frontend └── Main ├── Main.tsx └── MainView ├── MainView.tsx └── components └── Header └── Header.tsx
1 parent 88c0ba5 commit f5f4a71

2 files changed

Lines changed: 78 additions & 0 deletions

File tree

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

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,42 @@ export const translations = {
7171
cs: 'V terminálovém sandboxu nebyly nalezeny žádné změny.',
7272
hu: 'Nem találhatók változások a terminál homokozójában.',
7373
bg: 'Не са намерени промени в пясъчника на терминала.'
74+
},
75+
'command.apply-from-terminal-command.info.agent-started-edits': {
76+
en: 'Agent started making edits in sandbox. Apply once finished.',
77+
pl: 'Agent rozpoczął wprowadzanie zmian w piaskownicy. Zastosuj po zakończeniu.',
78+
'zh-cn': '代理已开始在沙盒中进行编辑。完成后应用。',
79+
ja: 'エージェントがサンドボックスで編集を開始しました。完了したら適用してください。',
80+
'zh-tw': '代理已開始在沙盒中進行編輯。完成後套用。',
81+
de: 'Der Agent hat mit der Bearbeitung in der Sandbox begonnen. Nach Abschluss anwenden.',
82+
es: 'El agente comenzó a realizar ediciones en el sandbox. Aplicar una vez finalizado.',
83+
fr: "L'agent a commencé à effectuer des modifications dans la sandbox. Appliquez une fois terminé.",
84+
'pt-br':
85+
'O agente começou a fazer edições no sandbox. Aplique quando terminar.',
86+
ru: 'Агент начал вносить правки в песочнице. Примените по завершении.',
87+
ko: '에이전트가 샌드박스에서 편집을 시작했습니다. 완료되면 적용하세요.',
88+
it: "L'agente ha iniziato ad apportare modifiche nella sandbox. Applica una volta terminato.",
89+
tr: "Aracı sandbox'ta düzenlemeler yapmaya başladı. Tamamlandığında uygulayın.",
90+
cs: 'Agent začal provádět úpravy v sandboxu. Po dokončení použijte.',
91+
hu: 'Az ügynök megkezdte a szerkesztést a homokozóban. Ha végzett, alkalmazza.',
92+
bg: 'Агентът започна да прави редакции в пясъчника. Приложете след завършване.'
93+
},
94+
'command.apply-from-terminal-command.action.apply': {
95+
en: 'Apply',
96+
pl: 'Zastosuj',
97+
'zh-cn': '应用',
98+
ja: '適用',
99+
'zh-tw': '套用',
100+
de: 'Anwenden',
101+
es: 'Aplicar',
102+
fr: 'Appliquer',
103+
'pt-br': 'Aplicar',
104+
ru: 'Применить',
105+
ko: '적용',
106+
it: 'Applica',
107+
tr: 'Uygula',
108+
cs: 'Použít',
109+
hu: 'Alkalmaz',
110+
bg: 'Прилагане'
74111
}
75112
} as const

‎apps/editor/src/utils/agentic-cli-invocation/invoke-agentic-cli.ts‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,43 @@ export const invoke_agentic_cli = async (params: {
641641
}
642642
})
643643
})
644+
645+
let watcher: vscode.FileSystemWatcher | undefined
646+
let notification_shown = false
647+
648+
if (temp_dir_path && prompt_type === 'edit') {
649+
watcher = vscode.workspace.createFileSystemWatcher(
650+
new vscode.RelativePattern(vscode.Uri.file(temp_dir_path), '**/*')
651+
)
652+
653+
const handle_change = (uri: vscode.Uri) => {
654+
if (uri.fsPath.includes('.cwc')) return
655+
if (notification_shown) return
656+
notification_shown = true
657+
vscode.window
658+
.showInformationMessage(
659+
t(
660+
'command.apply-from-terminal-command.info.agent-started-edits'
661+
),
662+
t('command.apply-from-terminal-command.action.apply')
663+
)
664+
.then((selection) => {
665+
if (
666+
selection ===
667+
t('command.apply-from-terminal-command.action.apply')
668+
) {
669+
vscode.commands.executeCommand(
670+
'codeWebChat.applyFromTerminal'
671+
)
672+
}
673+
})
674+
}
675+
676+
watcher.onDidChange(handle_change)
677+
watcher.onDidCreate(handle_change)
678+
watcher.onDidDelete(handle_change)
679+
}
680+
644681
terminal.show()
645682
terminal.sendText(command)
646683

@@ -655,6 +692,10 @@ export const invoke_agentic_cli = async (params: {
655692

656693
await terminal_closed
657694

695+
if (watcher) {
696+
watcher.dispose()
697+
}
698+
658699
if (temp_dir_path) {
659700
try {
660701
await fs.promises.rm(temp_dir_path, {

0 commit comments

Comments
 (0)