Deploy AIOS web (React glide grid + FastAPI slice)
Browse files- RELEASES.json +1 -1
- VERSION +1 -1
- api/routes_grid.py +4 -2
- platform/aios_grid.py +8 -0
- platform/core/grid_events.py +8 -3
- platform/core/table_store.py +8 -6
- web/public/AIOS_DEPLOY_RECEIPT +1 -1
- web/src/customer-grid/CustomerGrid.tsx +16 -31
- web/src/customer-grid/types.ts +2 -0
- web/src/customer-grid/viewOps.ts +25 -10
- web/src/shell/Shell.tsx +5 -0
RELEASES.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
{
|
| 2 |
-
"current": "
|
| 3 |
"releases": []
|
| 4 |
}
|
|
|
|
| 1 |
{
|
| 2 |
+
"current": "dd3944a9ffc",
|
| 3 |
"releases": []
|
| 4 |
}
|
VERSION
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
|
|
|
|
| 1 |
+
dd3944a9ffc
|
api/routes_grid.py
CHANGED
|
@@ -423,7 +423,9 @@ def _workspace_filter_removals(workspace, fields, measures, hidden=()):
|
|
| 423 |
import aios_grid
|
| 424 |
|
| 425 |
workspace = dict(workspace)
|
| 426 |
-
|
|
|
|
|
|
|
| 427 |
valid_keys = field_keys | {measure['key'] for measure in measures}
|
| 428 |
cohort_ids = {str(entry['id']) for entry in workspace.get('lists') or () if entry.get('id')}
|
| 429 |
view_ids = {str(view['id']) for view in workspace.get('views') or () if view.get('id')}
|
|
@@ -438,7 +440,7 @@ def _workspace_filter_removals(workspace, fields, measures, hidden=()):
|
|
| 438 |
cfg['filters'] = aios_grid.clean_filter_tree(
|
| 439 |
cfg.get('filters'), valid_keys, cohort_ids=cohort_ids,
|
| 440 |
visible_view_ids=view_ids, report=reports)
|
| 441 |
-
prune_view_field_members(view, live_keys=field_keys, prune_filters=False)
|
| 442 |
removals = []
|
| 443 |
for report in [*(view.get('filterRemovals') or ()), *reports]:
|
| 444 |
if (isinstance(report, dict) and report.get('colId') not in hidden
|
|
|
|
| 423 |
import aios_grid
|
| 424 |
|
| 425 |
workspace = dict(workspace)
|
| 426 |
+
workspace['layoutFields'] = aios_grid.audit_layout_fields(fields, hidden)
|
| 427 |
+
layout_keys = {field['key'] for field in workspace['layoutFields']}
|
| 428 |
+
field_keys = {field['key'] for field in fields} - set(hidden or ())
|
| 429 |
valid_keys = field_keys | {measure['key'] for measure in measures}
|
| 430 |
cohort_ids = {str(entry['id']) for entry in workspace.get('lists') or () if entry.get('id')}
|
| 431 |
view_ids = {str(view['id']) for view in workspace.get('views') or () if view.get('id')}
|
|
|
|
| 440 |
cfg['filters'] = aios_grid.clean_filter_tree(
|
| 441 |
cfg.get('filters'), valid_keys, cohort_ids=cohort_ids,
|
| 442 |
visible_view_ids=view_ids, report=reports)
|
| 443 |
+
prune_view_field_members(view, live_keys=field_keys, prune_filters=False, layout_keys=layout_keys)
|
| 444 |
removals = []
|
| 445 |
for report in [*(view.get('filterRemovals') or ()), *reports]:
|
| 446 |
if (isinstance(report, dict) and report.get('colId') not in hidden
|
platform/aios_grid.py
CHANGED
|
@@ -33,6 +33,14 @@ from pathlib import Path
|
|
| 33 |
|
| 34 |
_HERE = Path(__file__).resolve().parent
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
# Where the inlined single-file build lives. FIRST match wins:
|
| 37 |
# 1. the shipped copy in this dir (what deploy_hf.py uploads to the Space)
|
| 38 |
# 2. the raw build output in the sibling aios-web tree (local dev, pre-copy)
|
|
|
|
| 33 |
|
| 34 |
_HERE = Path(__file__).resolve().parent
|
| 35 |
|
| 36 |
+
|
| 37 |
+
def audit_layout_fields(fields=(), hidden=()):
|
| 38 |
+
"""Publish the audit presentation column without granting cell or schema authority."""
|
| 39 |
+
if '_updated' in hidden or any(field.get('key') == '_updated' for field in fields):
|
| 40 |
+
return []
|
| 41 |
+
return [{'key': '_updated', 'label': 'Last updated', 'type': 'date', 'source': 'odoo',
|
| 42 |
+
'derived': True, 'origin': 'system', 'valueAuthority': 'derived'}]
|
| 43 |
+
|
| 44 |
# Where the inlined single-file build lives. FIRST match wins:
|
| 45 |
# 1. the shipped copy in this dir (what deploy_hf.py uploads to the Space)
|
| 46 |
# 2. the raw build output in the sibling aios-web tree (local dev, pre-copy)
|
platform/core/grid_events.py
CHANGED
|
@@ -1117,7 +1117,10 @@ def clean_view_member(member, value, ctx, prior):
|
|
| 1117 |
or (family in (*field_families, 'filter', 'memberPid') and not separator)
|
| 1118 |
or (family in scalar_families and separator and family != 'filterConj')):
|
| 1119 |
return refuse('unknown_member', 'Choose a supported View setting.')
|
| 1120 |
-
valid_keys = {item['key'] for item in ctx.fields}
|
|
|
|
|
|
|
|
|
|
| 1121 |
if family in field_families:
|
| 1122 |
key = _view_field_key(key, valid_keys)
|
| 1123 |
if key not in valid_keys:
|
|
@@ -1236,7 +1239,9 @@ def _clean_view_config(cfg, ctx, prior, display):
|
|
| 1236 |
cleaned, refusal = clean_view_member(member, value, cleaner_ctx, prior)
|
| 1237 |
return default if refusal else cleaned
|
| 1238 |
|
| 1239 |
-
|
|
|
|
|
|
|
| 1240 |
config = {
|
| 1241 |
'filters': [], 'filterConj': clean('filterConj', cfg.get('filterConj', 'and'), 'and'),
|
| 1242 |
'important': clean('important', cfg.get('important', False), False),
|
|
@@ -1265,7 +1270,7 @@ def _clean_view_config(cfg, ctx, prior, display):
|
|
| 1265 |
config['order'] = list(dict.fromkeys(
|
| 1266 |
_view_field_key(key, valid_keys) for key in order
|
| 1267 |
if isinstance(key, str) and _view_field_key(key, valid_keys) in valid_keys))
|
| 1268 |
-
config['order'] += [item['key'] for item in
|
| 1269 |
visible = cfg.get('visible') if isinstance(cfg.get('visible'), list) else []
|
| 1270 |
for key in dict.fromkeys(_view_field_key(key, valid_keys) for key in visible if isinstance(key, str)):
|
| 1271 |
hidden = clean('hidden:' + key, False)
|
|
|
|
| 1117 |
or (family in (*field_families, 'filter', 'memberPid') and not separator)
|
| 1118 |
or (family in scalar_families and separator and family != 'filterConj')):
|
| 1119 |
return refuse('unknown_member', 'Choose a supported View setting.')
|
| 1120 |
+
valid_keys = {item['key'] for item in ctx.fields} - set(ctx.hidden_keys or ())
|
| 1121 |
+
if family in ('hidden', 'width', 'position'):
|
| 1122 |
+
import aios_grid as _ag
|
| 1123 |
+
valid_keys |= {item['key'] for item in _ag.audit_layout_fields(ctx.fields, ctx.hidden_keys or ())}
|
| 1124 |
if family in field_families:
|
| 1125 |
key = _view_field_key(key, valid_keys)
|
| 1126 |
if key not in valid_keys:
|
|
|
|
| 1239 |
cleaned, refusal = clean_view_member(member, value, cleaner_ctx, prior)
|
| 1240 |
return default if refusal else cleaned
|
| 1241 |
|
| 1242 |
+
layout_fields = [item for item in ctx.fields if item['key'] not in (ctx.hidden_keys or ())]
|
| 1243 |
+
layout_fields += _ag.audit_layout_fields(ctx.fields, ctx.hidden_keys or ())
|
| 1244 |
+
valid_keys = {item['key'] for item in layout_fields}
|
| 1245 |
config = {
|
| 1246 |
'filters': [], 'filterConj': clean('filterConj', cfg.get('filterConj', 'and'), 'and'),
|
| 1247 |
'important': clean('important', cfg.get('important', False), False),
|
|
|
|
| 1270 |
config['order'] = list(dict.fromkeys(
|
| 1271 |
_view_field_key(key, valid_keys) for key in order
|
| 1272 |
if isinstance(key, str) and _view_field_key(key, valid_keys) in valid_keys))
|
| 1273 |
+
config['order'] += [item['key'] for item in layout_fields if item['key'] not in config['order']]
|
| 1274 |
visible = cfg.get('visible') if isinstance(cfg.get('visible'), list) else []
|
| 1275 |
for key in dict.fromkeys(_view_field_key(key, valid_keys) for key in visible if isinstance(key, str)):
|
| 1276 |
hidden = clean('hidden:' + key, False)
|
platform/core/table_store.py
CHANGED
|
@@ -175,22 +175,22 @@ def _view_filter_nodes(nodes, parent=None):
|
|
| 175 |
yield from _view_filter_nodes(node['children'], node.get('id'))
|
| 176 |
|
| 177 |
|
| 178 |
-
def prune_view_field_members(view, *, live_keys=None, removed_keys=(), prune_filters=True):
|
| 179 |
"""Drop dead field references from a mutable View without changing live member values."""
|
| 180 |
cfg = view.get('config') if isinstance(view, dict) else None
|
| 181 |
if not isinstance(cfg, dict):
|
| 182 |
return
|
| 183 |
removed = set(removed_keys)
|
| 184 |
|
| 185 |
-
def keep(key):
|
| 186 |
-
return key not in removed and (live_keys is None or key in live_keys)
|
| 187 |
|
| 188 |
for name in ('visible', 'order'):
|
| 189 |
if isinstance(cfg.get(name), list):
|
| 190 |
-
cfg[name] = [key for key in cfg[name] if keep(key)]
|
| 191 |
for name in ('widths', 'positions', 'summary'):
|
| 192 |
if isinstance(cfg.get(name), dict):
|
| 193 |
-
cfg[name] = {key: value for key, value in cfg[name].items() if keep(key)}
|
| 194 |
if isinstance(cfg.get('sorts'), list):
|
| 195 |
cfg['sorts'] = [rule for rule in cfg['sorts']
|
| 196 |
if isinstance(rule, dict) and keep(rule.get('colId'))]
|
|
@@ -1924,10 +1924,12 @@ class TableStore:
|
|
| 1924 |
own = workspace.get('fields') or {}
|
| 1925 |
if view_settings_rows.supports(self.table_key):
|
| 1926 |
from core import user_tables
|
|
|
|
| 1927 |
definition = user_tables.get_definition(self._shared_stratum_key(), st=self._st) or {}
|
| 1928 |
return ({field['key'] for field in definition.get('fields', [])}
|
| 1929 |
| {key for key in own if key.startswith(('custom_', 'measure_'))}
|
| 1930 |
-
| self._tenant_wide_keys()
|
|
|
|
| 1931 |
# The event adapter checks built-in fields against its scoped field contract.
|
| 1932 |
return None
|
| 1933 |
|
|
|
|
| 175 |
yield from _view_filter_nodes(node['children'], node.get('id'))
|
| 176 |
|
| 177 |
|
| 178 |
+
def prune_view_field_members(view, *, live_keys=None, removed_keys=(), prune_filters=True, layout_keys=()):
|
| 179 |
"""Drop dead field references from a mutable View without changing live member values."""
|
| 180 |
cfg = view.get('config') if isinstance(view, dict) else None
|
| 181 |
if not isinstance(cfg, dict):
|
| 182 |
return
|
| 183 |
removed = set(removed_keys)
|
| 184 |
|
| 185 |
+
def keep(key, layout=False):
|
| 186 |
+
return key not in removed and (live_keys is None or key in live_keys or (layout and key in layout_keys))
|
| 187 |
|
| 188 |
for name in ('visible', 'order'):
|
| 189 |
if isinstance(cfg.get(name), list):
|
| 190 |
+
cfg[name] = [key for key in cfg[name] if keep(key, layout=True)]
|
| 191 |
for name in ('widths', 'positions', 'summary'):
|
| 192 |
if isinstance(cfg.get(name), dict):
|
| 193 |
+
cfg[name] = {key: value for key, value in cfg[name].items() if keep(key, layout=name != 'summary')}
|
| 194 |
if isinstance(cfg.get('sorts'), list):
|
| 195 |
cfg['sorts'] = [rule for rule in cfg['sorts']
|
| 196 |
if isinstance(rule, dict) and keep(rule.get('colId'))]
|
|
|
|
| 1924 |
own = workspace.get('fields') or {}
|
| 1925 |
if view_settings_rows.supports(self.table_key):
|
| 1926 |
from core import user_tables
|
| 1927 |
+
from aios_grid import audit_layout_fields
|
| 1928 |
definition = user_tables.get_definition(self._shared_stratum_key(), st=self._st) or {}
|
| 1929 |
return ({field['key'] for field in definition.get('fields', [])}
|
| 1930 |
| {key for key in own if key.startswith(('custom_', 'measure_'))}
|
| 1931 |
+
| self._tenant_wide_keys()
|
| 1932 |
+
| {field['key'] for field in audit_layout_fields()})
|
| 1933 |
# The event adapter checks built-in fields against its scoped field contract.
|
| 1934 |
return None
|
| 1935 |
|
web/public/AIOS_DEPLOY_RECEIPT
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
|
|
|
|
| 1 |
+
84ff467fc92d5384e075324ffdd83437d63997a414cc364b466d68cfd3fb6b24
|
web/src/customer-grid/CustomerGrid.tsx
CHANGED
|
@@ -2818,13 +2818,10 @@ function CustomerGridSurface({
|
|
| 2818 |
onEmbeddedRecordsMutableChange?.(embeddedRecordsMutable);
|
| 2819 |
}, [onEmbeddedRecordsMutableChange, embeddedRecordsMutable]);
|
| 2820 |
const payloadFields = useMemo(() => {
|
| 2821 |
-
|
| 2822 |
-
|
| 2823 |
-
return [...payloadFieldsRaw,
|
| 2824 |
-
|
| 2825 |
-
derived: true, origin: "system", valueAuthority: "derived",
|
| 2826 |
-
} satisfies Field];
|
| 2827 |
-
}, [payloadFieldsRaw, payload?.workspace?.auditTimestamps]);
|
| 2828 |
/**
|
| 2829 |
* ⭐ WAVE 27 · OWNER ITEM 2 (contract C2) — **ROWS THIS BROWSER JUST CREATED**, held locally
|
| 2830 |
* until the server's own copy comes back.
|
|
@@ -3339,10 +3336,10 @@ function CustomerGridSurface({
|
|
| 3339 |
entry.op.view_id === before.id && entry.status !== "refused" &&
|
| 3340 |
(entry.status !== "acked" || entry.readAfter === undefined ||
|
| 3341 |
workspaceReadOrder(payload?.workspace) < entry.readAfter)).map((entry) => entry.paint);
|
| 3342 |
-
const canonical = { ...stored, config: normalizeMemberConfig(stored.config) };
|
| 3343 |
const previous = { ...canonical, ...applyPendingOps(canonical, pending) };
|
| 3344 |
-
const base = { ...before, config: normalizeMemberConfig(before.config) };
|
| 3345 |
-
const next = { ...after, config: normalizeMemberConfig(after.config, base.config) };
|
| 3346 |
const intent = diffViewOps(base, next);
|
| 3347 |
const merged = { ...previous, ...applyPendingOps(previous, intent) };
|
| 3348 |
const ops = diffViewOps(previous, merged);
|
|
@@ -3371,10 +3368,10 @@ function CustomerGridSurface({
|
|
| 3371 |
}
|
| 3372 |
}
|
| 3373 |
return painted;
|
| 3374 |
-
}, [scope, emitHostEvent, payload?.workspace]);
|
| 3375 |
const overlayNativeView = useCallback((view: SavedView) => {
|
| 3376 |
const ledger = nativeViewLedger.current;
|
| 3377 |
-
const server = { ...view, config: normalizeMemberConfig(view.config) };
|
| 3378 |
for (const edit of editOutbox.snapshot().pending) {
|
| 3379 |
const event = edit.payload as Extract<HostEvent, { type: "view_op" }>;
|
| 3380 |
if (edit.scope !== scope || edit.kind !== "event" || event.type !== "view_op" || event.view_id !== view.id) continue;
|
|
@@ -3396,7 +3393,7 @@ function CustomerGridSurface({
|
|
| 3396 |
}
|
| 3397 |
const restored = { ...server, ...applyPendingOps(server, paints) };
|
| 3398 |
return restored;
|
| 3399 |
-
}, [scope, payload?.workspace]);
|
| 3400 |
useEffect(() => {
|
| 3401 |
if (embedded || queryBinding || hostOwnsLayout) return;
|
| 3402 |
return editOutbox.subscribeReceipts((edit, receipt) => {
|
|
@@ -3499,6 +3496,8 @@ function CustomerGridSurface({
|
|
| 3499 |
: surfaceStorageKey.startsWith(LOCAL_KEY_PREFIX)
|
| 3500 |
? `${LOCAL_KEY_PREFIX}${embedStorageKey(surfaceStorageKey.slice(LOCAL_KEY_PREFIX.length), true)}`
|
| 3501 |
: embedStorageKey(surfaceStorageKey, true);
|
|
|
|
|
|
|
| 3502 |
// A parent may rebuild an equivalent tree on every render. Depend on its value, not its identity,
|
| 3503 |
// so the initialization effect cannot re-seed over an edit still settling in this surface.
|
| 3504 |
const cellFilterKey = useMemo(() => JSON.stringify(cellFilter ?? null), [cellFilter]);
|
|
@@ -3754,7 +3753,7 @@ function CustomerGridSurface({
|
|
| 3754 |
useEffect(() => {
|
| 3755 |
// `hostWorkspace`: this adopts views out of `payload.workspace`, which a Query surface never
|
| 3756 |
// fetches. Keyed on `embedded` it would read a workspace that is not there.
|
| 3757 |
-
if (!
|
| 3758 |
if (workspaceError) {
|
| 3759 |
// S72-T57: a failed refresh keeps the last rail; writes stay withheld by `readOnly`.
|
| 3760 |
if (workspaceRefreshFailed) return;
|
|
@@ -3770,20 +3769,6 @@ function CustomerGridSurface({
|
|
| 3770 |
return;
|
| 3771 |
}
|
| 3772 |
const now = Date.now();
|
| 3773 |
-
/**
|
| 3774 |
-
* ⭐⭐ W36-T02 (owner item 1) — CORRECT, THEN ADOPT. The two steps answer two questions and
|
| 3775 |
-
* this effect used to ask only the second one.
|
| 3776 |
-
*
|
| 3777 |
-
* ⛔ THE DEFECT, reproduced in `_test/gridUx.test.ts` T01/D before it was fixed: both merges
|
| 3778 |
-
* below are add-only, and add-only was implemented as "skip any id I already hold" — which
|
| 3779 |
-
* also means CANNOT CORRECT. So an edit made on the owner's machine reached this browser (the
|
| 3780 |
-
* change-token poller notices and `reread()` fetches it) and was then thrown away, leaving a
|
| 3781 |
-
* pre-edit filter tree and a pre-edit `agg` in place until a remount. Measured
|
| 3782 |
-
* `{rows: 2, totals: false}` against a reload's `{rows: 4, totals: true, sum: "$4,000"}` off
|
| 3783 |
-
* the SAME server state — the owner's *"only when I refresh it works"*, both symptoms, one
|
| 3784 |
-
* cause. ⚠ The PRD blamed an init RACE; that one is real but self-healing, because
|
| 3785 |
-
* `storageKey` is derived from the workspace and re-arms the guard. See mailbox/B.md B-1.
|
| 3786 |
-
*/
|
| 3787 |
const heldFields = reconcileHeldFields(fields, payloadFields, fieldStampsRef.current, now);
|
| 3788 |
const nextFields = adoptNewFields(
|
| 3789 |
heldFields, payloadFields, fieldStampsRef.current.deleted, now
|
|
@@ -3832,7 +3817,7 @@ function CustomerGridSurface({
|
|
| 3832 |
// ⚠ TERMINATION IS THE IDENTITY CONTRACT, not a flag: once corrected, both merges return
|
| 3833 |
// their input by reference and `nextViews === views`, so the next pass sets nothing and the
|
| 3834 |
// effect stops. That is why `views` can be a dependency at all.
|
| 3835 |
-
}, [
|
| 3836 |
hostWorkspace, workspaceError, workspaceRefreshFailed, scope, payload?.workspace,
|
| 3837 |
overlayNativeView, saveStatus]);
|
| 3838 |
|
|
@@ -4312,7 +4297,7 @@ function CustomerGridSurface({
|
|
| 4312 |
personalLayoutInitialized, storageKey, viewAsReadOnly]);
|
| 4313 |
|
| 4314 |
useEffect(() => {
|
| 4315 |
-
if (viewAsReadOnly || !
|
| 4316 |
const active = views.find((view) => view.id === activeViewId);
|
| 4317 |
if (!active || retiredHostViewIds.has(active.id) ||
|
| 4318 |
!canSaveViewDisplay(active.config.display, config.display) || sameConfig(active.config, config)) return;
|
|
@@ -4332,7 +4317,7 @@ function CustomerGridSurface({
|
|
| 4332 |
else if (routed.channel === "query")
|
| 4333 |
void routed.result.then((result) => { if (!result.ok) signal(TOAST_EVENT, result.message); });
|
| 4334 |
}
|
| 4335 |
-
}, [
|
| 4336 |
emitHostEvent, retiredHostViewIds, sendNativeViewOps, viewAsReadOnly]);
|
| 4337 |
|
| 4338 |
// Loading can replace the grid node without changing workspace readiness.
|
|
|
|
| 2818 |
onEmbeddedRecordsMutableChange?.(embeddedRecordsMutable);
|
| 2819 |
}, [onEmbeddedRecordsMutableChange, embeddedRecordsMutable]);
|
| 2820 |
const payloadFields = useMemo(() => {
|
| 2821 |
+
const layout = (payload?.workspace?.layoutFields ?? [])
|
| 2822 |
+
.filter((field) => !payloadFieldsRaw.some((existing) => existing.key === field.key));
|
| 2823 |
+
return layout.length ? [...payloadFieldsRaw, ...layout] : payloadFieldsRaw;
|
| 2824 |
+
}, [payloadFieldsRaw, payload?.workspace?.layoutFields]);
|
|
|
|
|
|
|
|
|
|
| 2825 |
/**
|
| 2826 |
* ⭐ WAVE 27 · OWNER ITEM 2 (contract C2) — **ROWS THIS BROWSER JUST CREATED**, held locally
|
| 2827 |
* until the server's own copy comes back.
|
|
|
|
| 3336 |
entry.op.view_id === before.id && entry.status !== "refused" &&
|
| 3337 |
(entry.status !== "acked" || entry.readAfter === undefined ||
|
| 3338 |
workspaceReadOrder(payload?.workspace) < entry.readAfter)).map((entry) => entry.paint);
|
| 3339 |
+
const canonical = { ...stored, config: normalizeMemberConfig(normalizeConfig(stored.config, fields)) };
|
| 3340 |
const previous = { ...canonical, ...applyPendingOps(canonical, pending) };
|
| 3341 |
+
const base = { ...before, config: normalizeMemberConfig(normalizeConfig(before.config, fields)) };
|
| 3342 |
+
const next = { ...after, config: normalizeMemberConfig(normalizeConfig(after.config, fields), base.config) };
|
| 3343 |
const intent = diffViewOps(base, next);
|
| 3344 |
const merged = { ...previous, ...applyPendingOps(previous, intent) };
|
| 3345 |
const ops = diffViewOps(previous, merged);
|
|
|
|
| 3368 |
}
|
| 3369 |
}
|
| 3370 |
return painted;
|
| 3371 |
+
}, [scope, emitHostEvent, payload?.workspace, fields]);
|
| 3372 |
const overlayNativeView = useCallback((view: SavedView) => {
|
| 3373 |
const ledger = nativeViewLedger.current;
|
| 3374 |
+
const server = { ...view, config: normalizeMemberConfig(normalizeConfig(view.config, fields)) };
|
| 3375 |
for (const edit of editOutbox.snapshot().pending) {
|
| 3376 |
const event = edit.payload as Extract<HostEvent, { type: "view_op" }>;
|
| 3377 |
if (edit.scope !== scope || edit.kind !== "event" || event.type !== "view_op" || event.view_id !== view.id) continue;
|
|
|
|
| 3393 |
}
|
| 3394 |
const restored = { ...server, ...applyPendingOps(server, paints) };
|
| 3395 |
return restored;
|
| 3396 |
+
}, [scope, payload?.workspace, fields]);
|
| 3397 |
useEffect(() => {
|
| 3398 |
if (embedded || queryBinding || hostOwnsLayout) return;
|
| 3399 |
return editOutbox.subscribeReceipts((edit, receipt) => {
|
|
|
|
| 3496 |
: surfaceStorageKey.startsWith(LOCAL_KEY_PREFIX)
|
| 3497 |
? `${LOCAL_KEY_PREFIX}${embedStorageKey(surfaceStorageKey.slice(LOCAL_KEY_PREFIX.length), true)}`
|
| 3498 |
: embedStorageKey(surfaceStorageKey, true);
|
| 3499 |
+
// Effects may use only the workspace state admitted by their render, before initialization queues its replacement.
|
| 3500 |
+
const workspaceInitialized = workspaceReady && initializedKey.current === storageKey;
|
| 3501 |
// A parent may rebuild an equivalent tree on every render. Depend on its value, not its identity,
|
| 3502 |
// so the initialization effect cannot re-seed over an edit still settling in this surface.
|
| 3503 |
const cellFilterKey = useMemo(() => JSON.stringify(cellFilter ?? null), [cellFilter]);
|
|
|
|
| 3753 |
useEffect(() => {
|
| 3754 |
// `hostWorkspace`: this adopts views out of `payload.workspace`, which a Query surface never
|
| 3755 |
// fetches. Keyed on `embedded` it would read a workspace that is not there.
|
| 3756 |
+
if (!workspaceInitialized || !hostWorkspace) return;
|
| 3757 |
if (workspaceError) {
|
| 3758 |
// S72-T57: a failed refresh keeps the last rail; writes stay withheld by `readOnly`.
|
| 3759 |
if (workspaceRefreshFailed) return;
|
|
|
|
| 3769 |
return;
|
| 3770 |
}
|
| 3771 |
const now = Date.now();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3772 |
const heldFields = reconcileHeldFields(fields, payloadFields, fieldStampsRef.current, now);
|
| 3773 |
const nextFields = adoptNewFields(
|
| 3774 |
heldFields, payloadFields, fieldStampsRef.current.deleted, now
|
|
|
|
| 3817 |
// ⚠ TERMINATION IS THE IDENTITY CONTRACT, not a flag: once corrected, both merges return
|
| 3818 |
// their input by reference and `nextViews === views`, so the next pass sets nothing and the
|
| 3819 |
// effect stops. That is why `views` can be a dependency at all.
|
| 3820 |
+
}, [workspaceInitialized, hostWorkspaceViews, payloadFields, fields, views, activeViewId,
|
| 3821 |
hostWorkspace, workspaceError, workspaceRefreshFailed, scope, payload?.workspace,
|
| 3822 |
overlayNativeView, saveStatus]);
|
| 3823 |
|
|
|
|
| 4297 |
personalLayoutInitialized, storageKey, viewAsReadOnly]);
|
| 4298 |
|
| 4299 |
useEffect(() => {
|
| 4300 |
+
if (viewAsReadOnly || !workspaceInitialized || embedded || hostOwnsLayout) return;
|
| 4301 |
const active = views.find((view) => view.id === activeViewId);
|
| 4302 |
if (!active || retiredHostViewIds.has(active.id) ||
|
| 4303 |
!canSaveViewDisplay(active.config.display, config.display) || sameConfig(active.config, config)) return;
|
|
|
|
| 4317 |
else if (routed.channel === "query")
|
| 4318 |
void routed.result.then((result) => { if (!result.ok) signal(TOAST_EVENT, result.message); });
|
| 4319 |
}
|
| 4320 |
+
}, [workspaceInitialized, activeViewId, config, views, embedded, queryBinding, scope, hostOwnsLayout,
|
| 4321 |
emitHostEvent, retiredHostViewIds, sendNativeViewOps, viewAsReadOnly]);
|
| 4322 |
|
| 4323 |
// Loading can replace the grid node without changing workspace readiness.
|
web/src/customer-grid/types.ts
CHANGED
|
@@ -5226,6 +5226,8 @@ export interface GridWorkspace {
|
|
| 5226 |
fields?: Field[];
|
| 5227 |
/** W48-T10: scoped record/field audit values, never bucket metadata. */
|
| 5228 |
auditTimestamps?: Record<string, { record: string; fields: Record<string, string> }>;
|
|
|
|
|
|
|
| 5229 |
/** C4 — the view rail's folders. Absent = no folders, the pre-wave-8 shape. */
|
| 5230 |
folders?: GridFolder[];
|
| 5231 |
/** C4 — the cohort rail's folders (the cohort page's workspace). */
|
|
|
|
| 5226 |
fields?: Field[];
|
| 5227 |
/** W48-T10: scoped record/field audit values, never bucket metadata. */
|
| 5228 |
auditTimestamps?: Record<string, { record: string; fields: Record<string, string> }>;
|
| 5229 |
+
/** Server-owned presentation fields with no cell or schema write authority. */
|
| 5230 |
+
layoutFields?: Field[];
|
| 5231 |
/** C4 — the view rail's folders. Absent = no folders, the pre-wave-8 shape. */
|
| 5232 |
folders?: GridFolder[];
|
| 5233 |
/** C4 — the cohort rail's folders (the cohort page's workspace). */
|
web/src/customer-grid/viewOps.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
import { isFilterGroup, mintFilterNodeId } from "./types";
|
| 2 |
import type { DisplaySpec, FilterNode, SavedView, SortRule, ViewConfig, ViewMember,
|
| 3 |
ViewMemberFamily, ViewMemberOp } from "./types";
|
| 4 |
export type { ViewMember, ViewMemberOp } from "./types";
|
|
@@ -35,6 +35,8 @@ const DIGITS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
| 35 |
const POSITION = /^[0-9A-Za-z]{1,64}$/;
|
| 36 |
const scalars = ["colorBy", "rowHeightMode", "frozenCount", "important", "secondaryView",
|
| 37 |
"application", "fullscreen"] as const;
|
|
|
|
|
|
|
| 38 |
type Snapshot = Pick<SavedView, "id" | "config"> & Partial<Pick<SavedView, "name" | "note" | "locked">>;
|
| 39 |
type Input = Snapshot | ViewConfig;
|
| 40 |
type FilterValue = { node: FilterNode; parent: string | null };
|
|
@@ -130,6 +132,7 @@ function nextPositions(before: string[], after: string[], old: Record<string, st
|
|
| 130 |
explicit: Record<string, string> = {}): Record<string, string> {
|
| 131 |
const moved = new Set(after.filter((key) => explicit[key] !== undefined && explicit[key] !== old[key]));
|
| 132 |
const stable = stationaryKeys(before.filter((key) => !moved.has(key)), after.filter((key) => !moved.has(key)));
|
|
|
|
| 133 |
const result: Record<string, string> = {};
|
| 134 |
after.forEach((key, i) => {
|
| 135 |
if (explicit[key] !== undefined && explicit[key] !== old[key]) {
|
|
@@ -138,7 +141,11 @@ function nextPositions(before: string[], after: string[], old: Record<string, st
|
|
| 138 |
} else if (stable.has(key)) result[key] = old[key];
|
| 139 |
else {
|
| 140 |
const next = after.slice(i + 1).find((candidate) => stable.has(candidate));
|
| 141 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 142 |
}
|
| 143 |
});
|
| 144 |
return result;
|
|
@@ -214,12 +221,17 @@ function members(view: Snapshot, fields: Set<string>, positions: Record<string,
|
|
| 214 |
for (const [key, value] of Object.entries(positions)) out.set(`position:${key}`, value);
|
| 215 |
for (const [key, value] of Object.entries(c.summary ?? {})) out.set(`summary:${key}`, value);
|
| 216 |
for (const pid of c.memberPids ?? []) out.set(`memberPid:${pid}`, true);
|
| 217 |
-
out.set("group", c.groupBy);
|
| 218 |
-
|
| 219 |
...(c.display ?? { mode: "grid" }), ...(c.groupSummary === undefined ? {} : { groupSummary: c.groupSummary }),
|
| 220 |
-
}
|
| 221 |
-
|
| 222 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 223 |
return out;
|
| 224 |
}
|
| 225 |
|
|
@@ -237,8 +249,11 @@ export function diffViewOps(before: Input, after: Input, viewId?: string): ViewM
|
|
| 237 |
const positions = seedPositions(ac.order, ac.positions);
|
| 238 |
const sorts = seedPositions(sortKeys(ac), savedSortPositions(ac));
|
| 239 |
const old = members({ ...a, config: ac }, fields, positions, sorts);
|
| 240 |
-
|
| 241 |
-
|
|
|
|
|
|
|
|
|
|
| 242 |
nextPositions(sortKeys(ac), sortKeys(bc), sorts, savedSortPositions(bc)));
|
| 243 |
const result: ViewMemberOp[] = [];
|
| 244 |
const emit = (member: ViewMember, op: "set" | "remove", value: unknown): void => {
|
|
@@ -342,7 +357,7 @@ function applyOne(view: Snapshot, op: ViewMemberOp): Snapshot {
|
|
| 342 |
c.memberPids = [...pids];
|
| 343 |
} else if (family === "group") c.groupBy = remove ? null : value as string | null;
|
| 344 |
else if (family === "display") {
|
| 345 |
-
if (remove) { delete c.display; delete c.groupSummary; }
|
| 346 |
else {
|
| 347 |
c.display = value as DisplaySpec;
|
| 348 |
if (c.display.groupSummary !== undefined) c.groupSummary = c.display.groupSummary;
|
|
|
|
| 1 |
+
import { DEFAULT_ROW_HEIGHT_MODE, isFilterGroup, mintFilterNodeId } from "./types";
|
| 2 |
import type { DisplaySpec, FilterNode, SavedView, SortRule, ViewConfig, ViewMember,
|
| 3 |
ViewMemberFamily, ViewMemberOp } from "./types";
|
| 4 |
export type { ViewMember, ViewMemberOp } from "./types";
|
|
|
|
| 35 |
const POSITION = /^[0-9A-Za-z]{1,64}$/;
|
| 36 |
const scalars = ["colorBy", "rowHeightMode", "frozenCount", "important", "secondaryView",
|
| 37 |
"application", "fullscreen"] as const;
|
| 38 |
+
const scalarDefaults = { colorBy: null, rowHeightMode: DEFAULT_ROW_HEIGHT_MODE, frozenCount: 1,
|
| 39 |
+
important: false, secondaryView: null, application: null, fullscreen: false };
|
| 40 |
type Snapshot = Pick<SavedView, "id" | "config"> & Partial<Pick<SavedView, "name" | "note" | "locked">>;
|
| 41 |
type Input = Snapshot | ViewConfig;
|
| 42 |
type FilterValue = { node: FilterNode; parent: string | null };
|
|
|
|
| 132 |
explicit: Record<string, string> = {}): Record<string, string> {
|
| 133 |
const moved = new Set(after.filter((key) => explicit[key] !== undefined && explicit[key] !== old[key]));
|
| 134 |
const stable = stationaryKeys(before.filter((key) => !moved.has(key)), after.filter((key) => !moved.has(key)));
|
| 135 |
+
const occupied = new Set([...Object.values(old), ...Object.values(explicit)]);
|
| 136 |
const result: Record<string, string> = {};
|
| 137 |
after.forEach((key, i) => {
|
| 138 |
if (explicit[key] !== undefined && explicit[key] !== old[key]) {
|
|
|
|
| 141 |
} else if (stable.has(key)) result[key] = old[key];
|
| 142 |
else {
|
| 143 |
const next = after.slice(i + 1).find((candidate) => stable.has(candidate));
|
| 144 |
+
const upper = next ? old[next] : null;
|
| 145 |
+
let position = fractionalPositionBetween(i ? result[after[i - 1]] : null, upper);
|
| 146 |
+
// Each member applies separately, so another moving key still occupies its old position.
|
| 147 |
+
while (occupied.has(position)) position = fractionalPositionBetween(position, upper);
|
| 148 |
+
result[key] = position;
|
| 149 |
}
|
| 150 |
});
|
| 151 |
return result;
|
|
|
|
| 221 |
for (const [key, value] of Object.entries(positions)) out.set(`position:${key}`, value);
|
| 222 |
for (const [key, value] of Object.entries(c.summary ?? {})) out.set(`summary:${key}`, value);
|
| 223 |
for (const pid of c.memberPids ?? []) out.set(`memberPid:${pid}`, true);
|
| 224 |
+
out.set("group", c.groupBy ?? null);
|
| 225 |
+
const display = {
|
| 226 |
...(c.display ?? { mode: "grid" }), ...(c.groupSummary === undefined ? {} : { groupSummary: c.groupSummary }),
|
| 227 |
+
};
|
| 228 |
+
if (display.groupSummary === false) delete display.groupSummary;
|
| 229 |
+
out.set("display", display.mode === "grid" && !display.groupSummary &&
|
| 230 |
+
Object.keys(display).every((key) => key === "mode" || key === "groupSummary") ? null : display);
|
| 231 |
+
for (const key of scalars) out.set(key, c[key] ?? scalarDefaults[key]);
|
| 232 |
+
if (view.name !== undefined) out.set("name", view.name);
|
| 233 |
+
out.set("note", view.note ?? "");
|
| 234 |
+
out.set("locked", view.locked ?? false);
|
| 235 |
return out;
|
| 236 |
}
|
| 237 |
|
|
|
|
| 249 |
const positions = seedPositions(ac.order, ac.positions);
|
| 250 |
const sorts = seedPositions(sortKeys(ac), savedSortPositions(ac));
|
| 251 |
const old = members({ ...a, config: ac }, fields, positions, sorts);
|
| 252 |
+
// Rendered orders omit unavailable columns. Their canonical positions remain untouched.
|
| 253 |
+
const nextColumnPositions = nextPositions(ac.order, bc.order, positions, bc.positions);
|
| 254 |
+
for (const [key, position] of Object.entries(positions))
|
| 255 |
+
if (nextColumnPositions[key] === undefined) nextColumnPositions[key] = position;
|
| 256 |
+
const next = members({ ...b, config: bc }, fields, nextColumnPositions,
|
| 257 |
nextPositions(sortKeys(ac), sortKeys(bc), sorts, savedSortPositions(bc)));
|
| 258 |
const result: ViewMemberOp[] = [];
|
| 259 |
const emit = (member: ViewMember, op: "set" | "remove", value: unknown): void => {
|
|
|
|
| 357 |
c.memberPids = [...pids];
|
| 358 |
} else if (family === "group") c.groupBy = remove ? null : value as string | null;
|
| 359 |
else if (family === "display") {
|
| 360 |
+
if (remove || value === null) { delete c.display; delete c.groupSummary; }
|
| 361 |
else {
|
| 362 |
c.display = value as DisplaySpec;
|
| 363 |
if (c.display.groupSummary !== undefined) c.groupSummary = c.display.groupSummary;
|
web/src/shell/Shell.tsx
CHANGED
|
@@ -139,6 +139,7 @@ import { gridScopeFor } from "./dbFrame";
|
|
| 139 |
import { useEscapeClose } from "../ui/useEscapeClose";
|
| 140 |
import { useApplicationWizardOverlay } from "./useApplicationWizardOverlay";
|
| 141 |
import { BodyPortal } from "../customer-grid/OverlaySurface";
|
|
|
|
| 142 |
import { OPEN_APP_TEMPLATE_EVENT } from "../sheet/templates/templatesApi";
|
| 143 |
import { AppMark } from "../apps/templateMarks";
|
| 144 |
import type { TemplateModule } from "../sheet/templates/templatesApi";
|
|
@@ -1804,6 +1805,10 @@ function ShellFrame() {
|
|
| 1804 |
viewEmitCancel.current?.();
|
| 1805 |
viewEmitCancel.current = retryEmit(
|
| 1806 |
() => {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1807 |
signal(VIEW_OPEN_EVENT, { topic: gridScopeFor(database), viewId });
|
| 1808 |
},
|
| 1809 |
undefined,
|
|
|
|
| 139 |
import { useEscapeClose } from "../ui/useEscapeClose";
|
| 140 |
import { useApplicationWizardOverlay } from "./useApplicationWizardOverlay";
|
| 141 |
import { BodyPortal } from "../customer-grid/OverlaySurface";
|
| 142 |
+
import { ALL_VIEW_ID } from "../customer-grid/types";
|
| 143 |
import { OPEN_APP_TEMPLATE_EVENT } from "../sheet/templates/templatesApi";
|
| 144 |
import { AppMark } from "../apps/templateMarks";
|
| 145 |
import type { TemplateModule } from "../sheet/templates/templatesApi";
|
|
|
|
| 1805 |
viewEmitCancel.current?.();
|
| 1806 |
viewEmitCancel.current = retryEmit(
|
| 1807 |
() => {
|
| 1808 |
+
const address = readDataAddress(window.location.hash);
|
| 1809 |
+
// A later Table choice ends this opening request, including its remaining retries.
|
| 1810 |
+
if (address.database !== database
|
| 1811 |
+
|| (address.view || ALL_VIEW_ID) !== (viewId || ALL_VIEW_ID)) return true;
|
| 1812 |
signal(VIEW_OPEN_EVENT, { topic: gridScopeFor(database), viewId });
|
| 1813 |
},
|
| 1814 |
undefined,
|