@agent-native/core 0.63.0 → 0.63.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/dist/agent/harness/ai-sdk-adapter.d.ts +44 -0
  2. package/dist/agent/harness/ai-sdk-adapter.d.ts.map +1 -1
  3. package/dist/agent/harness/ai-sdk-adapter.js +120 -1
  4. package/dist/agent/harness/ai-sdk-adapter.js.map +1 -1
  5. package/dist/agent/harness/index.d.ts +1 -1
  6. package/dist/agent/harness/index.d.ts.map +1 -1
  7. package/dist/agent/harness/index.js.map +1 -1
  8. package/dist/cli/code-agent-executor.js +1 -1
  9. package/dist/cli/code-agent-executor.js.map +1 -1
  10. package/dist/cli/create.js +1 -1
  11. package/dist/cli/create.js.map +1 -1
  12. package/dist/client/NewWorkspaceAppFlow.js +1 -1
  13. package/dist/client/NewWorkspaceAppFlow.js.map +1 -1
  14. package/dist/client/blocks/library/AnnotatedCodeBlock.d.ts.map +1 -1
  15. package/dist/client/blocks/library/AnnotatedCodeBlock.js +29 -10
  16. package/dist/client/blocks/library/AnnotatedCodeBlock.js.map +1 -1
  17. package/dist/client/blocks/library/DiffBlock.d.ts.map +1 -1
  18. package/dist/client/blocks/library/DiffBlock.js +48 -20
  19. package/dist/client/blocks/library/DiffBlock.js.map +1 -1
  20. package/dist/client/blocks/library/diagram.d.ts.map +1 -1
  21. package/dist/client/blocks/library/diagram.js +14 -3
  22. package/dist/client/blocks/library/diagram.js.map +1 -1
  23. package/dist/client/blocks/library/wireframe.d.ts.map +1 -1
  24. package/dist/client/blocks/library/wireframe.js +14 -3
  25. package/dist/client/blocks/library/wireframe.js.map +1 -1
  26. package/dist/client/blocks/types.d.ts +5 -0
  27. package/dist/client/blocks/types.d.ts.map +1 -1
  28. package/dist/client/blocks/types.js.map +1 -1
  29. package/dist/client/chat/index.d.ts +2 -1
  30. package/dist/client/chat/index.d.ts.map +1 -1
  31. package/dist/client/chat/index.js +2 -1
  32. package/dist/client/chat/index.js.map +1 -1
  33. package/dist/client/chat-view-transition.d.ts +17 -0
  34. package/dist/client/chat-view-transition.d.ts.map +1 -1
  35. package/dist/client/chat-view-transition.js +46 -0
  36. package/dist/client/chat-view-transition.js.map +1 -1
  37. package/dist/client/index.d.ts +2 -1
  38. package/dist/client/index.d.ts.map +1 -1
  39. package/dist/client/index.js +2 -1
  40. package/dist/client/index.js.map +1 -1
  41. package/dist/client/use-agent-chat-home-handoff.d.ts +27 -0
  42. package/dist/client/use-agent-chat-home-handoff.d.ts.map +1 -0
  43. package/dist/client/use-agent-chat-home-handoff.js +120 -0
  44. package/dist/client/use-agent-chat-home-handoff.js.map +1 -0
  45. package/dist/index.d.ts +1 -1
  46. package/dist/index.d.ts.map +1 -1
  47. package/dist/index.js +3 -1
  48. package/dist/index.js.map +1 -1
  49. package/dist/server/action-discovery.d.ts.map +1 -1
  50. package/dist/server/action-discovery.js +24 -2
  51. package/dist/server/action-discovery.js.map +1 -1
  52. package/dist/server/deep-link.d.ts +2 -2
  53. package/dist/server/deep-link.d.ts.map +1 -1
  54. package/dist/server/deep-link.js +2 -2
  55. package/dist/server/deep-link.js.map +1 -1
  56. package/dist/styles/agent-native.css +2 -6
  57. package/dist/tailwind.preset.d.ts.map +1 -1
  58. package/dist/tailwind.preset.js +8 -1
  59. package/dist/tailwind.preset.js.map +1 -1
  60. package/dist/templates/default/package.json +1 -0
  61. package/dist/templates/headless/AGENTS.md +3 -0
  62. package/dist/templates/headless/DEVELOPING.md +4 -0
  63. package/dist/templates/headless/actions/run.ts +6 -0
  64. package/dist/templates/workspace-root/README.md +4 -4
  65. package/docs/content/actions.md +32 -42
  66. package/docs/content/agent-surfaces.md +105 -84
  67. package/docs/content/agent-teams.md +2 -14
  68. package/docs/content/agent-web-surfaces.md +4 -4
  69. package/docs/content/authentication.md +40 -24
  70. package/docs/content/automations.md +18 -36
  71. package/docs/content/blueprint-installer.md +3 -0
  72. package/docs/content/cli-adapters.md +24 -168
  73. package/docs/content/client.md +11 -77
  74. package/docs/content/cloneable-saas.md +1 -1
  75. package/docs/content/code-agents-ui.md +44 -0
  76. package/docs/content/components.md +10 -23
  77. package/docs/content/context-awareness.md +3 -3
  78. package/docs/content/creating-templates.md +20 -18
  79. package/docs/content/database.md +1 -1
  80. package/docs/content/deployment.md +5 -37
  81. package/docs/content/dispatch.md +17 -28
  82. package/docs/content/drop-in-agent.md +24 -111
  83. package/docs/content/durable-resume.md +4 -0
  84. package/docs/content/embedding-sdk.md +141 -135
  85. package/docs/content/evals.md +3 -3
  86. package/docs/content/extensions.md +1 -1
  87. package/docs/content/external-agents.md +35 -61
  88. package/docs/content/faq.md +5 -5
  89. package/docs/content/frames.md +13 -4
  90. package/docs/content/getting-started.md +96 -142
  91. package/docs/content/harness-agents.md +53 -9
  92. package/docs/content/human-approval.md +1 -1
  93. package/docs/content/key-concepts.md +14 -99
  94. package/docs/content/local-file-mode.md +2 -2
  95. package/docs/content/mcp-apps.md +9 -2
  96. package/docs/content/mcp-clients.md +8 -3
  97. package/docs/content/mcp-protocol.md +11 -29
  98. package/docs/content/messaging.md +1 -1
  99. package/docs/content/migration-workbench.md +14 -175
  100. package/docs/content/multi-app-workspace.md +1 -1
  101. package/docs/content/multi-tenancy.md +18 -47
  102. package/docs/content/native-chat-ui.md +15 -12
  103. package/docs/content/observability.md +16 -4
  104. package/docs/content/observational-memory.md +1 -1
  105. package/docs/content/pure-agent-apps.md +17 -124
  106. package/docs/content/real-time-collaboration.md +14 -14
  107. package/docs/content/routing.md +71 -0
  108. package/docs/content/sandbox-adapters.md +78 -4
  109. package/docs/content/security.md +59 -39
  110. package/docs/content/server.md +16 -8
  111. package/docs/content/sharing.md +1 -6
  112. package/docs/content/skills-guide.md +3 -1
  113. package/docs/content/template-analytics.md +1 -1
  114. package/docs/content/template-assets.md +12 -3
  115. package/docs/content/template-brain.md +64 -72
  116. package/docs/content/template-chat.md +32 -4
  117. package/docs/content/template-clips.md +35 -4
  118. package/docs/content/template-design.md +19 -3
  119. package/docs/content/template-dispatch.md +9 -0
  120. package/docs/content/template-forms.md +15 -10
  121. package/docs/content/template-plan.md +13 -5
  122. package/docs/content/template-slides.md +14 -14
  123. package/docs/content/template-videos.md +10 -12
  124. package/docs/content/tracking.md +66 -55
  125. package/docs/content/using-your-agent.md +6 -16
  126. package/docs/content/what-is-agent-native.md +5 -11
  127. package/docs/content/workspace-management.md +2 -2
  128. package/docs/content/workspace.md +20 -160
  129. package/package.json +6 -2
  130. package/src/templates/default/package.json +1 -0
  131. package/src/templates/headless/AGENTS.md +3 -0
  132. package/src/templates/headless/DEVELOPING.md +4 -0
  133. package/src/templates/headless/actions/run.ts +6 -0
  134. package/src/templates/workspace-root/README.md +4 -4
@@ -1 +1 @@
1
- {"version":3,"file":"DiffBlock.js","sourceRoot":"","sources":["../../../../src/client/blocks/library/DiffBlock.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,WAAW,EACX,SAAS,EACT,OAAO,EACP,MAAM,EACN,QAAQ,GAGT,MAAM,OAAO,CAAC;AACf,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,gBAAgB,EAChB,YAAY,EACZ,QAAQ,EACR,QAAQ,EACR,SAAS,GACV,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAO/D,OAAO,EACL,sBAAsB,EACtB,qBAAqB,EACrB,mBAAmB,EACnB,4BAA4B,EAC5B,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,iCAAiC,EACjC,kBAAkB,GAInB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC7E,OAAO,EAAE,oBAAoB,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K,EAAE,EAAE,CAClB,gBAAgB,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,GAExD,EACF,KAAC,QAAQ,kBACK,cAAc,KAAK,GAAG,CAAC,QAAQ,EAC3C,KAAK,EAAE,UAAU,CAAC,KAAK,IAAI,EAAE,EAC7B,WAAW,EAAC,kBAAkB,EAC9B,QAAQ,EAAE,CAAC,QAAQ,EACnB,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAClB,gBAAgB,CAAC,KAAK,EAAE;4CACtB,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,IAAI,SAAS;yCACvC,CAAC,GAEJ,EACD,QAAQ,IAAI,CACX,iBACE,IAAI,EAAC,QAAQ,+CAED,qBAAqB,KAAK,GAAG,CAAC,EAAE,EAC5C,OAAO,EAAE,GAAG,EAAE,CAAC,gBAAgB,CAAC,KAAK,CAAC,EACtC,SAAS,EAAC,mJAAmJ,YAE7J,KAAC,SAAS,IAAC,SAAS,EAAC,QAAQ,GAAG,GACzB,CACV,IACG,EACN,KAAC,WAAW,kBACE,cAAc,KAAK,GAAG,CAAC,OAAO,EAC1C,SAAS,EAAC,sBAAsB,EAChC,KAAK,EAAE,UAAU,CAAC,IAAI,EACtB,WAAW,EAAC,mCAA8B,EAC1C,QAAQ,EAAE,CAAC,QAAQ,EACnB,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAClB,gBAAgB,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,GAEvD,KA3DG,KAAK,CA4DN,CACP,CAAC,IACE,IACF,CACP,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC","sourcesContent":["import {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n type RefObject,\n type ReactNode,\n} from \"react\";\nimport {\n IconChevronRight,\n IconColumns,\n IconDotsVertical,\n IconFileDiff,\n IconList,\n IconPlus,\n IconTrash,\n} from \"@tabler/icons-react\";\nimport { common, createLowlight } from \"lowlight\";\nimport { cn } from \"../../utils.js\";\nimport { ltrCodeBlockProps } from \"../code-block-direction.js\";\nimport type {\n BlockEditProps,\n BlockReadProps,\n BlockRenderContext,\n} from \"../types.js\";\nimport type { DiffAnnotation, DiffData, DiffMode } from \"./diff.config.js\";\nimport {\n AnnotationGutterMarker,\n AnnotationHiddenStack,\n AnnotationHoverCard,\n AnnotationInlineOverlayStack,\n anchorFromElements,\n buildLineMarkerMap,\n hasRailAnnotations,\n resolveAnnotations,\n useAnnotationMarginNotesAvailable,\n useAnnotationHover,\n type AnnotationMarginSide,\n type AnnotationSide,\n type ResolvedAnnotation,\n} from \"./annotation-rail.js\";\nimport { DevInput, DevLabel, DevTextarea, DevSelect } from \"./dev-doc-ui.js\";\nimport { useInNarrowContainer } from \"./narrow-container.js\";\n\n/**\n * GitHub-style before/after diff block. The read renderer computes a line-level\n * diff, then renders it either unified (one column, `+`/`−` gutters) or split\n * (side-by-side). Long unchanged runs collapse into an expandable \"N unchanged\n * lines\" row (progressive disclosure). The read surface keeps the GitHub diff\n * shape while using the framework Tailwind theme tokens, so it follows each\n * host app's light/dark appearance instead of bringing its own palette.\n *\n * Lives in core so any app can register the dev-doc block. The line differ is\n * inlined (a small LCS-based `diffLines`) rather than pulling the `diff` package\n * into core; the output shape (`{ value, added, removed }` change records) is\n * identical to what the read renderer consumed before.\n *\n * Editing is panel-driven (config-style, like the HTML block): two monospace\n * textareas (Before / After) plus filename, language, and mode controls.\n */\n\n/* ── Inline line differ (LCS) — replaces jsdiff `diffLines` ─────────────────── */\n\ninterface Change {\n value: string;\n added?: boolean;\n removed?: boolean;\n}\n\n/**\n * Split text into lines, each KEEPING its trailing newline (so the change\n * `value`s concatenate back to the original and `splitLines` below behaves the\n * same as it did against jsdiff output).\n */\nfunction toLineTokens(text: string): string[] {\n if (text === \"\") return [];\n const out: string[] = [];\n let start = 0;\n for (let i = 0; i < text.length; i += 1) {\n if (text[i] === \"\\n\") {\n out.push(text.slice(start, i + 1));\n start = i + 1;\n }\n }\n if (start < text.length) out.push(text.slice(start));\n return out;\n}\n\n/**\n * A minimal line-level diff producing jsdiff-compatible `Change[]` records\n * (`{ value }` for context, `{ value, added: true }`, `{ value, removed: true }`).\n * Uses a classic LCS table over line tokens; the inputs here are short code\n * snippets so the O(n·m) table is fine. Removed lines are emitted before added\n * lines within a change region, matching jsdiff's ordering.\n */\nexport function diffLines(before: string, after: string): Change[] {\n const a = toLineTokens(before);\n const b = toLineTokens(after);\n const n = a.length;\n const m = b.length;\n const cells = (n + 1) * (m + 1);\n\n if (cells > MAX_DIFF_LCS_CELLS) {\n return [\n ...(before ? [{ value: before, removed: true }] : []),\n ...(after ? [{ value: after, added: true }] : []),\n ];\n }\n\n // LCS length table.\n const lcs: number[][] = Array.from({ length: n + 1 }, () =>\n new Array<number>(m + 1).fill(0),\n );\n for (let i = n - 1; i >= 0; i -= 1) {\n for (let j = m - 1; j >= 0; j -= 1) {\n lcs[i][j] =\n a[i] === b[j]\n ? lcs[i + 1][j + 1] + 1\n : Math.max(lcs[i + 1][j], lcs[i][j + 1]);\n }\n }\n\n const changes: Change[] = [];\n // Push a token onto the last change if same kind, else open a new change.\n const push = (value: string, kind: \"context\" | \"added\" | \"removed\") => {\n const last = changes[changes.length - 1];\n const sameKind =\n last &&\n Boolean(last.added) === (kind === \"added\") &&\n Boolean(last.removed) === (kind === \"removed\");\n if (sameKind) {\n last.value += value;\n } else {\n changes.push({\n value,\n added: kind === \"added\" ? true : undefined,\n removed: kind === \"removed\" ? true : undefined,\n });\n }\n };\n\n let i = 0;\n let j = 0;\n while (i < n && j < m) {\n if (a[i] === b[j]) {\n push(a[i], \"context\");\n i += 1;\n j += 1;\n } else if (lcs[i + 1][j] >= lcs[i][j + 1]) {\n push(a[i], \"removed\");\n i += 1;\n } else {\n push(b[j], \"added\");\n j += 1;\n }\n }\n while (i < n) {\n push(a[i], \"removed\");\n i += 1;\n }\n while (j < m) {\n push(b[j], \"added\");\n j += 1;\n }\n return changes;\n}\n\n/* ── Syntax highlighting ───────────────────────────────────────────────────── */\n\nconst lowlight = createLowlight(common);\n\ntype LowlightNode = {\n type: string;\n value?: string;\n properties?: {\n className?: string[] | string;\n };\n children?: LowlightNode[];\n};\n\nconst LANGUAGE_ALIASES: Record<string, string> = {\n cjs: \"javascript\",\n cts: \"typescript\",\n htm: \"html\",\n js: \"javascript\",\n jsonc: \"json\",\n jsx: \"jsx\",\n md: \"markdown\",\n mdx: \"markdown\",\n mjs: \"javascript\",\n mts: \"typescript\",\n py: \"python\",\n rb: \"ruby\",\n rs: \"rust\",\n sh: \"bash\",\n shell: \"bash\",\n ts: \"typescript\",\n tsx: \"tsx\",\n yml: \"yaml\",\n zsh: \"bash\",\n};\n\nconst TOKEN_CLASS_NAMES: Record<string, string> = {\n \"hljs-addition\": \"text-emerald-700 dark:text-emerald-300\",\n \"hljs-attr\": \"text-primary\",\n \"hljs-attribute\": \"text-primary\",\n \"hljs-built_in\": \"text-amber-700 dark:text-amber-300\",\n \"hljs-bullet\": \"text-primary\",\n \"hljs-comment\": \"text-muted-foreground italic\",\n \"hljs-deletion\": \"text-destructive\",\n \"hljs-doctag\": \"text-destructive\",\n \"hljs-emphasis\": \"italic\",\n \"hljs-formula\": \"text-destructive\",\n \"hljs-keyword\": \"text-destructive\",\n \"hljs-link\": \"text-primary underline-offset-2\",\n \"hljs-literal\": \"text-primary\",\n \"hljs-meta\": \"text-primary\",\n \"hljs-meta-string\": \"text-emerald-700 dark:text-emerald-300\",\n \"hljs-name\": \"text-emerald-700 dark:text-emerald-300\",\n \"hljs-number\": \"text-primary\",\n \"hljs-params\": \"text-primary\",\n \"hljs-property\": \"text-primary\",\n \"hljs-quote\": \"text-muted-foreground italic\",\n \"hljs-regexp\": \"text-emerald-700 dark:text-emerald-300\",\n \"hljs-section\": \"text-violet-700 dark:text-violet-300\",\n \"hljs-selector-attr\": \"text-primary\",\n \"hljs-selector-class\": \"text-emerald-700 dark:text-emerald-300\",\n \"hljs-selector-id\": \"text-emerald-700 dark:text-emerald-300\",\n \"hljs-selector-pseudo\": \"text-primary\",\n \"hljs-selector-tag\": \"text-emerald-700 dark:text-emerald-300\",\n \"hljs-string\": \"text-emerald-700 dark:text-emerald-300\",\n \"hljs-strong\": \"font-semibold\",\n \"hljs-subst\": \"text-destructive\",\n \"hljs-symbol\": \"text-primary\",\n \"hljs-tag\": \"text-emerald-700 dark:text-emerald-300\",\n \"hljs-template-variable\": \"text-amber-700 dark:text-amber-300\",\n \"hljs-title\": \"text-violet-700 dark:text-violet-300\",\n \"hljs-type\": \"text-amber-700 dark:text-amber-300\",\n \"hljs-variable\": \"text-amber-700 dark:text-amber-300\",\n language_: \"text-amber-700 dark:text-amber-300\",\n};\n\nfunction normalizeLanguage(value?: string | null): string | null {\n const raw = value?.trim().toLowerCase();\n if (!raw) return null;\n const normalized = LANGUAGE_ALIASES[raw] ?? raw;\n return lowlight.registered(normalized) ? normalized : null;\n}\n\nfunction getLanguageFromFilename(filename?: string): string | null {\n const basename = filename?.split(\"/\").pop()?.toLowerCase();\n if (!basename) return null;\n if (basename === \"dockerfile\") return normalizeLanguage(\"bash\");\n if (basename === \"makefile\") return normalizeLanguage(\"makefile\");\n const ext = basename.includes(\".\") ? basename.split(\".\").pop() : basename;\n return normalizeLanguage(ext);\n}\n\nfunction resolveDiffLanguage(data: DiffData): string {\n return (\n normalizeLanguage(data.language) ??\n getLanguageFromFilename(data.filename) ??\n \"plaintext\"\n );\n}\n\nfunction tokenClassName(className?: string[] | string): string | undefined {\n const classes = Array.isArray(className)\n ? className\n : className\n ? className.split(/\\s+/)\n : [];\n const mapped = classes\n .map((name) => TOKEN_CLASS_NAMES[name])\n .filter(Boolean)\n .join(\" \");\n return mapped || undefined;\n}\n\nfunction hastToReact(children: LowlightNode[], keyPrefix: string): ReactNode[] {\n return children.map((node, index) => {\n if (node.type === \"text\") return node.value ?? \"\";\n if (node.type === \"element\") {\n const key = `${keyPrefix}${index}`;\n const renderedChildren = node.children?.length\n ? hastToReact(node.children, `${key}-`)\n : null;\n const className = tokenClassName(node.properties?.className);\n if (className) {\n return (\n <span key={key} className={className}>\n {renderedChildren}\n </span>\n );\n }\n return <span key={key}>{renderedChildren}</span>;\n }\n return null;\n });\n}\n\nfunction SyntaxHighlightedLine({\n code,\n language,\n}: {\n code: string;\n language: string;\n}) {\n const highlighted = useMemo(() => {\n if (!code.trim() || language === \"plaintext\" || language === \"text\") {\n return null;\n }\n try {\n const tree = lowlight.highlight(language, code) as LowlightNode;\n return hastToReact(tree.children ?? [], `${language}-`);\n } catch {\n return null;\n }\n }, [code, language]);\n\n return <>{highlighted ?? code}</>;\n}\n\n/* ── Diff model ────────────────────────────────────────────────────────────── */\n\ntype DiffRowKind = \"context\" | \"added\" | \"removed\";\n\ninterface DiffRow {\n kind: DiffRowKind;\n /** Line number in the OLD file (omitted for added rows). */\n oldNo?: number;\n /** Line number in the NEW file (omitted for removed rows). */\n newNo?: number;\n text: string;\n}\n\n/** A contiguous run of context lines collapsed when longer than the threshold. */\ninterface CollapsedRun {\n collapsed: true;\n rows: DiffRow[];\n}\n\ntype DiffSegment = DiffRow | CollapsedRun;\n\n/** Which column a split-view row belongs to (the unified view passes nothing). */\ntype RowSide = \"old\" | \"new\";\n\n/**\n * Resolve the markers landing on a row. `side` scopes the lookup to one column\n * in the split view (so a left cell only lights from `before` annotations and a\n * right cell from `after`); the unified view omits it to merge both sides.\n */\ntype MarkersForRow = (\n row: DiffRow,\n side?: RowSide,\n) => ResolvedAnnotation<DiffAnnotation>[];\n\n/** The default side an annotation targets when `side` is omitted. */\nfunction annotationSide(annotation: DiffAnnotation): \"before\" | \"after\" {\n return annotation.side === \"before\" ? \"before\" : \"after\";\n}\n\n/**\n * Count 1-based source lines in a side's text, matching how `buildRows` numbers\n * `oldNo`/`newNo`: a trailing newline does not add a phantom final line.\n */\nfunction countLines(text: string): number {\n if (text === \"\") return 0;\n return splitLines(text).length;\n}\n\n/** Number of context lines above which an unchanged run is collapsed. */\nconst COLLAPSE_THRESHOLD = 6;\n/** Context lines kept visible at each edge of a collapsed run. */\nconst CONTEXT_EDGE = 3;\n\n/**\n * Split a change `value` into individual lines. Most hunks carry a trailing\n * newline; drop the empty final element it produces so a 2-line change does not\n * render a phantom 3rd blank line.\n */\nfunction splitLines(value: string): string[] {\n const lines = value.split(\"\\n\");\n if (lines.length > 0 && lines[lines.length - 1] === \"\") lines.pop();\n return lines;\n}\n\n/** Flatten change objects into numbered diff rows. */\nfunction buildRows(changes: Change[]): DiffRow[] {\n const rows: DiffRow[] = [];\n let oldNo = 0;\n let newNo = 0;\n for (const change of changes) {\n const lines = splitLines(change.value);\n for (const text of lines) {\n if (change.added) {\n newNo += 1;\n rows.push({ kind: \"added\", newNo, text });\n } else if (change.removed) {\n oldNo += 1;\n rows.push({ kind: \"removed\", oldNo, text });\n } else {\n oldNo += 1;\n newNo += 1;\n rows.push({ kind: \"context\", oldNo, newNo, text });\n }\n }\n }\n return rows;\n}\n\n/**\n * Group rows into segments, collapsing interior runs of >COLLAPSE_THRESHOLD\n * context rows (keeping CONTEXT_EDGE visible at each side). Leading/trailing runs\n * collapse too, but keep only the inner edge visible.\n *\n * `isAnchored` marks context rows that carry an annotation (or sit adjacent to\n * one): an anchored row is NEVER hidden inside a collapsed run, so a note that\n * targets an unchanged line stays reachable. An anchor splits its run into the\n * separately-collapsible spans on either side of it, with CONTEXT_EDGE rows kept\n * visible around the anchor.\n */\nfunction segmentRows(\n rows: DiffRow[],\n isAnchored?: (row: DiffRow) => boolean,\n): DiffSegment[] {\n const segments: DiffSegment[] = [];\n\n // Collapse one contiguous context run [from, to) that contains NO anchors.\n const collapseRun = (run: DiffRow[], atStart: boolean, atEnd: boolean) => {\n if (run.length <= COLLAPSE_THRESHOLD) {\n for (const row of run) segments.push(row);\n return;\n }\n const head = atStart ? [] : run.slice(0, CONTEXT_EDGE);\n const tail = atEnd ? [] : run.slice(run.length - CONTEXT_EDGE);\n const hidden = run.slice(head.length, run.length - tail.length);\n for (const row of head) segments.push(row);\n if (hidden.length > 0) segments.push({ collapsed: true, rows: hidden });\n for (const row of tail) segments.push(row);\n };\n\n let i = 0;\n while (i < rows.length) {\n if (rows[i].kind !== \"context\") {\n segments.push(rows[i]);\n i += 1;\n continue;\n }\n // Gather the full contiguous context run.\n let j = i;\n while (j < rows.length && rows[j].kind === \"context\") j += 1;\n const fullRun = rows.slice(i, j);\n const runAtStart = i === 0;\n const runAtEnd = j === rows.length;\n\n if (!isAnchored || !fullRun.some(isAnchored)) {\n collapseRun(fullRun, runAtStart, runAtEnd);\n } else {\n // Walk the run, emitting anchored rows verbatim and collapsing the\n // unanchored spans between them. An anchored row is always visible; the\n // spans on each side of it collapse independently.\n let spanStart = 0;\n for (let k = 0; k <= fullRun.length; k += 1) {\n const atAnchor = k < fullRun.length && isAnchored(fullRun[k]);\n if (atAnchor || k === fullRun.length) {\n const span = fullRun.slice(spanStart, k);\n if (span.length > 0) {\n collapseRun(\n span,\n runAtStart && spanStart === 0,\n runAtEnd && k === fullRun.length,\n );\n }\n if (k < fullRun.length) segments.push(fullRun[k]);\n spanStart = k + 1;\n }\n }\n }\n i = j;\n }\n return segments;\n}\n\n/* ── Theme-aware row styling (light + dark) ────────────────────────────────── */\n\nconst ROW_BG: Record<DiffRowKind, string> = {\n added: \"bg-emerald-500/10 dark:bg-emerald-500/15\",\n removed: \"bg-destructive/10\",\n context: \"bg-background\",\n};\n\nconst GUTTER_BG: Record<DiffRowKind, string> = {\n added: \"bg-emerald-500/15 dark:bg-emerald-500/20\",\n removed: \"bg-destructive/15\",\n context: \"bg-muted/60\",\n};\n\nconst SIGN_COLOR: Record<DiffRowKind, string> = {\n added: \"text-emerald-700 dark:text-emerald-300\",\n removed: \"text-destructive\",\n context: \"text-muted-foreground\",\n};\n\nconst SIGN: Record<DiffRowKind, string> = {\n added: \"+\",\n removed: \"−\",\n context: \" \",\n};\n\nconst LINE_NO_CLASS =\n \"select-none px-2 py-0 text-right font-mono [font-size:var(--plan-doc-code-size)] leading-5 text-muted-foreground tabular-nums\";\n\nconst DIFF_LINE_CLASS =\n \"block min-w-max flex-1 whitespace-pre px-2 py-0 font-mono [font-size:var(--plan-doc-code-size)] leading-5 text-foreground\";\n\nconst DEFAULT_VISIBLE_DIFF_LINES = 15;\nconst MAX_DIFF_LCS_CELLS = 1_000_000;\nconst DIFF_MODE_STORAGE_KEY = \"agent-native:diff-view-mode\";\nconst DIFF_MODE_STORAGE_EVENT = \"agent-native:diff-view-mode-change\";\n\n/**\n * Below this rendered container width (px) a diff drops side-by-side `split`\n * mode and falls back to `unified`: split's two line-number gutters double the\n * width the code needs, exactly where space is tightest (e.g. a diff nested in a\n * vertical-tabs content column). Measured from the block's own box, not the\n * viewport, so the fallback fires by available width at any nesting depth.\n */\nconst SPLIT_MIN_WIDTH = 560;\n\n/**\n * Observe the rendered inline width of an element. Returns a ref to attach plus\n * the measured content-box width (null until the first ResizeObserver tick).\n * Lets the diff pick an effective mode from the width it was actually handed — a\n * measurement CSS container queries can't drive, since switching split↔unified\n * is a structural (DOM) change, not a style toggle.\n */\nfunction useContainerWidth<T extends HTMLElement>() {\n const ref = useRef<T | null>(null);\n const [width, setWidth] = useState<number | null>(null);\n useEffect(() => {\n const el = ref.current;\n if (!el || typeof ResizeObserver === \"undefined\") return;\n const observer = new ResizeObserver((entries) => {\n const entry = entries[0];\n if (entry) setWidth(entry.contentRect.width);\n });\n observer.observe(el);\n return () => observer.disconnect();\n }, []);\n return [ref, width] as const;\n}\n\nfunction isDiffMode(value: unknown): value is DiffMode {\n return value === \"unified\" || value === \"split\";\n}\n\nfunction readStoredDiffMode(): DiffMode | null {\n if (typeof window === \"undefined\") return null;\n try {\n const value = window.localStorage?.getItem(DIFF_MODE_STORAGE_KEY);\n return isDiffMode(value) ? value : null;\n } catch {\n return null;\n }\n}\n\nfunction writeStoredDiffMode(mode: DiffMode): void {\n if (typeof window === \"undefined\") return;\n try {\n window.localStorage?.setItem(DIFF_MODE_STORAGE_KEY, mode);\n } catch {\n // Storage may be unavailable in sandboxed/private contexts.\n }\n}\n\nfunction dispatchDiffModeChange(mode: DiffMode): void {\n if (typeof window === \"undefined\") return;\n try {\n window.dispatchEvent(\n new CustomEvent<DiffMode>(DIFF_MODE_STORAGE_EVENT, { detail: mode }),\n );\n } catch {\n // Best-effort sync; local component state and storage already changed.\n }\n}\n\nfunction usePreferredDiffMode(authoredMode: DiffMode | undefined) {\n const [mode, setMode] = useState<DiffMode>(authoredMode ?? \"split\");\n\n useEffect(() => {\n if (authoredMode) return;\n const storedMode = readStoredDiffMode();\n if (storedMode) setMode(storedMode);\n }, [authoredMode]);\n\n useEffect(() => {\n if (authoredMode) return;\n if (typeof window === \"undefined\") return;\n\n const onStorage = (event: StorageEvent) => {\n if (event.key !== DIFF_MODE_STORAGE_KEY) return;\n if (isDiffMode(event.newValue)) setMode(event.newValue);\n };\n const onModeChange = (event: Event) => {\n const mode = (event as CustomEvent<unknown>).detail;\n if (isDiffMode(mode)) setMode(mode);\n };\n\n window.addEventListener(\"storage\", onStorage);\n window.addEventListener(DIFF_MODE_STORAGE_EVENT, onModeChange);\n return () => {\n window.removeEventListener(\"storage\", onStorage);\n window.removeEventListener(DIFF_MODE_STORAGE_EVENT, onModeChange);\n };\n }, [authoredMode]);\n\n const setPreferredMode = useCallback((nextMode: DiffMode) => {\n setMode(nextMode);\n writeStoredDiffMode(nextMode);\n dispatchDiffModeChange(nextMode);\n }, []);\n\n return [mode, setPreferredMode] as const;\n}\n\nfunction splitDiffFilename(filename?: string): {\n basename: string;\n directory: string | null;\n} {\n const value = filename?.trim() || \"diff\";\n const segments = value.split(\"/\").filter(Boolean);\n const basename = segments[segments.length - 1] ?? value;\n const directory =\n segments.length > 1 ? segments.slice(0, -1).join(\"/\") : null;\n return { basename, directory };\n}\n\nfunction DiffLineText({ language, text }: { language: string; text: string }) {\n const code = text || \" \";\n return (\n <span className={DIFF_LINE_CLASS}>\n <SyntaxHighlightedLine code={code} language={language} />\n </span>\n );\n}\n\n/* ── Read ──────────────────────────────────────────────────────────────────── */\n\nfunction DiffRead({\n data,\n blockId,\n title,\n summary,\n ctx,\n}: BlockReadProps<DiffData>) {\n // Default layout when none is authored is SPLIT so reviewers can compare\n // before/after code side-by-side. An explicitly authored `mode` or stored\n // viewer preference still wins, and truly narrow hosts can fall back below.\n const inNarrowContainer = useInNarrowContainer();\n const [mode, setMode] = usePreferredDiffMode(data.mode);\n const [expanded, setExpanded] = useState<Set<number>>(() => new Set());\n const [showAllRows, setShowAllRows] = useState(false);\n const [containerRef, containerWidth] = useContainerWidth<HTMLElement>();\n // On-hover popover (anchored to the right of the code) replaces the old\n // persistent rail: nothing is shown when idle. `codeRef` measures the code\n // box's right edge; `hover` carries the active index + captured geometry.\n const hover = useAnnotationHover();\n const { activeIndex } = hover;\n const codeRef = useRef<HTMLDivElement | null>(null);\n\n const rows = useMemo(\n () => buildRows(diffLines(data.before, data.after)),\n [data.before, data.after],\n );\n const language = useMemo(\n () => resolveDiffLanguage(data),\n [data.filename, data.language],\n );\n const fileParts = useMemo(\n () => splitDiffFilename(data.filename),\n [data.filename],\n );\n const splitLineCount = useMemo(() => pairSplitRows(rows).length, [rows]);\n\n // Resolve annotations against the side they target. A `before` annotation's\n // `lines` ref is clamped to the OLD file's line count and matched on `oldNo`;\n // an `after` (default) ref to the NEW file and matched on `newNo`. Markers are\n // authoring-order across BOTH sides so a note ↔ row ↔ rail card share one id.\n const beforeLineCount = useMemo(() => countLines(data.before), [data.before]);\n const afterLineCount = useMemo(() => countLines(data.after), [data.after]);\n const showAnnotationOverlays = Boolean(ctx.showCodeAnnotationOverlays);\n const annotationLayout = ctx.codeAnnotationLayout;\n const annotationHoverSide = annotationLayout?.hoverSide ?? \"right\";\n const annotationHoverFallbackSide =\n annotationLayout?.hoverFallbackSide ?? \"right\";\n const annotationMarginSide = annotationLayout?.marginSide ?? \"auto\";\n const resolved = useMemo(\n () =>\n resolveAnnotations(data.annotations, (annotation) =>\n annotationSide(annotation) === \"before\"\n ? beforeLineCount\n : afterLineCount,\n ),\n [data.annotations, beforeLineCount, afterLineCount],\n );\n const hasAnnotations = hasRailAnnotations(resolved);\n const showMarginAnnotations = useAnnotationMarginNotesAvailable({\n containerRef: codeRef,\n enabled: Boolean(\n hasAnnotations &&\n !showAnnotationOverlays &&\n annotationLayout?.showByDefaultWhenRoom,\n ),\n side: annotationMarginSide,\n preferredSide: annotationHoverSide,\n });\n const showPersistentAnnotations =\n showAnnotationOverlays || showMarginAnnotations;\n const captureOverlayAnnotationIndex = useMemo(\n () => resolved.find((item) => item.range)?.index ?? null,\n [resolved],\n );\n // Effective render mode. Annotations live in a SEPARATE right-hand rail (not\n // over the code), so they no longer force a mode. When no mode was authored, a\n // truly narrow container still falls back to unified so split's doubled\n // gutters never crush the code; an explicitly authored `mode` wins even in a\n // narrow host. `canSplit` only hides the toggle for auto-mode narrow fallbacks.\n const measuredNarrow =\n containerWidth != null && containerWidth < SPLIT_MIN_WIDTH;\n const narrow = data.mode == null && (measuredNarrow || inNarrowContainer);\n const canSplit = !narrow;\n const effectiveMode: DiffMode = canSplit ? mode : \"unified\";\n\n // Annotations (diff): NO persistent column. Hovering a marked code line (or\n // its numbered pip) opens THAT note's card as an on-hover popover anchored to\n // the RIGHT of the code box, never over the code. The in-code pip stays as the\n // anchor indicator + active-line highlight. `onRowEnter` captures the code\n // box's right edge + the hovered row's vertical position to place the card;\n // `onRowLeave` schedules a short-delay close so the pointer can cross the gap\n // into the card (which cancels the close while hovered).\n const onRowEnter = useCallback(\n (index: number, rowEl: HTMLElement) => {\n const startRow =\n codeRef.current?.querySelector<HTMLElement>(\n `[data-annot-row=\"${index}\"]`,\n ) ?? rowEl;\n const anchor = anchorFromElements(codeRef.current, startRow);\n if (anchor) hover.open(index, anchor);\n },\n [hover],\n );\n const onRowLeave = useCallback(() => hover.scheduleClose(), [hover]);\n const onRowClick = useCallback(\n (index: number, rowEl: HTMLElement) => {\n const startRow =\n codeRef.current?.querySelector<HTMLElement>(\n `[data-annot-row=\"${index}\"]`,\n ) ?? rowEl;\n const anchor = anchorFromElements(codeRef.current, startRow);\n if (anchor) hover.open(index, anchor);\n },\n [hover],\n );\n // Side-scoped line → markers maps so a row only lights from its own side.\n const beforeMarkers = useMemo(\n () =>\n buildLineMarkerMap(\n resolved.filter((r) => annotationSide(r.annotation) === \"before\"),\n ),\n [resolved],\n );\n const afterMarkers = useMemo(\n () =>\n buildLineMarkerMap(\n resolved.filter((r) => annotationSide(r.annotation) !== \"before\"),\n ),\n [resolved],\n );\n const markersForRow = useMemo<MarkersForRow>(() => {\n return (row, side) => {\n const out: ResolvedAnnotation<DiffAnnotation>[] = [];\n if (\n (side === undefined || side === \"old\") &&\n row.oldNo != null &&\n row.kind !== \"added\"\n ) {\n out.push(...(beforeMarkers.get(row.oldNo) ?? []));\n }\n if (\n (side === undefined || side === \"new\") &&\n row.newNo != null &&\n row.kind !== \"removed\"\n ) {\n out.push(...(afterMarkers.get(row.newNo) ?? []));\n }\n return out;\n };\n }, [beforeMarkers, afterMarkers]);\n // A context row that carries a marker is an anchor: never collapse it away.\n const anchoredRow = useMemo(() => {\n if (!hasAnnotations) return undefined;\n return (row: DiffRow) => markersForRow(row).length > 0;\n }, [hasAnnotations, markersForRow]);\n\n // The resolved annotation whose card is currently shown on hover.\n const activeItem = useMemo<ResolvedAnnotation<DiffAnnotation> | null>(\n () =>\n activeIndex == null\n ? null\n : (resolved.find((item) => item.index === activeIndex) ?? null),\n [activeIndex, resolved],\n );\n\n const added = rows.filter((r) => r.kind === \"added\").length;\n const removed = rows.filter((r) => r.kind === \"removed\").length;\n const unchanged = data.before === data.after;\n const totalVisibleLineCount =\n effectiveMode === \"split\" ? splitLineCount : rows.length;\n const shouldLimitRows = totalVisibleLineCount > DEFAULT_VISIBLE_DIFF_LINES;\n // Never truncate away an annotated row: extend the window past the last one.\n const effectiveRowLimit = useMemo(() => {\n if (showAllRows || !shouldLimitRows) return undefined;\n let limit = DEFAULT_VISIBLE_DIFF_LINES;\n if (hasAnnotations) {\n for (let idx = rows.length - 1; idx >= limit; idx -= 1) {\n if (markersForRow(rows[idx]).length > 0) {\n limit = idx + 1;\n break;\n }\n }\n }\n return limit;\n }, [showAllRows, shouldLimitRows, hasAnnotations, rows, markersForRow]);\n const rowLimit = effectiveRowLimit;\n const displayedRows =\n effectiveMode === \"unified\" && rowLimit ? rows.slice(0, rowLimit) : rows;\n\n const toggleRun = (index: number) =>\n setExpanded((prev) => {\n const next = new Set(prev);\n if (next.has(index)) next.delete(index);\n else next.add(index);\n return next;\n });\n\n // The bordered code box. It always spans its full width — annotations surface\n // as an on-hover popover anchored to this box's right edge, never as a column.\n // `codeRef` measures that right edge for the popover's placement.\n const diffBox = (\n <div\n ref={codeRef}\n className=\"overflow-hidden rounded-md border border-border bg-background\"\n >\n {/* Header: filename, path, +/− counts, mode toggle. */}\n <div className=\"flex min-h-10 flex-wrap items-center gap-2 border-b border-border bg-muted/60 px-3 py-1.5\">\n <IconFileDiff className=\"size-4 shrink-0 text-muted-foreground\" />\n <span\n className=\"flex min-w-0 flex-1 items-baseline gap-1.5 font-mono\"\n title={data.filename || undefined}\n >\n <span className=\"min-w-0 max-w-[16rem] truncate text-[13px] font-semibold leading-5 text-foreground\">\n {fileParts.basename}\n </span>\n {fileParts.directory && (\n <span className=\"min-w-0 flex-1 truncate text-[11px] leading-5 text-muted-foreground/70\">\n {fileParts.directory}\n </span>\n )}\n </span>\n <span className=\"ml-1 flex shrink-0 items-center gap-2 font-mono text-xs\">\n <span className=\"text-emerald-700 dark:text-emerald-300\">\n +{added}\n </span>\n <span className=\"text-destructive\">−{removed}</span>\n </span>\n {/* Mode toggle only when split is actually available: a narrow\n container forces unified (split's doubled gutters would crush the\n code), so the toggle would otherwise be a no-op. Annotations are an\n on-hover popover now, so they work in both unified and split. */}\n {canSplit && (\n <div className=\"pointer-events-none ml-auto flex shrink-0 items-center overflow-hidden rounded-md border border-border bg-background opacity-0 transition-opacity group-hover/diff-block:pointer-events-auto group-hover/diff-block:opacity-100 group-focus-within/diff-block:pointer-events-auto group-focus-within/diff-block:opacity-100\">\n <ModeButton\n active={mode === \"unified\"}\n onClick={() => setMode(\"unified\")}\n icon={<IconList className=\"size-3.5\" />}\n label=\"Unified\"\n />\n <ModeButton\n active={mode === \"split\"}\n onClick={() => setMode(\"split\")}\n icon={<IconColumns className=\"size-3.5\" />}\n label=\"Split\"\n />\n </div>\n )}\n </div>\n\n {/* Body. */}\n {unchanged ? (\n <div className=\"px-4 py-6 text-center font-mono text-sm text-muted-foreground\">\n No changes\n </div>\n ) : effectiveMode === \"split\" ? (\n <SplitView\n rows={rows}\n language={language}\n rowLimit={rowLimit}\n markersForRow={markersForRow}\n activeIndex={activeIndex}\n onRowEnter={onRowEnter}\n onRowLeave={onRowLeave}\n onRowClick={onRowClick}\n showAnnotationOverlays={showPersistentAnnotations}\n annotationOverlayMode={showAnnotationOverlays ? \"capture\" : \"margin\"}\n annotationOverlaySide={\n showAnnotationOverlays ? \"right\" : annotationMarginSide\n }\n annotationOverlayPreferredSide={annotationHoverSide}\n annotationOverlayContainerRef={codeRef}\n captureOverlayAnnotationIndex={captureOverlayAnnotationIndex}\n ctx={ctx}\n />\n ) : (\n <UnifiedView\n rows={displayedRows}\n language={language}\n expanded={expanded}\n onToggleRun={toggleRun}\n markersForRow={markersForRow}\n anchoredRow={anchoredRow}\n activeIndex={activeIndex}\n onRowEnter={onRowEnter}\n onRowLeave={onRowLeave}\n onRowClick={onRowClick}\n showAnnotationOverlays={showPersistentAnnotations}\n annotationOverlayMode={showAnnotationOverlays ? \"capture\" : \"margin\"}\n annotationOverlaySide={\n showAnnotationOverlays ? \"right\" : annotationMarginSide\n }\n annotationOverlayPreferredSide={annotationHoverSide}\n annotationOverlayContainerRef={codeRef}\n captureOverlayAnnotationIndex={captureOverlayAnnotationIndex}\n ctx={ctx}\n />\n )}\n {!unchanged && shouldLimitRows && (\n <button\n type=\"button\"\n data-plan-interactive\n aria-expanded={showAllRows}\n onClick={() => setShowAllRows((current) => !current)}\n className=\"flex h-7 w-full items-center justify-center gap-1.5 border-t border-border bg-background px-2 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-muted/70 hover:text-foreground\"\n >\n <IconChevronRight\n className={cn(\n \"size-3 shrink-0 transition-transform\",\n showAllRows ? \"-rotate-90\" : \"rotate-90\",\n )}\n />\n {showAllRows\n ? \"Show fewer\"\n : `Show all ${totalVisibleLineCount} lines`}\n </button>\n )}\n </div>\n );\n\n return (\n <section\n {...ltrCodeBlockProps}\n ref={containerRef}\n className=\"relative plan-block group/diff-block\"\n data-block-id={blockId}\n >\n {title && <div className=\"plan-block-label\">{title}</div>}\n {summary && (\n <p className=\"mb-3 text-sm leading-relaxed text-plan-muted\">\n {summary}\n </p>\n )}\n {/* The diff keeps its full width — no persistent annotation column. The\n in-code numbered pips remain the hover anchors; notes live in a\n visually-hidden stack (a11y + tests) and surface ONE at a time as an\n on-hover popover anchored to the right of the code box. */}\n {diffBox}\n {hasAnnotations && (\n <AnnotationHiddenStack items={resolved} ctx={ctx} showMarker />\n )}\n {hasAnnotations &&\n !showPersistentAnnotations &&\n activeItem &&\n hover.anchor && (\n <AnnotationHoverCard\n item={activeItem}\n anchor={hover.anchor}\n ctx={ctx}\n showMarker\n preferredSide={annotationHoverSide}\n hoverFallbackSide={annotationHoverFallbackSide}\n onMouseEnter={hover.cancelClose}\n onMouseLeave={hover.scheduleClose}\n onClose={hover.closeForScroll}\n />\n )}\n </section>\n );\n}\n\nfunction ModeButton({\n active,\n onClick,\n icon,\n label,\n}: {\n active: boolean;\n onClick: () => void;\n icon: ReactNode;\n label: string;\n}) {\n return (\n <button\n type=\"button\"\n data-plan-interactive\n onClick={onClick}\n aria-pressed={active}\n className={cn(\n \"flex cursor-pointer items-center gap-1 px-2 py-1 text-xs font-medium transition-colors\",\n active\n ? \"bg-accent text-accent-foreground\"\n : \"text-muted-foreground hover:bg-muted/80 hover:text-foreground\",\n )}\n >\n {icon}\n {label}\n </button>\n );\n}\n\n/* ── Annotation wiring shared by both views ────────────────────────────────── */\n\n/** Marker + hover props threaded into the unified/split rows. */\ninterface RowAnnotationProps {\n markersForRow: MarkersForRow;\n anchoredRow?: (row: DiffRow) => boolean;\n activeIndex: number | null;\n showAnnotationOverlays: boolean;\n ctx: BlockRenderContext;\n /** Hovering an annotated row opens its popover, anchored to this row's box. */\n onRowEnter: (index: number, rowEl: HTMLElement) => void;\n /** Leaving an annotated row schedules the popover's close. */\n onRowLeave: () => void;\n /** Clicking/tapping an annotated row toggles its popover (for touch). */\n onRowClick: (index: number, rowEl: HTMLElement) => void;\n annotationOverlayMode: \"capture\" | \"margin\";\n annotationOverlaySide: AnnotationMarginSide;\n annotationOverlayPreferredSide: AnnotationSide;\n annotationOverlayContainerRef: RefObject<HTMLElement | null>;\n captureOverlayAnnotationIndex: number | null;\n}\n\n/**\n * The numbered marker pip(s) for a row plus the active-state it derives. Returns\n * `null` when the row carries no annotation so unannotated diffs render an empty\n * marker column (or no column at all when the whole diff is unannotated).\n */\nfunction rowMarkerInfo(\n markers: ResolvedAnnotation<DiffAnnotation>[],\n activeIndex: number | null,\n): { isActive: boolean; primaryIndex: number } | null {\n if (markers.length === 0) return null;\n const isActive = markers.some((m) => m.index === activeIndex);\n return { isActive, primaryIndex: markers[0].index };\n}\n\n/** Shared amber wash for an annotated row, brighter when active. */\nfunction annotatedRowBg(info: { isActive: boolean } | null): string | null {\n if (!info) return null;\n return info.isActive\n ? \"bg-amber-400/[0.12] dark:bg-amber-300/[0.10]\"\n : \"bg-amber-400/[0.045] dark:bg-amber-300/[0.045]\";\n}\n\n/**\n * Whether `row` is the FIRST line of `marker`'s resolved range. The numbered pip\n * renders only on this line, so a multi-line annotation shows a single marker at\n * the top of its span instead of repeating the same number down every line it\n * covers. The amber band still washes the whole range (via `annotatedRowBg`), so\n * the span stays visually grouped without the column of duplicate numbers.\n */\nfunction isMarkerRangeStart(\n row: DiffRow,\n marker: ResolvedAnnotation<DiffAnnotation>,\n): boolean {\n if (!marker.range) return false;\n const lineNo =\n annotationSide(marker.annotation) === \"before\" ? row.oldNo : row.newNo;\n return lineNo === marker.range.start;\n}\n\n/* ── Unified view ──────────────────────────────────────────────────────────── */\n\nfunction UnifiedView({\n rows,\n language,\n expanded,\n onToggleRun,\n markersForRow,\n anchoredRow,\n activeIndex,\n onRowEnter,\n onRowLeave,\n onRowClick,\n showAnnotationOverlays,\n annotationOverlayMode,\n annotationOverlaySide,\n annotationOverlayPreferredSide,\n annotationOverlayContainerRef,\n captureOverlayAnnotationIndex,\n ctx,\n}: {\n rows: DiffRow[];\n language: string;\n expanded: Set<number>;\n onToggleRun: (index: number) => void;\n} & RowAnnotationProps) {\n const segments = useMemo(\n () => segmentRows(rows, anchoredRow),\n [rows, anchoredRow],\n );\n // Any annotation present ⇒ reserve the marker column so rows stay aligned.\n const showMarkerColumn = useMemo(\n () => rows.some((row) => markersForRow(row).length > 0),\n [rows, markersForRow],\n );\n const rowProps = {\n language,\n markersForRow,\n activeIndex,\n onRowEnter,\n onRowLeave,\n onRowClick,\n showMarkerColumn,\n showAnnotationOverlays,\n annotationOverlayMode,\n annotationOverlaySide,\n annotationOverlayPreferredSide,\n annotationOverlayContainerRef,\n captureOverlayAnnotationIndex,\n ctx,\n };\n let runIndex = 0;\n return (\n <div className=\"overflow-x-auto\" data-code-surface>\n <div className=\"w-max min-w-full font-mono [font-size:var(--plan-doc-code-size)] leading-5\">\n {segments.map((segment, idx) => {\n if (\"collapsed\" in segment) {\n const key = runIndex++;\n const open = expanded.has(key);\n return (\n <div key={`run-${key}`}>\n <CollapsedRow\n count={segment.rows.length}\n open={open}\n onClick={() => onToggleRun(key)}\n />\n {open &&\n segment.rows.map((row, ri) => (\n <UnifiedRow\n key={`run-${key}-${ri}`}\n row={row}\n {...rowProps}\n />\n ))}\n </div>\n );\n }\n return <UnifiedRow key={idx} row={segment} {...rowProps} />;\n })}\n </div>\n </div>\n );\n}\n\nfunction UnifiedRow({\n language,\n row,\n markersForRow,\n activeIndex,\n onRowEnter,\n onRowLeave,\n onRowClick,\n showMarkerColumn,\n showAnnotationOverlays,\n annotationOverlayMode,\n annotationOverlaySide,\n annotationOverlayPreferredSide,\n annotationOverlayContainerRef,\n captureOverlayAnnotationIndex,\n ctx,\n}: {\n language: string;\n row: DiffRow;\n markersForRow: MarkersForRow;\n activeIndex: number | null;\n onRowEnter: (index: number, rowEl: HTMLElement) => void;\n onRowLeave: () => void;\n onRowClick: (index: number, rowEl: HTMLElement) => void;\n showMarkerColumn: boolean;\n showAnnotationOverlays: boolean;\n annotationOverlayMode: \"capture\" | \"margin\";\n annotationOverlaySide: AnnotationMarginSide;\n annotationOverlayPreferredSide: AnnotationSide;\n annotationOverlayContainerRef: RefObject<HTMLElement | null>;\n captureOverlayAnnotationIndex: number | null;\n ctx: BlockRenderContext;\n}) {\n const markers = markersForRow(row);\n const info = rowMarkerInfo(markers, activeIndex);\n const startMarker = markers.find((marker) => isMarkerRangeStart(row, marker));\n const primaryIndex = startMarker?.index ?? info?.primaryIndex;\n const overlayItems =\n showAnnotationOverlays &&\n startMarker &&\n (annotationOverlayMode !== \"capture\" ||\n startMarker.index === captureOverlayAnnotationIndex)\n ? [startMarker]\n : [];\n return (\n <div\n data-annot-row={startMarker ? startMarker.index : undefined}\n tabIndex={info ? 0 : undefined}\n role={info ? \"button\" : undefined}\n aria-expanded={info ? info.isActive : undefined}\n className={cn(\n \"relative flex min-h-5 min-w-full\",\n info && \"cursor-pointer\",\n ROW_BG[row.kind],\n annotatedRowBg(info),\n )}\n onMouseEnter={\n info && primaryIndex != null\n ? (event) => onRowEnter(primaryIndex, event.currentTarget)\n : undefined\n }\n onMouseLeave={info ? () => onRowLeave() : undefined}\n onClick={\n info && primaryIndex != null\n ? (event) => onRowClick(primaryIndex, event.currentTarget)\n : undefined\n }\n onKeyDown={\n info && primaryIndex != null\n ? (event) => {\n if (event.key !== \"Enter\" && event.key !== \" \") return;\n event.preventDefault();\n onRowClick(primaryIndex, event.currentTarget);\n }\n : undefined\n }\n onFocus={\n info && primaryIndex != null\n ? (event) => onRowEnter(primaryIndex, event.currentTarget)\n : undefined\n }\n onBlur={info ? () => onRowLeave() : undefined}\n >\n <span className={cn(LINE_NO_CLASS, \"w-[52px]\")}>{row.oldNo ?? \"\"}</span>\n <span className={cn(LINE_NO_CLASS, \"w-[52px]\")}>{row.newNo ?? \"\"}</span>\n <span\n className={cn(\n \"w-6 shrink-0 select-none py-0 text-center font-semibold leading-5\",\n GUTTER_BG[row.kind],\n SIGN_COLOR[row.kind],\n )}\n >\n {SIGN[row.kind]}\n </span>\n {showMarkerColumn && (\n <MarkerCell\n startMarker={startMarker}\n active={startMarker != null && startMarker.index === activeIndex}\n />\n )}\n <DiffLineText text={row.text} language={language} />\n {overlayItems.length > 0 && (\n <AnnotationInlineOverlayStack\n items={overlayItems}\n ctx={ctx}\n showMarker\n containerRef={annotationOverlayContainerRef}\n mode={annotationOverlayMode}\n side={annotationOverlaySide}\n preferredSide={annotationOverlayPreferredSide}\n />\n )}\n </div>\n );\n}\n\n/**\n * The fixed-width marker column rendered between the sign gutter and the code.\n * `startMarker` is set only on the FIRST line of an annotation's range, so the\n * numbered pip appears once at the top of a span; every other row (the rest of a\n * span, and every unannotated row in a diff that has annotations) renders an\n * empty spacer so the code text stays aligned.\n */\nfunction MarkerCell({\n startMarker,\n active,\n}: {\n startMarker?: ResolvedAnnotation<DiffAnnotation>;\n active: boolean;\n}) {\n return (\n <span className=\"flex w-6 shrink-0 select-none items-center justify-center py-0\">\n {startMarker != null && (\n <AnnotationGutterMarker marker={startMarker.marker} active={active} />\n )}\n </span>\n );\n}\n\nfunction CollapsedRow({\n count,\n open,\n onClick,\n}: {\n count: number;\n open: boolean;\n onClick: () => void;\n}) {\n return (\n <button\n type=\"button\"\n data-plan-interactive\n onClick={onClick}\n className=\"flex w-full cursor-pointer items-center gap-2 border-y border-border bg-muted/70 px-3 py-1 text-left text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground\"\n >\n <IconDotsVertical className=\"size-3.5 shrink-0\" />\n <span>\n {open ? \"Hide\" : \"Show\"} {count} unchanged line\n {count === 1 ? \"\" : \"s\"}\n </span>\n </button>\n );\n}\n\n/* ── Split (side-by-side) view ─────────────────────────────────────────────── */\n\ninterface SplitRow {\n left?: DiffRow;\n right?: DiffRow;\n}\n\n/**\n * Pair removed lines (left) with added lines (right) so a modification shows the\n * old and new side by side; context lines mirror on both columns. Leftover adds\n * or removes fall through as half-empty rows (GitHub split behavior).\n */\nfunction pairSplitRows(rows: DiffRow[]): SplitRow[] {\n const out: SplitRow[] = [];\n let i = 0;\n while (i < rows.length) {\n const row = rows[i];\n if (row.kind === \"context\") {\n out.push({ left: row, right: row });\n i += 1;\n continue;\n }\n // Collect a contiguous block of removed-then-added rows.\n const removed: DiffRow[] = [];\n const added: DiffRow[] = [];\n while (i < rows.length && rows[i].kind === \"removed\")\n removed.push(rows[i++]);\n while (i < rows.length && rows[i].kind === \"added\") added.push(rows[i++]);\n const max = Math.max(removed.length, added.length);\n for (let k = 0; k < max; k += 1) {\n out.push({ left: removed[k], right: added[k] });\n }\n }\n return out;\n}\n\nfunction SplitView({\n language,\n rowLimit,\n rows,\n markersForRow,\n activeIndex,\n onRowEnter,\n onRowLeave,\n onRowClick,\n showAnnotationOverlays,\n annotationOverlayMode,\n annotationOverlaySide,\n annotationOverlayPreferredSide,\n annotationOverlayContainerRef,\n captureOverlayAnnotationIndex,\n ctx,\n}: {\n language: string;\n rowLimit?: number;\n rows: DiffRow[];\n} & Omit<RowAnnotationProps, \"anchoredRow\">) {\n const pairs = useMemo(() => pairSplitRows(rows), [rows]);\n const displayedPairs = rowLimit ? pairs.slice(0, rowLimit) : pairs;\n // Reserve the marker column on a side only if any visible row there has one.\n const showOldMarkers = useMemo(\n () =>\n displayedPairs.some(\n (pair) => pair.left && markersForRow(pair.left, \"old\").length > 0,\n ),\n [displayedPairs, markersForRow],\n );\n const showNewMarkers = useMemo(\n () =>\n displayedPairs.some(\n (pair) => pair.right && markersForRow(pair.right, \"new\").length > 0,\n ),\n [displayedPairs, markersForRow],\n );\n const cellProps = {\n language,\n markersForRow,\n activeIndex,\n onRowEnter,\n onRowLeave,\n onRowClick,\n showAnnotationOverlays,\n annotationOverlayMode,\n annotationOverlaySide,\n annotationOverlayPreferredSide,\n annotationOverlayContainerRef,\n captureOverlayAnnotationIndex,\n ctx,\n };\n return (\n <div\n className=\"flex w-full bg-background font-mono [font-size:var(--plan-doc-code-size)] leading-5\"\n data-code-surface\n >\n <div className=\"min-w-0 flex-1 overflow-x-auto border-r border-border\">\n <div className=\"inline-block min-w-full\">\n {displayedPairs.map((pair, idx) => (\n <SplitCell\n key={`old-${idx}`}\n row={pair.left}\n side=\"old\"\n showMarkerColumn={showOldMarkers}\n {...cellProps}\n />\n ))}\n </div>\n </div>\n <div className=\"min-w-0 flex-1 overflow-x-auto\">\n <div className=\"inline-block min-w-full\">\n {displayedPairs.map((pair, idx) => (\n <SplitCell\n key={`new-${idx}`}\n row={pair.right}\n side=\"new\"\n showMarkerColumn={showNewMarkers}\n {...cellProps}\n />\n ))}\n </div>\n </div>\n </div>\n );\n}\n\nfunction SplitCell({\n language,\n row,\n side,\n markersForRow,\n activeIndex,\n onRowEnter,\n onRowLeave,\n onRowClick,\n showMarkerColumn,\n showAnnotationOverlays,\n annotationOverlayMode,\n annotationOverlaySide,\n annotationOverlayPreferredSide,\n annotationOverlayContainerRef,\n captureOverlayAnnotationIndex,\n ctx,\n}: {\n language: string;\n row?: DiffRow;\n side: RowSide;\n markersForRow: MarkersForRow;\n activeIndex: number | null;\n onRowEnter: (index: number, rowEl: HTMLElement) => void;\n onRowLeave: () => void;\n onRowClick: (index: number, rowEl: HTMLElement) => void;\n showMarkerColumn: boolean;\n showAnnotationOverlays: boolean;\n annotationOverlayMode: \"capture\" | \"margin\";\n annotationOverlaySide: AnnotationMarginSide;\n annotationOverlayPreferredSide: AnnotationSide;\n annotationOverlayContainerRef: RefObject<HTMLElement | null>;\n captureOverlayAnnotationIndex: number | null;\n ctx: BlockRenderContext;\n}) {\n if (!row) {\n return (\n <div className=\"flex min-h-5 min-w-full bg-muted/40 opacity-70\">\n <span className={cn(LINE_NO_CLASS, \"w-[52px]\")} />\n <span className=\"w-6 shrink-0 bg-muted/60\" />\n {showMarkerColumn && <span className=\"w-6 shrink-0\" />}\n <span className={DIFF_LINE_CLASS}> </span>\n </div>\n );\n }\n const sign = side === \"old\" ? \"−\" : \"+\";\n const showSign = row.kind !== \"context\";\n const markers = markersForRow(row, side);\n const info = rowMarkerInfo(markers, activeIndex);\n const startMarker = markers.find((marker) => isMarkerRangeStart(row, marker));\n const primaryIndex = startMarker?.index ?? info?.primaryIndex;\n const overlayItems =\n showAnnotationOverlays &&\n startMarker &&\n (annotationOverlayMode !== \"capture\" ||\n startMarker.index === captureOverlayAnnotationIndex)\n ? [startMarker]\n : [];\n return (\n <div\n data-annot-row={startMarker ? startMarker.index : undefined}\n tabIndex={info ? 0 : undefined}\n role={info ? \"button\" : undefined}\n aria-expanded={info ? info.isActive : undefined}\n className={cn(\n \"relative flex min-h-5 min-w-full\",\n info && \"cursor-pointer\",\n ROW_BG[row.kind],\n annotatedRowBg(info),\n )}\n onMouseEnter={\n info && primaryIndex != null\n ? (event) => onRowEnter(primaryIndex, event.currentTarget)\n : undefined\n }\n onMouseLeave={info ? () => onRowLeave() : undefined}\n onClick={\n info && primaryIndex != null\n ? (event) => onRowClick(primaryIndex, event.currentTarget)\n : undefined\n }\n onKeyDown={\n info && primaryIndex != null\n ? (event) => {\n if (event.key !== \"Enter\" && event.key !== \" \") return;\n event.preventDefault();\n onRowClick(primaryIndex, event.currentTarget);\n }\n : undefined\n }\n onFocus={\n info && primaryIndex != null\n ? (event) => onRowEnter(primaryIndex, event.currentTarget)\n : undefined\n }\n onBlur={info ? () => onRowLeave() : undefined}\n >\n <span className={cn(LINE_NO_CLASS, \"w-[52px]\")}>\n {side === \"old\" ? (row.oldNo ?? \"\") : (row.newNo ?? \"\")}\n </span>\n <span\n className={cn(\n \"w-6 shrink-0 select-none py-0 text-center font-semibold leading-5\",\n GUTTER_BG[row.kind],\n SIGN_COLOR[row.kind],\n )}\n >\n {showSign ? sign : \" \"}\n </span>\n {showMarkerColumn && (\n <MarkerCell\n startMarker={startMarker}\n active={startMarker != null && startMarker.index === activeIndex}\n />\n )}\n <DiffLineText text={row.text} language={language} />\n {overlayItems.length > 0 && (\n <AnnotationInlineOverlayStack\n items={overlayItems}\n ctx={ctx}\n showMarker\n containerRef={annotationOverlayContainerRef}\n mode={annotationOverlayMode}\n side={annotationOverlaySide}\n preferredSide={annotationOverlayPreferredSide}\n />\n )}\n </div>\n );\n}\n\n/* ── Edit (panel) ──────────────────────────────────────────────────────────── */\n\nconst codeAreaClass =\n \"min-h-[140px] font-mono [font-size:var(--plan-code-size)] leading-5\";\n\nfunction DiffEdit({ data, onChange, editable }: BlockEditProps<DiffData>) {\n const patch = (next: Partial<DiffData>) => onChange({ ...data, ...next });\n const mode: DiffMode = data.mode ?? \"split\";\n const annotations = data.annotations ?? [];\n\n const updateAnnotation = (index: number, next: Partial<DiffAnnotation>) =>\n patch({\n annotations: annotations.map((annotation, i) =>\n i === index ? { ...annotation, ...next } : annotation,\n ),\n });\n\n const removeAnnotation = (index: number) =>\n patch({ annotations: annotations.filter((_, i) => i !== index) });\n\n const addAnnotation = () => {\n if (annotations.length >= 80) return; // schema max\n patch({\n annotations: [\n ...annotations,\n { side: \"after\", lines: \"1\", label: \"\", note: \"\" },\n ],\n });\n };\n\n return (\n <div className=\"flex flex-col gap-3\" data-plan-interactive>\n <div className=\"grid gap-3 sm:grid-cols-2\">\n <div className=\"flex flex-col gap-1.5\">\n <DevLabel htmlFor=\"diff-filename\" className=\"text-xs\">\n Filename\n </DevLabel>\n <DevInput\n id=\"diff-filename\"\n value={data.filename ?? \"\"}\n placeholder=\"src/add.ts\"\n disabled={!editable}\n onChange={(event) =>\n patch({ filename: event.target.value || undefined })\n }\n />\n </div>\n <div className=\"flex flex-col gap-1.5\">\n <DevLabel htmlFor=\"diff-language\" className=\"text-xs\">\n Language\n </DevLabel>\n <DevInput\n id=\"diff-language\"\n value={data.language ?? \"\"}\n placeholder=\"ts\"\n disabled={!editable}\n onChange={(event) =>\n patch({ language: event.target.value || undefined })\n }\n />\n </div>\n </div>\n\n <div className=\"flex flex-col gap-1.5\">\n <DevLabel className=\"text-xs\">Layout</DevLabel>\n <DevSelect\n value={mode}\n disabled={!editable}\n onValueChange={(value) => patch({ mode: value as DiffMode })}\n options={[\n { value: \"unified\", label: \"Unified\" },\n { value: \"split\", label: \"Split (side-by-side)\" },\n ]}\n />\n </div>\n\n <div className=\"flex flex-col gap-1.5\">\n <DevLabel htmlFor=\"diff-before\" className=\"text-xs\">\n Before\n </DevLabel>\n <DevTextarea\n id=\"diff-before\"\n spellCheck={false}\n className={codeAreaClass}\n value={data.before}\n disabled={!editable}\n onChange={(event) => patch({ before: event.target.value })}\n />\n </div>\n\n <div className=\"flex flex-col gap-1.5\">\n <DevLabel htmlFor=\"diff-after\" className=\"text-xs\">\n After\n </DevLabel>\n <DevTextarea\n id=\"diff-after\"\n spellCheck={false}\n className={codeAreaClass}\n value={data.after}\n disabled={!editable}\n onChange={(event) => patch({ after: event.target.value })}\n />\n </div>\n\n <div className=\"flex flex-col gap-2\">\n <div className=\"flex items-center justify-between\">\n <DevLabel className=\"text-xs\">Annotations</DevLabel>\n {editable && annotations.length < 80 && (\n <button\n type=\"button\"\n data-plan-interactive\n onClick={addAnnotation}\n className=\"flex cursor-pointer items-center gap-1 rounded-md px-2 py-1 text-xs font-medium text-plan-muted transition-colors hover:bg-plan-block/60 hover:text-plan-text\"\n >\n <IconPlus className=\"size-3.5\" />\n Add annotation\n </button>\n )}\n </div>\n {annotations.length === 0 && (\n <p className=\"text-xs text-plan-muted\">\n No annotations yet. Add one to anchor a note to a line range on the\n before or after side.\n </p>\n )}\n {annotations.map((annotation, index) => (\n <div\n key={index}\n className=\"flex flex-col gap-2 rounded-md border border-plan-line bg-plan-block/30 p-2\"\n >\n <div className=\"grid gap-2 sm:grid-cols-[110px_110px_minmax(0,1fr)_auto]\">\n <DevSelect\n aria-label={`Annotation ${index + 1} side`}\n value={annotation.side ?? \"after\"}\n disabled={!editable}\n onValueChange={(value) =>\n updateAnnotation(index, {\n side: value as DiffAnnotation[\"side\"],\n })\n }\n options={[\n { value: \"after\", label: \"After\" },\n { value: \"before\", label: \"Before\" },\n ]}\n />\n <DevInput\n aria-label={`Annotation ${index + 1} lines`}\n value={annotation.lines}\n placeholder=\"3-5\"\n disabled={!editable}\n onChange={(event) =>\n updateAnnotation(index, { lines: event.target.value })\n }\n />\n <DevInput\n aria-label={`Annotation ${index + 1} label`}\n value={annotation.label ?? \"\"}\n placeholder=\"Label (optional)\"\n disabled={!editable}\n onChange={(event) =>\n updateAnnotation(index, {\n label: event.target.value || undefined,\n })\n }\n />\n {editable && (\n <button\n type=\"button\"\n data-plan-interactive\n aria-label={`Remove annotation ${index + 1}`}\n onClick={() => removeAnnotation(index)}\n className=\"flex size-9 shrink-0 cursor-pointer items-center justify-center rounded-md text-plan-muted transition-colors hover:bg-muted hover:text-foreground\"\n >\n <IconTrash className=\"size-4\" />\n </button>\n )}\n </div>\n <DevTextarea\n aria-label={`Annotation ${index + 1} note`}\n className=\"min-h-[60px] text-sm\"\n value={annotation.note}\n placeholder=\"Explain what these lines do…\"\n disabled={!editable}\n onChange={(event) =>\n updateAnnotation(index, { note: event.target.value })\n }\n />\n </div>\n ))}\n </div>\n </div>\n );\n}\n\nexport { DiffRead, DiffEdit };\n"]}
1
+ {"version":3,"file":"DiffBlock.js","sourceRoot":"","sources":["../../../../src/client/blocks/library/DiffBlock.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,WAAW,EACX,SAAS,EACT,OAAO,EACP,MAAM,EACN,QAAQ,GAGT,MAAM,OAAO,CAAC;AACf,OAAO,EACL,gBAAgB,EAChB,WAA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EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,GAExD,EACF,KAAC,QAAQ,kBACK,cAAc,KAAK,GAAG,CAAC,QAAQ,EAC3C,KAAK,EAAE,UAAU,CAAC,KAAK,IAAI,EAAE,EAC7B,WAAW,EAAC,kBAAkB,EAC9B,QAAQ,EAAE,CAAC,QAAQ,EACnB,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAClB,gBAAgB,CAAC,KAAK,EAAE;4CACtB,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,IAAI,SAAS;yCACvC,CAAC,GAEJ,EACD,QAAQ,IAAI,CACX,iBACE,IAAI,EAAC,QAAQ,+CAED,qBAAqB,KAAK,GAAG,CAAC,EAAE,EAC5C,OAAO,EAAE,GAAG,EAAE,CAAC,gBAAgB,CAAC,KAAK,CAAC,EACtC,SAAS,EAAC,mJAAmJ,YAE7J,KAAC,SAAS,IAAC,SAAS,EAAC,QAAQ,GAAG,GACzB,CACV,IACG,EACN,KAAC,WAAW,kBACE,cAAc,KAAK,GAAG,CAAC,OAAO,EAC1C,SAAS,EAAC,sBAAsB,EAChC,KAAK,EAAE,UAAU,CAAC,IAAI,EACtB,WAAW,EAAC,mCAA8B,EAC1C,QAAQ,EAAE,CAAC,QAAQ,EACnB,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAClB,gBAAgB,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,GAEvD,KA3DG,KAAK,CA4DN,CACP,CAAC,IACE,IACF,CACP,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC","sourcesContent":["import {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n type RefObject,\n type ReactNode,\n} from \"react\";\nimport {\n IconChevronRight,\n IconColumns,\n IconDotsVertical,\n IconFileDiff,\n IconList,\n IconPlus,\n IconTrash,\n} from \"@tabler/icons-react\";\nimport { common, createLowlight } from \"lowlight\";\nimport { cn } from \"../../utils.js\";\nimport { ltrCodeBlockProps } from \"../code-block-direction.js\";\nimport type {\n BlockEditProps,\n BlockReadProps,\n BlockRenderContext,\n} from \"../types.js\";\nimport type { DiffAnnotation, DiffData, DiffMode } from \"./diff.config.js\";\nimport {\n AnnotationGutterMarker,\n AnnotationHiddenStack,\n AnnotationHoverCard,\n AnnotationInlineOverlayStack,\n anchorFromElements,\n buildLineMarkerMap,\n hasRailAnnotations,\n resolveAnnotations,\n useAnnotationMarginNotesAvailable,\n useAnnotationHover,\n type AnnotationMarginSide,\n type AnnotationSide,\n type ResolvedAnnotation,\n} from \"./annotation-rail.js\";\nimport { DevInput, DevLabel, DevTextarea, DevSelect } from \"./dev-doc-ui.js\";\nimport { useInNarrowContainer } from \"./narrow-container.js\";\n\n/**\n * GitHub-style before/after diff block. The read renderer computes a line-level\n * diff, then renders it either unified (one column, `+`/`−` gutters) or split\n * (side-by-side). Long unchanged runs collapse into an expandable \"N unchanged\n * lines\" row (progressive disclosure). The read surface keeps the GitHub diff\n * shape while using the framework Tailwind theme tokens, so it follows each\n * host app's light/dark appearance instead of bringing its own palette.\n *\n * Lives in core so any app can register the dev-doc block. The line differ is\n * inlined (a small LCS-based `diffLines`) rather than pulling the `diff` package\n * into core; the output shape (`{ value, added, removed }` change records) is\n * identical to what the read renderer consumed before.\n *\n * Editing is panel-driven (config-style, like the HTML block): two monospace\n * textareas (Before / After) plus filename, language, and mode controls.\n */\n\n/* ── Inline line differ (LCS) — replaces jsdiff `diffLines` ─────────────────── */\n\ninterface Change {\n value: string;\n added?: boolean;\n removed?: boolean;\n}\n\n/**\n * Split text into lines, each KEEPING its trailing newline (so the change\n * `value`s concatenate back to the original and `splitLines` below behaves the\n * same as it did against jsdiff output).\n */\nfunction toLineTokens(text: string): string[] {\n if (text === \"\") return [];\n const out: string[] = [];\n let start = 0;\n for (let i = 0; i < text.length; i += 1) {\n if (text[i] === \"\\n\") {\n out.push(text.slice(start, i + 1));\n start = i + 1;\n }\n }\n if (start < text.length) out.push(text.slice(start));\n return out;\n}\n\n/**\n * A minimal line-level diff producing jsdiff-compatible `Change[]` records\n * (`{ value }` for context, `{ value, added: true }`, `{ value, removed: true }`).\n * Uses a classic LCS table over line tokens; the inputs here are short code\n * snippets so the O(n·m) table is fine. Removed lines are emitted before added\n * lines within a change region, matching jsdiff's ordering.\n */\nexport function diffLines(before: string, after: string): Change[] {\n const a = toLineTokens(before);\n const b = toLineTokens(after);\n const n = a.length;\n const m = b.length;\n const cells = (n + 1) * (m + 1);\n\n if (cells > MAX_DIFF_LCS_CELLS) {\n return [\n ...(before ? [{ value: before, removed: true }] : []),\n ...(after ? [{ value: after, added: true }] : []),\n ];\n }\n\n // LCS length table.\n const lcs: number[][] = Array.from({ length: n + 1 }, () =>\n new Array<number>(m + 1).fill(0),\n );\n for (let i = n - 1; i >= 0; i -= 1) {\n for (let j = m - 1; j >= 0; j -= 1) {\n lcs[i][j] =\n a[i] === b[j]\n ? lcs[i + 1][j + 1] + 1\n : Math.max(lcs[i + 1][j], lcs[i][j + 1]);\n }\n }\n\n const changes: Change[] = [];\n // Push a token onto the last change if same kind, else open a new change.\n const push = (value: string, kind: \"context\" | \"added\" | \"removed\") => {\n const last = changes[changes.length - 1];\n const sameKind =\n last &&\n Boolean(last.added) === (kind === \"added\") &&\n Boolean(last.removed) === (kind === \"removed\");\n if (sameKind) {\n last.value += value;\n } else {\n changes.push({\n value,\n added: kind === \"added\" ? true : undefined,\n removed: kind === \"removed\" ? true : undefined,\n });\n }\n };\n\n let i = 0;\n let j = 0;\n while (i < n && j < m) {\n if (a[i] === b[j]) {\n push(a[i], \"context\");\n i += 1;\n j += 1;\n } else if (lcs[i + 1][j] >= lcs[i][j + 1]) {\n push(a[i], \"removed\");\n i += 1;\n } else {\n push(b[j], \"added\");\n j += 1;\n }\n }\n while (i < n) {\n push(a[i], \"removed\");\n i += 1;\n }\n while (j < m) {\n push(b[j], \"added\");\n j += 1;\n }\n return changes;\n}\n\n/* ── Syntax highlighting ───────────────────────────────────────────────────── */\n\nconst lowlight = createLowlight(common);\n\ntype LowlightNode = {\n type: string;\n value?: string;\n properties?: {\n className?: string[] | string;\n };\n children?: LowlightNode[];\n};\n\nconst LANGUAGE_ALIASES: Record<string, string> = {\n cjs: \"javascript\",\n cts: \"typescript\",\n htm: \"html\",\n js: \"javascript\",\n jsonc: \"json\",\n jsx: \"jsx\",\n md: \"markdown\",\n mdx: \"markdown\",\n mjs: \"javascript\",\n mts: \"typescript\",\n py: \"python\",\n rb: \"ruby\",\n rs: \"rust\",\n sh: \"bash\",\n shell: \"bash\",\n ts: \"typescript\",\n tsx: \"tsx\",\n yml: \"yaml\",\n zsh: \"bash\",\n};\n\nconst TOKEN_CLASS_NAMES: Record<string, string> = {\n \"hljs-addition\": \"text-emerald-700 dark:text-emerald-300\",\n \"hljs-attr\": \"text-primary\",\n \"hljs-attribute\": \"text-primary\",\n \"hljs-built_in\": \"text-amber-700 dark:text-amber-300\",\n \"hljs-bullet\": \"text-primary\",\n \"hljs-comment\": \"text-muted-foreground italic\",\n \"hljs-deletion\": \"text-destructive\",\n \"hljs-doctag\": \"text-destructive\",\n \"hljs-emphasis\": \"italic\",\n \"hljs-formula\": \"text-destructive\",\n \"hljs-keyword\": \"text-destructive\",\n \"hljs-link\": \"text-primary underline-offset-2\",\n \"hljs-literal\": \"text-primary\",\n \"hljs-meta\": \"text-primary\",\n \"hljs-meta-string\": \"text-emerald-700 dark:text-emerald-300\",\n \"hljs-name\": \"text-emerald-700 dark:text-emerald-300\",\n \"hljs-number\": \"text-primary\",\n \"hljs-params\": \"text-primary\",\n \"hljs-property\": \"text-primary\",\n \"hljs-quote\": \"text-muted-foreground italic\",\n \"hljs-regexp\": \"text-emerald-700 dark:text-emerald-300\",\n \"hljs-section\": \"text-violet-700 dark:text-violet-300\",\n \"hljs-selector-attr\": \"text-primary\",\n \"hljs-selector-class\": \"text-emerald-700 dark:text-emerald-300\",\n \"hljs-selector-id\": \"text-emerald-700 dark:text-emerald-300\",\n \"hljs-selector-pseudo\": \"text-primary\",\n \"hljs-selector-tag\": \"text-emerald-700 dark:text-emerald-300\",\n \"hljs-string\": \"text-emerald-700 dark:text-emerald-300\",\n \"hljs-strong\": \"font-semibold\",\n \"hljs-subst\": \"text-destructive\",\n \"hljs-symbol\": \"text-primary\",\n \"hljs-tag\": \"text-emerald-700 dark:text-emerald-300\",\n \"hljs-template-variable\": \"text-amber-700 dark:text-amber-300\",\n \"hljs-title\": \"text-violet-700 dark:text-violet-300\",\n \"hljs-type\": \"text-amber-700 dark:text-amber-300\",\n \"hljs-variable\": \"text-amber-700 dark:text-amber-300\",\n language_: \"text-amber-700 dark:text-amber-300\",\n};\n\nfunction normalizeLanguage(value?: string | null): string | null {\n const raw = value?.trim().toLowerCase();\n if (!raw) return null;\n const normalized = LANGUAGE_ALIASES[raw] ?? raw;\n return lowlight.registered(normalized) ? normalized : null;\n}\n\nfunction getLanguageFromFilename(filename?: string): string | null {\n const basename = filename?.split(\"/\").pop()?.toLowerCase();\n if (!basename) return null;\n if (basename === \"dockerfile\") return normalizeLanguage(\"bash\");\n if (basename === \"makefile\") return normalizeLanguage(\"makefile\");\n const ext = basename.includes(\".\") ? basename.split(\".\").pop() : basename;\n return normalizeLanguage(ext);\n}\n\nfunction resolveDiffLanguage(data: DiffData): string {\n return (\n normalizeLanguage(data.language) ??\n getLanguageFromFilename(data.filename) ??\n \"plaintext\"\n );\n}\n\nfunction tokenClassName(className?: string[] | string): string | undefined {\n const classes = Array.isArray(className)\n ? className\n : className\n ? className.split(/\\s+/)\n : [];\n const mapped = classes\n .map((name) => TOKEN_CLASS_NAMES[name])\n .filter(Boolean)\n .join(\" \");\n return mapped || undefined;\n}\n\nfunction hastToReact(children: LowlightNode[], keyPrefix: string): ReactNode[] {\n return children.map((node, index) => {\n if (node.type === \"text\") return node.value ?? \"\";\n if (node.type === \"element\") {\n const key = `${keyPrefix}${index}`;\n const renderedChildren = node.children?.length\n ? hastToReact(node.children, `${key}-`)\n : null;\n const className = tokenClassName(node.properties?.className);\n if (className) {\n return (\n <span key={key} className={className}>\n {renderedChildren}\n </span>\n );\n }\n return <span key={key}>{renderedChildren}</span>;\n }\n return null;\n });\n}\n\nfunction SyntaxHighlightedLine({\n code,\n language,\n}: {\n code: string;\n language: string;\n}) {\n const highlighted = useMemo(() => {\n if (!code.trim() || language === \"plaintext\" || language === \"text\") {\n return null;\n }\n try {\n const tree = lowlight.highlight(language, code) as LowlightNode;\n return hastToReact(tree.children ?? [], `${language}-`);\n } catch {\n return null;\n }\n }, [code, language]);\n\n return <>{highlighted ?? code}</>;\n}\n\n/* ── Diff model ────────────────────────────────────────────────────────────── */\n\ntype DiffRowKind = \"context\" | \"added\" | \"removed\";\n\ninterface DiffRow {\n kind: DiffRowKind;\n /** Line number in the OLD file (omitted for added rows). */\n oldNo?: number;\n /** Line number in the NEW file (omitted for removed rows). */\n newNo?: number;\n text: string;\n}\n\n/** A contiguous run of context lines collapsed when longer than the threshold. */\ninterface CollapsedRun {\n collapsed: true;\n rows: DiffRow[];\n}\n\ntype DiffSegment = DiffRow | CollapsedRun;\n\n/** Which column a split-view row belongs to (the unified view passes nothing). */\ntype RowSide = \"old\" | \"new\";\n\n/**\n * Resolve the markers landing on a row. `side` scopes the lookup to one column\n * in the split view (so a left cell only lights from `before` annotations and a\n * right cell from `after`); the unified view omits it to merge both sides.\n */\ntype MarkersForRow = (\n row: DiffRow,\n side?: RowSide,\n) => ResolvedAnnotation<DiffAnnotation>[];\n\n/** The default side an annotation targets when `side` is omitted. */\nfunction annotationSide(annotation: DiffAnnotation): \"before\" | \"after\" {\n return annotation.side === \"before\" ? \"before\" : \"after\";\n}\n\n/**\n * Count 1-based source lines in a side's text, matching how `buildRows` numbers\n * `oldNo`/`newNo`: a trailing newline does not add a phantom final line.\n */\nfunction countLines(text: string): number {\n if (text === \"\") return 0;\n return splitLines(text).length;\n}\n\n/** Number of context lines above which an unchanged run is collapsed. */\nconst COLLAPSE_THRESHOLD = 6;\n/** Context lines kept visible at each edge of a collapsed run. */\nconst CONTEXT_EDGE = 3;\n\n/**\n * Split a change `value` into individual lines. Most hunks carry a trailing\n * newline; drop the empty final element it produces so a 2-line change does not\n * render a phantom 3rd blank line.\n */\nfunction splitLines(value: string): string[] {\n const lines = value.split(\"\\n\");\n if (lines.length > 0 && lines[lines.length - 1] === \"\") lines.pop();\n return lines;\n}\n\n/** Flatten change objects into numbered diff rows. */\nfunction buildRows(changes: Change[]): DiffRow[] {\n const rows: DiffRow[] = [];\n let oldNo = 0;\n let newNo = 0;\n for (const change of changes) {\n const lines = splitLines(change.value);\n for (const text of lines) {\n if (change.added) {\n newNo += 1;\n rows.push({ kind: \"added\", newNo, text });\n } else if (change.removed) {\n oldNo += 1;\n rows.push({ kind: \"removed\", oldNo, text });\n } else {\n oldNo += 1;\n newNo += 1;\n rows.push({ kind: \"context\", oldNo, newNo, text });\n }\n }\n }\n return rows;\n}\n\n/**\n * Group rows into segments, collapsing interior runs of >COLLAPSE_THRESHOLD\n * context rows (keeping CONTEXT_EDGE visible at each side). Leading/trailing runs\n * collapse too, but keep only the inner edge visible.\n *\n * `isAnchored` marks context rows that carry an annotation (or sit adjacent to\n * one): an anchored row is NEVER hidden inside a collapsed run, so a note that\n * targets an unchanged line stays reachable. An anchor splits its run into the\n * separately-collapsible spans on either side of it, with CONTEXT_EDGE rows kept\n * visible around the anchor.\n */\nfunction segmentRows(\n rows: DiffRow[],\n isAnchored?: (row: DiffRow) => boolean,\n): DiffSegment[] {\n const segments: DiffSegment[] = [];\n\n // Collapse one contiguous context run [from, to) that contains NO anchors.\n const collapseRun = (run: DiffRow[], atStart: boolean, atEnd: boolean) => {\n if (run.length <= COLLAPSE_THRESHOLD) {\n for (const row of run) segments.push(row);\n return;\n }\n const head = atStart ? [] : run.slice(0, CONTEXT_EDGE);\n const tail = atEnd ? [] : run.slice(run.length - CONTEXT_EDGE);\n const hidden = run.slice(head.length, run.length - tail.length);\n for (const row of head) segments.push(row);\n if (hidden.length > 0) segments.push({ collapsed: true, rows: hidden });\n for (const row of tail) segments.push(row);\n };\n\n let i = 0;\n while (i < rows.length) {\n if (rows[i].kind !== \"context\") {\n segments.push(rows[i]);\n i += 1;\n continue;\n }\n // Gather the full contiguous context run.\n let j = i;\n while (j < rows.length && rows[j].kind === \"context\") j += 1;\n const fullRun = rows.slice(i, j);\n const runAtStart = i === 0;\n const runAtEnd = j === rows.length;\n\n if (!isAnchored || !fullRun.some(isAnchored)) {\n collapseRun(fullRun, runAtStart, runAtEnd);\n } else {\n // Walk the run, emitting anchored rows verbatim and collapsing the\n // unanchored spans between them. An anchored row is always visible; the\n // spans on each side of it collapse independently.\n let spanStart = 0;\n for (let k = 0; k <= fullRun.length; k += 1) {\n const atAnchor = k < fullRun.length && isAnchored(fullRun[k]);\n if (atAnchor || k === fullRun.length) {\n const span = fullRun.slice(spanStart, k);\n if (span.length > 0) {\n collapseRun(\n span,\n runAtStart && spanStart === 0,\n runAtEnd && k === fullRun.length,\n );\n }\n if (k < fullRun.length) segments.push(fullRun[k]);\n spanStart = k + 1;\n }\n }\n }\n i = j;\n }\n return segments;\n}\n\n/* ── Theme-aware row styling (light + dark) ────────────────────────────────── */\n\nconst ROW_BG: Record<DiffRowKind, string> = {\n added: \"bg-emerald-500/10 dark:bg-emerald-500/15\",\n removed: \"bg-destructive/10\",\n context: \"bg-background\",\n};\n\nconst GUTTER_BG: Record<DiffRowKind, string> = {\n added: \"bg-emerald-500/15 dark:bg-emerald-500/20\",\n removed: \"bg-destructive/15\",\n context: \"bg-muted/60\",\n};\n\nconst SIGN_COLOR: Record<DiffRowKind, string> = {\n added: \"text-emerald-700 dark:text-emerald-300\",\n removed: \"text-destructive\",\n context: \"text-muted-foreground\",\n};\n\nconst SIGN: Record<DiffRowKind, string> = {\n added: \"+\",\n removed: \"−\",\n context: \" \",\n};\n\nconst LINE_NO_CLASS =\n \"select-none px-2 py-0 text-right font-mono [font-size:var(--plan-doc-code-size)] leading-5 text-muted-foreground tabular-nums\";\n\nconst DIFF_LINE_CLASS =\n \"block min-w-max flex-1 whitespace-pre px-2 py-0 font-mono [font-size:var(--plan-doc-code-size)] leading-5 text-foreground\";\n\nconst DEFAULT_VISIBLE_DIFF_LINES = 15;\nconst MAX_DIFF_LCS_CELLS = 1_000_000;\nconst DIFF_MODE_STORAGE_KEY = \"agent-native:diff-view-mode\";\nconst DIFF_MODE_STORAGE_EVENT = \"agent-native:diff-view-mode-change\";\n\n/**\n * Below this rendered container width (px) a diff drops side-by-side `split`\n * mode and falls back to `unified`: split's two line-number gutters double the\n * width the code needs, exactly where space is tightest (e.g. a diff nested in a\n * vertical-tabs content column). Measured from the block's own box, not the\n * viewport, so the fallback fires by available width at any nesting depth.\n */\nconst SPLIT_MIN_WIDTH = 560;\n\n/**\n * Observe the rendered inline width of an element. Returns a ref to attach plus\n * the measured content-box width (null until the first ResizeObserver tick).\n * Lets the diff pick an effective mode from the width it was actually handed — a\n * measurement CSS container queries can't drive, since switching split↔unified\n * is a structural (DOM) change, not a style toggle.\n */\nfunction useContainerWidth<T extends HTMLElement>() {\n const ref = useRef<T | null>(null);\n const [width, setWidth] = useState<number | null>(null);\n useEffect(() => {\n const el = ref.current;\n if (!el || typeof ResizeObserver === \"undefined\") return;\n const observer = new ResizeObserver((entries) => {\n const entry = entries[0];\n if (entry) setWidth(entry.contentRect.width);\n });\n observer.observe(el);\n return () => observer.disconnect();\n }, []);\n return [ref, width] as const;\n}\n\nfunction isDiffMode(value: unknown): value is DiffMode {\n return value === \"unified\" || value === \"split\";\n}\n\nfunction readStoredDiffMode(): DiffMode | null {\n if (typeof window === \"undefined\") return null;\n try {\n const value = window.localStorage?.getItem(DIFF_MODE_STORAGE_KEY);\n return isDiffMode(value) ? value : null;\n } catch {\n return null;\n }\n}\n\nfunction writeStoredDiffMode(mode: DiffMode): void {\n if (typeof window === \"undefined\") return;\n try {\n window.localStorage?.setItem(DIFF_MODE_STORAGE_KEY, mode);\n } catch {\n // Storage may be unavailable in sandboxed/private contexts.\n }\n}\n\nfunction dispatchDiffModeChange(mode: DiffMode): void {\n if (typeof window === \"undefined\") return;\n try {\n window.dispatchEvent(\n new CustomEvent<DiffMode>(DIFF_MODE_STORAGE_EVENT, { detail: mode }),\n );\n } catch {\n // Best-effort sync; local component state and storage already changed.\n }\n}\n\nfunction usePreferredDiffMode(authoredMode: DiffMode | undefined) {\n const [mode, setMode] = useState<DiffMode>(authoredMode ?? \"split\");\n\n useEffect(() => {\n if (authoredMode) return;\n const storedMode = readStoredDiffMode();\n if (storedMode) setMode(storedMode);\n }, [authoredMode]);\n\n useEffect(() => {\n if (authoredMode) return;\n if (typeof window === \"undefined\") return;\n\n const onStorage = (event: StorageEvent) => {\n if (event.key !== DIFF_MODE_STORAGE_KEY) return;\n if (isDiffMode(event.newValue)) setMode(event.newValue);\n };\n const onModeChange = (event: Event) => {\n const mode = (event as CustomEvent<unknown>).detail;\n if (isDiffMode(mode)) setMode(mode);\n };\n\n window.addEventListener(\"storage\", onStorage);\n window.addEventListener(DIFF_MODE_STORAGE_EVENT, onModeChange);\n return () => {\n window.removeEventListener(\"storage\", onStorage);\n window.removeEventListener(DIFF_MODE_STORAGE_EVENT, onModeChange);\n };\n }, [authoredMode]);\n\n const setPreferredMode = useCallback((nextMode: DiffMode) => {\n setMode(nextMode);\n writeStoredDiffMode(nextMode);\n dispatchDiffModeChange(nextMode);\n }, []);\n\n return [mode, setPreferredMode] as const;\n}\n\nfunction splitDiffFilename(filename?: string): {\n basename: string;\n directory: string | null;\n} {\n const value = filename?.trim() || \"diff\";\n const segments = value.split(\"/\").filter(Boolean);\n const basename = segments[segments.length - 1] ?? value;\n const directory =\n segments.length > 1 ? segments.slice(0, -1).join(\"/\") : null;\n return { basename, directory };\n}\n\nfunction DiffLineText({ language, text }: { language: string; text: string }) {\n const code = text || \" \";\n return (\n <span className={DIFF_LINE_CLASS}>\n <SyntaxHighlightedLine code={code} language={language} />\n </span>\n );\n}\n\n/* ── Read ──────────────────────────────────────────────────────────────────── */\n\nfunction DiffRead({\n data,\n blockId,\n title,\n summary,\n ctx,\n}: BlockReadProps<DiffData>) {\n // Default layout when none is authored is SPLIT so reviewers can compare\n // before/after code side-by-side. An explicitly authored `mode` or stored\n // viewer preference still wins, and truly narrow hosts can fall back below.\n const inNarrowContainer = useInNarrowContainer();\n const [mode, setMode] = usePreferredDiffMode(data.mode);\n const [expanded, setExpanded] = useState<Set<number>>(() => new Set());\n const [showAllRows, setShowAllRows] = useState(false);\n const [containerRef, containerWidth] = useContainerWidth<HTMLElement>();\n // On-hover popover (anchored to the right of the code) replaces the old\n // persistent rail: nothing is shown when idle. `codeRef` measures the code\n // box's right edge; `hover` carries the active index + captured geometry.\n const hover = useAnnotationHover();\n const { activeIndex } = hover;\n const codeRef = useRef<HTMLDivElement | null>(null);\n\n const rows = useMemo(\n () => buildRows(diffLines(data.before, data.after)),\n [data.before, data.after],\n );\n const language = useMemo(\n () => resolveDiffLanguage(data),\n [data.filename, data.language],\n );\n const fileParts = useMemo(\n () => splitDiffFilename(data.filename),\n [data.filename],\n );\n const splitLineCount = useMemo(() => pairSplitRows(rows).length, [rows]);\n\n // Resolve annotations against the side they target. A `before` annotation's\n // `lines` ref is clamped to the OLD file's line count and matched on `oldNo`;\n // an `after` (default) ref to the NEW file and matched on `newNo`. Markers are\n // authoring-order across BOTH sides so a note ↔ row ↔ rail card share one id.\n const beforeLineCount = useMemo(() => countLines(data.before), [data.before]);\n const afterLineCount = useMemo(() => countLines(data.after), [data.after]);\n const showAnnotationOverlays = Boolean(ctx.showCodeAnnotationOverlays);\n const annotationLayout = ctx.codeAnnotationLayout;\n const annotationHoverSide = annotationLayout?.hoverSide ?? \"right\";\n const annotationHoverFallbackSide =\n annotationLayout?.hoverFallbackSide ?? \"right\";\n const annotationMarginSide = annotationLayout?.marginSide ?? \"auto\";\n const defaultVisibleAnnotations =\n annotationLayout?.defaultVisibleAnnotations ??\n (annotationLayout?.showByDefaultWhenRoom ? \"all\" : undefined);\n const resolved = useMemo(\n () =>\n resolveAnnotations(data.annotations, (annotation) =>\n annotationSide(annotation) === \"before\"\n ? beforeLineCount\n : afterLineCount,\n ),\n [data.annotations, beforeLineCount, afterLineCount],\n );\n const hasAnnotations = hasRailAnnotations(resolved);\n const showMarginAnnotations = useAnnotationMarginNotesAvailable({\n containerRef: codeRef,\n enabled: Boolean(\n hasAnnotations && !showAnnotationOverlays && defaultVisibleAnnotations,\n ),\n side: annotationMarginSide,\n preferredSide: annotationHoverSide,\n });\n const showPersistentAnnotations =\n showAnnotationOverlays || showMarginAnnotations;\n const persistentAnnotationIndexes = useMemo(() => {\n if (!showMarginAnnotations || !defaultVisibleAnnotations) {\n return new Set<number>();\n }\n const visible = resolved.filter((item) => item.range);\n if (defaultVisibleAnnotations === \"first\") {\n const first = visible[0];\n return first ? new Set([first.index]) : new Set<number>();\n }\n return new Set(visible.map((item) => item.index));\n }, [defaultVisibleAnnotations, resolved, showMarginAnnotations]);\n const captureOverlayAnnotationIndex = useMemo(\n () => resolved.find((item) => item.range)?.index ?? null,\n [resolved],\n );\n // Effective render mode. Annotations live in a SEPARATE right-hand rail (not\n // over the code), so they no longer force a mode. When no mode was authored, a\n // truly narrow container still falls back to unified so split's doubled\n // gutters never crush the code; an explicitly authored `mode` wins even in a\n // narrow host. `canSplit` only hides the toggle for auto-mode narrow fallbacks.\n const measuredNarrow =\n containerWidth != null && containerWidth < SPLIT_MIN_WIDTH;\n const narrow = data.mode == null && (measuredNarrow || inNarrowContainer);\n const canSplit = !narrow;\n const effectiveMode: DiffMode = canSplit ? mode : \"unified\";\n\n // Annotations (diff): NO persistent column. Hovering a marked code line (or\n // its numbered pip) opens THAT note's card as an on-hover popover anchored to\n // the RIGHT of the code box, never over the code. The in-code pip stays as the\n // anchor indicator + active-line highlight. `onRowEnter` captures the code\n // box's right edge + the hovered row's vertical position to place the card;\n // `onRowLeave` schedules a short-delay close so the pointer can cross the gap\n // into the card (which cancels the close while hovered).\n const onRowEnter = useCallback(\n (index: number, rowEl: HTMLElement) => {\n const startRow =\n codeRef.current?.querySelector<HTMLElement>(\n `[data-annot-row=\"${index}\"]`,\n ) ?? rowEl;\n const anchor = anchorFromElements(codeRef.current, startRow);\n if (anchor) hover.open(index, anchor);\n },\n [hover],\n );\n const onRowLeave = useCallback(() => hover.scheduleClose(), [hover]);\n const onRowClick = useCallback(\n (index: number, rowEl: HTMLElement) => {\n const startRow =\n codeRef.current?.querySelector<HTMLElement>(\n `[data-annot-row=\"${index}\"]`,\n ) ?? rowEl;\n const anchor = anchorFromElements(codeRef.current, startRow);\n if (anchor) hover.open(index, anchor);\n },\n [hover],\n );\n // Side-scoped line → markers maps so a row only lights from its own side.\n const beforeMarkers = useMemo(\n () =>\n buildLineMarkerMap(\n resolved.filter((r) => annotationSide(r.annotation) === \"before\"),\n ),\n [resolved],\n );\n const afterMarkers = useMemo(\n () =>\n buildLineMarkerMap(\n resolved.filter((r) => annotationSide(r.annotation) !== \"before\"),\n ),\n [resolved],\n );\n const markersForRow = useMemo<MarkersForRow>(() => {\n return (row, side) => {\n const out: ResolvedAnnotation<DiffAnnotation>[] = [];\n if (\n (side === undefined || side === \"old\") &&\n row.oldNo != null &&\n row.kind !== \"added\"\n ) {\n out.push(...(beforeMarkers.get(row.oldNo) ?? []));\n }\n if (\n (side === undefined || side === \"new\") &&\n row.newNo != null &&\n row.kind !== \"removed\"\n ) {\n out.push(...(afterMarkers.get(row.newNo) ?? []));\n }\n return out;\n };\n }, [beforeMarkers, afterMarkers]);\n // A context row that carries a marker is an anchor: never collapse it away.\n const anchoredRow = useMemo(() => {\n if (!hasAnnotations) return undefined;\n return (row: DiffRow) => markersForRow(row).length > 0;\n }, [hasAnnotations, markersForRow]);\n\n // The resolved annotation whose card is currently shown on hover.\n const activeItem = useMemo<ResolvedAnnotation<DiffAnnotation> | null>(\n () =>\n activeIndex == null\n ? null\n : (resolved.find((item) => item.index === activeIndex) ?? null),\n [activeIndex, resolved],\n );\n const activeItemIsPersistentlyVisible = Boolean(\n activeItem &&\n !showAnnotationOverlays &&\n persistentAnnotationIndexes.has(activeItem.index),\n );\n\n const added = rows.filter((r) => r.kind === \"added\").length;\n const removed = rows.filter((r) => r.kind === \"removed\").length;\n const unchanged = data.before === data.after;\n const totalVisibleLineCount =\n effectiveMode === \"split\" ? splitLineCount : rows.length;\n const shouldLimitRows = totalVisibleLineCount > DEFAULT_VISIBLE_DIFF_LINES;\n // Never truncate away an annotated row: extend the window past the last one.\n const effectiveRowLimit = useMemo(() => {\n if (showAllRows || !shouldLimitRows) return undefined;\n let limit = DEFAULT_VISIBLE_DIFF_LINES;\n if (hasAnnotations) {\n for (let idx = rows.length - 1; idx >= limit; idx -= 1) {\n if (markersForRow(rows[idx]).length > 0) {\n limit = idx + 1;\n break;\n }\n }\n }\n return limit;\n }, [showAllRows, shouldLimitRows, hasAnnotations, rows, markersForRow]);\n const rowLimit = effectiveRowLimit;\n const displayedRows =\n effectiveMode === \"unified\" && rowLimit ? rows.slice(0, rowLimit) : rows;\n\n const toggleRun = (index: number) =>\n setExpanded((prev) => {\n const next = new Set(prev);\n if (next.has(index)) next.delete(index);\n else next.add(index);\n return next;\n });\n\n // The bordered code box. It always spans its full width — annotations surface\n // as an on-hover popover anchored to this box's right edge, never as a column.\n // `codeRef` measures that right edge for the popover's placement.\n const diffBox = (\n <div\n ref={codeRef}\n className=\"overflow-hidden rounded-md border border-border bg-background\"\n >\n {/* Header: filename, path, +/− counts, mode toggle. */}\n <div className=\"flex min-h-10 flex-wrap items-center gap-2 border-b border-border bg-muted/60 px-3 py-1.5\">\n <IconFileDiff className=\"size-4 shrink-0 text-muted-foreground\" />\n <span\n className=\"flex min-w-0 flex-1 items-baseline gap-1.5 font-mono\"\n title={data.filename || undefined}\n >\n <span className=\"min-w-0 max-w-[16rem] truncate text-[13px] font-semibold leading-5 text-foreground\">\n {fileParts.basename}\n </span>\n {fileParts.directory && (\n <span className=\"min-w-0 flex-1 truncate text-[11px] leading-5 text-muted-foreground/70\">\n {fileParts.directory}\n </span>\n )}\n </span>\n <span className=\"ml-1 flex shrink-0 items-center gap-2 font-mono text-xs\">\n <span className=\"text-emerald-700 dark:text-emerald-300\">\n +{added}\n </span>\n <span className=\"text-destructive\">−{removed}</span>\n </span>\n {/* Mode toggle only when split is actually available: a narrow\n container forces unified (split's doubled gutters would crush the\n code), so the toggle would otherwise be a no-op. Annotations are an\n on-hover popover now, so they work in both unified and split. */}\n {canSplit && (\n <div className=\"pointer-events-none ml-auto flex shrink-0 items-center overflow-hidden rounded-md border border-border bg-background opacity-0 transition-opacity group-hover/diff-block:pointer-events-auto group-hover/diff-block:opacity-100 group-focus-within/diff-block:pointer-events-auto group-focus-within/diff-block:opacity-100\">\n <ModeButton\n active={mode === \"unified\"}\n onClick={() => setMode(\"unified\")}\n icon={<IconList className=\"size-3.5\" />}\n label=\"Unified\"\n />\n <ModeButton\n active={mode === \"split\"}\n onClick={() => setMode(\"split\")}\n icon={<IconColumns className=\"size-3.5\" />}\n label=\"Split\"\n />\n </div>\n )}\n </div>\n\n {/* Body. */}\n {unchanged ? (\n <div className=\"px-4 py-6 text-center font-mono text-sm text-muted-foreground\">\n No changes\n </div>\n ) : effectiveMode === \"split\" ? (\n <SplitView\n rows={rows}\n language={language}\n rowLimit={rowLimit}\n markersForRow={markersForRow}\n activeIndex={activeIndex}\n onRowEnter={onRowEnter}\n onRowLeave={onRowLeave}\n onRowClick={onRowClick}\n showAnnotationOverlays={showPersistentAnnotations}\n annotationOverlayMode={showAnnotationOverlays ? \"capture\" : \"margin\"}\n annotationOverlaySide={\n showAnnotationOverlays ? \"right\" : annotationMarginSide\n }\n annotationOverlayPreferredSide={annotationHoverSide}\n annotationOverlayContainerRef={codeRef}\n captureOverlayAnnotationIndex={captureOverlayAnnotationIndex}\n persistentAnnotationIndexes={persistentAnnotationIndexes}\n ctx={ctx}\n />\n ) : (\n <UnifiedView\n rows={displayedRows}\n language={language}\n expanded={expanded}\n onToggleRun={toggleRun}\n markersForRow={markersForRow}\n anchoredRow={anchoredRow}\n activeIndex={activeIndex}\n onRowEnter={onRowEnter}\n onRowLeave={onRowLeave}\n onRowClick={onRowClick}\n showAnnotationOverlays={showPersistentAnnotations}\n annotationOverlayMode={showAnnotationOverlays ? \"capture\" : \"margin\"}\n annotationOverlaySide={\n showAnnotationOverlays ? \"right\" : annotationMarginSide\n }\n annotationOverlayPreferredSide={annotationHoverSide}\n annotationOverlayContainerRef={codeRef}\n captureOverlayAnnotationIndex={captureOverlayAnnotationIndex}\n persistentAnnotationIndexes={persistentAnnotationIndexes}\n ctx={ctx}\n />\n )}\n {!unchanged && shouldLimitRows && (\n <button\n type=\"button\"\n data-plan-interactive\n aria-expanded={showAllRows}\n onClick={() => setShowAllRows((current) => !current)}\n className=\"flex h-7 w-full items-center justify-center gap-1.5 border-t border-border bg-background px-2 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-muted/70 hover:text-foreground\"\n >\n <IconChevronRight\n className={cn(\n \"size-3 shrink-0 transition-transform\",\n showAllRows ? \"-rotate-90\" : \"rotate-90\",\n )}\n />\n {showAllRows\n ? \"Show fewer\"\n : `Show all ${totalVisibleLineCount} lines`}\n </button>\n )}\n </div>\n );\n\n return (\n <section\n {...ltrCodeBlockProps}\n ref={containerRef}\n className=\"relative plan-block group/diff-block\"\n data-block-id={blockId}\n >\n {title && <div className=\"plan-block-label\">{title}</div>}\n {summary && (\n <p className=\"mb-3 text-sm leading-relaxed text-plan-muted\">\n {summary}\n </p>\n )}\n {/* The diff keeps its full width — no persistent annotation column. The\n in-code numbered pips remain the hover anchors; notes live in a\n visually-hidden stack (a11y + tests) and surface ONE at a time as an\n on-hover popover anchored to the right of the code box. */}\n {diffBox}\n {hasAnnotations && (\n <AnnotationHiddenStack items={resolved} ctx={ctx} showMarker />\n )}\n {hasAnnotations &&\n !showAnnotationOverlays &&\n !activeItemIsPersistentlyVisible &&\n activeItem &&\n hover.anchor && (\n <AnnotationHoverCard\n item={activeItem}\n anchor={hover.anchor}\n ctx={ctx}\n showMarker\n preferredSide={annotationHoverSide}\n hoverFallbackSide={annotationHoverFallbackSide}\n onMouseEnter={hover.cancelClose}\n onMouseLeave={hover.scheduleClose}\n onClose={hover.closeForScroll}\n />\n )}\n </section>\n );\n}\n\nfunction ModeButton({\n active,\n onClick,\n icon,\n label,\n}: {\n active: boolean;\n onClick: () => void;\n icon: ReactNode;\n label: string;\n}) {\n return (\n <button\n type=\"button\"\n data-plan-interactive\n onClick={onClick}\n aria-pressed={active}\n className={cn(\n \"flex cursor-pointer items-center gap-1 px-2 py-1 text-xs font-medium transition-colors\",\n active\n ? \"bg-accent text-accent-foreground\"\n : \"text-muted-foreground hover:bg-muted/80 hover:text-foreground\",\n )}\n >\n {icon}\n {label}\n </button>\n );\n}\n\n/* ── Annotation wiring shared by both views ────────────────────────────────── */\n\n/** Marker + hover props threaded into the unified/split rows. */\ninterface RowAnnotationProps {\n markersForRow: MarkersForRow;\n anchoredRow?: (row: DiffRow) => boolean;\n activeIndex: number | null;\n showAnnotationOverlays: boolean;\n ctx: BlockRenderContext;\n /** Hovering an annotated row opens its popover, anchored to this row's box. */\n onRowEnter: (index: number, rowEl: HTMLElement) => void;\n /** Leaving an annotated row schedules the popover's close. */\n onRowLeave: () => void;\n /** Clicking/tapping an annotated row toggles its popover (for touch). */\n onRowClick: (index: number, rowEl: HTMLElement) => void;\n annotationOverlayMode: \"capture\" | \"margin\";\n annotationOverlaySide: AnnotationMarginSide;\n annotationOverlayPreferredSide: AnnotationSide;\n annotationOverlayContainerRef: RefObject<HTMLElement | null>;\n captureOverlayAnnotationIndex: number | null;\n persistentAnnotationIndexes: ReadonlySet<number>;\n}\n\n/**\n * The numbered marker pip(s) for a row plus the active-state it derives. Returns\n * `null` when the row carries no annotation so unannotated diffs render an empty\n * marker column (or no column at all when the whole diff is unannotated).\n */\nfunction rowMarkerInfo(\n markers: ResolvedAnnotation<DiffAnnotation>[],\n activeIndex: number | null,\n): { isActive: boolean; primaryIndex: number } | null {\n if (markers.length === 0) return null;\n const isActive = markers.some((m) => m.index === activeIndex);\n return { isActive, primaryIndex: markers[0].index };\n}\n\n/** Shared amber wash for an annotated row, brighter when active. */\nfunction annotatedRowBg(\n info: { isActive: boolean } | null,\n persistentlyVisible = false,\n): string | null {\n if (!info) return null;\n if (info.isActive) {\n return \"bg-amber-400/[0.12] dark:bg-amber-300/[0.10]\";\n }\n return persistentlyVisible\n ? \"bg-amber-300/[0.14] dark:bg-amber-300/[0.10]\"\n : \"bg-amber-400/[0.045] dark:bg-amber-300/[0.045]\";\n}\n\n/**\n * Whether `row` is the FIRST line of `marker`'s resolved range. The numbered pip\n * renders only on this line, so a multi-line annotation shows a single marker at\n * the top of its span instead of repeating the same number down every line it\n * covers. The amber band still washes the whole range (via `annotatedRowBg`), so\n * the span stays visually grouped without the column of duplicate numbers.\n */\nfunction isMarkerRangeStart(\n row: DiffRow,\n marker: ResolvedAnnotation<DiffAnnotation>,\n): boolean {\n if (!marker.range) return false;\n const lineNo =\n annotationSide(marker.annotation) === \"before\" ? row.oldNo : row.newNo;\n return lineNo === marker.range.start;\n}\n\n/* ── Unified view ──────────────────────────────────────────────────────────── */\n\nfunction UnifiedView({\n rows,\n language,\n expanded,\n onToggleRun,\n markersForRow,\n anchoredRow,\n activeIndex,\n onRowEnter,\n onRowLeave,\n onRowClick,\n showAnnotationOverlays,\n annotationOverlayMode,\n annotationOverlaySide,\n annotationOverlayPreferredSide,\n annotationOverlayContainerRef,\n captureOverlayAnnotationIndex,\n persistentAnnotationIndexes,\n ctx,\n}: {\n rows: DiffRow[];\n language: string;\n expanded: Set<number>;\n onToggleRun: (index: number) => void;\n} & RowAnnotationProps) {\n const segments = useMemo(\n () => segmentRows(rows, anchoredRow),\n [rows, anchoredRow],\n );\n // Any annotation present ⇒ reserve the marker column so rows stay aligned.\n const showMarkerColumn = useMemo(\n () => rows.some((row) => markersForRow(row).length > 0),\n [rows, markersForRow],\n );\n const rowProps = {\n language,\n markersForRow,\n activeIndex,\n onRowEnter,\n onRowLeave,\n onRowClick,\n showMarkerColumn,\n showAnnotationOverlays,\n annotationOverlayMode,\n annotationOverlaySide,\n annotationOverlayPreferredSide,\n annotationOverlayContainerRef,\n captureOverlayAnnotationIndex,\n persistentAnnotationIndexes,\n ctx,\n };\n let runIndex = 0;\n return (\n <div className=\"overflow-x-auto\" data-code-surface>\n <div className=\"w-max min-w-full font-mono [font-size:var(--plan-doc-code-size)] leading-5\">\n {segments.map((segment, idx) => {\n if (\"collapsed\" in segment) {\n const key = runIndex++;\n const open = expanded.has(key);\n return (\n <div key={`run-${key}`}>\n <CollapsedRow\n count={segment.rows.length}\n open={open}\n onClick={() => onToggleRun(key)}\n />\n {open &&\n segment.rows.map((row, ri) => (\n <UnifiedRow\n key={`run-${key}-${ri}`}\n row={row}\n {...rowProps}\n />\n ))}\n </div>\n );\n }\n return <UnifiedRow key={idx} row={segment} {...rowProps} />;\n })}\n </div>\n </div>\n );\n}\n\nfunction UnifiedRow({\n language,\n row,\n markersForRow,\n activeIndex,\n onRowEnter,\n onRowLeave,\n onRowClick,\n showMarkerColumn,\n showAnnotationOverlays,\n annotationOverlayMode,\n annotationOverlaySide,\n annotationOverlayPreferredSide,\n annotationOverlayContainerRef,\n captureOverlayAnnotationIndex,\n persistentAnnotationIndexes,\n ctx,\n}: {\n language: string;\n row: DiffRow;\n markersForRow: MarkersForRow;\n activeIndex: number | null;\n onRowEnter: (index: number, rowEl: HTMLElement) => void;\n onRowLeave: () => void;\n onRowClick: (index: number, rowEl: HTMLElement) => void;\n showMarkerColumn: boolean;\n showAnnotationOverlays: boolean;\n annotationOverlayMode: \"capture\" | \"margin\";\n annotationOverlaySide: AnnotationMarginSide;\n annotationOverlayPreferredSide: AnnotationSide;\n annotationOverlayContainerRef: RefObject<HTMLElement | null>;\n captureOverlayAnnotationIndex: number | null;\n persistentAnnotationIndexes: ReadonlySet<number>;\n ctx: BlockRenderContext;\n}) {\n const markers = markersForRow(row);\n const info = rowMarkerInfo(markers, activeIndex);\n const startMarker = markers.find((marker) => isMarkerRangeStart(row, marker));\n const primaryIndex = startMarker?.index ?? info?.primaryIndex;\n const overlayItems =\n showAnnotationOverlays &&\n startMarker &&\n (annotationOverlayMode === \"capture\"\n ? startMarker.index === captureOverlayAnnotationIndex\n : persistentAnnotationIndexes.has(startMarker.index))\n ? [startMarker]\n : [];\n const rowHasPersistentAnnotation = markers.some((marker) =>\n persistentAnnotationIndexes.has(marker.index),\n );\n return (\n <div\n data-annot-row={startMarker ? startMarker.index : undefined}\n tabIndex={info ? 0 : undefined}\n role={info ? \"button\" : undefined}\n aria-expanded={info ? info.isActive : undefined}\n className={cn(\n \"relative flex min-h-5 min-w-full\",\n info && \"cursor-pointer\",\n ROW_BG[row.kind],\n annotatedRowBg(info, rowHasPersistentAnnotation),\n )}\n onMouseEnter={\n info && primaryIndex != null\n ? (event) => onRowEnter(primaryIndex, event.currentTarget)\n : undefined\n }\n onMouseLeave={info ? () => onRowLeave() : undefined}\n onClick={\n info && primaryIndex != null\n ? (event) => onRowClick(primaryIndex, event.currentTarget)\n : undefined\n }\n onKeyDown={\n info && primaryIndex != null\n ? (event) => {\n if (event.key !== \"Enter\" && event.key !== \" \") return;\n event.preventDefault();\n onRowClick(primaryIndex, event.currentTarget);\n }\n : undefined\n }\n onFocus={\n info && primaryIndex != null\n ? (event) => onRowEnter(primaryIndex, event.currentTarget)\n : undefined\n }\n onBlur={info ? () => onRowLeave() : undefined}\n >\n <span className={cn(LINE_NO_CLASS, \"w-[52px]\")}>{row.oldNo ?? \"\"}</span>\n <span className={cn(LINE_NO_CLASS, \"w-[52px]\")}>{row.newNo ?? \"\"}</span>\n <span\n className={cn(\n \"w-6 shrink-0 select-none py-0 text-center font-semibold leading-5\",\n GUTTER_BG[row.kind],\n SIGN_COLOR[row.kind],\n )}\n >\n {SIGN[row.kind]}\n </span>\n {showMarkerColumn && (\n <MarkerCell\n startMarker={startMarker}\n active={\n startMarker != null &&\n (startMarker.index === activeIndex ||\n persistentAnnotationIndexes.has(startMarker.index))\n }\n />\n )}\n <DiffLineText text={row.text} language={language} />\n {overlayItems.length > 0 && (\n <AnnotationInlineOverlayStack\n items={overlayItems}\n ctx={ctx}\n showMarker\n containerRef={annotationOverlayContainerRef}\n mode={annotationOverlayMode}\n side={annotationOverlaySide}\n preferredSide={annotationOverlayPreferredSide}\n />\n )}\n </div>\n );\n}\n\n/**\n * The fixed-width marker column rendered between the sign gutter and the code.\n * `startMarker` is set only on the FIRST line of an annotation's range, so the\n * numbered pip appears once at the top of a span; every other row (the rest of a\n * span, and every unannotated row in a diff that has annotations) renders an\n * empty spacer so the code text stays aligned.\n */\nfunction MarkerCell({\n startMarker,\n active,\n}: {\n startMarker?: ResolvedAnnotation<DiffAnnotation>;\n active: boolean;\n}) {\n return (\n <span className=\"flex w-6 shrink-0 select-none items-center justify-center py-0\">\n {startMarker != null && (\n <AnnotationGutterMarker marker={startMarker.marker} active={active} />\n )}\n </span>\n );\n}\n\nfunction CollapsedRow({\n count,\n open,\n onClick,\n}: {\n count: number;\n open: boolean;\n onClick: () => void;\n}) {\n return (\n <button\n type=\"button\"\n data-plan-interactive\n onClick={onClick}\n className=\"flex w-full cursor-pointer items-center gap-2 border-y border-border bg-muted/70 px-3 py-1 text-left text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground\"\n >\n <IconDotsVertical className=\"size-3.5 shrink-0\" />\n <span>\n {open ? \"Hide\" : \"Show\"} {count} unchanged line\n {count === 1 ? \"\" : \"s\"}\n </span>\n </button>\n );\n}\n\n/* ── Split (side-by-side) view ─────────────────────────────────────────────── */\n\ninterface SplitRow {\n left?: DiffRow;\n right?: DiffRow;\n}\n\n/**\n * Pair removed lines (left) with added lines (right) so a modification shows the\n * old and new side by side; context lines mirror on both columns. Leftover adds\n * or removes fall through as half-empty rows (GitHub split behavior).\n */\nfunction pairSplitRows(rows: DiffRow[]): SplitRow[] {\n const out: SplitRow[] = [];\n let i = 0;\n while (i < rows.length) {\n const row = rows[i];\n if (row.kind === \"context\") {\n out.push({ left: row, right: row });\n i += 1;\n continue;\n }\n // Collect a contiguous block of removed-then-added rows.\n const removed: DiffRow[] = [];\n const added: DiffRow[] = [];\n while (i < rows.length && rows[i].kind === \"removed\")\n removed.push(rows[i++]);\n while (i < rows.length && rows[i].kind === \"added\") added.push(rows[i++]);\n const max = Math.max(removed.length, added.length);\n for (let k = 0; k < max; k += 1) {\n out.push({ left: removed[k], right: added[k] });\n }\n }\n return out;\n}\n\nfunction SplitView({\n language,\n rowLimit,\n rows,\n markersForRow,\n activeIndex,\n onRowEnter,\n onRowLeave,\n onRowClick,\n showAnnotationOverlays,\n annotationOverlayMode,\n annotationOverlaySide,\n annotationOverlayPreferredSide,\n annotationOverlayContainerRef,\n captureOverlayAnnotationIndex,\n persistentAnnotationIndexes,\n ctx,\n}: {\n language: string;\n rowLimit?: number;\n rows: DiffRow[];\n} & Omit<RowAnnotationProps, \"anchoredRow\">) {\n const pairs = useMemo(() => pairSplitRows(rows), [rows]);\n const displayedPairs = rowLimit ? pairs.slice(0, rowLimit) : pairs;\n // Reserve the marker column on a side only if any visible row there has one.\n const showOldMarkers = useMemo(\n () =>\n displayedPairs.some(\n (pair) => pair.left && markersForRow(pair.left, \"old\").length > 0,\n ),\n [displayedPairs, markersForRow],\n );\n const showNewMarkers = useMemo(\n () =>\n displayedPairs.some(\n (pair) => pair.right && markersForRow(pair.right, \"new\").length > 0,\n ),\n [displayedPairs, markersForRow],\n );\n const cellProps = {\n language,\n markersForRow,\n activeIndex,\n onRowEnter,\n onRowLeave,\n onRowClick,\n showAnnotationOverlays,\n annotationOverlayMode,\n annotationOverlaySide,\n annotationOverlayPreferredSide,\n annotationOverlayContainerRef,\n captureOverlayAnnotationIndex,\n persistentAnnotationIndexes,\n ctx,\n };\n return (\n <div\n className=\"flex w-full bg-background font-mono [font-size:var(--plan-doc-code-size)] leading-5\"\n data-code-surface\n >\n <div className=\"min-w-0 flex-1 overflow-x-auto border-r border-border\">\n <div className=\"inline-block min-w-full\">\n {displayedPairs.map((pair, idx) => (\n <SplitCell\n key={`old-${idx}`}\n row={pair.left}\n side=\"old\"\n showMarkerColumn={showOldMarkers}\n {...cellProps}\n />\n ))}\n </div>\n </div>\n <div className=\"min-w-0 flex-1 overflow-x-auto\">\n <div className=\"inline-block min-w-full\">\n {displayedPairs.map((pair, idx) => (\n <SplitCell\n key={`new-${idx}`}\n row={pair.right}\n side=\"new\"\n showMarkerColumn={showNewMarkers}\n {...cellProps}\n />\n ))}\n </div>\n </div>\n </div>\n );\n}\n\nfunction SplitCell({\n language,\n row,\n side,\n markersForRow,\n activeIndex,\n onRowEnter,\n onRowLeave,\n onRowClick,\n showMarkerColumn,\n showAnnotationOverlays,\n annotationOverlayMode,\n annotationOverlaySide,\n annotationOverlayPreferredSide,\n annotationOverlayContainerRef,\n captureOverlayAnnotationIndex,\n persistentAnnotationIndexes,\n ctx,\n}: {\n language: string;\n row?: DiffRow;\n side: RowSide;\n markersForRow: MarkersForRow;\n activeIndex: number | null;\n onRowEnter: (index: number, rowEl: HTMLElement) => void;\n onRowLeave: () => void;\n onRowClick: (index: number, rowEl: HTMLElement) => void;\n showMarkerColumn: boolean;\n showAnnotationOverlays: boolean;\n annotationOverlayMode: \"capture\" | \"margin\";\n annotationOverlaySide: AnnotationMarginSide;\n annotationOverlayPreferredSide: AnnotationSide;\n annotationOverlayContainerRef: RefObject<HTMLElement | null>;\n captureOverlayAnnotationIndex: number | null;\n persistentAnnotationIndexes: ReadonlySet<number>;\n ctx: BlockRenderContext;\n}) {\n if (!row) {\n return (\n <div className=\"flex min-h-5 min-w-full bg-muted/40 opacity-70\">\n <span className={cn(LINE_NO_CLASS, \"w-[52px]\")} />\n <span className=\"w-6 shrink-0 bg-muted/60\" />\n {showMarkerColumn && <span className=\"w-6 shrink-0\" />}\n <span className={DIFF_LINE_CLASS}> </span>\n </div>\n );\n }\n const sign = side === \"old\" ? \"−\" : \"+\";\n const showSign = row.kind !== \"context\";\n const markers = markersForRow(row, side);\n const info = rowMarkerInfo(markers, activeIndex);\n const startMarker = markers.find((marker) => isMarkerRangeStart(row, marker));\n const primaryIndex = startMarker?.index ?? info?.primaryIndex;\n const overlayItems =\n showAnnotationOverlays &&\n startMarker &&\n (annotationOverlayMode === \"capture\"\n ? startMarker.index === captureOverlayAnnotationIndex\n : persistentAnnotationIndexes.has(startMarker.index))\n ? [startMarker]\n : [];\n const rowHasPersistentAnnotation = markers.some((marker) =>\n persistentAnnotationIndexes.has(marker.index),\n );\n return (\n <div\n data-annot-row={startMarker ? startMarker.index : undefined}\n tabIndex={info ? 0 : undefined}\n role={info ? \"button\" : undefined}\n aria-expanded={info ? info.isActive : undefined}\n className={cn(\n \"relative flex min-h-5 min-w-full\",\n info && \"cursor-pointer\",\n ROW_BG[row.kind],\n annotatedRowBg(info, rowHasPersistentAnnotation),\n )}\n onMouseEnter={\n info && primaryIndex != null\n ? (event) => onRowEnter(primaryIndex, event.currentTarget)\n : undefined\n }\n onMouseLeave={info ? () => onRowLeave() : undefined}\n onClick={\n info && primaryIndex != null\n ? (event) => onRowClick(primaryIndex, event.currentTarget)\n : undefined\n }\n onKeyDown={\n info && primaryIndex != null\n ? (event) => {\n if (event.key !== \"Enter\" && event.key !== \" \") return;\n event.preventDefault();\n onRowClick(primaryIndex, event.currentTarget);\n }\n : undefined\n }\n onFocus={\n info && primaryIndex != null\n ? (event) => onRowEnter(primaryIndex, event.currentTarget)\n : undefined\n }\n onBlur={info ? () => onRowLeave() : undefined}\n >\n <span className={cn(LINE_NO_CLASS, \"w-[52px]\")}>\n {side === \"old\" ? (row.oldNo ?? \"\") : (row.newNo ?? \"\")}\n </span>\n <span\n className={cn(\n \"w-6 shrink-0 select-none py-0 text-center font-semibold leading-5\",\n GUTTER_BG[row.kind],\n SIGN_COLOR[row.kind],\n )}\n >\n {showSign ? sign : \" \"}\n </span>\n {showMarkerColumn && (\n <MarkerCell\n startMarker={startMarker}\n active={\n startMarker != null &&\n (startMarker.index === activeIndex ||\n persistentAnnotationIndexes.has(startMarker.index))\n }\n />\n )}\n <DiffLineText text={row.text} language={language} />\n {overlayItems.length > 0 && (\n <AnnotationInlineOverlayStack\n items={overlayItems}\n ctx={ctx}\n showMarker\n containerRef={annotationOverlayContainerRef}\n mode={annotationOverlayMode}\n side={annotationOverlaySide}\n preferredSide={annotationOverlayPreferredSide}\n />\n )}\n </div>\n );\n}\n\n/* ── Edit (panel) ──────────────────────────────────────────────────────────── */\n\nconst codeAreaClass =\n \"min-h-[140px] font-mono [font-size:var(--plan-code-size)] leading-5\";\n\nfunction DiffEdit({ data, onChange, editable }: BlockEditProps<DiffData>) {\n const patch = (next: Partial<DiffData>) => onChange({ ...data, ...next });\n const mode: DiffMode = data.mode ?? \"split\";\n const annotations = data.annotations ?? [];\n\n const updateAnnotation = (index: number, next: Partial<DiffAnnotation>) =>\n patch({\n annotations: annotations.map((annotation, i) =>\n i === index ? { ...annotation, ...next } : annotation,\n ),\n });\n\n const removeAnnotation = (index: number) =>\n patch({ annotations: annotations.filter((_, i) => i !== index) });\n\n const addAnnotation = () => {\n if (annotations.length >= 80) return; // schema max\n patch({\n annotations: [\n ...annotations,\n { side: \"after\", lines: \"1\", label: \"\", note: \"\" },\n ],\n });\n };\n\n return (\n <div className=\"flex flex-col gap-3\" data-plan-interactive>\n <div className=\"grid gap-3 sm:grid-cols-2\">\n <div className=\"flex flex-col gap-1.5\">\n <DevLabel htmlFor=\"diff-filename\" className=\"text-xs\">\n Filename\n </DevLabel>\n <DevInput\n id=\"diff-filename\"\n value={data.filename ?? \"\"}\n placeholder=\"src/add.ts\"\n disabled={!editable}\n onChange={(event) =>\n patch({ filename: event.target.value || undefined })\n }\n />\n </div>\n <div className=\"flex flex-col gap-1.5\">\n <DevLabel htmlFor=\"diff-language\" className=\"text-xs\">\n Language\n </DevLabel>\n <DevInput\n id=\"diff-language\"\n value={data.language ?? \"\"}\n placeholder=\"ts\"\n disabled={!editable}\n onChange={(event) =>\n patch({ language: event.target.value || undefined })\n }\n />\n </div>\n </div>\n\n <div className=\"flex flex-col gap-1.5\">\n <DevLabel className=\"text-xs\">Layout</DevLabel>\n <DevSelect\n value={mode}\n disabled={!editable}\n onValueChange={(value) => patch({ mode: value as DiffMode })}\n options={[\n { value: \"unified\", label: \"Unified\" },\n { value: \"split\", label: \"Split (side-by-side)\" },\n ]}\n />\n </div>\n\n <div className=\"flex flex-col gap-1.5\">\n <DevLabel htmlFor=\"diff-before\" className=\"text-xs\">\n Before\n </DevLabel>\n <DevTextarea\n id=\"diff-before\"\n spellCheck={false}\n className={codeAreaClass}\n value={data.before}\n disabled={!editable}\n onChange={(event) => patch({ before: event.target.value })}\n />\n </div>\n\n <div className=\"flex flex-col gap-1.5\">\n <DevLabel htmlFor=\"diff-after\" className=\"text-xs\">\n After\n </DevLabel>\n <DevTextarea\n id=\"diff-after\"\n spellCheck={false}\n className={codeAreaClass}\n value={data.after}\n disabled={!editable}\n onChange={(event) => patch({ after: event.target.value })}\n />\n </div>\n\n <div className=\"flex flex-col gap-2\">\n <div className=\"flex items-center justify-between\">\n <DevLabel className=\"text-xs\">Annotations</DevLabel>\n {editable && annotations.length < 80 && (\n <button\n type=\"button\"\n data-plan-interactive\n onClick={addAnnotation}\n className=\"flex cursor-pointer items-center gap-1 rounded-md px-2 py-1 text-xs font-medium text-plan-muted transition-colors hover:bg-plan-block/60 hover:text-plan-text\"\n >\n <IconPlus className=\"size-3.5\" />\n Add annotation\n </button>\n )}\n </div>\n {annotations.length === 0 && (\n <p className=\"text-xs text-plan-muted\">\n No annotations yet. Add one to anchor a note to a line range on the\n before or after side.\n </p>\n )}\n {annotations.map((annotation, index) => (\n <div\n key={index}\n className=\"flex flex-col gap-2 rounded-md border border-plan-line bg-plan-block/30 p-2\"\n >\n <div className=\"grid gap-2 sm:grid-cols-[110px_110px_minmax(0,1fr)_auto]\">\n <DevSelect\n aria-label={`Annotation ${index + 1} side`}\n value={annotation.side ?? \"after\"}\n disabled={!editable}\n onValueChange={(value) =>\n updateAnnotation(index, {\n side: value as DiffAnnotation[\"side\"],\n })\n }\n options={[\n { value: \"after\", label: \"After\" },\n { value: \"before\", label: \"Before\" },\n ]}\n />\n <DevInput\n aria-label={`Annotation ${index + 1} lines`}\n value={annotation.lines}\n placeholder=\"3-5\"\n disabled={!editable}\n onChange={(event) =>\n updateAnnotation(index, { lines: event.target.value })\n }\n />\n <DevInput\n aria-label={`Annotation ${index + 1} label`}\n value={annotation.label ?? \"\"}\n placeholder=\"Label (optional)\"\n disabled={!editable}\n onChange={(event) =>\n updateAnnotation(index, {\n label: event.target.value || undefined,\n })\n }\n />\n {editable && (\n <button\n type=\"button\"\n data-plan-interactive\n aria-label={`Remove annotation ${index + 1}`}\n onClick={() => removeAnnotation(index)}\n className=\"flex size-9 shrink-0 cursor-pointer items-center justify-center rounded-md text-plan-muted transition-colors hover:bg-muted hover:text-foreground\"\n >\n <IconTrash className=\"size-4\" />\n </button>\n )}\n </div>\n <DevTextarea\n aria-label={`Annotation ${index + 1} note`}\n className=\"min-h-[60px] text-sm\"\n value={annotation.note}\n placeholder=\"Explain what these lines do…\"\n disabled={!editable}\n onChange={(event) =>\n updateAnnotation(index, { note: event.target.value })\n }\n />\n </div>\n ))}\n </div>\n </div>\n );\n}\n\nexport { DiffRead, DiffEdit };\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"diagram.d.ts","sourceRoot":"","sources":["../../../../src/client/blocks/library/diagram.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EAEf,MAAM,aAAa,CAAC;AAQrB,OAAO,EAGL,KAAK,WAAW,EAGjB,MAAM,qBAAqB,CAAC;AA+f7B;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,EAC9B,QAAQ,EACR,OAAO,GACR,EAAE;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,2CAsCA;AA2CD,iFAAiF;AACjF,wBAAgB,WAAW,CAAC,EAC1B,IAAI,EACJ,OAAO,EACP,KAAK,EACL,OAAO,EACP,GAAG,GACJ,EAAE,cAAc,CAAC,WAAW,CAAC,2CAY7B;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,EAC1B,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,KAAK,EACL,OAAO,EACP,GAAG,GACJ,EAAE,cAAc,CAAC,WAAW,CAAC,2CAkL7B;AAED,kFAAkF;AAClF,eAAO,MAAM,YAAY,8CAgBvB,CAAC"}
1
+ {"version":3,"file":"diagram.d.ts","sourceRoot":"","sources":["../../../../src/client/blocks/library/diagram.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EAEf,MAAM,aAAa,CAAC;AAarB,OAAO,EAGL,KAAK,WAAW,EAGjB,MAAM,qBAAqB,CAAC;AA+f7B;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,EAC9B,QAAQ,EACR,OAAO,GACR,EAAE;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,2CAsCA;AAuED,iFAAiF;AACjF,wBAAgB,WAAW,CAAC,EAC1B,IAAI,EACJ,OAAO,EACP,KAAK,EACL,OAAO,EACP,GAAG,GACJ,EAAE,cAAc,CAAC,WAAW,CAAC,2CAY7B;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,EAC1B,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,KAAK,EACL,OAAO,EACP,GAAG,GACJ,EAAE,cAAc,CAAC,WAAW,CAAC,2CAkL7B;AAED,kFAAkF;AAClF,eAAO,MAAM,YAAY,8CAgBvB,CAAC"}
@@ -1,11 +1,11 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useEffect, useId, useMemo, useRef, useState } from "react";
3
- import { IconArrowsMaximize, IconX } from "@tabler/icons-react";
3
+ import { IconArrowsMaximize, IconPencil, IconX } from "@tabler/icons-react";
4
4
  import { cn } from "../../utils.js";
5
5
  import { ltrCodeBlockProps } from "../code-block-direction.js";
6
6
  import { defineBlock } from "../types.js";
7
7
  import { AiEditableFieldLabel } from "../AiEditableField.js";
8
- import { RoughOverlay, useIsDark, useWireframeStyle } from "./wireframe-kit.js";
8
+ import { RoughOverlay, toggleWireframeStyle, useIsDark, useWireframeStyle, } from "./wireframe-kit.js";
9
9
  import { sanitizeDiagramHtml, sanitizeWireframeCss, scopeDesignCss, } from "./sanitize-html.js";
10
10
  import { diagramMdx, diagramSchema, } from "./diagram.config.js";
11
11
  /**
@@ -274,7 +274,18 @@ export function DiagramLightbox({ children, onClose, }) {
274
274
  */
275
275
  function ExpandableDiagramBody({ data, ctx, }) {
276
276
  const [expanded, setExpanded] = useState(false);
277
- return (_jsxs("div", { className: "group/diagram relative", children: [_jsx(DiagramBody, { data: data, ctx: ctx }), _jsx("button", { type: "button", "data-plan-interactive": true, onClick: () => setExpanded(true), "aria-label": "Expand diagram", title: "Expand diagram", className: "an-diagram-expand-trigger absolute right-2 top-2 z-10 flex size-7 items-center justify-center rounded-md border border-border/60 bg-background/90 text-muted-foreground opacity-0 shadow-sm backdrop-blur transition-[color,opacity] hover:text-foreground focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring group-hover/diagram:opacity-100", children: _jsx(IconArrowsMaximize, { className: "size-4" }) }), expanded ? (_jsx(DiagramLightbox, { onClose: () => setExpanded(false), children: _jsx(DiagramBody, { data: data, ctx: ctx }) })) : null] }));
277
+ const supportsStyleToggle = Boolean(data.html);
278
+ return (_jsxs("div", { className: "group/diagram relative", children: [_jsx(DiagramBody, { data: data, ctx: ctx }), _jsxs("div", { className: "absolute right-2 top-2 z-10 flex gap-1 opacity-0 transition-opacity focus-within:opacity-100 group-hover/diagram:opacity-100", children: [supportsStyleToggle && _jsx(DiagramStyleToggleButton, {}), _jsx("button", { type: "button", "data-plan-interactive": true, onClick: () => setExpanded(true), "aria-label": "Expand diagram", title: "Expand diagram", className: "an-diagram-expand-trigger flex size-7 items-center justify-center rounded-md border border-border/60 bg-background/90 text-muted-foreground shadow-sm backdrop-blur transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring", children: _jsx(IconArrowsMaximize, { className: "size-4" }) })] }), expanded ? (_jsx(DiagramLightbox, { onClose: () => setExpanded(false), children: _jsx(DiagramBody, { data: data, ctx: ctx }) })) : null] }));
279
+ }
280
+ function DiagramStyleToggleButton() {
281
+ const style = useWireframeStyle();
282
+ const nextStyle = style === "sketchy" ? "clean" : "sketchy";
283
+ const label = nextStyle === "clean" ? "Clean" : "Sketchy";
284
+ const description = `Switch to ${label.toLowerCase()} visual style`;
285
+ return (_jsxs("button", { type: "button", "data-plan-interactive": true, "aria-label": description, title: description, onClick: (event) => {
286
+ event.stopPropagation();
287
+ toggleWireframeStyle();
288
+ }, className: "inline-flex h-7 items-center gap-1 rounded-md border border-border/60 bg-background/90 px-2 text-xs font-medium text-muted-foreground shadow-sm backdrop-blur transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring", children: [_jsx(IconPencil, { className: "size-3.5", "aria-hidden": "true" }), _jsx("span", { children: label })] }));
278
289
  }
279
290
  /* -------------------------------------------------------------------------- */
280
291
  /* Read + Edit */