@ai-matrx/design-system 0.18.1 → 0.18.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2426,7 +2426,12 @@ async function buildArtifact(draft, format, label) {
2426
2426
  const extension = format === "plain" ? "txt" : format === "compact-json" ? "json" : format;
2427
2427
  return (0, import_content_transfer.serialize)(draft, format, { spreadsheetSafe: format === "csv" || format === "tsv", filename: `${filenameFor(label)}.${extension}` });
2428
2428
  }
2429
- function ContentTransferMenu({ source, surface, label, projection, sections, preferences, table, formatSources, variants = EMPTY_VARIANTS, actions = [], capabilities: local, disabled, enabled = true, className, stopPropagation = true, hide = [], controllerRef }) {
2429
+ function ContentTransferMenu(props) {
2430
+ const inherited = React12.useContext(CapabilityContext);
2431
+ const identityKey = props.capabilities?.identityKey ?? inherited.identityKey;
2432
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ContentTransferMenuSession, { ...props }, identityKey ?? "anonymous");
2433
+ }
2434
+ function ContentTransferMenuSession({ source, surface, label, projection, sections, preferences, table, formatSources, variants = EMPTY_VARIANTS, actions = [], capabilities: local, disabled, enabled = true, className, stopPropagation = true, hide = [], controllerRef }) {
2430
2435
  const triggerRef = React12.useRef(null);
2431
2436
  const inherited = React12.useContext(CapabilityContext);
2432
2437
  const nearestSurface = React12.useContext(SurfaceContext);
@@ -2719,6 +2724,9 @@ function PreparationWorkspace({ restoreFocus, open, state, scopes, onClose, onCh
2719
2724
  const [instruction, setInstruction] = React12.useState("");
2720
2725
  const [busy, setBusy] = React12.useState(null);
2721
2726
  const [aiFailed, setAiFailed] = React12.useState(false);
2727
+ React12.useEffect(() => {
2728
+ setAiFailed(false);
2729
+ }, [state.snapshot.id, state.draft.revision]);
2722
2730
  const activeAi = React12.useRef(null);
2723
2731
  const activeCapture = React12.useRef(null);
2724
2732
  React12.useEffect(() => {
@@ -3029,7 +3037,7 @@ function PreparationWorkspace({ restoreFocus, open, state, scopes, onClose, onCh
3029
3037
  activeCapture.current = null;
3030
3038
  setBusy(null);
3031
3039
  }, children: "Stop loading rows" }) : null,
3032
- ai && aiSession.current?.recover && busy !== "ai" ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Button, { type: "button", variant: "outline", onClick: () => void runAi(true), children: aiFailed ? "Retry or rejoin AI run" : "Rejoin AI run" }) : null,
3040
+ ai && aiFailed && aiSession.current?.recover && busy !== "ai" ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Button, { type: "button", variant: "outline", onClick: () => void runAi(true), children: aiFailed ? "Retry or rejoin AI run" : "Rejoin AI run" }) : null,
3033
3041
  ai ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "matrx-alchemy-meta", children: "AI creates a preview. It never copies automatically. Closing detaches this view without cancelling server work." }) : null,
3034
3042
  state.error ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { role: "alert", className: "matrx-alchemy-error", children: state.error }) : null
3035
3043
  ] }) : null
@@ -3156,7 +3164,17 @@ var sourceFor = (id, label, build) => ({
3156
3164
  }
3157
3165
  });
3158
3166
  function MatrxCopyMenu(props) {
3159
- return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(MatrxCopyMenuSession, { ...props }, props.sourceId ?? props.label);
3167
+ const inherited = useContentTransferCapabilities();
3168
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
3169
+ MatrxCopyMenuSession,
3170
+ {
3171
+ ...props
3172
+ },
3173
+ JSON.stringify([
3174
+ inherited.identityKey ?? null,
3175
+ props.sourceId ?? props.label
3176
+ ])
3177
+ );
3160
3178
  }
3161
3179
  function MatrxCopyMenuSession(props) {
3162
3180
  const instance = React13.useId();
@@ -3184,7 +3202,7 @@ function MatrxCopyMenuSession(props) {
3184
3202
  })) : void 0;
3185
3203
  const agent = aiVisible && props.agent !== void 0 ? make("agent", () => asPayload(resolve(props.agent))) : void 0;
3186
3204
  const structuredAgent = aiVisible && props.agent !== void 0 ? make("structured-agent", () => structuredPayload(resolve(props.agent))) : void 0;
3187
- const table = exportVisible && props.export?.sheetRows ? make("rows", () => {
3205
+ const table = (exportVisible || props.primarySource === "table") && props.export?.sheetRows ? make("rows", () => {
3188
3206
  const value = (0, import_content_transfer2.normalizeTransferJson)(props.export.sheetRows());
3189
3207
  if (!Array.isArray(value) || value.some(
3190
3208
  (row) => row === null || typeof row !== "object" || Array.isArray(row)
@@ -3331,7 +3349,7 @@ function MatrxCopyMenuSession(props) {
3331
3349
  return props.sendToSheet(draft.payload.rows, props.label);
3332
3350
  }
3333
3351
  });
3334
- const source = json ?? table ?? structuredAgent ?? human ?? builderVariants[0]?.source;
3352
+ const source = (props.primarySource === "table" ? table : void 0) ?? json ?? table ?? structuredAgent ?? human ?? builderVariants[0]?.source;
3335
3353
  if (!source && !actions.length) return null;
3336
3354
  const target = source ?? make("actions", () => ({ kind: "text", text: props.label }));
3337
3355
  return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(import_jsx_runtime20.Fragment, { children: [
@@ -3351,7 +3369,7 @@ function MatrxCopyMenuSession(props) {
3351
3369
  formatSources: {
3352
3370
  ...human ? { plain: human, markdown: humanMarkdown, html: humanMarkdown } : {},
3353
3371
  ...json ? { json, "compact-json": json } : {},
3354
- ...table ? { csv: table, tsv: table } : {}
3372
+ ...table && exportVisible ? { csv: table, tsv: table } : {}
3355
3373
  },
3356
3374
  ...props.disabled !== void 0 ? { disabled: props.disabled } : {},
3357
3375
  className: cn(
@@ -3651,8 +3669,9 @@ ${JSON.stringify(value.data, null, 2)}
3651
3669
  var import_jsx_runtime21 = require("react/jsx-runtime");
3652
3670
  function CopyButtons(props) {
3653
3671
  const { CopyControls } = useMatrxDataTableHost();
3654
- if (CopyControls) return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(CopyControls, { ...props });
3655
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(MatrxCopyMenu, { ...props });
3672
+ const copyProps = props.export?.sheetRows ? { ...props, primarySource: "table" } : props;
3673
+ if (CopyControls) return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(CopyControls, { ...copyProps });
3674
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(MatrxCopyMenu, { ...copyProps });
3656
3675
  }
3657
3676
  function jsonExportItem(build, label) {
3658
3677
  return { id: "json", label, build: () => ({ content: JSON.stringify(build(), null, 2), extension: "json", mime: "application/json" }) };