MCPcopy Index your code
hub / github.com/CommonstackAI/UncommonRoute / Explainer

Function Explainer

frontend/dashboard/src/components/Explainer.tsx:26–317  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

24};
25
26export default function Explainer() {
27 const { recent: liveRecent } = useLiveData();
28 const completedCount = useMemo(
29 () => liveRecent.filter((r) => r.state === "completed").length,
30 [liveRecent],
31 );
32 const [recent, setRecent] = useState<TraceRecord[]>([]);
33 const [selectedId, setSelectedId] = useState<string | null>(null);
34 const [selected, setSelected] = useState<TraceRecord | null>(null);
35 const [loadingDetail, setLoadingDetail] = useState(false);
36 const [error, setError] = useState<string | null>(null);
37
38 useEffect(() => {
39 let cancelled = false;
40 const load = async () => {
41 const payload = await fetchTraces(30);
42 if (cancelled) return;
43 if (!payload) {
44 setError("[ERROR: TRACE ENDPOINT UNREACHABLE]");
45 setRecent([]);
46 return;
47 }
48 setError(null);
49 setRecent(payload.items);
50 setSelectedId((current) => {
51 if (current && payload.items.some((item) => item.request_id === current)) return current;
52 return payload.items[0]?.request_id ?? null;
53 });
54 };
55 load();
56 return () => {
57 cancelled = true;
58 };
59 }, [completedCount]);
60
61 useEffect(() => {
62 let cancelled = false;
63 if (!selectedId) {
64 setSelected(null);
65 return;
66 }
67
68 setLoadingDetail(true);
69 fetchTraceDetail(selectedId)
70 .then((detail) => {
71 if (cancelled) return;
72 setSelected(detail);
73 })
74 .catch(() => {
75 if (cancelled) return;
76 setSelected(null);
77 })
78 .finally(() => {
79 if (!cancelled) setLoadingDetail(false);
80 });
81
82 return () => {
83 cancelled = true;

Callers

nothing calls this directly

Calls 9

useLiveDataFunction · 0.90
fetchTraceDetailFunction · 0.90
loadFunction · 0.70
prettyTransportFunction · 0.70
prettifySourceFunction · 0.70
normTierFunction · 0.70
shortModelFunction · 0.70
prettyQualityFunction · 0.70
prettyLaneFunction · 0.70

Tested by

no test coverage detected