The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
feat(studio): tidy up bottom tray in logs interface (#45371)
kemal.earthb2e5476146c4
diff --git a/apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/components/ServiceFlowHeader.tsx b/apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/components/ServiceFlowHeader.tsxdeleted file mode 100644index a5f3d80e4d3..00000000000--- a/apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/components/ServiceFlowHeader.tsx+++ /dev/null@@ -1,169 +0,0 @@-import { ChevronDown, ChevronUp, X } from 'lucide-react'-import { useCallback, useEffect, useMemo } from 'react'-import { Badge, Button, Separator } from 'ui'--import { LogTypeIcon } from '../../components/LogTypeIcon'-import { ColumnSchema } from '../../UnifiedLogs.schema'-import { getStatusLevel } from '../../UnifiedLogs.utils'-import { TruncatedTextWithPopover } from './shared/TruncatedTextWithPopover'-import { ButtonTooltip } from '@/components/ui/ButtonTooltip'-import { DataTableColumnStatusCode } from '@/components/ui/DataTable/DataTableColumn/DataTableColumnStatusCode'-import { Kbd } from '@/components/ui/DataTable/primitives/Kbd'-import { useDataTable } from '@/components/ui/DataTable/providers/DataTableProvider'--interface ServiceFlowHeaderProps {- selectedRow: ColumnSchema- enrichedData?: Record<string, any>-}--export const ServiceFlowHeader = ({ selectedRow, enrichedData }: ServiceFlowHeaderProps) => {- const { table, rowSelection, isLoading } = useDataTable()-- const method = selectedRow?.method- const logType = selectedRow?.log_type- const status = selectedRow?.status-- // Display logic: path → event_message → grayed out "/"- const displayPath = useMemo(() => {- const actualPath = enrichedData?.request_path || selectedRow?.pathname- if (actualPath && actualPath !== '/') {- return { text: actualPath, isDefault: false, isTruncatable: false }- }-- const eventMessage = enrichedData?.event_message || selectedRow?.event_message- if (eventMessage) {- return { text: eventMessage, isDefault: false, isTruncatable: true }- }-- return { text: '/', isDefault: true, isTruncatable: false }- }, [enrichedData, selectedRow])-- // Navigation logic (same as DataTableSheetDetails)- const selectedRowKey = Object.keys(rowSelection)?.[0]-- const selectedRowData = useMemo(() => {- if (isLoading && !selectedRowKey) return- return table.getCoreRowModel().flatRows.find((row) => row.id === selectedRowKey)- }, [selectedRowKey, isLoading, table])-- const index = table.getCoreRowModel().flatRows.findIndex((row) => row.id === selectedRowData?.id)- // Get the ID of the next row in the table for navigation- const nextId = useMemo(- () => table.getCoreRowModel().flatRows[index + 1]?.id,- [index, isLoading, table]- )-- // Get the ID of the previous row in the table for navigation- const prevId = useMemo(- () => table.getCoreRowModel().flatRows[index - 1]?.id,- [index, isLoading, table]- )-- // Navigate to the previous row when called- const onPrev = useCallback(() => {- if (prevId) table.setRowSelection({ [prevId]: true })- }, [prevId, table])-- // Navigate to the next row when called- const onNext = useCallback(() => {- if (nextId) table.setRowSelection({ [nextId]: true })- }, [nextId, table])-- // Close the current row selection- const onClose = useCallback(() => {- table.resetRowSelection()- }, [table])-- useEffect(() => {- const down = (e: KeyboardEvent) => {- if (!selectedRowKey) return-- // REMINDER: prevent dropdown navigation inside of sheet to change row selection- const activeElement = document.activeElement- const isMenuActive = activeElement?.closest('[role="menu"]')-- if (isMenuActive) return-- if (e.key === 'ArrowUp') {- e.preventDefault()- onPrev()- }- if (e.key === 'ArrowDown') {- e.preventDefault()- onNext()- }- }-- document.addEventListener('keydown', down)- return () => document.removeEventListener('keydown', down)- }, [selectedRowKey, onNext, onPrev])-- return (- <div className="flex items-center justify-between px-4 py-3">- <div className="flex items-center gap-3 min-w-0 flex-1 mr-6">- {logType && <LogTypeIcon type={logType} size={16} className="text-foreground/70" />}- {method && <Badge variant="default">{method}</Badge>}- {displayPath.isTruncatable ? (- <TruncatedTextWithPopover- text={displayPath.text}- maxLength={60}- className={`font-mono text-sm truncate ${displayPath.isDefault ? 'text-foreground-muted' : 'text-foreground'}`}- />- ) : (- <span- className={`font-mono text-sm truncate ${displayPath.isDefault ? 'text-foreground-muted' : 'text-foreground'}`}- >- {displayPath.text}- </span>- )}- </div>-- <div className="flex h-7 items-center gap-1">- {status && (- <DataTableColumnStatusCode- value={status}- level={getStatusLevel(status)}- className="text-xs"- />- )}- <ButtonTooltip- size="tiny"- type="text"- disabled={!prevId}- onClick={onPrev}- className="px-1"- icon={<ChevronUp />}- tooltip={{- content: {- text: (- <p>- Navigate <Kbd>↑</Kbd>- </p>- ),- },- }}- />- <ButtonTooltip- size="tiny"- type="text"- disabled={!nextId}- onClick={onNext}- className="px-1"- icon={<ChevronDown />}- tooltip={{- content: {- text: (- <p>- Navigate <Kbd>↓</Kbd>- </p>- ),- },- }}- />- <Separator orientation="vertical" className="mx-1" />-- <Button size="tiny" type="text" onClick={onClose} className="px-1" icon={<X />} />- </div>- </div>- )-}diff --git a/apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/components/ServiceFlowPanelControls.tsx b/apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/components/ServiceFlowPanelControls.tsxnew file mode 100644index 00000000000..22477d14508--- /dev/null+++ b/apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/components/ServiceFlowPanelControls.tsx@@ -0,0 +1,117 @@+import { ChevronDown, ChevronUp, X } from 'lucide-react'+import { useCallback, useEffect, useMemo } from 'react'+import { Button, KeyboardShortcut, Separator, Tooltip, TooltipContent, TooltipTrigger } from 'ui'++import { useDataTable } from '@/components/ui/DataTable/providers/DataTableProvider'++export const ServiceFlowPanelControls = () => {+ const { table, rowSelection, isLoading } = useDataTable()++ const selectedRowKey = Object.keys(rowSelection)?.[0]++ const selectedRowData = useMemo(() => {+ if (isLoading && !selectedRowKey) return+ return table.getCoreRowModel().flatRows.find((row) => row.id === selectedRowKey)+ }, [selectedRowKey, isLoading, table])++ const index = table.getCoreRowModel().flatRows.findIndex((row) => row.id === selectedRowData?.id)++ const nextId = useMemo(+ () => table.getCoreRowModel().flatRows[index + 1]?.id,+ // eslint-disable-next-line react-hooks/exhaustive-deps+ [index, isLoading, table]+ )++ const prevId = useMemo(+ () => table.getCoreRowModel().flatRows[index - 1]?.id,+ // eslint-disable-next-line react-hooks/exhaustive-deps+ [index, isLoading, table]+ )++ const onPrev = useCallback(() => {+ if (prevId) table.setRowSelection({ [prevId]: true })+ }, [prevId, table])++ const onNext = useCallback(() => {+ if (nextId) table.setRowSelection({ [nextId]: true })+ }, [nextId, table])++ const onClose = useCallback(() => {+ table.resetRowSelection()+ }, [table])++ useEffect(() => {+ const down = (e: KeyboardEvent) => {+ if (!selectedRowKey) return++ const activeElement = document.activeElement+ if (activeElement?.closest('[role="menu"]')) return++ const tag = activeElement?.tagName+ const isEditable =+ tag === 'INPUT' ||+ tag === 'TEXTAREA' ||+ (activeElement as HTMLElement | null)?.isContentEditable ||+ activeElement?.getAttribute('role') === 'textbox'+ if (isEditable) return++ if (e.key === 'ArrowUp') {+ e.preventDefault()+ onPrev()+ }+ if (e.key === 'ArrowDown') {+ e.preventDefault()+ onNext()+ }+ }++ document.addEventListener('keydown', down)+ return () => document.removeEventListener('keydown', down)+ }, [selectedRowKey, onNext, onPrev])++ return (+ <div className="flex h-7 items-center gap-1">+ <Tooltip>+ <TooltipTrigger asChild>+ <Button+ size="tiny"+ type="text"+ disabled={!prevId}+ onClick={onPrev}+ className="px-1"+ icon={<ChevronUp />}+ />+ </TooltipTrigger>+ <TooltipContent side="top" className="flex items-center gap-2">+ <span>Previous</span>+ <KeyboardShortcut keys={['ArrowUp']} />+ </TooltipContent>+ </Tooltip>+ <Tooltip>+ <TooltipTrigger asChild>+ <Button+ size="tiny"+ type="text"+ disabled={!nextId}+ onClick={onNext}+ className="px-1"+ icon={<ChevronDown />}+ />+ </TooltipTrigger>+ <TooltipContent side="top" className="flex items-center gap-2">+ <span>Next</span>+ <KeyboardShortcut keys={['ArrowDown']} />+ </TooltipContent>+ </Tooltip>+ <Separator orientation="vertical" className="mx-1 h-4" />+ <Tooltip>+ <TooltipTrigger asChild>+ <Button size="tiny" type="text" onClick={onClose} className="px-1" icon={<X />} />+ </TooltipTrigger>+ <TooltipContent side="top">+ <span>Close</span>+ </TooltipContent>+ </Tooltip>+ </div>+ )+}diff --git a/apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/components/blocks/PostgresFlowDetail.tsx b/apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/components/blocks/PostgresFlowDetail.tsxnew file mode 100644index 00000000000..357215c95db--- /dev/null+++ b/apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/components/blocks/PostgresFlowDetail.tsx@@ -0,0 +1,125 @@+import { Table } from '@tanstack/react-table'+import { Cable, Clock, Database } from 'lucide-react'+import { memo } from 'react'++import { ColumnSchema } from '../../../UnifiedLogs.schema'+import { postgresDetailsFields, postgresPrimaryFields } from '../../config/serviceFlowFields'+import { BlockFieldConfig } from '../../types'+import { DetailRow } from '../shared/DetailRow'+import { DetailSectionHeader } from '../shared/DetailSection'+import { FieldValue } from '../shared/FieldValue'+import { DataTableFilterField } from '@/components/ui/DataTable/DataTable.types'++interface PostgresFlowDetailProps {+ data: ColumnSchema+ enrichedData?: Record<string, any>+ isLoading?: boolean+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- matches ServiceFlow types convention+ filterFields: DataTableFilterField<any>[]+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- matches ServiceFlow types convention+ table: Table<any>+}++const FieldDetailRow = ({+ config,+ data,+ enrichedData,+ isLoading,+ filterFields,+ table,+}: {+ config: BlockFieldConfig+ data: ColumnSchema+ enrichedData?: Record<string, any>+ isLoading?: boolean+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- matches ServiceFlow types convention+ filterFields: DataTableFilterField<any>[]+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- matches ServiceFlow types convention+ table: Table<any>+}) => {+ const value = config.getValue(data, enrichedData)+ const showSkeleton = !!config.requiresEnrichedData && !!isLoading && !value++ return (+ <DetailRow+ label={config.label}+ value={<FieldValue config={config} value={value} wrap={config.wrap} />}+ filterId={config.id}+ filterValue={typeof value === 'string' || typeof value === 'number' ? value : undefined}+ filterFields={filterFields}+ table={table}+ isLoading={showSkeleton}+ wrap={config.wrap}+ />+ )+}++export const PostgresFlowDetail = memo(function PostgresFlowDetail({+ data,+ enrichedData,+ isLoading,+ filterFields,+ table,+}: PostgresFlowDetailProps) {+ const timestampMs = data?.timestamp+ ? data.timestamp / 1000+ : data?.date+ ? data.date.getTime()+ : null+ const formattedTime = timestampMs ? new Date(timestampMs).toLocaleString() : null++ const severity: string | undefined =+ enrichedData?.error_severity ??+ ((data as Record<string, unknown>)?.error_severity as string | undefined)++ return (+ <div className="[&>*:nth-child(even)]:bg-surface-100/50">+ <DetailSectionHeader+ title="Requested started"+ icon={Clock}+ summary={formattedTime ?? undefined}+ />++ <DetailSectionHeader title="Postgres" icon={Database} />++ {postgresPrimaryFields.map((field) => (+ <FieldDetailRow+ key={field.id}+ config={field}+ data={data}+ enrichedData={enrichedData}+ isLoading={isLoading}+ filterFields={filterFields}+ table={table}+ />+ ))}++ <DetailSectionHeader title="Connection & Session Details" icon={Cable} />++ {postgresDetailsFields.map((field) => (+ <FieldDetailRow+ key={field.id}+ config={field}+ data={data}+ enrichedData={enrichedData}+ isLoading={isLoading}+ filterFields={filterFields}+ table={table}+ />+ ))}++ <DetailSectionHeader+ title="Operation result"+ icon={Clock}+ topDivider+ summary={+ severity ? (+ <span className="font-mono text-sm uppercase text-foreground">{severity}</span>+ ) : undefined+ }+ />+ </div>+ )+})++PostgresFlowDetail.displayName = 'PostgresFlowDetail'diff --git a/apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/components/blocks/ResponseCompletedBlock.tsx b/apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/components/blocks/ResponseCompletedBlock.tsxindex 90163c771c0..e7a88aff82d 100644--- a/apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/components/blocks/ResponseCompletedBlock.tsx+++ b/apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/components/blocks/ResponseCompletedBlock.tsx@@ -24,7 +24,7 @@ export const MemoizedResponseCompletedBlock = memo(function ResponseCompletedBloconst status = Number(data?.status)// Postgres operation handling- const eventMessage = enrichedData?.event_message || (data as any)?.event_message+ const eventMessage = enrichedData?.event_message || data?.event_messageconst severity = enrichedData?.error_severityconst hasPostgresError = severity && ['error', 'fatal'].includes(severity.toLowerCase())diff --git a/apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/components/shared/Block.tsx b/apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/components/shared/Block.tsxindex 83e42654e71..95aea634dc4 100644--- a/apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/components/shared/Block.tsx+++ b/apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/components/shared/Block.tsx@@ -1,14 +1,14 @@-import { SquareDashedBottomCode } from 'lucide-react'+import { LucideIcon } from 'lucide-react'import { memo } from 'react'-import { BlockFieldConfig, ServiceFlowBlockProps } from '../../types'-import { BlockField } from './BlockField'-import { CollapsibleSection } from './CollapsibleSection'-import { FieldWithSeeMore } from './FieldWithSeeMore'-import { TimelineStep } from './TimelineStep'+import { BlockFieldConfig, BlockFieldProps, ServiceFlowBlockProps } from '../../types'+import { DetailRow } from './DetailRow'+import { DetailSectionHeader } from './DetailSection'+import { FieldValue } from './FieldValue'export interface BlockSection {title: string+ icon?: LucideIconfields: BlockFieldConfig[]collapsible?: boolean}@@ -22,48 +22,63 @@ export interface FieldWithSeeMoreSection {export interface BlockConfig {title: string+ icon?: LucideIconprimaryFields?: BlockFieldConfig[]sections?: (BlockSection | FieldWithSeeMoreSection)[]}-// Simple check: show empty state only for Postgres blocks in non-postgres logs-const shouldShowEmptyState = (config: BlockConfig, data: any): boolean => {- return config.title === 'Postgres' && data?.log_type !== 'postgres'+const FieldRow = ({+ config,+ data,+ enrichedData,+ isLoading,+ filterFields,+ table,+}: BlockFieldProps) => {+ const value = config.getValue(data, enrichedData)+ const showSkeleton = !!config.requiresEnrichedData && !!isLoading && !value+ return (+ <DetailRow+ label={config.label}+ value={<FieldValue config={config} value={value} wrap={config.wrap} />}+ filterId={config.id}+ filterValue={typeof value === 'string' || typeof value === 'number' ? value : undefined}+ filterFields={filterFields}+ table={table}+ isLoading={showSkeleton}+ wrap={config.wrap}+ />+ )}-// Empty state component-const BlockEmptyState = ({ title }: { title: string }) => (- <div className="flex flex-col items-center justify-center py-8 px-4 text-center">- <div className="flex items-center justify-center w-7 h-7 rounded-full bg-surface-300 mb-3">- <SquareDashedBottomCode size={16} className="text-foreground-light" strokeWidth={1.5} />- </div>- <div className="text-sm text-foreground-light mb-1">- No {title.toLowerCase()} data available- </div>- <div className="text-xs text-foreground-lighter">- This service was involved but no details were captured- </div>- </div>-)-export function createBlock(config: BlockConfig) {const Block = memo(function Block({data,enrichedData,isLoading,- isLast,filterFields,table,}: ServiceFlowBlockProps) {return (- <TimelineStep title={config.title} isLast={isLast}>- {shouldShowEmptyState(config, data) ? (- <BlockEmptyState title={config.title} />- ) : (- <>- {/* Primary Fields */}- {config.primaryFields?.map((field) => (- <BlockField+ <>+ <DetailSectionHeader title={config.title} icon={config.icon} />++ {config.primaryFields?.map((field) => (+ <FieldRow+ key={field.id}+ config={field}+ data={data}+ enrichedData={enrichedData}+ isLoading={isLoading}+ filterFields={filterFields}+ table={table}+ />+ ))}++ {config.sections?.map((section) => {+ if ('type' in section && section.type === 'fieldWithSeeMore') {+ return [section.primaryField, ...section.additionalFields].map((field) => (+ <FieldRowkey={field.id}config={field}data={data}@@ -72,62 +87,31 @@ export function createBlock(config: BlockConfig) {filterFields={filterFields}table={table}/>- ))}+ ))+ }- {/* Sections */}- {config.sections?.map((section, index) => {- if ('type' in section && section.type === 'fieldWithSeeMore') {- return (- <FieldWithSeeMore- key={index}- primaryField={section.primaryField}- additionalFields={section.additionalFields}- data={data}- enrichedData={enrichedData}- isLoading={isLoading}- filterFields={filterFields}- table={table}- showValueAsBadge={section.showValueAsBadge}- />- )- }-- // Now we know it's a BlockSection- const blockSection = section as BlockSection- return blockSection.collapsible ? (- <CollapsibleSection- key={blockSection.title}- title={blockSection.title}- fields={blockSection.fields}+ const blockSection = section as BlockSection+ return (+ <span key={blockSection.title} className="contents">+ <DetailSectionHeader title={blockSection.title} icon={blockSection.icon} />+ {blockSection.fields.map((field) => (+ <FieldRow+ key={field.id}+ config={field}data={data}enrichedData={enrichedData}isLoading={isLoading}filterFields={filterFields}table={table}/>- ) : (- <div key={blockSection.title}>- {blockSection.fields.map((field) => (- <BlockField- key={field.id}- config={field}- data={data}- enrichedData={enrichedData}- isLoading={isLoading}- filterFields={filterFields}- table={table}- />- ))}- </div>- )- })}- </>- )}- </TimelineStep>+ ))}+ </span>+ )+ })}+ </>)})Block.displayName = 'Block'-return Block}diff --git a/apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/components/shared/DetailRow.tsx b/apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/components/shared/DetailRow.tsxnew file mode 100644index 00000000000..0802d7abec7--- /dev/null+++ b/apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/components/shared/DetailRow.tsx@@ -0,0 +1,118 @@+import { Table } from '@tanstack/react-table'+import { ReactNode } from 'react'+import { cn, Skeleton } from 'ui'++import { DataTableFilterField } from '@/components/ui/DataTable/DataTable.types'+import { DataTableSheetRowAction } from '@/components/ui/DataTable/DataTableSheetRowAction'++interface DetailRowProps {+ label: string+ value: ReactNode+ filterId?: string+ filterValue?: string | number+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- matches ServiceFlow types convention+ filterFields?: DataTableFilterField<any>[]+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- matches ServiceFlow types convention+ table?: Table<any>+ isLoading?: boolean+ wrap?: boolean+}++export const DetailRow = ({+ label,+ value,+ filterId,+ filterValue,+ filterFields,+ table,+ isLoading,+ wrap,+}: DetailRowProps) => {+ const isEmpty = value === null || value === undefined || value === ''++ const isFilterable =+ !!filterId &&+ !!filterFields?.some((f) => f.value === filterId) &&+ !!table &&+ !isLoading &&+ !isEmpty++ const resolvedFilterValue =+ filterValue ?? (typeof value === 'string' || typeof value === 'number' ? value : undefined)++ const labelEl = (+ <span+ className={cn(+ 'flex items-center gap-2 text-xs uppercase tracking-wide text-foreground-lighter',+ wrap ? 'shrink-0' : 'min-w-0 truncate'+ )}+ >+ <span+ aria-hidden+ className="select-none font-mono text-foreground-muted translate-y-0.5 ml-5"+ >+ └+ </span>+ <span className={cn('font-mono', !wrap && 'truncate')}>{label}</span>+ </span>+ )++ const valueEl = isLoading ? (+ <Skeleton className="h-4 w-24" />+ ) : isEmpty ? (+ <span className="font-mono text-xs text-foreground-muted">—</span>+ ) : typeof value === 'string' || typeof value === 'number' ? (+ <span+ className={cn(+ 'font-mono text-xs text-foreground',+ wrap ? 'break-all text-right max-w-[calc(100%-12rem)]' : 'truncate text-right',+ isFilterable && 'group-hover:underline'+ )}+ >+ {value}+ </span>+ ) : (+ value+ )++ const rowClass = cn(+ 'flex items-start justify-between gap-3 px-4',+ wrap ? 'min-h-9 py-2' : 'h-9 items-center'+ )++ const isStringValue = typeof value === 'string' || typeof value === 'number'++ if (isFilterable && resolvedFilterValue !== undefined && isStringValue) {+ return (+ <DataTableSheetRowAction+ fieldValue={filterId!}+ filterFields={filterFields!}+ value={resolvedFilterValue}+ table={table!}+ className={cn(rowClass, 'group w-full cursor-pointer hover:bg-surface-200/50')}+ >+ {labelEl}+ {valueEl}+ </DataTableSheetRowAction>+ )+ }++ return (+ <div className={rowClass}>+ {labelEl}+ {isFilterable && resolvedFilterValue !== undefined && !isStringValue ? (+ <DataTableSheetRowAction+ fieldValue={filterId!}+ filterFields={filterFields!}+ value={resolvedFilterValue}+ table={table!}+ className="group"+ >+ <span className="[&_div]:group-hover:text-foreground">{valueEl}</span>+ </DataTableSheetRowAction>+ ) : (+ valueEl+ )}+ </div>+ )+}diff --git a/apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/components/shared/DetailSection.tsx b/apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/components/shared/DetailSection.tsxnew file mode 100644index 00000000000..a91e2d8b012--- /dev/null+++ b/apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/components/shared/DetailSection.tsx@@ -0,0 +1,40 @@+import { LucideIcon } from 'lucide-react'+import { ReactNode } from 'react'+import { cn } from 'ui'++type IconComponent = LucideIcon | React.ComponentType<{ size?: number; className?: string }>++interface DetailSectionHeaderProps {+ title: string+ icon?: IconComponent+ summary?: ReactNode+ className?: string+ topDivider?: boolean+}++export const DetailSectionHeader = ({+ title,+ icon: Icon,+ summary,+ className,+ topDivider,+}: DetailSectionHeaderProps) => (+ <div className={cn('relative flex h-9 items-center justify-between gap-3 px-4', className)}>+ {topDivider && (+ <span className="absolute inset-x-4 top-0 border-t border-dashed border-border-strong" />+ )}+ <div className="flex min-w-0 items-center gap-2">+ {Icon ? (+ <Icon size={14} className="shrink-0 text-foreground-lighter" />+ ) : (+ <span className="w-3.5 shrink-0" aria-hidden />+ )}+ <span className="truncate text-xs uppercase tracking-wider text-foreground-light font-mono">+ {title}+ </span>+ </div>+ {summary !== undefined && summary !== null && summary !== '' ? (+ <span className="truncate text-right font-mono text-xs text-foreground">{summary}</span>+ ) : null}+ </div>+)diff --git a/apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/components/shared/FieldValue.tsx b/apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/components/shared/FieldValue.tsxnew file mode 100644index 00000000000..d2d695a5e0b--- /dev/null+++ b/apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/components/shared/FieldValue.tsx@@ -0,0 +1,42 @@+import { ReactNode } from 'react'+import { cn } from 'ui'++import { getStatusLevel } from '../../../UnifiedLogs.utils'+import { BlockFieldConfig } from '../../types'+import { DataTableColumnStatusCode } from '@/components/ui/DataTable/DataTableColumn/DataTableColumnStatusCode'++interface FieldValueProps {+ config: BlockFieldConfig+ value: unknown+ wrap?: boolean+}++export const FieldValue = ({ config, value, wrap }: FieldValueProps): ReactNode => {+ if (value === null || value === undefined || value === '') return null++ if (config.id === 'status') {+ return (+ <DataTableColumnStatusCode+ value={value as string | number}+ level={getStatusLevel(value as string | number)}+ className="text-xs"+ />+ )+ }++ if (typeof value === 'string' || typeof value === 'number') {+ return (+ <span+ className={cn(+ 'font-mono text-xs text-foreground',+ wrap ? 'break-all text-right max-w-[calc(100%-12rem)]' : 'truncate text-right',+ 'group-hover:underline'+ )}+ >+ {value}+ </span>+ )+ }++ return value as ReactNode+}diff --git a/apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/config/blockConfigs.ts b/apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/config/blockConfigs.tsindex 444316116a8..ffdc3ff347c 100644--- a/apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/config/blockConfigs.ts+++ b/apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/config/blockConfigs.ts@@ -1,3 +1,17 @@+import {+ Cable,+ Code,+ Globe,+ HardDrive,+ Lock,+ MonitorDot,+ PackageOpen,+ ReceiptText,+ Server,+ ShieldCheck,+ Zap,+} from 'lucide-react'+import { BlockConfig } from '../components/shared/Block'import {apiKeyAdditionalFields,@@ -22,23 +36,26 @@ import {export const authBlockConfig: BlockConfig = {title: 'Authentication',+ icon: Lock,primaryFields: authPrimaryFields,}export const postgrestBlockConfig: BlockConfig = {title: 'Data API',+ icon: Server,primaryFields: postgrestPrimaryFields,sections: [{title: 'Response Details',+ icon: ReceiptText,fields: postgrestResponseFields,- collapsible: true,},],}export const networkBlockConfig: BlockConfig = {title: 'Network',+ icon: Globe,primaryFields: networkPrimaryFields,sections: [{@@ -59,37 +76,39 @@ export const networkBlockConfig: BlockConfig = {},{title: 'Authorization',+ icon: ShieldCheck,fields: authorizationFields,- collapsible: true,},{title: 'Tech Details',+ icon: MonitorDot,fields: techDetailsFields,- collapsible: true,},],}export const edgeFunctionBlockConfig: BlockConfig = {title: 'Edge Function',+ icon: Zap,primaryFields: edgeFunctionPrimaryFields,sections: [{title: 'Function Details',+ icon: Code,fields: edgeFunctionDetailsFields,- collapsible: true,},],}export const storageBlockConfig: BlockConfig = {title: 'Storage',+ icon: HardDrive,primaryFields: storagePrimaryFields,sections: [{title: 'Storage Details',+ icon: PackageOpen,fields: storageDetailsFields,- collapsible: true,},],}@@ -100,8 +119,8 @@ export const postgresBlockConfig: BlockConfig = {sections: [{title: 'Connection & Session Details',+ icon: Cable,fields: postgresDetailsFields,- collapsible: true,},],}diff --git a/apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/config/serviceFlowFields.ts b/apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/config/serviceFlowFields.tsindex 50101e8f338..9aac986d2c6 100644--- a/apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/config/serviceFlowFields.ts+++ b/apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/config/serviceFlowFields.ts@@ -655,6 +655,12 @@ export const storageDetailsFields: BlockFieldConfig[] = [// Primary Postgres Fields (Always Visible)export const postgresPrimaryFields: BlockFieldConfig[] = [+ {+ id: 'event_message',+ label: 'Message',+ getValue: (data, enrichedData) => enrichedData?.event_message || data?.event_message,+ wrap: true,+ },{id: 'status',label: 'Status',@@ -697,10 +703,7 @@ export const postgresDetailsFields: BlockFieldConfig[] = [{id: 'session_id',label: 'Session ID',- getValue: (data, enrichedData) => {- const sessionId = enrichedData?.session_id || data?.session_id- return sessionId ? `${sessionId.substring(0, 12)}...` : null- },+ getValue: (data, enrichedData) => enrichedData?.session_id || data?.session_id,requiresEnrichedData: true,},{diff --git a/apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/types.ts b/apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/types.tsindex e71f31a8d8e..6da454a0c8e 100644--- a/apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/types.ts+++ b/apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/types.ts@@ -28,6 +28,7 @@ export interface BlockFieldConfig {getValue: (data: any, enrichedData?: any) => string | number | null | undefined // Function to extract valuerequiresEnrichedData?: boolean // Whether field needs enriched data to displaymaxLength?: number // Maximum length for truncation+ wrap?: boolean // Allow value to wrap instead of truncate}/**diff --git a/apps/studio/components/interfaces/UnifiedLogs/ServiceFlowPanel.tsx b/apps/studio/components/interfaces/UnifiedLogs/ServiceFlowPanel.tsxindex 52a2bea3882..d86e1649be2 100644--- a/apps/studio/components/interfaces/UnifiedLogs/ServiceFlowPanel.tsx+++ b/apps/studio/components/interfaces/UnifiedLogs/ServiceFlowPanel.tsx@@ -1,7 +1,9 @@import { useParams } from 'common'-import { useState } from 'react'+import { Check, Clock, Copy } from 'lucide-react'+import { useEffect, useRef, useState } from 'react'import {- cn,+ Button,+ copyToClipboard,ResizableHandle,ResizablePanel,Skeleton,@@ -12,8 +14,7 @@ import {} from 'ui'import { CodeBlock } from 'ui-patterns/CodeBlock'-import { MemoizedRequestStartedBlock } from './ServiceFlow/components/blocks/RequestStartedBlock'-import { MemoizedResponseCompletedBlock } from './ServiceFlow/components/blocks/ResponseCompletedBlock'+import { PostgresFlowDetail } from './ServiceFlow/components/blocks/PostgresFlowDetail'import {MemoizedEdgeFunctionBlock,MemoizedGoTrueBlock,@@ -22,7 +23,8 @@ import {MemoizedPostgRESTBlock,MemoizedStorageBlock,} from './ServiceFlow/components/ServiceBlocks'-import { ServiceFlowHeader } from './ServiceFlow/components/ServiceFlowHeader'+import { ServiceFlowPanelControls } from './ServiceFlow/components/ServiceFlowPanelControls'+import { DetailSectionHeader } from './ServiceFlow/components/shared/DetailSection'import { ColumnSchema } from './UnifiedLogs.schema'import { QuerySearchParamsType } from './UnifiedLogs.types'import { useDataTable } from '@/components/ui/DataTable/providers/DataTableProvider'@@ -33,7 +35,7 @@ import {import { useIsFeatureEnabled } from '@/hooks/misc/useIsFeatureEnabled'interface ServiceFlowPanelProps {- selectedRow: ColumnSchema+ selectedRow?: ColumnSchemaselectedRowKey: stringsearchParameters: QuerySearchParamsType}@@ -45,15 +47,29 @@ export function ServiceFlowPanel({}: ServiceFlowPanelProps) {const { table, filterFields } = useDataTable()const { ref: projectRef } = useParams()- const [activeTab, setActiveTab] = useState('service-flow')+ const [activeTab, setActiveTab] = useState('overview')+ const [jsonCopied, setJsonCopied] = useState(false)+ const overviewScrollRef = useRef<HTMLDivElement>(null)+ const jsonScrollRef = useRef<HTMLDivElement>(null)- const { logsMetadata } = useIsFeatureEnabled(['logs:metadata'])+ useEffect(() => {+ overviewScrollRef.current?.scrollTo({ top: 0 })+ jsonScrollRef.current?.scrollTo({ top: 0 })+ }, [selectedRowKey])const logType = selectedRow?.log_typeconst serviceFlowType: ServiceFlowType | undefined =logType === 'edge function' ? 'edge-function' : (logType as ServiceFlowType)const shouldShowServiceFlow = !!serviceFlowType+ useEffect(() => {+ if (!shouldShowServiceFlow && activeTab === 'overview') {+ setActiveTab('raw-json')+ }+ }, [shouldShowServiceFlow, activeTab])++ const { logsMetadata } = useIsFeatureEnabled(['logs:metadata'])+// Query the logs API directlyconst {data: serviceFlowData,@@ -71,6 +87,15 @@ export function ServiceFlowPanel({})+ if (!selectedRowKey || !selectedRow) return null++ const timestampMs = selectedRow.timestamp+ ? selectedRow.timestamp / 1000+ : selectedRow.date+ ? selectedRow.date.getTime()+ : null+ const formattedTime = timestampMs ? new Date(timestampMs).toLocaleString() : null+// Prepare JSON data for Raw JSON tabconst jsonData =shouldShowServiceFlow && serviceFlowData?.result?.[0] ? serviceFlowData.result[0] : selectedRow@@ -83,156 +108,157 @@ export function ServiceFlowPanel({}: jsonData- if (selectedRowKey) {- return (- <>- <ResizableHandle withHandle className="z-10" />- <ResizablePanel- id="log-sidepanel"- defaultSize={45}- minSize={400}- maxSize={400}- className={cn('bg-dash-sidebar border-t')}- >- <div className="h-full overflow-auto">- {/* Service Flow Header with navigation */}- <ServiceFlowHeader- selectedRow={selectedRow}- enrichedData={serviceFlowData?.result?.[0]}- />-- <div className="relative">- <Tabs- defaultValue="service-flow"- value={activeTab}- onValueChange={setActiveTab}- className="w-full h-full flex flex-col pt-2"- >- <TabsList className="flex gap-3 px-5">- {shouldShowServiceFlow && (- <TabsTrigger value="service-flow">Overview</TabsTrigger>- )}- <TabsTrigger value="raw-json">Raw JSON</TabsTrigger>- </TabsList>-+ return (+ <>+ <ResizableHandle withHandle />+ <ResizablePanel+ id="log-sidepanel"+ defaultSize={400}+ minSize={300}+ className="bg-dash-sidebar"+ >+ <div className="flex h-full flex-col overflow-hidden">+ <Tabs+ defaultValue={shouldShowServiceFlow ? 'overview' : 'raw-json'}+ value={activeTab}+ onValueChange={setActiveTab}+ className="flex h-full w-full flex-col"+ >+ <div className="flex items-center justify-between px-4 border-b border-border">+ <TabsList className="flex h-auto gap-x-4 rounded-none border-none!">{shouldShowServiceFlow && (- <TabsContent value="service-flow">- <div className="p-4">- {error ? (- <div className="text-center py-8 text-destructive">- Error: {error.toString()}- </div>- ) : (- <>- {serviceFlowType === 'postgres' ? (- // Postgres flows: Connection Started -> Postgres -> Response- <>- <MemoizedRequestStartedBlock data={selectedRow} />-- <MemoizedPostgresBlock- data={selectedRow}- enrichedData={serviceFlowData?.result?.[0]}- isLoading={isLoading}- isLast={false}- filterFields={filterFields}- table={table}- />-- <MemoizedResponseCompletedBlock- data={selectedRow}- enrichedData={serviceFlowData?.result?.[0]}- />- </>- ) : (- // HTTP-based flows: Request Started -> Network -> Service -> Response- <>- <MemoizedRequestStartedBlock data={selectedRow} />-- <MemoizedNetworkBlock- data={selectedRow}- enrichedData={serviceFlowData?.result?.[0]}- isLoading={isLoading}- filterFields={filterFields}- table={table}- />-- {serviceFlowType === 'auth' ? (- <MemoizedGoTrueBlock- data={selectedRow}- enrichedData={serviceFlowData?.result?.[0]}- isLoading={isLoading}- filterFields={filterFields}- table={table}- />- ) : serviceFlowType === 'edge-function' ? (- <MemoizedEdgeFunctionBlock- data={selectedRow}- enrichedData={serviceFlowData?.result?.[0]}- isLoading={isLoading}- filterFields={filterFields}- table={table}- />- ) : serviceFlowType === 'storage' ? (- <MemoizedStorageBlock- data={selectedRow}- enrichedData={serviceFlowData?.result?.[0]}- isLoading={isLoading}- filterFields={filterFields}- table={table}- />- ) : (- <>- <MemoizedPostgRESTBlock- data={selectedRow}- enrichedData={serviceFlowData?.result?.[0]}- isLoading={isLoading}- filterFields={filterFields}- table={table}- />-- <MemoizedPostgresBlock- data={selectedRow}- enrichedData={serviceFlowData?.result?.[0]}- isLoading={isLoading}- filterFields={filterFields}- table={table}- />- </>- )}-- <MemoizedResponseCompletedBlock- data={selectedRow}- enrichedData={serviceFlowData?.result?.[0]}- />- </>- )}- </>- )}- </div>- </TabsContent>- )}-- <TabsContent value="raw-json" className="grow overflow-auto">- {isLoading && shouldShowServiceFlow && (- <div className="flex items-center gap-3 text-foreground-light p-3 bg-surface-100 border-b border-border">- <Skeleton className="h-4 w-4 rounded-full animate-pulse" />- <span className="text-sm">Enriching log...</span>- </div>- )}- <CodeBlock- language="json"- className="max-h-[800px] overflow-auto border-none rounded-none [&_pre]:leading-tight! [&_code]:leading-tight!"+ <TabsTrigger+ value="overview"+ className="border-b py-3 font-mono text-xs uppercase">- {JSON.stringify(formattedJsonData, null, 2)}- </CodeBlock>- </TabsContent>- </Tabs>+ Overview+ </TabsTrigger>+ )}+ <TabsTrigger value="raw-json" className="border-b py-3 font-mono text-xs uppercase">+ Raw JSON+ </TabsTrigger>+ </TabsList>+ <ServiceFlowPanelControls /></div>- </div>- </ResizablePanel>- </>- )- }- return null+ {shouldShowServiceFlow && (+ <TabsContent+ ref={overviewScrollRef}+ value="overview"+ className="mt-0 grow overflow-auto py-2"+ >+ {error ? (+ <div className="py-8 text-center text-destructive">Error: {error.toString()}</div>+ ) : serviceFlowType === 'postgres' ? (+ <PostgresFlowDetail+ data={selectedRow}+ enrichedData={serviceFlowData?.result?.[0]}+ isLoading={isLoading}+ filterFields={filterFields}+ table={table}+ />+ ) : (+ <div className="[&>*:nth-child(even)]:bg-surface-100/50">+ <DetailSectionHeader+ title="Request started"+ icon={Clock}+ summary={formattedTime ?? undefined}+ />++ <MemoizedNetworkBlock+ data={selectedRow}+ enrichedData={serviceFlowData?.result?.[0]}+ isLoading={isLoading}+ filterFields={filterFields}+ table={table}+ />++ {serviceFlowType === 'auth' ? (+ <MemoizedGoTrueBlock+ data={selectedRow}+ enrichedData={serviceFlowData?.result?.[0]}+ isLoading={isLoading}+ filterFields={filterFields}+ table={table}+ />+ ) : serviceFlowType === 'edge-function' ? (+ <MemoizedEdgeFunctionBlock+ data={selectedRow}+ enrichedData={serviceFlowData?.result?.[0]}+ isLoading={isLoading}+ filterFields={filterFields}+ table={table}+ />+ ) : serviceFlowType === 'storage' ? (+ <MemoizedStorageBlock+ data={selectedRow}+ enrichedData={serviceFlowData?.result?.[0]}+ isLoading={isLoading}+ filterFields={filterFields}+ table={table}+ />+ ) : (+ <>+ <MemoizedPostgRESTBlock+ data={selectedRow}+ enrichedData={serviceFlowData?.result?.[0]}+ isLoading={isLoading}+ filterFields={filterFields}+ table={table}+ />++ <MemoizedPostgresBlock+ data={selectedRow}+ enrichedData={serviceFlowData?.result?.[0]}+ isLoading={isLoading}+ filterFields={filterFields}+ table={table}+ />+ </>+ )}+ </div>+ )}+ </TabsContent>+ )}++ <TabsContent+ ref={jsonScrollRef}+ value="raw-json"+ className="mt-0 grow overflow-auto bg-surface-100/50"+ >+ {isLoading && shouldShowServiceFlow && (+ <div className="flex items-center gap-3 border-b border-border bg-surface-100 p-3 text-foreground-light">+ <Skeleton className="h-4 w-4 animate-pulse rounded-full" />+ <span className="text-sm">Enriching log...</span>+ </div>+ )}+ <div className="sticky top-2 z-10 flex justify-end px-2 -mb-9 pointer-events-none">+ <Button+ size="tiny"+ type="default"+ className="pointer-events-auto px-1.5"+ icon={jsonCopied ? <Check size={12} /> : <Copy size={12} />}+ onClick={() => {+ copyToClipboard(JSON.stringify(formattedJsonData, null, 2))+ setJsonCopied(true)+ setTimeout(() => setJsonCopied(false), 1000)+ }}+ >+ {jsonCopied ? 'Copied' : ''}+ </Button>+ </div>+ <CodeBlock+ language="json"+ hideCopy+ wrapperClassName="!overflow-visible bg-surface-100/50 [&_pre]:!bg-surface-100/50"+ className="rounded-none border-none [&_code]:!leading-tight [&_pre]:!leading-tight"+ >+ {JSON.stringify(formattedJsonData, null, 2)}+ </CodeBlock>+ </TabsContent>+ </Tabs>+ </div>+ </ResizablePanel>+ </>+ )}diff --git a/apps/studio/components/interfaces/UnifiedLogs/UnifiedLogs.queries.ts b/apps/studio/components/interfaces/UnifiedLogs/UnifiedLogs.queries.tsindex e38a98bb060..0de20cdbe37 100644--- a/apps/studio/components/interfaces/UnifiedLogs/UnifiedLogs.queries.ts+++ b/apps/studio/components/interfaces/UnifiedLogs/UnifiedLogs.queries.ts@@ -23,7 +23,7 @@ const buildQueryConditions = (search: QuerySearchParamsType) => {// Process all search parameters for filteringObject.entries(search).forEach(([key, value]) => {// Skip pagination/control parameters- if (EXCLUDED_QUERY_PARAMS.includes(key as any)) {+ if ((EXCLUDED_QUERY_PARAMS as readonly string[]).includes(key)) {return}@@ -54,12 +54,12 @@ const buildQueryConditions = (search: QuerySearchParamsType) => {* and determines the appropriate bucketing level (minute, hour, day)* Ported from the older implementation (apps/studio/components/interfaces/Settings/Logs/Logs.utils.ts)*/-const calculateChartBucketing = (search: SearchParamsType | Record<string, any>): string => {+const calculateChartBucketing = (search: SearchParamsType | Record<string, unknown>): string => {// Extract start and end times from the date array if available- const dateRange = search.date || []+ const dateRange = (search.date as Array<Date | string | number | null | undefined>) || []// Handle timestamps that could be in various formats- const convertToMillis = (timestamp: any) => {+ const convertToMillis = (timestamp: Date | string | number | null | undefined) => {if (!timestamp) return null// If timestamp is a Date objectif (timestamp instanceof Date) return timestamp.getTime()@@ -375,7 +375,7 @@ const buildFacetWhere = (search: QuerySearchParamsType, excludeField: string): sObject.entries(search).forEach(([key, value]) => {if (key === excludeField) return // Skip the field we're getting facets for- if (EXCLUDED_QUERY_PARAMS.includes(key as any)) return // Skip pagination and special params+ if ((EXCLUDED_QUERY_PARAMS as readonly string[]).includes(key)) return // Skip pagination and special params// Handle array filters (IN clause)if (Array.isArray(value) && value.length > 0) {diff --git a/apps/studio/components/interfaces/UnifiedLogs/UnifiedLogs.tsx b/apps/studio/components/interfaces/UnifiedLogs/UnifiedLogs.tsxindex 4bcacd95016..0ad47b03baa 100644--- a/apps/studio/components/interfaces/UnifiedLogs/UnifiedLogs.tsx+++ b/apps/studio/components/interfaces/UnifiedLogs/UnifiedLogs.tsx@@ -13,7 +13,7 @@ import {useReactTable,VisibilityState,} from '@tanstack/react-table'-import { LOCAL_STORAGE_KEYS, useDebounce, useParams } from 'common'+import { useDebounce, useParams } from 'common'import { PanelLeftClose, PanelLeftOpen } from 'lucide-react'import { useQueryStates } from 'nuqs'import { useEffect, useMemo, useRef, useState } from 'react'@@ -39,8 +39,11 @@ import { ServiceFlowPanel } from './ServiceFlowPanel'import { SEARCH_PARAMS_PARSER } from './UnifiedLogs.constants'import { filterFields as defaultFilterFields } from './UnifiedLogs.fields'import { useLiveMode, useResetFocus } from './UnifiedLogs.hooks'+import { ColumnSchema } from './UnifiedLogs.schema'import { QuerySearchParamsType } from './UnifiedLogs.types'import { getFacetedUniqueValues, getLevelRowClassName } from './UnifiedLogs.utils'+import { LEVELS } from '@/components/ui/DataTable/DataTable.constants'+import { Option } from '@/components/ui/DataTable/DataTable.types'import { arrSome, inDateRange } from '@/components/ui/DataTable/DataTable.utils'import { DataTableFilterCommand } from '@/components/ui/DataTable/DataTableFilters/DataTableFilterCommand'import { DataTableFilterControlsDrawer } from '@/components/ui/DataTable/DataTableFilters/DataTableFilterControlsDrawer'@@ -52,7 +55,6 @@ import { LiveButton } from '@/components/ui/DataTable/LiveButton'import { Kbd } from '@/components/ui/DataTable/primitives/Kbd'import { DataTableProvider } from '@/components/ui/DataTable/providers/DataTableProvider'import { TimelineChart } from '@/components/ui/DataTable/TimelineChart'-import { FeaturePreviewBadge } from '@/components/ui/FeaturePreviewBadge'import { useUnifiedLogsChartQuery } from '@/data/logs/unified-logs-chart-query'import { useUnifiedLogsCountQuery } from '@/data/logs/unified-logs-count-query'import { useUnifiedLogsInfiniteQuery } from '@/data/logs/unified-logs-infinite-query'@@ -129,7 +131,7 @@ export const UnifiedLogs = () => {}return acc},- {} as Record<string, any>+ {} as Record<string, unknown>) as QuerySearchParamsType,[search])@@ -193,18 +195,22 @@ export const UnifiedLogs = () => {// Create a filtered version of the chart config based on selected levelsconst filteredChartConfig = useMemo(() => {- const levelFilter = search.level || ['success', 'warning', 'error']+ const levelFilter = search.level || LEVELSreturn Object.fromEntries(- Object.entries(CHART_CONFIG).filter(([key]) => levelFilter.includes(key as any))+ Object.entries(CHART_CONFIG).filter(([key]) =>+ levelFilter.includes(key as (typeof LEVELS)[number])+ )) as ChartConfig}, [search.level])- const getRowClassName = <TData extends { date: Date; level: string; timestamp: number }>(+ const getRowClassName = <+ TData extends { date: Date; level: (typeof LEVELS)[number]; timestamp: number },+ >(row: Row<TData>) => {const rowTimestamp = row.original.timestampconst isPast = rowTimestamp <= (liveMode.timestamp || -1)- const levelClassName = getLevelRowClassName(row.original.level as any)+ const levelClassName = getLevelRowClassName(row.original.level)return cn(levelClassName, isPast ? 'opacity-50' : 'opacity-100', 'h-[30px]')}@@ -213,7 +219,7 @@ export const UnifiedLogs = () => {return generateDynamicColumns(flatData)}, [flatData])- const table: Table<any> = useReactTable({+ const table: Table<ColumnSchema> = useReactTable({data: flatData,columns: dynamicColumns,state: {@@ -262,22 +268,15 @@ export const UnifiedLogs = () => {if (!facetsField) return field// For hardcoded enum fields, keep the predefined options (facets only used for counts)- const isHardcodedField = ['log_type', 'method', 'level'].includes(field.value as string)- if (isHardcodedField) {- return field // Keep original predefined options+ if (field.value === 'log_type' || field.value === 'method' || field.value === 'level') {+ return field}// For dynamic fields, use faceted options- const options = facetsField.rows.map(({ value }) => ({ label: `${value}`, value }))-- if (field.type === ('slider' as any)) {- return {- ...(field as any),- min: facetsField.min ?? (field as any).min,- max: facetsField.max ?? (field as any).max,- options,- }- }+ const options: Option[] = facetsField.rows.map(({ value }) => ({+ label: `${value}`,+ value,+ }))return { ...field, options }})@@ -410,7 +409,6 @@ export const UnifiedLogs = () => {<DataTableFilterControlsDrawer /></div><div className="ml-auto flex items-center gap-x-4">- <FeaturePreviewBadge featureKey={LOCAL_STORAGE_KEYS.UI_PREVIEW_UNIFIED_LOGS} /><RefreshButton isLoading={isRefetchingData} onRefresh={refetchAllData} /><DataTableViewOptions /><DownloadLogsButton searchParameters={searchParameters} />@@ -435,7 +433,7 @@ export const UnifiedLogs = () => {<ResizablePanelGroup key="main-logs" orientation="vertical" className="flex-1"><ResizablePaneldefaultSize="100"- minSize="30"+ minSize="10"className={cn('bg',isFetchingButNotPaginating && 'opacity-60 transition-opacity duration-150'diff --git a/apps/studio/components/interfaces/UnifiedLogs/UnifiedLogs.utils.ts b/apps/studio/components/interfaces/UnifiedLogs/UnifiedLogs.utils.tsindex cb506fac8a4..7df87e2356a 100644--- a/apps/studio/components/interfaces/UnifiedLogs/UnifiedLogs.utils.ts+++ b/apps/studio/components/interfaces/UnifiedLogs/UnifiedLogs.utils.ts@@ -5,7 +5,7 @@ import { FacetMetadataSchema } from './UnifiedLogs.schema'import { LEVELS } from '@/components/ui/DataTable/DataTable.constants'export const logEventBus = {- listeners: new Map<string, Set<(...args: any[]) => void>>(),+ listeners: new Map<string, Set<(rowId: string) => void>>(),on(event: 'selectTraceTab', callback: (rowId: string) => void) {if (!this.listeners.has(event)) {diff --git a/apps/studio/components/interfaces/UnifiedLogs/components/DownloadLogsButton.tsx b/apps/studio/components/interfaces/UnifiedLogs/components/DownloadLogsButton.tsxindex d01e78b6e04..bc2b0bca1f8 100644--- a/apps/studio/components/interfaces/UnifiedLogs/components/DownloadLogsButton.tsx+++ b/apps/studio/components/interfaces/UnifiedLogs/components/DownloadLogsButton.tsx@@ -54,10 +54,11 @@ export const DownloadLogsButton = ({ searchParameters }: DownloadLogsButtonProps} else {if (res.length === 0) returnconst headers = Object.keys(res[0])- const formattedResults = res.map((row: any) => {- const r = { ...row }+ const formattedResults = res.map((row) => {+ const r: Record<string, unknown> = { ...row }Object.keys(row).forEach((x) => {- if (typeof row[x] === 'object') r[x] = JSON.stringify(row[x])+ const k = x as keyof typeof row+ if (typeof row[k] === 'object') r[x] = JSON.stringify(row[k])})return r})diff --git a/apps/studio/components/interfaces/UnifiedLogs/components/LogsListPanel.tsx b/apps/studio/components/interfaces/UnifiedLogs/components/LogsListPanel.tsxindex 1bdb77d7905..21bfe693dd9 100644--- a/apps/studio/components/interfaces/UnifiedLogs/components/LogsListPanel.tsx+++ b/apps/studio/components/interfaces/UnifiedLogs/components/LogsListPanel.tsx@@ -3,9 +3,10 @@ import { ChevronDown } from 'lucide-react'import { useState } from 'react'import { Button, cn, ResizableHandle, ResizablePanel } from 'ui'+import { ColumnSchema } from '../UnifiedLogs.schema'import { LogsList } from './LogsList'-export const LogsListPanel = ({ selectedRow }: { selectedRow?: Row<any> }) => {+export const LogsListPanel = ({ selectedRow }: { selectedRow?: Row<ColumnSchema> }) => {const [open, setOpenState] = useState(true)return (diff --git a/apps/studio/components/ui/DataTable/DataTableInfinite.tsx b/apps/studio/components/ui/DataTable/DataTableInfinite.tsxindex fc71b076984..51d59ed5123 100644--- a/apps/studio/components/ui/DataTable/DataTableInfinite.tsx+++ b/apps/studio/components/ui/DataTable/DataTableInfinite.tsx@@ -153,7 +153,7 @@ export function DataTableInfinite<TData, TValue, TMeta>({disabled={isFetching}onClick={() => fetchNextPage()}size="small"- type="outline"+ type="default"icon={isFetching ? <LoaderCircle className="mr-2 h-4 w-4 animate-spin" /> : null}diff --git a/apps/studio/components/ui/DataTable/DataTableSheetRowAction.tsx b/apps/studio/components/ui/DataTable/DataTableSheetRowAction.tsxindex 69c9d0283a2..43415aec2ec 100644--- a/apps/studio/components/ui/DataTable/DataTableSheetRowAction.tsx+++ b/apps/studio/components/ui/DataTable/DataTableSheetRowAction.tsx@@ -169,7 +169,9 @@ export function DataTableSheetRowAction<TData, TFields extends DataTableFilterFi>{children}{isCopied ? (- <div className="absolute inset-0 bg-background/70 place-content-center">Value copied</div>+ <div className="absolute inset-0 flex items-center justify-center rounded-md bg-surface-100/80 backdrop-blur-sm animate-in fade-in duration-150">+ <span className="font-mono text-xs text-foreground-light">Copied</span>+ </div>) : null}</DropdownMenuTrigger><DropdownMenuContent align="end" side="bottom" className="w-40">diff --git a/apps/studio/components/ui/DataTable/FilterSideBar.tsx b/apps/studio/components/ui/DataTable/FilterSideBar.tsxindex a4dadc8001c..6b07599d94f 100644--- a/apps/studio/components/ui/DataTable/FilterSideBar.tsx+++ b/apps/studio/components/ui/DataTable/FilterSideBar.tsx@@ -1,9 +1,10 @@-import { useParams } from 'common'+import { LOCAL_STORAGE_KEYS, useParams } from 'common'import Link from 'next/link'import { useRouter } from 'next/router'import React, { useEffect } from 'react'import { Button, cn, ResizablePanel, usePanelRef } from 'ui'+import { FeaturePreviewBadge } from '../FeaturePreviewBadge'import { FeaturePreviewSidebarPanel } from '../FeaturePreviewSidebarPanel'import { DateRangeDisabled } from './DataTable.types'import { DataTableFilterControls } from './DataTableFilters/DataTableFilterControls'@@ -27,7 +28,11 @@ export function FilterSideBar({const { ref } = useParams()const { table } = useDataTable()- const { disable: disableUnifiedLogs, isEligible: isUnifiedLogsEligible } = useUnifiedLogsPreview()+ const {+ disable: disableUnifiedLogs,+ isEligible: isUnifiedLogsEligible,+ isEnabled: isUnifiedLogsEnabled,+ } = useUnifiedLogsPreview()const handleGoBackToOldLogs = () => {disableUnifiedLogs()@@ -73,6 +78,11 @@ export function FilterSideBar({className="mx-2 mt-2 mb-3"title="Go back to old logs"description="Use the traditional interface"+ illustration={+ isUnifiedLogsEnabled ? (+ <FeaturePreviewBadge featureKey={LOCAL_STORAGE_KEYS.UI_PREVIEW_UNIFIED_LOGS} />+ ) : undefined+ }actions={<Button type="default" size="tiny" onClick={handleGoBackToOldLogs}>Switch backdiff --git a/apps/studio/components/ui/DataTable/Table.tsx b/apps/studio/components/ui/DataTable/Table.tsxindex 1d407c9fd05..2d03bf9793a 100644--- a/apps/studio/components/ui/DataTable/Table.tsx+++ b/apps/studio/components/ui/DataTable/Table.tsx@@ -43,7 +43,8 @@ export const TableBody = forwardRef<ref={ref}{...props}className={cn(- 'outline-1 -outline-offset-1 outline-primary transition-colors focus-visible:outline'+ 'transition-colors focus-visible:outline focus-visible:outline-1 focus-visible:-outline-offset-1 focus-visible:outline-primary',+ className)}/>))