mirror of
https://github.com/lukaszraczylo/traefik-llmgateway.git
synced 2026-11-26 10:06:31 +00:00
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:
@@ -43,6 +43,7 @@ async function sampleIds(page: Page, scenario: string): Promise<Record<string, s
|
||||
'provider-degraded': `provider:${encodeURIComponent('amd')}`,
|
||||
'provider-open': `provider:${encodeURIComponent('alibaba')}`,
|
||||
router: `router:${encodeURIComponent(catalog.routers[0].name)}`,
|
||||
'target-callers': `target:${encodeURIComponent('mcp/readitall')}`,
|
||||
'router-uni': `router:${encodeURIComponent(catalog.routers[1].name)}`,
|
||||
target: `target:${encodeURIComponent(targets.mcpServers[0] ? `mcp/${targets.mcpServers[0].name}` : `agent/${targets.agents[0].name}`)}`,
|
||||
}
|
||||
@@ -60,6 +61,7 @@ const PANEL_PAGES: Array<{ page: (typeof PAGE_IDS)[number]; kind: string; scenar
|
||||
{ page: 'routers', kind: 'router', scenario: 'router-escalations' },
|
||||
{ page: 'routers', kind: 'router-uni' },
|
||||
{ page: 'targets', kind: 'target' },
|
||||
{ page: 'targets', kind: 'target-callers' },
|
||||
]
|
||||
|
||||
async function visit(page: Page, hash: string, scenario: string, theme: string): Promise<void> {
|
||||
@@ -234,3 +236,28 @@ test('events rows are capped and show more', async ({ page }) => {
|
||||
await page.getByRole('button', { name: /Show \d+ more/ }).click()
|
||||
expect(await rows.count()).toBeGreaterThan(50)
|
||||
})
|
||||
|
||||
// A caller that is a configured user opens its panel; "gateway-probe" is not a user and stays plain text.
|
||||
test('target panel callers link only known users', async ({ page }) => {
|
||||
await page.setViewportSize(VIEWPORTS.desktop)
|
||||
const sel = (await sampleIds(page, 'live'))['target-callers']
|
||||
await visit(page, `#targets?sel=${encodeURIComponent(sel)}`, 'live', 'light')
|
||||
const callers = page.getByRole('list', { name: 'Top callers' })
|
||||
await expect(callers.getByText('gateway-probe')).toBeVisible()
|
||||
await expect(callers.getByRole('button', { name: /^gateway-probe/ })).toHaveCount(0)
|
||||
await callers.getByRole('button', { name: /^user-01/ }).click()
|
||||
await expect(page).toHaveURL(/#users\?.*sel=user%3Auser-01/)
|
||||
})
|
||||
|
||||
// Events from earlier days carry a date; the unpriced row links to the models search.
|
||||
test('events show dates for older rows and unpriced rows are clickable', async ({ page }) => {
|
||||
await page.setViewportSize(VIEWPORTS.desktop)
|
||||
await visit(page, '#events', 'live', 'light')
|
||||
const feed = page.getByRole('list', { name: 'Events' })
|
||||
const more = page.getByRole('button', { name: /Show \d+ more/ })
|
||||
for (let i = 0; i < 4 && (await more.count()) > 0; i++) await more.click()
|
||||
await expect(feed.getByText(/^[A-Z][a-z]{2} \d+ \d\d:\d\d$/).first()).toBeVisible()
|
||||
await page.goto(page.url().replace(/#events.*/, '#events?kind=unpriced'))
|
||||
await feed.getByRole('button').first().click()
|
||||
await expect(page).toHaveURL(/#models\?/)
|
||||
})
|
||||
|
||||
@@ -230,7 +230,7 @@
|
||||
"group": "friends",
|
||||
"route": "pacing",
|
||||
"kind": "paced",
|
||||
"message": "request paced 8.333333333s"
|
||||
"message": "request paced 8.3s"
|
||||
},
|
||||
{
|
||||
"time": "2026-11-25T00:38:08.870258606Z",
|
||||
@@ -240,7 +240,7 @@
|
||||
"group": "friends",
|
||||
"route": "pacing",
|
||||
"kind": "paced",
|
||||
"message": "request paced 6.666666666s"
|
||||
"message": "request paced 6.7s"
|
||||
},
|
||||
{
|
||||
"time": "2026-11-25T00:38:08.427318063Z",
|
||||
@@ -250,7 +250,7 @@
|
||||
"group": "friends",
|
||||
"route": "pacing",
|
||||
"kind": "paced",
|
||||
"message": "request paced 1.666666666s"
|
||||
"message": "request paced 1.7s"
|
||||
},
|
||||
{
|
||||
"time": "2026-11-25T00:37:04.66491348Z",
|
||||
@@ -269,7 +269,7 @@
|
||||
"group": "friends",
|
||||
"route": "pacing",
|
||||
"kind": "paced",
|
||||
"message": "request paced 8.333333333s"
|
||||
"message": "request paced 8.3s"
|
||||
},
|
||||
{
|
||||
"time": "2026-11-25T00:36:07.061720559Z",
|
||||
@@ -279,7 +279,7 @@
|
||||
"group": "friends",
|
||||
"route": "pacing",
|
||||
"kind": "paced",
|
||||
"message": "request paced 3.333333333s"
|
||||
"message": "request paced 3.3s"
|
||||
},
|
||||
{
|
||||
"time": "2026-11-25T00:36:05.250311853Z",
|
||||
@@ -289,7 +289,7 @@
|
||||
"group": "friends",
|
||||
"route": "pacing",
|
||||
"kind": "paced",
|
||||
"message": "request paced 1.666666666s"
|
||||
"message": "request paced 1.7s"
|
||||
},
|
||||
{
|
||||
"time": "2026-11-25T00:36:01.834717092Z",
|
||||
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"kind": "targetcaller",
|
||||
"window": "day",
|
||||
"metrics": [
|
||||
"req"
|
||||
],
|
||||
"rows": [
|
||||
{
|
||||
"id": "mcp/readitall/internal",
|
||||
"values": {
|
||||
"req": 12759
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "mcp/readitall/user-01",
|
||||
"values": {
|
||||
"req": 1840
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "mcp/readitall/gateway-probe",
|
||||
"values": {
|
||||
"req": 312
|
||||
}
|
||||
}
|
||||
],
|
||||
"span": 7,
|
||||
"offset": 0
|
||||
}
|
||||
@@ -5216,6 +5216,19 @@
|
||||
},
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"file": "usage_totals__kind-targetcaller_metrics-req_window-day_span-7_limit-10_target-mcp~readitall.json",
|
||||
"path": "/admin/api/usage/totals",
|
||||
"query": {
|
||||
"kind": "targetcaller",
|
||||
"window": "day",
|
||||
"span": "7",
|
||||
"metrics": "req",
|
||||
"limit": "10",
|
||||
"target": "mcp/readitall"
|
||||
},
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"file": "usage_totals__kind-targetcaller_metrics-req_window-day_span-7_limit-10_target-agent~agentkit.json",
|
||||
"path": "/admin/api/usage/totals",
|
||||
|
||||
@@ -15,7 +15,7 @@ export function useEntityLinks() {
|
||||
function openLink(link: AttentionLink): void {
|
||||
const sel = parseSel(link.sel)
|
||||
if (!sel) {
|
||||
nav.goTo(link.page, {}, { replace: false })
|
||||
nav.goTo(link.page, link.params ?? {}, { replace: false })
|
||||
return
|
||||
}
|
||||
nav.goTo(link.page)
|
||||
|
||||
@@ -7,6 +7,8 @@ export type AttentionSeverity = 'danger' | 'warning' | 'info'
|
||||
export interface AttentionLink {
|
||||
page: PageId
|
||||
sel?: string
|
||||
/** Page params when no panel opens, e.g. a search. */
|
||||
params?: Record<string, string>
|
||||
}
|
||||
|
||||
export interface AttentionItem {
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import { collapseEvents, eventSubject, formatEventTime } from './event-feed'
|
||||
import type { AdminEventView } from '@/types/api'
|
||||
|
||||
function event(overrides: Partial<AdminEventView> = {}): AdminEventView {
|
||||
return { time: '2026-11-25T12:00:00Z', replica: 'pod-a', route: 'chat/completions', kind: 'upstream', message: 'status 503', provider: 'amd', ...overrides }
|
||||
}
|
||||
const local = (y: number, mo: number, d: number, h: number, mi: number) => new Date(y, mo - 1, d, h, mi).toISOString()
|
||||
|
||||
describe('formatEventTime', () => {
|
||||
const now = new Date(2026, 10, 25, 15, 0)
|
||||
it('shows only the clock for an event from today', () => {
|
||||
expect(formatEventTime(local(2026, 11, 25, 9, 5), now)).toBe('09:05')
|
||||
})
|
||||
it('adds the date for an earlier day', () => {
|
||||
expect(formatEventTime(local(2026, 11, 24, 23, 59), now)).toBe('Nov 24 23:59')
|
||||
})
|
||||
it('adds the date across a year boundary', () => {
|
||||
expect(formatEventTime(local(2025, 12, 31, 8, 0), now)).toBe('Dec 31 08:00')
|
||||
})
|
||||
it('is empty for an unparseable time', () => {
|
||||
expect(formatEventTime('garbage', now)).toBe('')
|
||||
})
|
||||
})
|
||||
|
||||
describe('eventSubject', () => {
|
||||
it('prefers user, then group, provider, model, route, message', () => {
|
||||
expect(eventSubject(event({ user: 'u', group: 'g' }))).toBe('u')
|
||||
expect(eventSubject(event({ provider: undefined, model: 'm' }))).toBe('m')
|
||||
expect(eventSubject(event({ provider: undefined, route: '' }))).toBe('status 503')
|
||||
})
|
||||
})
|
||||
|
||||
describe('collapseEvents', () => {
|
||||
it('merges consecutive identical events into one row with a count', () => {
|
||||
const rows = collapseEvents([event({ time: 'a' }), event({ time: 'b' }), event({ time: 'c' })])
|
||||
expect(rows).toHaveLength(1)
|
||||
expect(rows[0].count).toBe(3)
|
||||
expect(rows[0].event.time).toBe('a')
|
||||
})
|
||||
it('does not merge across a different event', () => {
|
||||
expect(collapseEvents([event(), event({ message: 'other' }), event()]).map((r) => r.count)).toEqual([1, 1, 1])
|
||||
})
|
||||
it('treats a different kind or subject as different', () => {
|
||||
expect(collapseEvents([event(), event({ kind: 'timeout' }), event({ kind: 'timeout', provider: 'x' })])).toHaveLength(3)
|
||||
})
|
||||
it('keeps distinct keys for rows', () => {
|
||||
const keys = collapseEvents([event({ message: 'a' }), event({ message: 'b' })]).map((r) => r.key)
|
||||
expect(new Set(keys).size).toBe(2)
|
||||
})
|
||||
it('is empty for no events', () => {
|
||||
expect(collapseEvents([])).toEqual([])
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,43 @@
|
||||
import type { AdminEventView } from '@/types/api'
|
||||
|
||||
const MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
|
||||
const pad = (n: number): string => String(n).padStart(2, '0')
|
||||
|
||||
/** Clock time for today's events; date and time for any other day. Empty for an unparseable time. */
|
||||
export function formatEventTime(iso: string, now: Date = new Date()): string {
|
||||
const d = new Date(iso)
|
||||
if (Number.isNaN(d.getTime())) return ''
|
||||
const clock = `${pad(d.getHours())}:${pad(d.getMinutes())}`
|
||||
const today = d.getFullYear() === now.getFullYear() && d.getMonth() === now.getMonth() && d.getDate() === now.getDate()
|
||||
return today ? clock : `${MONTHS[d.getMonth()]} ${d.getDate()} ${clock}`
|
||||
}
|
||||
|
||||
/** The entity an event is about, falling back to its route and then its message. */
|
||||
export function eventSubject(e: AdminEventView): string {
|
||||
return e.user || e.group || e.provider || e.model || e.route || e.message
|
||||
}
|
||||
|
||||
export interface EventGroup {
|
||||
/** The newest event of the run. */
|
||||
event: AdminEventView
|
||||
count: number
|
||||
key: string
|
||||
}
|
||||
|
||||
/** Merges runs of consecutive events with the same kind, subject and message into one row. */
|
||||
export function collapseEvents(events: readonly AdminEventView[]): EventGroup[] {
|
||||
const out: EventGroup[] = []
|
||||
const seen = new Map<string, number>()
|
||||
for (const e of events) {
|
||||
const last = out[out.length - 1]
|
||||
if (last && last.event.kind === e.kind && eventSubject(last.event) === eventSubject(e) && last.event.message === e.message) {
|
||||
last.count++
|
||||
continue
|
||||
}
|
||||
const base = `${e.time}|${e.replica}|${e.kind}|${e.message}`
|
||||
const n = seen.get(base) ?? 0
|
||||
seen.set(base, n + 1)
|
||||
out.push({ event: e, count: 1, key: `${base}|${n}` })
|
||||
}
|
||||
return out
|
||||
}
|
||||
@@ -35,4 +35,12 @@ describe('eventLink', () => {
|
||||
it('links router_escalation to its provider panel', () => {
|
||||
expect(eventLink(event({ kind: 'router_escalation', provider: 'gx10' }))).toEqual({ page: 'models', sel: 'provider:gx10' })
|
||||
})
|
||||
|
||||
it('links an unpriced event with its provider to the model panel', () => {
|
||||
expect(eventLink(event({ kind: 'unpriced', provider: 'amd', model: 'qwen' }))).toEqual({ page: 'models', sel: 'model:amd%2Fqwen' })
|
||||
})
|
||||
|
||||
it('links an unpriced event without a provider to the models search', () => {
|
||||
expect(eventLink(event({ kind: 'unpriced', model: 'deepseek-v4' }))).toEqual({ page: 'models', params: { q: 'deepseek-v4' } })
|
||||
})
|
||||
})
|
||||
|
||||
@@ -8,9 +8,19 @@ 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)
|
||||
|
||||
@@ -3,6 +3,7 @@ import { Button, Card, CardAction, CardContent, CardHeader, CardTitle, FilterBar
|
||||
import type { FilterField, FilterItem } from '@perfect-design/ui'
|
||||
import { computed, onMounted, onUnmounted, ref, watch } from 'vue'
|
||||
|
||||
import { collapseEvents } from '@/lib/event-feed'
|
||||
import { EVENT_KIND_LABEL, EVENT_KINDS, eventFilterFromParams, filterEvents, itemsFromFilter, paramsFromItems } from '@/lib/events-filter'
|
||||
import { loadState } from '@/lib/load-state'
|
||||
import { EVENTS_POLL_MS, useEventsStore } from '@/stores/events'
|
||||
@@ -21,16 +22,10 @@ const nav = useNavStore()
|
||||
const filter = computed(() => eventFilterFromParams(nav.params))
|
||||
const items = computed<FilterItem[]>(() => itemsFromFilter(filter.value))
|
||||
|
||||
const providerOptions = computed(() => {
|
||||
const names = new Set(events.events.flatMap((e) => (e.provider ? [e.provider] : [])))
|
||||
if (filter.value.provider) names.add(filter.value.provider)
|
||||
return [...names].sort().map((value) => ({ value, label: value }))
|
||||
})
|
||||
const fields = computed<FilterField[]>(() => [
|
||||
{ id: 'kind', label: 'Kind', type: 'select', operators: ['eq'], options: EVENT_KINDS.map((k) => ({ value: k, label: EVENT_KIND_LABEL[k] })) },
|
||||
{ id: 'user', label: 'User or group', type: 'text', operators: ['contains'], placeholder: 'name' },
|
||||
// The select needs at least one option; until events name a provider it is a plain text field.
|
||||
{ id: 'provider', label: 'Provider', type: providerOptions.value.length > 0 ? 'select' : 'text', operators: ['eq'], options: providerOptions.value },
|
||||
{ id: 'provider', label: 'Provider', type: 'text', operators: ['eq'], placeholder: 'provider name' },
|
||||
{ id: 'route', label: 'Route', type: 'text', operators: ['contains'], placeholder: 'chat/completions' },
|
||||
])
|
||||
|
||||
@@ -42,8 +37,9 @@ function setItems(next: FilterItem[]): void {
|
||||
const filtered = computed(() => filterEvents(events.events, filter.value))
|
||||
const shown = ref(PAGE_STEP)
|
||||
watch(filter, () => (shown.value = PAGE_STEP))
|
||||
const visible = computed(() => filtered.value.slice(0, shown.value))
|
||||
const remaining = computed(() => filtered.value.length - visible.value.length)
|
||||
const grouped = computed(() => collapseEvents(filtered.value))
|
||||
const visible = computed(() => grouped.value.slice(0, shown.value))
|
||||
const remaining = computed(() => grouped.value.length - visible.value.length)
|
||||
|
||||
// --- Live tail: the store polls while mounted and not paused ---
|
||||
const live = ref(true)
|
||||
@@ -95,9 +91,9 @@ const countNote = computed(() => (filtered.value.length === events.events.length
|
||||
<span>{{ sourceNote }}</span>
|
||||
</div>
|
||||
<StateView :state="state" :empty-title="emptyTitle" :empty-description="emptyDescription" :error-message="events.error" :updated-at="events.lastUpdated ?? undefined" @retry="events.refresh()">
|
||||
<RecentEvents :events="visible" label="Events" with-message />
|
||||
<RecentEvents :groups="visible" label="Events" with-message />
|
||||
<div v-if="remaining > 0" class="flex items-center justify-between gap-2">
|
||||
<span class="text-muted-foreground text-xs">Showing {{ visible.length.toLocaleString('en-US') }} of {{ filtered.length.toLocaleString('en-US') }}</span>
|
||||
<span class="text-muted-foreground text-xs">Showing {{ visible.length.toLocaleString('en-US') }} of {{ grouped.length.toLocaleString('en-US') }} rows</span>
|
||||
<Button variant="outline" size="sm" @click="shown += PAGE_STEP">Show {{ Math.min(PAGE_STEP, remaining) }} more</Button>
|
||||
</div>
|
||||
</StateView>
|
||||
|
||||
@@ -77,9 +77,14 @@ async function loadCallers(): Promise<void> {
|
||||
}
|
||||
watch([targetRef, () => filters.window, () => filters.span], () => void loadCallers(), { immediate: true })
|
||||
|
||||
// Only a configured user has a panel to open; other callers (e.g. "internal") stay plain text.
|
||||
const knownUsers = computed(() => new Set((dashboard.usage?.users ?? []).map((u) => u.id)))
|
||||
const callerRows = computed(() =>
|
||||
callers.value
|
||||
.map((r) => ({ id: r.id, caller: parseTargetCallerId(r.id).caller || r.id, requests: r.values.req ?? 0 }))
|
||||
.map((r) => {
|
||||
const caller = parseTargetCallerId(r.id).caller || r.id
|
||||
return { id: r.id, caller, requests: r.values.req ?? 0, isUser: knownUsers.value.has(caller) }
|
||||
})
|
||||
.sort((a, b) => b.requests - a.requests || a.caller.localeCompare(b.caller)),
|
||||
)
|
||||
</script>
|
||||
@@ -129,10 +134,14 @@ const callerRows = computed(() =>
|
||||
<StateView :state="callersState" empty-title="No callers in this range" :error-message="callersError" :rows="3" @retry="loadCallers()">
|
||||
<ul class="m-0 flex list-none flex-col p-0" aria-label="Top callers">
|
||||
<li v-for="c in callerRows" :key="c.id">
|
||||
<button type="button" class="hover:bg-accent flex h-8 w-full items-center justify-between gap-3 rounded px-2 text-left text-sm" :title="c.caller" @click="openEntity('user', c.caller)">
|
||||
<button v-if="c.isUser" type="button" class="hover:bg-accent flex h-8 w-full items-center justify-between gap-3 rounded px-2 text-left text-sm" :title="c.caller" @click="openEntity('user', c.caller)">
|
||||
<span class="min-w-0 truncate">{{ c.caller }}</span>
|
||||
<span class="shrink-0 font-mono text-xs tabular-nums">{{ formatCompactCount(c.requests) }} req</span>
|
||||
</button>
|
||||
<div v-else class="flex h-8 w-full items-center justify-between gap-3 px-2 text-sm" :title="`${c.caller} (not a configured user)`">
|
||||
<span class="text-muted-foreground min-w-0 truncate">{{ c.caller }}</span>
|
||||
<span class="shrink-0 font-mono text-xs tabular-nums">{{ formatCompactCount(c.requests) }} req</span>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</StateView>
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user