@agent-native/core 0.49.6 → 0.49.9
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.
- package/dist/agent/production-agent.d.ts.map +1 -1
- package/dist/agent/production-agent.js +6 -2
- package/dist/agent/production-agent.js.map +1 -1
- package/dist/agent/types.d.ts +6 -1
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/agent/types.js.map +1 -1
- package/dist/cli/app-skill.d.ts.map +1 -1
- package/dist/cli/app-skill.js +21 -5
- package/dist/cli/app-skill.js.map +1 -1
- package/dist/cli/connect.d.ts.map +1 -1
- package/dist/cli/connect.js +46 -2
- package/dist/cli/connect.js.map +1 -1
- package/dist/cli/pr-visual-recap-workflow.d.ts +1 -1
- package/dist/cli/pr-visual-recap-workflow.d.ts.map +1 -1
- package/dist/cli/pr-visual-recap-workflow.js +1 -1
- package/dist/cli/pr-visual-recap-workflow.js.map +1 -1
- package/dist/cli/recap.d.ts +6 -11
- package/dist/cli/recap.d.ts.map +1 -1
- package/dist/cli/recap.js +14 -24
- package/dist/cli/recap.js.map +1 -1
- package/dist/client/agent-chat-adapter.d.ts.map +1 -1
- package/dist/client/agent-chat-adapter.js +30 -11
- package/dist/client/agent-chat-adapter.js.map +1 -1
- package/dist/client/blocks/library/AnnotatedCodeBlock.d.ts.map +1 -1
- package/dist/client/blocks/library/AnnotatedCodeBlock.js +20 -4
- package/dist/client/blocks/library/AnnotatedCodeBlock.js.map +1 -1
- package/dist/client/blocks/library/DiffBlock.d.ts.map +1 -1
- package/dist/client/blocks/library/DiffBlock.js +33 -9
- package/dist/client/blocks/library/DiffBlock.js.map +1 -1
- package/dist/client/blocks/library/annotation-rail.d.ts +41 -3
- package/dist/client/blocks/library/annotation-rail.d.ts.map +1 -1
- package/dist/client/blocks/library/annotation-rail.js +157 -29
- package/dist/client/blocks/library/annotation-rail.js.map +1 -1
- package/dist/client/blocks/types.d.ts +19 -0
- package/dist/client/blocks/types.d.ts.map +1 -1
- package/dist/client/blocks/types.js.map +1 -1
- package/dist/client/sse-event-processor.d.ts.map +1 -1
- package/dist/client/sse-event-processor.js +13 -12
- package/dist/client/sse-event-processor.js.map +1 -1
- package/dist/vite/client.d.ts.map +1 -1
- package/dist/vite/client.js +6 -8
- package/dist/vite/client.js.map +1 -1
- package/docs/content/pr-visual-recap.md +11 -12
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnnotatedCodeBlock.d.ts","sourceRoot":"","sources":["../../../../src/client/blocks/library/AnnotatedCodeBlock.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,KAAK,EAEV,iBAAiB,EAClB,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"AnnotatedCodeBlock.d.ts","sourceRoot":"","sources":["../../../../src/client/blocks/library/AnnotatedCodeBlock.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,KAAK,EAEV,iBAAiB,EAClB,MAAM,4BAA4B,CAAC;AA6IpC,iBAAS,iBAAiB,CAAC,EACzB,IAAI,EACJ,OAAO,EACP,KAAK,EACL,OAAO,EACP,GAAG,GACJ,EAAE,cAAc,CAAC,iBAAiB,CAAC,2CAmSnC;AAOD,iBAAS,iBAAiB,CAAC,EACzB,IAAI,EACJ,QAAQ,EACR,QAAQ,GACT,EAAE,cAAc,CAAC,iBAAiB,CAAC,2CAiJnC;AAED,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -3,7 +3,7 @@ import { useMemo, useRef, useState } from "react";
|
|
|
3
3
|
import { IconCode, IconPlus, IconTrash } from "@tabler/icons-react";
|
|
4
4
|
import { cn } from "../../utils.js";
|
|
5
5
|
import { highlightCode, inferLanguageFromFilename, normalizeCodeLanguage, } from "./code-highlight.js";
|
|
6
|
-
import { AnnotationHiddenStack, AnnotationHoverCard, AnnotationInlineOverlayStack, anchorFromElements, buildLineMarkerMap, hasRailAnnotations, resolveAnnotations, useAnnotationHover, } from "./annotation-rail.js";
|
|
6
|
+
import { AnnotationHiddenStack, AnnotationHoverCard, AnnotationInlineOverlayStack, anchorFromElements, buildLineMarkerMap, hasRailAnnotations, resolveAnnotations, useAnnotationMarginNotesAvailable, useAnnotationHover, } from "./annotation-rail.js";
|
|
7
7
|
import { CodeFilenameLabel } from "./code-filename-label.js";
|
|
8
8
|
import { DevInput, DevLabel, DevTextarea } from "./dev-doc-ui.js";
|
|
9
9
|
/**
|
|
@@ -120,6 +120,19 @@ function AnnotatedCodeRead({ data, blockId, title, summary, ctx, }) {
|
|
|
120
120
|
const lineMarkers = useMemo(() => buildLineMarkerMap(resolved), [resolved]);
|
|
121
121
|
const hasAnnotations = hasRailAnnotations(resolved);
|
|
122
122
|
const showAnnotationOverlays = Boolean(ctx.showCodeAnnotationOverlays);
|
|
123
|
+
const annotationLayout = ctx.codeAnnotationLayout;
|
|
124
|
+
const annotationHoverSide = annotationLayout?.hoverSide ?? "right";
|
|
125
|
+
const annotationHoverFallbackSide = annotationLayout?.hoverFallbackSide ?? "below";
|
|
126
|
+
const annotationMarginSide = annotationLayout?.marginSide ?? "auto";
|
|
127
|
+
const showMarginAnnotations = useAnnotationMarginNotesAvailable({
|
|
128
|
+
containerRef: codeRef,
|
|
129
|
+
enabled: Boolean(hasAnnotations &&
|
|
130
|
+
!showAnnotationOverlays &&
|
|
131
|
+
annotationLayout?.showByDefaultWhenRoom),
|
|
132
|
+
side: annotationMarginSide,
|
|
133
|
+
preferredSide: annotationHoverSide,
|
|
134
|
+
});
|
|
135
|
+
const showPersistentAnnotations = showAnnotationOverlays || showMarginAnnotations;
|
|
123
136
|
const langChip = data.language?.trim();
|
|
124
137
|
const hasFilename = Boolean(data.filename?.trim());
|
|
125
138
|
const showLangChip = Boolean(langChip && !hasFilename);
|
|
@@ -135,7 +148,7 @@ function AnnotatedCodeRead({ data, blockId, title, summary, ctx, }) {
|
|
|
135
148
|
const markers = lineMarkers.get(lineNo);
|
|
136
149
|
const isAnnotated = !!markers?.length;
|
|
137
150
|
const isActive = activeIndex != null && !!markers?.some((m) => m.index === activeIndex);
|
|
138
|
-
const overlayItems =
|
|
151
|
+
const overlayItems = showPersistentAnnotations && markers
|
|
139
152
|
? markers.filter((item) => item.range?.start === lineNo)
|
|
140
153
|
: [];
|
|
141
154
|
const buildAnchorForRow = (el) => {
|
|
@@ -185,7 +198,7 @@ function AnnotatedCodeRead({ data, blockId, title, summary, ctx, }) {
|
|
|
185
198
|
: showAnnotationOverlays
|
|
186
199
|
? "bg-amber-500/90 dark:bg-amber-300/70"
|
|
187
200
|
: "bg-amber-400/45 dark:bg-amber-300/35"
|
|
188
|
-
: null) }), _jsx("span", { className: "w-11 shrink-0 select-none px-3 text-right text-[11px] tabular-nums text-plan-muted/60", children: lineNo }), _jsx("span", { className: "flex-1 whitespace-pre pr-4 text-plan-code-text", children: highlightedLines[lineNo - 1] }), overlayItems.length > 0 && (_jsx(AnnotationInlineOverlayStack, { items: overlayItems, ctx: ctx }))] }, lineNo));
|
|
201
|
+
: null) }), _jsx("span", { className: "w-11 shrink-0 select-none px-3 text-right text-[11px] tabular-nums text-plan-muted/60", children: lineNo }), _jsx("span", { className: "flex-1 whitespace-pre pr-4 text-plan-code-text", children: highlightedLines[lineNo - 1] }), overlayItems.length > 0 && (_jsx(AnnotationInlineOverlayStack, { items: overlayItems, ctx: ctx, containerRef: codeRef, mode: showAnnotationOverlays ? "capture" : "margin", side: showAnnotationOverlays ? "right" : annotationMarginSide, preferredSide: annotationHoverSide }))] }, lineNo));
|
|
189
202
|
};
|
|
190
203
|
const codeSurface = (_jsxs("div", { ref: codeRef, className: "overflow-hidden rounded-xl border border-plan-line bg-plan-code", children: [(hasFilename || showLangChip) && (_jsxs("div", { className: "flex items-center gap-2 border-b border-plan-line bg-plan-block/50 px-3.5 py-2", children: [_jsx(IconCode, { className: "size-3.5 shrink-0 text-plan-muted" }), _jsx(CodeFilenameLabel, { filename: data.filename, className: "text-[13px] font-medium", directoryClassName: "text-plan-muted", basenameClassName: "text-plan-code-text" }), showLangChip && (_jsx("span", { className: "shrink-0 rounded border border-plan-line px-1.5 py-0.5 font-mono text-[10px] uppercase tracking-wide text-plan-muted", children: langChip }))] })), _jsx("div", { className: "overflow-x-auto py-1.5", "data-code-surface": true, children: _jsx("div", { className: "min-w-full font-mono [font-size:var(--plan-doc-code-size)] leading-[22px]", children: segments.map((seg) => {
|
|
191
204
|
if (seg.kind === "visible") {
|
|
@@ -205,7 +218,10 @@ function AnnotatedCodeRead({ data, blockId, title, summary, ctx, }) {
|
|
|
205
218
|
return next;
|
|
206
219
|
}), className: "flex w-full cursor-pointer items-center gap-2 border-y border-plan-line/50 bg-plan-block/20 px-3 py-0.5 text-left hover:bg-plan-block/40", children: [_jsx("span", { "aria-hidden": true, className: "w-[3px] shrink-0 self-stretch" }), _jsx("span", { className: "w-8 shrink-0 select-none text-right text-[11px] tabular-nums text-plan-muted/40", children: "\u00B7\u00B7\u00B7" }), _jsxs("span", { className: "flex-1 text-[11px] text-plan-muted/70", children: [hiddenCount, " lines \u2014 click to expand"] })] }, `collapse-${seg.startLine}`));
|
|
207
220
|
}) }) })] }));
|
|
208
|
-
return (_jsxs("section", { className: "plan-block relative", "data-block-id": blockId, children: [title && _jsx("div", { className: "plan-block-label", children: title }), codeSurface, hasAnnotations && _jsx(AnnotationHiddenStack, { items: resolved, ctx: ctx }), hasAnnotations &&
|
|
221
|
+
return (_jsxs("section", { className: "plan-block relative", "data-block-id": blockId, children: [title && _jsx("div", { className: "plan-block-label", children: title }), codeSurface, hasAnnotations && _jsx(AnnotationHiddenStack, { items: resolved, ctx: ctx }), hasAnnotations &&
|
|
222
|
+
!showPersistentAnnotations &&
|
|
223
|
+
activeItem &&
|
|
224
|
+
hover.anchor && (_jsx(AnnotationHoverCard, { item: activeItem, anchor: hover.anchor, ctx: ctx, preferredSide: annotationHoverSide, hoverFallbackSide: annotationHoverFallbackSide, onMouseEnter: hover.cancelClose, onMouseLeave: hover.scheduleClose, onClose: hover.closeForScroll })), summary && _jsx("p", { className: "mt-5 text-plan-muted", children: summary })] }));
|
|
209
225
|
}
|
|
210
226
|
/* ── Edit (panel) ──────────────────────────────────────────────────────────── */
|
|
211
227
|
const codeAreaClass = "min-h-[160px] font-mono [font-size:var(--plan-code-size)] leading-5";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnnotatedCodeBlock.js","sourceRoot":"","sources":["../../../../src/client/blocks/library/AnnotatedCodeBlock.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACpE,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAMpC,OAAO,EACL,aAAa,EACb,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,4BAA4B,EAC5B,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,GAEnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAElE;;;;;;;;;;;;;;;;;;GAkBG;AAEH,kFAAkF;AAElF;;;GAGG;AACH,MAAM,wBAAwB,GAAG,EAAE,CAAC;AAEpC;;;GAGG;AACH,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAE9B;;;GAGG;AACH,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAUhC;;;;;;GAMG;AACH,SAAS,iBA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,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,KA7CG,KAAK,CA8CN,CACP,CAAC,IACE,IACF,CACP,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,CAAC","sourcesContent":["import { useMemo, useRef, useState } from \"react\";\nimport { IconCode, IconPlus, IconTrash } from \"@tabler/icons-react\";\nimport { cn } from \"../../utils.js\";\nimport type { BlockEditProps, BlockReadProps } from \"../types.js\";\nimport type {\n AnnotatedCodeAnnotation,\n AnnotatedCodeData,\n} from \"./annotated-code.config.js\";\nimport {\n highlightCode,\n inferLanguageFromFilename,\n normalizeCodeLanguage,\n} from \"./code-highlight.js\";\nimport {\n AnnotationHiddenStack,\n AnnotationHoverCard,\n AnnotationInlineOverlayStack,\n anchorFromElements,\n buildLineMarkerMap,\n hasRailAnnotations,\n resolveAnnotations,\n useAnnotationHover,\n type ResolvedAnnotation,\n} from \"./annotation-rail.js\";\nimport { CodeFilenameLabel } from \"./code-filename-label.js\";\nimport { DevInput, DevLabel, DevTextarea } from \"./dev-doc-ui.js\";\n\n/**\n * \"Explain this code\" walkthrough block: a standard syntax-highlighted code\n * surface on the left with line-anchored annotation cards on the right (the\n * Stripe-docs / Sourcegraph layout). Each annotated line range gets a subtle\n * highlight band + an accent rail down the gutter; its card shows the `lines`\n * range, optional `label`, and the always-visible markdown `note` (via\n * `ctx.renderMarkdown`). Hovering a card highlights its lines and vice-versa.\n *\n * Syntax highlighting reuses the shared `highlightCode` lowlight helper (the same\n * colorful palette as the `code-tabs` block) per line, so it matches the app's\n * standard code styling and supports per-line bands without an async loader. The\n * surface uses the plan `--plan-code*`/`--plan-*` tokens and Tailwind `dark:`\n * pairs, so it reads correctly in BOTH light and dark mode. Code lines render as\n * `<span>`s (never one `<pre>` per line) so they don't pick up document\n * code/pre chrome. Lives in core so any app can register the dev-doc block.\n *\n * Editing is panel-driven (config-style, like the diff/HTML blocks): a monospace\n * code Textarea, filename/language Inputs, and add/remove-able annotation rows.\n */\n\n/* ── Collapse helpers ──────────────────────────────────────────────────────── */\n\n/**\n * Minimum total line count before collapse is considered. Short files render\n * fully expanded regardless of annotation coverage.\n */\nconst COLLAPSE_MIN_TOTAL_LINES = 40;\n\n/**\n * Number of unannotated lines in a run that triggers collapse. Runs at or\n * below this threshold always stay expanded (no expander button).\n */\nconst COLLAPSE_THRESHOLD = 16;\n\n/**\n * Context lines kept visible at each edge of a collapsed run (8 lines of\n * breathing room so the collapsed region is clearly framed).\n */\nconst COLLAPSE_CONTEXT_EDGE = 8;\n\ntype CollapsedSegment = {\n kind: \"collapsed\";\n startLine: number;\n endLine: number;\n};\ntype VisibleSegment = { kind: \"visible\"; startLine: number; endLine: number };\ntype LineSegment = VisibleSegment | CollapsedSegment;\n\n/**\n * Partition line numbers [1..lineCount] into visible and collapsed segments.\n * Annotated lines (and COLLAPSE_CONTEXT_EDGE lines on either side of them) are\n * always visible. Runs of unannotated lines longer than COLLAPSE_THRESHOLD are\n * collapsed. The file header (first COLLAPSE_CONTEXT_EDGE lines) is always\n * visible so context is preserved.\n */\nfunction buildLineSegments(\n lineCount: number,\n lineMarkers: Map<number, Array<{ index: number }>>,\n): LineSegment[] {\n if (lineCount <= COLLAPSE_MIN_TOTAL_LINES) {\n return [{ kind: \"visible\", startLine: 1, endLine: lineCount }];\n }\n\n // Build a boolean array: true if the line must stay visible.\n const mustShow = new Array<boolean>(lineCount + 1).fill(false);\n // File header always visible.\n for (let i = 1; i <= Math.min(COLLAPSE_CONTEXT_EDGE, lineCount); i += 1) {\n mustShow[i] = true;\n }\n // Annotated lines and their context edges.\n for (const lineNo of lineMarkers.keys()) {\n for (\n let i = Math.max(1, lineNo - COLLAPSE_CONTEXT_EDGE);\n i <= Math.min(lineCount, lineNo + COLLAPSE_CONTEXT_EDGE);\n i += 1\n ) {\n mustShow[i] = true;\n }\n }\n\n // Compute initial segments.\n const raw: LineSegment[] = [];\n let segStart = 1;\n let visible = mustShow[1] ?? false;\n for (let i = 2; i <= lineCount; i += 1) {\n const nextVisible = mustShow[i] ?? false;\n if (nextVisible !== visible) {\n raw.push(\n visible\n ? { kind: \"visible\", startLine: segStart, endLine: i - 1 }\n : { kind: \"collapsed\", startLine: segStart, endLine: i - 1 },\n );\n segStart = i;\n visible = nextVisible;\n }\n }\n raw.push(\n visible\n ? { kind: \"visible\", startLine: segStart, endLine: lineCount }\n : { kind: \"collapsed\", startLine: segStart, endLine: lineCount },\n );\n\n // Don't collapse short hidden runs — expand them in-place.\n return raw.map((seg) => {\n if (\n seg.kind === \"collapsed\" &&\n seg.endLine - seg.startLine + 1 <= COLLAPSE_THRESHOLD\n ) {\n return {\n kind: \"visible\",\n startLine: seg.startLine,\n endLine: seg.endLine,\n };\n }\n return seg;\n });\n}\n\n/* ── Read ──────────────────────────────────────────────────────────────────── */\n\nfunction AnnotatedCodeRead({\n data,\n blockId,\n title,\n summary,\n ctx,\n}: BlockReadProps<AnnotatedCodeData>) {\n // On-hover popover (anchored to the right of the code) replaces the old\n // persistent rail: nothing is visible when idle. `codeRef` measures the code\n // block'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 const lineRefs = useRef(new Map<number, HTMLDivElement>());\n\n const setLineRef = (lineNo: number, node: HTMLDivElement | null) => {\n if (node) lineRefs.current.set(lineNo, node);\n else lineRefs.current.delete(lineNo);\n };\n\n const lines = useMemo(\n () => data.code.replace(/\\n$/, \"\").split(\"\\n\"),\n [data.code],\n );\n const lineCount = lines.length;\n\n const language = useMemo(\n () =>\n normalizeCodeLanguage(data.language) ??\n inferLanguageFromFilename(data.filename),\n [data.language, data.filename],\n );\n\n // Highlight each line once; empty lines keep their height with a NBSP.\n const highlightedLines = useMemo(\n () =>\n lines.map((text) => (text.length ? highlightCode(text, language) : \" \")),\n [lines, language],\n );\n\n const resolved = useMemo(\n () => resolveAnnotations(data.annotations, () => lineCount),\n [data.annotations, lineCount],\n );\n\n // line number (1-based) → resolved annotations covering it.\n const lineMarkers = useMemo(() => buildLineMarkerMap(resolved), [resolved]);\n\n const hasAnnotations = hasRailAnnotations(resolved);\n const showAnnotationOverlays = Boolean(ctx.showCodeAnnotationOverlays);\n const langChip = data.language?.trim();\n const hasFilename = Boolean(data.filename?.trim());\n const showLangChip = Boolean(langChip && !hasFilename);\n\n // The resolved annotation whose card is currently shown on hover.\n const activeItem =\n useMemo<ResolvedAnnotation<AnnotatedCodeAnnotation> | null>(\n () =>\n activeIndex == null\n ? null\n : (resolved.find((item) => item.index === activeIndex) ?? null),\n [activeIndex, resolved],\n );\n\n // Line-collapse state: a set of collapsed segment start lines that have been\n // expanded by the reader. Starts empty (all segments in their default state).\n const [expandedCollapsed, setExpandedCollapsed] = useState<Set<number>>(\n () => new Set(),\n );\n\n const segments = useMemo(\n () => buildLineSegments(lineCount, lineMarkers),\n [lineCount, lineMarkers],\n );\n\n const renderLine = (lineNo: number) => {\n const markers = lineMarkers.get(lineNo);\n const isAnnotated = !!markers?.length;\n const isActive =\n activeIndex != null && !!markers?.some((m) => m.index === activeIndex);\n const overlayItems =\n showAnnotationOverlays && markers\n ? markers.filter((item) => item.range?.start === lineNo)\n : [];\n\n const buildAnchorForRow = (el: HTMLElement) => {\n if (!markers) return null;\n const primaryMarker = markers[0];\n const anchorLine = primaryMarker.range?.start ?? lineNo;\n const anchorRow = lineRefs.current.get(anchorLine) ?? el;\n return anchorFromElements(codeRef.current, anchorRow);\n };\n\n return (\n <div\n key={lineNo}\n ref={(node) => setLineRef(lineNo, node)}\n data-code-line={lineNo}\n data-annot-row={isAnnotated ? markers?.[0].index : undefined}\n tabIndex={isAnnotated ? 0 : undefined}\n role={isAnnotated ? \"button\" : undefined}\n aria-expanded={isAnnotated ? isActive : undefined}\n aria-label={isAnnotated ? `Line ${lineNo} annotation` : undefined}\n className={cn(\n \"relative flex w-full\",\n isAnnotated && \"cursor-pointer\",\n isActive\n ? \"bg-amber-400/20 dark:bg-amber-300/15\"\n : isAnnotated && showAnnotationOverlays\n ? \"bg-amber-300/25 dark:bg-amber-300/15\"\n : isAnnotated\n ? \"bg-amber-400/[0.07] dark:bg-amber-300/[0.07]\"\n : null,\n )}\n onMouseEnter={\n isAnnotated && markers\n ? (event) => {\n const anchor = buildAnchorForRow(event.currentTarget);\n if (anchor) hover.open(markers[0].index, anchor);\n }\n : undefined\n }\n onMouseLeave={isAnnotated ? () => hover.scheduleClose() : undefined}\n onClick={\n isAnnotated && markers\n ? (event) => {\n const anchor = buildAnchorForRow(event.currentTarget);\n if (anchor) hover.open(markers[0].index, anchor);\n }\n : undefined\n }\n onKeyDown={\n isAnnotated && markers\n ? (event) => {\n if (event.key !== \"Enter\" && event.key !== \" \") return;\n event.preventDefault();\n const anchor = buildAnchorForRow(event.currentTarget);\n if (anchor) hover.open(markers[0].index, anchor);\n }\n : undefined\n }\n onFocus={\n isAnnotated && markers\n ? (event) => {\n const anchor = buildAnchorForRow(event.currentTarget);\n if (anchor) hover.open(markers[0].index, anchor);\n }\n : undefined\n }\n onBlur={isAnnotated ? () => hover.scheduleClose() : undefined}\n >\n <span\n aria-hidden\n className={cn(\n \"w-[3px] shrink-0 self-stretch\",\n isAnnotated\n ? isActive\n ? \"bg-amber-500 dark:bg-amber-400\"\n : showAnnotationOverlays\n ? \"bg-amber-500/90 dark:bg-amber-300/70\"\n : \"bg-amber-400/45 dark:bg-amber-300/35\"\n : null,\n )}\n />\n <span className=\"w-11 shrink-0 select-none px-3 text-right text-[11px] tabular-nums text-plan-muted/60\">\n {lineNo}\n </span>\n <span className=\"flex-1 whitespace-pre pr-4 text-plan-code-text\">\n {highlightedLines[lineNo - 1]}\n </span>\n {overlayItems.length > 0 && (\n <AnnotationInlineOverlayStack items={overlayItems} ctx={ctx} />\n )}\n </div>\n );\n };\n\n const codeSurface = (\n <div\n ref={codeRef}\n className=\"overflow-hidden rounded-xl border border-plan-line bg-plan-code\"\n >\n {(hasFilename || showLangChip) && (\n <div className=\"flex items-center gap-2 border-b border-plan-line bg-plan-block/50 px-3.5 py-2\">\n <IconCode className=\"size-3.5 shrink-0 text-plan-muted\" />\n <CodeFilenameLabel\n filename={data.filename}\n className=\"text-[13px] font-medium\"\n directoryClassName=\"text-plan-muted\"\n basenameClassName=\"text-plan-code-text\"\n />\n {showLangChip && (\n <span className=\"shrink-0 rounded border border-plan-line px-1.5 py-0.5 font-mono text-[10px] uppercase tracking-wide text-plan-muted\">\n {langChip}\n </span>\n )}\n </div>\n )}\n <div className=\"overflow-x-auto py-1.5\" data-code-surface>\n <div className=\"min-w-full font-mono [font-size:var(--plan-doc-code-size)] leading-[22px]\">\n {segments.map((seg) => {\n if (seg.kind === \"visible\") {\n const lineNos = Array.from(\n { length: seg.endLine - seg.startLine + 1 },\n (_, i) => seg.startLine + i,\n );\n return lineNos.map(renderLine);\n }\n // Collapsed segment — show an expander row.\n const isExpanded = expandedCollapsed.has(seg.startLine);\n const hiddenCount = seg.endLine - seg.startLine + 1;\n if (isExpanded) {\n const lineNos = Array.from(\n { length: hiddenCount },\n (_, i) => seg.startLine + i,\n );\n return lineNos.map(renderLine);\n }\n return (\n <button\n key={`collapse-${seg.startLine}`}\n type=\"button\"\n data-plan-interactive\n onClick={() =>\n setExpandedCollapsed((prev) => {\n const next = new Set(prev);\n next.add(seg.startLine);\n return next;\n })\n }\n className=\"flex w-full cursor-pointer items-center gap-2 border-y border-plan-line/50 bg-plan-block/20 px-3 py-0.5 text-left hover:bg-plan-block/40\"\n >\n <span aria-hidden className=\"w-[3px] shrink-0 self-stretch\" />\n <span className=\"w-8 shrink-0 select-none text-right text-[11px] tabular-nums text-plan-muted/40\">\n ···\n </span>\n <span className=\"flex-1 text-[11px] text-plan-muted/70\">\n {hiddenCount} lines — click to expand\n </span>\n </button>\n );\n })}\n </div>\n </div>\n </div>\n );\n\n return (\n <section className=\"plan-block relative\" data-block-id={blockId}>\n {title && <div className=\"plan-block-label\">{title}</div>}\n {/* The code keeps its full width — no persistent annotation column. Notes\n live in a visually-hidden stack (a11y + tests) and surface ONE at a\n time as an on-hover popover anchored to the right of the code. */}\n {codeSurface}\n {hasAnnotations && <AnnotationHiddenStack items={resolved} ctx={ctx} />}\n {hasAnnotations && activeItem && hover.anchor && (\n <AnnotationHoverCard\n item={activeItem}\n anchor={hover.anchor}\n ctx={ctx}\n onMouseEnter={hover.cancelClose}\n onMouseLeave={hover.scheduleClose}\n onClose={hover.closeForScroll}\n />\n )}\n {summary && <p className=\"mt-5 text-plan-muted\">{summary}</p>}\n </section>\n );\n}\n\n/* ── Edit (panel) ──────────────────────────────────────────────────────────── */\n\nconst codeAreaClass =\n \"min-h-[160px] font-mono [font-size:var(--plan-code-size)] leading-5\";\n\nfunction AnnotatedCodeEdit({\n data,\n onChange,\n editable,\n}: BlockEditProps<AnnotatedCodeData>) {\n const annotations = data.annotations ?? [];\n const patch = (next: Partial<AnnotatedCodeData>) =>\n onChange({ ...data, ...next });\n\n const updateAnnotation = (\n index: number,\n next: Partial<AnnotatedCodeAnnotation>,\n ) =>\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: [...annotations, { lines: \"1\", label: \"\", note: \"\" }],\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=\"annotated-code-filename\" className=\"text-xs\">\n Filename\n </DevLabel>\n <DevInput\n id=\"annotated-code-filename\"\n value={data.filename ?? \"\"}\n placeholder=\"src/server/auth.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=\"annotated-code-language\" className=\"text-xs\">\n Language\n </DevLabel>\n <DevInput\n id=\"annotated-code-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 htmlFor=\"annotated-code-code\" className=\"text-xs\">\n Code\n </DevLabel>\n <DevTextarea\n id=\"annotated-code-code\"\n spellCheck={false}\n className={codeAreaClass}\n value={data.code}\n disabled={!editable}\n onChange={(event) => patch({ code: 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.\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-[120px_minmax(0,1fr)_auto]\">\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 { AnnotatedCodeRead, AnnotatedCodeEdit };\n"]}
|
|
1
|
+
{"version":3,"file":"AnnotatedCodeBlock.js","sourceRoot":"","sources":["../../../../src/client/blocks/library/AnnotatedCodeBlock.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACpE,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAMpC,OAAO,EACL,aAAa,EACb,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,4BAA4B,EAC5B,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,iCAAiC,EACjC,kBAAkB,GAEnB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,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,KA7CG,KAAK,CA8CN,CACP,CAAC,IACE,IACF,CACP,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,CAAC","sourcesContent":["import { useMemo, useRef, useState } from \"react\";\nimport { IconCode, IconPlus, IconTrash } from \"@tabler/icons-react\";\nimport { cn } from \"../../utils.js\";\nimport type { BlockEditProps, BlockReadProps } from \"../types.js\";\nimport type {\n AnnotatedCodeAnnotation,\n AnnotatedCodeData,\n} from \"./annotated-code.config.js\";\nimport {\n highlightCode,\n inferLanguageFromFilename,\n normalizeCodeLanguage,\n} from \"./code-highlight.js\";\nimport {\n AnnotationHiddenStack,\n AnnotationHoverCard,\n AnnotationInlineOverlayStack,\n anchorFromElements,\n buildLineMarkerMap,\n hasRailAnnotations,\n resolveAnnotations,\n useAnnotationMarginNotesAvailable,\n useAnnotationHover,\n type ResolvedAnnotation,\n} from \"./annotation-rail.js\";\nimport { CodeFilenameLabel } from \"./code-filename-label.js\";\nimport { DevInput, DevLabel, DevTextarea } from \"./dev-doc-ui.js\";\n\n/**\n * \"Explain this code\" walkthrough block: a standard syntax-highlighted code\n * surface on the left with line-anchored annotation cards on the right (the\n * Stripe-docs / Sourcegraph layout). Each annotated line range gets a subtle\n * highlight band + an accent rail down the gutter; its card shows the `lines`\n * range, optional `label`, and the always-visible markdown `note` (via\n * `ctx.renderMarkdown`). Hovering a card highlights its lines and vice-versa.\n *\n * Syntax highlighting reuses the shared `highlightCode` lowlight helper (the same\n * colorful palette as the `code-tabs` block) per line, so it matches the app's\n * standard code styling and supports per-line bands without an async loader. The\n * surface uses the plan `--plan-code*`/`--plan-*` tokens and Tailwind `dark:`\n * pairs, so it reads correctly in BOTH light and dark mode. Code lines render as\n * `<span>`s (never one `<pre>` per line) so they don't pick up document\n * code/pre chrome. Lives in core so any app can register the dev-doc block.\n *\n * Editing is panel-driven (config-style, like the diff/HTML blocks): a monospace\n * code Textarea, filename/language Inputs, and add/remove-able annotation rows.\n */\n\n/* ── Collapse helpers ──────────────────────────────────────────────────────── */\n\n/**\n * Minimum total line count before collapse is considered. Short files render\n * fully expanded regardless of annotation coverage.\n */\nconst COLLAPSE_MIN_TOTAL_LINES = 40;\n\n/**\n * Number of unannotated lines in a run that triggers collapse. Runs at or\n * below this threshold always stay expanded (no expander button).\n */\nconst COLLAPSE_THRESHOLD = 16;\n\n/**\n * Context lines kept visible at each edge of a collapsed run (8 lines of\n * breathing room so the collapsed region is clearly framed).\n */\nconst COLLAPSE_CONTEXT_EDGE = 8;\n\ntype CollapsedSegment = {\n kind: \"collapsed\";\n startLine: number;\n endLine: number;\n};\ntype VisibleSegment = { kind: \"visible\"; startLine: number; endLine: number };\ntype LineSegment = VisibleSegment | CollapsedSegment;\n\n/**\n * Partition line numbers [1..lineCount] into visible and collapsed segments.\n * Annotated lines (and COLLAPSE_CONTEXT_EDGE lines on either side of them) are\n * always visible. Runs of unannotated lines longer than COLLAPSE_THRESHOLD are\n * collapsed. The file header (first COLLAPSE_CONTEXT_EDGE lines) is always\n * visible so context is preserved.\n */\nfunction buildLineSegments(\n lineCount: number,\n lineMarkers: Map<number, Array<{ index: number }>>,\n): LineSegment[] {\n if (lineCount <= COLLAPSE_MIN_TOTAL_LINES) {\n return [{ kind: \"visible\", startLine: 1, endLine: lineCount }];\n }\n\n // Build a boolean array: true if the line must stay visible.\n const mustShow = new Array<boolean>(lineCount + 1).fill(false);\n // File header always visible.\n for (let i = 1; i <= Math.min(COLLAPSE_CONTEXT_EDGE, lineCount); i += 1) {\n mustShow[i] = true;\n }\n // Annotated lines and their context edges.\n for (const lineNo of lineMarkers.keys()) {\n for (\n let i = Math.max(1, lineNo - COLLAPSE_CONTEXT_EDGE);\n i <= Math.min(lineCount, lineNo + COLLAPSE_CONTEXT_EDGE);\n i += 1\n ) {\n mustShow[i] = true;\n }\n }\n\n // Compute initial segments.\n const raw: LineSegment[] = [];\n let segStart = 1;\n let visible = mustShow[1] ?? false;\n for (let i = 2; i <= lineCount; i += 1) {\n const nextVisible = mustShow[i] ?? false;\n if (nextVisible !== visible) {\n raw.push(\n visible\n ? { kind: \"visible\", startLine: segStart, endLine: i - 1 }\n : { kind: \"collapsed\", startLine: segStart, endLine: i - 1 },\n );\n segStart = i;\n visible = nextVisible;\n }\n }\n raw.push(\n visible\n ? { kind: \"visible\", startLine: segStart, endLine: lineCount }\n : { kind: \"collapsed\", startLine: segStart, endLine: lineCount },\n );\n\n // Don't collapse short hidden runs — expand them in-place.\n return raw.map((seg) => {\n if (\n seg.kind === \"collapsed\" &&\n seg.endLine - seg.startLine + 1 <= COLLAPSE_THRESHOLD\n ) {\n return {\n kind: \"visible\",\n startLine: seg.startLine,\n endLine: seg.endLine,\n };\n }\n return seg;\n });\n}\n\n/* ── Read ──────────────────────────────────────────────────────────────────── */\n\nfunction AnnotatedCodeRead({\n data,\n blockId,\n title,\n summary,\n ctx,\n}: BlockReadProps<AnnotatedCodeData>) {\n // On-hover popover (anchored to the right of the code) replaces the old\n // persistent rail: nothing is visible when idle. `codeRef` measures the code\n // block'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 const lineRefs = useRef(new Map<number, HTMLDivElement>());\n\n const setLineRef = (lineNo: number, node: HTMLDivElement | null) => {\n if (node) lineRefs.current.set(lineNo, node);\n else lineRefs.current.delete(lineNo);\n };\n\n const lines = useMemo(\n () => data.code.replace(/\\n$/, \"\").split(\"\\n\"),\n [data.code],\n );\n const lineCount = lines.length;\n\n const language = useMemo(\n () =>\n normalizeCodeLanguage(data.language) ??\n inferLanguageFromFilename(data.filename),\n [data.language, data.filename],\n );\n\n // Highlight each line once; empty lines keep their height with a NBSP.\n const highlightedLines = useMemo(\n () =>\n lines.map((text) => (text.length ? highlightCode(text, language) : \" \")),\n [lines, language],\n );\n\n const resolved = useMemo(\n () => resolveAnnotations(data.annotations, () => lineCount),\n [data.annotations, lineCount],\n );\n\n // line number (1-based) → resolved annotations covering it.\n const lineMarkers = useMemo(() => buildLineMarkerMap(resolved), [resolved]);\n\n const hasAnnotations = hasRailAnnotations(resolved);\n const showAnnotationOverlays = Boolean(ctx.showCodeAnnotationOverlays);\n const annotationLayout = ctx.codeAnnotationLayout;\n const annotationHoverSide = annotationLayout?.hoverSide ?? \"right\";\n const annotationHoverFallbackSide =\n annotationLayout?.hoverFallbackSide ?? \"below\";\n const annotationMarginSide = annotationLayout?.marginSide ?? \"auto\";\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 langChip = data.language?.trim();\n const hasFilename = Boolean(data.filename?.trim());\n const showLangChip = Boolean(langChip && !hasFilename);\n\n // The resolved annotation whose card is currently shown on hover.\n const activeItem =\n useMemo<ResolvedAnnotation<AnnotatedCodeAnnotation> | null>(\n () =>\n activeIndex == null\n ? null\n : (resolved.find((item) => item.index === activeIndex) ?? null),\n [activeIndex, resolved],\n );\n\n // Line-collapse state: a set of collapsed segment start lines that have been\n // expanded by the reader. Starts empty (all segments in their default state).\n const [expandedCollapsed, setExpandedCollapsed] = useState<Set<number>>(\n () => new Set(),\n );\n\n const segments = useMemo(\n () => buildLineSegments(lineCount, lineMarkers),\n [lineCount, lineMarkers],\n );\n\n const renderLine = (lineNo: number) => {\n const markers = lineMarkers.get(lineNo);\n const isAnnotated = !!markers?.length;\n const isActive =\n activeIndex != null && !!markers?.some((m) => m.index === activeIndex);\n const overlayItems =\n showPersistentAnnotations && markers\n ? markers.filter((item) => item.range?.start === lineNo)\n : [];\n\n const buildAnchorForRow = (el: HTMLElement) => {\n if (!markers) return null;\n const primaryMarker = markers[0];\n const anchorLine = primaryMarker.range?.start ?? lineNo;\n const anchorRow = lineRefs.current.get(anchorLine) ?? el;\n return anchorFromElements(codeRef.current, anchorRow);\n };\n\n return (\n <div\n key={lineNo}\n ref={(node) => setLineRef(lineNo, node)}\n data-code-line={lineNo}\n data-annot-row={isAnnotated ? markers?.[0].index : undefined}\n tabIndex={isAnnotated ? 0 : undefined}\n role={isAnnotated ? \"button\" : undefined}\n aria-expanded={isAnnotated ? isActive : undefined}\n aria-label={isAnnotated ? `Line ${lineNo} annotation` : undefined}\n className={cn(\n \"relative flex w-full\",\n isAnnotated && \"cursor-pointer\",\n isActive\n ? \"bg-amber-400/20 dark:bg-amber-300/15\"\n : isAnnotated && showAnnotationOverlays\n ? \"bg-amber-300/25 dark:bg-amber-300/15\"\n : isAnnotated\n ? \"bg-amber-400/[0.07] dark:bg-amber-300/[0.07]\"\n : null,\n )}\n onMouseEnter={\n isAnnotated && markers\n ? (event) => {\n const anchor = buildAnchorForRow(event.currentTarget);\n if (anchor) hover.open(markers[0].index, anchor);\n }\n : undefined\n }\n onMouseLeave={isAnnotated ? () => hover.scheduleClose() : undefined}\n onClick={\n isAnnotated && markers\n ? (event) => {\n const anchor = buildAnchorForRow(event.currentTarget);\n if (anchor) hover.open(markers[0].index, anchor);\n }\n : undefined\n }\n onKeyDown={\n isAnnotated && markers\n ? (event) => {\n if (event.key !== \"Enter\" && event.key !== \" \") return;\n event.preventDefault();\n const anchor = buildAnchorForRow(event.currentTarget);\n if (anchor) hover.open(markers[0].index, anchor);\n }\n : undefined\n }\n onFocus={\n isAnnotated && markers\n ? (event) => {\n const anchor = buildAnchorForRow(event.currentTarget);\n if (anchor) hover.open(markers[0].index, anchor);\n }\n : undefined\n }\n onBlur={isAnnotated ? () => hover.scheduleClose() : undefined}\n >\n <span\n aria-hidden\n className={cn(\n \"w-[3px] shrink-0 self-stretch\",\n isAnnotated\n ? isActive\n ? \"bg-amber-500 dark:bg-amber-400\"\n : showAnnotationOverlays\n ? \"bg-amber-500/90 dark:bg-amber-300/70\"\n : \"bg-amber-400/45 dark:bg-amber-300/35\"\n : null,\n )}\n />\n <span className=\"w-11 shrink-0 select-none px-3 text-right text-[11px] tabular-nums text-plan-muted/60\">\n {lineNo}\n </span>\n <span className=\"flex-1 whitespace-pre pr-4 text-plan-code-text\">\n {highlightedLines[lineNo - 1]}\n </span>\n {overlayItems.length > 0 && (\n <AnnotationInlineOverlayStack\n items={overlayItems}\n ctx={ctx}\n containerRef={codeRef}\n mode={showAnnotationOverlays ? \"capture\" : \"margin\"}\n side={showAnnotationOverlays ? \"right\" : annotationMarginSide}\n preferredSide={annotationHoverSide}\n />\n )}\n </div>\n );\n };\n\n const codeSurface = (\n <div\n ref={codeRef}\n className=\"overflow-hidden rounded-xl border border-plan-line bg-plan-code\"\n >\n {(hasFilename || showLangChip) && (\n <div className=\"flex items-center gap-2 border-b border-plan-line bg-plan-block/50 px-3.5 py-2\">\n <IconCode className=\"size-3.5 shrink-0 text-plan-muted\" />\n <CodeFilenameLabel\n filename={data.filename}\n className=\"text-[13px] font-medium\"\n directoryClassName=\"text-plan-muted\"\n basenameClassName=\"text-plan-code-text\"\n />\n {showLangChip && (\n <span className=\"shrink-0 rounded border border-plan-line px-1.5 py-0.5 font-mono text-[10px] uppercase tracking-wide text-plan-muted\">\n {langChip}\n </span>\n )}\n </div>\n )}\n <div className=\"overflow-x-auto py-1.5\" data-code-surface>\n <div className=\"min-w-full font-mono [font-size:var(--plan-doc-code-size)] leading-[22px]\">\n {segments.map((seg) => {\n if (seg.kind === \"visible\") {\n const lineNos = Array.from(\n { length: seg.endLine - seg.startLine + 1 },\n (_, i) => seg.startLine + i,\n );\n return lineNos.map(renderLine);\n }\n // Collapsed segment — show an expander row.\n const isExpanded = expandedCollapsed.has(seg.startLine);\n const hiddenCount = seg.endLine - seg.startLine + 1;\n if (isExpanded) {\n const lineNos = Array.from(\n { length: hiddenCount },\n (_, i) => seg.startLine + i,\n );\n return lineNos.map(renderLine);\n }\n return (\n <button\n key={`collapse-${seg.startLine}`}\n type=\"button\"\n data-plan-interactive\n onClick={() =>\n setExpandedCollapsed((prev) => {\n const next = new Set(prev);\n next.add(seg.startLine);\n return next;\n })\n }\n className=\"flex w-full cursor-pointer items-center gap-2 border-y border-plan-line/50 bg-plan-block/20 px-3 py-0.5 text-left hover:bg-plan-block/40\"\n >\n <span aria-hidden className=\"w-[3px] shrink-0 self-stretch\" />\n <span className=\"w-8 shrink-0 select-none text-right text-[11px] tabular-nums text-plan-muted/40\">\n ···\n </span>\n <span className=\"flex-1 text-[11px] text-plan-muted/70\">\n {hiddenCount} lines — click to expand\n </span>\n </button>\n );\n })}\n </div>\n </div>\n </div>\n );\n\n return (\n <section className=\"plan-block relative\" data-block-id={blockId}>\n {title && <div className=\"plan-block-label\">{title}</div>}\n {/* The code keeps its full width — no persistent annotation column. Notes\n live in a visually-hidden stack (a11y + tests) and surface ONE at a\n time as an on-hover popover anchored to the right of the code. */}\n {codeSurface}\n {hasAnnotations && <AnnotationHiddenStack items={resolved} ctx={ctx} />}\n {hasAnnotations &&\n !showPersistentAnnotations &&\n activeItem &&\n hover.anchor && (\n <AnnotationHoverCard\n item={activeItem}\n anchor={hover.anchor}\n ctx={ctx}\n preferredSide={annotationHoverSide}\n hoverFallbackSide={annotationHoverFallbackSide}\n onMouseEnter={hover.cancelClose}\n onMouseLeave={hover.scheduleClose}\n onClose={hover.closeForScroll}\n />\n )}\n {summary && <p className=\"mt-5 text-plan-muted\">{summary}</p>}\n </section>\n );\n}\n\n/* ── Edit (panel) ──────────────────────────────────────────────────────────── */\n\nconst codeAreaClass =\n \"min-h-[160px] font-mono [font-size:var(--plan-code-size)] leading-5\";\n\nfunction AnnotatedCodeEdit({\n data,\n onChange,\n editable,\n}: BlockEditProps<AnnotatedCodeData>) {\n const annotations = data.annotations ?? [];\n const patch = (next: Partial<AnnotatedCodeData>) =>\n onChange({ ...data, ...next });\n\n const updateAnnotation = (\n index: number,\n next: Partial<AnnotatedCodeAnnotation>,\n ) =>\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: [...annotations, { lines: \"1\", label: \"\", note: \"\" }],\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=\"annotated-code-filename\" className=\"text-xs\">\n Filename\n </DevLabel>\n <DevInput\n id=\"annotated-code-filename\"\n value={data.filename ?? \"\"}\n placeholder=\"src/server/auth.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=\"annotated-code-language\" className=\"text-xs\">\n Language\n </DevLabel>\n <DevInput\n id=\"annotated-code-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 htmlFor=\"annotated-code-code\" className=\"text-xs\">\n Code\n </DevLabel>\n <DevTextarea\n id=\"annotated-code-code\"\n spellCheck={false}\n className={codeAreaClass}\n value={data.code}\n disabled={!editable}\n onChange={(event) => patch({ code: 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.\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-[120px_minmax(0,1fr)_auto]\">\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 { AnnotatedCodeRead, AnnotatedCodeEdit };\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DiffBlock.d.ts","sourceRoot":"","sources":["../../../../src/client/blocks/library/DiffBlock.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DiffBlock.d.ts","sourceRoot":"","sources":["../../../../src/client/blocks/library/DiffBlock.tsx"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EAEf,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAkB,QAAQ,EAAY,MAAM,kBAAkB,CAAC;AAmB3E;;;;;;;;;;;;;;;GAeG;AAIH,UAAU,MAAM;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAqBD;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAsEjE;AAoeD,iBAAS,QAAQ,CAAC,EAChB,IAAI,EACJ,OAAO,EACP,KAAK,EACL,OAAO,EACP,GAAG,GACJ,EAAE,cAAc,CAAC,QAAQ,CAAC,2CAyV1B;AAskBD,iBAAS,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,cAAc,CAAC,QAAQ,CAAC,2CA2LvE;AAED,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -3,7 +3,7 @@ import { useCallback, useEffect, useMemo, useRef, useState, } from "react";
|
|
|
3
3
|
import { IconChevronRight, IconColumns, IconDotsVertical, IconFileDiff, IconList, IconPlus, IconTrash, } from "@tabler/icons-react";
|
|
4
4
|
import { common, createLowlight } from "lowlight";
|
|
5
5
|
import { cn } from "../../utils.js";
|
|
6
|
-
import { AnnotationGutterMarker, AnnotationHiddenStack, AnnotationHoverCard, AnnotationInlineOverlayStack, anchorFromElements, buildLineMarkerMap, hasRailAnnotations, resolveAnnotations, useAnnotationHover, } from "./annotation-rail.js";
|
|
6
|
+
import { AnnotationGutterMarker, AnnotationHiddenStack, AnnotationHoverCard, AnnotationInlineOverlayStack, anchorFromElements, buildLineMarkerMap, hasRailAnnotations, resolveAnnotations, useAnnotationMarginNotesAvailable, useAnnotationHover, } from "./annotation-rail.js";
|
|
7
7
|
import { DevInput, DevLabel, DevTextarea, DevSelect } from "./dev-doc-ui.js";
|
|
8
8
|
import { useInNarrowContainer } from "./narrow-container.js";
|
|
9
9
|
/**
|
|
@@ -522,10 +522,23 @@ function DiffRead({ data, blockId, title, summary, ctx, }) {
|
|
|
522
522
|
const beforeLineCount = useMemo(() => countLines(data.before), [data.before]);
|
|
523
523
|
const afterLineCount = useMemo(() => countLines(data.after), [data.after]);
|
|
524
524
|
const showAnnotationOverlays = Boolean(ctx.showCodeAnnotationOverlays);
|
|
525
|
+
const annotationLayout = ctx.codeAnnotationLayout;
|
|
526
|
+
const annotationHoverSide = annotationLayout?.hoverSide ?? "right";
|
|
527
|
+
const annotationHoverFallbackSide = annotationLayout?.hoverFallbackSide ?? "below";
|
|
528
|
+
const annotationMarginSide = annotationLayout?.marginSide ?? "auto";
|
|
525
529
|
const resolved = useMemo(() => resolveAnnotations(data.annotations, (annotation) => annotationSide(annotation) === "before"
|
|
526
530
|
? beforeLineCount
|
|
527
531
|
: afterLineCount), [data.annotations, beforeLineCount, afterLineCount]);
|
|
528
532
|
const hasAnnotations = hasRailAnnotations(resolved);
|
|
533
|
+
const showMarginAnnotations = useAnnotationMarginNotesAvailable({
|
|
534
|
+
containerRef: codeRef,
|
|
535
|
+
enabled: Boolean(hasAnnotations &&
|
|
536
|
+
!showAnnotationOverlays &&
|
|
537
|
+
annotationLayout?.showByDefaultWhenRoom),
|
|
538
|
+
side: annotationMarginSide,
|
|
539
|
+
preferredSide: annotationHoverSide,
|
|
540
|
+
});
|
|
541
|
+
const showPersistentAnnotations = showAnnotationOverlays || showMarginAnnotations;
|
|
529
542
|
// Effective render mode. Annotations live in a SEPARATE right-hand rail (not
|
|
530
543
|
// over the code), so they no longer force a mode. When no mode was authored, a
|
|
531
544
|
// truly narrow container still falls back to unified so split's doubled
|
|
@@ -617,10 +630,13 @@ function DiffRead({ data, blockId, title, summary, ctx, }) {
|
|
|
617
630
|
// The bordered code box. It always spans its full width — annotations surface
|
|
618
631
|
// as an on-hover popover anchored to this box's right edge, never as a column.
|
|
619
632
|
// `codeRef` measures that right edge for the popover's placement.
|
|
620
|
-
const diffBox = (_jsxs("div", { ref: codeRef, className: "overflow-hidden rounded-md border border-border bg-background", children: [_jsxs("div", { className: "flex min-h-10 flex-wrap items-center gap-2 border-b border-border bg-muted/60 px-3 py-1.5", children: [_jsx(IconFileDiff, { className: "size-4 shrink-0 text-muted-foreground" }), _jsxs("span", { className: "flex min-w-0 flex-1 items-baseline gap-1.5 font-mono", title: data.filename || undefined, children: [_jsx("span", { className: "min-w-0 max-w-[16rem] truncate text-[13px] font-semibold leading-5 text-foreground", children: fileParts.basename }), fileParts.directory && (_jsx("span", { className: "min-w-0 flex-1 truncate text-[11px] leading-5 text-muted-foreground/70", children: fileParts.directory }))] }), _jsxs("span", { className: "ml-1 flex shrink-0 items-center gap-2 font-mono text-xs", children: [_jsxs("span", { className: "text-emerald-700 dark:text-emerald-300", children: ["+", added] }), _jsxs("span", { className: "text-destructive", children: ["\u2212", removed] })] }), canSplit && (_jsxs("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", children: [_jsx(ModeButton, { active: mode === "unified", onClick: () => setMode("unified"), icon: _jsx(IconList, { className: "size-3.5" }), label: "Unified" }), _jsx(ModeButton, { active: mode === "split", onClick: () => setMode("split"), icon: _jsx(IconColumns, { className: "size-3.5" }), label: "Split" })] }))] }), unchanged ? (_jsx("div", { className: "px-4 py-6 text-center font-mono text-sm text-muted-foreground", children: "No changes" })) : effectiveMode === "split" ? (_jsx(SplitView, { rows: rows, language: language, rowLimit: rowLimit, markersForRow: markersForRow, activeIndex: activeIndex, onRowEnter: onRowEnter, onRowLeave: onRowLeave, onRowClick: onRowClick, showAnnotationOverlays: showAnnotationOverlays, ctx: ctx })) : (_jsx(UnifiedView, { rows: displayedRows, language: language, expanded: expanded, onToggleRun: toggleRun, markersForRow: markersForRow, anchoredRow: anchoredRow, activeIndex: activeIndex, onRowEnter: onRowEnter, onRowLeave: onRowLeave, onRowClick: onRowClick, showAnnotationOverlays: showAnnotationOverlays, ctx: ctx })), !unchanged && shouldLimitRows && (_jsxs("button", { type: "button", "data-plan-interactive": true, "aria-expanded": showAllRows, onClick: () => setShowAllRows((current) => !current), 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", children: [_jsx(IconChevronRight, { className: cn("size-3 shrink-0 transition-transform", showAllRows ? "-rotate-90" : "rotate-90") }), showAllRows
|
|
633
|
+
const diffBox = (_jsxs("div", { ref: codeRef, className: "overflow-hidden rounded-md border border-border bg-background", children: [_jsxs("div", { className: "flex min-h-10 flex-wrap items-center gap-2 border-b border-border bg-muted/60 px-3 py-1.5", children: [_jsx(IconFileDiff, { className: "size-4 shrink-0 text-muted-foreground" }), _jsxs("span", { className: "flex min-w-0 flex-1 items-baseline gap-1.5 font-mono", title: data.filename || undefined, children: [_jsx("span", { className: "min-w-0 max-w-[16rem] truncate text-[13px] font-semibold leading-5 text-foreground", children: fileParts.basename }), fileParts.directory && (_jsx("span", { className: "min-w-0 flex-1 truncate text-[11px] leading-5 text-muted-foreground/70", children: fileParts.directory }))] }), _jsxs("span", { className: "ml-1 flex shrink-0 items-center gap-2 font-mono text-xs", children: [_jsxs("span", { className: "text-emerald-700 dark:text-emerald-300", children: ["+", added] }), _jsxs("span", { className: "text-destructive", children: ["\u2212", removed] })] }), canSplit && (_jsxs("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", children: [_jsx(ModeButton, { active: mode === "unified", onClick: () => setMode("unified"), icon: _jsx(IconList, { className: "size-3.5" }), label: "Unified" }), _jsx(ModeButton, { active: mode === "split", onClick: () => setMode("split"), icon: _jsx(IconColumns, { className: "size-3.5" }), label: "Split" })] }))] }), unchanged ? (_jsx("div", { className: "px-4 py-6 text-center font-mono text-sm text-muted-foreground", children: "No changes" })) : effectiveMode === "split" ? (_jsx(SplitView, { rows: rows, language: language, rowLimit: rowLimit, markersForRow: markersForRow, activeIndex: activeIndex, onRowEnter: onRowEnter, onRowLeave: onRowLeave, onRowClick: onRowClick, showAnnotationOverlays: showPersistentAnnotations, annotationOverlayMode: showAnnotationOverlays ? "capture" : "margin", annotationOverlaySide: showAnnotationOverlays ? "right" : annotationMarginSide, annotationOverlayPreferredSide: annotationHoverSide, annotationOverlayContainerRef: codeRef, ctx: ctx })) : (_jsx(UnifiedView, { rows: displayedRows, language: language, expanded: expanded, onToggleRun: toggleRun, markersForRow: markersForRow, anchoredRow: anchoredRow, activeIndex: activeIndex, onRowEnter: onRowEnter, onRowLeave: onRowLeave, onRowClick: onRowClick, showAnnotationOverlays: showPersistentAnnotations, annotationOverlayMode: showAnnotationOverlays ? "capture" : "margin", annotationOverlaySide: showAnnotationOverlays ? "right" : annotationMarginSide, annotationOverlayPreferredSide: annotationHoverSide, annotationOverlayContainerRef: codeRef, ctx: ctx })), !unchanged && shouldLimitRows && (_jsxs("button", { type: "button", "data-plan-interactive": true, "aria-expanded": showAllRows, onClick: () => setShowAllRows((current) => !current), 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", children: [_jsx(IconChevronRight, { className: cn("size-3 shrink-0 transition-transform", showAllRows ? "-rotate-90" : "rotate-90") }), showAllRows
|
|
621
634
|
? "Show fewer"
|
|
622
635
|
: `Show all ${totalVisibleLineCount} lines`] }))] }));
|
|
623
|
-
return (_jsxs("section", { ref: containerRef, className: "relative plan-block group/diff-block", "data-block-id": blockId, children: [title && _jsx("div", { className: "plan-block-label", children: title }), summary && (_jsx("p", { className: "mb-3 text-sm leading-relaxed text-plan-muted", children: summary })), diffBox, hasAnnotations && (_jsx(AnnotationHiddenStack, { items: resolved, ctx: ctx, showMarker: true })), hasAnnotations &&
|
|
636
|
+
return (_jsxs("section", { ref: containerRef, className: "relative plan-block group/diff-block", "data-block-id": blockId, children: [title && _jsx("div", { className: "plan-block-label", children: title }), summary && (_jsx("p", { className: "mb-3 text-sm leading-relaxed text-plan-muted", children: summary })), diffBox, hasAnnotations && (_jsx(AnnotationHiddenStack, { items: resolved, ctx: ctx, showMarker: true })), hasAnnotations &&
|
|
637
|
+
!showPersistentAnnotations &&
|
|
638
|
+
activeItem &&
|
|
639
|
+
hover.anchor && (_jsx(AnnotationHoverCard, { item: activeItem, anchor: hover.anchor, ctx: ctx, showMarker: true, preferredSide: annotationHoverSide, hoverFallbackSide: annotationHoverFallbackSide, onMouseEnter: hover.cancelClose, onMouseLeave: hover.scheduleClose, onClose: hover.closeForScroll }))] }));
|
|
624
640
|
}
|
|
625
641
|
function ModeButton({ active, onClick, icon, label, }) {
|
|
626
642
|
return (_jsxs("button", { type: "button", "data-plan-interactive": true, onClick: onClick, "aria-pressed": active, className: cn("flex cursor-pointer items-center gap-1 px-2 py-1 text-xs font-medium transition-colors", active
|
|
@@ -660,7 +676,7 @@ function isMarkerRangeStart(row, marker) {
|
|
|
660
676
|
return lineNo === marker.range.start;
|
|
661
677
|
}
|
|
662
678
|
/* ── Unified view ──────────────────────────────────────────────────────────── */
|
|
663
|
-
function UnifiedView({ rows, language, expanded, onToggleRun, markersForRow, anchoredRow, activeIndex, onRowEnter, onRowLeave, onRowClick, showAnnotationOverlays, ctx, }) {
|
|
679
|
+
function UnifiedView({ rows, language, expanded, onToggleRun, markersForRow, anchoredRow, activeIndex, onRowEnter, onRowLeave, onRowClick, showAnnotationOverlays, annotationOverlayMode, annotationOverlaySide, annotationOverlayPreferredSide, annotationOverlayContainerRef, ctx, }) {
|
|
664
680
|
const segments = useMemo(() => segmentRows(rows, anchoredRow), [rows, anchoredRow]);
|
|
665
681
|
// Any annotation present ⇒ reserve the marker column so rows stay aligned.
|
|
666
682
|
const showMarkerColumn = useMemo(() => rows.some((row) => markersForRow(row).length > 0), [rows, markersForRow]);
|
|
@@ -673,6 +689,10 @@ function UnifiedView({ rows, language, expanded, onToggleRun, markersForRow, anc
|
|
|
673
689
|
onRowClick,
|
|
674
690
|
showMarkerColumn,
|
|
675
691
|
showAnnotationOverlays,
|
|
692
|
+
annotationOverlayMode,
|
|
693
|
+
annotationOverlaySide,
|
|
694
|
+
annotationOverlayPreferredSide,
|
|
695
|
+
annotationOverlayContainerRef,
|
|
676
696
|
ctx,
|
|
677
697
|
};
|
|
678
698
|
let runIndex = 0;
|
|
@@ -686,7 +706,7 @@ function UnifiedView({ rows, language, expanded, onToggleRun, markersForRow, anc
|
|
|
686
706
|
return _jsx(UnifiedRow, { row: segment, ...rowProps }, idx);
|
|
687
707
|
}) }) }));
|
|
688
708
|
}
|
|
689
|
-
function UnifiedRow({ language, row, markersForRow, activeIndex, onRowEnter, onRowLeave, onRowClick, showMarkerColumn, showAnnotationOverlays, ctx, }) {
|
|
709
|
+
function UnifiedRow({ language, row, markersForRow, activeIndex, onRowEnter, onRowLeave, onRowClick, showMarkerColumn, showAnnotationOverlays, annotationOverlayMode, annotationOverlaySide, annotationOverlayPreferredSide, annotationOverlayContainerRef, ctx, }) {
|
|
690
710
|
const markers = markersForRow(row);
|
|
691
711
|
const info = rowMarkerInfo(markers, activeIndex);
|
|
692
712
|
const startMarker = markers.find((marker) => isMarkerRangeStart(row, marker));
|
|
@@ -705,7 +725,7 @@ function UnifiedRow({ language, row, markersForRow, activeIndex, onRowEnter, onR
|
|
|
705
725
|
}
|
|
706
726
|
: undefined, onFocus: info && primaryIndex != null
|
|
707
727
|
? (event) => onRowEnter(primaryIndex, event.currentTarget)
|
|
708
|
-
: undefined, onBlur: info ? () => onRowLeave() : undefined, children: [_jsx("span", { className: cn(LINE_NO_CLASS, "w-[52px]"), children: row.oldNo ?? "" }), _jsx("span", { className: cn(LINE_NO_CLASS, "w-[52px]"), children: row.newNo ?? "" }), _jsx("span", { className: cn("w-6 shrink-0 select-none py-0 text-center font-semibold leading-5", GUTTER_BG[row.kind], SIGN_COLOR[row.kind]), children: SIGN[row.kind] }), showMarkerColumn && (_jsx(MarkerCell, { startMarker: startMarker, active: startMarker != null && startMarker.index === activeIndex })), _jsx(DiffLineText, { text: row.text, language: language }), overlayItems.length > 0 && (_jsx(AnnotationInlineOverlayStack, { items: overlayItems, ctx: ctx, showMarker: true }))] }));
|
|
728
|
+
: undefined, onBlur: info ? () => onRowLeave() : undefined, children: [_jsx("span", { className: cn(LINE_NO_CLASS, "w-[52px]"), children: row.oldNo ?? "" }), _jsx("span", { className: cn(LINE_NO_CLASS, "w-[52px]"), children: row.newNo ?? "" }), _jsx("span", { className: cn("w-6 shrink-0 select-none py-0 text-center font-semibold leading-5", GUTTER_BG[row.kind], SIGN_COLOR[row.kind]), children: SIGN[row.kind] }), showMarkerColumn && (_jsx(MarkerCell, { startMarker: startMarker, active: startMarker != null && startMarker.index === activeIndex })), _jsx(DiffLineText, { text: row.text, language: language }), overlayItems.length > 0 && (_jsx(AnnotationInlineOverlayStack, { items: overlayItems, ctx: ctx, showMarker: true, containerRef: annotationOverlayContainerRef, mode: annotationOverlayMode, side: annotationOverlaySide, preferredSide: annotationOverlayPreferredSide }))] }));
|
|
709
729
|
}
|
|
710
730
|
/**
|
|
711
731
|
* The fixed-width marker column rendered between the sign gutter and the code.
|
|
@@ -749,7 +769,7 @@ function pairSplitRows(rows) {
|
|
|
749
769
|
}
|
|
750
770
|
return out;
|
|
751
771
|
}
|
|
752
|
-
function SplitView({ language, rowLimit, rows, markersForRow, activeIndex, onRowEnter, onRowLeave, onRowClick, showAnnotationOverlays, ctx, }) {
|
|
772
|
+
function SplitView({ language, rowLimit, rows, markersForRow, activeIndex, onRowEnter, onRowLeave, onRowClick, showAnnotationOverlays, annotationOverlayMode, annotationOverlaySide, annotationOverlayPreferredSide, annotationOverlayContainerRef, ctx, }) {
|
|
753
773
|
const pairs = useMemo(() => pairSplitRows(rows), [rows]);
|
|
754
774
|
const displayedPairs = rowLimit ? pairs.slice(0, rowLimit) : pairs;
|
|
755
775
|
// Reserve the marker column on a side only if any visible row there has one.
|
|
@@ -763,11 +783,15 @@ function SplitView({ language, rowLimit, rows, markersForRow, activeIndex, onRow
|
|
|
763
783
|
onRowLeave,
|
|
764
784
|
onRowClick,
|
|
765
785
|
showAnnotationOverlays,
|
|
786
|
+
annotationOverlayMode,
|
|
787
|
+
annotationOverlaySide,
|
|
788
|
+
annotationOverlayPreferredSide,
|
|
789
|
+
annotationOverlayContainerRef,
|
|
766
790
|
ctx,
|
|
767
791
|
};
|
|
768
792
|
return (_jsxs("div", { className: "flex w-full bg-background font-mono [font-size:var(--plan-doc-code-size)] leading-5", "data-code-surface": true, children: [_jsx("div", { className: "min-w-0 flex-1 overflow-x-auto border-r border-border", children: _jsx("div", { className: "inline-block min-w-full", children: displayedPairs.map((pair, idx) => (_jsx(SplitCell, { row: pair.left, side: "old", showMarkerColumn: showOldMarkers, ...cellProps }, `old-${idx}`))) }) }), _jsx("div", { className: "min-w-0 flex-1 overflow-x-auto", children: _jsx("div", { className: "inline-block min-w-full", children: displayedPairs.map((pair, idx) => (_jsx(SplitCell, { row: pair.right, side: "new", showMarkerColumn: showNewMarkers, ...cellProps }, `new-${idx}`))) }) })] }));
|
|
769
793
|
}
|
|
770
|
-
function SplitCell({ language, row, side, markersForRow, activeIndex, onRowEnter, onRowLeave, onRowClick, showMarkerColumn, showAnnotationOverlays, ctx, }) {
|
|
794
|
+
function SplitCell({ language, row, side, markersForRow, activeIndex, onRowEnter, onRowLeave, onRowClick, showMarkerColumn, showAnnotationOverlays, annotationOverlayMode, annotationOverlaySide, annotationOverlayPreferredSide, annotationOverlayContainerRef, ctx, }) {
|
|
771
795
|
if (!row) {
|
|
772
796
|
return (_jsxs("div", { className: "flex min-h-5 min-w-full bg-muted/40 opacity-70", children: [_jsx("span", { className: cn(LINE_NO_CLASS, "w-[52px]") }), _jsx("span", { className: "w-6 shrink-0 bg-muted/60" }), showMarkerColumn && _jsx("span", { className: "w-6 shrink-0" }), _jsx("span", { className: DIFF_LINE_CLASS, children: " " })] }));
|
|
773
797
|
}
|
|
@@ -791,7 +815,7 @@ function SplitCell({ language, row, side, markersForRow, activeIndex, onRowEnter
|
|
|
791
815
|
}
|
|
792
816
|
: undefined, onFocus: info && primaryIndex != null
|
|
793
817
|
? (event) => onRowEnter(primaryIndex, event.currentTarget)
|
|
794
|
-
: undefined, onBlur: info ? () => onRowLeave() : undefined, children: [_jsx("span", { className: cn(LINE_NO_CLASS, "w-[52px]"), children: side === "old" ? (row.oldNo ?? "") : (row.newNo ?? "") }), _jsx("span", { className: cn("w-6 shrink-0 select-none py-0 text-center font-semibold leading-5", GUTTER_BG[row.kind], SIGN_COLOR[row.kind]), children: showSign ? sign : " " }), showMarkerColumn && (_jsx(MarkerCell, { startMarker: startMarker, active: startMarker != null && startMarker.index === activeIndex })), _jsx(DiffLineText, { text: row.text, language: language }), overlayItems.length > 0 && (_jsx(AnnotationInlineOverlayStack, { items: overlayItems, ctx: ctx, showMarker: true }))] }));
|
|
818
|
+
: undefined, onBlur: info ? () => onRowLeave() : undefined, children: [_jsx("span", { className: cn(LINE_NO_CLASS, "w-[52px]"), children: side === "old" ? (row.oldNo ?? "") : (row.newNo ?? "") }), _jsx("span", { className: cn("w-6 shrink-0 select-none py-0 text-center font-semibold leading-5", GUTTER_BG[row.kind], SIGN_COLOR[row.kind]), children: showSign ? sign : " " }), showMarkerColumn && (_jsx(MarkerCell, { startMarker: startMarker, active: startMarker != null && startMarker.index === activeIndex })), _jsx(DiffLineText, { text: row.text, language: language }), overlayItems.length > 0 && (_jsx(AnnotationInlineOverlayStack, { items: overlayItems, ctx: ctx, showMarker: true, containerRef: annotationOverlayContainerRef, mode: annotationOverlayMode, side: annotationOverlaySide, preferredSide: annotationOverlayPreferredSide }))] }));
|
|
795
819
|
}
|
|
796
820
|
/* ── Edit (panel) ──────────────────────────────────────────────────────────── */
|
|
797
821
|
const codeAreaClass = "min-h-[140px] font-mono [font-size:var(--plan-code-size)] leading-5";
|