Spaces:
Running

mcp-webcam / src /components /clients /CallerRow.tsx
evalstate's picture
evalstate HF Staff
Deploy mcp-webcam v0.3.0 (stateless MCP 2026-07-28 + SEP-3415 Events + Studio UI)
6f5f15e verified
Raw History Blame Contribute Delete
3.39 kB
import { useState } from 'react';
import { ChevronDown, ChevronRight } from 'lucide-react';
import type { CallerView } from '../../../shared/api-types';
import { Badge } from '@/components/ui/badge';
import { relativeTime } from '@/lib/format';
import { ClientBadge } from './ClientBadge';
import { EraBadge } from './EraBadge';
import { cn } from '@/lib/utils';
export function CallerRow({ caller, nowMs }: { caller: CallerView; nowMs: number }) {
const [expanded, setExpanded] = useState(false);
const dotClass =
caller.status === 'active'
? 'bg-emerald-400'
: caller.status === 'idle'
? 'bg-event'
: 'bg-zinc-500';
const methodEntries = Object.entries(caller.methods).sort((a, b) => b[1] - a[1]);
return (
<div className="rounded-lg border border-line bg-panel-2/40 p-2.5 space-y-1.5">
<div className="flex items-start justify-between gap-2">
<div className="min-w-0 space-y-1">
<div className="flex flex-wrap items-center gap-1.5">
<span className={cn('h-2 w-2 rounded-full shrink-0', dotClass)} title={caller.status} />
<ClientBadge client={caller.client} />
<EraBadge era={caller.client.era} protocolVersion={caller.client.protocolVersion} />
<Badge variant={caller.client.transport === 'stdio' ? 'call' : 'outline'} className="font-mono text-[10px] uppercase">
{caller.client.transport}
</Badge>
{caller.client.eventsCapable && (
<Badge variant="push" className="text-[10px]">
events-capable
</Badge>
)}
</div>
<div className="flex flex-wrap items-center gap-2 text-[11px] text-muted tabular-nums">
<span className="font-mono text-fg">
{caller.lastMethod}
{caller.lastDetail ? ` · ${caller.lastDetail}` : ''}
</span>
{caller.lastResponse && (
<Badge variant="muted" className="font-mono text-[9.5px] uppercase">
{caller.lastResponse}
</Badge>
)}
</div>
</div>
<button
type="button"
onClick={() => setExpanded((e) => !e)}
className="inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[11px] text-muted hover:bg-panel-2 hover:text-fg cursor-pointer tabular-nums"
>
<span>{caller.requests} req</span>
{expanded ? <ChevronDown className="h-3 w-3" /> : <ChevronRight className="h-3 w-3" />}
</button>
</div>
<div className="flex items-center justify-between text-[10.5px] text-muted-2 tabular-nums">
<span>last seen {relativeTime(caller.lastSeenAt, nowMs)}</span>
{caller.open && <span className="text-call">stdio open</span>}
</div>
{expanded && methodEntries.length > 0 && (
<div className="flex flex-wrap gap-1.5 border-t border-line pt-2">
{methodEntries.map(([method, count]) => (
<span
key={method}
className="inline-flex items-center gap-1 rounded border border-line bg-panel px-1.5 py-0.5 font-mono text-[10px] text-muted tabular-nums"
>
<span className="text-fg">{method}</span>
<span>×{count}</span>
</span>
))}
</div>
)}
</div>
);
}