mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-08 07:17:39 +00:00
feat(web): add turn-duration event display
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user