@ai-matrx/records-ui 0.115.103 → 0.115.104

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/pickers.cjs CHANGED
@@ -6210,6 +6210,11 @@ var import_design_system28 = require("@ai-matrx/design-system");
6210
6210
  var import_react50 = require("@ai-matrx/records/react");
6211
6211
  init_Refusal();
6212
6212
 
6213
+ // src/leadingBlank.ts
6214
+ function withoutLeadingBlank(text) {
6215
+ return text.replace(/^\s+/, "");
6216
+ }
6217
+
6213
6218
  // src/values.tsx
6214
6219
  init_personChip();
6215
6220
  var import_data_table3 = require("@ai-matrx/design-system/data-table");
@@ -8158,9 +8163,9 @@ function RecordsTable({ items }) {
8158
8163
  const pictureFirst = [...keys].sort((a, b) => rank(a, items) - rank(b, items)).slice(0, TABLE_COLUMNS);
8159
8164
  const shown2 = all ? items : items.slice(0, TABLE_ROWS);
8160
8165
  return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "min-w-0", "data-records-structured": "table", children: [
8161
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "max-w-full overflow-x-auto rounded-md border border-border", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("table", { className: "w-full border-collapse text-xs", children: [
8166
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "max-w-full overflow-x-auto rounded-md border border-border", "data-records-structured-table-frame": "", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("table", { className: "w-full border-collapse text-xs", children: [
8162
8167
  /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("thead", { className: "bg-muted/60 text-left", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("tr", { children: pictureFirst.map((k) => /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("th", { scope: "col", className: "whitespace-nowrap px-2 py-1 font-medium text-muted-foreground", children: keyWords(k) }, k)) }) }),
8163
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("tbody", { children: shown2.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("tr", { className: "border-t border-border/60 align-top", children: pictureFirst.map((k) => /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("td", { className: "min-w-[7rem] max-w-[18rem] px-2 py-1", children: k in item ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Nested, { value: item[k], keyName: k, dense: true }) : /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "text-muted-foreground", children: "\u2014" }) }, k)) }, i)) })
8168
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("tbody", { children: shown2.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("tr", { className: "border-t border-border/60 align-top", children: pictureFirst.map((k) => /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("td", { className: "min-w-[4rem] max-w-[18rem] break-words px-2 py-1 [overflow-wrap:anywhere]", children: k in item ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Nested, { value: item[k], keyName: k, dense: true }) : /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "text-muted-foreground", children: "\u2014" }) }, k)) }, i)) })
8164
8169
  ] }) }),
8165
8170
  items.length > TABLE_ROWS ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_design_system26.Button, { type: "button", variant: "ghost", size: "sm", className: "mt-1 h-6 px-2 text-xs", onClick: (e) => {
8166
8171
  stop(e);
@@ -8571,7 +8576,7 @@ function scalarText(field, value, labels, stillWaitingFor) {
8571
8576
  }
8572
8577
  if (Array.isArray(value)) return value.length === 0 ? "" : structuredSummary(value);
8573
8578
  if (typeof value === "object") return structuredOf(value) ? structuredSummary(value) : "\u2026";
8574
- return String(value);
8579
+ return typeof value === "string" ? withoutLeadingBlank(value) : String(value);
8575
8580
  }
8576
8581
 
8577
8582
  // src/SourceArchivedNotice.tsx
@@ -11702,12 +11707,39 @@ function buttonPressWords(label, pressed) {
11702
11707
  }
11703
11708
  var POLL_EVERY_MS = 1200;
11704
11709
  var POLL_FOR_MS = 12e4;
11705
- function runAnswerWords(label, run) {
11710
+ var RUN_BOOKKEEPING = /* @__PURE__ */ new Set(["run_id", "conversation_id"]);
11711
+ function answerOf(output) {
11712
+ const raw = (output ?? "").trim();
11713
+ if (raw === "") return { words: "" };
11714
+ let parsed;
11715
+ try {
11716
+ parsed = JSON.parse(raw);
11717
+ } catch {
11718
+ return { words: raw };
11719
+ }
11720
+ if (typeof parsed === "string") return { words: parsed.trim() };
11721
+ if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)) {
11722
+ const shown2 = Object.fromEntries(Object.entries(parsed).filter(([k]) => !RUN_BOOKKEEPING.has(k)));
11723
+ const keys = Object.keys(shown2);
11724
+ if (keys.length === 1 && typeof shown2.text === "string") return { words: shown2.text.trim() };
11725
+ const value2 = structuredOf(shown2);
11726
+ return value2 ? { words: "", value: value2 } : { words: raw };
11727
+ }
11728
+ const value = structuredOf(parsed);
11729
+ return value ? { words: "", value } : { words: raw };
11730
+ }
11731
+ function runAnswer(label, run) {
11706
11732
  const steps = run.steps ?? [];
11707
11733
  const failedStep = [...steps].reverse().find((s) => s.status === "failed");
11708
- if (run.status === "failed") return [failedStep?.output_text ?? failedStep?.says, run.says].filter((t, i, all) => t && all.indexOf(t) === i).join(" ") || `${label} failed.`;
11709
- const answered = [...steps].reverse().find((s) => s.output_text && s.output_text.trim() !== "");
11710
- return answered?.output_text?.trim() || run.says || `${label} ran.`;
11734
+ if (run.status === "failed") {
11735
+ const failed = answerOf(failedStep?.output_text).words || failedStep?.says;
11736
+ return { words: [failed, run.says].filter((t, i, all) => t && all.indexOf(t) === i).join(" ") || `${label} failed.` };
11737
+ }
11738
+ for (const step of [...steps].reverse()) {
11739
+ const answered = answerOf(step.output_text);
11740
+ if (answered.words !== "" || answered.value) return answered;
11741
+ }
11742
+ return { words: run.says || `${label} ran.` };
11711
11743
  }
11712
11744
  var stop2 = (event) => event.stopPropagation();
11713
11745
  function ButtonValue({ field, recordId, inCell }) {
@@ -11754,7 +11786,8 @@ function ButtonValue({ field, recordId, inCell }) {
11754
11786
  const run = runs.data.runs.find((r) => r.run_id === pressed.run_id);
11755
11787
  if (run && run.status !== "waiting") {
11756
11788
  setBusy(false);
11757
- return setSaid(run.status === "ran" ? { kind: "ran", says: runAnswerWords(b.label, run) } : { kind: "failed", says: runAnswerWords(b.label, run) });
11789
+ const answer = runAnswer(b.label, run);
11790
+ return setSaid(run.status === "ran" ? { kind: "ran", says: answer.words, value: answer.value } : { kind: "failed", says: answer.words });
11758
11791
  }
11759
11792
  if (Date.now() > until) {
11760
11793
  setBusy(false);
@@ -11803,7 +11836,8 @@ function ButtonValue({ field, recordId, inCell }) {
11803
11836
  said2?.kind === "waiting" ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("p", { className: "matrx-shimmer rounded px-1 py-0.5", role: "status", "aria-live": "polite", children: said2.says }) : null,
11804
11837
  said2?.kind === "failed" ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("p", { className: "break-words text-destructive", role: "alert", children: said2.says }) : null,
11805
11838
  said2?.kind === "public" ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("p", { children: "Buttons run for signed-in people." }) : null,
11806
- said2?.kind === "ran" ? /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("p", { className: "break-words", children: [
11839
+ said2?.kind === "ran" ? /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: "break-words", children: [
11840
+ said2.value ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(StructuredValueView, { structured: said2.value, label: b.label }) : null,
11807
11841
  said2.says,
11808
11842
  " ",
11809
11843
  said2.link ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_outbound_react7.OutboundLink, { href: said2.link, className: "text-primary underline", children: said2.link }) : null