@lotics/app-sdk 0.59.4 → 0.60.0

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/src/hooks.js CHANGED
@@ -30,10 +30,20 @@ export function useWorkflow(alias) {
30
30
  // Shared SWR config: surface a failed query immediately, keep the last good
31
31
  // rows (no retry loop that masks the error), and honor the focus/reconnect
32
32
  // opt-out.
33
+ //
34
+ // `revalidateIfStale: false` — SWR defaults this to `true`, and its initial
35
+ // -revalidation decision is `isUndefined(data) || revalidateIfStale`, so every
36
+ // re-mount of a screen that already had rows re-queried the backend. An app
37
+ // that navigates between screens (or re-opens a drawer) paid a full query set
38
+ // each time for data it was already showing. A cold mount still fetches
39
+ // (`isUndefined(data)` short-circuits), focus/reconnect still refresh, and the
40
+ // host's `refetchQueries` poke still forces a refresh after a chat turn mutates
41
+ // records — so freshness keeps every path it had except "re-mounted".
33
42
  function swrConfig(revalidateOnFocus) {
34
43
  return {
35
44
  revalidateOnFocus,
36
45
  revalidateOnReconnect: revalidateOnFocus,
46
+ revalidateIfStale: false,
37
47
  shouldRetryOnError: false,
38
48
  };
39
49
  }
@@ -68,8 +68,13 @@ server validates system conditions by `type` and never reads `field_key` on them
68
68
  the paged hooks). Object *contents* are hashed, not references — passing a fresh inline
69
69
  `{ status: "open" }` each render is the same key; you never need to memoize params.
70
70
  - The cache **survives unmount/remount**: returning to a screen renders the cached rows instantly
71
- and revalidates in the background (stale-while-revalidate). Identical concurrent reads dedupe to
72
- one request.
71
+ and **sends no request**. Identical concurrent reads dedupe to one request.
72
+ - **A re-mount is not a refresh event.** Freshness comes from window focus / tab return / network
73
+ reconnect (`revalidateOnFocus`, default on), the host's post-chat-turn refetch poke, and explicit
74
+ `refetch()`. Re-mounting a screen you already loaded is none of those, so it re-uses the cache.
75
+ A **cold** key (never loaded, or a new `(alias, params, pageSize, sort, filter)` tuple) always
76
+ fetches — this only affects keys that already hold rows.
77
+ After a write the user is watching for, call `refetch()`; never rely on navigation to refresh.
73
78
  - **`loading`** is `true` only on the *initial* load of a key — a request is in flight and there
74
79
  are no rows yet. It stays `false` during background revalidation of a key that already has rows,
75
80
  so consumers never blank loaded data to a spinner on refetch. A key *change* (new params, sort,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lotics/app-sdk",
3
- "version": "0.59.4",
3
+ "version": "0.60.0",
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": {