Phase 4 of the debug-console expansion — the tester no longer makes you
hand-write JSON. Each param renders the right smart control from its
semantic role: group/friend/member pickers (member linked to the sibling
group_id), FileSource for media, FaceGrid, datetime for timestamps,
switch for bool, select for enum — with the raw-JSON escape hatch kept.
- Read-only actions badge green, side-effecting amber; a name-pattern set
of destructive actions (kick/ban/recall/delete/…) confirms first.
- Stream API actions invoke over /api/debug/invoke-stream and render
frames live, tracked in the app-level task registry with progress; a
clean success requires the terminal response frame, and a failed frame
shows its reason (not just the {type:'error'} marker).
- Every call lands in capped localStorage history with one-click replay;
responses render in a collapsible JsonTree.
- Extracted LiveActivity (filter / search / export) and the Segmented
control into their own components; debug-page is now a thin host.
Adversarially reviewed: stream terminal-frame judging, member/group
linkage, and contract shapes verified; fixed the failed-stream-frame
reason being hidden, a latent required-enum controlled-select trap, stale
member value on group change, and several low UX edges.
40 lines
1.5 KiB
TypeScript
40 lines
1.5 KiB
TypeScript
// Segmented — an iOS-style segmented control with a sliding active pill. Shared
|
|
// by the debug console's tester / stream panels. Extracted from the original
|
|
// debug page so multiple panels reuse one implementation.
|
|
import { useId, type ReactNode } from 'react';
|
|
import { motion } from 'motion/react';
|
|
import { cn } from '@/lib/utils';
|
|
|
|
export function Segmented<T extends string>({ value, onChange, options }: {
|
|
value: T; onChange: (v: T) => void; options: { value: T; label: ReactNode }[];
|
|
}) {
|
|
const id = useId();
|
|
return (
|
|
<div role="radiogroup" className="inline-flex rounded-full bg-muted/70 p-0.5 text-sm">
|
|
{options.map((o) => {
|
|
const active = o.value === value;
|
|
return (
|
|
<button
|
|
key={o.value}
|
|
type="button"
|
|
role="radio"
|
|
aria-checked={active}
|
|
onClick={() => onChange(o.value)}
|
|
className={cn('relative rounded-full px-3.5 py-1 font-medium transition-colors',
|
|
active ? 'text-foreground' : 'text-muted-foreground hover:text-foreground')}
|
|
>
|
|
{active && (
|
|
<motion.span
|
|
layoutId={`seg-${id}`}
|
|
transition={{ type: 'spring', stiffness: 500, damping: 38 }}
|
|
className="absolute inset-0 rounded-full bg-card shadow-sm ring-1 ring-border/50"
|
|
/>
|
|
)}
|
|
<span className="relative z-10">{o.label}</span>
|
|
</button>
|
|
);
|
|
})}
|
|
</div>
|
|
);
|
|
}
|