From b9f6c9d392f8a54a331205febcc45a63dd75fd41 Mon Sep 17 00:00:00 2001 From: Suresh Chaudhary Date: Thu, 2 Jul 2026 23:46:15 +0530 Subject: [PATCH] fix: extra column accessors for logs table --- ui/app/workspace/logs/views/columns.tsx | 112 +++++++++++++++++++----- ui/lib/types/logs.ts | 2 + 2 files changed, 91 insertions(+), 23 deletions(-) diff --git a/ui/app/workspace/logs/views/columns.tsx b/ui/app/workspace/logs/views/columns.tsx index 05a48f72da0..a42f4537e38 100644 --- a/ui/app/workspace/logs/views/columns.tsx +++ b/ui/app/workspace/logs/views/columns.tsx @@ -1,5 +1,4 @@ import { formatCost, formatLatency } from "@/app/workspace/dashboard/utils/chartUtils"; -import { formatCompactNumber } from "@/lib/utils/numbers"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@/components/ui/dropdownMenu"; @@ -7,6 +6,7 @@ import { ProviderIconType, RenderProviderIcon } from "@/lib/constants/icons"; import { getProviderLabel, ProviderName, RequestTypeColors, RequestTypeLabels, Status, StatusBarColors } from "@/lib/constants/logs"; import { ChatMessageContent, LogEntry, ResponsesMessageContentBlock } from "@/lib/types/logs"; import { cn } from "@/lib/utils"; +import { formatCompactNumber } from "@/lib/utils/numbers"; import { ColumnDef } from "@tanstack/react-table"; import { format, formatDistanceToNow } from "date-fns"; import { ArrowUpDown, MoreHorizontal, Trash2 } from "lucide-react"; @@ -178,7 +178,7 @@ export function LogMessageCell({ log, contentClassName = "max-w-full" }: { log: )} {realtimeMessages && - (realtimeMessages.tool || realtimeMessages.user || realtimeMessages.assistantToolCall || realtimeMessages.assistant) ? ( + (realtimeMessages.tool || realtimeMessages.user || realtimeMessages.assistantToolCall || realtimeMessages.assistant) ? (
{realtimeMessages.tool ?
Tool Result: {realtimeMessages.tool}
: null} {realtimeMessages.user ?
User: {realtimeMessages.user}
: null} @@ -199,6 +199,53 @@ export function LogMessageCell({ log, contentClassName = "max-w-full" }: { log: ); } +const MAX_ATTRIBUTION_LINES = 1; + +// AttributionCell resolves an attribution value using a plural-first fallback: +// plural names -> singular name -> plural ids -> singular id. When a plural +// (array) source is used, values render one per line, capped at +// MAX_ATTRIBUTION_LINES with a "+N more" indicator for the remainder. +function AttributionCell({ + names, + name, + ids, + id, +}: { + names?: string[]; + name?: string | null; + ids?: string[]; + id?: string | null; +}) { + let values: string[] = []; + if (Array.isArray(names) && names.filter(Boolean).length > 0) { + values = names.filter(Boolean); + } else if (name) { + values = [name]; + } else if (Array.isArray(ids) && ids.filter(Boolean).length > 0) { + values = ids.filter(Boolean); + } else if (id) { + values = [id]; + } + + if (values.length === 0) { + return
-
; + } + + const visible = values.slice(0, MAX_ATTRIBUTION_LINES); + const remaining = values.length - visible.length; + + return ( +
+ {visible.map((value, index) => ( + + {value} + + ))} + {remaining > 0 && +{remaining} more} +
+ ); +} + export const createColumns = ( onDelete: (log: LogEntry) => void, hasDeleteAccess = true, @@ -367,44 +414,63 @@ export const createColumns = ( }, ]; - const attributionCell = (value?: string | null) =>
{value || "-"}
; - const attributionColumns: ColumnDef[] = [ { id: "virtual_key", header: "Virtual Key", size: 170, - cell: ({ row }) => attributionCell(row.original.virtual_key?.name ?? row.original.virtual_key_id), + cell: ({ row }) => , }, { id: "routing_rule", header: "Routing Rule", size: 170, - cell: ({ row }) => attributionCell(row.original.routing_rule?.name ?? row.original.routing_rule_id), + cell: ({ row }) => , }, { id: "team", header: "Team", size: 150, - cell: ({ row }) => attributionCell(row.original.team_name ?? row.original.team_id), + cell: ({ row }) => ( + + ), }, { id: "customer", header: "Customer", size: 150, - cell: ({ row }) => attributionCell(row.original.customer_name ?? row.original.customer_id), + cell: ({ row }) => ( + + ), }, { id: "user", header: "User", size: 150, - cell: ({ row }) => attributionCell(row.original.user_name ?? row.original.user_id), + cell: ({ row }) => , }, { id: "business_unit", header: "Business Unit", size: 150, - cell: ({ row }) => attributionCell(row.original.business_unit_name ?? row.original.business_unit_id), + cell: ({ row }) => ( + + ), }, ]; @@ -420,20 +486,20 @@ export const createColumns = ( const actionsColumn: ColumnDef[] = hasDeleteAccess ? [ - { - id: "actions", - header: "", - size: 56, - cell: ({ row }) => { - const log = row.original; - return ( -
- -
- ); - }, + { + id: "actions", + header: "", + size: 56, + cell: ({ row }) => { + const log = row.original; + return ( +
+ +
+ ); }, - ] + }, + ] : []; return [...baseColumns, ...attributionColumns, ...metadataColumns, ...actionsColumn]; diff --git a/ui/lib/types/logs.ts b/ui/lib/types/logs.ts index 52e332b072c..566c4089fae 100644 --- a/ui/lib/types/logs.ts +++ b/ui/lib/types/logs.ts @@ -529,8 +529,10 @@ export interface LogEntry { user_id?: string; user_name?: string; virtual_key_id?: string; + virtual_key_name?: string; routing_engines_used?: string[]; routing_rule_id?: string; + routing_rule_name?: string; routing_engine_logs?: string; // Human-readable routing decision logs plugin_logs?: string; // JSON string of plugin execution logs grouped by plugin name selected_key?: DBKey;