@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.
@@ -696,7 +696,12 @@ async function buildArtifact(draft, format, label) {
696
696
  const extension = format === "plain" ? "txt" : format === "compact-json" ? "json" : format;
697
697
  return serialize(draft, format, { spreadsheetSafe: format === "csv" || format === "tsv", filename: `${filenameFor(label)}.${extension}` });
698
698
  }
699
- function ContentTransferMenu({ source, surface, label, projection, sections, preferences, table, formatSources, variants = EMPTY_VARIANTS, actions = [], capabilities: local, disabled, enabled = true, className, stopPropagation = true, hide = [], controllerRef }) {
699
+ function ContentTransferMenu(props) {
700
+ const inherited = React7.useContext(CapabilityContext);
701
+ const identityKey = props.capabilities?.identityKey ?? inherited.identityKey;
702
+ return /* @__PURE__ */ jsx7(ContentTransferMenuSession, { ...props }, identityKey ?? "anonymous");
703
+ }
704
+ function ContentTransferMenuSession({ source, surface, label, projection, sections, preferences, table, formatSources, variants = EMPTY_VARIANTS, actions = [], capabilities: local, disabled, enabled = true, className, stopPropagation = true, hide = [], controllerRef }) {
700
705
  const triggerRef = React7.useRef(null);
701
706
  const inherited = React7.useContext(CapabilityContext);
702
707
  const nearestSurface = React7.useContext(SurfaceContext);
@@ -989,6 +994,9 @@ function PreparationWorkspace({ restoreFocus, open, state, scopes, onClose, onCh
989
994
  const [instruction, setInstruction] = React7.useState("");
990
995
  const [busy, setBusy] = React7.useState(null);
991
996
  const [aiFailed, setAiFailed] = React7.useState(false);
997
+ React7.useEffect(() => {
998
+ setAiFailed(false);
999
+ }, [state.snapshot.id, state.draft.revision]);
992
1000
  const activeAi = React7.useRef(null);
993
1001
  const activeCapture = React7.useRef(null);
994
1002
  React7.useEffect(() => {
@@ -1299,7 +1307,7 @@ function PreparationWorkspace({ restoreFocus, open, state, scopes, onClose, onCh
1299
1307
  activeCapture.current = null;
1300
1308
  setBusy(null);
1301
1309
  }, children: "Stop loading rows" }) : null,
1302
- ai && aiSession.current?.recover && busy !== "ai" ? /* @__PURE__ */ jsx7(Button, { type: "button", variant: "outline", onClick: () => void runAi(true), children: aiFailed ? "Retry or rejoin AI run" : "Rejoin AI run" }) : null,
1310
+ ai && aiFailed && aiSession.current?.recover && busy !== "ai" ? /* @__PURE__ */ jsx7(Button, { type: "button", variant: "outline", onClick: () => void runAi(true), children: aiFailed ? "Retry or rejoin AI run" : "Rejoin AI run" }) : null,
1303
1311
  ai ? /* @__PURE__ */ jsx7("p", { className: "matrx-alchemy-meta", children: "AI creates a preview. It never copies automatically. Closing detaches this view without cancelling server work." }) : null,
1304
1312
  state.error ? /* @__PURE__ */ jsx7("p", { role: "alert", className: "matrx-alchemy-error", children: state.error }) : null
1305
1313
  ] }) : null
@@ -1426,7 +1434,17 @@ var sourceFor = (id, label, build) => ({
1426
1434
  }
1427
1435
  });
1428
1436
  function MatrxCopyMenu(props) {
1429
- return /* @__PURE__ */ jsx8(MatrxCopyMenuSession, { ...props }, props.sourceId ?? props.label);
1437
+ const inherited = useContentTransferCapabilities();
1438
+ return /* @__PURE__ */ jsx8(
1439
+ MatrxCopyMenuSession,
1440
+ {
1441
+ ...props
1442
+ },
1443
+ JSON.stringify([
1444
+ inherited.identityKey ?? null,
1445
+ props.sourceId ?? props.label
1446
+ ])
1447
+ );
1430
1448
  }
1431
1449
  function MatrxCopyMenuSession(props) {
1432
1450
  const instance = React8.useId();
@@ -1454,7 +1472,7 @@ function MatrxCopyMenuSession(props) {
1454
1472
  })) : void 0;
1455
1473
  const agent = aiVisible && props.agent !== void 0 ? make("agent", () => asPayload(resolve(props.agent))) : void 0;
1456
1474
  const structuredAgent = aiVisible && props.agent !== void 0 ? make("structured-agent", () => structuredPayload(resolve(props.agent))) : void 0;
1457
- const table = exportVisible && props.export?.sheetRows ? make("rows", () => {
1475
+ const table = (exportVisible || props.primarySource === "table") && props.export?.sheetRows ? make("rows", () => {
1458
1476
  const value = normalizeTransferJson(props.export.sheetRows());
1459
1477
  if (!Array.isArray(value) || value.some(
1460
1478
  (row) => row === null || typeof row !== "object" || Array.isArray(row)
@@ -1601,7 +1619,7 @@ function MatrxCopyMenuSession(props) {
1601
1619
  return props.sendToSheet(draft.payload.rows, props.label);
1602
1620
  }
1603
1621
  });
1604
- const source = json ?? table ?? structuredAgent ?? human ?? builderVariants[0]?.source;
1622
+ const source = (props.primarySource === "table" ? table : void 0) ?? json ?? table ?? structuredAgent ?? human ?? builderVariants[0]?.source;
1605
1623
  if (!source && !actions.length) return null;
1606
1624
  const target = source ?? make("actions", () => ({ kind: "text", text: props.label }));
1607
1625
  return /* @__PURE__ */ jsxs5(Fragment2, { children: [
@@ -1621,7 +1639,7 @@ function MatrxCopyMenuSession(props) {
1621
1639
  formatSources: {
1622
1640
  ...human ? { plain: human, markdown: humanMarkdown, html: humanMarkdown } : {},
1623
1641
  ...json ? { json, "compact-json": json } : {},
1624
- ...table ? { csv: table, tsv: table } : {}
1642
+ ...table && exportVisible ? { csv: table, tsv: table } : {}
1625
1643
  },
1626
1644
  ...props.disabled !== void 0 ? { disabled: props.disabled } : {},
1627
1645
  className: cn(
@@ -1904,8 +1922,9 @@ function useMatrxDataTableHost() {
1904
1922
  import { jsx as jsx10 } from "react/jsx-runtime";
1905
1923
  function CopyButtons(props) {
1906
1924
  const { CopyControls } = useMatrxDataTableHost();
1907
- if (CopyControls) return /* @__PURE__ */ jsx10(CopyControls, { ...props });
1908
- return /* @__PURE__ */ jsx10(MatrxCopyMenu, { ...props });
1925
+ const copyProps = props.export?.sheetRows ? { ...props, primarySource: "table" } : props;
1926
+ if (CopyControls) return /* @__PURE__ */ jsx10(CopyControls, { ...copyProps });
1927
+ return /* @__PURE__ */ jsx10(MatrxCopyMenu, { ...copyProps });
1909
1928
  }
1910
1929
 
1911
1930
  // src/data-table/MatrxUuidCell.tsx