{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "diff-apply-feature",
  "type": "registry:block",
  "title": "Diff Apply Feature",
  "description": "Feature Section built with Diff Apply (animated code diff): an agent's code change applies line by line. A take on the code diff (code review). A feature section about reviewing what an agent writes. Beside three plain points, a Diff Apply editor plays the agent's tracking change into a real component, line by line, then waits for Keep or Undo on each change, with a running count of what was kept underneath.",
  "author": "KeyframeUI <https://keyframeui.com>",
  "categories": [
    "blocks",
    "feature-sections",
    "features",
    "code-diff"
  ],
  "docs": "Live preview and the components it's built with: https://keyframeui.com/blocks/feature-sections/diff-apply-feature",
  "registryDependencies": [
    "https://keyframeui.com/r/diff-apply.json"
  ],
  "files": [
    {
      "path": "components/diff-apply-feature.tsx",
      "type": "registry:component",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nimport { DiffApply, type DiffApplyDecision } from \"@/components/ui/diff-apply\";\n\n/* ── Content ─────────────────────────────────────────────────\n * Everything you'd change to make the section yours: the copy,\n * the points beside the editor, and the file the agent edits\n * (BEFORE and AFTER, one string per line; the component works\n * out the diff).\n * ─────────────────────────────────────────────────────────── */\n\n/** The one accent: the point markers and the review summary. */\nconst ACCENT = { light: \"#ea580c\", dark: \"#fb923c\" };\n\nconst HEADLINE = \"Read every line\";\nconst HEADLINE_QUIET = \"before it lands.\";\nconst SUBLINE =\n  \"Tern's agent edits your components the way a teammate would: a diff you can read, keep or undo, change by change.\";\n\nconst POINTS = [\n  {\n    title: \"Tracking that lives in your code\",\n    body: \"No snippet in the page head. Calls sit next to the button they measure, typed and tested with the rest.\",\n  },\n  {\n    title: \"Nothing lands without you\",\n    body: \"Each change waits for Keep or Undo, so a stray event name never reaches production.\",\n  },\n  {\n    title: \"Undo is just undo\",\n    body: \"Undo a change and it plays backwards, leaving the file exactly as it was.\",\n  },\n];\n\nconst PROMPT = \"Track signup_submitted with the chosen plan\";\nconst FILENAME = \"app/signup/form.tsx\";\n\nconst BEFORE = [\n  '\"use client\";',\n  \"\",\n  'import { useState } from \"react\";',\n  'import { createAccount } from \"./actions\";',\n  \"\",\n  \"export function SignupForm() {\",\n  '  const [plan, setPlan] = useState<Plan>(\"starter\");',\n  \"\",\n  \"  async function onSubmit(data: FormData) {\",\n  \"    const account = await createAccount(data, plan);\",\n  \"    window.location.assign(account.welcomeUrl);\",\n  \"  }\",\n  \"\",\n  \"  return <Form plan={plan} onPlanChange={setPlan} onSubmit={onSubmit} />;\",\n  \"}\",\n].join(\"\\n\");\n\nconst AFTER = [\n  '\"use client\";',\n  \"\",\n  'import { useState } from \"react\";',\n  'import { track } from \"@/lib/tern\";',\n  'import { createAccount } from \"./actions\";',\n  \"\",\n  \"export function SignupForm() {\",\n  '  const [plan, setPlan] = useState<Plan>(\"starter\");',\n  \"\",\n  \"  async function onSubmit(data: FormData) {\",\n  '    track(\"signup_submitted\", { plan });',\n  \"    const account = await createAccount(data, plan);\",\n  '    track(\"account_created\", { plan, id: account.id });',\n  \"    window.location.assign(account.welcomeUrl);\",\n  \"  }\",\n  \"\",\n  \"  return <Form plan={plan} onPlanChange={setPlan} onSubmit={onSubmit} />;\",\n  \"}\",\n].join(\"\\n\");\n\n/* ── Section ─────────────────────────────────────────────── */\n\nexport function DiffApplyFeature() {\n  const [decisions, setDecisions] = React.useState<DiffApplyDecision[]>([]);\n  const kept = decisions.filter((decision) => decision === \"kept\").length;\n  const undone = decisions.filter((decision) => decision === \"undone\").length;\n  const waiting = decisions.length - kept - undone;\n\n  return (\n    <section\n      style={{ \"--accent-light\": ACCENT.light, \"--accent-dark\": ACCENT.dark } as React.CSSProperties}\n      className=\"bg-zinc-50 text-zinc-950 [--accent:var(--accent-light)] dark:bg-zinc-950 dark:text-white dark:[--accent:var(--accent-dark)]\"\n    >\n      <div className=\"mx-auto grid max-w-6xl gap-x-14 gap-y-12 px-6 py-24 sm:py-32 lg:grid-cols-12 lg:items-center\">\n        <div className=\"lg:col-span-5\">\n          <h2 className=\"text-4xl/[1.05] font-semibold tracking-[-0.035em] text-balance sm:text-5xl/[1.02]\">\n            {HEADLINE} <span className=\"block text-zinc-400 dark:text-zinc-500\">{HEADLINE_QUIET}</span>\n          </h2>\n          <p className=\"mt-5 max-w-md text-base/7 text-pretty text-zinc-600 dark:text-zinc-400\">{SUBLINE}</p>\n\n          <ul className=\"mt-10 border-t border-zinc-950/10 dark:border-white/10\">\n            {POINTS.map((point) => (\n              <li key={point.title} className=\"flex gap-4 border-b border-zinc-950/10 py-5 dark:border-white/10\">\n                <span aria-hidden className=\"mt-2 size-1.5 shrink-0 rounded-full bg-(--accent)\" />\n                <div>\n                  <h3 className=\"text-sm font-semibold\">{point.title}</h3>\n                  <p className=\"mt-1 text-sm/6 text-pretty text-zinc-600 dark:text-zinc-400\">{point.body}</p>\n                </div>\n              </li>\n            ))}\n          </ul>\n        </div>\n\n        <div className=\"min-w-0 lg:col-span-7\">\n          <div className=\"mb-3 flex items-center gap-2.5 text-sm\">\n            <span className=\"grid size-6 shrink-0 place-items-center rounded-full bg-zinc-950 text-white dark:bg-white dark:text-zinc-950\">\n              <SparkIcon className=\"size-3\" />\n            </span>\n            <p className=\"min-w-0 truncate text-zinc-700 dark:text-zinc-300\">{PROMPT}</p>\n          </div>\n          <DiffApply\n            before={BEFORE}\n            after={AFTER}\n            filename={FILENAME}\n            onReview={setDecisions}\n            className=\"shadow-[0_24px_60px_-32px_rgb(9_9_11/0.35)] dark:shadow-[0_24px_60px_-24px_rgb(0_0_0/0.8)]\"\n          />\n          <p className=\"mt-3 h-5 text-sm text-zinc-500 tabular-nums\" aria-live=\"polite\">\n            {decisions.length > 0 &&\n              `${kept} kept · ${undone} undone${waiting > 0 ? ` · ${waiting} waiting for you` : \"\"}`}\n          </p>\n        </div>\n      </div>\n    </section>\n  );\n}\n\nfunction SparkIcon({ className }: { className?: string }) {\n  return (\n    <svg viewBox=\"0 0 16 16\" className={className} aria-hidden>\n      <path d=\"M8 1.5 9.6 6.4 14.5 8 9.6 9.6 8 14.5 6.4 9.6 1.5 8 6.4 6.4Z\" fill=\"currentColor\" />\n    </svg>\n  );\n}\n"
    }
  ]
}