fsanyoto commited on
Commit
602dda9
·
verified ·
1 Parent(s): 4258ee3

Deploy AIOS web (React glide grid + FastAPI slice)

Browse files
RELEASES.json CHANGED
@@ -1,5 +1,5 @@
1
  {
2
- "current": "5aef04c1e (5aef04c1e404)",
3
  "releases": [
4
  {
5
  "version": "v86",
 
1
  {
2
+ "current": "092e56b2ead (092e56b2ead3)",
3
  "releases": [
4
  {
5
  "version": "v86",
VERSION CHANGED
@@ -1 +1 @@
1
- 5aef04c1e (5aef04c1e404)
 
1
+ 092e56b2ead (092e56b2ead3)
api/routes_external.py CHANGED
@@ -2934,11 +2934,17 @@ def _query_database_page(session: Session, database: str, payload: dict):
2934
  "database": database, "fields": selected_keys, "filters": scoped.get("filters"),
2935
  "sorts": sorts, "aggregates": aggregates, "limit": limit,
2936
  })
2937
- # Bind a cursor to the live permission projection as well as the source revision. A field or
2938
- # row-scope revocation changes this hash on the next call, so an old page cannot skip into a
2939
- # newly narrowed result set. Only the digest enters the cursor; no record id or value does.
 
 
 
 
 
 
2940
  snapshot_digest = _json_digest({
2941
- "source_version": scoped.get("source_version"),
2942
  "visible_fields": [field["key"] for field in visible_fields
2943
  if isinstance(field, dict) and field.get("key") in visible_keys],
2944
  "permitted_pids": [row.get("pid") for row in rows],
 
2934
  "database": database, "fields": selected_keys, "filters": scoped.get("filters"),
2935
  "sorts": sorts, "aggregates": aggregates, "limit": limit,
2936
  })
2937
+ snapshot_source = scoped.get("source_version")
2938
+ if scoped.get("source_kind") == "runtime_cache":
2939
+ # Bind authorized content and linked permissions because pool timestamps differ by worker.
2940
+ snapshot_source = {
2941
+ "records": rows,
2942
+ "link_scope": (snapshot_source.get("link_scope")
2943
+ if isinstance(snapshot_source, dict) else None),
2944
+ }
2945
+ # Only the digest enters the cursor, including every visible field and permitted row.
2946
  snapshot_digest = _json_digest({
2947
+ "source_version": snapshot_source,
2948
  "visible_fields": [field["key"] for field in visible_fields
2949
  if isinstance(field, dict) and field.get("key") in visible_keys],
2950
  "permitted_pids": [row.get("pid") for row in rows],
web/public/AIOS_DEPLOY_RECEIPT CHANGED
@@ -1 +1 @@
1
- 9b2ce4c855610f54752a0f35e4049696a37d9723f1a6af5be2452e8e366090fc
 
1
+ 758f9a0b4bfb557f8c867bdf69a8f50cc45adcc8a4fd1a5669b8739c5cd26ae7
web/src/apps/catalog/useCatalogData.ts CHANGED
@@ -1,6 +1,6 @@
1
  import { useCallback, useEffect, useState } from "react";
2
- import { TypedRefusal, typedOpenApi, typedQuery } from "../../typed/client";
3
- import type { QueryRequest, QueryResponse, TypedOpenApi } from "../../typed/client";
4
  import { FILTER_OPS, isFilterGroup } from "../../customer-grid/types";
5
  import type { Field, FilterNode, FilterOp, Row, ViewConfig } from "../../customer-grid/types";
6
 
@@ -195,28 +195,73 @@ export function useCatalogData(database: string, scope: CatalogReadScope, search
195
 
196
  export interface CatalogRecords { fields: Field[]; rows: Row[] }
197
 
198
- /** Read every page of one query. The document is read once and one limit holds for the whole walk. */
199
  export async function loadCatalogRecords(database: string, scope: CatalogReadScope, signal: AbortSignal,
200
  query: Pick<CatalogPageRequest, "search" | "searchFields"> = {},
201
  onPage?: (data: CatalogRecords) => void): Promise<CatalogRecords> {
202
  const properties = await documentProperties(await typedOpenApi(signal), database);
203
- const cursors: (string | null)[] = [null];
204
- let limit = RECORDS_PAGE_SIZE;
205
- let data: CatalogRecords = { fields: [], rows: [] };
206
- for (;;) {
207
- const page = await loadCatalogData(database, scope, signal,
208
- { ...query, cursor: cursors[cursors.length - 1], limit, priorCursors: [...cursors] }, properties);
209
- limit = page.limit;
210
- data = { fields: page.fields, rows: [...data.rows, ...page.rows] };
211
- onPage?.(data);
212
- if (!page.nextCursor) return data;
213
- cursors.push(page.nextCursor);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
214
  }
215
  }
216
 
217
  type RecordsState = CatalogRecords & { key: string; loading: boolean; error: string };
218
 
219
- /** Hold every record of the query. Rows grow per page and loading stays true until the last page. */
220
  export function useCatalogRecords(database: string, scope: CatalogReadScope, searchFields: string[] = []) {
221
  const [search, setSearch] = useState("");
222
  const scopeJson = JSON.stringify(scope);
@@ -228,52 +273,147 @@ export function useCatalogRecords(database: string, scope: CatalogReadScope, sea
228
 
229
  useEffect(() => {
230
  const controller = new AbortController();
231
- setState((live) => ({ fields: live.fields, rows: [], key, loading: true, error: "" }));
 
232
  void loadCatalogRecords(database, JSON.parse(scopeJson) as CatalogReadScope, controller.signal,
233
  { search, searchFields: JSON.parse(searchJson) }, (data) => {
234
- if (!controller.signal.aborted) setState({ ...data, key, loading: true, error: "" });
 
235
  }).then((data) => {
236
  if (!controller.signal.aborted) setState({ ...data, key, loading: false, error: "" });
237
- }).catch((error: unknown) => {
238
- if (!controller.signal.aborted) setState((live) => ({ fields: live.fields, rows: [], key, loading: false,
239
- error: error instanceof Error ? error.message : "The App could not be loaded." }));
240
  });
241
  return () => controller.abort();
242
  }, [database, scopeJson, searchJson, search, key, attempt]);
243
 
244
- const live = state.key === key ? state : { fields: state.fields, rows: [] as Row[], key, loading: true, error: "" };
245
  return { fields: live.fields, rows: live.rows, loading: live.loading, error: live.error, retry, search, setSearch };
246
  }
247
 
248
- /** Resolve only saved product codes, independently of the visible search and filters. */
249
- export async function loadCatalogPlacements(database: string, key: string, codes: string[], signal: AbortSignal): Promise<Row[]> {
250
- const rows: Row[] = [];
251
- for (const code of new Set(codes)) {
252
- const scope: CatalogReadScope = { filters: [{ id: "placement", colId: key, op: "eq", value: code }], filterConj: "and", sorts: [] };
253
- const page = await loadCatalogData(database, scope, signal);
254
- if (page.nextCursor || page.rows.length !== 1 || String(page.rows[0][key]) !== code) throw new Error(key === "pid"
255
- ? "A selected customer could not be confirmed." : `The saved product ${code} could not be confirmed.`);
256
- rows.push(page.rows[0]);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
257
  }
258
- return rows;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
259
  }
260
 
261
- export function useCatalogPlacements(database: string, key: string, codes: string[]) {
262
  const codesJson = JSON.stringify([...new Set(codes)].sort());
263
- const requestKey = `${database}::${key}::${codesJson}`;
264
  const [attempt, setAttempt] = useState(0);
265
- const [state, setState] = useState({ key: "", rows: [] as Row[], loading: true, error: "" });
266
  useEffect(() => {
267
  const controller = new AbortController();
268
- setState({ key: requestKey, rows: [], loading: true, error: "" });
269
- void loadCatalogPlacements(database, key, JSON.parse(codesJson), controller.signal).then((rows) => {
270
- if (!controller.signal.aborted) setState({ key: requestKey, rows, loading: false, error: "" });
 
 
271
  }).catch((error: unknown) => {
272
- if (!controller.signal.aborted) setState({ key: requestKey, rows: [], loading: false,
273
- error: error instanceof Error ? error.message : "Saved products could not be loaded." });
 
 
 
274
  });
275
  return () => controller.abort();
276
- }, [database, key, codesJson, requestKey, attempt]);
277
- return { ...(state.key === requestKey ? state : { rows: [], loading: true, error: "" }),
278
  retry: () => setAttempt((value) => value + 1) };
279
  }
 
1
  import { useCallback, useEffect, useState } from "react";
2
+ import { TypedRefusal, typedOpenApi, typedQuery, typedSchema } from "../../typed/client";
3
+ import type { DatabaseSchema, QueryRequest, QueryResponse, TypedOpenApi } from "../../typed/client";
4
  import { FILTER_OPS, isFilterGroup } from "../../customer-grid/types";
5
  import type { Field, FilterNode, FilterOp, Row, ViewConfig } from "../../customer-grid/types";
6
 
 
195
 
196
  export interface CatalogRecords { fields: Field[]; rows: Row[] }
197
 
198
+ /** Read every page with one document and one negotiated limit across at most two stale restarts. */
199
  export async function loadCatalogRecords(database: string, scope: CatalogReadScope, signal: AbortSignal,
200
  query: Pick<CatalogPageRequest, "search" | "searchFields"> = {},
201
  onPage?: (data: CatalogRecords) => void): Promise<CatalogRecords> {
202
  const properties = await documentProperties(await typedOpenApi(signal), database);
203
+ signal.throwIfAborted();
204
+ const filters = typedFilters(scope);
205
+ const search = query.search?.trim();
206
+ const searchNodes = search ? [...new Set(query.searchFields)].filter(Boolean).map((colId) =>
207
+ ({ colId, op: "contains", value: search })) : [];
208
+ if (search && !searchNodes.length) throw new Error("Choose a search field.");
209
+ const body: QueryRequest = {
210
+ limit: RECORDS_PAGE_SIZE,
211
+ filters: searchNodes.length ? { conj: "and", nodes: [
212
+ ...(filters ? [{ conj: filters.conj, children: filters.nodes }] : []),
213
+ { conj: "or", children: searchNodes },
214
+ ] } as QueryRequest["filters"] : filters,
215
+ sorts: scope.sorts.map((sort) => ({ field: sort.colId, direction: sort.dir })),
216
+ };
217
+ let limit: number | null = null;
218
+ for (let restarts = 0; ; restarts += 1) {
219
+ const cursors: (string | null)[] = [null];
220
+ let data: CatalogRecords = { fields: [], rows: [] };
221
+ try {
222
+ for (;;) {
223
+ signal.throwIfAborted();
224
+ const cursor = cursors[cursors.length - 1];
225
+ let response: QueryResponse;
226
+ if (limit === null) {
227
+ const first = await firstPage(database, body, signal);
228
+ response = first.response;
229
+ limit = first.limit;
230
+ } else {
231
+ response = await typedQuery(database, { ...body, cursor, limit }, signal);
232
+ }
233
+ signal.throwIfAborted();
234
+ if (response.database !== database || !Array.isArray(response.records) || !Array.isArray(response.fields) ||
235
+ response.page?.returned !== response.records.length || response.records.length > limit ||
236
+ typeof response.page.has_more !== "boolean") {
237
+ throw new Error("The App page could not be confirmed.");
238
+ }
239
+ const nextCursor = response.page.has_more ? response.page.next_cursor : null;
240
+ if (response.page.has_more && (typeof nextCursor !== "string" || !nextCursor || cursors.includes(nextCursor) ||
241
+ !response.page.returned)) {
242
+ throw new Error("The App cursor did not advance. Retry the request.");
243
+ }
244
+ const fields = response.fields.filter((field) => Object.hasOwn(properties, field.key)).map<Field>((field) => ({
245
+ ...field, label: field.label ?? field.key, type: field.type as Field["type"],
246
+ source: field.source === "odoo" ? "odoo" : "overlay",
247
+ }));
248
+ const rows = response.records.map((record) => projectRow(record, properties));
249
+ data = { fields, rows: [...data.rows, ...rows] };
250
+ onPage?.(data);
251
+ signal.throwIfAborted();
252
+ if (!nextCursor) return data;
253
+ cursors.push(nextCursor);
254
+ }
255
+ } catch (error) {
256
+ signal.throwIfAborted();
257
+ if (!(error instanceof TypedRefusal) || error.code !== "query_cursor_stale" || restarts >= 2) throw error;
258
+ }
259
  }
260
  }
261
 
262
  type RecordsState = CatalogRecords & { key: string; loading: boolean; error: string };
263
 
264
+ /** Retain rows for the current query while a new walk loads or fails. */
265
  export function useCatalogRecords(database: string, scope: CatalogReadScope, searchFields: string[] = []) {
266
  const [search, setSearch] = useState("");
267
  const scopeJson = JSON.stringify(scope);
 
273
 
274
  useEffect(() => {
275
  const controller = new AbortController();
276
+ setState((live) => ({ fields: live.key === key ? live.fields : [], rows: live.key === key ? live.rows : [],
277
+ key, loading: true, error: "" }));
278
  void loadCatalogRecords(database, JSON.parse(scopeJson) as CatalogReadScope, controller.signal,
279
  { search, searchFields: JSON.parse(searchJson) }, (data) => {
280
+ if (!controller.signal.aborted) setState((live) => live.key === key && live.rows.length > data.rows.length
281
+ ? live : { ...data, key, loading: true, error: "" });
282
  }).then((data) => {
283
  if (!controller.signal.aborted) setState({ ...data, key, loading: false, error: "" });
284
+ }).catch(() => {
285
+ if (!controller.signal.aborted) setState((live) => ({ ...live, key, loading: false,
286
+ error: "Could not load records" }));
287
  });
288
  return () => controller.abort();
289
  }, [database, scopeJson, searchJson, search, key, attempt]);
290
 
291
+ const live = state.key === key ? state : { fields: [], rows: [] as Row[], key, loading: true, error: "" };
292
  return { fields: live.fields, rows: live.rows, loading: live.loading, error: live.error, retry, search, setSearch };
293
  }
294
 
295
+ function placementProperties(schema: DatabaseSchema, database: string): Properties {
296
+ if (schema.database !== database || !Array.isArray(schema.fields) || schema.fields.some((field) =>
297
+ !field || typeof field.key !== "string" || !field.key || typeof field.type !== "string")) {
298
+ throw new Error("The Catalog database is unavailable.");
299
+ }
300
+ return Object.fromEntries(schema.fields.map((field) => {
301
+ const numeric = ["number", "int", "rating", "currency", "pct", "metric", "formula", "rollup"].includes(field.type);
302
+ const boolean = field.type === "checkbox" && ["mirror_user_table", "runtime_cache"].includes(String(schema.source_kind));
303
+ return [field.key, { type: field.type === "multiselect" ? ["string", "array", "null"]
304
+ : numeric ? ["number", "string", "null"] : [boolean ? "boolean" : "string", "null"] }];
305
+ }));
306
+ }
307
+
308
+ type PlacementProgress = { rows: Row[]; errors: Record<string, string> };
309
+
310
+ /** Resolve saved codes in order. A progress callback opts into independent results. */
311
+ export async function loadCatalogPlacements(database: string, key: string, codes: string[], signal: AbortSignal,
312
+ onProgress?: (data: PlacementProgress) => void): Promise<Row[]> {
313
+ signal.throwIfAborted();
314
+ const unique = [...new Set(codes)];
315
+ if (!unique.length) return [];
316
+ const schema = await typedSchema(database, signal);
317
+ const properties = placementProperties(schema, database);
318
+ signal.throwIfAborted();
319
+ const rows: (Row | undefined)[] = new Array(unique.length);
320
+ const errors: Record<string, string> = {};
321
+ const resolved = () => rows.filter((row): row is Row => row !== undefined);
322
+ const batchIdentities = database === "customer_data" && key === "pid" && schema.fields.some((field) =>
323
+ field.key === "partner_id" && field.source === "odoo" && ["int", "number"].includes(field.type)) &&
324
+ unique.every((code) => /^[1-9]\d*$/.test(code) && Number.isSafeInteger(Number(code)));
325
+ if (batchIdentities) {
326
+ for (let offset = 0; offset < unique.length; offset += 100) {
327
+ signal.throwIfAborted();
328
+ const batch = unique.slice(offset, offset + 100);
329
+ try {
330
+ const requested = new Set(batch);
331
+ const found = new Map<string, Row>();
332
+ const cursors: (string | null)[] = [null];
333
+ let limit = 100;
334
+ const scope: CatalogReadScope = { filters: [{ id: "placement", colId: "partner_id", op: "isAnyOf", value: "", values: batch }],
335
+ filterConj: "and", sorts: [] };
336
+ for (;;) {
337
+ const page = await loadCatalogData(database, scope, signal,
338
+ { cursor: cursors[cursors.length - 1], limit, priorCursors: [...cursors] }, properties);
339
+ limit = page.limit;
340
+ for (const row of page.rows) {
341
+ const code = String(row.pid);
342
+ if (!requested.has(code) || String(row.partner_id) !== code || found.has(code)) {
343
+ throw new Error("A selected customer batch could not be confirmed.");
344
+ }
345
+ found.set(code, row);
346
+ }
347
+ if (!page.nextCursor) break;
348
+ cursors.push(page.nextCursor);
349
+ }
350
+ for (const [index, code] of batch.entries()) {
351
+ const row = found.get(code);
352
+ if (row) rows[offset + index] = row;
353
+ else {
354
+ const message = "A selected customer could not be confirmed.";
355
+ if (!onProgress) throw new Error(message);
356
+ errors[code] = message;
357
+ }
358
+ }
359
+ } catch (error: unknown) {
360
+ signal.throwIfAborted();
361
+ if (!onProgress) throw error;
362
+ for (const code of batch) errors[code] = error instanceof Error ? error.message : "The selected record could not be loaded.";
363
+ }
364
+ signal.throwIfAborted();
365
+ onProgress?.({ rows: resolved(), errors: { ...errors } });
366
+ }
367
+ signal.throwIfAborted();
368
+ return resolved();
369
  }
370
+ let next = 0;
371
+ let rejected = false;
372
+ await Promise.all(Array.from({ length: Math.min(6, unique.length) }, async () => {
373
+ while (next < unique.length && !rejected) {
374
+ signal.throwIfAborted();
375
+ const index = next++;
376
+ const code = unique[index];
377
+ try {
378
+ const scope: CatalogReadScope = { filters: [{ id: "placement", colId: key, op: "eq", value: code }], filterConj: "and", sorts: [] };
379
+ const page = await loadCatalogData(database, scope, signal, {}, properties);
380
+ if (page.nextCursor || page.rows.length !== 1 || String(page.rows[0][key]) !== code) throw new Error(key === "pid"
381
+ ? "A selected customer could not be confirmed." : `The saved product ${code} could not be confirmed.`);
382
+ rows[index] = page.rows[0];
383
+ } catch (error: unknown) {
384
+ signal.throwIfAborted();
385
+ if (!onProgress) { rejected = true; throw error; }
386
+ errors[code] = error instanceof Error ? error.message : "The selected record could not be loaded.";
387
+ }
388
+ signal.throwIfAborted();
389
+ onProgress?.({ rows: resolved(), errors: { ...errors } });
390
+ }
391
+ }));
392
+ signal.throwIfAborted();
393
+ return resolved();
394
  }
395
 
396
+ export function useCatalogPlacements(database: string, key: string, codes: string[], partial = false) {
397
  const codesJson = JSON.stringify([...new Set(codes)].sort());
398
+ const requestKey = `${database}::${key}::${codesJson}::${partial}`;
399
  const [attempt, setAttempt] = useState(0);
400
+ const [state, setState] = useState({ key: "", rows: [] as Row[], loading: true, error: "", errors: {} as Record<string, string> });
401
  useEffect(() => {
402
  const controller = new AbortController();
403
+ setState({ key: requestKey, rows: [], loading: true, error: "", errors: {} });
404
+ void loadCatalogPlacements(database, key, JSON.parse(codesJson), controller.signal, partial ? (data) => {
405
+ if (!controller.signal.aborted) setState({ ...data, key: requestKey, loading: true, error: "" });
406
+ } : undefined).then((rows) => {
407
+ if (!controller.signal.aborted) setState((live) => ({ ...live, key: requestKey, rows, loading: false, error: "" }));
408
  }).catch((error: unknown) => {
409
+ if (!controller.signal.aborted) setState((live) => {
410
+ const message = error instanceof Error ? error.message : "Saved products could not be loaded.";
411
+ return { key: requestKey, rows: partial ? live.rows : [], loading: false, error: message,
412
+ errors: partial ? Object.fromEntries((JSON.parse(codesJson) as string[]).map((code) => [code, message])) : {} };
413
+ });
414
  });
415
  return () => controller.abort();
416
+ }, [database, key, codesJson, requestKey, partial, attempt]);
417
+ return { ...(state.key === requestKey ? state : { rows: [], loading: true, error: "", errors: {} }),
418
  retry: () => setAttempt((value) => value + 1) };
419
  }
web/src/customer-grid/MapView.tsx CHANGED
@@ -64,6 +64,7 @@ import { AppFrame } from "./AppFrame";
64
  import { AppFrameMarks } from "../apps/templateMarks";
65
  import { CatalogApp } from "../apps/catalog/CatalogApp";
66
  import { useCatalogPlacements, useCatalogRecords } from "../apps/catalog/useCatalogData";
 
67
  import type { CatalogApplicationDefinition, CatalogViewSpec } from "./CatalogView";
68
  import { applicationTemplateSurface } from "./viewModes";
69
  import { LAND_PATH, LAKE_PATHS } from "./mapGeometry";
@@ -5124,7 +5125,7 @@ function RouteApplicationMapView({ props, titleKey, applicationId }: {
5124
  sorts: props.activeView?.config.sorts ?? [],
5125
  }, [titleKey]);
5126
  const [search, setSearch] = useState("");
5127
- const selected = useCatalogPlacements(props.tableKey, "pid", Array.from(props.selectedPids, String));
5128
  const selectedPending = selected.loading && props.selectedPids.size > 0;
5129
  const allRows = selected.rows.length
5130
  ? [...new Map([...data.rows, ...selected.rows].map((row) => [row.pid, row])).values()] : data.rows;
@@ -5155,7 +5156,8 @@ function RouteApplicationMapView({ props, titleKey, applicationId }: {
5155
  if (allRows.some((candidate) => candidate.pid === pid))
5156
  setCustomerPid(pid);
5157
  };
5158
- return <MapViewSurface {...props} rows={data.rows} allRows={allRows}
 
5159
  recordsPending={data.loading || selected.loading || !!selected.error}
5160
  applicationId={applicationId} onOpen={openCustomer} customerDetail={customerDetail}
5161
  onCustomerBack={() => setCustomerPid(null)} routingFilters={<>
@@ -5173,9 +5175,10 @@ function RouteApplicationMapView({ props, titleKey, applicationId }: {
5173
  </form>
5174
  {data.error && <div className="cg-catalog-library-error" role="alert"><span>{data.error}</span>
5175
  <button className="cg-btn" type="button" disabled={data.loading} onClick={data.retry}>Retry</button></div>}
5176
- {selected.error && <div className="cg-catalog-library-error" role="alert"><span>{selected.error}</span>
 
5177
  <button className="cg-btn" type="button" disabled={selected.loading} onClick={selected.retry}>Retry selected</button></div>}
5178
- </>} />;
5179
  }
5180
 
5181
  /** Resolve an Application deep link from the registry before selecting a specialized renderer.
 
64
  import { AppFrameMarks } from "../apps/templateMarks";
65
  import { CatalogApp } from "../apps/catalog/CatalogApp";
66
  import { useCatalogPlacements, useCatalogRecords } from "../apps/catalog/useCatalogData";
67
+ import { RoutingStopLabelErrors } from "./routeZoneApi";
68
  import type { CatalogApplicationDefinition, CatalogViewSpec } from "./CatalogView";
69
  import { applicationTemplateSurface } from "./viewModes";
70
  import { LAND_PATH, LAKE_PATHS } from "./mapGeometry";
 
5125
  sorts: props.activeView?.config.sorts ?? [],
5126
  }, [titleKey]);
5127
  const [search, setSearch] = useState("");
5128
+ const selected = useCatalogPlacements(props.tableKey, "pid", Array.from(props.selectedPids, String), true);
5129
  const selectedPending = selected.loading && props.selectedPids.size > 0;
5130
  const allRows = selected.rows.length
5131
  ? [...new Map([...data.rows, ...selected.rows].map((row) => [row.pid, row])).values()] : data.rows;
 
5156
  if (allRows.some((candidate) => candidate.pid === pid))
5157
  setCustomerPid(pid);
5158
  };
5159
+ return <RoutingStopLabelErrors.Provider value={selected.errors}>
5160
+ <MapViewSurface {...props} rows={data.rows} allRows={allRows}
5161
  recordsPending={data.loading || selected.loading || !!selected.error}
5162
  applicationId={applicationId} onOpen={openCustomer} customerDetail={customerDetail}
5163
  onCustomerBack={() => setCustomerPid(null)} routingFilters={<>
 
5175
  </form>
5176
  {data.error && <div className="cg-catalog-library-error" role="alert"><span>{data.error}</span>
5177
  <button className="cg-btn" type="button" disabled={data.loading} onClick={data.retry}>Retry</button></div>}
5178
+ {(selected.error || Object.keys(selected.errors).length > 0) && <div className="cg-catalog-library-error" role="alert">
5179
+ <span>{selected.error || "Some stops could not be loaded."}</span>
5180
  <button className="cg-btn" type="button" disabled={selected.loading} onClick={selected.retry}>Retry selected</button></div>}
5181
+ </>} /></RoutingStopLabelErrors.Provider>;
5182
  }
5183
 
5184
  /** Resolve an Application deep link from the registry before selecting a specialized renderer.
web/src/customer-grid/RouteNav.tsx CHANGED
@@ -1,4 +1,4 @@
1
- import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
2
  import type { ReactElement } from "react";
3
  import { createPortal } from "react-dom";
4
  import { FolderMark } from "./icons";
@@ -19,6 +19,7 @@ import {
19
  routeLocationPartition,
20
  routeApplicationPath,
21
  routeStopIdentity,
 
22
  } from "./routeZoneApi";
23
  // W51-T28 / R6 + C8 — the wave-51 base kit's ONE confirm dialog. Consumed, never re-implemented.
24
  import { TruncatedName } from "../home/TruncatedName";
@@ -296,6 +297,7 @@ function RouteNavContent({ routes, folders, selectedIds, activeRouteId, sources,
296
  /** False until the first saved-Route read answers, so an empty list is not read as "none". */
297
  routesLoaded?: boolean;
298
  }) {
 
299
  /* ⭐⭐ OWNER 2026-08-31 item 3 - THE ROUTES RAIL IS THE VIEWS RAIL, NOT A COUSIN OF IT.
300
  Owner: *"I need the routes LIST navigation and the routes itself to have the exact same
301
  interface just like how we have it with view, where you can just click it and drag it AND
@@ -1127,7 +1129,8 @@ function RouteNavContent({ routes, folders, selectedIds, activeRouteId, sources,
1127
  // the name on paper is the same function as the name on screen, and every stop is on the
1128
  // page whether or not it has a coordinate.
1129
  const printStops = routePrintStops(
1130
- stopIds, stopLabels, stopCoords, routeStopIdentity, reversePrintLabels,
 
1131
  );
1132
  // ⚠ THE NAME HAS EXACTLY ONE WRITER NOW. `Save` below sends only the Maps URL, so an
1133
  // abandoned draft in the title can never be committed by a control that says nothing about
@@ -1216,9 +1219,9 @@ function RouteNavContent({ routes, folders, selectedIds, activeRouteId, sources,
1216
  onChange={(e) => onRouteStartChange?.(e.target.value ? Number(e.target.value) : null)}>
1217
  <option value="">Automatic</option>
1218
  {startUnavailable && <option value={routeStartPid!} disabled>
1219
- {routeStopIdentity(stopLabels[routeStartPid!], routeStartPid!)} (no map location)
1220
  </option>}
1221
- {locatedPids.map((pid) => <option key={pid} value={pid}>{routeStopIdentity(stopLabels[pid], pid)}</option>)}
1222
  </select>
1223
  </label>
1224
  <label>End
@@ -1228,9 +1231,9 @@ function RouteNavContent({ routes, folders, selectedIds, activeRouteId, sources,
1228
  onChange={(e) => onRouteEndChange?.(e.target.value ? Number(e.target.value) : null)}>
1229
  <option value="">Automatic</option>
1230
  {endUnavailable && <option value={routeEndPid!} disabled>
1231
- {routeStopIdentity(stopLabels[routeEndPid!], routeEndPid!)} (no map location)
1232
  </option>}
1233
- {locatedPids.filter((pid) => pid !== routeStartPid).map((pid) => <option key={pid} value={pid}>{routeStopIdentity(stopLabels[pid], pid)}</option>)}
1234
  </select>
1235
  </label>
1236
  </div>
@@ -1375,8 +1378,8 @@ function RouteNavContent({ routes, folders, selectedIds, activeRouteId, sources,
1375
  hover and focus. The id moves to the wrapper because TruncatedName takes none. */}
1376
  <span className="cg-view-text" id={`cg-route-stop-name-${pid}`}>
1377
  {/* Keyed by seat: a reorder remounts the tip, so it never paints at a stale row. */}
1378
- <TruncatedName key={index} className="cg-view-name">
1379
- {routeStopIdentity(stopLabels[pid], pid)}
1380
  </TruncatedName>
1381
  </span>
1382
  </button>
@@ -1412,7 +1415,7 @@ function RouteNavContent({ routes, folders, selectedIds, activeRouteId, sources,
1412
  <div role="list" aria-label="Route stops without a map location">
1413
  {unlocated.map((stop) => (
1414
  <p className="cg-w46-timer-note" role="listitem" key={stop.pid}>
1415
- <strong>{stop.label}</strong>: {stop.reason}
1416
  </p>
1417
  ))}
1418
  </div>
 
1
+ import { useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
2
  import type { ReactElement } from "react";
3
  import { createPortal } from "react-dom";
4
  import { FolderMark } from "./icons";
 
19
  routeLocationPartition,
20
  routeApplicationPath,
21
  routeStopIdentity,
22
+ RoutingStopLabelErrors,
23
  } from "./routeZoneApi";
24
  // W51-T28 / R6 + C8 — the wave-51 base kit's ONE confirm dialog. Consumed, never re-implemented.
25
  import { TruncatedName } from "../home/TruncatedName";
 
297
  /** False until the first saved-Route read answers, so an empty list is not read as "none". */
298
  routesLoaded?: boolean;
299
  }) {
300
+ const stopLabelErrors = useContext(RoutingStopLabelErrors);
301
  /* ⭐⭐ OWNER 2026-08-31 item 3 - THE ROUTES RAIL IS THE VIEWS RAIL, NOT A COUSIN OF IT.
302
  Owner: *"I need the routes LIST navigation and the routes itself to have the exact same
303
  interface just like how we have it with view, where you can just click it and drag it AND
 
1129
  // the name on paper is the same function as the name on screen, and every stop is on the
1130
  // page whether or not it has a coordinate.
1131
  const printStops = routePrintStops(
1132
+ stopIds, stopLabels, stopCoords,
1133
+ (label, pid) => routeStopIdentity(label, pid, stopLabelErrors[pid]), reversePrintLabels,
1134
  );
1135
  // ⚠ THE NAME HAS EXACTLY ONE WRITER NOW. `Save` below sends only the Maps URL, so an
1136
  // abandoned draft in the title can never be committed by a control that says nothing about
 
1219
  onChange={(e) => onRouteStartChange?.(e.target.value ? Number(e.target.value) : null)}>
1220
  <option value="">Automatic</option>
1221
  {startUnavailable && <option value={routeStartPid!} disabled>
1222
+ {routeStopIdentity(stopLabels[routeStartPid!], routeStartPid!, stopLabelErrors[routeStartPid!])} (no map location)
1223
  </option>}
1224
+ {locatedPids.map((pid) => <option key={pid} value={pid}>{routeStopIdentity(stopLabels[pid], pid, stopLabelErrors[pid])}</option>)}
1225
  </select>
1226
  </label>
1227
  <label>End
 
1231
  onChange={(e) => onRouteEndChange?.(e.target.value ? Number(e.target.value) : null)}>
1232
  <option value="">Automatic</option>
1233
  {endUnavailable && <option value={routeEndPid!} disabled>
1234
+ {routeStopIdentity(stopLabels[routeEndPid!], routeEndPid!, stopLabelErrors[routeEndPid!])} (no map location)
1235
  </option>}
1236
+ {locatedPids.filter((pid) => pid !== routeStartPid).map((pid) => <option key={pid} value={pid}>{routeStopIdentity(stopLabels[pid], pid, stopLabelErrors[pid])}</option>)}
1237
  </select>
1238
  </label>
1239
  </div>
 
1378
  hover and focus. The id moves to the wrapper because TruncatedName takes none. */}
1379
  <span className="cg-view-text" id={`cg-route-stop-name-${pid}`}>
1380
  {/* Keyed by seat: a reorder remounts the tip, so it never paints at a stale row. */}
1381
+ <TruncatedName key={index} className={"cg-view-name" + (!stopLabels[pid] && stopLabelErrors[pid] ? " cg-w44-route-order-error" : "")}>
1382
+ {routeStopIdentity(stopLabels[pid], pid, stopLabelErrors[pid])}
1383
  </TruncatedName>
1384
  </span>
1385
  </button>
 
1415
  <div role="list" aria-label="Route stops without a map location">
1416
  {unlocated.map((stop) => (
1417
  <p className="cg-w46-timer-note" role="listitem" key={stop.pid}>
1418
+ <strong>{routeStopIdentity(stopLabels[stop.pid], stop.pid, stopLabelErrors[stop.pid])}</strong>: {stop.reason}
1419
  </p>
1420
  ))}
1421
  </div>
web/src/customer-grid/routeZoneApi.ts CHANGED
@@ -1,3 +1,4 @@
 
1
  import type {
2
  RouteDeliveryRecipientDirectory,
3
  RouteDeliveryDto,
@@ -11,6 +12,8 @@ export const ROUTE_INVENTORY_PATH = "/api/v1/customers/routes";
11
  export type RouteStopLabels = Record<number, { name: string; address: string }>;
12
  export type RouteStopCoords = Record<number, { lat: number; lon: number }>;
13
 
 
 
14
  export type UnlocatedRouteStop = {
15
  pid: number;
16
  label: string;
@@ -27,7 +30,9 @@ export type RouteLocationPartition = {
27
  export function routeStopIdentity(
28
  label: { name: string; address: string } | undefined,
29
  pid: number,
 
30
  ): string {
 
31
  const name = (label?.name || "").trim();
32
  if (name) return name;
33
  const address = (label?.address || "").trim();
 
1
+ import { createContext } from "react";
2
  import type {
3
  RouteDeliveryRecipientDirectory,
4
  RouteDeliveryDto,
 
12
  export type RouteStopLabels = Record<number, { name: string; address: string }>;
13
  export type RouteStopCoords = Record<number, { lat: number; lon: number }>;
14
 
15
+ export const RoutingStopLabelErrors = createContext<Readonly<Record<string, string>>>({});
16
+
17
  export type UnlocatedRouteStop = {
18
  pid: number;
19
  label: string;
 
30
  export function routeStopIdentity(
31
  label: { name: string; address: string } | undefined,
32
  pid: number,
33
+ error?: string,
34
  ): string {
35
+ if (!label) return error ? `Stop ${pid}: ${error}` : "Loading stop";
36
  const name = (label?.name || "").trim();
37
  if (name) return name;
38
  const address = (label?.address || "").trim();