@agent-native/core 0.49.2 → 0.49.3

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 (88) hide show
  1. package/dist/agent/engine/builder-engine.d.ts +1 -1
  2. package/dist/agent/engine/builder-engine.d.ts.map +1 -1
  3. package/dist/agent/engine/index.d.ts +1 -1
  4. package/dist/agent/engine/index.d.ts.map +1 -1
  5. package/dist/agent/engine/index.js +1 -1
  6. package/dist/agent/engine/index.js.map +1 -1
  7. package/dist/agent/engine/registry.d.ts +1 -0
  8. package/dist/agent/engine/registry.d.ts.map +1 -1
  9. package/dist/agent/engine/registry.js +11 -0
  10. package/dist/agent/engine/registry.js.map +1 -1
  11. package/dist/agent/model-config.d.ts +2 -2
  12. package/dist/agent/model-config.d.ts.map +1 -1
  13. package/dist/agent/model-config.js +2 -6
  14. package/dist/agent/model-config.js.map +1 -1
  15. package/dist/agent/production-agent.d.ts.map +1 -1
  16. package/dist/agent/production-agent.js +3 -2
  17. package/dist/agent/production-agent.js.map +1 -1
  18. package/dist/cli/code-agent-executor.d.ts.map +1 -1
  19. package/dist/cli/code-agent-executor.js +3 -2
  20. package/dist/cli/code-agent-executor.js.map +1 -1
  21. package/dist/cli/connect.d.ts.map +1 -1
  22. package/dist/cli/connect.js +117 -33
  23. package/dist/cli/connect.js.map +1 -1
  24. package/dist/cli/pr-visual-recap-workflow.d.ts +1 -1
  25. package/dist/cli/pr-visual-recap-workflow.d.ts.map +1 -1
  26. package/dist/cli/pr-visual-recap-workflow.js +1 -1
  27. package/dist/cli/pr-visual-recap-workflow.js.map +1 -1
  28. package/dist/cli/recap.d.ts +20 -0
  29. package/dist/cli/recap.d.ts.map +1 -1
  30. package/dist/cli/recap.js +256 -40
  31. package/dist/cli/recap.js.map +1 -1
  32. package/dist/cli/skills.d.ts +2 -2
  33. package/dist/cli/skills.d.ts.map +1 -1
  34. package/dist/cli/skills.js +5 -5
  35. package/dist/cli/skills.js.map +1 -1
  36. package/dist/client/MultiTabAssistantChat.d.ts.map +1 -1
  37. package/dist/client/MultiTabAssistantChat.js +0 -7
  38. package/dist/client/MultiTabAssistantChat.js.map +1 -1
  39. package/dist/client/blocks/library/annotation-rail.d.ts +14 -0
  40. package/dist/client/blocks/library/annotation-rail.d.ts.map +1 -1
  41. package/dist/client/blocks/library/annotation-rail.js +64 -2
  42. package/dist/client/blocks/library/annotation-rail.js.map +1 -1
  43. package/dist/client/use-chat-models.d.ts.map +1 -1
  44. package/dist/client/use-chat-models.js +0 -5
  45. package/dist/client/use-chat-models.js.map +1 -1
  46. package/dist/integrations/webhook-handler.d.ts.map +1 -1
  47. package/dist/integrations/webhook-handler.js +3 -2
  48. package/dist/integrations/webhook-handler.js.map +1 -1
  49. package/dist/jobs/scheduler.d.ts.map +1 -1
  50. package/dist/jobs/scheduler.js +3 -2
  51. package/dist/jobs/scheduler.js.map +1 -1
  52. package/dist/mcp/connect-route.d.ts +2 -0
  53. package/dist/mcp/connect-route.d.ts.map +1 -1
  54. package/dist/mcp/connect-route.js +3 -0
  55. package/dist/mcp/connect-route.js.map +1 -1
  56. package/dist/mcp/server.js +1 -1
  57. package/dist/mcp/server.js.map +1 -1
  58. package/dist/observability/evals.d.ts.map +1 -1
  59. package/dist/observability/evals.js +5 -3
  60. package/dist/observability/evals.js.map +1 -1
  61. package/dist/scripts/agent-engines/list-agent-engines.d.ts.map +1 -1
  62. package/dist/scripts/agent-engines/list-agent-engines.js +6 -3
  63. package/dist/scripts/agent-engines/list-agent-engines.js.map +1 -1
  64. package/dist/scripts/agent-engines/manage-agent-engine.d.ts.map +1 -1
  65. package/dist/scripts/agent-engines/manage-agent-engine.js +5 -1
  66. package/dist/scripts/agent-engines/manage-agent-engine.js.map +1 -1
  67. package/dist/scripts/agent-engines/set-agent-engine.d.ts.map +1 -1
  68. package/dist/scripts/agent-engines/set-agent-engine.js +7 -2
  69. package/dist/scripts/agent-engines/set-agent-engine.js.map +1 -1
  70. package/dist/server/agent-chat-plugin.d.ts.map +1 -1
  71. package/dist/server/agent-chat-plugin.js +14 -4
  72. package/dist/server/agent-chat-plugin.js.map +1 -1
  73. package/dist/server/complete-text.d.ts.map +1 -1
  74. package/dist/server/complete-text.js +3 -2
  75. package/dist/server/complete-text.js.map +1 -1
  76. package/dist/server/core-routes-plugin.d.ts +2 -0
  77. package/dist/server/core-routes-plugin.d.ts.map +1 -1
  78. package/dist/server/core-routes-plugin.js +1 -0
  79. package/dist/server/core-routes-plugin.js.map +1 -1
  80. package/dist/templates/workspace-core/.agents/skills/external-agents/SKILL.md +7 -6
  81. package/dist/triggers/dispatcher.d.ts.map +1 -1
  82. package/dist/triggers/dispatcher.js +3 -2
  83. package/dist/triggers/dispatcher.js.map +1 -1
  84. package/docs/content/external-agents.md +1 -1
  85. package/docs/content/plan-plugin.md +2 -2
  86. package/docs/content/pr-visual-recap.md +12 -4
  87. package/package.json +1 -1
  88. package/src/templates/workspace-core/.agents/skills/external-agents/SKILL.md +7 -6
@@ -118,6 +118,20 @@ export interface AnnotationAnchor {
118
118
  /** Bottom of the hovered line (for the below-fallback placement). */
119
119
  lineBottom: number;
120
120
  }
121
+ export declare function resolveAnnotationInlineOverlayPosition(anchor: {
122
+ right: number;
123
+ top: number;
124
+ height: number;
125
+ }, card: {
126
+ width: number;
127
+ height: number;
128
+ }, viewport: {
129
+ width: number;
130
+ height: number;
131
+ }): {
132
+ top: number;
133
+ right: number;
134
+ };
121
135
  export declare function resolveAnnotationHoverCardPosition(anchor: AnnotationAnchor, card: {
122
136
  width: number;
123
137
  height: number;
@@ -1 +1 @@
1
- {"version":3,"file":"annotation-rail.d.ts","sourceRoot":"","sources":["../../../../src/client/blocks/library/annotation-rail.tsx"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAGf,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAIH;;;;;G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AA6D;IAC7D,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,2CAoBA;AAED,gFAAgF;AAChF,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,kBAAkB,EAAE,GAAG,OAAO,CAEvE;AAED,MAAM,MAAM,sBAAsB,GAAG,SAAS,CAAC"}
@@ -1,4 +1,4 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { useEffect, useLayoutEffect, useMemo, useRef, useState, } from "react";
3
3
  import { createPortal } from "react-dom";
4
4
  import { cn } from "../../utils.js";
@@ -125,14 +125,76 @@ export function AnnotationHiddenStack({ items, ctx, showMarker = false, }) {
125
125
  }
126
126
  export function AnnotationInlineOverlayStack({ items, ctx, showMarker = false, }) {
127
127
  const resolved = items.filter((item) => item.range);
128
+ const anchorRef = useRef(null);
129
+ const portalRef = useRef(null);
130
+ const [position, setPosition] = useState(null);
131
+ const positionKey = resolved
132
+ .map((item) => `${item.index}:${item.marker}:${item.annotation.lines}:${item.annotation.label ?? ""}:${item.annotation.note}`)
133
+ .join("|");
134
+ useLayoutEffect(() => {
135
+ if (typeof window === "undefined")
136
+ return;
137
+ const anchor = anchorRef.current;
138
+ if (!anchor)
139
+ return;
140
+ let frame = null;
141
+ const updatePosition = () => {
142
+ const anchorRect = anchor.getBoundingClientRect();
143
+ const portalRect = portalRef.current?.getBoundingClientRect();
144
+ const viewportWidth = Math.max(window.innerWidth || 0, INLINE_OVERLAY_WIDTH + VIEWPORT_MARGIN * 2);
145
+ const viewportHeight = Math.max(window.innerHeight || 0, VIEWPORT_MARGIN * 2);
146
+ const width = portalRect && portalRect.width > 0
147
+ ? portalRect.width
148
+ : Math.min(INLINE_OVERLAY_WIDTH, viewportWidth * 0.45);
149
+ const height = portalRect && portalRect.height > 0 ? portalRect.height : 0;
150
+ setPosition(resolveAnnotationInlineOverlayPosition({
151
+ right: anchorRect.right,
152
+ top: anchorRect.top,
153
+ height: anchorRect.height,
154
+ }, { width, height }, { width: viewportWidth, height: viewportHeight }));
155
+ };
156
+ updatePosition();
157
+ if (typeof window.requestAnimationFrame === "function") {
158
+ frame = window.requestAnimationFrame(updatePosition);
159
+ }
160
+ window.addEventListener("resize", updatePosition);
161
+ window.addEventListener("scroll", updatePosition, {
162
+ capture: true,
163
+ passive: true,
164
+ });
165
+ return () => {
166
+ if (frame != null && typeof window.cancelAnimationFrame === "function") {
167
+ window.cancelAnimationFrame(frame);
168
+ }
169
+ window.removeEventListener("resize", updatePosition);
170
+ window.removeEventListener("scroll", updatePosition, { capture: true });
171
+ };
172
+ }, [positionKey]);
128
173
  if (resolved.length === 0)
129
174
  return null;
130
- return (_jsx("div", { "aria-hidden": true, "data-annotation-inline-overlay": true, className: "pointer-events-none sticky right-3 z-20 ml-auto h-0 w-0 shrink-0 overflow-visible", children: _jsx("div", { className: "absolute right-0 top-1/2 flex w-[min(20rem,45vw)] -translate-y-1/2 flex-col gap-2", children: resolved.map((item) => (_jsx(AnnotationCard, { item: item, ctx: ctx, active: true, showMarker: showMarker, className: "border-amber-400/80 bg-amber-50/95 shadow-lg shadow-black/10 dark:border-amber-300/45 dark:bg-amber-300/[0.09] dark:shadow-black/40" }, item.index))) }) }));
175
+ const portal = typeof document === "undefined"
176
+ ? null
177
+ : createPortal(_jsx("div", { "aria-hidden": true, ref: portalRef, "data-annotation-inline-overlay": true, className: "pointer-events-none fixed z-50 flex w-[min(20rem,45vw)] flex-col gap-2", style: {
178
+ top: position?.top ?? VIEWPORT_MARGIN,
179
+ right: position?.right ?? VIEWPORT_MARGIN,
180
+ visibility: position ? "visible" : "hidden",
181
+ }, children: resolved.map((item) => (_jsx(AnnotationCard, { item: item, ctx: ctx, active: true, showMarker: showMarker, className: "border-amber-400/80 bg-amber-50/95 shadow-lg shadow-black/10 dark:border-amber-300/45 dark:bg-amber-300/[0.09] dark:shadow-black/40" }, item.index))) }), document.body);
182
+ return (_jsxs(_Fragment, { children: [_jsx("div", { "aria-hidden": true, ref: anchorRef, "data-annotation-inline-overlay-anchor": true, className: "pointer-events-none sticky right-3 z-20 ml-auto h-0 w-0 shrink-0 overflow-visible" }), portal] }));
131
183
  }
132
184
  const HOVER_CARD_WIDTH = 280;
185
+ const INLINE_OVERLAY_WIDTH = 320;
133
186
  const HOVER_CARD_GAP = 12;
134
187
  const VIEWPORT_MARGIN = 8;
135
188
  const SCROLL_HOVER_SUPPRESS_MS = 260;
189
+ export function resolveAnnotationInlineOverlayPosition(anchor, card, viewport) {
190
+ const maxTop = Math.max(VIEWPORT_MARGIN, viewport.height - card.height - VIEWPORT_MARGIN);
191
+ const centeredTop = anchor.top + anchor.height / 2 - card.height / 2;
192
+ const maxRight = Math.max(VIEWPORT_MARGIN, viewport.width - card.width - VIEWPORT_MARGIN);
193
+ return {
194
+ top: Math.max(VIEWPORT_MARGIN, Math.min(centeredTop, maxTop)),
195
+ right: Math.max(VIEWPORT_MARGIN, Math.min(viewport.width - anchor.right, maxRight)),
196
+ };
197
+ }
136
198
  export function resolveAnnotationHoverCardPosition(anchor, card, viewport) {
137
199
  const rightLeft = anchor.codeRight + HOVER_CARD_GAP;
138
200
  const fitsRight = rightLeft + card.width + VIEWPORT_MARGIN <= viewport.width;
@@ -1 +1 @@
1
- {"version":3,"file":"annotation-rail.js","sourceRoot":"","sources":["../../../../src/client/blocks/library/annotation-rail.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,SAAS,EACT,eAAe,EACf,OAAO,EACP,MAAM,EACN,QAAQ,GAET,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAGpC;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,kFAAkF;AAElF;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAC5B,GAAW,EACX,SAAiB;IAEjB,MAAM,KAAK,GAAG,gCAA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ACT,UAAU,GAAG,KAAK,GASnB;IACC,MAAM,eAAe,GAAG,OAAO,CAC7B,GAAG,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,EACxC,CAAC,KAAK,CAAC,CACR,CAAC;IACF,OAAO,CACL,cAAK,SAAS,EAAE,EAAE,CAAC,uBAAuB,EAAE,SAAS,CAAC,YACnD,eAAe,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAC7B,KAAC,cAAc,IAEb,IAAI,EAAE,IAAI,EACV,GAAG,EAAE,GAAG,EACR,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC,KAAK,EAClC,UAAU,EAAE,UAAU,EACtB,YAAY,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,EAC9C,YAAY,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,IANnC,IAAI,CAAC,KAAK,CAOf,CACH,CAAC,GACE,CACP,CAAC;AACJ,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,kBAAkB,CAAC,KAA2B;IAC5D,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC1C,CAAC","sourcesContent":["import {\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n type ReactNode,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { cn } from \"../../utils.js\";\nimport type { BlockRenderContext } from \"../types.js\";\n\n/**\n * Shared line-anchored annotation UI for the `annotated-code` and `diff` blocks.\n *\n * Both blocks render a numbered code surface plus a side \"rail\" of notes, where\n * each note targets a 1-based `lines` ref (`\"3\"` or `\"3-5\"`) and hovering a code\n * line ↔ its note cross-highlights. This module owns the pure pieces that were\n * identical between them so neither block forks the behavior:\n *\n * - `parseLineRange` — the forgiving 1-based `lines` range parser.\n * - `resolveAnnotations` / `buildLineMarkerMap` — turn a raw annotation list\n * into stable, marker-numbered, range-resolved records and a line→markers map.\n * - `rangeLabel` — the human \"Line 8\" / \"Lines 3–6\" label.\n * - `AnnotationGutterMarker` — the numbered amber pip placed on an annotated row\n * (used by the diff grid; the annotated-code surface uses its own rail bar).\n * - `AnnotationNoteRail` — the responsive list of note cards with two-way hover.\n * `showMarker` opts the diff block into a leading numbered pip on each card so\n * a note can be matched to its `①`/`②` row marker; annotated-code omits it to\n * keep its original card chrome.\n *\n * `AnnotatedCodeBlock` annotates a single code surface; `DiffBlock` annotates a\n * before/after grid (each annotation also carries a `side`). The shared types\n * here are intentionally minimal — callers pass their own `side` handling and\n * decide which rows a marker lands on; this module only owns the parsing, the\n * resolved-record shape, and the rendered marker + rail chrome.\n */\n\n/* ── Line-ref parsing ──────────────────────────────────────────────────────── */\n\n/**\n * Parse a 1-based `lines` ref (`\"3\"` or `\"3-5\"`) into an inclusive `[start,end]`\n * pair, clamped to `[1, lineCount]`. Returns `null` for malformed or fully\n * out-of-range refs so callers can ignore them gracefully. A reversed range\n * (`\"5-3\"`) is normalized; a partially out-of-range range is clamped.\n */\nexport function parseLineRange(\n ref: string,\n lineCount: number,\n): { start: number; end: number } | null {\n const match = /^\\s*(\\d+)\\s*(?:-\\s*(\\d+)\\s*)?$/.exec(ref);\n if (!match) return null;\n let start = Number.parseInt(match[1], 10);\n let end = match[2] != null ? Number.parseInt(match[2], 10) : start;\n if (!Number.isFinite(start) || !Number.isFinite(end)) return null;\n if (start > end) [start, end] = [end, start];\n // Fully outside the file → ignore.\n if (end < 1 || start > lineCount) return null;\n return { start: Math.max(1, start), end: Math.min(lineCount, end) };\n}\n\n/** The minimal annotation shape the rail needs (a superset works too). */\nexport interface RailAnnotation {\n lines: string;\n label?: string;\n note: string;\n}\n\nexport interface ResolvedAnnotation<A extends RailAnnotation = RailAnnotation> {\n /** Index in the original `annotations` array (stable hover key). */\n index: number;\n /** 1-based marker number (authoring order). */\n marker: number;\n annotation: A;\n range: { start: number; end: number } | null;\n}\n\n/**\n * Resolve a raw annotation list into stable, marker-numbered records, parsing\n * each `lines` ref against `lineCount`. `lineCountFor` lets the diff block pick a\n * per-annotation line count (before-side vs after-side); annotated-code passes a\n * single constant. Markers are authoring-order, 1-based, and assigned to ALL\n * annotations (even unresolved ones) so numbering is stable regardless of which\n * refs happen to match.\n */\nexport function resolveAnnotations<A extends RailAnnotation>(\n annotations: A[] | undefined,\n lineCountFor: (annotation: A) => number,\n): ResolvedAnnotation<A>[] {\n return (annotations ?? []).map((annotation, index) => ({\n index,\n marker: index + 1,\n annotation,\n range: parseLineRange(annotation.lines, lineCountFor(annotation)),\n }));\n}\n\n/** Map a 1-based line number → the resolved annotations covering it. */\nexport function buildLineMarkerMap<A extends RailAnnotation>(\n resolved: ResolvedAnnotation<A>[],\n): Map<number, ResolvedAnnotation<A>[]> {\n const map = new Map<number, ResolvedAnnotation<A>[]>();\n for (const item of resolved) {\n if (!item.range) continue;\n for (let n = item.range.start; n <= item.range.end; n += 1) {\n const list = map.get(n) ?? [];\n list.push(item);\n map.set(n, list);\n }\n }\n return map;\n}\n\n/** Human label for a resolved annotation's line span (\"Line 8\" / \"Lines 3–6\"). */\nexport function rangeLabel(item: ResolvedAnnotation): string {\n if (!item.range) return `Lines ${item.annotation.lines}`;\n return item.range.start === item.range.end\n ? `Line ${item.range.start}`\n : `Lines ${item.range.start}–${item.range.end}`;\n}\n\n/* ── Marker ────────────────────────────────────────────────────────────────── */\n\n/**\n * The numbered amber pip rendered on an annotated code row's gutter. `active`\n * brightens it when its note (or a co-located row) is hovered.\n */\nexport function AnnotationGutterMarker({\n marker,\n active,\n className,\n}: {\n marker: number;\n active: boolean;\n className?: string;\n}) {\n return (\n <span\n aria-hidden\n className={cn(\n \"inline-flex size-[15px] shrink-0 items-center justify-center rounded-full text-[9px] font-semibold leading-none tabular-nums transition-colors\",\n active\n ? \"bg-amber-500 text-white dark:bg-amber-400 dark:text-amber-950\"\n : \"bg-amber-400/25 text-amber-700 dark:bg-amber-300/20 dark:text-amber-300\",\n className,\n )}\n >\n {marker}\n </span>\n );\n}\n\n/* ── Note card ─────────────────────────────────────────────────────────────── */\n\n/**\n * One line-anchored note card: marker pip (when `showMarker`), the resolved line\n * span (\"Line 8\"), an optional label, and the markdown `note` (via\n * `ctx.renderMarkdown`). This is the single source of card markup, rendered both\n * by the visually-hidden a11y/test stack and by the on-hover portal popover.\n */\nexport function AnnotationCard<A extends RailAnnotation>({\n item,\n ctx,\n active = false,\n showMarker = false,\n className,\n onMouseEnter,\n onMouseLeave,\n}: {\n item: ResolvedAnnotation<A>;\n ctx: BlockRenderContext;\n active?: boolean;\n showMarker?: boolean;\n className?: string;\n onMouseEnter?: () => void;\n onMouseLeave?: () => void;\n}) {\n return (\n <div\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n className={cn(\n \"rounded-lg border px-3.5 py-2.5 transition-colors\",\n active\n ? \"border-amber-400/70 bg-amber-50 dark:border-amber-300/40 dark:bg-amber-300/[0.08]\"\n : \"border-plan-line bg-plan-block/40 hover:border-amber-400/50\",\n className,\n )}\n >\n <div\n className={cn(\n \"flex flex-wrap gap-x-2 gap-y-0.5\",\n showMarker ? \"items-center\" : \"items-baseline\",\n )}\n >\n {showMarker && (\n <AnnotationGutterMarker marker={item.marker} active={active} />\n )}\n <span className=\"text-[11px] font-semibold uppercase tracking-wide text-plan-muted\">\n {rangeLabel(item)}\n </span>\n {item.annotation.label && (\n <span className=\"text-[13px] font-semibold text-plan-text\">\n {item.annotation.label}\n </span>\n )}\n </div>\n <div className=\"plan-annotation-note mt-1 text-[13px] leading-relaxed text-plan-text/85\">\n {ctx.renderMarkdown ? (\n ctx.renderMarkdown(item.annotation.note)\n ) : (\n <p>{item.annotation.note}</p>\n )}\n </div>\n </div>\n );\n}\n\n/**\n * Visually-hidden stack of every resolved note. It is NOT a visible column — it\n * sits in the flow but clipped to a 1px box (the `sr-only` pattern) so the note\n * text and the per-card marker pips stay in the accessibility tree and in the\n * DOM (assistive tech can reach them, and tests that read `textContent`/count\n * pips still see them) WITHOUT painting a persistent rail beside the code. The\n * visible card appears only on hover via {@link AnnotationHoverCard}.\n */\nexport function AnnotationHiddenStack<A extends RailAnnotation>({\n items,\n ctx,\n showMarker = false,\n}: {\n items: ResolvedAnnotation<A>[];\n ctx: BlockRenderContext;\n showMarker?: boolean;\n}) {\n const resolved = useMemo(() => items.filter((item) => item.range), [items]);\n if (resolved.length === 0) return null;\n return (\n <div\n className=\"absolute size-px overflow-hidden whitespace-nowrap border-0 p-0 [clip:rect(0,0,0,0)] [clip-path:inset(50%)]\"\n data-annotation-hidden-stack\n >\n {resolved.map((item) => (\n <AnnotationCard\n key={item.index}\n item={item}\n ctx={ctx}\n showMarker={showMarker}\n />\n ))}\n </div>\n );\n}\n\nexport function AnnotationInlineOverlayStack<A extends RailAnnotation>({\n items,\n ctx,\n showMarker = false,\n}: {\n items: ResolvedAnnotation<A>[];\n ctx: BlockRenderContext;\n showMarker?: boolean;\n}) {\n const resolved = items.filter((item) => item.range);\n if (resolved.length === 0) return null;\n return (\n <div\n aria-hidden\n data-annotation-inline-overlay\n className=\"pointer-events-none sticky right-3 z-20 ml-auto h-0 w-0 shrink-0 overflow-visible\"\n >\n <div className=\"absolute right-0 top-1/2 flex w-[min(20rem,45vw)] -translate-y-1/2 flex-col gap-2\">\n {resolved.map((item) => (\n <AnnotationCard\n key={item.index}\n item={item}\n ctx={ctx}\n active\n showMarker={showMarker}\n className=\"border-amber-400/80 bg-amber-50/95 shadow-lg shadow-black/10 dark:border-amber-300/45 dark:bg-amber-300/[0.09] dark:shadow-black/40\"\n />\n ))}\n </div>\n </div>\n );\n}\n\n/* ── Hover popover (portal, anchored beside the code) ──────────────────────── */\n\n/** The geometry the hover card anchors to (in viewport coordinates). */\nexport interface AnnotationAnchor {\n /** Right edge of the code block (where the card should start). */\n codeRight: number;\n /** Left edge of the code block (for the below-fallback alignment). */\n codeLeft: number;\n /** Vertical center of the hovered line. */\n lineCenter: number;\n /** Bottom of the hovered line (for the below-fallback placement). */\n lineBottom: number;\n}\n\nconst HOVER_CARD_WIDTH = 280;\nconst HOVER_CARD_GAP = 12;\nconst VIEWPORT_MARGIN = 8;\nconst SCROLL_HOVER_SUPPRESS_MS = 260;\n\nexport function resolveAnnotationHoverCardPosition(\n anchor: AnnotationAnchor,\n card: { width: number; height: number },\n viewport: { width: number; height: number },\n): { top: number; left: number } {\n const rightLeft = anchor.codeRight + HOVER_CARD_GAP;\n const fitsRight = rightLeft + card.width + VIEWPORT_MARGIN <= viewport.width;\n const leftLeft = anchor.codeLeft - HOVER_CARD_GAP - card.width;\n const fitsLeft = leftLeft >= VIEWPORT_MARGIN;\n\n let left: number;\n let top: number;\n if (fitsRight) {\n // Default: to the right of the code, centered on the hovered line.\n left = rightLeft;\n top = anchor.lineCenter - card.height / 2;\n } else if (fitsLeft) {\n // Prefer the left gutter over covering the code below the hovered line.\n left = leftLeft;\n top = anchor.lineCenter - card.height / 2;\n } else {\n // No clean side gutter → drop below the line, aligned to the code's left.\n left = anchor.codeLeft;\n top = anchor.lineBottom + HOVER_CARD_GAP;\n }\n\n // Clamp within the viewport so the card is never cut off.\n left = Math.max(\n VIEWPORT_MARGIN,\n Math.min(left, viewport.width - card.width - VIEWPORT_MARGIN),\n );\n top = Math.max(\n VIEWPORT_MARGIN,\n Math.min(top, viewport.height - card.height - VIEWPORT_MARGIN),\n );\n\n return { top, left };\n}\n\n/**\n * The single on-hover note card, portaled to `document.body` and positioned\n * `fixed` so it escapes the code block's `overflow` and never reflows the code.\n *\n * Placement: by default it sits to the RIGHT of the code block's right edge,\n * vertically centered on the hovered line — so it never overlaps the code text.\n * If there isn't room to the right, it uses the LEFT of the code block when the\n * card can fit there without covering code. Only when neither side fits does it\n * fall back to BELOW the hovered line (left-aligned to the code block). The card\n * keeps itself open while hovered (`onMouseEnter`/`onMouseLeave` forwarded) so\n * it stays readable; the caller adds the small hover-intent close delay.\n */\nexport function AnnotationHoverCard<A extends RailAnnotation>({\n item,\n anchor,\n ctx,\n showMarker = false,\n onMouseEnter,\n onMouseLeave,\n onClose,\n}: {\n item: ResolvedAnnotation<A>;\n anchor: AnnotationAnchor;\n ctx: BlockRenderContext;\n showMarker?: boolean;\n onMouseEnter?: () => void;\n onMouseLeave?: () => void;\n /** Called when the card should be dismissed (e.g. on scroll). */\n onClose?: () => void;\n}) {\n const cardRef = useRef<HTMLDivElement | null>(null);\n const [pos, setPos] = useState<{ top: number; left: number } | null>(null);\n\n // Measure the rendered card, then resolve a non-overlapping position: right of\n // the code if it fits, then left if that side has a clean gutter, otherwise\n // below the line.\n useLayoutEffect(() => {\n if (typeof window === \"undefined\") return;\n const el = cardRef.current;\n const rect = el?.getBoundingClientRect();\n const width = rect && rect.width > 0 ? rect.width : HOVER_CARD_WIDTH;\n const height = rect && rect.height > 0 ? rect.height : 0;\n const vw = window.innerWidth || 0;\n const vh = window.innerHeight || 0;\n setPos(\n resolveAnnotationHoverCardPosition(\n anchor,\n { width, height },\n { width: vw, height: vh },\n ),\n );\n }, [\n anchor.codeRight,\n anchor.codeLeft,\n anchor.lineCenter,\n anchor.lineBottom,\n item.index,\n ]);\n\n // Close the card when the user scrolls so it doesn't float detached. Scrolls\n // inside a long hover card are local to the card and should not dismiss it.\n useEffect(() => {\n if (!onClose || typeof window === \"undefined\") return;\n const handler = (event: Event) => {\n const target = event.target;\n if (\n target instanceof Node &&\n cardRef.current &&\n cardRef.current.contains(target)\n ) {\n return;\n }\n onClose();\n };\n window.addEventListener(\"scroll\", handler, {\n capture: true,\n passive: true,\n });\n return () =>\n window.removeEventListener(\"scroll\", handler, { capture: true });\n }, [onClose]);\n\n if (typeof document === \"undefined\") return null;\n\n return createPortal(\n <div\n ref={cardRef}\n role=\"tooltip\"\n data-annotation-hover-card\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n className=\"pointer-events-auto fixed z-50 overflow-y-auto overscroll-contain\"\n style={{\n top: pos?.top ?? anchor.lineCenter,\n left: pos?.left ?? anchor.codeRight + HOVER_CARD_GAP,\n width: HOVER_CARD_WIDTH,\n maxHeight: `calc(100vh - ${VIEWPORT_MARGIN * 2}px)`,\n // Hide until measured to avoid a one-frame jump from the fallback spot.\n visibility: pos ? \"visible\" : \"hidden\",\n }}\n >\n <AnnotationCard\n item={item}\n ctx={ctx}\n active\n showMarker={showMarker}\n className=\"shadow-lg shadow-black/10 dark:shadow-black/40\"\n />\n </div>,\n document.body,\n );\n}\n\n/**\n * Hover-intent + tap controller for the on-hover note card. Exposes\n * `activeIndex` + the captured `anchor`, plus `open`/`toggle`/`close`/\n * `scheduleClose`/`cancelClose` handlers.\n *\n * - `open(index, anchor)` shows a card immediately (cancels any pending close).\n * - `toggle(index, anchor)` opens a card if it isn't already the active one,\n * or closes it if it is — used for click/tap on annotated rows so touch users\n * can access notes without hover.\n * - `close()` hides the card immediately (used on scroll to avoid stale cards).\n * - `scheduleClose()` hides after a short delay, so moving the pointer from the\n * code line across the gap into the card itself keeps it open.\n * - `cancelClose()` (call on card mouse-enter) keeps it open while reading.\n */\nexport function useAnnotationHover(delay = 130) {\n const [active, setActive] = useState<{\n index: number;\n anchor: AnnotationAnchor;\n } | null>(null);\n const timer = useRef<ReturnType<typeof setTimeout> | null>(null);\n const suppressHoverUntil = useRef(0);\n\n const cancelClose = () => {\n if (timer.current) {\n clearTimeout(timer.current);\n timer.current = null;\n }\n };\n const open = (index: number, anchor: AnnotationAnchor) => {\n if (Date.now() < suppressHoverUntil.current) return;\n cancelClose();\n setActive({ index, anchor });\n };\n const toggle = (index: number, anchor: AnnotationAnchor) => {\n cancelClose();\n setActive((prev) => (prev?.index === index ? null : { index, anchor }));\n };\n const close = () => {\n cancelClose();\n setActive(null);\n };\n const closeForScroll = () => {\n suppressHoverUntil.current = Date.now() + SCROLL_HOVER_SUPPRESS_MS;\n close();\n };\n const scheduleClose = () => {\n cancelClose();\n timer.current = setTimeout(() => setActive(null), delay);\n };\n\n useEffect(() => () => cancelClose(), []);\n\n return {\n activeIndex: active?.index ?? null,\n anchor: active?.anchor ?? null,\n open,\n toggle,\n close,\n closeForScroll,\n scheduleClose,\n cancelClose,\n } as const;\n}\n\n/**\n * Build an {@link AnnotationAnchor} from the code block element and the hovered\n * row element. The card anchors to the code block's RIGHT edge and the row's\n * vertical center, both in viewport coordinates (so a `fixed` portal lines up).\n */\nexport function anchorFromElements(\n codeEl: HTMLElement | null,\n rowEl: HTMLElement | null,\n): AnnotationAnchor | null {\n if (!codeEl || !rowEl) return null;\n const code = codeEl.getBoundingClientRect();\n const row = rowEl.getBoundingClientRect();\n return {\n codeRight: code.right,\n codeLeft: code.left,\n lineCenter: row.top + row.height / 2,\n lineBottom: row.bottom,\n };\n}\n\n/**\n * The responsive list of line-anchored note cards. Each card shows its marker\n * pip, the resolved line span (\"Line 8\"), an optional label, and the markdown\n * `note` (via `ctx.renderMarkdown`). Hovering a card sets the active index;\n * `activeIndex` driven from outside lets a hovered code row light its card and\n * vice-versa. Only annotations whose `range` resolved are listed.\n *\n * @deprecated Superseded by the on-hover {@link AnnotationHoverCard}; kept for\n * back-compat with any external importer. Both block read renderers now use the\n * hover popover anchored to the right of the code instead of a persistent rail.\n */\nexport function AnnotationNoteRail<A extends RailAnnotation>({\n items,\n activeIndex,\n onActiveChange,\n ctx,\n className,\n showMarker = false,\n}: {\n items: ResolvedAnnotation<A>[];\n activeIndex: number | null;\n onActiveChange: (index: number | null) => void;\n ctx: BlockRenderContext;\n className?: string;\n /** Show a leading numbered pip on each card (diff block). */\n showMarker?: boolean;\n}) {\n const sideAnnotations = useMemo(\n () => items.filter((item) => item.range),\n [items],\n );\n return (\n <div className={cn(\"flex flex-col gap-2.5\", className)}>\n {sideAnnotations.map((item) => (\n <AnnotationCard\n key={item.index}\n item={item}\n ctx={ctx}\n active={activeIndex === item.index}\n showMarker={showMarker}\n onMouseEnter={() => onActiveChange(item.index)}\n onMouseLeave={() => onActiveChange(null)}\n />\n ))}\n </div>\n );\n}\n\n/** Whether a resolved list has at least one note worth rendering a rail for. */\nexport function hasRailAnnotations(items: ResolvedAnnotation[]): boolean {\n return items.some((item) => item.range);\n}\n\nexport type AnnotationRailChildren = ReactNode;\n"]}
1
+ {"version":3,"file":"annotation-rail.js","sourceRoot":"","sources":["../../../../src/client/blocks/library/annotation-rail.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,SAAS,EACT,eAAe,EACf,OAAO,EACP,MAAM,EACN,QAAQ,GAET,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAGpC;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,kFAAkF;AAElF;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAC5B,GAAW,EACX,SAAiB;IAEjB,MAAM,KAAK,GAAG,gCAAgC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACzD,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IACxB,IAAI,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC1C,IAAI,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IACnE,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IAClE,IAAI,KAAK,GAAG,GAAG;QAAE,CAAC,KAAK,EAAE,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAC7C,mCAAmC;IACnC,IAAI,GAAG,GAAG,CAAC,IAAI,KAAK,GAAG,SAAS;QAAE,OAAO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AC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC1C,CAAC","sourcesContent":["import {\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n type ReactNode,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { cn } from \"../../utils.js\";\nimport type { BlockRenderContext } from \"../types.js\";\n\n/**\n * Shared line-anchored annotation UI for the `annotated-code` and `diff` blocks.\n *\n * Both blocks render a numbered code surface plus a side \"rail\" of notes, where\n * each note targets a 1-based `lines` ref (`\"3\"` or `\"3-5\"`) and hovering a code\n * line ↔ its note cross-highlights. This module owns the pure pieces that were\n * identical between them so neither block forks the behavior:\n *\n * - `parseLineRange` — the forgiving 1-based `lines` range parser.\n * - `resolveAnnotations` / `buildLineMarkerMap` — turn a raw annotation list\n * into stable, marker-numbered, range-resolved records and a line→markers map.\n * - `rangeLabel` — the human \"Line 8\" / \"Lines 3–6\" label.\n * - `AnnotationGutterMarker` — the numbered amber pip placed on an annotated row\n * (used by the diff grid; the annotated-code surface uses its own rail bar).\n * - `AnnotationNoteRail` — the responsive list of note cards with two-way hover.\n * `showMarker` opts the diff block into a leading numbered pip on each card so\n * a note can be matched to its `①`/`②` row marker; annotated-code omits it to\n * keep its original card chrome.\n *\n * `AnnotatedCodeBlock` annotates a single code surface; `DiffBlock` annotates a\n * before/after grid (each annotation also carries a `side`). The shared types\n * here are intentionally minimal — callers pass their own `side` handling and\n * decide which rows a marker lands on; this module only owns the parsing, the\n * resolved-record shape, and the rendered marker + rail chrome.\n */\n\n/* ── Line-ref parsing ──────────────────────────────────────────────────────── */\n\n/**\n * Parse a 1-based `lines` ref (`\"3\"` or `\"3-5\"`) into an inclusive `[start,end]`\n * pair, clamped to `[1, lineCount]`. Returns `null` for malformed or fully\n * out-of-range refs so callers can ignore them gracefully. A reversed range\n * (`\"5-3\"`) is normalized; a partially out-of-range range is clamped.\n */\nexport function parseLineRange(\n ref: string,\n lineCount: number,\n): { start: number; end: number } | null {\n const match = /^\\s*(\\d+)\\s*(?:-\\s*(\\d+)\\s*)?$/.exec(ref);\n if (!match) return null;\n let start = Number.parseInt(match[1], 10);\n let end = match[2] != null ? Number.parseInt(match[2], 10) : start;\n if (!Number.isFinite(start) || !Number.isFinite(end)) return null;\n if (start > end) [start, end] = [end, start];\n // Fully outside the file → ignore.\n if (end < 1 || start > lineCount) return null;\n return { start: Math.max(1, start), end: Math.min(lineCount, end) };\n}\n\n/** The minimal annotation shape the rail needs (a superset works too). */\nexport interface RailAnnotation {\n lines: string;\n label?: string;\n note: string;\n}\n\nexport interface ResolvedAnnotation<A extends RailAnnotation = RailAnnotation> {\n /** Index in the original `annotations` array (stable hover key). */\n index: number;\n /** 1-based marker number (authoring order). */\n marker: number;\n annotation: A;\n range: { start: number; end: number } | null;\n}\n\n/**\n * Resolve a raw annotation list into stable, marker-numbered records, parsing\n * each `lines` ref against `lineCount`. `lineCountFor` lets the diff block pick a\n * per-annotation line count (before-side vs after-side); annotated-code passes a\n * single constant. Markers are authoring-order, 1-based, and assigned to ALL\n * annotations (even unresolved ones) so numbering is stable regardless of which\n * refs happen to match.\n */\nexport function resolveAnnotations<A extends RailAnnotation>(\n annotations: A[] | undefined,\n lineCountFor: (annotation: A) => number,\n): ResolvedAnnotation<A>[] {\n return (annotations ?? []).map((annotation, index) => ({\n index,\n marker: index + 1,\n annotation,\n range: parseLineRange(annotation.lines, lineCountFor(annotation)),\n }));\n}\n\n/** Map a 1-based line number → the resolved annotations covering it. */\nexport function buildLineMarkerMap<A extends RailAnnotation>(\n resolved: ResolvedAnnotation<A>[],\n): Map<number, ResolvedAnnotation<A>[]> {\n const map = new Map<number, ResolvedAnnotation<A>[]>();\n for (const item of resolved) {\n if (!item.range) continue;\n for (let n = item.range.start; n <= item.range.end; n += 1) {\n const list = map.get(n) ?? [];\n list.push(item);\n map.set(n, list);\n }\n }\n return map;\n}\n\n/** Human label for a resolved annotation's line span (\"Line 8\" / \"Lines 3–6\"). */\nexport function rangeLabel(item: ResolvedAnnotation): string {\n if (!item.range) return `Lines ${item.annotation.lines}`;\n return item.range.start === item.range.end\n ? `Line ${item.range.start}`\n : `Lines ${item.range.start}–${item.range.end}`;\n}\n\n/* ── Marker ────────────────────────────────────────────────────────────────── */\n\n/**\n * The numbered amber pip rendered on an annotated code row's gutter. `active`\n * brightens it when its note (or a co-located row) is hovered.\n */\nexport function AnnotationGutterMarker({\n marker,\n active,\n className,\n}: {\n marker: number;\n active: boolean;\n className?: string;\n}) {\n return (\n <span\n aria-hidden\n className={cn(\n \"inline-flex size-[15px] shrink-0 items-center justify-center rounded-full text-[9px] font-semibold leading-none tabular-nums transition-colors\",\n active\n ? \"bg-amber-500 text-white dark:bg-amber-400 dark:text-amber-950\"\n : \"bg-amber-400/25 text-amber-700 dark:bg-amber-300/20 dark:text-amber-300\",\n className,\n )}\n >\n {marker}\n </span>\n );\n}\n\n/* ── Note card ─────────────────────────────────────────────────────────────── */\n\n/**\n * One line-anchored note card: marker pip (when `showMarker`), the resolved line\n * span (\"Line 8\"), an optional label, and the markdown `note` (via\n * `ctx.renderMarkdown`). This is the single source of card markup, rendered both\n * by the visually-hidden a11y/test stack and by the on-hover portal popover.\n */\nexport function AnnotationCard<A extends RailAnnotation>({\n item,\n ctx,\n active = false,\n showMarker = false,\n className,\n onMouseEnter,\n onMouseLeave,\n}: {\n item: ResolvedAnnotation<A>;\n ctx: BlockRenderContext;\n active?: boolean;\n showMarker?: boolean;\n className?: string;\n onMouseEnter?: () => void;\n onMouseLeave?: () => void;\n}) {\n return (\n <div\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n className={cn(\n \"rounded-lg border px-3.5 py-2.5 transition-colors\",\n active\n ? \"border-amber-400/70 bg-amber-50 dark:border-amber-300/40 dark:bg-amber-300/[0.08]\"\n : \"border-plan-line bg-plan-block/40 hover:border-amber-400/50\",\n className,\n )}\n >\n <div\n className={cn(\n \"flex flex-wrap gap-x-2 gap-y-0.5\",\n showMarker ? \"items-center\" : \"items-baseline\",\n )}\n >\n {showMarker && (\n <AnnotationGutterMarker marker={item.marker} active={active} />\n )}\n <span className=\"text-[11px] font-semibold uppercase tracking-wide text-plan-muted\">\n {rangeLabel(item)}\n </span>\n {item.annotation.label && (\n <span className=\"text-[13px] font-semibold text-plan-text\">\n {item.annotation.label}\n </span>\n )}\n </div>\n <div className=\"plan-annotation-note mt-1 text-[13px] leading-relaxed text-plan-text/85\">\n {ctx.renderMarkdown ? (\n ctx.renderMarkdown(item.annotation.note)\n ) : (\n <p>{item.annotation.note}</p>\n )}\n </div>\n </div>\n );\n}\n\n/**\n * Visually-hidden stack of every resolved note. It is NOT a visible column — it\n * sits in the flow but clipped to a 1px box (the `sr-only` pattern) so the note\n * text and the per-card marker pips stay in the accessibility tree and in the\n * DOM (assistive tech can reach them, and tests that read `textContent`/count\n * pips still see them) WITHOUT painting a persistent rail beside the code. The\n * visible card appears only on hover via {@link AnnotationHoverCard}.\n */\nexport function AnnotationHiddenStack<A extends RailAnnotation>({\n items,\n ctx,\n showMarker = false,\n}: {\n items: ResolvedAnnotation<A>[];\n ctx: BlockRenderContext;\n showMarker?: boolean;\n}) {\n const resolved = useMemo(() => items.filter((item) => item.range), [items]);\n if (resolved.length === 0) return null;\n return (\n <div\n className=\"absolute size-px overflow-hidden whitespace-nowrap border-0 p-0 [clip:rect(0,0,0,0)] [clip-path:inset(50%)]\"\n data-annotation-hidden-stack\n >\n {resolved.map((item) => (\n <AnnotationCard\n key={item.index}\n item={item}\n ctx={ctx}\n showMarker={showMarker}\n />\n ))}\n </div>\n );\n}\n\nexport function AnnotationInlineOverlayStack<A extends RailAnnotation>({\n items,\n ctx,\n showMarker = false,\n}: {\n items: ResolvedAnnotation<A>[];\n ctx: BlockRenderContext;\n showMarker?: boolean;\n}) {\n const resolved = items.filter((item) => item.range);\n const anchorRef = useRef<HTMLDivElement | null>(null);\n const portalRef = useRef<HTMLDivElement | null>(null);\n const [position, setPosition] = useState<{\n top: number;\n right: number;\n } | null>(null);\n const positionKey = resolved\n .map(\n (item) =>\n `${item.index}:${item.marker}:${item.annotation.lines}:${item.annotation.label ?? \"\"}:${item.annotation.note}`,\n )\n .join(\"|\");\n\n useLayoutEffect(() => {\n if (typeof window === \"undefined\") return;\n const anchor = anchorRef.current;\n if (!anchor) return;\n\n let frame: number | null = null;\n const updatePosition = () => {\n const anchorRect = anchor.getBoundingClientRect();\n const portalRect = portalRef.current?.getBoundingClientRect();\n const viewportWidth = Math.max(\n window.innerWidth || 0,\n INLINE_OVERLAY_WIDTH + VIEWPORT_MARGIN * 2,\n );\n const viewportHeight = Math.max(\n window.innerHeight || 0,\n VIEWPORT_MARGIN * 2,\n );\n const width =\n portalRect && portalRect.width > 0\n ? portalRect.width\n : Math.min(INLINE_OVERLAY_WIDTH, viewportWidth * 0.45);\n const height =\n portalRect && portalRect.height > 0 ? portalRect.height : 0;\n setPosition(\n resolveAnnotationInlineOverlayPosition(\n {\n right: anchorRect.right,\n top: anchorRect.top,\n height: anchorRect.height,\n },\n { width, height },\n { width: viewportWidth, height: viewportHeight },\n ),\n );\n };\n\n updatePosition();\n if (typeof window.requestAnimationFrame === \"function\") {\n frame = window.requestAnimationFrame(updatePosition);\n }\n window.addEventListener(\"resize\", updatePosition);\n window.addEventListener(\"scroll\", updatePosition, {\n capture: true,\n passive: true,\n });\n return () => {\n if (frame != null && typeof window.cancelAnimationFrame === \"function\") {\n window.cancelAnimationFrame(frame);\n }\n window.removeEventListener(\"resize\", updatePosition);\n window.removeEventListener(\"scroll\", updatePosition, { capture: true });\n };\n }, [positionKey]);\n\n if (resolved.length === 0) return null;\n\n const portal =\n typeof document === \"undefined\"\n ? null\n : createPortal(\n <div\n aria-hidden\n ref={portalRef}\n data-annotation-inline-overlay\n className=\"pointer-events-none fixed z-50 flex w-[min(20rem,45vw)] flex-col gap-2\"\n style={{\n top: position?.top ?? VIEWPORT_MARGIN,\n right: position?.right ?? VIEWPORT_MARGIN,\n visibility: position ? \"visible\" : \"hidden\",\n }}\n >\n {resolved.map((item) => (\n <AnnotationCard\n key={item.index}\n item={item}\n ctx={ctx}\n active\n showMarker={showMarker}\n className=\"border-amber-400/80 bg-amber-50/95 shadow-lg shadow-black/10 dark:border-amber-300/45 dark:bg-amber-300/[0.09] dark:shadow-black/40\"\n />\n ))}\n </div>,\n document.body,\n );\n\n return (\n <>\n <div\n aria-hidden\n ref={anchorRef}\n data-annotation-inline-overlay-anchor\n className=\"pointer-events-none sticky right-3 z-20 ml-auto h-0 w-0 shrink-0 overflow-visible\"\n />\n {portal}\n </>\n );\n}\n\n/* ── Hover popover (portal, anchored beside the code) ──────────────────────── */\n\n/** The geometry the hover card anchors to (in viewport coordinates). */\nexport interface AnnotationAnchor {\n /** Right edge of the code block (where the card should start). */\n codeRight: number;\n /** Left edge of the code block (for the below-fallback alignment). */\n codeLeft: number;\n /** Vertical center of the hovered line. */\n lineCenter: number;\n /** Bottom of the hovered line (for the below-fallback placement). */\n lineBottom: number;\n}\n\nconst HOVER_CARD_WIDTH = 280;\nconst INLINE_OVERLAY_WIDTH = 320;\nconst HOVER_CARD_GAP = 12;\nconst VIEWPORT_MARGIN = 8;\nconst SCROLL_HOVER_SUPPRESS_MS = 260;\n\nexport function resolveAnnotationInlineOverlayPosition(\n anchor: { right: number; top: number; height: number },\n card: { width: number; height: number },\n viewport: { width: number; height: number },\n): { top: number; right: number } {\n const maxTop = Math.max(\n VIEWPORT_MARGIN,\n viewport.height - card.height - VIEWPORT_MARGIN,\n );\n const centeredTop = anchor.top + anchor.height / 2 - card.height / 2;\n const maxRight = Math.max(\n VIEWPORT_MARGIN,\n viewport.width - card.width - VIEWPORT_MARGIN,\n );\n\n return {\n top: Math.max(VIEWPORT_MARGIN, Math.min(centeredTop, maxTop)),\n right: Math.max(\n VIEWPORT_MARGIN,\n Math.min(viewport.width - anchor.right, maxRight),\n ),\n };\n}\n\nexport function resolveAnnotationHoverCardPosition(\n anchor: AnnotationAnchor,\n card: { width: number; height: number },\n viewport: { width: number; height: number },\n): { top: number; left: number } {\n const rightLeft = anchor.codeRight + HOVER_CARD_GAP;\n const fitsRight = rightLeft + card.width + VIEWPORT_MARGIN <= viewport.width;\n const leftLeft = anchor.codeLeft - HOVER_CARD_GAP - card.width;\n const fitsLeft = leftLeft >= VIEWPORT_MARGIN;\n\n let left: number;\n let top: number;\n if (fitsRight) {\n // Default: to the right of the code, centered on the hovered line.\n left = rightLeft;\n top = anchor.lineCenter - card.height / 2;\n } else if (fitsLeft) {\n // Prefer the left gutter over covering the code below the hovered line.\n left = leftLeft;\n top = anchor.lineCenter - card.height / 2;\n } else {\n // No clean side gutter → drop below the line, aligned to the code's left.\n left = anchor.codeLeft;\n top = anchor.lineBottom + HOVER_CARD_GAP;\n }\n\n // Clamp within the viewport so the card is never cut off.\n left = Math.max(\n VIEWPORT_MARGIN,\n Math.min(left, viewport.width - card.width - VIEWPORT_MARGIN),\n );\n top = Math.max(\n VIEWPORT_MARGIN,\n Math.min(top, viewport.height - card.height - VIEWPORT_MARGIN),\n );\n\n return { top, left };\n}\n\n/**\n * The single on-hover note card, portaled to `document.body` and positioned\n * `fixed` so it escapes the code block's `overflow` and never reflows the code.\n *\n * Placement: by default it sits to the RIGHT of the code block's right edge,\n * vertically centered on the hovered line — so it never overlaps the code text.\n * If there isn't room to the right, it uses the LEFT of the code block when the\n * card can fit there without covering code. Only when neither side fits does it\n * fall back to BELOW the hovered line (left-aligned to the code block). The card\n * keeps itself open while hovered (`onMouseEnter`/`onMouseLeave` forwarded) so\n * it stays readable; the caller adds the small hover-intent close delay.\n */\nexport function AnnotationHoverCard<A extends RailAnnotation>({\n item,\n anchor,\n ctx,\n showMarker = false,\n onMouseEnter,\n onMouseLeave,\n onClose,\n}: {\n item: ResolvedAnnotation<A>;\n anchor: AnnotationAnchor;\n ctx: BlockRenderContext;\n showMarker?: boolean;\n onMouseEnter?: () => void;\n onMouseLeave?: () => void;\n /** Called when the card should be dismissed (e.g. on scroll). */\n onClose?: () => void;\n}) {\n const cardRef = useRef<HTMLDivElement | null>(null);\n const [pos, setPos] = useState<{ top: number; left: number } | null>(null);\n\n // Measure the rendered card, then resolve a non-overlapping position: right of\n // the code if it fits, then left if that side has a clean gutter, otherwise\n // below the line.\n useLayoutEffect(() => {\n if (typeof window === \"undefined\") return;\n const el = cardRef.current;\n const rect = el?.getBoundingClientRect();\n const width = rect && rect.width > 0 ? rect.width : HOVER_CARD_WIDTH;\n const height = rect && rect.height > 0 ? rect.height : 0;\n const vw = window.innerWidth || 0;\n const vh = window.innerHeight || 0;\n setPos(\n resolveAnnotationHoverCardPosition(\n anchor,\n { width, height },\n { width: vw, height: vh },\n ),\n );\n }, [\n anchor.codeRight,\n anchor.codeLeft,\n anchor.lineCenter,\n anchor.lineBottom,\n item.index,\n ]);\n\n // Close the card when the user scrolls so it doesn't float detached. Scrolls\n // inside a long hover card are local to the card and should not dismiss it.\n useEffect(() => {\n if (!onClose || typeof window === \"undefined\") return;\n const handler = (event: Event) => {\n const target = event.target;\n if (\n target instanceof Node &&\n cardRef.current &&\n cardRef.current.contains(target)\n ) {\n return;\n }\n onClose();\n };\n window.addEventListener(\"scroll\", handler, {\n capture: true,\n passive: true,\n });\n return () =>\n window.removeEventListener(\"scroll\", handler, { capture: true });\n }, [onClose]);\n\n if (typeof document === \"undefined\") return null;\n\n return createPortal(\n <div\n ref={cardRef}\n role=\"tooltip\"\n data-annotation-hover-card\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n className=\"pointer-events-auto fixed z-50 overflow-y-auto overscroll-contain\"\n style={{\n top: pos?.top ?? anchor.lineCenter,\n left: pos?.left ?? anchor.codeRight + HOVER_CARD_GAP,\n width: HOVER_CARD_WIDTH,\n maxHeight: `calc(100vh - ${VIEWPORT_MARGIN * 2}px)`,\n // Hide until measured to avoid a one-frame jump from the fallback spot.\n visibility: pos ? \"visible\" : \"hidden\",\n }}\n >\n <AnnotationCard\n item={item}\n ctx={ctx}\n active\n showMarker={showMarker}\n className=\"shadow-lg shadow-black/10 dark:shadow-black/40\"\n />\n </div>,\n document.body,\n );\n}\n\n/**\n * Hover-intent + tap controller for the on-hover note card. Exposes\n * `activeIndex` + the captured `anchor`, plus `open`/`toggle`/`close`/\n * `scheduleClose`/`cancelClose` handlers.\n *\n * - `open(index, anchor)` shows a card immediately (cancels any pending close).\n * - `toggle(index, anchor)` opens a card if it isn't already the active one,\n * or closes it if it is — used for click/tap on annotated rows so touch users\n * can access notes without hover.\n * - `close()` hides the card immediately (used on scroll to avoid stale cards).\n * - `scheduleClose()` hides after a short delay, so moving the pointer from the\n * code line across the gap into the card itself keeps it open.\n * - `cancelClose()` (call on card mouse-enter) keeps it open while reading.\n */\nexport function useAnnotationHover(delay = 130) {\n const [active, setActive] = useState<{\n index: number;\n anchor: AnnotationAnchor;\n } | null>(null);\n const timer = useRef<ReturnType<typeof setTimeout> | null>(null);\n const suppressHoverUntil = useRef(0);\n\n const cancelClose = () => {\n if (timer.current) {\n clearTimeout(timer.current);\n timer.current = null;\n }\n };\n const open = (index: number, anchor: AnnotationAnchor) => {\n if (Date.now() < suppressHoverUntil.current) return;\n cancelClose();\n setActive({ index, anchor });\n };\n const toggle = (index: number, anchor: AnnotationAnchor) => {\n cancelClose();\n setActive((prev) => (prev?.index === index ? null : { index, anchor }));\n };\n const close = () => {\n cancelClose();\n setActive(null);\n };\n const closeForScroll = () => {\n suppressHoverUntil.current = Date.now() + SCROLL_HOVER_SUPPRESS_MS;\n close();\n };\n const scheduleClose = () => {\n cancelClose();\n timer.current = setTimeout(() => setActive(null), delay);\n };\n\n useEffect(() => () => cancelClose(), []);\n\n return {\n activeIndex: active?.index ?? null,\n anchor: active?.anchor ?? null,\n open,\n toggle,\n close,\n closeForScroll,\n scheduleClose,\n cancelClose,\n } as const;\n}\n\n/**\n * Build an {@link AnnotationAnchor} from the code block element and the hovered\n * row element. The card anchors to the code block's RIGHT edge and the row's\n * vertical center, both in viewport coordinates (so a `fixed` portal lines up).\n */\nexport function anchorFromElements(\n codeEl: HTMLElement | null,\n rowEl: HTMLElement | null,\n): AnnotationAnchor | null {\n if (!codeEl || !rowEl) return null;\n const code = codeEl.getBoundingClientRect();\n const row = rowEl.getBoundingClientRect();\n return {\n codeRight: code.right,\n codeLeft: code.left,\n lineCenter: row.top + row.height / 2,\n lineBottom: row.bottom,\n };\n}\n\n/**\n * The responsive list of line-anchored note cards. Each card shows its marker\n * pip, the resolved line span (\"Line 8\"), an optional label, and the markdown\n * `note` (via `ctx.renderMarkdown`). Hovering a card sets the active index;\n * `activeIndex` driven from outside lets a hovered code row light its card and\n * vice-versa. Only annotations whose `range` resolved are listed.\n *\n * @deprecated Superseded by the on-hover {@link AnnotationHoverCard}; kept for\n * back-compat with any external importer. Both block read renderers now use the\n * hover popover anchored to the right of the code instead of a persistent rail.\n */\nexport function AnnotationNoteRail<A extends RailAnnotation>({\n items,\n activeIndex,\n onActiveChange,\n ctx,\n className,\n showMarker = false,\n}: {\n items: ResolvedAnnotation<A>[];\n activeIndex: number | null;\n onActiveChange: (index: number | null) => void;\n ctx: BlockRenderContext;\n className?: string;\n /** Show a leading numbered pip on each card (diff block). */\n showMarker?: boolean;\n}) {\n const sideAnnotations = useMemo(\n () => items.filter((item) => item.range),\n [items],\n );\n return (\n <div className={cn(\"flex flex-col gap-2.5\", className)}>\n {sideAnnotations.map((item) => (\n <AnnotationCard\n key={item.index}\n item={item}\n ctx={ctx}\n active={activeIndex === item.index}\n showMarker={showMarker}\n onMouseEnter={() => onActiveChange(item.index)}\n onMouseLeave={() => onActiveChange(null)}\n />\n ))}\n </div>\n );\n}\n\n/** Whether a resolved list has at least one note worth rendering a rail for. */\nexport function hasRailAnnotations(items: ResolvedAnnotation[]): boolean {\n return items.some((item) => item.range);\n}\n\nexport type AnnotationRailChildren = ReactNode;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"use-chat-models.d.ts","sourceRoot":"","sources":["../../src/client/use-chat-models.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,KAAK,eAAe,EACrB,MA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MAAM,CAAC;IACvB,cAAc,EAAE,eAAe,CAAC;IAChC,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACvD,cAAc,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,IAAI,CAAC;IAClD,cAAc,EAAE,MAAM,IAAI,CAAC;CAC5B;AAED,UAAU,OAAO;IACf;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AA2BD;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,EAC5B,UAAgC,EAChC,OAAc,GACf,GAAE,OAAY,GAAG,mBAAmB,CAoQpC"}
@@ -144,11 +144,6 @@ export function useChatModels({ storageKey = DEFAULT_STORAGE_KEY, enabled = true
144
144
  ]
145
145
  : []),
146
146
  ];
147
- if (currentModel && !builderModels.includes(currentModel)) {
148
- const firstGroup = groups[0];
149
- if (firstGroup)
150
- firstGroup.models.unshift(currentModel);
151
- }
152
147
  }
153
148
  else {
154
149
  const allowedEngines = new Set([
@@ -1 +1 @@
1
- {"version":3,"file":"use-chat-models.js","sourceRoot":"","sources":["../../src/client/use-chat-models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EACL,iCAAiC,GAElC,MAAM,+BAA+B,CAAC;AAiCvC,MAAM,mBAAmB,GAAG,oCAAoC,CAAC;AAQjE,SAAS,aAAa,CAAC,GAAkB;IACvC,IAAI,CAAC,GAAG,IAAI,OAAO,MAAM,KAAK,WAAW;QAAE,OAAO,EAAE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1B,CAAC,CAAC,MAAM,CAAC;gBACb,gBAAgB,CAAC,SAAS,CAAC,CAAC;gBAC5B,iBAAiB,CAAC,UAAU,CAAC,CAAC;gBAC9B,iBAAiB,CAAC,UAAU,CAAC,CAAC;gBAC9B,cAAc,CAAC,UAAU,EAAE;oBACzB,KAAK,EAAE,SAAS;oBAChB,MAAM,EAAE,UAAU;oBAClB,MAAM,EAAE,UAAU;iBACnB,CAAC,CAAC;YACL,CAAC;QACH,CAAC,CAAC;aACD,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IACrB,CAAC,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC;IAE1B,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,OAAO;YAAE,OAAO;QACrB,cAAc,EAAE,CAAC;IACnB,CAAC,EAAE,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC;IAE9B,OAAO;QACL,eAAe;QACf,YAAY;QACZ,aAAa;QACb,cAAc;QACd,cAAc;QACd,aAAa;QACb,cAAc;QACd,cAAc;KACf,CAAC;AACJ,CAAC","sourcesContent":["import { useCallback, useEffect, useRef, useState } from \"react\";\nimport { agentNativePath } from \"./api-path.js\";\nimport { callAction } from \"./use-action.js\";\nimport { DEFAULT_MODEL } from \"../agent/default-model.js\";\nimport {\n getReasoningEffortOptionsForModel,\n type ReasoningEffort,\n} from \"../shared/reasoning-effort.js\";\n\nexport interface EngineModelGroup {\n engine: string;\n label: string;\n models: string[];\n configured: boolean;\n}\n\nexport interface UseChatModelsResult {\n availableModels: EngineModelGroup[];\n defaultModel: string;\n selectedModel: string;\n selectedEngine: string;\n selectedEffort: ReasoningEffort;\n onModelChange: (model: string, engine: string) => void;\n onEffortChange: (effort: ReasoningEffort) => void;\n refreshEngines: () => void;\n}\n\ninterface Options {\n /**\n * localStorage key used to persist the user's model + effort selection across\n * page loads. Pass `null` to disable persistence.\n */\n storageKey?: string | null;\n /**\n * Disable server-backed model discovery for hosts that provide their own\n * model list/state, such as Electron Code.\n */\n enabled?: boolean;\n}\n\nconst DEFAULT_STORAGE_KEY = \"agent-native:chat-models:selection\";\n\ninterface PersistedSelection {\n model?: string;\n engine?: string;\n effort?: ReasoningEffort;\n}\n\nfunction readPersisted(key: string | null): PersistedSelection {\n if (!key || typeof window === \"undefined\") return {};\n try {\n const raw = window.localStorage.getItem(key);\n return raw ? (JSON.parse(raw) as PersistedSelection) : {};\n } catch {\n return {};\n }\n}\n\nfunction writePersisted(key: string | null, value: PersistedSelection) {\n if (!key || typeof window === \"undefined\") return;\n try {\n window.localStorage.setItem(key, JSON.stringify(value));\n } catch {}\n}\n\n/**\n * Fetches available engines/models from the agent server and exposes the same\n * model picker state that `MultiTabAssistantChat` wires up — for surfaces like\n * the Dispatch homepage hero composer that need an identical model picker\n * without mounting the full tabbed chat.\n */\nexport function useChatModels({\n storageKey = DEFAULT_STORAGE_KEY,\n enabled = true,\n}: Options = {}): UseChatModelsResult {\n const [availableModels, setAvailableModels] = useState<EngineModelGroup[]>(\n [],\n );\n const [defaultModel, setDefaultModel] = useState<string>(DEFAULT_MODEL);\n\n const initialPersisted = readPersisted(storageKey);\n const hasExplicitSelectionRef = useRef(Boolean(initialPersisted.model));\n const [selectedModel, setSelectedModel] = useState<string>(\n initialPersisted.model ?? DEFAULT_MODEL,\n );\n const [selectedEngine, setSelectedEngine] = useState<string>(\n initialPersisted.engine ?? \"\",\n );\n const [selectedEffort, setSelectedEffort] = useState<ReasoningEffort>(\n initialPersisted.effort ?? \"auto\",\n );\n const selectionRef = useRef({\n selectedModel,\n selectedEngine,\n selectedEffort,\n });\n\n useEffect(() => {\n selectionRef.current = {\n selectedModel,\n selectedEngine,\n selectedEffort,\n };\n }, [selectedEffort, selectedEngine, selectedModel]);\n\n const onModelChange = useCallback(\n (model: string, engine: string) => {\n hasExplicitSelectionRef.current = true;\n const effortOptions = getReasoningEffortOptionsForModel(model);\n setSelectedModel(model);\n setSelectedEngine(engine);\n setSelectedEffort((prevEffort) => {\n const next =\n prevEffort === \"auto\" || effortOptions.includes(prevEffort)\n ? prevEffort\n : \"auto\";\n writePersisted(storageKey, { model, engine, effort: next });\n return next;\n });\n },\n [storageKey],\n );\n\n const onEffortChange = useCallback(\n (effort: ReasoningEffort) => {\n hasExplicitSelectionRef.current = true;\n setSelectedEffort(effort);\n writePersisted(storageKey, {\n model: selectedModel,\n engine: selectedEngine,\n effort,\n });\n },\n [selectedEngine, selectedModel, storageKey],\n );\n\n const refreshEngines = useCallback(() => {\n if (!enabled) return;\n Promise.all([\n callAction(\"manage-agent-engine\" as any, { action: \"list\" } as any).catch(\n () => null,\n ),\n fetch(agentNativePath(\"/_agent-native/env-status\"))\n .then((r) => (r.ok ? r.json() : []))\n .catch(() => []),\n fetch(agentNativePath(\"/_agent-native/builder/status\"))\n .then((r) => (r.ok ? r.json() : null))\n .catch(() => null),\n ])\n .then(([enginesData, envKeys, builderStatus]) => {\n if (!enginesData?.engines) return;\n const configuredKeys = new Set(\n (envKeys as Array<{ key: string; configured: boolean }>)\n .filter((k) => k.configured)\n .map((k) => k.key),\n );\n const builderConnected = builderStatus?.configured === true;\n const currentEngineName: string | undefined =\n enginesData.current?.engine;\n const currentModel: string | undefined = enginesData.current?.model;\n\n let groups: EngineModelGroup[];\n\n if (builderConnected) {\n const builderEngine = enginesData.engines.find(\n (e: any) => e.name === \"builder\",\n );\n const builderModels: string[] = builderEngine?.supportedModels ?? [];\n const claude = builderModels.filter((m: string) =>\n m.startsWith(\"claude-\"),\n );\n const openai = builderModels.filter((m: string) =>\n m.startsWith(\"gpt-\"),\n );\n const gemini = builderModels.filter((m: string) =>\n m.startsWith(\"gemini-\"),\n );\n const other = builderModels.filter(\n (m: string) =>\n !m.startsWith(\"claude-\") &&\n !m.startsWith(\"gpt-\") &&\n !m.startsWith(\"gemini-\"),\n );\n\n groups = [\n ...(claude.length\n ? [\n {\n engine: \"builder\",\n label: \"Claude\",\n models: claude,\n configured: true,\n },\n ]\n : []),\n ...(openai.length\n ? [\n {\n engine: \"builder\",\n label: \"OpenAI\",\n models: openai,\n configured: true,\n },\n ]\n : []),\n ...(gemini.length\n ? [\n {\n engine: \"builder\",\n label: \"Gemini\",\n models: gemini,\n configured: true,\n },\n ]\n : []),\n ...(other.length\n ? [\n {\n engine: \"builder\",\n label: \"More\",\n models: other,\n configured: true,\n },\n ]\n : []),\n ];\n\n if (currentModel && !builderModels.includes(currentModel)) {\n const firstGroup = groups[0];\n if (firstGroup) firstGroup.models.unshift(currentModel);\n }\n } else {\n const allowedEngines = new Set([\n \"anthropic\",\n \"ai-sdk:openai\",\n \"ai-sdk:google\",\n ]);\n groups = enginesData.engines\n .filter(\n (e: any) =>\n allowedEngines.has(e.name) && e.packageInstalled !== false,\n )\n .map((e: any) => {\n const models = [...e.supportedModels];\n if (\n e.name === currentEngineName &&\n currentModel &&\n !models.includes(currentModel)\n ) {\n models.unshift(currentModel);\n }\n return {\n engine: e.name,\n label: e.label,\n models,\n configured:\n e.requiredEnvVars.length === 0 ||\n e.requiredEnvVars.some((v: string) =>\n configuredKeys.has(v),\n ) ||\n e.name === currentEngineName,\n };\n });\n }\n const nextDefaultModel = currentModel ?? DEFAULT_MODEL;\n setAvailableModels(groups);\n setDefaultModel(nextDefaultModel);\n\n const selection = selectionRef.current;\n if (!hasExplicitSelectionRef.current) {\n const defaultGroup =\n groups.find((group) => group.models.includes(nextDefaultModel)) ??\n groups[0];\n const nextModel =\n defaultGroup?.models.find((model) => model === nextDefaultModel) ??\n defaultGroup?.models[0] ??\n nextDefaultModel;\n const nextEngine = defaultGroup?.engine ?? \"\";\n const effortOptions = getReasoningEffortOptionsForModel(nextModel);\n const nextEffort =\n selection.selectedEffort === \"auto\" ||\n effortOptions.includes(selection.selectedEffort)\n ? selection.selectedEffort\n : \"auto\";\n setSelectedModel(nextModel);\n setSelectedEngine(nextEngine);\n setSelectedEffort(nextEffort);\n return;\n }\n\n const selectedGroup = groups.find(\n (group) =>\n group.models.includes(selection.selectedModel) &&\n (!selection.selectedEngine ||\n group.engine === selection.selectedEngine),\n );\n if (!selectedGroup) {\n const defaultGroup =\n groups.find((group) => group.models.includes(nextDefaultModel)) ??\n groups[0];\n const nextModel =\n defaultGroup?.models.find((model) => model === nextDefaultModel) ??\n defaultGroup?.models[0] ??\n nextDefaultModel;\n const nextEngine = defaultGroup?.engine ?? \"\";\n const effortOptions = getReasoningEffortOptionsForModel(nextModel);\n const nextEffort =\n selection.selectedEffort === \"auto\" ||\n effortOptions.includes(selection.selectedEffort)\n ? selection.selectedEffort\n : \"auto\";\n setSelectedModel(nextModel);\n setSelectedEngine(nextEngine);\n setSelectedEffort(nextEffort);\n writePersisted(storageKey, {\n model: nextModel,\n engine: nextEngine,\n effort: nextEffort,\n });\n }\n })\n .catch(() => {});\n }, [enabled, storageKey]);\n\n useEffect(() => {\n if (!enabled) return;\n refreshEngines();\n }, [enabled, refreshEngines]);\n\n return {\n availableModels,\n defaultModel,\n selectedModel,\n selectedEngine,\n selectedEffort,\n onModelChange,\n onEffortChange,\n refreshEngines,\n };\n}\n"]}
1
+ {"version":3,"file":"use-chat-models.js","sourceRoot":"","sources":["../../src/client/use-chat-models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EACL,iCAAiC,GAElC,MAAM,+BAA+B,CAAC;AAiCvC,MAAM,mBAAmB,GAAG,oCAAoC,CAAC;AAQjE,SAAS,aAAa,CAAC,GAAkB;IACvC,IAAI,CAAC,GAAG,IAAI,OAAO,MAAM,KAAK,WAAW;QAAE,OAAO,EAAE,CAAC;IACrD,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,CAA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,CAAC,CAAC;aACD,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IACrB,CAAC,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC;IAE1B,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,OAAO;YAAE,OAAO;QACrB,cAAc,EAAE,CAAC;IACnB,CAAC,EAAE,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC;IAE9B,OAAO;QACL,eAAe;QACf,YAAY;QACZ,aAAa;QACb,cAAc;QACd,cAAc;QACd,aAAa;QACb,cAAc;QACd,cAAc;KACf,CAAC;AACJ,CAAC","sourcesContent":["import { useCallback, useEffect, useRef, useState } from \"react\";\nimport { agentNativePath } from \"./api-path.js\";\nimport { callAction } from \"./use-action.js\";\nimport { DEFAULT_MODEL } from \"../agent/default-model.js\";\nimport {\n getReasoningEffortOptionsForModel,\n type ReasoningEffort,\n} from \"../shared/reasoning-effort.js\";\n\nexport interface EngineModelGroup {\n engine: string;\n label: string;\n models: string[];\n configured: boolean;\n}\n\nexport interface UseChatModelsResult {\n availableModels: EngineModelGroup[];\n defaultModel: string;\n selectedModel: string;\n selectedEngine: string;\n selectedEffort: ReasoningEffort;\n onModelChange: (model: string, engine: string) => void;\n onEffortChange: (effort: ReasoningEffort) => void;\n refreshEngines: () => void;\n}\n\ninterface Options {\n /**\n * localStorage key used to persist the user's model + effort selection across\n * page loads. Pass `null` to disable persistence.\n */\n storageKey?: string | null;\n /**\n * Disable server-backed model discovery for hosts that provide their own\n * model list/state, such as Electron Code.\n */\n enabled?: boolean;\n}\n\nconst DEFAULT_STORAGE_KEY = \"agent-native:chat-models:selection\";\n\ninterface PersistedSelection {\n model?: string;\n engine?: string;\n effort?: ReasoningEffort;\n}\n\nfunction readPersisted(key: string | null): PersistedSelection {\n if (!key || typeof window === \"undefined\") return {};\n try {\n const raw = window.localStorage.getItem(key);\n return raw ? (JSON.parse(raw) as PersistedSelection) : {};\n } catch {\n return {};\n }\n}\n\nfunction writePersisted(key: string | null, value: PersistedSelection) {\n if (!key || typeof window === \"undefined\") return;\n try {\n window.localStorage.setItem(key, JSON.stringify(value));\n } catch {}\n}\n\n/**\n * Fetches available engines/models from the agent server and exposes the same\n * model picker state that `MultiTabAssistantChat` wires up — for surfaces like\n * the Dispatch homepage hero composer that need an identical model picker\n * without mounting the full tabbed chat.\n */\nexport function useChatModels({\n storageKey = DEFAULT_STORAGE_KEY,\n enabled = true,\n}: Options = {}): UseChatModelsResult {\n const [availableModels, setAvailableModels] = useState<EngineModelGroup[]>(\n [],\n );\n const [defaultModel, setDefaultModel] = useState<string>(DEFAULT_MODEL);\n\n const initialPersisted = readPersisted(storageKey);\n const hasExplicitSelectionRef = useRef(Boolean(initialPersisted.model));\n const [selectedModel, setSelectedModel] = useState<string>(\n initialPersisted.model ?? DEFAULT_MODEL,\n );\n const [selectedEngine, setSelectedEngine] = useState<string>(\n initialPersisted.engine ?? \"\",\n );\n const [selectedEffort, setSelectedEffort] = useState<ReasoningEffort>(\n initialPersisted.effort ?? \"auto\",\n );\n const selectionRef = useRef({\n selectedModel,\n selectedEngine,\n selectedEffort,\n });\n\n useEffect(() => {\n selectionRef.current = {\n selectedModel,\n selectedEngine,\n selectedEffort,\n };\n }, [selectedEffort, selectedEngine, selectedModel]);\n\n const onModelChange = useCallback(\n (model: string, engine: string) => {\n hasExplicitSelectionRef.current = true;\n const effortOptions = getReasoningEffortOptionsForModel(model);\n setSelectedModel(model);\n setSelectedEngine(engine);\n setSelectedEffort((prevEffort) => {\n const next =\n prevEffort === \"auto\" || effortOptions.includes(prevEffort)\n ? prevEffort\n : \"auto\";\n writePersisted(storageKey, { model, engine, effort: next });\n return next;\n });\n },\n [storageKey],\n );\n\n const onEffortChange = useCallback(\n (effort: ReasoningEffort) => {\n hasExplicitSelectionRef.current = true;\n setSelectedEffort(effort);\n writePersisted(storageKey, {\n model: selectedModel,\n engine: selectedEngine,\n effort,\n });\n },\n [selectedEngine, selectedModel, storageKey],\n );\n\n const refreshEngines = useCallback(() => {\n if (!enabled) return;\n Promise.all([\n callAction(\"manage-agent-engine\" as any, { action: \"list\" } as any).catch(\n () => null,\n ),\n fetch(agentNativePath(\"/_agent-native/env-status\"))\n .then((r) => (r.ok ? r.json() : []))\n .catch(() => []),\n fetch(agentNativePath(\"/_agent-native/builder/status\"))\n .then((r) => (r.ok ? r.json() : null))\n .catch(() => null),\n ])\n .then(([enginesData, envKeys, builderStatus]) => {\n if (!enginesData?.engines) return;\n const configuredKeys = new Set(\n (envKeys as Array<{ key: string; configured: boolean }>)\n .filter((k) => k.configured)\n .map((k) => k.key),\n );\n const builderConnected = builderStatus?.configured === true;\n const currentEngineName: string | undefined =\n enginesData.current?.engine;\n const currentModel: string | undefined = enginesData.current?.model;\n\n let groups: EngineModelGroup[];\n\n if (builderConnected) {\n const builderEngine = enginesData.engines.find(\n (e: any) => e.name === \"builder\",\n );\n const builderModels: string[] = builderEngine?.supportedModels ?? [];\n const claude = builderModels.filter((m: string) =>\n m.startsWith(\"claude-\"),\n );\n const openai = builderModels.filter((m: string) =>\n m.startsWith(\"gpt-\"),\n );\n const gemini = builderModels.filter((m: string) =>\n m.startsWith(\"gemini-\"),\n );\n const other = builderModels.filter(\n (m: string) =>\n !m.startsWith(\"claude-\") &&\n !m.startsWith(\"gpt-\") &&\n !m.startsWith(\"gemini-\"),\n );\n\n groups = [\n ...(claude.length\n ? [\n {\n engine: \"builder\",\n label: \"Claude\",\n models: claude,\n configured: true,\n },\n ]\n : []),\n ...(openai.length\n ? [\n {\n engine: \"builder\",\n label: \"OpenAI\",\n models: openai,\n configured: true,\n },\n ]\n : []),\n ...(gemini.length\n ? [\n {\n engine: \"builder\",\n label: \"Gemini\",\n models: gemini,\n configured: true,\n },\n ]\n : []),\n ...(other.length\n ? [\n {\n engine: \"builder\",\n label: \"More\",\n models: other,\n configured: true,\n },\n ]\n : []),\n ];\n } else {\n const allowedEngines = new Set([\n \"anthropic\",\n \"ai-sdk:openai\",\n \"ai-sdk:google\",\n ]);\n groups = enginesData.engines\n .filter(\n (e: any) =>\n allowedEngines.has(e.name) && e.packageInstalled !== false,\n )\n .map((e: any) => {\n const models = [...e.supportedModels];\n if (\n e.name === currentEngineName &&\n currentModel &&\n !models.includes(currentModel)\n ) {\n models.unshift(currentModel);\n }\n return {\n engine: e.name,\n label: e.label,\n models,\n configured:\n e.requiredEnvVars.length === 0 ||\n e.requiredEnvVars.some((v: string) =>\n configuredKeys.has(v),\n ) ||\n e.name === currentEngineName,\n };\n });\n }\n const nextDefaultModel = currentModel ?? DEFAULT_MODEL;\n setAvailableModels(groups);\n setDefaultModel(nextDefaultModel);\n\n const selection = selectionRef.current;\n if (!hasExplicitSelectionRef.current) {\n const defaultGroup =\n groups.find((group) => group.models.includes(nextDefaultModel)) ??\n groups[0];\n const nextModel =\n defaultGroup?.models.find((model) => model === nextDefaultModel) ??\n defaultGroup?.models[0] ??\n nextDefaultModel;\n const nextEngine = defaultGroup?.engine ?? \"\";\n const effortOptions = getReasoningEffortOptionsForModel(nextModel);\n const nextEffort =\n selection.selectedEffort === \"auto\" ||\n effortOptions.includes(selection.selectedEffort)\n ? selection.selectedEffort\n : \"auto\";\n setSelectedModel(nextModel);\n setSelectedEngine(nextEngine);\n setSelectedEffort(nextEffort);\n return;\n }\n\n const selectedGroup = groups.find(\n (group) =>\n group.models.includes(selection.selectedModel) &&\n (!selection.selectedEngine ||\n group.engine === selection.selectedEngine),\n );\n if (!selectedGroup) {\n const defaultGroup =\n groups.find((group) => group.models.includes(nextDefaultModel)) ??\n groups[0];\n const nextModel =\n defaultGroup?.models.find((model) => model === nextDefaultModel) ??\n defaultGroup?.models[0] ??\n nextDefaultModel;\n const nextEngine = defaultGroup?.engine ?? \"\";\n const effortOptions = getReasoningEffortOptionsForModel(nextModel);\n const nextEffort =\n selection.selectedEffort === \"auto\" ||\n effortOptions.includes(selection.selectedEffort)\n ? selection.selectedEffort\n : \"auto\";\n setSelectedModel(nextModel);\n setSelectedEngine(nextEngine);\n setSelectedEffort(nextEffort);\n writePersisted(storageKey, {\n model: nextModel,\n engine: nextEngine,\n effort: nextEffort,\n });\n }\n })\n .catch(() => {});\n }, [enabled, storageKey]);\n\n useEffect(() => {\n if (!enabled) return;\n refreshEngines();\n }, [enabled, refreshEngines]);\n\n return {\n availableModels,\n defaultModel,\n selectedModel,\n selectedEngine,\n selectedEffort,\n onModelChange,\n onEffortChange,\n refreshEngines,\n };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"webhook-handler.d.ts","sourceRoot":"","sources":["../../src/integrations/webhook-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAGnE,OAAO,EAML,KAAK,WAAW,EACjB,MAAM,8BAA8B,CAAC;AAYtC,OAAO,KAAK,EAAE,WAAW,EAAiB,MAAM,0BAA0B,CAAC;AAS3E,OAAO,EAGL,KAAK,WAAW,EACjB,MAAM,0BAA0B,CAAC;AAsClC,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,eAAe,CAAC;IACzB,oCAAoC;IACpC,YAAY,EAAE,MAAM,CAAC;IACrB,mCAAmC;IACnC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACrC,qEAAqE;IACrE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wBAAwB;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,sEAAsE;IACtE,MAAM,CAAC,EACH,WAAW,GACX,MAAM,GACN;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC;IACtD,kEAAkE;IAClE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wDAAwD;IACxD,UAAU,EAAE,MAAM,CAAC;IACnB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,eAAe,CAAC;IAC3B,yEAAyE;IACzE,aAAa,CAAC,EAAE,CACd,QAAQ,EAAE,eAAe,EACzB,OAAO,EAAE,eAAe,KACrB,OAAO,CACR;QACE,OAAO,EAAE,IAAI,CAAC;QACd,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,GACD;QAAE,OAAO,EAAE,KAAK,CAAA;KAAE,CACrB,CAAC;CACH;AAmDD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,aAAa,CACjC,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC,CAsE5C;AAgHD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAgCrD;AAED;;;;GAIG;AACH,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,WAAW,EACjB,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,IAAI,CAAC,CAWf"}
1
+ {"version":3,"file":"webhook-handler.d.ts","sourceRoot":"","sources":["../../src/integrations/webhook-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAGnE,OAAO,EAML,KAAK,WAAW,EACjB,MAAM,8BAA8B,CAAC;AAatC,OAAO,KAAK,EAAE,WAAW,EAAiB,MAAM,0BAA0B,CAAC;AAS3E,OAAO,EAGL,KAAK,WAAW,EACjB,MAAM,0BAA0B,CAAC;AAsClC,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,eAAe,CAAC;IACzB,oCAAoC;IACpC,YAAY,EAAE,MAAM,CAAC;IACrB,mCAAmC;IACnC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACrC,qEAAqE;IACrE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wBAAwB;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,sEAAsE;IACtE,MAAM,CAAC,EACH,WAAW,GACX,MAAM,GACN;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC;IACtD,kEAAkE;IAClE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wDAAwD;IACxD,UAAU,EAAE,MAAM,CAAC;IACnB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,eAAe,CAAC;IAC3B,yEAAyE;IACzE,aAAa,CAAC,EAAE,CACd,QAAQ,EAAE,eAAe,EACzB,OAAO,EAAE,eAAe,KACrB,OAAO,CACR;QACE,OAAO,EAAE,IAAI,CAAC;QACd,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,GACD;QAAE,OAAO,EAAE,KAAK,CAAA;KAAE,CACrB,CAAC;CACH;AAmDD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,aAAa,CACjC,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC,CAsE5C;AAgHD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAgCrD;AAED;;;;GAIG;AACH,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,WAAW,EACjB,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,IAAI,CAAC,CAWf"}
@@ -4,7 +4,7 @@ import { runAgentLoop, actionsToEngineTools, getOwnerActiveApiKey, getOwnerApiKe
4
4
  import { PROVIDER_TO_ENV } from "../agent/engine/provider-env-vars.js";
5
5
  import { isLocalDatabase } from "../db/client.js";
6
6
  import { readDeployCredentialEnv } from "../server/credential-provider.js";
7
- import { getStoredModelForEngine, resolveEngine, } from "../agent/engine/index.js";
7
+ import { getStoredModelForEngine, normalizeModelForEngine, resolveEngine, } from "../agent/engine/index.js";
8
8
  import { formatLlmCredentialErrorMessage, isLlmCredentialError, } from "../agent/engine/credential-errors.js";
9
9
  import { startRun } from "../agent/run-manager.js";
10
10
  import { buildAssistantMessage, extractThreadMeta, } from "../agent/thread-data-builder.js";
@@ -407,11 +407,12 @@ async function processIncomingMessage(incoming, options, opts = {}) {
407
407
  model,
408
408
  appId: options.appId,
409
409
  });
410
- const resolvedModel = (await getStoredModelForEngine(engine, {
410
+ const modelCandidate = (await getStoredModelForEngine(engine, {
411
411
  appId: options.appId,
412
412
  })) ??
413
413
  model ??
414
414
  engine.defaultModel;
415
+ const resolvedModel = normalizeModelForEngine(engine, modelCandidate);
415
416
  return runAgentLoop({
416
417
  engine,
417
418
  model: resolvedModel,