Spaces:
Running

mcp-webcam / src /components /clients /CameraTabRow.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
2.38 kB
import { Snowflake, Star } from 'lucide-react';
import { toast } from 'sonner';
import type { CameraTabView } from '../../../shared/api-types';
import { Badge } from '@/components/ui/badge';
import { Button } from '@/components/ui/button';
import { formatUptime, parseBrowser, shortId } from '@/lib/format';
export function CameraTabRow({
tab,
isCurrentTab,
nowMs,
onMakePrimary,
}: {
tab: CameraTabView;
isCurrentTab: boolean;
nowMs: number;
onMakePrimary: (tabId: string) => Promise<void>;
}) {
return (
<div className="flex items-center justify-between gap-2 rounded-lg border border-line bg-panel-2/40 p-2.5">
<div className="min-w-0 space-y-1">
<div className="flex flex-wrap items-center gap-1.5">
<span className="text-xs font-medium text-fg">{parseBrowser(tab.userAgent)}</span>
{isCurrentTab && (
<Badge variant="default" className="text-[10px]">
This tab
</Badge>
)}
{tab.primary && (
<Badge variant="push" className="text-[10px]">
<Star className="h-2.5 w-2.5 fill-current" />
Primary
</Badge>
)}
{tab.frozen && (
<Badge variant="event" className="text-[10px]">
<Snowflake className="h-2.5 w-2.5" />
Frozen
</Badge>
)}
</div>
<div className="flex flex-wrap items-center gap-2 text-[11px] text-muted tabular-nums">
<span className="font-mono text-muted-2">{shortId(tab.tabId, 12)}</span>
{tab.deviceLabel && <span className="truncate max-w-[160px]">{tab.deviceLabel}</span>}
{tab.width && tab.height && (
<span className="font-mono">
{tab.width}×{tab.height}
</span>
)}
<span>up {formatUptime(tab.connectedAt, nowMs)}</span>
</div>
</div>
{!tab.primary && (
<Button
variant="outline"
size="sm"
className="h-7 shrink-0"
onClick={() =>
void onMakePrimary(tab.tabId)
.then(() => toast.success('Switched primary camera tab'))
.catch((e) => toast.error(e instanceof Error ? e.message : 'Failed to switch primary tab'))
}
>
Make primary
</Button>
)}
</div>
);
}