fix(ui): log table shows component on the Logs page and a bordered sticky header

This commit is contained in:
sam committed 2026-10-25 02:21:57 +11:00
1 parent 0ccd1793e3
commit 4241dbf817
5 files changed
+87 -84

No files matched your search

+7 -4
View File
@@ -15,7 +15,8 @@ const props = withDefaults(
storageKey: string;
/** Fields the page itself already names, such as the task it is about. */
omit?: string[];
/** Shows the service column by default, for logs spanning services. */
/** Shows service and component columns by default, for logs spanning
* services; a task's own log shows its stage instead. */
services?: boolean;
}>(),
{ omit: () => [], services: false },
@@ -25,11 +26,12 @@ const columns: DataTableColumn<LogEntry>[] = [
{ id: "time", label: "Time", fixed: true, class: "w-0 whitespace-nowrap" },
{ id: "level", label: "Level", fixed: true, class: "w-0" },
{ id: "service", label: "Service", hidden: !props.services, class: "w-0 whitespace-nowrap" },
{ id: "stage", label: "Stage", class: "w-0 whitespace-nowrap" },
{ id: "component", label: "Component", hidden: !props.services, class: "w-0 whitespace-nowrap" },
{ id: "stage", label: "Stage", hidden: props.services, class: "w-0 whitespace-nowrap" },
{ id: "message", label: "Message", fixed: true },
];
// received_at restates the time; stage and service have columns.
const shown = new Set(["received_at", "stage", "service", ...props.omit]);
// received_at restates the time; the rest have columns.
const shown = new Set(["received_at", "stage", "service", "component", ...props.omit]);
const field = (entry: LogEntry, name: string) => fmtValue(entry.fields?.[name] ?? "");
const details = (entry: LogEntry) =>
Object.entries(entry.fields ?? {})
@@ -44,6 +46,7 @@ const details = (entry: LogEntry) =>
<span class="text-micro font-semibold tracking-[0.04em]" :class="LEVEL_COLOR[levelKind(row.level)]">{{ (row.level || "info").toUpperCase() }}</span>
</template>
<template #cell-service="{ row }"><span class="block max-w-40 truncate font-mono text-xs text-fg-muted">{{ field(row, "service") }}</span></template>
<template #cell-component="{ row }"><span class="block max-w-48 truncate font-mono text-xs text-fg-muted">{{ field(row, "component") }}</span></template>
<template #cell-stage="{ row }"><span class="block max-w-48 truncate font-mono text-xs text-fg-muted" :title="field(row, 'stage')">{{ field(row, "stage") }}</span></template>
<template #cell-message="{ row }">
<span class="font-mono text-xs [overflow-wrap:anywhere]">{{ row.message || row.msg || "" }}</span>
@@ -85,7 +85,7 @@ function open(row: Row): void {
<!-- A sticky header sticks to the page's scrolling frame, so the table
must not be a scroll container of its own. -->
<Table :container-class="stickyHeader && 'overflow-visible'">
<TableHeader :class="stickyHeader && 'sticky top-0 z-10 bg-card'">
<TableHeader :class="stickyHeader && 'sticky top-0 z-10 bg-card shadow-[inset_0_-1px_0_var(--color-border)]'">
<TableRow>
<TableHead
v-for="column in shown"
+1 -1
View File
@@ -44,7 +44,7 @@ watch(
</script>
<template>
<div ref="scroller" class="max-h-[62vh] overflow-y-auto font-mono text-xs">
<div ref="scroller" class="max-h-[62vh] overflow-y-auto text-xs">
<!-- A failed read is about this page's request, not about the log, so it
says what the server said rather than borrowing an empty state. -->
<LogsEmpty v-if="readError" title="Cannot read logs" :detail="readError" />