mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 15:39:13 +00:00
## Problem Selecting a related event in the Logs Timeline updated the panel header, but users still had to switch to Overview to inspect the event. ## Fix Open the selected event’s Overview and move focus to its tab. Returning to Timeline shows the original request with the inspected event highlighted. Addresses the Timeline interaction reported in [FE-5160](https://linear.app/supabase/issue/FE-5160). The issue also tracks missing Auth events in unfiltered results. ## How to test 1. Open a log with a related event and select Timeline. 2. Click a related event. Check that Overview opens with that event’s details. 3. Return to Timeline and use Enter on a different event. Check its Overview and keyboard focus. ## Verification Verified on the Studio staging preview for commit `96ba43278c`: clicking a related runtime event opened its Overview. Returning to Timeline highlighted that event. Pressing Enter on another event opened its details with focus on the Overview tab. All 37 focused Timeline and user-detail tests passed locally. The updated regression test failed against the previous behavior. Studio typecheck, changed-file ESLint, and Prettier passed.
198 lines
7.5 KiB
TypeScript
198 lines
7.5 KiB
TypeScript
import { useRef, useState } from 'react'
|
|
import {
|
|
ResizableHandle,
|
|
ResizablePanel,
|
|
Tabs,
|
|
TabsContent,
|
|
TabsIndicator,
|
|
TabsList,
|
|
TabsTrigger,
|
|
} from 'ui'
|
|
|
|
import { LogDetail } from './components/LogDetail'
|
|
import { LogStepSummary } from './components/LogTimeline'
|
|
import { LogUser } from './components/LogUser'
|
|
import { LogTimestampHeader, RequestTimeline } from './components/RequestTimeline'
|
|
import { useLogEnrichment } from './components/useLogEnrichment'
|
|
import { LogSelectionActions } from './LogSelectionActions'
|
|
import {
|
|
LogPanelCloseButton,
|
|
LogPanelNavigation,
|
|
} from './ServiceFlow/components/ServiceFlowPanelControls'
|
|
import { getLogDataForMetadataVisibility } from './ServiceFlowPanel.utils'
|
|
import { ColumnSchema } from './UnifiedLogs.schema'
|
|
import { QuerySearchParamsType } from './UnifiedLogs.types'
|
|
import { getEventMessageDisplay, getRawLogData } from './UnifiedLogs.utils'
|
|
import { JsonCodeBlock } from '@/components/ui/JsonCodeBlock'
|
|
import { ShortcutBadge } from '@/components/ui/ShortcutBadge'
|
|
import { useUnifiedLogsBackend } from '@/data/logs/unified-logs-infinite-query'
|
|
import { useIsFeatureEnabled } from '@/hooks/misc/useIsFeatureEnabled'
|
|
import { SHORTCUT_IDS } from '@/state/shortcuts/registry'
|
|
|
|
const TAB_TRIGGER_CLASS_NAME = 'py-2.5 data-[state=active]:shadow-none'
|
|
|
|
interface ServiceFlowPanelProps {
|
|
dock: 'bottom' | 'right'
|
|
setDock: (value: 'bottom' | 'right') => void
|
|
selectedRows: ColumnSchema[]
|
|
searchParameters: QuerySearchParamsType
|
|
}
|
|
|
|
export function ServiceFlowPanel({
|
|
dock,
|
|
setDock,
|
|
selectedRows,
|
|
searchParameters,
|
|
}: ServiceFlowPanelProps) {
|
|
const [activeTab, setActiveTab] = useState('overview')
|
|
const overviewTabRef = useRef<HTMLButtonElement>(null)
|
|
|
|
const [openedLog, setOpenedLog] = useState<{ fromId: string; log: ColumnSchema } | null>(null)
|
|
const isRequestTimelineEnabled = useUnifiedLogsBackend(searchParameters)
|
|
const hasMultiple = selectedRows.length > 1
|
|
const selectedRow = selectedRows[0]
|
|
const activeLog =
|
|
(openedLog && openedLog.fromId === selectedRow?.id ? openedLog.log : undefined) ?? selectedRow
|
|
const isProcessLog = selectedRow?.log_type === 'compute' || selectedRow?.log_type === 'pipelines'
|
|
const showTimeline = isRequestTimelineEnabled && !isProcessLog
|
|
const showUser = !isProcessLog
|
|
const tabs = [
|
|
'overview',
|
|
'raw-json',
|
|
...(showTimeline ? ['timeline'] : []),
|
|
...(showUser ? ['user'] : []),
|
|
]
|
|
const currentTab = tabs.includes(activeTab) ? activeTab : 'overview'
|
|
const title = hasMultiple
|
|
? `${selectedRows.length} logs selected`
|
|
: getEventMessageDisplay(activeLog?.log_type ?? '', activeLog?.event_message).message ||
|
|
activeLog?.id
|
|
|
|
const handleSelectTimelineLog = (log: ColumnSchema) => {
|
|
if (!selectedRow) return
|
|
setOpenedLog(log.id === selectedRow.id ? null : { fromId: selectedRow.id, log })
|
|
setActiveTab('overview')
|
|
overviewTabRef.current?.focus()
|
|
}
|
|
const { logsMetadata } = useIsFeatureEnabled(['logs:metadata'])
|
|
const selectedJson = selectedRows.map((row) =>
|
|
getLogDataForMetadataVisibility(getRawLogData(row), logsMetadata)
|
|
)
|
|
|
|
return (
|
|
<>
|
|
<ResizableHandle withHandle />
|
|
<ResizablePanel
|
|
id="log-sidepanel"
|
|
defaultSize={400}
|
|
minSize={dock === 'bottom' ? 300 : 400}
|
|
className="bg-card"
|
|
>
|
|
<div className="flex h-full flex-col overflow-hidden">
|
|
{/* Matches the table header height so the title lines up with the column labels */}
|
|
<div className="flex h-9 min-w-0 shrink-0 items-center gap-3 px-4">
|
|
<div className="flex min-w-0 flex-1" role="status" title={title}>
|
|
{!hasMultiple && activeLog ? (
|
|
<OpenLogSummary log={activeLog} searchParameters={searchParameters} />
|
|
) : (
|
|
<span className="truncate text-sm font-medium leading-6 text-foreground">
|
|
{title}
|
|
</span>
|
|
)}
|
|
</div>
|
|
<div className="-mr-1 flex h-6 shrink-0 items-center gap-1">
|
|
<LogSelectionActions rows={hasMultiple || !activeLog ? selectedRows : [activeLog]} />
|
|
<LogPanelCloseButton />
|
|
</div>
|
|
</div>
|
|
{hasMultiple ? (
|
|
<div
|
|
className="min-h-0 flex-1 overflow-auto"
|
|
role="region"
|
|
aria-label="Selected logs JSON"
|
|
>
|
|
<JsonCodeBlock>{JSON.stringify(selectedJson, null, 2)}</JsonCodeBlock>
|
|
</div>
|
|
) : (
|
|
<Tabs
|
|
value={currentTab}
|
|
onValueChange={setActiveTab}
|
|
className="flex min-h-0 flex-1 flex-col"
|
|
>
|
|
<TabsList className="shrink-0 gap-x-5 px-4">
|
|
<TabsTrigger
|
|
ref={overviewTabRef}
|
|
value="overview"
|
|
className={TAB_TRIGGER_CLASS_NAME}
|
|
>
|
|
Overview
|
|
</TabsTrigger>
|
|
<TabsTrigger value="raw-json" className={TAB_TRIGGER_CLASS_NAME}>
|
|
Raw JSON
|
|
</TabsTrigger>
|
|
{showTimeline && (
|
|
<TabsTrigger value="timeline" className={TAB_TRIGGER_CLASS_NAME}>
|
|
Timeline
|
|
</TabsTrigger>
|
|
)}
|
|
{showUser && (
|
|
<TabsTrigger value="user" className={TAB_TRIGGER_CLASS_NAME}>
|
|
User
|
|
</TabsTrigger>
|
|
)}
|
|
<TabsIndicator />
|
|
</TabsList>
|
|
{tabs.map((tab) => (
|
|
<TabsContent
|
|
key={`${tab}-${selectedRow?.id}`}
|
|
value={tab}
|
|
className="mt-0 min-h-0 flex-1 overflow-auto"
|
|
>
|
|
{tab === 'timeline' && selectedRow && activeLog && (
|
|
<RequestTimeline
|
|
row={selectedRow}
|
|
activeLog={activeLog}
|
|
onSelectLog={handleSelectTimelineLog}
|
|
/>
|
|
)}
|
|
{tab === 'user' && activeLog && (
|
|
<LogUser row={activeLog} searchParameters={searchParameters} />
|
|
)}
|
|
{(tab === 'overview' || tab === 'raw-json') && activeLog && (
|
|
<LogDetail
|
|
row={activeLog}
|
|
tab={tab}
|
|
searchParameters={searchParameters}
|
|
overviewHeader={<LogTimestampHeader log={activeLog} />}
|
|
/>
|
|
)}
|
|
</TabsContent>
|
|
))}
|
|
</Tabs>
|
|
)}
|
|
<div className="flex shrink-0 items-center gap-2 border-t py-1.5 pl-4 pr-3 text-xs text-foreground-lighter">
|
|
<div className="flex min-w-0 flex-1 flex-wrap items-center gap-2">
|
|
<ShortcutBadge shortcutId={SHORTCUT_IDS.UNIFIED_LOGS_EXTEND_PREV_ROW} />
|
|
<ShortcutBadge shortcutId={SHORTCUT_IDS.UNIFIED_LOGS_EXTEND_NEXT_ROW} />
|
|
<span>Extend selection</span>
|
|
</div>
|
|
<LogPanelNavigation dock={dock} setDock={setDock} />
|
|
</div>
|
|
</div>
|
|
</ResizablePanel>
|
|
</>
|
|
)
|
|
}
|
|
|
|
/** Shows a spinner in place of the log type icon while the open log's details load */
|
|
function OpenLogSummary({
|
|
log,
|
|
searchParameters,
|
|
}: {
|
|
log: ColumnSchema
|
|
searchParameters: QuerySearchParamsType
|
|
}) {
|
|
const { isLoading } = useLogEnrichment({ row: log, searchParameters, shouldFetch: false })
|
|
return <LogStepSummary log={log} isLoading={isLoading} />
|
|
}
|