@lotics/app-sdk 0.82.0 → 0.82.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.
package/docs/ai.md CHANGED
@@ -322,6 +322,25 @@ Publish the **rendered** view, not the whole table. A screen that shows page 2 o
322
322
 
323
323
  Declarative and lifecycle-bound: mounting or changing `context` pushes it; unmounting, renaming the `slot`, or passing `null` clears it. Independent components hold **different slots** at once (a list screen + an open drawer), and the newest value per slot wins. Re-posting is change-gated — passing a fresh inline object each render does **not** spam the host; only a real value change re-publishes.
324
324
 
325
+ ### A slot that never publishes looks exactly like a slot with nothing to say
326
+
327
+ The failure mode worth knowing before you wire one: this hook has **no visible output**. A
328
+ `useAiContext` behind a guard that never opens publishes `null` forever while the screen it
329
+ describes renders perfectly, and nothing anywhere reports it. Silence is the same shape as
330
+ "there is nothing to report", so neither the app nor a review catches it.
331
+
332
+ The usual cause is a guard on the query state. `useQuery`'s `error` is `string | null` — it is
333
+ **never `undefined`** — so `error !== undefined` is always true and holds the guard shut on every
334
+ render. Write `if (loading || error) return;`, which is correct whichever of the two the field
335
+ turns out to be, and reads as the question you meant.
336
+
337
+ **Verify by observing what is published, never by reading the code.** Run the app under
338
+ `lotics app dev` and listen for the host notification on the wrapper page — the payload is the
339
+ context as the chat agent will receive it. Check three things, because each fails differently:
340
+ the slot carries REAL values matching what is on screen (not placeholders), it clears to `null`
341
+ when the surface closes or the tab changes, and it does not publish while the first read is still
342
+ in flight — a count of zero taken from a pending query is an answer nothing measured.
343
+
325
344
  ### The caps (host-enforced — exceeding them truncates or drops, never errors)
326
345
 
327
346
  | Field | Cap |
package/docs/mutations.md CHANGED
@@ -272,18 +272,22 @@ Inside the workflow body, the payload is `trigger.app_workflow.inputs.<name>`, t
272
272
  `T | null | undefined` for an optional input. The triggering member is
273
273
  `runtime.triggered_by_member_id` (`null` for an anonymous public caller).
274
274
 
275
- **Guard on `undefined`, not on nullish.** The three caller states arrive intact, and the loose
276
- `!= null` collapses two of them it skips a clear as well as an omission, which is how a Clear
277
- button ends up doing nothing:
275
+ **Guard on the KEY, not on the value.** The three caller states arrive intact an omitted input
276
+ has no key at all, a cleared one has the key with `null` so a value test cannot tell them apart:
277
+ `!= null` and `isNull(…)` both skip a clear as well as an omission, which is how a Clear button
278
+ ends up doing nothing. Ask whether the key was sent:
278
279
 
279
280
  ```js
280
281
  const i = trigger.app_workflow.inputs;
281
- if (i.title !== undefined) {
282
+ if (includes(keys(i), "title")) {
282
283
  // i.title may be null here — that is the CLEAR, and `set` writes it as one.
283
284
  await update_records({ table_id: "tbl_items", record_ids: [i.record_id], set: { fld_title: i.title } });
284
285
  }
285
286
  ```
286
287
 
288
+ `undefined` is not spellable in a workflow body — the expression subset has no such identifier, and
289
+ a body naming it fails to save with `Unknown identifier "undefined"`. `keys` is the presence test.
290
+
287
291
  When several optional inputs each map to a field, per-field guards become noise. Hand the whole
288
292
  bag to `update_records`' **`set_skip_null`** instead — same object shape as `set`, but entries
289
293
  whose value is `null`/`undefined` are dropped, so only the fields actually provided get written
package/docs/workflows.md CHANGED
@@ -504,15 +504,20 @@ record is the body's decision, and the two write surfaces answer differently:
504
504
  | `set: { fld_x: i.x }` | **clears the field** |
505
505
 
506
506
  So `set_skip_null` is the right default for a bag of optional inputs, and the wrong choice for any
507
- field the screen must be able to blank — put those in `set`, and guard on `undefined` so an input
508
- the caller never sent is not written:
507
+ field the screen must be able to blank — put those in `set`, and test whether the KEY was sent so
508
+ an input the caller never sent is not written:
509
509
 
510
510
  ```js
511
- if (i.phone !== undefined) { // NOT `!= null` — that swallows the clear
511
+ if (includes(keys(i), "phone")) { // NOT `isNull(i.phone)` — that swallows the clear
512
512
  await update_records({ table_id: "tbl_x", record_ids: [i.id], set: { fld_phone: i.phone } });
513
513
  }
514
514
  ```
515
515
 
516
+ An omitted input carries no key at all and a cleared one carries the key with `null`, so presence
517
+ is the only test that separates them. It has to be `keys` rather than a comparison against
518
+ `undefined`: the expression subset has no `undefined` identifier, and a body naming it fails to
519
+ save with `Unknown identifier "undefined"`.
520
+
516
521
  `""` is never a clear on any surface: an HTML input emits it for "the user skipped this", so the
517
522
  validator coerces it to omitted before the body runs. Reaching for `""` to blank a field fails
518
523
  silently — the write reports success and the old value stays. Send `null`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lotics/app-sdk",
3
- "version": "0.82.0",
3
+ "version": "0.82.2",
4
4
  "description": "Runtime SDK for Lotics custom-code apps \u2014 typed hooks, postMessage bridge, mount entry point",
5
5
  "type": "module",
6
6
  "exports": {