feat(web): add turn-duration event display

This commit is contained in:
weishu
2026-01-17 15:00:04 +08:00
parent f33d142446
commit 940d7b8233
3 changed files with 27 additions and 0 deletions
+12
View File
@@ -7,6 +7,14 @@ export function formatUnixTimestamp(value: number): string {
return date.toLocaleString()
}
function formatDuration(ms: number): string {
const seconds = ms / 1000
if (seconds < 60) return `${seconds.toFixed(1)}s`
const mins = Math.floor(seconds / 60)
const secs = Math.round(seconds % 60)
return `${mins}m ${secs}s`
}
export type EventPresentation = {
icon: string | null
text: string
@@ -46,6 +54,10 @@ export function getEventPresentation(event: AgentEvent): EventPresentation {
if (event.type === 'message') {
return { icon: null, text: typeof event.message === 'string' ? event.message : 'Message' }
}
if (event.type === 'turn-duration') {
const ms = typeof event.durationMs === 'number' ? event.durationMs : 0
return { icon: '⏱️', text: `Turn: ${formatDuration(ms)}` }
}
try {
return { icon: null, text: JSON.stringify(event) }
} catch {