fix(webui): events dates, phone detail, model links, caller coverage

Events show the date for rows from earlier days, the message sits on a second line on phones, and consecutive identical events collapse into one row with a count. Unpriced events link to the model panel or a models search. The provider filter keeps one control type. The harness covers the target callers list and the mock gains a readitall caller fixture.
This commit is contained in:
2026-11-25 11:52:38 +00:00
parent e0e5989326
commit dd11ada41f
13 changed files with 234 additions and 46 deletions
+22 -26
View File
@@ -4,10 +4,13 @@ import { computed } from 'vue'
import { useEntityLinks } from '@/composables/useEntityLinks'
import { eventLink } from '@/lib/event-link'
import { collapseEvents, eventSubject, formatEventTime } from '@/lib/event-feed'
import type { EventGroup } from '@/lib/event-feed'
import { kindLabel } from '@/lib/events-filter'
import { useNavStore } from '@/stores/nav'
import type { AdminEventView } from '@/types/api'
const CLOCK_LENGTH = 5
type Tone = 'danger' | 'warning' | 'info' | 'neutral'
const TONE: Record<string, Tone> = {
rate_limit: 'warning',
@@ -22,34 +25,27 @@ const TONE: Record<string, Tone> = {
router_timeout_fallback: 'warning',
}
const props = withDefaults(defineProps<{ events: AdminEventView[]; label?: string; withMessage?: boolean }>(), { label: 'Recent events', withMessage: false })
const props = withDefaults(defineProps<{ events?: AdminEventView[]; groups?: EventGroup[]; label?: string; withMessage?: boolean }>(), {
events: () => [],
groups: undefined,
label: 'Recent events',
withMessage: false,
})
const nav = useNavStore()
const { openLink } = useEntityLinks()
function subject(e: AdminEventView): string {
return e.user || e.group || e.provider || e.model || e.route || e.message
}
function clock(iso: string): string {
const d = new Date(iso)
return Number.isNaN(d.getTime()) ? '' : d.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', hour12: false })
}
// A link back to the page already showing, with nothing to open, would do nothing.
function linkOf(e: AdminEventView) {
const link = eventLink(e)
return link && !(link.page === nav.page && !link.sel) ? link : null
return link && !(link.page === nav.page && !link.sel && !link.params) ? link : null
}
const rows = computed(() => {
const seen = new Map<string, number>()
return props.events.map((e) => {
const base = `${e.time}|${e.replica}|${e.kind}|${e.message}`
const n = seen.get(base) ?? 0
seen.set(base, n + 1)
return { e, key: `${base}|${n}`, link: linkOf(e) }
})
const now = new Date()
return (props.groups ?? collapseEvents(props.events)).map((g) => ({ ...g, time: formatEventTime(g.event.time, now), link: linkOf(g.event) }))
})
// Dated rows are wider than a bare clock; a fixed width keeps the kind column aligned.
const dated = computed(() => rows.value.some((r) => r.time.length > CLOCK_LENGTH))
</script>
<template>
@@ -58,17 +54,17 @@ const rows = computed(() => {
<component
:is="r.link ? 'button' : 'div'"
:type="r.link ? 'button' : undefined"
class="flex h-8 w-full items-center gap-2 rounded-md px-2 text-left text-sm"
class="flex min-h-8 w-full flex-wrap items-center gap-x-2 rounded-md px-2 py-1 text-left text-sm sm:h-8 sm:flex-nowrap sm:py-0"
:class="r.link ? 'hover:bg-accent' : ''"
:title="`${kindLabel(r.e.kind)}: ${r.e.message}`"
:title="`${kindLabel(r.event.kind)}${r.count > 1 ? ` ×${r.count}` : ''}: ${r.event.message}`"
@click="r.link && openLink(r.link)"
>
<StatusDot class="shrink-0" :tone="TONE[r.e.kind] ?? 'neutral'" size="md" />
<span class="text-muted-foreground shrink-0 font-mono text-xs tabular-nums">{{ clock(r.e.time) }}</span>
<span class="text-muted-foreground shrink-0">{{ kindLabel(r.e.kind) }}</span>
<span class="min-w-0 flex-1 truncate">
{{ subject(r.e) }}<span v-if="withMessage" class="text-muted-foreground hidden sm:inline"> · {{ r.e.message }}</span>
</span>
<StatusDot class="shrink-0" :tone="TONE[r.event.kind] ?? 'neutral'" size="md" />
<span class="text-muted-foreground shrink-0 font-mono text-xs tabular-nums" :class="dated ? 'w-[5.5rem]' : ''">{{ r.time }}</span>
<span class="text-muted-foreground shrink-0">{{ kindLabel(r.event.kind) }}</span>
<span v-if="r.count > 1" class="text-muted-foreground shrink-0 font-mono text-xs tabular-nums" :aria-label="`${r.count} times`">×{{ r.count }}</span>
<span class="min-w-0 max-w-full truncate" :class="withMessage ? 'sm:max-w-[40%] sm:shrink-0' : 'flex-1'">{{ eventSubject(r.event) }}</span>
<span v-if="withMessage" class="text-muted-foreground min-w-0 basis-full truncate pl-4 text-xs sm:flex-1 sm:basis-0 sm:pl-0 sm:text-sm">{{ r.event.message }}</span>
</component>
</li>
</ul>