@ai-matrx/records-ui 0.115.94 → 0.115.95

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/CHANGELOG.md CHANGED
@@ -1,6 +1,23 @@
1
1
  # Changelog — @ai-matrx/records-ui
2
2
 
3
+ ## 0.115.95
4
+
5
+ UNVERIFIED: this release has no Unreleased entry and the source comparison could not be made (the caller supplied no source comparison). Whether source changed is unknown; consumer action is unknown.
6
+ Check the package's gitHead on npm against this version's gitHead: `git diff <previous gitHead> <this gitHead> -- apps/shared/records-ui/src`.
7
+
3
8
  ## 0.115.94
9
+
10
+ SOURCE CHANGED WITH NO RELEASE NOTE. This release shipped source changes that nobody described in an Unreleased entry,
11
+ so they may include breaking API changes. Consumer action is UNKNOWN: read the diff before upgrading.
12
+ Diff: `git diff 84cf41cf37 c127354b27 -- apps/shared/records-ui/src`
13
+
14
+ Changed shipped source files (4):
15
+ - `apps/shared/records-ui/src/InterfaceScreen.tsx`
16
+ - `apps/shared/records-ui/src/PageCanvas.tsx`
17
+ - `apps/shared/records-ui/src/index.ts`
18
+ - `apps/shared/records-ui/src/interfaces.ts`
19
+
20
+ ## 0.115.93
4
21
  ### Unreleased
5
22
 
6
23
  - URL preview (Airtable's "Preview links"): a URL cell shows the page's title, description, site icon and image in a hover card, read through the new optional host port `linkPreview.read(url)` (the host asks its server; the browser never fetches the page). Unbound, the cell is the plain link chip.
package/dist/index.cjs CHANGED
@@ -11133,6 +11133,15 @@ function buttonPressWords(label, pressed) {
11133
11133
  const status = pressed.status ?? "ran";
11134
11134
  return [`${pressed.automation ?? label}: ${status}.`, pressed.says].filter(Boolean).join(" ");
11135
11135
  }
11136
+ var POLL_EVERY_MS = 1200;
11137
+ var POLL_FOR_MS = 12e4;
11138
+ function runAnswerWords(label, run) {
11139
+ const steps = run.steps ?? [];
11140
+ const failedStep = [...steps].reverse().find((s) => s.status === "failed");
11141
+ if (run.status === "failed") return [failedStep?.output_text ?? failedStep?.says, run.says].filter((t, i, all) => t && all.indexOf(t) === i).join(" ") || `${label} failed.`;
11142
+ const answered = [...steps].reverse().find((s) => s.output_text && s.output_text.trim() !== "");
11143
+ return answered?.output_text?.trim() || run.says || `${label} ran.`;
11144
+ }
11136
11145
  var stop = (event) => event.stopPropagation();
11137
11146
  function ButtonValue({ field: field2, recordId, inCell }) {
11138
11147
  const client = (0, import_react59.useOptionalRecordsClient)();
@@ -11140,6 +11149,8 @@ function ButtonValue({ field: field2, recordId, inCell }) {
11140
11149
  const [busy, setBusy] = (0, import_react58.useState)(false);
11141
11150
  const [said2, setSaid] = (0, import_react58.useState)(null);
11142
11151
  const [settingUp, setSettingUp] = (0, import_react58.useState)(false);
11152
+ const waitingOn = (0, import_react58.useRef)(0);
11153
+ (0, import_react58.useEffect)(() => () => void (waitingOn.current += 1), []);
11143
11154
  if (!b) return null;
11144
11155
  const color = (0, import_data_table7.isStyleColor)(b.color) ? import_data_table7.CHOICE_CHIP_CLASS[b.color] : import_data_table7.NEUTRAL_CHIP_CLASS;
11145
11156
  const needs = (0, import_records29.buttonNeeds)(b);
@@ -11156,60 +11167,100 @@ function ButtonValue({ field: field2, recordId, inCell }) {
11156
11167
  const opened = typeof window !== "undefined" ? (0, import_outbound.openOutbound)(pressed.url, "_blank", "noopener") : null;
11157
11168
  return setSaid({ kind: "ran", says: opened ? `${b.label} opened.` : `${b.label} is ready:`, link: pressed.url });
11158
11169
  }
11159
- setSaid({ kind: "ran", says: buttonPressWords(b.label, pressed) });
11170
+ const words2 = buttonPressWords(b.label, pressed);
11171
+ if (pressed.do === "run_automation" && pressed.status === "waiting" && pressed.run_id && b.automation_id) {
11172
+ const mine = waitingOn.current += 1;
11173
+ setBusy(true);
11174
+ setSaid({ kind: "waiting", says: `${b.label} is running` });
11175
+ const until = Date.now() + POLL_FOR_MS;
11176
+ while (waitingOn.current === mine) {
11177
+ await new Promise((r) => setTimeout(r, POLL_EVERY_MS));
11178
+ if (waitingOn.current !== mine) return;
11179
+ const runs = await client.automationRuns({ automation_id: b.automation_id, limit: 10 });
11180
+ if (!runs.ok) {
11181
+ setBusy(false);
11182
+ return setSaid({ kind: "refused", error: runs.error });
11183
+ }
11184
+ const run = runs.data.runs.find((r) => r.run_id === pressed.run_id);
11185
+ if (run && run.status !== "waiting") {
11186
+ setBusy(false);
11187
+ return setSaid(run.status === "ran" ? { kind: "ran", says: runAnswerWords(b.label, run) } : { kind: "failed", says: runAnswerWords(b.label, run) });
11188
+ }
11189
+ if (Date.now() > until) {
11190
+ setBusy(false);
11191
+ return setSaid({ kind: "ran", says: `${b.label} is still running. Its answer will be in the automation's runs.` });
11192
+ }
11193
+ }
11194
+ return;
11195
+ }
11196
+ setSaid({ kind: "ran", says: words2 });
11160
11197
  };
11161
11198
  return /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(import_jsx_runtime40.Fragment, { children: [
11162
- /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(import_design_system35.Popover, { open: said2 !== null, onOpenChange: (open) => open ? null : setSaid(null), children: [
11163
- /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_design_system35.PopoverTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
11164
- import_design_system35.Button,
11165
- {
11166
- type: "button",
11167
- size: "xs",
11168
- variant: "outline",
11169
- "data-records-button": field2.key,
11170
- "data-records-button-unset": needs ? "" : void 0,
11171
- "aria-busy": busy || void 0,
11172
- disabled: busy,
11173
- className: (0, import_design_system35.cn)("max-w-full gap-1 border px-2 font-medium", inCell ? "h-5" : "h-6", color, needs && "border-dashed opacity-80"),
11174
- onPointerDown: stop,
11175
- onDoubleClick: stop,
11176
- onClick: (event) => {
11177
- event.stopPropagation();
11178
- event.preventDefault();
11179
- void press();
11180
- },
11181
- children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("span", { className: "truncate", children: b.label })
11182
- }
11183
- ) }),
11184
- /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(import_design_system35.PopoverContent, { className: "w-72 space-y-2 p-3 text-sm", onClick: stop, onPointerDown: stop, "data-records-button-said": said2?.kind, children: [
11185
- said2?.kind === "refused" ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(RefusalLine, { error: said2.error }) : null,
11186
- said2?.kind === "public" ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("p", { children: "Buttons run for signed-in people." }) : null,
11187
- said2?.kind === "ran" ? /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("p", { className: "break-words", children: [
11188
- said2.says,
11189
- " ",
11190
- said2.link ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_outbound_react6.OutboundLink, { href: said2.link, className: "text-primary underline", children: said2.link }) : null
11191
- ] }) : null,
11192
- said2?.kind === "needs" ? /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(import_jsx_runtime40.Fragment, { children: [
11193
- /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("p", { children: said2.says }),
11194
- tableId ? /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(
11199
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(
11200
+ import_design_system35.Popover,
11201
+ {
11202
+ open: said2 !== null,
11203
+ onOpenChange: (open) => {
11204
+ if (open) return;
11205
+ waitingOn.current += 1;
11206
+ setBusy(false);
11207
+ setSaid(null);
11208
+ },
11209
+ children: [
11210
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_design_system35.PopoverTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
11195
11211
  import_design_system35.Button,
11196
11212
  {
11197
11213
  type: "button",
11198
- size: "sm",
11199
- "data-records-button-set-up": "",
11200
- onClick: () => {
11201
- setSaid(null);
11202
- setSettingUp(true);
11214
+ size: "xs",
11215
+ variant: "outline",
11216
+ "data-records-button": field2.key,
11217
+ "data-records-button-unset": needs ? "" : void 0,
11218
+ "aria-busy": busy || void 0,
11219
+ disabled: busy,
11220
+ className: (0, import_design_system35.cn)("max-w-full gap-1 border px-2 font-medium", inCell ? "h-5" : "h-6", color, needs && "border-dashed opacity-80"),
11221
+ onPointerDown: stop,
11222
+ onDoubleClick: stop,
11223
+ onClick: (event) => {
11224
+ event.stopPropagation();
11225
+ event.preventDefault();
11226
+ void press();
11203
11227
  },
11204
- children: [
11205
- "Set up ",
11206
- b.label
11207
- ]
11228
+ children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("span", { className: "truncate", children: b.label })
11208
11229
  }
11209
- ) : null
11210
- ] }) : null
11211
- ] })
11212
- ] }),
11230
+ ) }),
11231
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(import_design_system35.PopoverContent, { className: "w-72 space-y-2 p-3 text-sm", onClick: stop, onPointerDown: stop, "data-records-button-said": said2?.kind, children: [
11232
+ said2?.kind === "refused" ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(RefusalLine, { error: said2.error }) : null,
11233
+ said2?.kind === "waiting" ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("p", { className: "matrx-shimmer rounded px-1 py-0.5", role: "status", "aria-live": "polite", children: said2.says }) : null,
11234
+ said2?.kind === "failed" ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("p", { className: "break-words text-destructive", role: "alert", children: said2.says }) : null,
11235
+ said2?.kind === "public" ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("p", { children: "Buttons run for signed-in people." }) : null,
11236
+ said2?.kind === "ran" ? /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("p", { className: "break-words", children: [
11237
+ said2.says,
11238
+ " ",
11239
+ said2.link ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_outbound_react6.OutboundLink, { href: said2.link, className: "text-primary underline", children: said2.link }) : null
11240
+ ] }) : null,
11241
+ said2?.kind === "needs" ? /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(import_jsx_runtime40.Fragment, { children: [
11242
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("p", { children: said2.says }),
11243
+ tableId ? /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(
11244
+ import_design_system35.Button,
11245
+ {
11246
+ type: "button",
11247
+ size: "sm",
11248
+ "data-records-button-set-up": "",
11249
+ onClick: () => {
11250
+ setSaid(null);
11251
+ setSettingUp(true);
11252
+ },
11253
+ children: [
11254
+ "Set up ",
11255
+ b.label
11256
+ ]
11257
+ }
11258
+ ) : null
11259
+ ] }) : null
11260
+ ] })
11261
+ ]
11262
+ }
11263
+ ),
11213
11264
  settingUp && tableId ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_design_system35.Dialog, { open: true, onOpenChange: (open) => open ? null : setSettingUp(false), children: /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(import_design_system35.DialogContent, { className: "max-h-[85vh] overflow-y-auto sm:max-w-2xl", onClick: stop, onPointerDown: stop, children: [
11214
11265
  /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(import_design_system35.DialogHeader, { children: [
11215
11266
  /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_design_system35.DialogTitle, { children: `Column settings \xB7 ${fieldName(field2)}` }),