{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "end-of-run-summary",
  "title": "End of Run Summary",
  "description": "The report an AI agent leaves when it finishes: how it went, what it cost and which bot spent it, how it compares to last time, and what still needs you.",
  "dependencies": [],
  "files": [
    {
      "path": "registry/new-york/end-of-run-summary/end-of-run-summary.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport type RunOutcome = \"success\" | \"partial\" | \"failed\";\n\nexport interface RunCost {\n  id: string;\n  label: string;\n  /** In dollars. */\n  amount: number;\n}\n\nexport interface RunStat {\n  label: string;\n  value: string;\n  /** Change against the last run, e.g. \"-18%\". */\n  change?: string;\n  /** Whether the change is a good thing. */\n  better?: boolean;\n}\n\nexport interface RunNote {\n  id: string;\n  text: string;\n  detail: string;\n}\n\nexport interface RunNoteGroup {\n  id: string;\n  label: string;\n  notes: RunNote[];\n}\n\nexport interface EndOfRunSummaryProps extends Omit<\n  React.ComponentPropsWithoutRef<\"section\">,\n  \"title\"\n> {\n  theme?: \"dark\" | \"light\";\n  title?: string;\n  outcome?: RunOutcome;\n  /** One line saying how it ended. */\n  verdict?: string;\n  costs?: RunCost[];\n  stats?: RunStat[];\n  groups?: RunNoteGroup[];\n  /** The main action, e.g. opening the pull request. */\n  action?: { label: string; onClick?: () => void };\n  onRunAgain?: () => void;\n  onRate?: (useful: boolean | null) => void;\n}\n\nconst FONT =\n  '\"Inter Variable\", Inter, \"SF Pro Display\", -apple-system, BlinkMacSystemFont, sans-serif';\nconst RING = \"outline-none focus-visible:ring-2 focus-visible:ring-[#5E6AD2]\";\nconst SERIES = [\"#5E6AD2\", \"#4EA7FC\", \"#8A8F98\", \"#62666D\"];\nconst BAR_H = 10;\n\nconst OUTCOMES: Record<RunOutcome, { label: string; color: string }> = {\n  success: { label: \"Finished\", color: \"#27A644\" },\n  partial: { label: \"Finished with notes\", color: \"#FC7840\" },\n  failed: { label: \"Failed\", color: \"#EB5757\" },\n};\n\nconst PALETTES = {\n  dark: {\n    card: \"#08090A\",\n    border: \"rgba(255,255,255,0.08)\",\n    text: \"#F7F8F8\",\n    soft: \"#D0D6E0\",\n    sub: \"#8A8F98\",\n    faint: \"#62666D\",\n    chip: \"rgba(255,255,255,0.05)\",\n    tab: \"rgba(255,255,255,0.08)\",\n    btn: \"#E5E5E6\",\n    btnText: \"#08090A\",\n  },\n  light: {\n    card: \"#FFFFFF\",\n    border: \"rgba(8,9,10,0.08)\",\n    text: \"#08090A\",\n    soft: \"#3C3F44\",\n    sub: \"#62666D\",\n    faint: \"#8A8F98\",\n    chip: \"rgba(8,9,10,0.04)\",\n    tab: \"#FFFFFF\",\n    btn: \"#08090A\",\n    btnText: \"#F7F8F8\",\n  },\n};\n\nconst DEFAULT_COSTS: RunCost[] = [\n  { id: \"patch\", label: \"Patch\", amount: 0.31 },\n  { id: \"scout\", label: \"Scout\", amount: 0.17 },\n  { id: \"review\", label: \"Review\", amount: 0.12 },\n];\n\nconst DEFAULT_STATS: RunStat[] = [\n  { label: \"Time\", value: \"12m 05s\", change: \"-18%\", better: true },\n  { label: \"Steps\", value: \"27\", change: \"-4\", better: true },\n  { label: \"Tokens\", value: \"81k\", change: \"+6%\", better: false },\n  { label: \"Tests passing\", value: \"152 of 152\", change: \"+1\", better: true },\n];\n\nconst DEFAULT_GROUPS: RunNoteGroup[] = [\n  {\n    id: \"changed\",\n    label: \"Changed\",\n    notes: [\n      {\n        id: \"api\",\n        text: \"Moved invoices to the new billing API\",\n        detail: \"6 files\",\n      },\n      {\n        id: \"tax\",\n        text: \"Rounded tax per line, as the old code did\",\n        detail: \"2 files\",\n      },\n      {\n        id: \"tests\",\n        text: \"Added 4 tests for refund totals\",\n        detail: \"1 file\",\n      },\n    ],\n  },\n  {\n    id: \"look\",\n    label: \"Needs a look\",\n    notes: [\n      {\n        id: \"webhook\",\n        text: \"Webhook retries are untested against live traffic\",\n        detail: \"Before release\",\n      },\n      {\n        id: \"old\",\n        text: \"The old invoice tables can go after one billing cycle\",\n        detail: \"Next month\",\n      },\n    ],\n  },\n  {\n    id: \"skipped\",\n    label: \"Skipped\",\n    notes: [\n      {\n        id: \"docs\",\n        text: \"Left the public API docs alone, as you asked\",\n        detail: \"By request\",\n      },\n    ],\n  },\n];\n\nconst round = (n: number) => Math.round(n * 100) / 100;\n\nfunction useWidth<T extends HTMLElement>(fallback: number) {\n  const ref = React.useRef<T>(null);\n  const [width, setWidth] = React.useState(fallback);\n  React.useEffect(() => {\n    const el = ref.current;\n    if (!el) return;\n    const ro = new ResizeObserver(([entry]) => {\n      setWidth(Math.round(entry.contentRect.width));\n    });\n    ro.observe(el);\n    return () => ro.disconnect();\n  }, []);\n  return [ref, width] as const;\n}\n\n/** Drawn as SVG, because a tiny border-radius circle turns lumpy on 1x screens. */\nfunction Dot({ size, color }: { size: number; color: string }) {\n  const r = size / 2;\n  return (\n    <svg\n      aria-hidden=\"true\"\n      width={size}\n      height={size}\n      viewBox={`0 0 ${size} ${size}`}\n      className=\"block shrink-0\"\n    >\n      <circle cx={r} cy={r} r={r} style={{ fill: color }} />\n    </svg>\n  );\n}\n\nfunction Thumb({ down }: { down?: boolean }) {\n  return (\n    <svg\n      aria-hidden=\"true\"\n      viewBox=\"0 0 16 16\"\n      width=\"16\"\n      height=\"16\"\n      fill=\"none\"\n      className=\"block\"\n      style={{ transform: down ? \"rotate(180deg)\" : undefined }}\n    >\n      <path\n        d=\"M5 7v6.5H3a.5.5 0 0 1-.5-.5V7.5A.5.5 0 0 1 3 7h2Zm0 0 2.6-4.7a1 1 0 0 1 1.9.5V6h3.1a1 1 0 0 1 1 1.2l-.9 5.5a1 1 0 0 1-1 .8H5\"\n        stroke=\"currentColor\"\n        strokeWidth=\"1.25\"\n        strokeLinejoin=\"round\"\n      />\n    </svg>\n  );\n}\n\nexport function EndOfRunSummary({\n  theme = \"dark\",\n  title = \"Move invoices to the new billing API\",\n  outcome = \"partial\",\n  verdict = \"The work is done, with two things to check.\",\n  costs = DEFAULT_COSTS,\n  stats = DEFAULT_STATS,\n  groups = DEFAULT_GROUPS,\n  action = { label: \"Open pull request\" },\n  onRunAgain,\n  onRate,\n  className,\n  style,\n  ...rest\n}: EndOfRunSummaryProps) {\n  const c = PALETTES[theme];\n  const state = OUTCOMES[outcome];\n  const [focus, setFocus] = React.useState<string | null>(null);\n  const [tab, setTab] = React.useState(groups[0]?.id ?? \"\");\n  const [rating, setRating] = React.useState<boolean | null>(null);\n  const [barRef, width] = useWidth<HTMLDivElement>(780);\n\n  const total = round(costs.reduce((sum, x) => sum + x.amount, 0));\n  const picked = costs.find((x) => x.id === focus);\n  const tabIndex = Math.max(\n    0,\n    groups.findIndex((g) => g.id === tab),\n  );\n\n  // The cost bar, drawn at its real width with a 2px gap between parts.\n  const gap = 2;\n  const usable = width - gap * Math.max(costs.length - 1, 0);\n  const parts: (RunCost & { x: number; w: number; color: string })[] = [];\n  for (const [i, cost] of costs.entries()) {\n    const previous = parts[parts.length - 1];\n    parts.push({\n      ...cost,\n      x: previous ? round(previous.x + previous.w + gap) : 0,\n      w: round(total ? (cost.amount / total) * usable : 0),\n      color: SERIES[i % SERIES.length],\n    });\n  }\n\n  const rate = (value: boolean) => {\n    const next = rating === value ? null : value;\n    setRating(next);\n    onRate?.(next);\n  };\n\n  const secondary = `h-9 cursor-pointer rounded-full border-0 px-4 text-[13px] leading-[20px] font-[510] tracking-[-0.011em] whitespace-nowrap ${RING}`;\n\n  return (\n    <section\n      aria-label={title}\n      className={`@container w-full rounded-2xl border ${className ?? \"\"}`}\n      style={{\n        background: c.card,\n        borderColor: c.border,\n        color: c.text,\n        fontFamily: FONT,\n        ...style,\n      }}\n      {...rest}\n    >\n      <div className=\"p-5 pb-4 @2xl:p-6 @2xl:pb-4\">\n        <div className=\"flex items-start justify-between gap-4\">\n          <header className=\"min-w-0\">\n            <p\n              className=\"m-0 flex items-center gap-2 text-[13px] leading-[20px] font-[510] tracking-[-0.011em]\"\n              style={{ color: c.soft }}\n            >\n              <Dot size={8} color={state.color} />\n              {state.label}\n            </p>\n            <h3 className=\"m-0 mt-1 text-[20px] leading-[26px] font-[590] tracking-[-0.012em]\">\n              {title}\n            </h3>\n            <p\n              className=\"m-0 mt-1 text-[13px] leading-[20px] tracking-[-0.011em]\"\n              style={{ color: c.sub }}\n            >\n              {verdict}\n            </p>\n          </header>\n          <div className=\"shrink-0 text-right\">\n            <p className=\"m-0 text-[32px] leading-[32px] font-[510] tracking-[-0.022em] tabular-nums\">\n              ${(picked ? picked.amount : total).toFixed(2)}\n            </p>\n            <p\n              className=\"m-0 mt-1.5 text-[13px] leading-[20px]\"\n              style={{ color: c.sub }}\n            >\n              {picked ? `${picked.label}'s share` : \"Total cost\"}\n            </p>\n          </div>\n        </div>\n\n        <div ref={barRef} className=\"mt-4 w-full\" style={{ height: BAR_H }}>\n          <svg\n            role=\"img\"\n            aria-label={`Cost by bot: ${costs.map((x) => `${x.label} $${x.amount.toFixed(2)}`).join(\", \")}.`}\n            width={width}\n            height={BAR_H}\n            className=\"block\"\n          >\n            {parts.map((part) => (\n              <rect\n                key={part.id}\n                x={part.x}\n                y={0}\n                width={part.w}\n                height={BAR_H}\n                rx=\"3\"\n                fill={part.color}\n                opacity={!focus || focus === part.id ? 1 : 0.3}\n                className=\"motion-safe:transition-opacity motion-safe:duration-150\"\n              />\n            ))}\n          </svg>\n        </div>\n        <div className=\"mt-2.5 flex flex-wrap gap-1.5\">\n          {parts.map((part) => (\n            <button\n              key={part.id}\n              type=\"button\"\n              data-cost={part.id}\n              aria-pressed={focus === part.id}\n              onClick={() => setFocus(focus === part.id ? null : part.id)}\n              className={`flex h-7 cursor-pointer items-center gap-2 rounded-full border-0 px-3 text-[13px] leading-[20px] font-[510] tracking-[-0.011em] motion-safe:transition-opacity motion-safe:duration-150 ${RING}`}\n              style={{\n                background: c.chip,\n                color: c.text,\n                opacity: !focus || focus === part.id ? 1 : 0.45,\n              }}\n            >\n              <Dot size={8} color={part.color} />\n              {part.label}\n              <span className=\"tabular-nums\" style={{ color: c.sub }}>\n                ${part.amount.toFixed(2)}\n              </span>\n            </button>\n          ))}\n        </div>\n      </div>\n\n      <dl\n        className=\"m-0 grid grid-cols-2 gap-x-4 gap-y-3 border-t px-5 py-4 @2xl:grid-cols-4 @2xl:px-6\"\n        style={{ borderColor: c.border }}\n      >\n        {stats.map((s) => (\n          <div key={s.label} className=\"min-w-0\">\n            <dt\n              className=\"truncate text-[12px] leading-[16px] tracking-[-0.005em]\"\n              style={{ color: c.faint }}\n            >\n              {s.label}\n            </dt>\n            <dd className=\"m-0 mt-0.5 flex items-baseline gap-1.5 tabular-nums\">\n              <span className=\"truncate text-[16px] leading-[22px] font-[510] tracking-[-0.014em]\">\n                {s.value}\n              </span>\n              {s.change && (\n                <span\n                  className=\"shrink-0 text-[12px] leading-[16px] tracking-[-0.005em]\"\n                  style={{ color: s.better ? \"#27A644\" : \"#FC7840\" }}\n                >\n                  {s.change.replace(\"-\", \"−\")}\n                </span>\n              )}\n            </dd>\n          </div>\n        ))}\n      </dl>\n\n      <div\n        className=\"border-t px-5 pt-4 @2xl:px-6\"\n        style={{ borderColor: c.border }}\n      >\n        <div\n          role=\"group\"\n          aria-label=\"Notes\"\n          className=\"relative grid h-8 rounded-full p-0.5\"\n          style={{\n            background: c.chip,\n            gridTemplateColumns: `repeat(${groups.length}, minmax(0, 1fr))`,\n          }}\n        >\n          <span\n            aria-hidden=\"true\"\n            className=\"absolute rounded-full motion-safe:transition-transform motion-safe:duration-300\"\n            style={{\n              top: 2,\n              bottom: 2,\n              left: 2,\n              width: `calc((100% - 4px) / ${groups.length})`,\n              transform: `translateX(${tabIndex * 100}%)`,\n              background: c.tab,\n            }}\n          />\n          {groups.map((g) => (\n            <button\n              key={g.id}\n              type=\"button\"\n              data-tab={g.id}\n              aria-pressed={g.id === tab}\n              onClick={() => setTab(g.id)}\n              className={`relative cursor-pointer truncate rounded-full border-0 bg-transparent px-2 text-[12.5px] leading-[18px] font-[510] tracking-[-0.011em] tabular-nums motion-safe:transition-colors motion-safe:duration-200 ${RING}`}\n              style={{ color: g.id === tab ? c.text : c.sub }}\n            >\n              {g.label} {g.notes.length}\n            </button>\n          ))}\n        </div>\n\n        {/* Every list shares one cell, so changing tab never changes the card's height. */}\n        <div\n          className=\"mt-2 grid\"\n          style={{ gridTemplateColumns: \"minmax(0, 1fr)\" }}\n        >\n          {groups.map((g) => {\n            const on = g.id === tab;\n            return (\n              <ul\n                key={g.id}\n                aria-hidden={!on}\n                className={`m-0 list-none p-0 [grid-area:1/1] motion-safe:transition-opacity motion-safe:duration-200 ${on ? \"visible opacity-100\" : \"invisible opacity-0\"}`}\n              >\n                {g.notes.map((note) => (\n                  <li\n                    key={note.id}\n                    className=\"flex items-center justify-between gap-4 py-1.5 text-[13.5px] leading-[20px] tracking-[-0.011em]\"\n                  >\n                    <span\n                      className=\"min-w-0 truncate\"\n                      style={{ color: c.soft }}\n                    >\n                      {note.text}\n                    </span>\n                    <span\n                      className=\"shrink-0 text-[12.5px] leading-[18px]\"\n                      style={{ color: c.faint }}\n                    >\n                      {note.detail}\n                    </span>\n                  </li>\n                ))}\n              </ul>\n            );\n          })}\n        </div>\n      </div>\n\n      <footer\n        className=\"mt-3 flex flex-wrap items-center justify-between gap-3 border-t px-5 py-3.5 @2xl:px-6\"\n        style={{ borderColor: c.border }}\n      >\n        <div className=\"flex items-center gap-1.5\">\n          <span\n            className=\"mr-1 text-[13px] leading-[20px] tracking-[-0.011em]\"\n            style={{ color: c.sub }}\n          >\n            Useful run?\n          </span>\n          {[true, false].map((value) => (\n            <button\n              key={String(value)}\n              type=\"button\"\n              data-rate={value ? \"up\" : \"down\"}\n              aria-label={value ? \"Yes\" : \"No\"}\n              aria-pressed={rating === value}\n              onClick={() => rate(value)}\n              className={`flex cursor-pointer items-center justify-center rounded-full border-0 motion-safe:transition-colors motion-safe:duration-150 ${RING}`}\n              style={{\n                width: 32,\n                height: 32,\n                background: rating === value ? c.btn : c.chip,\n                color: rating === value ? c.btnText : c.sub,\n              }}\n            >\n              <Thumb down={!value} />\n            </button>\n          ))}\n        </div>\n        <div className=\"flex w-full justify-end gap-2 @md:w-auto\">\n          <button\n            type=\"button\"\n            onClick={onRunAgain}\n            className={`${secondary} flex-1 @md:flex-none`}\n            style={{ background: c.chip, color: c.soft }}\n          >\n            Run again\n          </button>\n          <button\n            type=\"button\"\n            onClick={action.onClick}\n            className={`${secondary} flex-1 @md:flex-none`}\n            style={{ background: c.btn, color: c.btnText }}\n          >\n            {action.label}\n          </button>\n        </div>\n      </footer>\n    </section>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}