Skip to content

Commit db70f78

Browse files
committed
Add repeated action tracking and progressive dot formatting to muse agent progress reporting
- similarly to other agents, muse should show tool names e.g. 'search...' or 'bash...' for the notification progress update [Pasted text] - muse reports in notification 'read_file...', should 'read file...' └── apps └── editor └── src └── features └── search-files └── search-modes └── perform-agent-search-mode └── agents ├── antigravity.ts ├── codex.ts ├── muse.ts └── opencode.ts
1 parent 670f0a0 commit db70f78

1 file changed

Lines changed: 37 additions & 4 deletions

File tree

  • apps/editor/src/features/search-files/search-modes/perform-agent-search-mode/agents

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

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

44
let accumulated_output = ''
5+
let last_action_name = ''
6+
let action_count = 0
57

68
export const muse_agent: CodingAgent = {
79
id: 'muse',
@@ -16,43 +18,72 @@ export const muse_agent: CodingAgent = {
1618
},
1719
parse_stream_line: (parsed, report_progress) => {
1820
const payload = parsed.payload || parsed
21+
let action_name = ''
1922

20-
if (
23+
if (payload.event?.task_kind?.startsWith('tool.')) {
24+
action_name = payload.event.task_kind.slice(5)
25+
} else if (payload.event?.operation?.startsWith('tool:')) {
26+
action_name = payload.event.operation.slice(5)
27+
} else if (payload.correlation_facts?.tool_name) {
28+
action_name = payload.correlation_facts.tool_name
29+
} else if (
2130
parsed.type === 'tool.result' ||
2231
parsed.type === 'tool_call' ||
2332
payload.type === 'tool_call'
2433
) {
2534
const tool = payload.tool_name || payload.tool || payload.name
2635
if (tool)
27-
report_progress(typeof tool === 'string' ? tool : JSON.stringify(tool))
36+
action_name = typeof tool === 'string' ? tool : JSON.stringify(tool)
37+
} else if (payload.tool) {
38+
const tool = payload.tool.name || payload.tool
39+
if (tool)
40+
action_name = typeof tool === 'string' ? tool : JSON.stringify(tool)
41+
}
42+
43+
if (action_name) {
44+
action_name = action_name.replace(/_/g, ' ')
45+
if (action_name === last_action_name) {
46+
action_count++
47+
} else {
48+
last_action_name = action_name
49+
action_count = 1
50+
}
51+
const extra_dots = action_count > 1 ? '.'.repeat(action_count - 1) : ''
52+
report_progress(`${action_name}...${extra_dots}`)
2853
} else if (
2954
parsed.type === 'status' ||
3055
payload.type === 'status' ||
3156
parsed.type === 'run.model.configured'
3257
) {
3358
const msg = payload.message || payload.status || parsed.type
3459
if (msg) report_progress(msg)
35-
} else if (payload.tool) {
36-
report_progress(payload.tool.name || payload.tool)
3760
}
3861

3962
if (parsed.type === 'streamed' || payload.type === 'streamed') {
4063
if (payload.text) {
4164
accumulated_output += payload.text
65+
last_action_name = ''
66+
action_count = 0
4267
return { output: accumulated_output }
4368
}
4469
} else if (parsed.type === 'result' || payload.type === 'result') {
4570
const res = payload.result || payload
4671
if (res) {
72+
last_action_name = ''
73+
action_count = 0
4774
return {
4875
output: typeof res === 'string' ? res : res.text || res.response || ''
4976
}
5077
}
5178
}
5279

5380
if (payload.text && typeof payload.text === 'string') {
81+
last_action_name = ''
82+
action_count = 0
5483
return { output: payload.text }
5584
} else if (payload.output) {
85+
last_action_name = ''
86+
action_count = 0
5687
return {
5788
output:
5889
typeof payload.output === 'string'
@@ -62,6 +93,8 @@ export const muse_agent: CodingAgent = {
6293
}
6394
},
6495
parse_final_output: (parsed, current_output) => {
96+
last_action_name = ''
97+
action_count = 0
6598
const payload = parsed.payload || parsed
6699
if (parsed.type === 'result' || payload.type === 'result') {
67100
const res = payload.result || payload

0 commit comments

Comments
 (0)