Files
zeekay 1b367e2b62 chore: rebase the tree onto upstream master
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.
2026-08-01 15:44:40 -07:00

113 lines
3.7 KiB
TypeScript

import type { ReactElement } from 'react'
import { DescriptionList } from '@hanzo/mcp-ui'
import { Badge, Card, CardContent } from '@hanzo/quill'
export interface TraceSpanData {
uuid: string
trace_id: string
span_id: string
parent_span_id?: string | null
name: string
kind?: string | null
service_name?: string | null
status_code?: number | null
timestamp: string
end_time?: string | null
duration_nano?: number | null
is_root_span?: boolean
matched_filter?: boolean
_insightsUrl?: string
}
function formatDuration(nanos: number): string {
if (nanos < 1_000_000) {
return `${(nanos / 1_000).toFixed(1)} \u00b5s`
}
if (nanos < 1_000_000_000) {
return `${(nanos / 1_000_000).toFixed(1)} ms`
}
return `${(nanos / 1_000_000_000).toFixed(2)} s`
}
function formatTimestamp(ts: string): string {
try {
const d = new Date(ts)
return d.toLocaleString(undefined, {
year: 'numeric',
month: 'short',
day: 'numeric',
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
fractionalSecondDigits: 3,
})
} catch {
return ts
}
}
const statusVariant: Record<string, 'success' | 'destructive' | 'warning' | 'default'> = {
'0': 'default',
'1': 'success',
'2': 'destructive',
}
const statusLabel: Record<string, string> = {
'0': 'Unset',
'1': 'OK',
'2': 'Error',
}
const kindLabel: Record<string, string> = {
'0': 'Unspecified',
'1': 'Internal',
'2': 'Server',
'3': 'Client',
'4': 'Producer',
'5': 'Consumer',
}
export function TraceSpanView({ data }: { data: TraceSpanData }): ReactElement {
const statusKey = String(data.status_code ?? '0')
return (
<div className="p-4">
<div className="flex flex-col gap-3">
<div className="flex flex-col gap-1">
<div className="flex items-center gap-2 flex-wrap">
<span className="text-lg font-semibold break-all">{data.name}</span>
<Badge variant={statusVariant[statusKey] ?? 'default'}>
{statusLabel[statusKey] ?? `Status ${statusKey}`}
</Badge>
{data.is_root_span && <Badge>Root</Badge>}
</div>
{data.service_name && <span className="text-sm text-muted-foreground">{data.service_name}</span>}
</div>
<Card>
<CardContent>
<DescriptionList
columns={2}
items={[
{ label: 'Trace ID', value: data.trace_id },
{ label: 'Span ID', value: data.span_id },
...(data.parent_span_id
? [{ label: 'Parent span ID', value: data.parent_span_id }]
: []),
...(data.kind != null
? [{ label: 'Kind', value: kindLabel[String(data.kind)] ?? String(data.kind) }]
: []),
{ label: 'Timestamp', value: formatTimestamp(data.timestamp) },
...(data.duration_nano != null
? [{ label: 'Duration', value: formatDuration(data.duration_nano) }]
: []),
]}
/>
</CardContent>
</Card>
</div>
</div>
)
}