mirror of
https://github.com/hanzoai/insights.git
synced 2026-11-02 09:24:48 +00:00
The tree was a debranded snapshot of upstream taken around 2026-02-20, and upstream has moved about five months since. This replaces it with upstream master, mechanically re-derived: bin/debrand does the rename, and the pipeline and squashed migrations are restored from the shipped tree. Not a merge. The previous import replaced the tree wholesale in a single commit, so there is no shared content history to merge against. Reproducing the rename on the new tree is what actually converges. What survives: .hanzo/workflows, the Dockerfiles and bin/docker* entrypoints, compose files, LLM.md, and insights/migrations. The squashed initial migration is load-bearing — the live database records it by name, so upstream's ~918 individual migrations cannot come back. Nine products are dropped as unreferenced. Twenty-one more that we do not run are kept anyway because the core app still imports them; unpicking those is a refactor and does not belong in a rebase. This base does not build yet, and the reasons are not in the rename: upstream now wants Python 3.13.13 against our 3.12.12 and Django 5.2 against our 4.2, and the dependency manifests still name upstream packages that we republish under our own names. Those are decisions, not renames.
91 lines
3.2 KiB
TypeScript
91 lines
3.2 KiB
TypeScript
import { useCallback, useMemo } from 'react'
|
|
|
|
import { SpinnerOverlay } from '@hanzo/elements'
|
|
import { Heatmap, type HeatmapBrushData, useChartTheme } from '@hanzo/quill-charts'
|
|
|
|
import { dayjs } from 'lib/dayjs'
|
|
import { shortTimeZone } from 'lib/utils/timezones'
|
|
|
|
import type { TracingLatencyHeatmapData } from './durationBuckets'
|
|
|
|
const MAX_X_TICKS = 6
|
|
|
|
interface TracingLatencyHeatmapProps {
|
|
data: TracingLatencyHeatmapData
|
|
loading: boolean
|
|
displayTimezone: string
|
|
/** Enables the 2D brush: drag a rectangle to select a time window + duration range. */
|
|
onBrush?: (selection: HeatmapBrushData) => void
|
|
}
|
|
|
|
export function TracingLatencyHeatmap({
|
|
data,
|
|
loading,
|
|
displayTimezone,
|
|
onBrush,
|
|
}: TracingLatencyHeatmapProps): JSX.Element {
|
|
const theme = useChartTheme()
|
|
|
|
// Same tick density logic as TracingSparkline: pick a format for the window size and thin
|
|
// the categorical axis down to ~6 labels.
|
|
const tickFormat = useMemo(() => {
|
|
if (!data.timeBuckets.length) {
|
|
return 'HH:mm:ss'
|
|
}
|
|
const hoursDiff = dayjs(data.timeBuckets[data.timeBuckets.length - 1]).diff(dayjs(data.timeBuckets[0]), 'hours')
|
|
if (hoursDiff <= 6) {
|
|
return 'HH:mm:ss'
|
|
} else if (hoursDiff <= 48) {
|
|
return 'HH:mm'
|
|
}
|
|
return 'D MMM HH:mm'
|
|
}, [data.timeBuckets])
|
|
|
|
const tickStep = Math.max(1, Math.ceil(data.timeBuckets.length / MAX_X_TICKS))
|
|
const xTickFormatter = useCallback(
|
|
(label: string, index: number): string | null => {
|
|
if (index % tickStep !== 0) {
|
|
return null
|
|
}
|
|
const d = displayTimezone ? dayjs(label).tz(displayTimezone) : dayjs(label)
|
|
return d.format(tickFormat)
|
|
},
|
|
[tickStep, tickFormat, displayTimezone]
|
|
)
|
|
|
|
const tooltipLabelFormatter = useCallback(
|
|
(label: string): string => {
|
|
const d = displayTimezone ? dayjs(label).tz(displayTimezone) : dayjs(label)
|
|
const tz = displayTimezone === 'UTC' ? 'UTC' : (shortTimeZone(displayTimezone, d.toDate()) ?? 'Local')
|
|
return `${d.format('D MMM YYYY HH:mm:ss')} ${tz}`
|
|
},
|
|
[displayTimezone]
|
|
)
|
|
|
|
const config = useMemo(
|
|
() => ({ xTickFormatter, tooltip: { labelFormatter: tooltipLabelFormatter } }),
|
|
[xTickFormatter, tooltipLabelFormatter]
|
|
)
|
|
|
|
return (
|
|
// Flex column: the quill chart shell sizes itself with flex-1 and collapses to zero
|
|
// height in a plain block container.
|
|
<div className="relative h-full w-full flex flex-col">
|
|
{data.cells.length > 0 ? (
|
|
<Heatmap
|
|
xLabels={data.timeBuckets}
|
|
yLabels={data.labels}
|
|
cells={data.cells}
|
|
theme={theme}
|
|
config={config}
|
|
onBrush={onBrush}
|
|
dataAttr="tracing-latency-heatmap"
|
|
/>
|
|
) : !loading ? (
|
|
<div className="h-full text-muted flex items-center justify-center">No results matching filters</div>
|
|
) : null}
|
|
{loading && <SpinnerOverlay />}
|
|
</div>
|
|
)
|
|
}
|