@lotics/app-sdk 0.131.10 → 0.131.12

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/AGENTS.md CHANGED
@@ -20,11 +20,11 @@ This file is the index. The **exact type** of anything is its shipped declaratio
20
20
  | [docs/workflows.md](./docs/workflows.md) | **The workflow-BODY reference** — the JS subset a body may use, opaque `fld_*`/`opt_*` keys, every step form, the accepted sugar, helpers, record-write surfaces, the traps and the verify loop. |
21
21
  | [docs/recipes.md](./docs/recipes.md) | Task-shaped how-tos — returning a generated file, returning structured data, parameterized lookups, composable optional filters, cell decoding, testing an AI action without spending credits. |
22
22
  | [docs/files.md](./docs/files.md) | Files end to end — `useFileUpload` and its `fidelity` and a photo's `place`, `renameFile` (a new file over the same bytes), `useAttachments`/`useAttachmentPiles`, `readFiles` and presigned URLs (a bearer credential — never logged or persisted), workflow-generated files, naming a zip's entries, the delivery bounds. |
23
- | [docs/members_and_options.md](./docs/members_and_options.md) | People and select options — `useMembers`, `useFieldOptions`, `useViewer`, `useWorkspaceTimezone`/`useWorkspaceCurrency`, `useAppContext`, the workspace's zone at the root, a member's links to one record for a person with no seat (`useOutsideLinks`). |
24
- | [docs/navigation_and_state.md](./docs/navigation_and_state.md) | `AppRouter` (embedded/standalone URL model, the screens and `drawers` it reports to the host), `useUrlState` + `urlParam` codecs, `useRecents`, `useFolderPick`. |
23
+ | [docs/members_and_options.md](./docs/members_and_options.md) | People and select options — `useMembers`, `useFieldOptions`, `useViewer`, `useWorkspaceTimezone`/`useWorkspaceCurrency`, `useAppContext`, `askAppContext` (ask the host's context early), the workspace's zone at the root, a member's links to one record for a person with no seat (`useOutsideLinks`). |
24
+ | [docs/navigation_and_state.md](./docs/navigation_and_state.md) | `AppRouter` (embedded/standalone URL model, the screens and `drawers` it reports to the host, opening at `/` when the person opens the app from the host: `openRequested`, `subscribeOpen`), `useUrlState` + `urlParam` codecs, `useRecents`, `useFolderPick`. |
25
25
  | [docs/ai.md](./docs/ai.md) | `useAgentRun` (structured vs free-text, streaming parts, the agent's ask-back), `askAi`, `useAiContext`, and what the member's own chat agent can do with the app while it is open. |
26
26
  | [docs/security.md](./docs/security.md) | **Read before shipping** — the owner-principal model, `is_current_member` scoping, write attribution, group gates, public-app bounds, why a per-input bound is a tenancy floor rather than an authorization check. |
27
- | [docs/runtime.md](./docs/runtime.md) | `mount()` and the errors it reports to the host (`reportAppError`), the two transports, the API address a standalone bundle reads out of its own page (`<meta name="lotics-api-base">`), `rpc()` and `installRpcTransport` (a page that is never an app's answers every op itself), the mock harness (`fixture` + `?__mock=1` — queries, workflows and agents, a mocked agent's run played line by line), `openExternal`/`downloadFile`, geofencing, the peer dependencies. |
27
+ | [docs/runtime.md](./docs/runtime.md) | `mount()` and the errors it reports to the host (`reportAppError`), the two transports, the API address a standalone bundle reads out of its own page (`<meta name="lotics-api-base">`), `rpc()` (and its `holdsCover` option), `holdDrawn` (keep the host's loading cover up), `installRpcTransport` (a page that is never an app's answers every op itself), the mock harness (`fixture` + `?__mock=1` — queries, workflows and agents, a mocked agent's run played line by line), `openExternal`/`downloadFile`, geofencing, the peer dependencies. |
28
28
 
29
29
  ## Non-negotiables (each detailed in its doc)
30
30
 
@@ -1407,10 +1407,10 @@ function installRpcTransport(transport) {
1407
1407
  function hostSpec() {
1408
1408
  return rpc("spec", {});
1409
1409
  }
1410
- function rpc(op, payload) {
1410
+ function rpc(op, payload, options = {}) {
1411
1411
  if (installedTransport !== null) return installedTransport(op, payload);
1412
1412
  const hostOrigin = getHostOrigin();
1413
- return hostOrigin ? rpcBridged(op, payload, hostOrigin) : rpcStandalone(op, payload);
1413
+ return hostOrigin ? rpcBridged(op, payload, hostOrigin, options.holdsCover ?? true) : rpcStandalone(op, payload);
1414
1414
  }
1415
1415
  function getUrlParams() {
1416
1416
  return rpc("urlState.get", {});
@@ -1433,6 +1433,26 @@ function subscribeUrlParams(cb) {
1433
1433
  window.addEventListener("popstate", handler);
1434
1434
  return () => window.removeEventListener("popstate", handler);
1435
1435
  }
1436
+ var OPEN_KEY = "lotics_open";
1437
+ var openTold;
1438
+ var openSubscribers = /* @__PURE__ */ new Set();
1439
+ function openRequested() {
1440
+ if (!isEmbedded()) return false;
1441
+ openTold ??= new URLSearchParams(window.location.search).has(OPEN_KEY);
1442
+ return openTold;
1443
+ }
1444
+ function settleOpen() {
1445
+ openTold = false;
1446
+ }
1447
+ function subscribeOpen(cb) {
1448
+ if (!isEmbedded()) return () => {
1449
+ };
1450
+ ensureListener();
1451
+ openSubscribers.add(cb);
1452
+ return () => {
1453
+ openSubscribers.delete(cb);
1454
+ };
1455
+ }
1436
1456
  function postHostNotification(message) {
1437
1457
  const hostOrigin = getHostOrigin();
1438
1458
  if (!hostOrigin) return;
@@ -1468,6 +1488,11 @@ function ensureListener() {
1468
1488
  for (const cb of urlStateSubscribers) cb(msg.params);
1469
1489
  return;
1470
1490
  }
1491
+ if (msg.type === "open") {
1492
+ openTold = true;
1493
+ for (const cb of openSubscribers) cb();
1494
+ return;
1495
+ }
1471
1496
  if (msg.type === "queriesChanged" && Array.isArray(msg.aliases)) {
1472
1497
  const aliases = msg.aliases.filter((a) => typeof a === "string");
1473
1498
  for (const cb of refetchSubscribers) cb(aliases);
@@ -1491,7 +1516,7 @@ function ensureListener() {
1491
1516
  pending.delete(msg.id);
1492
1517
  if (msg.type === "result") handler.resolve(msg.data);
1493
1518
  else handler.reject(new Error(msg.message ?? "RPC failed"));
1494
- if (pending.size === 0) scheduleDrawn(event.origin);
1519
+ if (handler.holdsCover) scheduleDrawn(event.origin);
1495
1520
  return;
1496
1521
  }
1497
1522
  const stream = streaming.get(msg.id);
@@ -1510,31 +1535,49 @@ function ensureListener() {
1510
1535
  });
1511
1536
  }
1512
1537
  var firstRequestSent = false;
1513
- var requestsSent = 0;
1538
+ var coverRequestsSent = 0;
1514
1539
  var drawnPosted = false;
1515
1540
  var drawnScheduled = false;
1541
+ var coverHolds = 0;
1542
+ var coverPendingCount = () => [...pending.values()].filter((one) => one.holdsCover).length;
1516
1543
  function scheduleDrawn(host) {
1517
- if (drawnPosted || drawnScheduled) return;
1544
+ if (drawnPosted || drawnScheduled || coverHolds > 0 || coverPendingCount() > 0) return;
1518
1545
  drawnScheduled = true;
1519
- const sentAtStart = requestsSent;
1546
+ const sentAtStart = coverRequestsSent;
1520
1547
  requestAnimationFrame(
1521
1548
  () => requestAnimationFrame(() => {
1522
1549
  drawnScheduled = false;
1523
- if (pending.size === 0 && requestsSent === sentAtStart) {
1550
+ if (coverHolds > 0 || coverPendingCount() > 0) return;
1551
+ if (coverRequestsSent === sentAtStart) {
1524
1552
  drawnPosted = true;
1525
1553
  window.parent.postMessage({ type: "drawn" }, host);
1526
- } else if (pending.size === 0) {
1554
+ } else {
1527
1555
  scheduleDrawn(host);
1528
1556
  }
1529
1557
  })
1530
1558
  );
1531
1559
  }
1532
- function rpcBridged(op, payload, host) {
1560
+ var outstandingHolds = /* @__PURE__ */ new Set();
1561
+ function holdDrawn() {
1562
+ coverHolds += 1;
1563
+ const release = () => {
1564
+ if (!outstandingHolds.delete(release)) return;
1565
+ coverHolds -= 1;
1566
+ const host = getHostOrigin();
1567
+ if (host) scheduleDrawn(host);
1568
+ };
1569
+ outstandingHolds.add(release);
1570
+ return release;
1571
+ }
1572
+ function releaseAllHolds() {
1573
+ for (const release of [...outstandingHolds]) release();
1574
+ }
1575
+ function rpcBridged(op, payload, host, holdsCover) {
1533
1576
  ensureListener();
1534
1577
  return new Promise((resolve, reject) => {
1535
1578
  const id = nextRpcId++;
1536
- pending.set(id, { resolve, reject });
1537
- requestsSent += 1;
1579
+ pending.set(id, { resolve, reject, holdsCover });
1580
+ if (holdsCover) coverRequestsSent += 1;
1538
1581
  if (firstRequestSent) {
1539
1582
  window.parent.postMessage({ id, op, payload }, host);
1540
1583
  return;
@@ -2128,8 +2171,13 @@ export {
2128
2171
  setUrlParams,
2129
2172
  peekUrlParams,
2130
2173
  subscribeUrlParams,
2174
+ openRequested,
2175
+ settleOpen,
2176
+ subscribeOpen,
2131
2177
  postHostNotification,
2132
2178
  subscribeQueriesChanged,
2179
+ holdDrawn,
2180
+ releaseAllHolds,
2133
2181
  rpcAgentRun,
2134
2182
  rpcAgentRunContinue
2135
2183
  };
package/dist/index.d.ts CHANGED
@@ -13,7 +13,7 @@ export type { ExportNarrowing } from "./shared_types.js";
13
13
  export type { AttachedFile, AttachmentPiles, AttachmentPilesOptions, AttachmentsOptions, AttachmentsState } from "./attachments.js";
14
14
  export { useComments, useCommentCounts } from "./comments.js";
15
15
  export type { AppComment, AppCommentAuthor, AppCommentFile, CommentsState, UseCommentsArgs, CommentCountsState, UseCommentCountsArgs, } from "./comments.js";
16
- export { useAppContext, useViewer, useWorkspaceCurrency, useWorkspaceTimezone } from "./viewer.js";
16
+ export { askAppContext, useAppContext, useViewer, useWorkspaceCurrency, useWorkspaceTimezone } from "./viewer.js";
17
17
  export type { AppAbsence } from "./shared_types.js";
18
18
  export { useOutsideLinks } from "./outside_link.js";
19
19
  export type { OutsideLinksState } from "./outside_link.js";
@@ -22,7 +22,7 @@ export type { UseRecording, UseRecordings } from "./recording.js";
22
22
  export type { RecordingState, RecordingInputs } from "./recording_state.js";
23
23
  export { requestGeofencedLocation, isWithinZone } from "./geolocation.js";
24
24
  export type { GeofenceZone, GeoCoords, GeofenceOutcome, GeofenceOptions } from "./geolocation.js";
25
- export { rpc, hostSpec, isEmbedded, installRpcTransport } from "./rpc.js";
25
+ export { rpc, hostSpec, holdDrawn, isEmbedded, installRpcTransport, openRequested, subscribeOpen } from "./rpc.js";
26
26
  export type { RpcOp, RpcTransport, HostSpec, AiContextValue, AiContextRecordRef } from "./rpc.js";
27
27
  export { openExternal } from "./open_external.js";
28
28
  export { askAi, type AskAiArgs } from "./ask_ai.js";
package/dist/index.js CHANGED
@@ -20,6 +20,7 @@ import {
20
20
  fixedDecimal,
21
21
  foldDiacritics,
22
22
  getUrlParams,
23
+ holdDrawn,
23
24
  hostSpec,
24
25
  installRpcTransport,
25
26
  isEmbedded,
@@ -30,6 +31,7 @@ import {
30
31
  moduloDecimal,
31
32
  multiplyDecimal,
32
33
  multiplyExactly,
34
+ openRequested,
33
35
  paramsEqual,
34
36
  peekUrlParams,
35
37
  percentOf,
@@ -38,6 +40,7 @@ import {
38
40
  readRecordingSnapshot,
39
41
  recordingStateOf,
40
42
  recordingsVersion,
43
+ releaseAllHolds,
41
44
  replaceRecordings,
42
45
  roundDecimal,
43
46
  rpc,
@@ -45,13 +48,14 @@ import {
45
48
  rpcAgentRunContinue,
46
49
  searchWords,
47
50
  setUrlParams,
51
+ subscribeOpen,
48
52
  subscribeQueriesChanged,
49
53
  subscribeRecordings,
50
54
  subscribeUrlParams,
51
55
  subtractDecimal,
52
56
  sumDecimal,
53
57
  urlParam
54
- } from "./chunk-KKZIOVCD.js";
58
+ } from "./chunk-446OTYGZ.js";
55
59
 
56
60
  // src/mount.tsx
57
61
  import { createRoot } from "react-dom/client";
@@ -166,6 +170,7 @@ function installVisibleErrorHandlers(container) {
166
170
  banner.style.cssText = "position: fixed; top: 0; left: 0; right: 0; padding: 12px 16px; background: #fef2f2; color: #991b1b; font: 13px/1.4 monospace; white-space: pre-wrap; border-bottom: 1px solid #fecaca; margin: 0; z-index: 99999;";
167
171
  banner.textContent = message2;
168
172
  container.parentElement?.insertBefore(banner, container);
173
+ releaseAllHolds();
169
174
  };
170
175
  window.addEventListener("error", (e) => {
171
176
  if (e.error !== null && e.error !== void 0) showError(`Uncaught error: ${e.message}
@@ -7707,8 +7712,30 @@ var SafeEvalAstFactory = class extends EvalAstFactory {
7707
7712
  }
7708
7713
  };
7709
7714
  var astFactory = new SafeEvalAstFactory();
7715
+ function spacedAfterStrings(expression) {
7716
+ let out = "";
7717
+ let quote = null;
7718
+ for (let at2 = 0; at2 < expression.length; at2++) {
7719
+ const ch = expression.charAt(at2);
7720
+ out += ch;
7721
+ if (quote === null) {
7722
+ if (ch === '"' || ch === "'") quote = ch;
7723
+ continue;
7724
+ }
7725
+ if (ch === "\\") {
7726
+ out += expression.charAt(at2 + 1);
7727
+ at2++;
7728
+ continue;
7729
+ }
7730
+ if (ch !== quote) continue;
7731
+ quote = null;
7732
+ const next = expression.charAt(at2 + 1);
7733
+ if (next !== "" && !/\s/.test(next)) out += " ";
7734
+ }
7735
+ return out;
7736
+ }
7710
7737
  function parseWholeExpression(expression, astFactory2) {
7711
- const parser = new Parser(expression, astFactory2);
7738
+ const parser = new Parser(spacedAfterStrings(expression), astFactory2);
7712
7739
  const expr2 = parser.parse();
7713
7740
  const leftover = parser._token;
7714
7741
  if (leftover !== void 0) {
@@ -10296,7 +10323,7 @@ async function fieldValues(walk, input) {
10296
10323
  for (const [field, inner] of Object.entries(input)) {
10297
10324
  const one = await attempt(walk, inner);
10298
10325
  if (one === UNKNOWN) unknown.push(field);
10299
- else cells[field] = one;
10326
+ else if (one !== void 0) cells[field] = one;
10300
10327
  }
10301
10328
  return { cells, unknown };
10302
10329
  }
@@ -10746,6 +10773,9 @@ async function readContext() {
10746
10773
  throw cause;
10747
10774
  }
10748
10775
  }
10776
+ function askAppContext() {
10777
+ readKey(APP_CONTEXT_KEY, readContext).catch(() => void 0);
10778
+ }
10749
10779
  function useAppContext() {
10750
10780
  const { data, error, refetch } = useKey(APP_CONTEXT_KEY, readContext, { focus: false, arrival: false });
10751
10781
  return {
@@ -10782,7 +10812,7 @@ function loadModel() {
10782
10812
  if (loaded !== null || hasMockFlag()) return;
10783
10813
  if (modelPromise !== null && (failedAtMs === null || Date.now() - failedAtMs < MODEL_RETRY_MS)) return;
10784
10814
  failedAtMs = null;
10785
- const attempt2 = Promise.all([rpc("write_model", {}), readKey(APP_CONTEXT_KEY, readContext)]).then(([model, context]) => {
10815
+ const attempt2 = Promise.all([rpc("write_model", {}, { holdsCover: false }), readKey(APP_CONTEXT_KEY, readContext)]).then(([model, context]) => {
10786
10816
  loaded = { model, tables: new Map(model.tables.map((table) => [table.id, table])), context };
10787
10817
  for (const { key, alias, askedAt, rows, since } of early.values()) noteAnswer(key, alias, askedAt, rows, since);
10788
10818
  early.clear();
@@ -11086,7 +11116,7 @@ function unpredicted(workflow, cause) {
11086
11116
  }
11087
11117
  function reportMisses(misses) {
11088
11118
  if (misses.length === 0 || hasMockFlag()) return;
11089
- rpc("prediction_miss", { misses: misses.slice(0, PREDICTION_MISSES_MAX) }).catch(
11119
+ rpc("prediction_miss", { misses: misses.slice(0, PREDICTION_MISSES_MAX) }, { holdsCover: false }).catch(
11090
11120
  (cause) => console.warn("Where the app's writes were drawn wrong or not at all could not be reported", cause)
11091
11121
  );
11092
11122
  }
@@ -15426,10 +15456,12 @@ function useFolderPick(table) {
15426
15456
  export {
15427
15457
  PENDING,
15428
15458
  askAi,
15459
+ askAppContext,
15429
15460
  buildChoiceOutput,
15430
15461
  downloadFile,
15431
15462
  exportApp,
15432
15463
  exportQuery,
15464
+ holdDrawn,
15433
15465
  hostSpec,
15434
15466
  installRpcTransport,
15435
15467
  isEmbedded,
@@ -15437,6 +15469,7 @@ export {
15437
15469
  mount,
15438
15470
  newRecordId,
15439
15471
  openExternal,
15472
+ openRequested,
15440
15473
  queryAll,
15441
15474
  readCreatedAt,
15442
15475
  readFiles,
@@ -15451,6 +15484,7 @@ export {
15451
15484
  requestGeofencedLocation,
15452
15485
  row,
15453
15486
  rpc,
15487
+ subscribeOpen,
15454
15488
  urlParam,
15455
15489
  useAgentRun,
15456
15490
  useAgentRuns,
package/dist/router.js CHANGED
@@ -1,24 +1,30 @@
1
1
  import {
2
2
  isEmbedded,
3
+ openRequested,
3
4
  postHostNotification,
4
- setUrlParams
5
- } from "./chunk-KKZIOVCD.js";
5
+ setUrlParams,
6
+ settleOpen,
7
+ subscribeOpen
8
+ } from "./chunk-446OTYGZ.js";
6
9
 
7
10
  // src/router.tsx
8
- import { useEffect } from "react";
11
+ import { useEffect, useLayoutEffect, useRef } from "react";
9
12
  import {
10
13
  BrowserRouter,
11
14
  Link,
12
15
  matchRoutes,
13
16
  useLocation,
17
+ useNavigate,
14
18
  useRoutes
15
19
  } from "react-router";
16
20
  import { jsx, jsxs } from "react/jsx-runtime";
17
21
  var LOC_KEY = "_loc";
18
22
  var HOST_KEY = "lotics_host";
23
+ var OPEN_KEY = "lotics_open";
19
24
  function screenHref(loc) {
20
25
  const search = new URLSearchParams(loc.search);
21
26
  search.delete(HOST_KEY);
27
+ search.delete(OPEN_KEY);
22
28
  const qs = search.toString();
23
29
  return loc.pathname + (qs ? `?${qs}` : "") + loc.hash;
24
30
  }
@@ -66,6 +72,30 @@ function HostScreenMirror({ routes, drawers }) {
66
72
  }, [pathname, openedAt, route]);
67
73
  return null;
68
74
  }
75
+ function OpenedFromHost() {
76
+ const navigate = useNavigate();
77
+ const { key } = useLocation();
78
+ const standing = useRef({ navigate, key });
79
+ useLayoutEffect(() => {
80
+ standing.current = { navigate, key };
81
+ });
82
+ const requestedAt = useRef(null);
83
+ useEffect(() => {
84
+ const open = () => {
85
+ requestedAt.current = standing.current.key;
86
+ standing.current.navigate({ pathname: "/", search: "" }, { replace: true });
87
+ };
88
+ if (openRequested()) open();
89
+ return subscribeOpen(open);
90
+ }, []);
91
+ useEffect(() => {
92
+ if (requestedAt.current === null || key === requestedAt.current) return;
93
+ requestedAt.current = null;
94
+ settleOpen();
95
+ postHostNotification({ type: "opened" });
96
+ }, [key]);
97
+ return null;
98
+ }
69
99
  function RoutedRoutes({ routes }) {
70
100
  return useRoutes(routes);
71
101
  }
@@ -123,6 +153,7 @@ function AppRouter({
123
153
  /* @__PURE__ */ jsx(NotFoundScreen, { home: firstScreenPath(routes), words: notFound })
124
154
  );
125
155
  return /* @__PURE__ */ jsxs(BrowserRouter, { children: [
156
+ embedded ? /* @__PURE__ */ jsx(OpenedFromHost, {}) : null,
126
157
  embedded ? /* @__PURE__ */ jsx(HostScreenMirror, { routes: claimed, drawers }) : null,
127
158
  /* @__PURE__ */ jsx(RoutedRoutes, { routes: claimed })
128
159
  ] });
package/dist/rpc.d.ts CHANGED
@@ -9,8 +9,8 @@ import { type UrlParams, type UrlParamsPatch } from "./url_params.js";
9
9
  * no credentials. The bridged wire must match `app_frame.tsx`:
10
10
  * app → host: { id, op, payload }, the first also carrying `reportsDrawn: true` and `load` (`AppLoadTiming`) when
11
11
  * the browser states any
12
- * app → host: { type: "drawn" }, once, after the first answer when no request has been in flight for two frames:
13
- * the app's first screen has its data
12
+ * app → host: { type: "drawn" }, once, when no hold (`holdDrawn`) is outstanding, every request that holds the
13
+ * cover is answered and none was sent for two frames: the app's first screen has its data
14
14
  * host → app: { id, type: "result", data } | { id, type: "error", message }
15
15
  */
16
16
  export type RpcOp = "query" | "export" | "field_options" | "workflow" | "agentRuns" | "agentRun.get" | "agentRun.cancel" | "upload" | "file.rename" | "members" | "context" | "spec" | "write_model" | "prediction_miss" | "openExternal" | "askAi" | "urlState.get" | "urlState.set" | "folder.get" | "folder.set" | "comments.list" | "comments.create" | "comments.update" | "comments.delete" | "comments.counts" | "recording.start" | "recording.stop" | "outsideLink.list" | "outsideLink.create" | "outsideLink.revoke";
@@ -58,6 +58,9 @@ export type HostNotification = {
58
58
  type: "screen_view";
59
59
  /** The route pattern that claims the screen (`/item/:id`), a `+<key>` per drawer open over it; never its address. */
60
60
  route: string;
61
+ } | {
62
+ /** The app replaced its screen with its opening address, as the host's `open` asked. */
63
+ type: "opened";
61
64
  };
62
65
  /** The app's identity: the host's context when bridged, `/by-subdomain` (no member) standalone. */
63
66
  export interface AppContext {
@@ -96,7 +99,11 @@ export declare function installRpcTransport(transport: RpcTransport): void;
96
99
  export type HostSpec = AppSpec;
97
100
  /** The app's spec, as the host hands it over the bridge. */
98
101
  export declare function hostSpec(): Promise<HostSpec>;
99
- export declare function rpc<T = unknown>(op: RpcOp, payload: unknown): Promise<T>;
102
+ export interface RpcOptions {
103
+ /** False for a request no screen draws from: the host's loading cover does not wait for it. Default true. */
104
+ holdsCover?: boolean;
105
+ }
106
+ export declare function rpc<T = unknown>(op: RpcOp, payload: unknown, options?: RpcOptions): Promise<T>;
100
107
  export declare function getUrlParams(): Promise<UrlParams>;
101
108
  /** A key set to `undefined` is cleared; every other param is kept, and no history entry added. */
102
109
  export declare function setUrlParams(patch: UrlParamsPatch): Promise<void>;
@@ -104,6 +111,12 @@ export declare function setUrlParams(patch: UrlParamsPatch): Promise<void>;
104
111
  export declare function peekUrlParams(): UrlParams;
105
112
  /** Back/forward and edited URLs: the host's `url-state` embedded, `popstate` standalone. */
106
113
  export declare function subscribeUrlParams(cb: (params: UrlParams) => void): () => void;
114
+ /** Whether the person has just opened the app and its first screen has not settled yet. */
115
+ export declare function openRequested(): boolean;
116
+ /** The router has moved to the opening address: what mounts from now on is not the open's. */
117
+ export declare function settleOpen(): void;
118
+ /** Calls `cb` each time the host opens the app again while its frame is kept; inert standalone. */
119
+ export declare function subscribeOpen(cb: () => void): () => void;
107
120
  /** No-ops standalone. */
108
121
  export declare function postHostNotification(message: HostNotification): void;
109
122
  /**
@@ -120,6 +133,13 @@ export declare function registerQueryAlias(alias: string): () => void;
120
133
  * tables a workflow touched.
121
134
  */
122
135
  export declare function notifyLocalWrite(reads?: readonly string[]): void;
136
+ /**
137
+ * Keeps the loading cover up until the returned release runs, for a page that has not yet drawn what its requests will
138
+ * feed. Releasing the last hold starts the two-frame check; releasing again does nothing.
139
+ */
140
+ export declare function holdDrawn(): () => void;
141
+ /** Lifts every hold still outstanding: an error is a screen, drawn as it is, so the cover has nothing left to wait for. */
142
+ export declare function releaseAllHolds(): void;
123
143
  /** Hands each raw SSE chunk to `onText`; `done` settles when the stream ends. */
124
144
  export declare function rpcAgentRun(payload: AgentRunPayload, onText: (chunk: string) => void, onRunId?: (runId: string) => void): AgentRunHandle;
125
145
  export interface AgentRunContinuePayload {
package/dist/viewer.d.ts CHANGED
@@ -3,6 +3,8 @@ import { type AppContext } from "./rpc.js";
3
3
  /** The store key the host's context is held under, read by every screen and by the write model alike. */
4
4
  export declare const APP_CONTEXT_KEY = "app-context";
5
5
  export declare function readContext(): Promise<AppContext>;
6
+ /** Asks the host for its context now, so the screen's later `useAppContext` finds the request already sent. */
7
+ export declare function askAppContext(): void;
6
8
  /**
7
9
  * The host's context, read once and shared. `settled` once it answered or
8
10
  * failed; on `failure` every fact is unknown, so draw the failure rather than
@@ -254,6 +254,8 @@ signed-in member, whether comments are enabled, the workspace's zone and currenc
254
254
  states — `resolved` once it answered, `settled` once it answered OR failed, and `failure` —
255
255
  `{ message, retry }`, `null` unless the read failed. Where it failed every fact is unknown, so a
256
256
  surface that dates or counts by them draws the failure rather than guessing the reader's zone.
257
+ The slot keeps a failed read until `retry` runs. `askAppContext()` asks the host now, so a page that
258
+ mounts later finds the request already sent.
257
259
 
258
260
  `absences` lists who in the organization is away, or will be (`AppAbsence`; one that has ended is left
259
261
  out): the member, the one standing in (`stand_in`), the first and last day (`starts_on`, `ends_on`,
@@ -49,6 +49,13 @@ routes, and splats all work. Inside the tree, use react-router normally:
49
49
  - **Its own entry.** `AppRouter` ships from `@lotics/app-sdk/router`
50
50
  (signature: `dist/router.d.ts`), apart from the hooks; its
51
51
  `react-router` peer is `^7 || ^8`.
52
+ - **Opened from the host, an app opens at its opening address, `/`.** When the person opens the app from the host's
53
+ sidebar or apps list, `AppRouter` replaces the entry stood on with `/` and no search, then tells the host with an
54
+ `opened` notification, which forgets the screen and filters it kept for the app; a reload, a shared link and
55
+ Back/Forward do not. A frame whose SDK predates this ignores the request and stays where it was.
56
+ `openRequested()` is true while that first screen mounts (never standalone), for a screen that restores what the
57
+ person left and must not; `subscribeOpen(cb)` calls `cb` each time the host opens the app again while its frame is
58
+ kept, for state the app holds beside the address. Both are exported from `@lotics/app-sdk`.
52
59
  - **An address no route claims says so.** `AppRouter` appends a catch-all at
53
60
  every level of the tree, so such a path renders a not-found screen — a
54
61
  message naming the path and a link to the first route — instead of an empty
package/docs/runtime.md CHANGED
@@ -159,12 +159,17 @@ results nor observe payloads. A host error with no message rejects as
159
159
 
160
160
  The host covers the app with its loading skeleton until the app's first screen
161
161
  has its data. The SDK says so for you: its first request carries
162
- `reportsDrawn: true`, and once every request is answered and none has been sent
163
- for two animation frames it posts `{ type: "drawn" }` to the host, once per page.
164
- A screen that issues its reads in its first render or effects is covered until
165
- they land; one that starts a read later than two frames after the previous
166
- answers is shown before it, and the host lifts the cover after a bounded time
167
- following the first request.
162
+ `reportsDrawn: true`, and it posts `{ type: "drawn" }` to the host, once per page,
163
+ when every cover-holding request is answered, no hold is outstanding, and none has
164
+ been sent for two animation frames. A request holds the cover unless it is sent
165
+ with `holdsCover: false` (background traffic: the write model, a prediction report).
166
+ `holdDrawn()` returns a release and keeps the cover up until it runs, for a page
167
+ that has not yet drawn what its requests will feed; releasing twice does nothing.
168
+ The SDK releases every hold when it shows an uncaught error or unhandled
169
+ rejection, so an error is drawn rather than covered. A screen that issues its
170
+ reads in its first render or effects is covered until they land; one that starts
171
+ a read later than two frames after the previous answers is shown before it, and
172
+ the host lifts the cover after a bounded time following the first request.
168
173
 
169
174
  **Warning:** a bridged call has **no timeout**. An op the host doesn't
170
175
  implement does reject (`"Unknown RPC op: …"`), but a message the host drops
@@ -243,8 +248,9 @@ const { rows } = await rpc<{ rows: Record<string, unknown>[] }>("query", {
243
248
  });
244
249
  ```
245
250
 
246
- `rpc<T = unknown>(op: RpcOp, payload: unknown): Promise<T>` sends one op over
247
- whichever transport is active. **Prefer the hooks** — they add the SDK's cache,
251
+ `rpc<T = unknown>(op: RpcOp, payload: unknown, options?: { holdsCover?: boolean }): Promise<T>`
252
+ sends one op over whichever transport is active; `holdsCover: false` marks a request no
253
+ screen draws from, which the loading cover does not wait for (default `true`). **Prefer the hooks** — they add the SDK's cache,
248
254
  loading/error state, analytics, and typing from your declared aliases; a file of
249
255
  every row of a set is `exportQuery`, made by the server ([data_fetching](./data_fetching.md)).
250
256
  `rpc()` exists for the imperative cases neither
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lotics/app-sdk",
3
- "version": "0.131.10",
3
+ "version": "0.131.12",
4
4
  "description": "The SDK a Lotics custom-code app reads and writes through — typed hooks over the host bridge, cell readers, mount() and AppRouter",
5
5
  "type": "module",
6
6
  "exports": {