Skip to content

Commit 66932f4

Browse files
committed
Show output channel when agentic CLI returns empty or unapplied responses
- when a respone applied from agentic cli invocation doesn't yield any result, the OUTPUT pane on 'CWC Agent' should be opened └── apps └── editor ├── package.json └── src ├── commands │ └── apply-response-command │ └── apply-response-command.ts ├── extension.ts ├── utils │ └── agentic-cli-invocation │ └── invoke-agentic-cli.ts └── views └── prompt └── backend └── message-handlers └── handle-invoke-agentic-cli.ts
1 parent 25a7edc commit 66932f4

3 files changed

Lines changed: 55 additions & 13 deletions

File tree

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

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export const apply_response_command = (params: {
7474
vscode.window.showErrorMessage(
7575
t('command.apply-response-command.error.no-workspace-folder')
7676
)
77-
return
77+
return false
7878
}
7979

8080
response = args?.response
@@ -84,13 +84,13 @@ export const apply_response_command = (params: {
8484
vscode.window.showInformationMessage(
8585
t('command.apply-response-command.info.clipboard-empty')
8686
)
87-
return
87+
return false
8888
}
8989
} else if (!response) {
9090
vscode.window.showErrorMessage(
9191
t('command.apply-response-command.error.response-missing')
9292
)
93-
return
93+
return false
9494
}
9595

9696
while (in_progress && !get_response_preview_promise_resolve()) {
@@ -121,7 +121,7 @@ export const apply_response_command = (params: {
121121
'codeWebChat.internal.generateCommitMessageWithProvidedTextAndCommit',
122122
commit_message_item.message
123123
)
124-
return
124+
return true
125125
}
126126

127127
is_intelligent_file_search_results = response_items.some(
@@ -134,15 +134,15 @@ export const apply_response_command = (params: {
134134

135135
if (patch_repair_items.length > 0) {
136136
if (!resolve_fn) {
137-
return
137+
return false
138138
}
139139

140140
await handle_patch_repair({
141141
patch_items: patch_repair_items,
142142
prompt_view_provider: params.prompt_view_provider,
143143
workspace_provider: params.workspace_provider
144144
})
145-
return
145+
return true
146146
}
147147

148148
is_code_at_cursor = response_items.some(
@@ -164,7 +164,25 @@ export const apply_response_command = (params: {
164164
content: item.content
165165
}
166166
)
167-
return
167+
return true
168+
}
169+
170+
const has_valid_blocks =
171+
(args?.files_with_content && args.files_with_content.length > 0) ||
172+
response_items.some(
173+
(item) => item.type == 'file' || item.type == 'diff'
174+
)
175+
176+
if (
177+
!has_valid_blocks &&
178+
!is_intelligent_file_search_results &&
179+
!is_code_at_cursor &&
180+
!commit_message_item &&
181+
patch_repair_items.length === 0
182+
) {
183+
if ((args as any)?.is_from_agentic_cli) {
184+
return false
185+
}
168186
}
169187

170188
if (resolve_fn && !is_intelligent_file_search_results) {
@@ -211,7 +229,7 @@ export const apply_response_command = (params: {
211229
await command_lifecycle_promise
212230
}
213231
} else {
214-
return
232+
return false
215233
}
216234
}
217235

@@ -367,6 +385,7 @@ export const apply_response_command = (params: {
367385
msg: err.message
368386
})
369387
)
388+
return false
370389
} finally {
371390
in_progress = false
372391
if (before_checkpoint) {
@@ -382,6 +401,8 @@ export const apply_response_command = (params: {
382401
command_lifecycle_promise = null
383402
}
384403
}
404+
405+
return true
385406
}
386407
)
387408
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ const get_output_channel = () => {
2121
return _output_channel
2222
}
2323

24+
export const show_agentic_cli_output_channel = () => {
25+
get_output_channel().show(true)
26+
}
27+
2428
export const invoke_agentic_cli = async (params: {
2529
workspace_provider: WorkspaceProvider
2630
extension_context: vscode.ExtensionContext

‎apps/editor/src/views/prompt/backend/message-handlers/handle-invoke-agentic-cli.ts‎

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as vscode from 'vscode'
22
import { t } from '@/i18n'
33
import { PromptViewProvider } from '@/views/prompt/backend/prompt-view-provider'
44
import { invoke_agentic_cli } from '@/utils/agentic-cli-invocation'
5+
import { show_agentic_cli_output_channel } from '@/utils/agentic-cli-invocation/invoke-agentic-cli'
56
import { build_cli_prompt } from './utils/build-cli-prompt'
67
import {
78
get_last_used_cli_configuration_key,
@@ -71,10 +72,26 @@ export const handle_invoke_agentic_cli = async (
7172

7273
const { agent_output } = result
7374

74-
if (agent_output && prompt_view_provider.cli_prompt_type == 'edit') {
75-
vscode.commands.executeCommand('codeWebChat.applyResponse', {
76-
response: agent_output,
77-
raw_instructions: current_instructions
78-
})
75+
if (
76+
agent_output !== undefined &&
77+
prompt_view_provider.cli_prompt_type == 'edit'
78+
) {
79+
if (!agent_output.trim()) {
80+
show_agentic_cli_output_channel()
81+
return
82+
}
83+
84+
const has_results = await vscode.commands.executeCommand(
85+
'codeWebChat.applyResponse',
86+
{
87+
response: agent_output,
88+
raw_instructions: current_instructions,
89+
is_from_agentic_cli: true
90+
}
91+
)
92+
93+
if (!has_results) {
94+
show_agentic_cli_output_channel()
95+
}
7996
}
8097
}

0 commit comments

Comments
 (0)