import React from "react"; import { Eye, EyeOff } from "lucide-react"; import { C, FD, FM, SEV, turnSeverity, toolBucket } from "../theme.js"; // MODE A left legend: typed entities with counts + severity colour dot + a // show/hide eye per type, then tool-type tallies and the Direct/Indirect // causality tally. (UI-SPEC: "Left legend panel: typed entities with counts, // a severity colour dot, and a show/hide eye per type.") function LegendRow({ color, label, count, visible, onToggle, dot = "circle" }) { return (
{label} {count} {visible ? : }
); } function GroupLabel({ text }) { return (
{text}
); } export default function Legend({ turns, vis, setVis }) { // Severity tallies across turns. const sevCounts = { heavy: 0, tip: 0, clean: 0 }; turns.forEach((t) => { sevCounts[turnSeverity(t)]++; }); // Tool-type tallies + causality tally across the whole session. const tool = { Read: 0, Bash: 0, Edit: 0, MCP: 0, Task: 0, Other: 0 }; let direct = 0, indirect = 0; turns.forEach((t) => (t.tools || []).forEach((tl) => { const b = toolBucket(tl.name); tool[b] = (tool[b] || 0) + 1; if (tl.provenance === "indirect") indirect++; else direct++; }) ); const toggle = (k) => setVis((v) => ({ ...v, [k]: !v[k] })); return (
toggle("heavy")} /> toggle("tip")} /> toggle("clean")} /> toggle("tRead")} dot="square" /> toggle("tBash")} dot="square" /> toggle("tEdit")} dot="square" /> toggle("tMCP")} dot="square" /> toggle("tTask")} dot="square" />
{direct}
{indirect}
Direct · you Indirect · agent
); } // Default visibility map for the legend toggles. export const defaultVis = { heavy: true, tip: true, clean: true, tRead: true, tBash: true, tEdit: true, tMCP: true, tTask: true, };