approval lifecycle entries in Activity timeline
- activityLog now detects 'requires approval' in tool results - Adds approval entries with shield icon + description + execution ID - Works for both run and remaining approval paths
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
import SparklesIcon from '@lucide/svelte/icons/sparkles'
|
||||
import HelpCircleIcon from '@lucide/svelte/icons/help-circle'
|
||||
import FlagIcon from '@lucide/svelte/icons/flag'
|
||||
import ShieldIcon from '@lucide/svelte/icons/shield'
|
||||
import ChevronDownIcon from '@lucide/svelte/icons/chevron-down'
|
||||
import ChevronRightIcon from '@lucide/svelte/icons/chevron-right'
|
||||
|
||||
@@ -29,6 +30,7 @@
|
||||
case 'knowledge': return SparklesIcon
|
||||
case 'complete': return FlagIcon
|
||||
case 'question': return HelpCircleIcon
|
||||
case 'approval': return ShieldIcon
|
||||
default: return null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,8 @@ export interface ActivityEntry {
|
||||
id: string
|
||||
type: 'goal' | 'plan' | 'step_running' | 'step_done' | 'step_failed' |
|
||||
'tool_running' | 'tool_done' | 'tool_error' |
|
||||
'knowledge' | 'complete' | 'question' | 'error'
|
||||
'knowledge' | 'complete' | 'question' | 'error' |
|
||||
'approval'
|
||||
description: string
|
||||
detail?: string
|
||||
timestamp: number
|
||||
@@ -127,6 +128,27 @@ export const activityLog = derived([messages, planSteps, currentTask], ([$msgs,
|
||||
})
|
||||
}
|
||||
|
||||
// Approvals — detect from tool results containing 'requires approval'
|
||||
for (let mi = 0; mi < $msgs.length; mi++) {
|
||||
for (const t of $msgs[mi].tools) {
|
||||
if (t.type !== 'tool_result') continue
|
||||
const text = typeof t.result === 'string' ? t.result : JSON.stringify(t.result ?? '')
|
||||
if (text.includes('requires approval')) {
|
||||
const m = text.match(/execution\s+([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i)
|
||||
const execId = m ? m[1] : ''
|
||||
const target = (t.args as any)?.target ?? ''
|
||||
const purpose = (t.args as any)?.purpose ?? ''
|
||||
entries.push({
|
||||
id: execId || `approval_${mi}`,
|
||||
type: 'approval',
|
||||
description: purpose ? `Approval: ${purpose.slice(0, 60)}` : `Approval required${target ? ` for ${target}` : ''}`,
|
||||
timestamp: now - ($msgs.length - mi) * 1000,
|
||||
status: 'running'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Sort oldest first
|
||||
entries.sort((a, b) => a.timestamp - b.timestamp)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user