@agent-native/core 0.49.22 → 0.49.23

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 (71) hide show
  1. package/dist/agent/production-agent.d.ts +1 -0
  2. package/dist/agent/production-agent.d.ts.map +1 -1
  3. package/dist/agent/production-agent.js +15 -0
  4. package/dist/agent/production-agent.js.map +1 -1
  5. package/dist/agent/tool-search.d.ts.map +1 -1
  6. package/dist/agent/tool-search.js +32 -7
  7. package/dist/agent/tool-search.js.map +1 -1
  8. package/dist/cli/connect.d.ts +2 -3
  9. package/dist/cli/connect.d.ts.map +1 -1
  10. package/dist/cli/connect.js +60 -37
  11. package/dist/cli/connect.js.map +1 -1
  12. package/dist/cli/pr-visual-recap-workflow.d.ts +5 -7
  13. package/dist/cli/pr-visual-recap-workflow.d.ts.map +1 -1
  14. package/dist/cli/pr-visual-recap-workflow.js +5 -7
  15. package/dist/cli/pr-visual-recap-workflow.js.map +1 -1
  16. package/dist/cli/recap.d.ts +44 -52
  17. package/dist/cli/recap.d.ts.map +1 -1
  18. package/dist/cli/recap.js +420 -414
  19. package/dist/cli/recap.js.map +1 -1
  20. package/dist/client/AssistantChat.d.ts +6 -3
  21. package/dist/client/AssistantChat.d.ts.map +1 -1
  22. package/dist/client/AssistantChat.js +1 -1
  23. package/dist/client/AssistantChat.js.map +1 -1
  24. package/dist/client/MultiTabAssistantChat.d.ts.map +1 -1
  25. package/dist/client/MultiTabAssistantChat.js +23 -3
  26. package/dist/client/MultiTabAssistantChat.js.map +1 -1
  27. package/dist/client/agent-chat.d.ts +8 -0
  28. package/dist/client/agent-chat.d.ts.map +1 -1
  29. package/dist/client/agent-chat.js +24 -1
  30. package/dist/client/agent-chat.js.map +1 -1
  31. package/dist/client/blocks/library/AnnotatedCodeBlock.d.ts.map +1 -1
  32. package/dist/client/blocks/library/AnnotatedCodeBlock.js +4 -1
  33. package/dist/client/blocks/library/AnnotatedCodeBlock.js.map +1 -1
  34. package/dist/client/blocks/library/DiffBlock.d.ts.map +1 -1
  35. package/dist/client/blocks/library/DiffBlock.js +20 -7
  36. package/dist/client/blocks/library/DiffBlock.js.map +1 -1
  37. package/dist/client/blocks/library/annotation-rail.js +5 -5
  38. package/dist/client/blocks/library/annotation-rail.js.map +1 -1
  39. package/dist/client/composer/TiptapComposer.d.ts.map +1 -1
  40. package/dist/client/composer/TiptapComposer.js +15 -2
  41. package/dist/client/composer/TiptapComposer.js.map +1 -1
  42. package/dist/coding-tools/run-code.d.ts.map +1 -1
  43. package/dist/coding-tools/run-code.js +69 -17
  44. package/dist/coding-tools/run-code.js.map +1 -1
  45. package/dist/integrations/plugin.d.ts.map +1 -1
  46. package/dist/integrations/plugin.js +2 -0
  47. package/dist/integrations/plugin.js.map +1 -1
  48. package/dist/mcp/build-server.d.ts +12 -10
  49. package/dist/mcp/build-server.d.ts.map +1 -1
  50. package/dist/mcp/build-server.js +53 -89
  51. package/dist/mcp/build-server.js.map +1 -1
  52. package/dist/mcp/connect-route.d.ts.map +1 -1
  53. package/dist/mcp/connect-route.js +5 -4
  54. package/dist/mcp/connect-route.js.map +1 -1
  55. package/dist/mcp/oauth-token.d.ts +6 -5
  56. package/dist/mcp/oauth-token.d.ts.map +1 -1
  57. package/dist/mcp/oauth-token.js.map +1 -1
  58. package/dist/mcp/stdio.d.ts.map +1 -1
  59. package/dist/mcp/stdio.js +9 -2
  60. package/dist/mcp/stdio.js.map +1 -1
  61. package/dist/provider-api/staging.d.ts.map +1 -1
  62. package/dist/provider-api/staging.js +6 -4
  63. package/dist/provider-api/staging.js.map +1 -1
  64. package/dist/server/agent-chat-plugin.d.ts +10 -7
  65. package/dist/server/agent-chat-plugin.d.ts.map +1 -1
  66. package/dist/server/agent-chat-plugin.js.map +1 -1
  67. package/docs/content/actions.md +1 -1
  68. package/docs/content/external-agents.md +53 -40
  69. package/docs/content/mcp-protocol.md +16 -11
  70. package/docs/content/pr-visual-recap.md +1 -1
  71. package/package.json +1 -1
@@ -7,6 +7,7 @@
7
7
  * stay inside the embedded app so its own AgentSidebar can receive them.
8
8
  */
9
9
  import type { ReasoningEffort } from "../shared/reasoning-effort.js";
10
+ export type AgentChatRequestMode = "act" | "plan";
10
11
  export interface AgentChatMessage {
11
12
  /** The visible prompt message sent to the chat */
12
13
  message: string;
@@ -43,6 +44,13 @@ export interface AgentChatMessage {
43
44
  engine?: string;
44
45
  /** Reasoning effort preference paired with model. */
45
46
  effort?: ReasoningEffort;
47
+ /**
48
+ * Execution mode for this submitted turn. When omitted, sendToAgentChat
49
+ * snapshots the current AgentPanel mode from localStorage when available.
50
+ */
51
+ mode?: AgentChatRequestMode;
52
+ /** @deprecated Use `mode` instead. */
53
+ requestMode?: AgentChatRequestMode;
46
54
  /** Scoped system prompt additions for this sub-agent */
47
55
  instructions?: string;
48
56
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"agent-chat.d.ts","sourceRoot":"","sources":["../../src/client/agent-chat.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAerE,MAAM,WAAW,gBAAgB;IAC/B,kDAAkD;IAClD,OAAO,EAAE,MAAM,CAAC;IAChB,oEAAoE;IACpE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2EAA2E;IAC3E,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,mDAAmD;IACnD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oDAAoD;IACpD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,qCAAqC;IACrC,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC/B,yCAAyC;IACzC,uBAAuB,CAAC,EAAE,MAAM,EAAE,CAAC;IACnC,wEAAwE;IACxE,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,wDAAwD;IACxD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;;;OAOG;IACH,IAAI,CAAC,EAAE,SAAS,GAA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qB,CAEhE;AAED,wBAAgB,oBAAoB,IAAI,oBAAoB,EAAE,CAE7D;AAED,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAK1E;AAED,wBAAsB,uBAAuB,IAAI,OAAO,CAAC,qBAAqB,CAAC,CAsB9E;AAED,wBAAgB,oCAAoC,CAClD,KAAK,EAAE,SAAS,oBAAoB,EAAE,GACrC,MAAM,CAMR;AAED,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,GACd,MAAM,CAIR;AA+ED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,gBAAgB,GAAG,MAAM,CAqF9D;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,0BAA0B,GAC/B,IAAI,CAUN;AAED,yDAAyD;AACzD,eAAO,MAAM,qBAAqB,gCAA0B,CAAC;AAE7D,yDAAyD;AACzD,eAAO,MAAM,qBAAqB,gCAA0B,CAAC;AAE7D,wBAAgB,0BAA0B,CACxC,SAAS,EAAE,MAAM,GAAG,6BAA6B,GAChD,IAAI,CAeN;AAED,wBAAgB,qBAAqB,CACnC,IAAI,GAAE,+BAAoC,GACzC,IAAI,CAQN;AAED,wBAAgB,8BAA8B,IAAI,IAAI,CAGrD"}
@@ -13,6 +13,7 @@ import { isInBuilderFrame, isTrustedBuilderMessage, sendToBuilderChat, } from ".
13
13
  import { agentNativePath } from "./api-path.js";
14
14
  const AGENT_CHAT_MESSAGE_TYPE = "agentNative.submitChat";
15
15
  const AGENT_CHAT_CONTEXT_STATE_KEY = "agent-chat-context";
16
+ const AGENT_CHAT_EXEC_MODE_KEY = "agent-native-exec-mode";
16
17
  export const AGENT_CHAT_CONTEXT_CHANGED_EVENT = "agentNative.chatContextChanged";
17
18
  export const AGENT_CHAT_SET_CONTEXT_MESSAGE_TYPE = "agentNative.setChatContext";
18
19
  export const AGENT_CHAT_REMOVE_CONTEXT_MESSAGE_TYPE = "agentNative.removeChatContext";
@@ -227,6 +228,22 @@ function dispatchAgentChatRunning(isRunning) {
227
228
  detail: { isRunning },
228
229
  }));
229
230
  }
231
+ function normalizeAgentChatRequestMode(value) {
232
+ return value === "act" || value === "plan" ? value : undefined;
233
+ }
234
+ function readStoredAgentChatRequestMode() {
235
+ if (typeof window === "undefined")
236
+ return undefined;
237
+ try {
238
+ const saved = window.localStorage.getItem(AGENT_CHAT_EXEC_MODE_KEY);
239
+ if (saved === "plan")
240
+ return "plan";
241
+ if (saved === "build")
242
+ return "act";
243
+ }
244
+ catch { }
245
+ return undefined;
246
+ }
230
247
  /**
231
248
  * Send a message to the agent chat via postMessage.
232
249
  * Returns the stable tabId for tracking this chat run.
@@ -242,9 +259,15 @@ export function sendToAgentChat(opts) {
242
259
  });
243
260
  return tabId;
244
261
  }
262
+ const requestMode = normalizeAgentChatRequestMode(opts.requestMode ?? opts.mode) ??
263
+ readStoredAgentChatRequestMode();
245
264
  const payload = {
246
265
  type: AGENT_CHAT_MESSAGE_TYPE,
247
- data: { ...opts, tabId },
266
+ data: {
267
+ ...opts,
268
+ tabId,
269
+ ...(requestMode ? { mode: requestMode, requestMode } : {}),
270
+ },
248
271
  };
249
272
  if (opts.submit !== false && isMcpAppChatBridgeEnabled()) {
250
273
  const directHostMessage = sendMcpAppHostMessage({
@@ -1 +1 @@
1
- {"version":3,"file":"agent-chat.js","sourceRoot":"","sources":["../../src/client/agent-chat.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,+BAA+B,EAC/B,qBAAqB,GACtB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,iBAAiB,EACjB,0BAA0B,EAC1B,4BAA4B,EAC5B,iCAAiC,GAClC,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,iBAAiB,GAClB,MAAM,oBAAoB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pC,CAAC","sourcesContent":["/**\n * Agent Chat Bridge (browser)\n *\n * Sends structured messages to the agent chat from UI interactions.\n * Messages are sent via postMessage to the parent window (or self if top-level).\n * Builder frames are special: code requests go to Builder, but content prompts\n * stay inside the embedded app so its own AgentSidebar can receive them.\n */\n\nimport {\n getFramePostMessageTargetOrigin,\n isTrustedFrameMessage,\n} from \"./frame.js\";\nimport type { ReasoningEffort } from \"../shared/reasoning-effort.js\";\nimport {\n isEmbedAuthActive,\n isEmbedMcpChatBridgeActive,\n markEmbedMcpChatBridgeActive,\n readEmbedMcpChatBridgeFlagFromUrl,\n} from \"./embed-auth.js\";\nimport { sendMcpAppHostMessage } from \"./mcp-app-host.js\";\nimport {\n isInBuilderFrame,\n isTrustedBuilderMessage,\n sendToBuilderChat,\n} from \"./builder-frame.js\";\nimport { agentNativePath } from \"./api-path.js\";\n\nexport interface AgentChatMessage {\n /** The visible prompt message sent to the chat */\n message: string;\n /** Hidden context appended to the message (not shown in chat UI) */\n context?: string;\n /** true = auto-submit, false = prefill only, omit = use project setting */\n submit?: boolean;\n /** Optional project slug for structured context */\n projectSlug?: string;\n /** Optional preset name for downstream consumers */\n preset?: string;\n /** Optional reference image paths */\n referenceImagePaths?: string[];\n /** Optional uploaded reference images */\n uploadedReferenceImages?: string[];\n /** Optional image data URLs to include in the submitted chat message */\n images?: string[];\n /** Stable tab identifier — auto-generated if omitted */\n tabId?: string;\n /**\n * Message routing type:\n * - \"content\" (default): stays in the embedded app agent for content/data operations\n * - \"code\": routes to the code editing frame (Agent Native Desktop or Builder.io)\n *\n * When type is \"code\" and no frame is connected, a dialog is shown.\n * `requiresCode: true` is treated as `type: \"code\"` for backward compatibility.\n */\n type?: \"content\" | \"code\";\n /** @deprecated Use `type: \"code\"` instead. If true, treated as `type: \"code\"`. */\n requiresCode?: boolean;\n /** Model preference for this sub-agent (e.g. \"claude-haiku-4-5\"). Uses default if omitted */\n model?: string;\n /** Engine preference paired with model for cross-provider switches. */\n engine?: string;\n /** Reasoning effort preference paired with model. */\n effort?: ReasoningEffort;\n /** Scoped system prompt additions for this sub-agent */\n instructions?: string;\n /**\n * Whether to open the agent sidebar if it's currently hidden.\n * Defaults to true — submitting a chat should make the response visible.\n * Pass `false` for background/silent sends that shouldn't pop the UI open.\n */\n openSidebar?: boolean;\n /**\n * When true, opens a new chat tab before sending the message.\n * Use for creation requests (create tool, dashboard, etc.) that deserve\n * their own isolated thread rather than cluttering an existing conversation.\n */\n newTab?: boolean;\n /**\n * When true with newTab, creates the tab in the background without\n * focusing it or opening the sidebar. The message runs silently.\n */\n background?: boolean;\n}\n\nexport interface AgentChatContextItem {\n /** Stable key used to replace an existing context nugget. */\n key: string;\n /** Short label shown in the composer context chip. */\n title: string;\n /** Hidden context included with the next submitted prompt. */\n context: string;\n}\n\nexport interface AgentChatContextSetOptions extends AgentChatContextItem {\n /**\n * Whether to open the agent sidebar if it's currently hidden.\n * Defaults to true so the user can see the staged context.\n */\n openSidebar?: boolean;\n}\n\n/** @deprecated Use `AgentChatContextSetOptions` instead. */\nexport type AgentChatContextMessage = AgentChatContextSetOptions;\n\nexport interface AgentChatContextState {\n items: AgentChatContextItem[];\n updatedAt: number;\n}\n\nexport interface AgentChatContextMutationOptions {\n /**\n * Whether to open the agent sidebar if it's currently hidden.\n * Defaults to true for set/add and false for remove/clear.\n */\n openSidebar?: boolean;\n}\n\nexport interface AgentChatContextRemoveOptions extends AgentChatContextMutationOptions {\n /** Stable key of the staged context nugget to remove. */\n key: string;\n}\n\nconst AGENT_CHAT_MESSAGE_TYPE = \"agentNative.submitChat\";\nconst AGENT_CHAT_CONTEXT_STATE_KEY = \"agent-chat-context\";\nexport const AGENT_CHAT_CONTEXT_CHANGED_EVENT =\n \"agentNative.chatContextChanged\";\nexport const AGENT_CHAT_SET_CONTEXT_MESSAGE_TYPE = \"agentNative.setChatContext\";\nexport const AGENT_CHAT_REMOVE_CONTEXT_MESSAGE_TYPE =\n \"agentNative.removeChatContext\";\nexport const AGENT_CHAT_CLEAR_CONTEXT_MESSAGE_TYPE =\n \"agentNative.clearChatContext\";\nconst AGENT_PANEL_PREPARE_EVENT = \"agent-panel:prepare\";\n\nlet agentChatContextState: AgentChatContextState = {\n items: [],\n updatedAt: 0,\n};\nconst agentChatContextListeners = new Set<() => void>();\n\n/**\n * Listen for chatRunning messages from the frame (postMessage)\n * and re-dispatch as a CustomEvent so hooks like useAgentChatGenerating() work.\n */\nif (typeof window !== \"undefined\") {\n window.addEventListener(\"message\", (event) => {\n if (!isTrustedFrameMessage(event) && !isTrustedBuilderMessage(event)) {\n return;\n }\n if (\n event.data?.type === \"agentNative.chatRunning\" ||\n event.data?.type === \"builder.chatRunning\"\n ) {\n window.dispatchEvent(\n new CustomEvent(\"agentNative.chatRunning\", {\n detail: event.data.detail ?? event.data.data,\n }),\n );\n }\n });\n}\n\n/** Generate a unique tab ID */\nexport function generateTabId(): string {\n return `chat-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;\n}\n\nexport function normalizeAgentChatContextItem(\n item: unknown,\n): AgentChatContextItem | null {\n if (typeof item !== \"object\" || item === null) return null;\n const candidate = item as Partial<AgentChatContextItem>;\n if (\n typeof candidate.key !== \"string\" ||\n typeof candidate.context !== \"string\" ||\n typeof candidate.title !== \"string\"\n ) {\n return null;\n }\n const key = candidate.key.trim();\n const context = candidate.context.trim();\n if (!key || !context) return null;\n return {\n key,\n title: candidate.title.trim() || key,\n context,\n };\n}\n\nexport function normalizeAgentChatContextItems(\n items: unknown,\n): AgentChatContextItem[] {\n if (!Array.isArray(items)) return [];\n const deduped = new Map<string, AgentChatContextItem>();\n for (const rawItem of items) {\n const item = normalizeAgentChatContextItem(rawItem);\n if (!item) continue;\n deduped.set(item.key, item);\n }\n return [...deduped.values()];\n}\n\nfunction normalizeAgentChatContextState(\n value: unknown,\n): AgentChatContextState | null {\n if (!value || typeof value !== \"object\") return null;\n const raw = value as {\n value?: unknown;\n items?: unknown;\n updatedAt?: unknown;\n };\n const candidate =\n raw.value && typeof raw.value === \"object\"\n ? (raw.value as { items?: unknown; updatedAt?: unknown })\n : raw;\n const items = normalizeAgentChatContextItems(candidate.items);\n return {\n items,\n updatedAt:\n typeof candidate.updatedAt === \"number\" ? candidate.updatedAt : 0,\n };\n}\n\nfunction withReplacedAgentChatContextItem(\n items: readonly AgentChatContextItem[],\n item: AgentChatContextItem,\n): AgentChatContextItem[] {\n const index = items.findIndex((current) => current.key === item.key);\n if (index === -1) return [...items, item];\n return items.map((current, currentIndex) =>\n currentIndex === index ? item : current,\n );\n}\n\nfunction notifyAgentChatContextListeners(): void {\n for (const listener of agentChatContextListeners) listener();\n}\n\nfunction persistAgentChatContextState(state: AgentChatContextState): void {\n if (typeof window === \"undefined\" || typeof fetch !== \"function\") return;\n fetch(\n agentNativePath(\n `/_agent-native/application-state/${AGENT_CHAT_CONTEXT_STATE_KEY}`,\n ),\n {\n method: \"PUT\",\n keepalive: true,\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify(state),\n },\n ).catch(() => {});\n}\n\nexport function publishAgentChatContextItems(\n items: readonly AgentChatContextItem[],\n options?: { persist?: boolean; updatedAt?: number },\n): AgentChatContextState {\n const next: AgentChatContextState = {\n items: normalizeAgentChatContextItems([...items]),\n updatedAt: options?.updatedAt ?? Date.now(),\n };\n if (next.updatedAt < agentChatContextState.updatedAt) {\n return agentChatContextState;\n }\n agentChatContextState = next;\n notifyAgentChatContextListeners();\n if (typeof window !== \"undefined\") {\n window.dispatchEvent(\n new CustomEvent(AGENT_CHAT_CONTEXT_CHANGED_EVENT, {\n detail: next,\n }),\n );\n }\n if (options?.persist !== false) {\n persistAgentChatContextState(next);\n }\n return next;\n}\n\nexport function getAgentChatContextState(): AgentChatContextState {\n return agentChatContextState;\n}\n\nexport function listAgentChatContext(): AgentChatContextItem[] {\n return [...agentChatContextState.items];\n}\n\nexport function subscribeAgentChatContext(listener: () => void): () => void {\n agentChatContextListeners.add(listener);\n return () => {\n agentChatContextListeners.delete(listener);\n };\n}\n\nexport async function refreshAgentChatContext(): Promise<AgentChatContextState> {\n if (typeof window === \"undefined\" || typeof fetch !== \"function\") {\n return agentChatContextState;\n }\n try {\n const res = await fetch(\n agentNativePath(\n `/_agent-native/application-state/${AGENT_CHAT_CONTEXT_STATE_KEY}`,\n ),\n );\n if (!res.ok || res.status === 204) return agentChatContextState;\n const text = await res.text();\n if (!text) return agentChatContextState;\n const state = normalizeAgentChatContextState(JSON.parse(text));\n if (!state) return agentChatContextState;\n return publishAgentChatContextItems(state.items, {\n persist: false,\n updatedAt: state.updatedAt,\n });\n } catch {\n return agentChatContextState;\n }\n}\n\nexport function formatAgentChatContextItemsForPrompt(\n items: readonly AgentChatContextItem[],\n): string {\n return items\n .map(normalizeAgentChatContextItem)\n .filter((item): item is AgentChatContextItem => item !== null)\n .map((item) => [`## ${item.title}`, item.context].join(\"\\n\"))\n .join(\"\\n\\n\");\n}\n\nexport function appendAgentChatContextToMessage(\n message: string,\n context: string,\n): string {\n const trimmedContext = context.trim();\n if (!trimmedContext) return message;\n return `${message.trim()}\\n\\n<context>\\n${trimmedContext}\\n</context>`;\n}\n\nfunction postAgentChatContextMessage(\n type:\n | typeof AGENT_CHAT_SET_CONTEXT_MESSAGE_TYPE\n | typeof AGENT_CHAT_REMOVE_CONTEXT_MESSAGE_TYPE\n | typeof AGENT_CHAT_CLEAR_CONTEXT_MESSAGE_TYPE,\n data: unknown,\n options: { openSidebar: boolean },\n): void {\n if (typeof window === \"undefined\") return;\n\n const payload = { type, data };\n const targetSelf = isInBuilderFrame() || isDirectMcpAppEmbedSession();\n const target = targetSelf\n ? window\n : window.parent !== window\n ? window.parent\n : window;\n const targetOrigin = targetSelf\n ? window.location.origin\n : getFramePostMessageTargetOrigin() || window.location.origin;\n\n if (options.openSidebar) {\n window.dispatchEvent(\n new CustomEvent(\"agent-panel:set-mode\", {\n detail: { mode: \"chat\" },\n }),\n );\n window.dispatchEvent(new CustomEvent(\"agent-panel:open\"));\n } else {\n window.dispatchEvent(new CustomEvent(AGENT_PANEL_PREPARE_EVENT));\n }\n\n const postToTarget = () => target.postMessage(payload, targetOrigin);\n if (target === window) {\n setTimeout(postToTarget, 0);\n } else {\n postToTarget();\n }\n}\n\nfunction isMcpAppChatBridgeEnabled(): boolean {\n if (typeof window === \"undefined\" || window.parent === window) return false;\n if (readEmbedMcpChatBridgeFlagFromUrl()) markEmbedMcpChatBridgeActive();\n return isEmbedMcpChatBridgeActive() && isEmbedAuthActive();\n}\n\nfunction isDirectMcpAppEmbedSession(): boolean {\n if (typeof window === \"undefined\" || window.parent === window) return false;\n if (readEmbedMcpChatBridgeFlagFromUrl()) markEmbedMcpChatBridgeActive();\n return isEmbedAuthActive() && !isEmbedMcpChatBridgeActive();\n}\n\nfunction dispatchAgentChatRunning(isRunning: boolean): void {\n if (typeof window === \"undefined\") return;\n window.dispatchEvent(\n new CustomEvent(\"agentNative.chatRunning\", {\n detail: { isRunning },\n }),\n );\n}\n\n/**\n * Send a message to the agent chat via postMessage.\n * Returns the stable tabId for tracking this chat run.\n */\nexport function sendToAgentChat(opts: AgentChatMessage): string {\n const tabId = opts.tabId ?? generateTabId();\n const isCodeRequest = opts.type === \"code\" || opts.requiresCode === true;\n if (isCodeRequest && isInBuilderFrame()) {\n sendToBuilderChat({\n message: opts.message,\n context: opts.context,\n submit: opts.submit,\n });\n return tabId;\n }\n\n const payload = {\n type: AGENT_CHAT_MESSAGE_TYPE,\n data: { ...opts, tabId },\n };\n\n if (opts.submit !== false && isMcpAppChatBridgeEnabled()) {\n const directHostMessage = sendMcpAppHostMessage({\n message: opts.message,\n context: opts.context,\n });\n if (directHostMessage) {\n void Promise.resolve(directHostMessage)\n .then((ok) => {\n if (!ok) {\n window.parent.postMessage(\n payload,\n getFramePostMessageTargetOrigin() || \"*\",\n );\n }\n })\n .finally(() => {\n dispatchAgentChatRunning(false);\n });\n return tabId;\n }\n window.parent.postMessage(\n payload,\n getFramePostMessageTargetOrigin() || \"*\",\n );\n return tabId;\n }\n\n const shouldOpenSidebar = opts.openSidebar !== false && !opts.background;\n\n const targetSelf =\n !isCodeRequest && (isInBuilderFrame() || isDirectMcpAppEmbedSession());\n const target = targetSelf\n ? window\n : window.parent !== window\n ? window.parent\n : window;\n const targetOrigin = targetSelf\n ? window.location.origin\n : getFramePostMessageTargetOrigin() || window.location.origin;\n if (shouldOpenSidebar) {\n window.dispatchEvent(\n new CustomEvent(\"agent-panel:set-mode\", {\n detail: { mode: \"chat\" },\n }),\n );\n window.dispatchEvent(new CustomEvent(\"agent-panel:open\"));\n } else if (!isCodeRequest) {\n window.dispatchEvent(new CustomEvent(AGENT_PANEL_PREPARE_EVENT));\n }\n\n const postToTarget = () => target.postMessage(payload, targetOrigin);\n\n // When the local app owns the chat surface, opening/preparing the sidebar\n // may mount the MessageEvent listener that receives this payload. Defer the\n // post one tick so a closed sidebar cannot drop the prompt while mounting.\n if (!isCodeRequest && target === window) {\n setTimeout(postToTarget, 0);\n } else {\n postToTarget();\n }\n return tabId;\n}\n\n/**\n * Add or replace a keyed context nugget in the active agent chat composer.\n * The context is not submitted until the user sends the prompt.\n */\nexport function setAgentChatContextItem(\n opts: AgentChatContextSetOptions,\n): void {\n const item = normalizeAgentChatContextItem(opts);\n if (!item || typeof window === \"undefined\") return;\n\n publishAgentChatContextItems(\n withReplacedAgentChatContextItem(agentChatContextState.items, item),\n );\n postAgentChatContextMessage(AGENT_CHAT_SET_CONTEXT_MESSAGE_TYPE, item, {\n openSidebar: opts.openSidebar !== false,\n });\n}\n\n/** @deprecated Use `setAgentChatContextItem` instead. */\nexport const setContextToAgentChat = setAgentChatContextItem;\n\n/** @deprecated Use `setAgentChatContextItem` instead. */\nexport const addContextToAgentChat = setAgentChatContextItem;\n\nexport function removeAgentChatContextItem(\n keyOrOpts: string | AgentChatContextRemoveOptions,\n): void {\n const key =\n typeof keyOrOpts === \"string\" ? keyOrOpts.trim() : keyOrOpts.key.trim();\n if (!key || typeof window === \"undefined\") return;\n const openSidebar =\n typeof keyOrOpts === \"string\" ? false : keyOrOpts.openSidebar === true;\n\n publishAgentChatContextItems(\n agentChatContextState.items.filter((item) => item.key !== key),\n );\n postAgentChatContextMessage(\n AGENT_CHAT_REMOVE_CONTEXT_MESSAGE_TYPE,\n { key },\n { openSidebar },\n );\n}\n\nexport function clearAgentChatContext(\n opts: AgentChatContextMutationOptions = {},\n): void {\n if (typeof window === \"undefined\") return;\n publishAgentChatContextItems([]);\n postAgentChatContextMessage(\n AGENT_CHAT_CLEAR_CONTEXT_MESSAGE_TYPE,\n {},\n { openSidebar: opts.openSidebar === true },\n );\n}\n\nexport function _resetAgentChatContextForTests(): void {\n agentChatContextState = { items: [], updatedAt: 0 };\n notifyAgentChatContextListeners();\n}\n"]}
1
+ {"version":3,"file":"agent-chat.js","sourceRoot":"","sources":["../../src/client/agent-chat.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,+BAA+B,EAC/B,qBAAqB,GACtB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,iBAAiB,EACjB,0BAA0B,EAC1B,4BAA4B,EAC5B,iCAAiC,GAClC,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AA0GhD,MAAM,uBAAuB,GAAG,wBAAwB,CAAC;AACzD,MAAM,4BAA4B,GAAG,oBAAoB,CAAC;AAC1D,MAAM,wBAAwB,GAAG,wBAAwB,CAAC;AAC1D,MAAM,CAAC,MAAM,gCAAgC,GAC3C,gCAAgC,CAAC;AACnC,MAAM,CAAC,MAAM,mCAAmC,GAAG,4BAA4B,CAAC;AAChF,MAAM,CAAC,MAAM,sCAAsC,GACjD,+BAA+B,CAAC;AAClC,MAAM,CAAC,MAAM,qCAAqC,GAChD,8BAA8B,CAAC;AACjC,MAAM,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qB,CACnC,OAAwC,EAAE;IAE1C,IAAI,OAAO,MAAM,KAAK,WAAW;QAAE,OAAO;IAC1C,4BAA4B,CAAC,EAAE,CAAC,CAAC;IACjC,2BAA2B,CACzB,qCAAqC,EACrC,EAAE,EACF,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,KAAK,IAAI,EAAE,CAC3C,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,8BAA8B;IAC5C,qBAAqB,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC;IACpD,+BAA+B,EAAE,CAAC;AACpC,CAAC","sourcesContent":["/**\n * Agent Chat Bridge (browser)\n *\n * Sends structured messages to the agent chat from UI interactions.\n * Messages are sent via postMessage to the parent window (or self if top-level).\n * Builder frames are special: code requests go to Builder, but content prompts\n * stay inside the embedded app so its own AgentSidebar can receive them.\n */\n\nimport {\n getFramePostMessageTargetOrigin,\n isTrustedFrameMessage,\n} from \"./frame.js\";\nimport type { ReasoningEffort } from \"../shared/reasoning-effort.js\";\nimport {\n isEmbedAuthActive,\n isEmbedMcpChatBridgeActive,\n markEmbedMcpChatBridgeActive,\n readEmbedMcpChatBridgeFlagFromUrl,\n} from \"./embed-auth.js\";\nimport { sendMcpAppHostMessage } from \"./mcp-app-host.js\";\nimport {\n isInBuilderFrame,\n isTrustedBuilderMessage,\n sendToBuilderChat,\n} from \"./builder-frame.js\";\nimport { agentNativePath } from \"./api-path.js\";\n\nexport type AgentChatRequestMode = \"act\" | \"plan\";\n\nexport interface AgentChatMessage {\n /** The visible prompt message sent to the chat */\n message: string;\n /** Hidden context appended to the message (not shown in chat UI) */\n context?: string;\n /** true = auto-submit, false = prefill only, omit = use project setting */\n submit?: boolean;\n /** Optional project slug for structured context */\n projectSlug?: string;\n /** Optional preset name for downstream consumers */\n preset?: string;\n /** Optional reference image paths */\n referenceImagePaths?: string[];\n /** Optional uploaded reference images */\n uploadedReferenceImages?: string[];\n /** Optional image data URLs to include in the submitted chat message */\n images?: string[];\n /** Stable tab identifier — auto-generated if omitted */\n tabId?: string;\n /**\n * Message routing type:\n * - \"content\" (default): stays in the embedded app agent for content/data operations\n * - \"code\": routes to the code editing frame (Agent Native Desktop or Builder.io)\n *\n * When type is \"code\" and no frame is connected, a dialog is shown.\n * `requiresCode: true` is treated as `type: \"code\"` for backward compatibility.\n */\n type?: \"content\" | \"code\";\n /** @deprecated Use `type: \"code\"` instead. If true, treated as `type: \"code\"`. */\n requiresCode?: boolean;\n /** Model preference for this sub-agent (e.g. \"claude-haiku-4-5\"). Uses default if omitted */\n model?: string;\n /** Engine preference paired with model for cross-provider switches. */\n engine?: string;\n /** Reasoning effort preference paired with model. */\n effort?: ReasoningEffort;\n /**\n * Execution mode for this submitted turn. When omitted, sendToAgentChat\n * snapshots the current AgentPanel mode from localStorage when available.\n */\n mode?: AgentChatRequestMode;\n /** @deprecated Use `mode` instead. */\n requestMode?: AgentChatRequestMode;\n /** Scoped system prompt additions for this sub-agent */\n instructions?: string;\n /**\n * Whether to open the agent sidebar if it's currently hidden.\n * Defaults to true — submitting a chat should make the response visible.\n * Pass `false` for background/silent sends that shouldn't pop the UI open.\n */\n openSidebar?: boolean;\n /**\n * When true, opens a new chat tab before sending the message.\n * Use for creation requests (create tool, dashboard, etc.) that deserve\n * their own isolated thread rather than cluttering an existing conversation.\n */\n newTab?: boolean;\n /**\n * When true with newTab, creates the tab in the background without\n * focusing it or opening the sidebar. The message runs silently.\n */\n background?: boolean;\n}\n\nexport interface AgentChatContextItem {\n /** Stable key used to replace an existing context nugget. */\n key: string;\n /** Short label shown in the composer context chip. */\n title: string;\n /** Hidden context included with the next submitted prompt. */\n context: string;\n}\n\nexport interface AgentChatContextSetOptions extends AgentChatContextItem {\n /**\n * Whether to open the agent sidebar if it's currently hidden.\n * Defaults to true so the user can see the staged context.\n */\n openSidebar?: boolean;\n}\n\n/** @deprecated Use `AgentChatContextSetOptions` instead. */\nexport type AgentChatContextMessage = AgentChatContextSetOptions;\n\nexport interface AgentChatContextState {\n items: AgentChatContextItem[];\n updatedAt: number;\n}\n\nexport interface AgentChatContextMutationOptions {\n /**\n * Whether to open the agent sidebar if it's currently hidden.\n * Defaults to true for set/add and false for remove/clear.\n */\n openSidebar?: boolean;\n}\n\nexport interface AgentChatContextRemoveOptions extends AgentChatContextMutationOptions {\n /** Stable key of the staged context nugget to remove. */\n key: string;\n}\n\nconst AGENT_CHAT_MESSAGE_TYPE = \"agentNative.submitChat\";\nconst AGENT_CHAT_CONTEXT_STATE_KEY = \"agent-chat-context\";\nconst AGENT_CHAT_EXEC_MODE_KEY = \"agent-native-exec-mode\";\nexport const AGENT_CHAT_CONTEXT_CHANGED_EVENT =\n \"agentNative.chatContextChanged\";\nexport const AGENT_CHAT_SET_CONTEXT_MESSAGE_TYPE = \"agentNative.setChatContext\";\nexport const AGENT_CHAT_REMOVE_CONTEXT_MESSAGE_TYPE =\n \"agentNative.removeChatContext\";\nexport const AGENT_CHAT_CLEAR_CONTEXT_MESSAGE_TYPE =\n \"agentNative.clearChatContext\";\nconst AGENT_PANEL_PREPARE_EVENT = \"agent-panel:prepare\";\n\nlet agentChatContextState: AgentChatContextState = {\n items: [],\n updatedAt: 0,\n};\nconst agentChatContextListeners = new Set<() => void>();\n\n/**\n * Listen for chatRunning messages from the frame (postMessage)\n * and re-dispatch as a CustomEvent so hooks like useAgentChatGenerating() work.\n */\nif (typeof window !== \"undefined\") {\n window.addEventListener(\"message\", (event) => {\n if (!isTrustedFrameMessage(event) && !isTrustedBuilderMessage(event)) {\n return;\n }\n if (\n event.data?.type === \"agentNative.chatRunning\" ||\n event.data?.type === \"builder.chatRunning\"\n ) {\n window.dispatchEvent(\n new CustomEvent(\"agentNative.chatRunning\", {\n detail: event.data.detail ?? event.data.data,\n }),\n );\n }\n });\n}\n\n/** Generate a unique tab ID */\nexport function generateTabId(): string {\n return `chat-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;\n}\n\nexport function normalizeAgentChatContextItem(\n item: unknown,\n): AgentChatContextItem | null {\n if (typeof item !== \"object\" || item === null) return null;\n const candidate = item as Partial<AgentChatContextItem>;\n if (\n typeof candidate.key !== \"string\" ||\n typeof candidate.context !== \"string\" ||\n typeof candidate.title !== \"string\"\n ) {\n return null;\n }\n const key = candidate.key.trim();\n const context = candidate.context.trim();\n if (!key || !context) return null;\n return {\n key,\n title: candidate.title.trim() || key,\n context,\n };\n}\n\nexport function normalizeAgentChatContextItems(\n items: unknown,\n): AgentChatContextItem[] {\n if (!Array.isArray(items)) return [];\n const deduped = new Map<string, AgentChatContextItem>();\n for (const rawItem of items) {\n const item = normalizeAgentChatContextItem(rawItem);\n if (!item) continue;\n deduped.set(item.key, item);\n }\n return [...deduped.values()];\n}\n\nfunction normalizeAgentChatContextState(\n value: unknown,\n): AgentChatContextState | null {\n if (!value || typeof value !== \"object\") return null;\n const raw = value as {\n value?: unknown;\n items?: unknown;\n updatedAt?: unknown;\n };\n const candidate =\n raw.value && typeof raw.value === \"object\"\n ? (raw.value as { items?: unknown; updatedAt?: unknown })\n : raw;\n const items = normalizeAgentChatContextItems(candidate.items);\n return {\n items,\n updatedAt:\n typeof candidate.updatedAt === \"number\" ? candidate.updatedAt : 0,\n };\n}\n\nfunction withReplacedAgentChatContextItem(\n items: readonly AgentChatContextItem[],\n item: AgentChatContextItem,\n): AgentChatContextItem[] {\n const index = items.findIndex((current) => current.key === item.key);\n if (index === -1) return [...items, item];\n return items.map((current, currentIndex) =>\n currentIndex === index ? item : current,\n );\n}\n\nfunction notifyAgentChatContextListeners(): void {\n for (const listener of agentChatContextListeners) listener();\n}\n\nfunction persistAgentChatContextState(state: AgentChatContextState): void {\n if (typeof window === \"undefined\" || typeof fetch !== \"function\") return;\n fetch(\n agentNativePath(\n `/_agent-native/application-state/${AGENT_CHAT_CONTEXT_STATE_KEY}`,\n ),\n {\n method: \"PUT\",\n keepalive: true,\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify(state),\n },\n ).catch(() => {});\n}\n\nexport function publishAgentChatContextItems(\n items: readonly AgentChatContextItem[],\n options?: { persist?: boolean; updatedAt?: number },\n): AgentChatContextState {\n const next: AgentChatContextState = {\n items: normalizeAgentChatContextItems([...items]),\n updatedAt: options?.updatedAt ?? Date.now(),\n };\n if (next.updatedAt < agentChatContextState.updatedAt) {\n return agentChatContextState;\n }\n agentChatContextState = next;\n notifyAgentChatContextListeners();\n if (typeof window !== \"undefined\") {\n window.dispatchEvent(\n new CustomEvent(AGENT_CHAT_CONTEXT_CHANGED_EVENT, {\n detail: next,\n }),\n );\n }\n if (options?.persist !== false) {\n persistAgentChatContextState(next);\n }\n return next;\n}\n\nexport function getAgentChatContextState(): AgentChatContextState {\n return agentChatContextState;\n}\n\nexport function listAgentChatContext(): AgentChatContextItem[] {\n return [...agentChatContextState.items];\n}\n\nexport function subscribeAgentChatContext(listener: () => void): () => void {\n agentChatContextListeners.add(listener);\n return () => {\n agentChatContextListeners.delete(listener);\n };\n}\n\nexport async function refreshAgentChatContext(): Promise<AgentChatContextState> {\n if (typeof window === \"undefined\" || typeof fetch !== \"function\") {\n return agentChatContextState;\n }\n try {\n const res = await fetch(\n agentNativePath(\n `/_agent-native/application-state/${AGENT_CHAT_CONTEXT_STATE_KEY}`,\n ),\n );\n if (!res.ok || res.status === 204) return agentChatContextState;\n const text = await res.text();\n if (!text) return agentChatContextState;\n const state = normalizeAgentChatContextState(JSON.parse(text));\n if (!state) return agentChatContextState;\n return publishAgentChatContextItems(state.items, {\n persist: false,\n updatedAt: state.updatedAt,\n });\n } catch {\n return agentChatContextState;\n }\n}\n\nexport function formatAgentChatContextItemsForPrompt(\n items: readonly AgentChatContextItem[],\n): string {\n return items\n .map(normalizeAgentChatContextItem)\n .filter((item): item is AgentChatContextItem => item !== null)\n .map((item) => [`## ${item.title}`, item.context].join(\"\\n\"))\n .join(\"\\n\\n\");\n}\n\nexport function appendAgentChatContextToMessage(\n message: string,\n context: string,\n): string {\n const trimmedContext = context.trim();\n if (!trimmedContext) return message;\n return `${message.trim()}\\n\\n<context>\\n${trimmedContext}\\n</context>`;\n}\n\nfunction postAgentChatContextMessage(\n type:\n | typeof AGENT_CHAT_SET_CONTEXT_MESSAGE_TYPE\n | typeof AGENT_CHAT_REMOVE_CONTEXT_MESSAGE_TYPE\n | typeof AGENT_CHAT_CLEAR_CONTEXT_MESSAGE_TYPE,\n data: unknown,\n options: { openSidebar: boolean },\n): void {\n if (typeof window === \"undefined\") return;\n\n const payload = { type, data };\n const targetSelf = isInBuilderFrame() || isDirectMcpAppEmbedSession();\n const target = targetSelf\n ? window\n : window.parent !== window\n ? window.parent\n : window;\n const targetOrigin = targetSelf\n ? window.location.origin\n : getFramePostMessageTargetOrigin() || window.location.origin;\n\n if (options.openSidebar) {\n window.dispatchEvent(\n new CustomEvent(\"agent-panel:set-mode\", {\n detail: { mode: \"chat\" },\n }),\n );\n window.dispatchEvent(new CustomEvent(\"agent-panel:open\"));\n } else {\n window.dispatchEvent(new CustomEvent(AGENT_PANEL_PREPARE_EVENT));\n }\n\n const postToTarget = () => target.postMessage(payload, targetOrigin);\n if (target === window) {\n setTimeout(postToTarget, 0);\n } else {\n postToTarget();\n }\n}\n\nfunction isMcpAppChatBridgeEnabled(): boolean {\n if (typeof window === \"undefined\" || window.parent === window) return false;\n if (readEmbedMcpChatBridgeFlagFromUrl()) markEmbedMcpChatBridgeActive();\n return isEmbedMcpChatBridgeActive() && isEmbedAuthActive();\n}\n\nfunction isDirectMcpAppEmbedSession(): boolean {\n if (typeof window === \"undefined\" || window.parent === window) return false;\n if (readEmbedMcpChatBridgeFlagFromUrl()) markEmbedMcpChatBridgeActive();\n return isEmbedAuthActive() && !isEmbedMcpChatBridgeActive();\n}\n\nfunction dispatchAgentChatRunning(isRunning: boolean): void {\n if (typeof window === \"undefined\") return;\n window.dispatchEvent(\n new CustomEvent(\"agentNative.chatRunning\", {\n detail: { isRunning },\n }),\n );\n}\n\nfunction normalizeAgentChatRequestMode(\n value: unknown,\n): AgentChatRequestMode | undefined {\n return value === \"act\" || value === \"plan\" ? value : undefined;\n}\n\nfunction readStoredAgentChatRequestMode(): AgentChatRequestMode | undefined {\n if (typeof window === \"undefined\") return undefined;\n try {\n const saved = window.localStorage.getItem(AGENT_CHAT_EXEC_MODE_KEY);\n if (saved === \"plan\") return \"plan\";\n if (saved === \"build\") return \"act\";\n } catch {}\n return undefined;\n}\n\n/**\n * Send a message to the agent chat via postMessage.\n * Returns the stable tabId for tracking this chat run.\n */\nexport function sendToAgentChat(opts: AgentChatMessage): string {\n const tabId = opts.tabId ?? generateTabId();\n const isCodeRequest = opts.type === \"code\" || opts.requiresCode === true;\n if (isCodeRequest && isInBuilderFrame()) {\n sendToBuilderChat({\n message: opts.message,\n context: opts.context,\n submit: opts.submit,\n });\n return tabId;\n }\n const requestMode =\n normalizeAgentChatRequestMode(opts.requestMode ?? opts.mode) ??\n readStoredAgentChatRequestMode();\n\n const payload = {\n type: AGENT_CHAT_MESSAGE_TYPE,\n data: {\n ...opts,\n tabId,\n ...(requestMode ? { mode: requestMode, requestMode } : {}),\n },\n };\n\n if (opts.submit !== false && isMcpAppChatBridgeEnabled()) {\n const directHostMessage = sendMcpAppHostMessage({\n message: opts.message,\n context: opts.context,\n });\n if (directHostMessage) {\n void Promise.resolve(directHostMessage)\n .then((ok) => {\n if (!ok) {\n window.parent.postMessage(\n payload,\n getFramePostMessageTargetOrigin() || \"*\",\n );\n }\n })\n .finally(() => {\n dispatchAgentChatRunning(false);\n });\n return tabId;\n }\n window.parent.postMessage(\n payload,\n getFramePostMessageTargetOrigin() || \"*\",\n );\n return tabId;\n }\n\n const shouldOpenSidebar = opts.openSidebar !== false && !opts.background;\n\n const targetSelf =\n !isCodeRequest && (isInBuilderFrame() || isDirectMcpAppEmbedSession());\n const target = targetSelf\n ? window\n : window.parent !== window\n ? window.parent\n : window;\n const targetOrigin = targetSelf\n ? window.location.origin\n : getFramePostMessageTargetOrigin() || window.location.origin;\n if (shouldOpenSidebar) {\n window.dispatchEvent(\n new CustomEvent(\"agent-panel:set-mode\", {\n detail: { mode: \"chat\" },\n }),\n );\n window.dispatchEvent(new CustomEvent(\"agent-panel:open\"));\n } else if (!isCodeRequest) {\n window.dispatchEvent(new CustomEvent(AGENT_PANEL_PREPARE_EVENT));\n }\n\n const postToTarget = () => target.postMessage(payload, targetOrigin);\n\n // When the local app owns the chat surface, opening/preparing the sidebar\n // may mount the MessageEvent listener that receives this payload. Defer the\n // post one tick so a closed sidebar cannot drop the prompt while mounting.\n if (!isCodeRequest && target === window) {\n setTimeout(postToTarget, 0);\n } else {\n postToTarget();\n }\n return tabId;\n}\n\n/**\n * Add or replace a keyed context nugget in the active agent chat composer.\n * The context is not submitted until the user sends the prompt.\n */\nexport function setAgentChatContextItem(\n opts: AgentChatContextSetOptions,\n): void {\n const item = normalizeAgentChatContextItem(opts);\n if (!item || typeof window === \"undefined\") return;\n\n publishAgentChatContextItems(\n withReplacedAgentChatContextItem(agentChatContextState.items, item),\n );\n postAgentChatContextMessage(AGENT_CHAT_SET_CONTEXT_MESSAGE_TYPE, item, {\n openSidebar: opts.openSidebar !== false,\n });\n}\n\n/** @deprecated Use `setAgentChatContextItem` instead. */\nexport const setContextToAgentChat = setAgentChatContextItem;\n\n/** @deprecated Use `setAgentChatContextItem` instead. */\nexport const addContextToAgentChat = setAgentChatContextItem;\n\nexport function removeAgentChatContextItem(\n keyOrOpts: string | AgentChatContextRemoveOptions,\n): void {\n const key =\n typeof keyOrOpts === \"string\" ? keyOrOpts.trim() : keyOrOpts.key.trim();\n if (!key || typeof window === \"undefined\") return;\n const openSidebar =\n typeof keyOrOpts === \"string\" ? false : keyOrOpts.openSidebar === true;\n\n publishAgentChatContextItems(\n agentChatContextState.items.filter((item) => item.key !== key),\n );\n postAgentChatContextMessage(\n AGENT_CHAT_REMOVE_CONTEXT_MESSAGE_TYPE,\n { key },\n { openSidebar },\n );\n}\n\nexport function clearAgentChatContext(\n opts: AgentChatContextMutationOptions = {},\n): void {\n if (typeof window === \"undefined\") return;\n publishAgentChatContextItems([]);\n postAgentChatContextMessage(\n AGENT_CHAT_CLEAR_CONTEXT_MESSAGE_TYPE,\n {},\n { openSidebar: opts.openSidebar === true },\n );\n}\n\nexport function _resetAgentChatContextForTests(): void {\n agentChatContextState = { items: [], updatedAt: 0 };\n notifyAgentChatContextListeners();\n}\n"]}
@@ -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;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"}
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,2CA4SnC;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"}
@@ -133,6 +133,7 @@ function AnnotatedCodeRead({ data, blockId, title, summary, ctx, }) {
133
133
  preferredSide: annotationHoverSide,
134
134
  });
135
135
  const showPersistentAnnotations = showAnnotationOverlays || showMarginAnnotations;
136
+ const captureOverlayAnnotationIndex = useMemo(() => resolved.find((item) => item.range)?.index ?? null, [resolved]);
136
137
  const langChip = data.language?.trim();
137
138
  const hasFilename = Boolean(data.filename?.trim());
138
139
  const showLangChip = Boolean(langChip && !hasFilename);
@@ -149,7 +150,9 @@ function AnnotatedCodeRead({ data, blockId, title, summary, ctx, }) {
149
150
  const isAnnotated = !!markers?.length;
150
151
  const isActive = activeIndex != null && !!markers?.some((m) => m.index === activeIndex);
151
152
  const overlayItems = showPersistentAnnotations && markers
152
- ? markers.filter((item) => item.range?.start === lineNo)
153
+ ? markers.filter((item) => item.range?.start === lineNo &&
154
+ (!showAnnotationOverlays ||
155
+ item.index === captureOverlayAnnotationIndex))
153
156
  : [];
154
157
  const buildAnchorForRow = (el) => {
155
158
  if (!markers)
@@ -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,iCAAiC,EACjC,kBAAkB,GAEnB,MAAM,s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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, AnnotatedC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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 captureOverlayAnnotationIndex = useMemo(\n () => resolved.find((item) => item.range)?.index ?? null,\n [resolved],\n );\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(\n (item) =>\n item.range?.start === lineNo &&\n (!showAnnotationOverlays ||\n item.index === captureOverlayAnnotationIndex),\n )\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":"AAoBA,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EAEf,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAkB,QAAQ,EAAY,MAAM,kBAAkB,CAAC;AAmB3E;;;;;;;;;;;;;;;GAeG;AAIH,UAA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Q,CAAC,2CA2LvE;AAED,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC"}
@@ -539,6 +539,7 @@ function DiffRead({ data, blockId, title, summary, ctx, }) {
539
539
  preferredSide: annotationHoverSide,
540
540
  });
541
541
  const showPersistentAnnotations = showAnnotationOverlays || showMarginAnnotations;
542
+ const captureOverlayAnnotationIndex = useMemo(() => resolved.find((item) => item.range)?.index ?? null, [resolved]);
542
543
  // Effective render mode. Annotations live in a SEPARATE right-hand rail (not
543
544
  // over the code), so they no longer force a mode. When no mode was authored, a
544
545
  // truly narrow container still falls back to unified so split's doubled
@@ -630,7 +631,7 @@ function DiffRead({ data, blockId, title, summary, ctx, }) {
630
631
  // The bordered code box. It always spans its full width — annotations surface
631
632
  // as an on-hover popover anchored to this box's right edge, never as a column.
632
633
  // `codeRef` measures that right edge for the popover's placement.
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
634
+ 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, captureOverlayAnnotationIndex: captureOverlayAnnotationIndex, 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, captureOverlayAnnotationIndex: captureOverlayAnnotationIndex, 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
634
635
  ? "Show fewer"
635
636
  : `Show all ${totalVisibleLineCount} lines`] }))] }));
636
637
  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 &&
@@ -676,7 +677,7 @@ function isMarkerRangeStart(row, marker) {
676
677
  return lineNo === marker.range.start;
677
678
  }
678
679
  /* ── Unified view ──────────────────────────────────────────────────────────── */
679
- function UnifiedView({ rows, language, expanded, onToggleRun, markersForRow, anchoredRow, activeIndex, onRowEnter, onRowLeave, onRowClick, showAnnotationOverlays, annotationOverlayMode, annotationOverlaySide, annotationOverlayPreferredSide, annotationOverlayContainerRef, ctx, }) {
680
+ function UnifiedView({ rows, language, expanded, onToggleRun, markersForRow, anchoredRow, activeIndex, onRowEnter, onRowLeave, onRowClick, showAnnotationOverlays, annotationOverlayMode, annotationOverlaySide, annotationOverlayPreferredSide, annotationOverlayContainerRef, captureOverlayAnnotationIndex, ctx, }) {
680
681
  const segments = useMemo(() => segmentRows(rows, anchoredRow), [rows, anchoredRow]);
681
682
  // Any annotation present ⇒ reserve the marker column so rows stay aligned.
682
683
  const showMarkerColumn = useMemo(() => rows.some((row) => markersForRow(row).length > 0), [rows, markersForRow]);
@@ -693,6 +694,7 @@ function UnifiedView({ rows, language, expanded, onToggleRun, markersForRow, anc
693
694
  annotationOverlaySide,
694
695
  annotationOverlayPreferredSide,
695
696
  annotationOverlayContainerRef,
697
+ captureOverlayAnnotationIndex,
696
698
  ctx,
697
699
  };
698
700
  let runIndex = 0;
@@ -706,12 +708,17 @@ function UnifiedView({ rows, language, expanded, onToggleRun, markersForRow, anc
706
708
  return _jsx(UnifiedRow, { row: segment, ...rowProps }, idx);
707
709
  }) }) }));
708
710
  }
709
- function UnifiedRow({ language, row, markersForRow, activeIndex, onRowEnter, onRowLeave, onRowClick, showMarkerColumn, showAnnotationOverlays, annotationOverlayMode, annotationOverlaySide, annotationOverlayPreferredSide, annotationOverlayContainerRef, ctx, }) {
711
+ function UnifiedRow({ language, row, markersForRow, activeIndex, onRowEnter, onRowLeave, onRowClick, showMarkerColumn, showAnnotationOverlays, annotationOverlayMode, annotationOverlaySide, annotationOverlayPreferredSide, annotationOverlayContainerRef, captureOverlayAnnotationIndex, ctx, }) {
710
712
  const markers = markersForRow(row);
711
713
  const info = rowMarkerInfo(markers, activeIndex);
712
714
  const startMarker = markers.find((marker) => isMarkerRangeStart(row, marker));
713
715
  const primaryIndex = startMarker?.index ?? info?.primaryIndex;
714
- const overlayItems = showAnnotationOverlays && startMarker ? [startMarker] : [];
716
+ const overlayItems = showAnnotationOverlays &&
717
+ startMarker &&
718
+ (annotationOverlayMode !== "capture" ||
719
+ startMarker.index === captureOverlayAnnotationIndex)
720
+ ? [startMarker]
721
+ : [];
715
722
  return (_jsxs("div", { "data-annot-row": startMarker ? startMarker.index : undefined, tabIndex: info ? 0 : undefined, role: info ? "button" : undefined, "aria-expanded": info ? info.isActive : undefined, className: cn("relative flex min-h-5 min-w-full", info && "cursor-pointer", ROW_BG[row.kind], annotatedRowBg(info)), onMouseEnter: info && primaryIndex != null
716
723
  ? (event) => onRowEnter(primaryIndex, event.currentTarget)
717
724
  : undefined, onMouseLeave: info ? () => onRowLeave() : undefined, onClick: info && primaryIndex != null
@@ -769,7 +776,7 @@ function pairSplitRows(rows) {
769
776
  }
770
777
  return out;
771
778
  }
772
- function SplitView({ language, rowLimit, rows, markersForRow, activeIndex, onRowEnter, onRowLeave, onRowClick, showAnnotationOverlays, annotationOverlayMode, annotationOverlaySide, annotationOverlayPreferredSide, annotationOverlayContainerRef, ctx, }) {
779
+ function SplitView({ language, rowLimit, rows, markersForRow, activeIndex, onRowEnter, onRowLeave, onRowClick, showAnnotationOverlays, annotationOverlayMode, annotationOverlaySide, annotationOverlayPreferredSide, annotationOverlayContainerRef, captureOverlayAnnotationIndex, ctx, }) {
773
780
  const pairs = useMemo(() => pairSplitRows(rows), [rows]);
774
781
  const displayedPairs = rowLimit ? pairs.slice(0, rowLimit) : pairs;
775
782
  // Reserve the marker column on a side only if any visible row there has one.
@@ -787,11 +794,12 @@ function SplitView({ language, rowLimit, rows, markersForRow, activeIndex, onRow
787
794
  annotationOverlaySide,
788
795
  annotationOverlayPreferredSide,
789
796
  annotationOverlayContainerRef,
797
+ captureOverlayAnnotationIndex,
790
798
  ctx,
791
799
  };
792
800
  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}`))) }) })] }));
793
801
  }
794
- function SplitCell({ language, row, side, markersForRow, activeIndex, onRowEnter, onRowLeave, onRowClick, showMarkerColumn, showAnnotationOverlays, annotationOverlayMode, annotationOverlaySide, annotationOverlayPreferredSide, annotationOverlayContainerRef, ctx, }) {
802
+ function SplitCell({ language, row, side, markersForRow, activeIndex, onRowEnter, onRowLeave, onRowClick, showMarkerColumn, showAnnotationOverlays, annotationOverlayMode, annotationOverlaySide, annotationOverlayPreferredSide, annotationOverlayContainerRef, captureOverlayAnnotationIndex, ctx, }) {
795
803
  if (!row) {
796
804
  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: " " })] }));
797
805
  }
@@ -801,7 +809,12 @@ function SplitCell({ language, row, side, markersForRow, activeIndex, onRowEnter
801
809
  const info = rowMarkerInfo(markers, activeIndex);
802
810
  const startMarker = markers.find((marker) => isMarkerRangeStart(row, marker));
803
811
  const primaryIndex = startMarker?.index ?? info?.primaryIndex;
804
- const overlayItems = showAnnotationOverlays && startMarker ? [startMarker] : [];
812
+ const overlayItems = showAnnotationOverlays &&
813
+ startMarker &&
814
+ (annotationOverlayMode !== "capture" ||
815
+ startMarker.index === captureOverlayAnnotationIndex)
816
+ ? [startMarker]
817
+ : [];
805
818
  return (_jsxs("div", { "data-annot-row": startMarker ? startMarker.index : undefined, tabIndex: info ? 0 : undefined, role: info ? "button" : undefined, "aria-expanded": info ? info.isActive : undefined, className: cn("relative flex min-h-5 min-w-full", info && "cursor-pointer", ROW_BG[row.kind], annotatedRowBg(info)), onMouseEnter: info && primaryIndex != null
806
819
  ? (event) => onRowEnter(primaryIndex, event.currentTarget)
807
820
  : undefined, onMouseLeave: info ? () => onRowLeave() : undefined, onClick: info && primaryIndex != null