Skip to content

Commit 754ed98

Browse files
committed
Pass the output channel to search files and coding agents for execution logging
- json stream reporting should also appear in Output pane - initialize output channel in `apps/editor/src/extension.ts`so that it can be used by many commands - here is an example antigravity output [Pasted text], what we want to show the user in notification is just the tool name. For example 'view_file' should be shown as 'view file...' - when run the same tool multiple times in a row we want to append counter: 'view file...', 'view file (2)...', 'view file (3)...' - change 'view file (3)...' to 'view file... (3)' - we like how antigravity shows tool calls in notification, e.g. 'view file...'. Review the codex output and implement better handling for it [Pasted text] - instead of saying 'Finished in 1m 0s.', say 'Finished in 1m.' └── apps └── editor ├── package.json └── src ├── commands │ └── search-files-commands │ ├── index.ts │ ├── search-files-commands.ts │ └── utils │ ├── get-target-folder-path.ts │ └── prompt-for-provided-results.ts ├── extension.ts └── features └── search-files ├── index.ts ├── search-files.ts ├── search-modes │ ├── perform-agent-search-mode │ │ ├── agents │ │ │ ├── antigravity.ts │ │ │ ├── claude.ts │ │ │ ├── codex.ts │ │ │ ├── cursor.ts │ │ │ ├── grok.ts │ │ │ ├── muse.ts │ │ │ └── opencode.ts │ │ ├── index.ts │ │ ├── perform-agent-search-mode.ts │ │ ├── types.ts │ │ └── utils.ts │ ├── perform-intelligent-search-mode.ts │ ├── perform-keywords-search-mode.ts │ └── perform-phrase-search-mode.ts └── utils ├── analyze-files.ts ├── check-matches-condition.ts ├── create-search-regex.ts ├── group-quick-pick-items.ts ├── handle-parent-folder-result.ts ├── map-files-to-quick-pick-items.ts ├── prompt-for-config.ts ├── prompt-for-intelligent-search-results.ts ├── prompt-for-keywords-match-mode.ts ├── prompt-for-keywords-target.ts ├── prompt-for-search-mode.ts ├── prompt-for-search-results.ts ├── prompt-for-search-term.ts ├── prompt-for-shrink-mode.ts ├── search-files-by-intelligent.ts ├── search-files-by-keywords.ts ├── search-files-by-phrase.ts └── show-search-results-quick-pick.ts
1 parent 9840018 commit 754ed98

7 files changed

Lines changed: 98 additions & 62 deletions

File tree

‎apps/editor/src/commands/search-files-commands/search-files-commands.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ let search_in_progress = false
1313
export const search_files_commands = (
1414
workspace_provider: WorkspaceProvider,
1515
extension_context: vscode.ExtensionContext,
16-
websocket_manager: WebSocketManager
16+
websocket_manager: WebSocketManager,
17+
output_channel: vscode.OutputChannel
1718
) => {
1819
const process_search_result = async (params: {
1920
result: {
@@ -180,6 +181,7 @@ export const search_files_commands = (
180181
workspace_provider,
181182
extension_context,
182183
websocket_manager,
184+
output_channel,
183185
show_back_button: true,
184186
is_sub_search: true
185187
})
@@ -237,6 +239,7 @@ export const search_files_commands = (
237239
workspace_provider,
238240
extension_context,
239241
websocket_manager,
242+
output_channel,
240243
folder_path,
241244
is_workspace_action: options?.is_workspace_action
242245
})
@@ -300,6 +303,7 @@ export const search_files_commands = (
300303
workspace_provider,
301304
extension_context,
302305
websocket_manager,
306+
output_channel,
303307
is_search_in_selected: true,
304308
folder_path
305309
})

‎apps/editor/src/extension.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ export const activate = async (extension_context: vscode.ExtensionContext) => {
8888
extension_context
8989
)
9090

91+
const output_channel = vscode.window.createOutputChannel('Code Web Chat')
92+
extension_context.subscriptions.push(output_channel)
93+
9194
const prompt_view_api_calls_manager = new PromptViewApiCallsManager(
9295
prompt_view_provider,
9396
chats_view_provider
@@ -203,7 +206,8 @@ export const activate = async (extension_context: vscode.ExtensionContext) => {
203206
...search_files_commands(
204207
workspace_provider,
205208
extension_context,
206-
websocket_server_instance
209+
websocket_server_instance,
210+
output_channel
207211
),
208212
select_definition_file_command(workspace_provider),
209213
open_url_command({

‎apps/editor/src/features/search-files/search-files.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export const search_files = async (params: {
1515
workspace_provider: WorkspaceProvider
1616
extension_context: vscode.ExtensionContext
1717
websocket_manager: WebSocketManager
18+
output_channel: vscode.OutputChannel
1819
show_back_button?: boolean
1920
is_sub_search?: boolean
2021
is_search_in_selected?: boolean
@@ -44,6 +45,7 @@ export const search_files = async (params: {
4445
workspace_provider: params.workspace_provider,
4546
extension_context: params.extension_context,
4647
websocket_manager: params.websocket_manager,
48+
output_channel: params.output_channel,
4749
show_back_button: true,
4850
is_sub_search: true,
4951
is_search_in_selected: params.is_search_in_selected,
@@ -107,6 +109,7 @@ export const search_files = async (params: {
107109
resolve_files,
108110
workspace_provider: params.workspace_provider,
109111
extension_context: params.extension_context,
112+
output_channel: params.output_channel,
110113
show_back_button: params.show_back_button,
111114
search_in_results,
112115
is_search_in_selected: params.is_search_in_selected,

‎apps/editor/src/features/search-files/search-modes/perform-agent-search-mode/agents/antigravity.ts‎

Lines changed: 25 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { CodingAgent } from '../types'
22
import { build_agent_prompt, check_command_exists } from '../utils'
33

4+
let last_action_name = ''
5+
let action_count = 0
6+
47
export const antigravity_agent: CodingAgent = {
58
id: 'antigravity',
69
label: 'Antigravity',
@@ -17,64 +20,38 @@ export const antigravity_agent: CodingAgent = {
1720
parse_stream_line: (parsed, report_progress) => {
1821
if (parsed.event == 'step_update' && parsed.step_update) {
1922
const step = parsed.step_update
20-
if (step.step_type == 'tool') {
21-
const tool_name = step.tool_name || step.tool_info?.name
22-
if (tool_name) {
23-
let msg = tool_name
24-
const params = step.tool_info?.parameters
25-
26-
if (params) {
27-
const formatted_name = tool_name.toLowerCase()
28-
29-
if (
30-
(formatted_name.includes('run') ||
31-
formatted_name.includes('command') ||
32-
formatted_name.includes('bash')) &&
33-
(params.CommandLine || params.command || params.cmd)
34-
) {
35-
msg = params.CommandLine || params.command || params.cmd
36-
} else if (formatted_name.includes('read') && params.path) {
37-
msg = params.path
38-
} else if (
39-
(formatted_name.includes('write') ||
40-
formatted_name.includes('edit')) &&
41-
params.path
42-
) {
43-
msg = params.path
44-
} else if (formatted_name.includes('list') && params.path) {
45-
msg = params.path
46-
} else if (
47-
(formatted_name.includes('search') ||
48-
formatted_name.includes('find') ||
49-
formatted_name.includes('grep')) &&
50-
(params.query ||
51-
params.pattern ||
52-
params.description ||
53-
params.keyword)
54-
) {
55-
msg =
56-
params.query ||
57-
params.pattern ||
58-
params.description ||
59-
params.keyword
60-
} else if (params.path) {
61-
msg = params.path
62-
} else if (params.command || params.cmd || params.CommandLine) {
63-
msg = params.command || params.cmd || params.CommandLine
64-
}
65-
}
23+
let action_name = ''
24+
let has_dots = false
6625

67-
report_progress(msg)
26+
if (step.step_type == 'tool') {
27+
if (step.tool_name) {
28+
action_name = step.tool_name.replace(/_/g, ' ')
29+
has_dots = true
6830
}
6931
} else if (step.subagent_info?.subagents?.length > 0) {
7032
const subagent = step.subagent_info.subagents[0]
71-
report_progress(subagent.role || subagent.type_name)
33+
action_name = subagent.role || subagent.type_name
34+
}
35+
36+
if (action_name) {
37+
if (action_name === last_action_name) {
38+
action_count++
39+
} else {
40+
last_action_name = action_name
41+
action_count = 1
42+
}
43+
const counter = action_count > 1 ? ` (${action_count})` : ''
44+
report_progress(`${action_name}${has_dots ? '...' : ''}${counter}`)
7245
}
7346
} else if (parsed.event == 'result' && parsed.result) {
47+
last_action_name = ''
48+
action_count = 0
7449
return { output: parsed.result.response || '' }
7550
}
7651
},
7752
parse_final_output: (parsed, current_output) => {
53+
last_action_name = ''
54+
action_count = 0
7855
if (parsed.event == 'result' && parsed.result) {
7956
return parsed.result.response || ''
8057
} else if (parsed.response) {

‎apps/editor/src/features/search-files/search-modes/perform-agent-search-mode/agents/codex.ts‎

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { CodingAgent } from '../types'
22
import { build_agent_prompt, check_command_exists } from '../utils'
33

4+
let last_action_name = ''
5+
let action_count = 0
6+
47
export const codex_agent: CodingAgent = {
58
id: 'codex',
69
label: 'Codex',
@@ -12,18 +15,55 @@ export const codex_agent: CodingAgent = {
1215
parse_stream_line: (parsed, report_progress) => {
1316
if (parsed.type == 'item.started' && parsed.item) {
1417
const item = parsed.item
18+
let action_name = ''
19+
1520
if (item.type == 'command_execution' && item.command) {
16-
report_progress(item.command)
21+
const cmd = item.command
22+
if (
23+
cmd.includes('rg --files') ||
24+
cmd.includes('find ') ||
25+
cmd.includes('fd ')
26+
) {
27+
action_name = 'search files'
28+
} else if (cmd.includes('rg ') || cmd.includes('grep ')) {
29+
action_name = 'search in files'
30+
} else if (
31+
cmd.includes('sed ') ||
32+
cmd.includes('cat ') ||
33+
cmd.includes('head ') ||
34+
cmd.includes('tail ')
35+
) {
36+
action_name = 'read file'
37+
} else if (cmd.includes('ls ')) {
38+
action_name = 'list files'
39+
} else {
40+
action_name = 'run command'
41+
}
1742
} else if (item.type) {
18-
report_progress(item.type)
43+
action_name = item.type.replace(/_/g, ' ')
44+
}
45+
46+
if (action_name) {
47+
if (action_name === last_action_name) {
48+
action_count++
49+
} else {
50+
last_action_name = action_name
51+
action_count = 1
52+
}
53+
const counter = action_count > 1 ? ` (${action_count})` : ''
54+
report_progress(`${action_name}...${counter}`)
1955
}
2056
} else if (parsed.type == 'item.completed' && parsed.item) {
2157
if (parsed.item.type == 'agent_message' && parsed.item.text) {
58+
last_action_name = ''
59+
action_count = 0
2260
return { output: parsed.item.text }
2361
}
2462
}
2563
},
2664
parse_final_output: (parsed, current_output) => {
65+
last_action_name = ''
66+
action_count = 0
2767
if (
2868
parsed.type == 'item.completed' &&
2969
parsed.item?.type == 'agent_message' &&

‎apps/editor/src/features/search-files/search-modes/perform-agent-search-mode/perform-agent-search-mode.ts‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export const perform_agent_search_mode = async (params: {
3737
resolve_files: () => Promise<string[]>
3838
workspace_provider: WorkspaceProvider
3939
extension_context: vscode.ExtensionContext
40+
output_channel: vscode.OutputChannel
4041
show_back_button?: boolean
4142
search_in_results: (
4243
matched_paths: string[]
@@ -510,8 +511,13 @@ export const perform_agent_search_mode = async (params: {
510511
stdio: ['ignore', 'pipe', 'pipe']
511512
})
512513

514+
const out_channel = params.output_channel
515+
out_channel.show(true)
516+
out_channel.appendLine(`\n${executable} ${args.join(' ')}\n`)
517+
513518
child.stdout.on('data', (data) => {
514519
const chunk = data.toString()
520+
out_channel.append(chunk)
515521
if (agent_info.parse_stream_line) {
516522
raw_stream_output += chunk
517523
const lines = raw_stream_output.split('\n')
@@ -540,8 +546,9 @@ export const perform_agent_search_mode = async (params: {
540546
}
541547
})
542548

543-
child.stderr.on('data', () => {
544-
// Ignore stderr
549+
child.stderr.on('data', (data) => {
550+
const chunk = data.toString()
551+
out_channel.append(chunk)
545552
})
546553

547554
token.onCancellationRequested(() => {
@@ -550,7 +557,8 @@ export const perform_agent_search_mode = async (params: {
550557
resolve()
551558
})
552559

553-
child.on('close', () => {
560+
child.on('close', (code) => {
561+
out_channel.appendLine(`\nProcess exited with code ${code}\n`)
554562
if (
555563
agent_info.parse_final_output &&
556564
raw_stream_output.trim()
@@ -573,6 +581,7 @@ export const perform_agent_search_mode = async (params: {
573581
})
574582

575583
child.on('error', (err) => {
584+
out_channel.appendLine(`\nProcess error: ${err.message}\n`)
576585
Logger.error({
577586
function_name: 'perform_agent_search_mode',
578587
message: 'Agent execution failed',

‎apps/editor/src/features/search-files/search-modes/perform-agent-search-mode/utils.ts‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,10 @@ export const format_duration = (ms: number): string => {
3333
const minutes = Math.floor((total_seconds % 3600) / 60)
3434
const seconds = total_seconds % 60
3535

36-
if (hours > 0) {
37-
return `${hours}h ${minutes}m ${seconds}s`
38-
}
39-
if (minutes > 0) {
40-
return `${minutes}m ${seconds}s`
41-
}
42-
return `${seconds}s`
36+
const parts = []
37+
if (hours > 0) parts.push(`${hours}h`)
38+
if (minutes > 0 || (hours > 0 && seconds > 0)) parts.push(`${minutes}m`)
39+
if (seconds > 0 || (hours === 0 && minutes === 0)) parts.push(`${seconds}s`)
40+
41+
return parts.join(' ')
4342
}

0 commit comments

Comments
 (0)