@ai-matrx/records-ui 0.116.99 → 0.116.101

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/index.js CHANGED
@@ -199,7 +199,7 @@ import {
199
199
  withoutLeadingBlank,
200
200
  workedOutErrorFor,
201
201
  workedOutHoldsNumbers
202
- } from "./chunk-CPFQVQIK.js";
202
+ } from "./chunk-VQDHNYJQ.js";
203
203
  import {
204
204
  CHART_PLOT_PX,
205
205
  EMBEDDED_ROW_PX,
@@ -309,7 +309,7 @@ import {
309
309
  valueFromPastedText,
310
310
  visibilityLaneFor,
311
311
  whyNotAskable
312
- } from "./chunk-HU3X5SRA.js";
312
+ } from "./chunk-T7SXM6ZL.js";
313
313
  import {
314
314
  ACTION_CHECKING_ACCESS_REASON,
315
315
  ACTION_NOT_HERE_REASON,
@@ -329,7 +329,7 @@ import {
329
329
  toDropdownEntries,
330
330
  toStripAndRows,
331
331
  withExtensions
332
- } from "./chunk-SB5UVLQK.js";
332
+ } from "./chunk-MTA5CGMH.js";
333
333
  import {
334
334
  ABSENCE_WORD_LABEL,
335
335
  ABSENCE_WORD_VALUES,
@@ -2921,6 +2921,7 @@ import {
2921
2921
  displayId
2922
2922
  } from "@ai-matrx/design-system";
2923
2923
  import { formatRelativeTime as formatRelativeTime2 } from "@ai-matrx/kit/format";
2924
+ import { RECORDS_LIMITS_DEFAULTS } from "@ai-matrx/records/core";
2924
2925
  import { humanizeIdentifier as humanizeIdentifier3 } from "@ai-matrx/kit/text-case";
2925
2926
 
2926
2927
  // src/valueSource.ts
@@ -3001,7 +3002,8 @@ function fillEstimateWords(args) {
3001
3002
  const total = costInPoints(args.estimate.costCents, args.rate);
3002
3003
  if (total !== null) return `about ${total}${args.estimate.extraReads ? " or more" : ""}`;
3003
3004
  }
3004
- return "no estimate";
3005
+ const why = args.estimate ? args.estimate.says?.trim() : "";
3006
+ return why ? `no estimate: ${why}` : "no estimate";
3005
3007
  }
3006
3008
  var FILL_OFF_REASON = "Switch it on to fill";
3007
3009
  var NO_ENRICH_REASON = "Having an agent fill this column is not switched on here yet, so this panel does not offer it rather than offering something that cannot happen. Everything else on this panel works. It is on our list, not yours.";
@@ -3106,17 +3108,29 @@ function useEnrichCells(tableId, recordIds) {
3106
3108
  return { cells, refresh, error };
3107
3109
  }
3108
3110
  var NEVER = "Fill it in once and leave it alone";
3109
- var FILL_TRY_MAX = 10;
3110
- var FILL_ROWS_MAX = 50;
3111
- var FILL_N_DEFAULT = "3";
3112
- function dueRowsEstimate(row) {
3111
+ function useFillLimits(client) {
3112
+ const [limits, setLimits] = useState7(null);
3113
+ useEffect8(() => {
3114
+ let live = true;
3115
+ if (!client?.recordsLimits) {
3116
+ setLimits({ ...RECORDS_LIMITS_DEFAULTS });
3117
+ return;
3118
+ }
3119
+ void client.recordsLimits().then((got) => live && setLimits(got), () => live && setLimits({ ...RECORDS_LIMITS_DEFAULTS }));
3120
+ return () => {
3121
+ live = false;
3122
+ };
3123
+ }, [client]);
3124
+ return limits;
3125
+ }
3126
+ function dueRowsEstimate(row, rowsMax = RECORDS_LIMITS_DEFAULTS.aiFillRowsMax) {
3113
3127
  const empty = Math.max(0, Number(row.rows_total) - Number(row.rows_filled));
3114
- return Math.max(1, Math.min(FILL_ROWS_MAX, empty));
3128
+ return Math.max(1, Math.min(rowsMax, empty));
3115
3129
  }
3116
- function fillCountFrom(text) {
3130
+ function fillCountFrom(text, rowsMax = RECORDS_LIMITS_DEFAULTS.aiFillRowsMax) {
3117
3131
  if (!/^\d+$/.test(text.trim())) return null;
3118
3132
  const n = Number(text);
3119
- return n >= 1 && n <= FILL_ROWS_MAX ? n : null;
3133
+ return n >= 1 && n <= rowsMax ? n : null;
3120
3134
  }
3121
3135
  function EnrichPanel({ tableId, fieldId, className }) {
3122
3136
  const client = useRecordsClient7();
@@ -3125,6 +3139,10 @@ function EnrichPanel({ tableId, fieldId, className }) {
3125
3139
  const table = useTable2(tableId);
3126
3140
  const fields = useFields(tableId);
3127
3141
  const rights = useTableRights(table.data);
3142
+ const limits = useFillLimits(client);
3143
+ const tryMax = limits?.aiFillTryMax ?? 0;
3144
+ const rowsMax = limits?.aiFillRowsMax ?? 0;
3145
+ const startN = String(limits?.aiFillDefaultRows ?? "");
3128
3146
  const [rows, setRows] = useState7(null);
3129
3147
  const [error, setError] = useState7(null);
3130
3148
  const [busy, setBusy] = useState7(null);
@@ -3195,7 +3213,7 @@ function EnrichPanel({ tableId, fieldId, className }) {
3195
3213
  tableId,
3196
3214
  fieldId: row.field_id,
3197
3215
  fieldKey: row.field_key,
3198
- rows: count ?? (previewOnly ? 5 : 50),
3216
+ rows: count ?? (previewOnly ? 5 : rowsMax),
3199
3217
  previewOnly
3200
3218
  });
3201
3219
  setBusy(null);
@@ -3206,11 +3224,11 @@ function EnrichPanel({ tableId, fieldId, className }) {
3206
3224
  }
3207
3225
  if (!previewOnly) await load();
3208
3226
  },
3209
- [host, load, tableId]
3227
+ [host, load, tableId, rowsMax]
3210
3228
  );
3211
3229
  const startFill = useCallback4(
3212
3230
  (row, count) => {
3213
- if (count > FILL_TRY_MAX) {
3231
+ if (count > tryMax) {
3214
3232
  setConfirming({ fieldId: row.field_id, count });
3215
3233
  if (row.cost_per_row_cents === null && previewCost[row.field_id] === void 0 && host.estimateFill) {
3216
3234
  const key = `${row.field_id}:${count}`;
@@ -3222,7 +3240,7 @@ function EnrichPanel({ tableId, fieldId, className }) {
3222
3240
  setConfirming(null);
3223
3241
  void runIt(row, false, count);
3224
3242
  },
3225
- [runIt, previewCost, host, tableId]
3243
+ [runIt, previewCost, host, tableId, tryMax]
3226
3244
  );
3227
3245
  if (error) return /* @__PURE__ */ jsx7(RefusalNotice, { error, className });
3228
3246
  if (rows === null) return /* @__PURE__ */ jsx7(Skeleton, { className: cn2("h-40 w-full", className) });
@@ -3463,7 +3481,7 @@ function EnrichPanel({ tableId, fieldId, className }) {
3463
3481
  children: "Show me five rows it would do"
3464
3482
  }
3465
3483
  ),
3466
- host.enrich ? /* @__PURE__ */ jsxs5(Fragment2, { children: [
3484
+ host.enrich && limits === null ? /* @__PURE__ */ jsx7(Skeleton, { className: "h-8 w-64", "data-enrich-limits-reading": "" }) : host.enrich ? /* @__PURE__ */ jsxs5(Fragment2, { children: [
3467
3485
  /* @__PURE__ */ jsx7(
3468
3486
  Button5,
3469
3487
  {
@@ -3492,10 +3510,10 @@ function EnrichPanel({ tableId, fieldId, className }) {
3492
3510
  type: "number",
3493
3511
  inputMode: "numeric",
3494
3512
  min: 1,
3495
- max: FILL_ROWS_MAX,
3513
+ max: rowsMax,
3496
3514
  className: "h-8 w-16",
3497
3515
  "aria-label": "How many rows to fill",
3498
- value: fillN[row.field_id] ?? FILL_N_DEFAULT,
3516
+ value: fillN[row.field_id] ?? startN,
3499
3517
  onChange: (e) => setFillN((prev) => ({ ...prev, [row.field_id]: e.target.value }))
3500
3518
  }
3501
3519
  ),
@@ -3504,15 +3522,15 @@ function EnrichPanel({ tableId, fieldId, className }) {
3504
3522
  {
3505
3523
  size: "sm",
3506
3524
  variant: "outline",
3507
- disabled: busy === row.field_id || !row.enabled || fillCountFrom(fillN[row.field_id] ?? FILL_N_DEFAULT) === null,
3525
+ disabled: busy === row.field_id || !row.enabled || fillCountFrom(fillN[row.field_id] ?? startN, rowsMax) === null,
3508
3526
  title: row.enabled ? void 0 : FILL_OFF_REASON,
3509
3527
  "data-enrich-fill-rows": "",
3510
3528
  onClick: () => {
3511
- const n = fillCountFrom(fillN[row.field_id] ?? FILL_N_DEFAULT);
3529
+ const n = fillCountFrom(fillN[row.field_id] ?? startN, rowsMax);
3512
3530
  if (n !== null) startFill(row, n);
3513
3531
  },
3514
3532
  children: (() => {
3515
- const n = fillCountFrom(fillN[row.field_id] ?? FILL_N_DEFAULT);
3533
+ const n = fillCountFrom(fillN[row.field_id] ?? startN, rowsMax);
3516
3534
  return n === null ? "Fill rows" : `Fill ${n} ${n === 1 ? "row" : "rows"}`;
3517
3535
  })()
3518
3536
  }
@@ -3525,7 +3543,7 @@ function EnrichPanel({ tableId, fieldId, className }) {
3525
3543
  disabled: busy === row.field_id || !row.enabled,
3526
3544
  title: row.enabled ? void 0 : FILL_OFF_REASON,
3527
3545
  "data-enrich-fill-due": "",
3528
- onClick: () => startFill(row, dueRowsEstimate(row)),
3546
+ onClick: () => startFill(row, dueRowsEstimate(row, rowsMax)),
3529
3547
  children: "Fill in what is due"
3530
3548
  }
3531
3549
  )
@@ -4270,17 +4288,17 @@ function MoveUnderDialog({ tableId, record, document: document2, open, onOpenCha
4270
4288
  disabled: busy
4271
4289
  }
4272
4290
  ),
4273
- parentTableId ? /* @__PURE__ */ jsx11(
4291
+ /* @__PURE__ */ jsx11(
4274
4292
  Input3,
4275
4293
  {
4276
4294
  value: search,
4277
4295
  onChange: (e) => setSearch(e.target.value),
4278
- placeholder: `Find in ${parentTableName}`,
4296
+ placeholder: parentTableId ? `Find in ${parentTableName}` : "Pick a table first",
4279
4297
  "aria-label": asHome ? "Find the record it also lives in" : "Find the record to move it under",
4280
- disabled: busy,
4298
+ disabled: busy || !parentTableId,
4281
4299
  "data-records-move-under-search": ""
4282
4300
  }
4283
- ) : null,
4301
+ ),
4284
4302
  /* @__PURE__ */ jsx11("div", { className: "h-48 overflow-y-auto", "data-records-move-under-list": "", children: !parentTableId ? null : rows === null ? /* @__PURE__ */ jsxs9("div", { className: "flex flex-col gap-2", children: [
4285
4303
  /* @__PURE__ */ jsx11(Skeleton4, { className: "h-7 w-full" }),
4286
4304
  /* @__PURE__ */ jsx11(Skeleton4, { className: "h-7 w-full" }),