Files
traefik-llmgateway/webui/src/lib/event-link.ts
T
lukaszraczylo dd11ada41f 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.
2026-11-25 11:52:38 +00:00

29 lines
1.3 KiB
TypeScript

import type { AttentionLink } from '@/lib/attention'
import { EVENT_KINDS } from '@/lib/events-filter'
import { formatSel, PANEL_PAGE } from '@/lib/panel-selection'
import type { PanelKind } from '@/lib/panel-selection'
import type { AdminEventView } from '@/types/api'
function panelLink(kind: PanelKind, id: string): AttentionLink {
return { page: PANEL_PAGE[kind], sel: formatSel(kind, id) }
}
const UNPRICED = 'unpriced'
/** The catalog id of an event's model: already qualified, or provider/model. */
function modelId(provider: string | undefined, model: string): string {
return model.includes('/') || !provider ? model : `${provider}/${model}`
}
/** Where an event row leads: the user, group or provider it names, else the events page; null for a kind this build does not know. */
export function eventLink(event: AdminEventView): AttentionLink | null {
if (!(EVENT_KINDS as readonly string[]).includes(event.kind)) return null
if (event.kind === UNPRICED && event.model) {
return event.provider || event.model.includes('/') ? panelLink('model', modelId(event.provider, event.model)) : { page: 'models', params: { q: event.model } }
}
if (event.user) return panelLink('user', event.user)
if (event.group) return panelLink('group', event.group)
if (event.provider) return panelLink('provider', event.provider)
return { page: 'events' }
}