fsanyoto commited on
Commit
dbefc92
·
verified ·
1 Parent(s): d8dba74

Deploy AIOS web (React glide grid + FastAPI slice)

Browse files
RELEASES.json CHANGED
@@ -1,4 +1,4 @@
1
  {
2
- "current": "2ede37eaa",
3
  "releases": []
4
  }
 
1
  {
2
+ "current": "ac66dbd61035",
3
  "releases": []
4
  }
VERSION CHANGED
@@ -1 +1 @@
1
- 2ede37eaa
 
1
+ ac66dbd61035
api/routes_products.py CHANGED
@@ -763,7 +763,7 @@ def patch_product(pid: int, body: dict = Body(default=None),
763
  if not updates:
764
  raise err(400, "empty_patch", "no fields to update")
765
  g = (_builtin_note_context(session, MODULE, pid) if notes is not None else
766
- product_assembly(session, consume_corrections=False))
767
  if pid not in g["pids"]:
768
  # 403, not 404 — the code may exist; it is simply not in this session's catalogue.
769
  from deps import _principal
 
763
  if not updates:
764
  raise err(400, "empty_patch", "no fields to update")
765
  g = (_builtin_note_context(session, MODULE, pid) if notes is not None else
766
+ product_assembly(session, consume_corrections=False, needed=set()))
767
  if pid not in g["pids"]:
768
  # 403, not 404 — the code may exist; it is simply not in this session's catalogue.
769
  from deps import _principal
web/public/AIOS_DEPLOY_RECEIPT CHANGED
@@ -1 +1 @@
1
- 2fcd6f38b9a11acdf50d3de247083b252536285ef4d855def136d5cce1508262
 
1
+ 25fc10c1d8940fd073f8cd9ca18c3d5c620eae250c96963b2892518f75c59f50
web/src/customer-grid/CustomerGrid.tsx CHANGED
@@ -39,7 +39,7 @@ import { acceptsQueryPreview, routeQueryViewMutation } from "./queryPreview";
39
  // only its own source text could otherwise be checked.
40
  import { PAGE_SIZES, fetchAggregates, fetchTableWindow, personalGridLayout, readPageSize, recordIdsKey,
41
  writePageSize } from "./apiBridge";
42
- import { ACCESS_REFUSED_MESSAGE, DATABASE_TIMEOUT_MESSAGE } from "./apiBridge";
43
  import { GridPager, pageLabel } from "./GridPager";
44
  import { GridActivity, useNativeActivity } from "./GridActivity";
45
  import { withoutAppliedLeaves } from "./drillLimits";
@@ -1429,9 +1429,7 @@ async function readImportantViewCount(table: string, view: SavedView,
1429
  }
1430
  }
1431
 
1432
- function ProductsFrozenNotice({ payload }: {
1433
- payload: (CustomersPayload & { paused?: boolean; frozenAt?: number }) | null;
1434
- }) {
1435
  if (payload?.paused !== true || typeof payload.frozenAt !== "number"
1436
  || !Number.isFinite(payload.frozenAt) || payload.frozenAt <= 0) return null;
1437
  // scope_cache stores Unix wall-clock seconds, not milliseconds or a monotonic clock.
@@ -1442,11 +1440,8 @@ function ProductsFrozenNotice({ payload }: {
1442
  timeZoneName: "short",
1443
  });
1444
  const note = limitSummary(payload.limits?.filter((entry) => entry.effect === "frozen")
1445
- .map((entry) => ({ ...entry, cause: `Odoo is paused with data as of ${stamp}.` })));
1446
- return note ? <div className="cg-more" role="status" data-products-frozen
1447
- style={{ color: "var(--lp-ink)", background: "transparent" }}>
1448
- <span className="cg-more-note">{note.short}</span>
1449
- </div> : null;
1450
  }
1451
 
1452
  function MirrorModeSkeleton() {
@@ -10979,6 +10974,11 @@ function CustomerGridSurface({
10979
  const filterRemovalNote = removedFilterNames.length
10980
  ? `Rule removed: ${removedFilterNames.map((key) => fieldByKey.get(key)?.label ?? key).join(", ")}.`
10981
  : null;
 
 
 
 
 
10982
  const routeSourceView: RouteSourceView | null = activeView
10983
  ? {
10984
  id: activeView.id,
@@ -11416,6 +11416,7 @@ function CustomerGridSurface({
11416
  search={pivotSearch}
11417
  onSearch={setPivotSearch}
11418
  recordCount={pivotAnswer?.targetCount ?? 0}
 
11419
  relationalTargets={pivotTargets}
11420
  relational={relationalState}
11421
  onRelational={setPivotVia}
@@ -11552,6 +11553,10 @@ function CustomerGridSurface({
11552
  searchRef={searchRef}
11553
  onSearchEscape={() => requestAnimationFrame(() => gridRef.current?.focus())}
11554
  recordCount={isPagedOdooApplication ? catalogData?.rows.length ?? 0 : recordCount}
 
 
 
 
11555
  scopeCounts={isPagedOdooApplication ? undefined : serverWindowed && payload?.counts && (displayMode === "kanban" || displayMode === "calendar")
11556
  ? { ...payload.counts, shown: payload.counts.matched } : payload?.counts}
11557
  pool={isPagedOdooApplication ? undefined : payload?.workspace?.pool}
@@ -11998,24 +12003,22 @@ function CustomerGridSurface({
11998
  cloned this `<main>` on every render without removing the last (21 copies measured,
11999
  live). Both sides are prefixed so neither can be spelled by the other. */}
12000
  <main className="cg-main" key={`cg-main:${scope}`}>
12001
- <ProductsFrozenNotice payload={scope === "product" ? payload : null} />
12002
  {/* A 403 is final: one plain line, no Retry, no skeleton, no grid. */}
12003
- {accessRefused && <div className="cg-more" role="status" data-access-refused>
12004
- <span className="cg-more-note">{ACCESS_REFUSED_MESSAGE}</span>
12005
- </div>}
12006
- {workspaceError && !accessRefused && <div className="cg-more" role="alert" data-workspace-error
12007
- title={workspaceError.replace(/[\u2013\u2014]/g, ",")}>
12008
- <span className="cg-more-note">{workspaceError === DATABASE_TIMEOUT_MESSAGE
12009
- ? DATABASE_TIMEOUT_MESSAGE : "Saved views unavailable."}</span>
12010
- <button type="button" className="cg-link-btn" disabled={workspacePending}
12011
- onClick={retryWorkspace}>Retry</button>
12012
  </div>}
12013
  {accessRefused ? null : <>
12014
- {rowLoadingMessage && <div className="cg-more" role="status" aria-busy={!mirrorUnavailable}>
12015
- <span className="cg-more-note">{rowLoadingMessage}</span>
12016
  </div>}
12017
  {mirrorUnavailable ? null : rowsLoading ? (
12018
- <div className="cg-initial-skeleton" role="status" aria-label="Loading records" aria-busy="true"
 
 
 
 
 
 
12019
  style={{ padding: "12px", width: "100%" }}>
12020
  <div aria-hidden="true" style={{ display: "grid", gridTemplateColumns: "48px minmax(160px, 2fr) minmax(100px, 1fr) minmax(100px, 1fr)" }}>
12021
  {Array.from({ length: 32 }, (_, index) => (
@@ -12066,8 +12069,6 @@ function CustomerGridSurface({
12066
  not be wired yet: absent beats present-and-inert. A control row over a database whose
12067
  columns never arrived would offer Hide fields, Filter, Sort and Group on nothing. */}
12068
  {secondaryToolbar}
12069
- {filterRemovalNote && <div className="cg-state-note" role="status">{filterRemovalNote}</div>}
12070
- {draftPredicateNote && <div className="cg-state-note" role="status">{draftPredicateNote}</div>}
12071
  {workspaceDrawer && <aside className="cg-workspace-drawer" aria-label="History">
12072
  <header><strong id="cg-workspace-title">History</strong><button type="button" className="cg-icon-button" aria-label="Close drawer" onClick={() => setWorkspaceDrawer(null)}>×</button></header>
12073
  {drawerBusy && <span className="lp-spin" role="status" aria-label="Loading" />}
@@ -13274,7 +13275,6 @@ function CustomerGridSurface({
13274
  size={pageSize} sizes={PAGE_SIZES} total={payload?.rows.length ?? 0}
13275
  totalKnown={false} hasNextPage={!!activityPage.next} pending={activityPage.pending}
13276
  onPage={activityPage.goToPage} onSize={setPageSize} />}
13277
- {nativeActivity && activityPage.error && <span role="alert">Activity could not be loaded.</span>}
13278
  {/* Activity starts only after a row payload admits this grid. */}
13279
  {!embedded && !isQueryPreview && !loading && <GridActivity key={scope}
13280
  database={scope === "customer" || scope === "cohort" ? "customer_data" : scope === "product" ? "product_data" : scope} />}
 
39
  // only its own source text could otherwise be checked.
40
  import { PAGE_SIZES, fetchAggregates, fetchTableWindow, personalGridLayout, readPageSize, recordIdsKey,
41
  writePageSize } from "./apiBridge";
42
+ import { ACCESS_REFUSED_MESSAGE } from "./apiBridge";
43
  import { GridPager, pageLabel } from "./GridPager";
44
  import { GridActivity, useNativeActivity } from "./GridActivity";
45
  import { withoutAppliedLeaves } from "./drillLimits";
 
1429
  }
1430
  }
1431
 
1432
+ function productsFrozenDetail(payload: (CustomersPayload & { paused?: boolean; frozenAt?: number }) | null) {
 
 
1433
  if (payload?.paused !== true || typeof payload.frozenAt !== "number"
1434
  || !Number.isFinite(payload.frozenAt) || payload.frozenAt <= 0) return null;
1435
  // scope_cache stores Unix wall-clock seconds, not milliseconds or a monotonic clock.
 
1440
  timeZoneName: "short",
1441
  });
1442
  const note = limitSummary(payload.limits?.filter((entry) => entry.effect === "frozen")
1443
+ .map((entry) => ({ ...entry, cause: `Odoo is paused with data as of ${stamp}.` })), undefined, () => "Products");
1444
+ return note?.full ?? null;
 
 
 
1445
  }
1446
 
1447
  function MirrorModeSkeleton() {
 
10974
  const filterRemovalNote = removedFilterNames.length
10975
  ? `Rule removed: ${removedFilterNames.map((key) => fieldByKey.get(key)?.label ?? key).join(", ")}.`
10976
  : null;
10977
+ const countDetail = [productsFrozenDetail(scope === "product" ? payload : null),
10978
+ limitNote?.full, summaryLimitNote?.full, foldNote, pagingNote?.full, capabilityNote?.full,
10979
+ lockedNote?.full, totalsScopeNote, filterRemovalNote, draftPredicateNote,
10980
+ workspaceError, nativeActivity && activityPage.error ? "Activity could not be loaded. Reload to try again." : null]
10981
+ .filter(Boolean).join("\n\n");
10982
  const routeSourceView: RouteSourceView | null = activeView
10983
  ? {
10984
  id: activeView.id,
 
11416
  search={pivotSearch}
11417
  onSearch={setPivotSearch}
11418
  recordCount={pivotAnswer?.targetCount ?? 0}
11419
+ countDetail={countDetail}
11420
  relationalTargets={pivotTargets}
11421
  relational={relationalState}
11422
  onRelational={setPivotVia}
 
11553
  searchRef={searchRef}
11554
  onSearchEscape={() => requestAnimationFrame(() => gridRef.current?.focus())}
11555
  recordCount={isPagedOdooApplication ? catalogData?.rows.length ?? 0 : recordCount}
11556
+ countDetail={countDetail}
11557
+ savedValueCount={!!draftPredicateNote}
11558
+ onRetryCount={workspaceError ? retryWorkspace : undefined}
11559
+ countRetrying={workspacePending}
11560
  scopeCounts={isPagedOdooApplication ? undefined : serverWindowed && payload?.counts && (displayMode === "kanban" || displayMode === "calendar")
11561
  ? { ...payload.counts, shown: payload.counts.matched } : payload?.counts}
11562
  pool={isPagedOdooApplication ? undefined : payload?.workspace?.pool}
 
12003
  cloned this `<main>` on every render without removing the last (21 copies measured,
12004
  live). Both sides are prefixed so neither can be spelled by the other. */}
12005
  <main className="cg-main" key={`cg-main:${scope}`}>
 
12006
  {/* A 403 is final: one plain line, no Retry, no skeleton, no grid. */}
12007
+ {accessRefused && <div className="cg-mode-empty" role="status" data-access-refused>
12008
+ {ACCESS_REFUSED_MESSAGE}
 
 
 
 
 
 
 
12009
  </div>}
12010
  {accessRefused ? null : <>
12011
+ {rowLoadingMessage && mirrorUnavailable && <div className="cg-mode-empty" role="status" aria-busy={!mirrorUnavailable}>
12012
+ {rowLoadingMessage}
12013
  </div>}
12014
  {mirrorUnavailable ? null : rowsLoading ? (
12015
+ workspaceError ? <div className="cg-mode-empty" role="alert" data-workspace-error
12016
+ title={workspaceError.replace(/[\u2013\u2014]/g, ",")}>
12017
+ Saved views unavailable.{" "}
12018
+ <button type="button" className="cg-link-btn" disabled={workspacePending}
12019
+ onClick={retryWorkspace}>Retry</button>
12020
+ </div> :
12021
+ <div className="cg-initial-skeleton" role="status" aria-label={rowLoadingMessage || "Loading records"} aria-busy="true"
12022
  style={{ padding: "12px", width: "100%" }}>
12023
  <div aria-hidden="true" style={{ display: "grid", gridTemplateColumns: "48px minmax(160px, 2fr) minmax(100px, 1fr) minmax(100px, 1fr)" }}>
12024
  {Array.from({ length: 32 }, (_, index) => (
 
12069
  not be wired yet: absent beats present-and-inert. A control row over a database whose
12070
  columns never arrived would offer Hide fields, Filter, Sort and Group on nothing. */}
12071
  {secondaryToolbar}
 
 
12072
  {workspaceDrawer && <aside className="cg-workspace-drawer" aria-label="History">
12073
  <header><strong id="cg-workspace-title">History</strong><button type="button" className="cg-icon-button" aria-label="Close drawer" onClick={() => setWorkspaceDrawer(null)}>×</button></header>
12074
  {drawerBusy && <span className="lp-spin" role="status" aria-label="Loading" />}
 
13275
  size={pageSize} sizes={PAGE_SIZES} total={payload?.rows.length ?? 0}
13276
  totalKnown={false} hasNextPage={!!activityPage.next} pending={activityPage.pending}
13277
  onPage={activityPage.goToPage} onSize={setPageSize} />}
 
13278
  {/* Activity starts only after a row payload admits this grid. */}
13279
  {!embedded && !isQueryPreview && !loading && <GridActivity key={scope}
13280
  database={scope === "customer" || scope === "cohort" ? "customer_data" : scope === "product" ? "product_data" : scope} />}
web/src/customer-grid/PendingEdits.tsx CHANGED
@@ -1,88 +1,6 @@
1
- import { useCallback, useEffect, useState } from "react";
2
- import { ConfirmDialog } from "../ui/ConfirmDialog";
3
- import { editOutbox, gridEditScope, pendingCellEdits } from "./apiBridge";
4
- import { pendingEditsCopy, pendingValueText, reviewPendingEdits } from "./pendingEdits";
5
- import { useSaveState } from "./SaveState";
6
  import type { Field } from "./types";
7
- import "./PendingEdits.css";
8
 
9
- export default function PendingEdits({ scope, fields }: { scope: string; fields: readonly Field[] }) {
10
- const includes = useCallback((edit: Parameters<typeof gridEditScope>[0]) => gridEditScope(edit, scope), [scope]);
11
- useSaveState(includes);
12
- const [open, setOpen] = useState(false);
13
- const [feedback, setFeedback] = useState("");
14
- const read = () => reviewPendingEdits(pendingCellEdits(scope), fields);
15
- const edits = read();
16
- useEffect(() => {
17
- if (!edits.length) { setOpen(false); setFeedback(""); }
18
- }, [edits.length]);
19
- const copy = async () => {
20
- try {
21
- const current = read();
22
- if (!current.length) return;
23
- await navigator.clipboard.writeText(pendingEditsCopy(current));
24
- setFeedback("Pending changes copied");
25
- } catch {
26
- setFeedback("Copy failed. Download a copy instead.");
27
- }
28
- };
29
- const download = () => {
30
- let url: string | undefined;
31
- let link: HTMLAnchorElement | undefined;
32
- try {
33
- const current = read();
34
- if (!current.length) return;
35
- url = URL.createObjectURL(new Blob([pendingEditsCopy(current)], { type: "application/json" }));
36
- link = document.createElement("a");
37
- link.href = url;
38
- link.download = "pending-changes.json";
39
- document.body.append(link);
40
- link.click();
41
- setFeedback("Pending changes downloaded");
42
- } catch {
43
- setFeedback("Download failed. Try copying the changes.");
44
- } finally {
45
- link?.remove();
46
- if (url) setTimeout(() => URL.revokeObjectURL(url!), 1000);
47
- }
48
- };
49
- const retry = async (id: string) => {
50
- const current = read().find((edit) => edit.id === id);
51
- if (!current?.retryable) return;
52
- setFeedback("");
53
- await editOutbox.retryNow((edit) => edit.id === current.id && gridEditScope(edit, scope));
54
- };
55
- if (!edits.length) return null;
56
- return <>
57
- <div className="cg-pending-summary">
58
- <button type="button" className="cg-save-retry" onClick={() => { setFeedback(""); setOpen(true); }}>
59
- Review pending changes ({edits.length})
60
- </button>
61
- </div>
62
- <ConfirmDialog open={open} title="Pending changes" cancelLabel="Close" confirmLabel="Copy pending changes"
63
- tone="primary" onCancel={() => setOpen(false)} onConfirm={() => void copy()} body={<>
64
- <div className="cg-pending-tools">
65
- <span>These changes have not been saved</span>
66
- <button type="button" className="cg-save-retry" onClick={download}>Download a copy</button>
67
- </div>
68
- <ol className="cg-pending-list">{edits.map((edit) => <li key={edit.id}>
69
- <div className="cg-pending-heading">
70
- <strong>Record {edit.pid}</strong>
71
- <span>{edit.failure ? "Not saved" : "Waiting to save"}</span>
72
- <button type="button" className="cg-save-retry" disabled={!edit.retryable}
73
- aria-label={`Retry change ${edit.order}, record ${edit.pid}`} onClick={() => void retry(edit.id)}>Retry</button>
74
- </div>
75
- {edit.changes.map((change) => <div className="cg-pending-change" key={change.field}>
76
- <span>{change.label}</span>
77
- <pre aria-label={`Pending value for ${change.label}`}>{pendingValueText(change.value)}</pre>
78
- {change.failure && <span className="cg-pending-failure">{change.failure}</span>}
79
- </div>)}
80
- {edit.failure && <p className="cg-pending-failure">{edit.failure}</p>}
81
- {edit.code === "out_of_scope" && <p>{scope === "product"
82
- ? "Product unavailable. Ask an administrator to check the source catalogue and your access, then retry."
83
- : "Record unavailable. Ask an administrator to check your access, then retry."}</p>}
84
- </li>)}</ol>
85
- <span role="status" aria-live="polite">{feedback}</span>
86
- </>} />
87
- </>;
88
  }
 
 
 
 
 
 
1
  import type { Field } from "./types";
 
2
 
3
+ /** The toolbar's SaveState owns scoped feedback without adding a Table notice row. */
4
+ export default function PendingEdits(_props: { scope: string; fields: readonly Field[] }) {
5
+ return null;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  }
web/src/customer-grid/SaveState.tsx CHANGED
@@ -10,12 +10,22 @@ export function useSaveState(includes: (edit: OutboxEdit) => boolean) {
10
  return useMemo(() => outboxStatus(snapshot, includes), [snapshot, includes]);
11
  }
12
 
13
- export default function SaveState({ includes }: { includes: (edit: OutboxEdit) => boolean }) {
 
 
 
14
  useEffect(() => { void editOutbox.start(); }, []);
15
  const status = useSaveState(includes);
 
 
16
  return (
17
- <div className="cg-save-state" data-state={status.state}>
18
- <span role="status" aria-live="polite" aria-atomic="true">{status.state}</span>
 
 
 
 
 
19
  </div>
20
  );
21
  }
 
10
  return useMemo(() => outboxStatus(snapshot, includes), [snapshot, includes]);
11
  }
12
 
13
+ export default function SaveState({ includes, showFailures = false }: {
14
+ includes: (edit: OutboxEdit) => boolean;
15
+ showFailures?: boolean;
16
+ }) {
17
  useEffect(() => { void editOutbox.start(); }, []);
18
  const status = useSaveState(includes);
19
+ const reason = showFailures ? [...new Set(Object.values(status.failures).map((failure) => failure.message))]
20
+ .join("\n").replace(/[\u2013\u2014]/g, ",") : "";
21
  return (
22
+ <div className="cg-save-state" data-state={status.state} title={reason || undefined}>
23
+ <span role="status" aria-live="polite" aria-atomic="true"
24
+ aria-label={reason ? `${status.state}. ${reason}` : undefined}>{status.state}</span>
25
+ {showFailures && status.state === "Not saved" && status.pending.length > 0 && <button type="button"
26
+ className="cg-save-retry" aria-label="Retry unsaved changes"
27
+ onClick={() => void editOutbox.retryNow((edit) => includes(edit)
28
+ && !!editOutbox.snapshot().failures[edit.id])}>Retry</button>}
29
  </div>
30
  );
31
  }
web/src/customer-grid/Toolbar.tsx CHANGED
@@ -45,7 +45,7 @@ import { AnchoredOverlay } from "./OverlaySurface";
45
  import { EyeOffIcon, FieldTypeIcon, ModeIcon } from "./icons";
46
  import { FieldSelectButton } from "./FieldSelect";
47
  import { TYPE_LABELS } from "./iconShapes";
48
- import { countLabel, countLabelCompact, poolProgressLabel } from "./counts";
49
  import type { PoolProgress } from "./counts";
50
  // Shared builders live in filter-kit so every list uses the same controls.
51
  import { FilterBuilderPanel, FieldsHidePanel, Popover, SortBuilder } from "../filter-kit";
@@ -206,6 +206,10 @@ interface ToolbarBaseProps {
206
  onCopyConfig?: (patch: Partial<ViewConfig>) => void;
207
 
208
  recordCount: number;
 
 
 
 
209
  /** Server-windowed tables only. When present the count is rendered from the SCOPE, never
210
  * from the rows in hand — see countLabel(). */
211
  scopeCounts?: ScopeCounts;
@@ -662,6 +666,10 @@ const ROW_OPTIONS: { mode: RowHeightMode; label: string }[] = [
662
  export default function Toolbar({
663
  toolbarKind = "table",
664
  saveScope,
 
 
 
 
665
  fields,
666
  viewer,
667
  visible,
@@ -853,6 +861,8 @@ export default function Toolbar({
853
  // current answer names it on the trigger, so the reader does not have to open it to find out.
854
  const saveIncludes = useCallback((edit: OutboxEdit) =>
855
  saveScope !== undefined && gridEditScope(edit, saveScope), [saveScope]);
 
 
856
  const relationalLabel = relational ? `Related: ${relational.label}` : "Related";
857
  // ⭐⭐ W54-T49 (R7) — the same idiom again, and here it is load bearing rather than convenient:
858
  // two connections show the same databases under the same column names, so the ONE thing on
@@ -1252,7 +1262,7 @@ export default function Toolbar({
1252
  </div>
1253
  )}
1254
  </Popover>
1255
- {saveScope !== undefined && <SaveState includes={saveIncludes} />}
1256
  </div>
1257
 
1258
  {onFullscreen && (
@@ -1357,11 +1367,11 @@ export default function Toolbar({
1357
  // readable rather than alarming, and it lasts exactly one round trip.
1358
  <span
1359
  className="cg-count cg-count-pending"
1360
- title={
1361
  `${pendingMeasureCount} measure condition${pendingMeasureCount === 1 ? "" : "s"} ` +
1362
  "still being calculated over the period you chose. Rows are hidden until the " +
1363
  "answer arrives rather than shown under a count that would be wrong."
1364
- }
1365
  >
1366
  Calculating…
1367
  </span>
@@ -1373,11 +1383,11 @@ export default function Toolbar({
1373
  // saying "calculating" about something that will never arrive is worse than silence.
1374
  <span
1375
  className="cg-count cg-count-pending"
1376
- title={
1377
  `${unresolvedCount} condition${unresolvedCount === 1 ? "" : "s"} cannot be ` +
1378
  "evaluated; a date that does not resolve, or a list this view refers to that no " +
1379
  "longer exists. Rows are hidden rather than shown under a count that would be wrong."
1380
- }
1381
  >
1382
  Filter unresolved
1383
  </span>
@@ -1397,20 +1407,24 @@ export default function Toolbar({
1397
  // affordance, not text on screen.
1398
  <span
1399
  className="cg-count cg-count-partial"
1400
- title={
1401
  `Loading the rest of your ${nouns} in the background; you can browse, ` +
1402
  "filter and sort what is already here."
1403
- }
1404
  >
1405
  <span className="lp-spin" role="status" aria-label="Loading" />
1406
- {poolProgressLabel(pool)}
 
 
1407
  </span>
1408
  ) : (
1409
- <span className="cg-count" title={countLabel(recordCount, scopeCounts)}>
1410
- <span className="cg-count-full">{countLabel(recordCount, scopeCounts)}</span>
1411
  <span className="cg-count-compact">
1412
- {countLabelCompact(recordCount, scopeCounts)}
1413
  </span>
 
 
1414
  </span>
1415
  )}
1416
  </div>
 
45
  import { EyeOffIcon, FieldTypeIcon, ModeIcon } from "./icons";
46
  import { FieldSelectButton } from "./FieldSelect";
47
  import { TYPE_LABELS } from "./iconShapes";
48
+ import { countLabel, countLabelCompact, gridLimitCopy, poolProgressLabel } from "./counts";
49
  import type { PoolProgress } from "./counts";
50
  // Shared builders live in filter-kit so every list uses the same controls.
51
  import { FilterBuilderPanel, FieldsHidePanel, Popover, SortBuilder } from "../filter-kit";
 
206
  onCopyConfig?: (patch: Partial<ViewConfig>) => void;
207
 
208
  recordCount: number;
209
+ countDetail?: string;
210
+ savedValueCount?: boolean;
211
+ onRetryCount?: () => void;
212
+ countRetrying?: boolean;
213
  /** Server-windowed tables only. When present the count is rendered from the SCOPE, never
214
  * from the rows in hand — see countLabel(). */
215
  scopeCounts?: ScopeCounts;
 
666
  export default function Toolbar({
667
  toolbarKind = "table",
668
  saveScope,
669
+ countDetail,
670
+ savedValueCount = false,
671
+ onRetryCount,
672
+ countRetrying = false,
673
  fields,
674
  viewer,
675
  visible,
 
861
  // current answer names it on the trigger, so the reader does not have to open it to find out.
862
  const saveIncludes = useCallback((edit: OutboxEdit) =>
863
  saveScope !== undefined && gridEditScope(edit, saveScope), [saveScope]);
864
+ const countTitle = (label: string) => gridLimitCopy([label, countDetail].filter(Boolean).join("\n\n"));
865
+ const countSuffix = savedValueCount ? " by saved values" : "";
866
  const relationalLabel = relational ? `Related: ${relational.label}` : "Related";
867
  // ⭐⭐ W54-T49 (R7) — the same idiom again, and here it is load bearing rather than convenient:
868
  // two connections show the same databases under the same column names, so the ONE thing on
 
1262
  </div>
1263
  )}
1264
  </Popover>
1265
+ {saveScope !== undefined && <SaveState includes={saveIncludes} showFailures />}
1266
  </div>
1267
 
1268
  {onFullscreen && (
 
1367
  // readable rather than alarming, and it lasts exactly one round trip.
1368
  <span
1369
  className="cg-count cg-count-pending"
1370
+ title={countTitle(
1371
  `${pendingMeasureCount} measure condition${pendingMeasureCount === 1 ? "" : "s"} ` +
1372
  "still being calculated over the period you chose. Rows are hidden until the " +
1373
  "answer arrives rather than shown under a count that would be wrong."
1374
+ )}
1375
  >
1376
  Calculating…
1377
  </span>
 
1383
  // saying "calculating" about something that will never arrive is worse than silence.
1384
  <span
1385
  className="cg-count cg-count-pending"
1386
+ title={countTitle(
1387
  `${unresolvedCount} condition${unresolvedCount === 1 ? "" : "s"} cannot be ` +
1388
  "evaluated; a date that does not resolve, or a list this view refers to that no " +
1389
  "longer exists. Rows are hidden rather than shown under a count that would be wrong."
1390
+ )}
1391
  >
1392
  Filter unresolved
1393
  </span>
 
1407
  // affordance, not text on screen.
1408
  <span
1409
  className="cg-count cg-count-partial"
1410
+ title={countTitle(
1411
  `Loading the rest of your ${nouns} in the background; you can browse, ` +
1412
  "filter and sort what is already here."
1413
+ )}
1414
  >
1415
  <span className="lp-spin" role="status" aria-label="Loading" />
1416
+ {poolProgressLabel(pool)}{countSuffix}
1417
+ {onRetryCount && <button type="button" className="cg-link-btn" disabled={countRetrying}
1418
+ aria-label="Retry saved views" onClick={onRetryCount}>Retry</button>}
1419
  </span>
1420
  ) : (
1421
+ <span className="cg-count" title={countTitle(countLabel(recordCount, scopeCounts) + countSuffix)}>
1422
+ <span className="cg-count-full">{countLabel(recordCount, scopeCounts)}{countSuffix}</span>
1423
  <span className="cg-count-compact">
1424
+ {countLabelCompact(recordCount, scopeCounts)}{countSuffix}
1425
  </span>
1426
+ {onRetryCount && <button type="button" className="cg-link-btn" disabled={countRetrying}
1427
+ aria-label="Retry saved views" onClick={onRetryCount}>Retry</button>}
1428
  </span>
1429
  )}
1430
  </div>
web/src/customer-grid/counts.ts CHANGED
@@ -278,11 +278,11 @@ export function limitSummary(
278
  return { short: short.join(" · "), full: full.join("\n\n") };
279
  }
280
 
281
- /** Causes and fixes retain their meaning without exposing subject keys. */
282
  function limitDetailCopy(text: string | undefined, keys: string[]): string {
283
  let copy = String(text ?? "");
284
  for (const key of [...keys].sort((a, b) => b.length - a.length)) {
285
- if (!key) continue;
286
  const escaped = key.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
287
  copy = copy.replace(new RegExp(`(^|[^\\w])${escaped}(?=$|[^\\w])`, "g"), "$1this column");
288
  }
 
278
  return { short: short.join(" · "), full: full.join("\n\n") };
279
  }
280
 
281
+ /** Natural words survive while structured column identifiers stay anonymous. */
282
  function limitDetailCopy(text: string | undefined, keys: string[]): string {
283
  let copy = String(text ?? "");
284
  for (const key of [...keys].sort((a, b) => b.length - a.length)) {
285
+ if (!/[_:]/.test(key)) continue;
286
  const escaped = key.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
287
  copy = copy.replace(new RegExp(`(^|[^\\w])${escaped}(?=$|[^\\w])`, "g"), "$1this column");
288
  }
web/src/customer-grid/useCustomerData.ts CHANGED
@@ -1061,10 +1061,17 @@ export function useCustomerData(
1061
  const identity = (key: string) => JSON.stringify([writeScope, pid, key]);
1062
  const row = dataRef.current?.rows.find((record) => record.pid === pid);
1063
  const overlay = overlayRef.current[pid] ?? {};
1064
- updates = Object.fromEntries(Object.entries(updates).filter(([key, value]) =>
1065
- committedEdits.current.has(identity(key))
1066
- ? committedEdits.current.get(identity(key)) !== value || overlay[key] !== value
1067
- : row?.[key] !== value));
 
 
 
 
 
 
 
1068
  if (!Object.keys(updates).length) return;
1069
  for (const [key, value] of Object.entries(updates)) committedEdits.current.set(identity(key), value);
1070
  const version = ++editSequence.current;
 
1061
  const identity = (key: string) => JSON.stringify([writeScope, pid, key]);
1062
  const row = dataRef.current?.rows.find((record) => record.pid === pid);
1063
  const overlay = overlayRef.current[pid] ?? {};
1064
+ updates = Object.fromEntries(Object.entries(updates).filter(([key, value]) => {
1065
+ if (!row && !committedEdits.current.has(identity(key))) return value !== undefined;
1066
+ const field = dataRef.current?.fields?.find((candidate) => candidate.key === key);
1067
+ const text = field?.type === "text" || field?.type === "long_text";
1068
+ // Text editors display missing, null and empty values as the same blank cell.
1069
+ const same = (previous: Row[string]) => previous === value || (text
1070
+ && (previous == null || previous === "") && (value == null || value === ""));
1071
+ return committedEdits.current.has(identity(key))
1072
+ ? !same(committedEdits.current.get(identity(key))) || !same(overlay[key])
1073
+ : !same(row?.[key]);
1074
+ }));
1075
  if (!Object.keys(updates).length) return;
1076
  for (const [key, value] of Object.entries(updates)) committedEdits.current.set(identity(key), value);
1077
  const version = ++editSequence.current;