Deploy AIOS web (React glide grid + FastAPI slice)
Browse files- RELEASES.json +1 -1
- VERSION +1 -1
- api/automation_engine.py +36 -2
- platform/core/user_tables.py +97 -7
- web/src/customer-grid/ColumnMenu.tsx +77 -1
- web/src/customer-grid/CustomerGrid.tsx +140 -12
- web/src/customer-grid/apiBridge.ts +44 -0
RELEASES.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
{
|
| 2 |
-
"current": "
|
| 3 |
"releases": [
|
| 4 |
{
|
| 5 |
"version": "v24",
|
|
|
|
| 1 |
{
|
| 2 |
+
"current": "a44fc14",
|
| 3 |
"releases": [
|
| 4 |
{
|
| 5 |
"version": "v24",
|
VERSION
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
|
|
|
|
| 1 |
+
a44fc14
|
api/automation_engine.py
CHANGED
|
@@ -8251,7 +8251,7 @@ def _rollup_ref_threshold(rows, field, sigmas):
|
|
| 8251 |
return (sum(nums) / len(nums)) + float(sigmas) * sd
|
| 8252 |
|
| 8253 |
|
| 8254 |
-
def _rollup_fold(fn, values):
|
| 8255 |
"""`values` (raw cells, in the order the window kept them) β the aggregate, as a STRING.
|
| 8256 |
|
| 8257 |
Returns `""` for "nothing to aggregate", NEVER `0`. β That distinction is this module's
|
|
@@ -8260,6 +8260,10 @@ def _rollup_fold(fn, values):
|
|
| 8260 |
that the creator gets no views.
|
| 8261 |
β The ONE exception is the count family, where zero IS the answer β "how many linked records"
|
| 8262 |
over an empty set is genuinely 0, not unknown.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8263 |
"""
|
| 8264 |
if fn == "countall":
|
| 8265 |
return str(len(values))
|
|
@@ -8274,6 +8278,32 @@ def _rollup_fold(fn, values):
|
|
| 8274 |
# Airtable's COUNT counts NUMERIC values; COUNTA counts non-empty ones. Keeping them
|
| 8275 |
# distinct is the whole reason both exist.
|
| 8276 |
return str(len([v for v in values if _lane_num(v) is not None]))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8277 |
if fn in _ROLLUP_NUM_FNS:
|
| 8278 |
nums = [n for n in (_lane_num(v) for v in values) if n is not None]
|
| 8279 |
if not nums:
|
|
@@ -8576,8 +8606,12 @@ def compute_relation_cells(rt, table_key, tables=None):
|
|
| 8576 |
else:
|
| 8577 |
hits = [pair for pair in hits if all(matches(pair))]
|
| 8578 |
src = str(bag.get("field") or "")
|
|
|
|
|
|
|
|
|
|
| 8579 |
want = _rollup_fold(str(bag.get("fn") or ""),
|
| 8580 |
-
[r.get(src) for _i, r in hits] if src else [1] * len(hits)
|
|
|
|
| 8581 |
if str(row.get(fk, "")) != want:
|
| 8582 |
changes.setdefault(rid, {})[fk] = want
|
| 8583 |
if not changes:
|
|
|
|
| 8251 |
return (sum(nums) / len(nums)) + float(sigmas) * sd
|
| 8252 |
|
| 8253 |
|
| 8254 |
+
def _rollup_fold(fn, values, ftype="text"):
|
| 8255 |
"""`values` (raw cells, in the order the window kept them) β the aggregate, as a STRING.
|
| 8256 |
|
| 8257 |
Returns `""` for "nothing to aggregate", NEVER `0`. β That distinction is this module's
|
|
|
|
| 8260 |
that the creator gets no views.
|
| 8261 |
β The ONE exception is the count family, where zero IS the answer β "how many linked records"
|
| 8262 |
over an empty set is genuinely 0, not unknown.
|
| 8263 |
+
|
| 8264 |
+
`ftype` is the SOURCE column's DECLARED type on the linked table (2026-08-10, D-92). Only
|
| 8265 |
+
`min`/`max` read it today; it defaults to `text` so every existing caller and every test that
|
| 8266 |
+
folds a bare list keeps its exact previous answer.
|
| 8267 |
"""
|
| 8268 |
if fn == "countall":
|
| 8269 |
return str(len(values))
|
|
|
|
| 8278 |
# Airtable's COUNT counts NUMERIC values; COUNTA counts non-empty ones. Keeping them
|
| 8279 |
# distinct is the whole reason both exist.
|
| 8280 |
return str(len([v for v in values if _lane_num(v) is not None]))
|
| 8281 |
+
# ββ 2026-08-10 β D-92 CLOSED: `min`/`max` OVER A DATE COLUMN.
|
| 8282 |
+
#
|
| 8283 |
+
# Both were numeric-only, so a rollup over `posted_at`, `due_date` or `order_date` rendered
|
| 8284 |
+
# BLANK forever while looking completely configured β the failure this module refuses
|
| 8285 |
+
# everywhere else, arriving through the one fold that had no type awareness. "Earliest order"
|
| 8286 |
+
# and "latest invoice due" are the two most ordinary date rollups there are, and
|
| 8287 |
+
# `odoo_relational` already ships `latest` over `due_date`, so the vocabulary claimed dates
|
| 8288 |
+
# and the fold did not.
|
| 8289 |
+
#
|
| 8290 |
+
# β NOT FIXED BY SNIFFING THE VALUES. An ISO date sorts correctly as a string, so a
|
| 8291 |
+
# string-compare fallback would have worked on well-formed data and silently mis-ordered a
|
| 8292 |
+
# `Aug 5, 2026` or a `2026-9-1` β [[measure-the-real-call]]'s shape. The DECLARED type is
|
| 8293 |
+
# already at this call site (`linked_types`), and `_sort_key` is already the one function that
|
| 8294 |
+
# turns a typed cell into a comparable key, blanks partitioned out. This reuses both rather
|
| 8295 |
+
# than growing a second idea of what a date is.
|
| 8296 |
+
# β RETURNS THE CELL, NOT THE KEY. `_sort_key` yields a comparison tuple; the answer a person
|
| 8297 |
+
# wants in the column is the stored date string exactly as the source row spells it.
|
| 8298 |
+
# β `min`/`max` ONLY. `sum`/`average`/`stdev` over dates are not blank by oversight β the mean
|
| 8299 |
+
# of two timestamps is a number this product has no column type for, and inventing one here
|
| 8300 |
+
# would be a value with no author.
|
| 8301 |
+
if fn in ("min", "max") and ftype == "date":
|
| 8302 |
+
keyed = [(k, str(v)) for k, v in
|
| 8303 |
+
((_sort_key(v, "date"), v) for v in values) if k is not None]
|
| 8304 |
+
if not keyed:
|
| 8305 |
+
return ""
|
| 8306 |
+
return (min(keyed) if fn == "min" else max(keyed))[1][:ROLLUP_MAX_CHARS]
|
| 8307 |
if fn in _ROLLUP_NUM_FNS:
|
| 8308 |
nums = [n for n in (_lane_num(v) for v in values) if n is not None]
|
| 8309 |
if not nums:
|
|
|
|
| 8606 |
else:
|
| 8607 |
hits = [pair for pair in hits if all(matches(pair))]
|
| 8608 |
src = str(bag.get("field") or "")
|
| 8609 |
+
# D-92 β the SOURCE column's declared type, read from the same `linked_types` map the
|
| 8610 |
+
# sort path above uses. `countall` folds a synthetic `[1]*n` with no source column at
|
| 8611 |
+
# all, so the default stands for it.
|
| 8612 |
want = _rollup_fold(str(bag.get("fn") or ""),
|
| 8613 |
+
[r.get(src) for _i, r in hits] if src else [1] * len(hits),
|
| 8614 |
+
(linked_types.get(lk_key) or {}).get(src, "text"))
|
| 8615 |
if str(row.get(fk, "")) != want:
|
| 8616 |
changes.setdefault(rid, {})[fk] = want
|
| 8617 |
if not changes:
|
platform/core/user_tables.py
CHANGED
|
@@ -101,9 +101,9 @@ def records_mutable(table_key, st=None):
|
|
| 101 |
return bool(table) and table.get('recordMode') != AUTOMATION_RECORD_MODE
|
| 102 |
|
| 103 |
#: The field types a user table may declare. β Kept a SUBSET of
|
| 104 |
-
#: `aios_grid.CUSTOM_FIELD_TYPES` (gated in verify_api's W18-UT section). `
|
| 105 |
-
#:
|
| 106 |
-
#:
|
| 107 |
#: contract C2): the engine and the automation-column picker read the DEFINITION, so a
|
| 108 |
#: grid-created automation column must be able to live there β the column's CELLS stay
|
| 109 |
#: machine-written (the engine is the writer). Before this, the grid's automation columns
|
|
@@ -116,8 +116,22 @@ def records_mutable(table_key, st=None):
|
|
| 116 |
#: β 2026-08-07 β `link` and `rollup` JOINED (the relational wave). They belong here for
|
| 117 |
#: `metric`'s reason, not `formula`'s: their cells are MACHINE-COMPUTED SERVER-SIDE and
|
| 118 |
#: materialised into the row, because a rollup reads ANOTHER TABLE'S ROWS β data the client has
|
| 119 |
-
#: not loaded and must not have to.
|
| 120 |
-
#:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
#: β `image` WAS MISSING FROM THIS SET UNTIL WAVE 27, AND THAT WAS A LIVE DEFECT β recorded
|
| 122 |
#: here because the shape repeats and the next kind will be added by somebody reading this line.
|
| 123 |
#: Wave-19 R7 landed `image` on FOUR of the five surfaces (the `FieldType` union, `CREATABLE_TYPES`,
|
|
@@ -130,7 +144,7 @@ def records_mutable(table_key, st=None):
|
|
| 130 |
#: found it (measured, not reviewed: `_clean_field({'type':'image'})` returned None).
|
| 131 |
UT_FIELD_TYPES = {'text', 'select', 'multiselect', 'user', 'int', 'currency', 'pct', 'date',
|
| 132 |
'checkbox', 'phone', 'email', 'url', 'rating', 'automation', 'json',
|
| 133 |
-
'link', 'rollup', 'code', 'image'}
|
| 134 |
#: A cell is still a scalar on the wire (`Row` values are strings/numbers) β what this bounds is
|
| 135 |
#: the DOCUMENT inside it. Source data is one already-paid provider response; keep it whole so a
|
| 136 |
#: provider field is never silently discarded merely because the response is rich. 32 MiB matches
|
|
@@ -314,6 +328,23 @@ def _slug(label):
|
|
| 314 |
return (s or 'table')[:40]
|
| 315 |
|
| 316 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 317 |
def clean_fields(raw):
|
| 318 |
"""Validate a caller-supplied field list into the stored shape οΏ½οΏ½οΏ½ refuse junk, never store
|
| 319 |
it. Returns a list of `{key,label,type,source}` dicts (source is always 'overlay': every
|
|
@@ -394,6 +425,16 @@ def clean_fields(raw):
|
|
| 394 |
entry = None
|
| 395 |
break
|
| 396 |
entry[bag_key] = bag
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 397 |
if entry is None:
|
| 398 |
seen.discard(key)
|
| 399 |
continue
|
|
@@ -1166,6 +1207,30 @@ def _clean_field(raw, previous=None):
|
|
| 1166 |
c = _agc._clean_code(code_raw)
|
| 1167 |
if c:
|
| 1168 |
out['code'] = c
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1169 |
return out
|
| 1170 |
|
| 1171 |
|
|
@@ -1186,9 +1251,19 @@ def is_computed_cell(field):
|
|
| 1186 |
The `ut_*` twin of `aios_grid.READONLY_CUSTOM_TYPES`, and deliberately a PREDICATE rather
|
| 1187 |
than a type set: a `link` is read-only when it is derived and editable when it is not, which
|
| 1188 |
a set of type names cannot express. `grid_events` is the wall that reads it.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1189 |
"""
|
| 1190 |
f = field or {}
|
| 1191 |
-
return (isinstance(f.get('metric'), dict) or f.get('type')
|
| 1192 |
or is_derived_link(f))
|
| 1193 |
|
| 1194 |
|
|
@@ -1370,6 +1445,21 @@ def sync_reciprocal_link(table_key, field_key, st=None):
|
|
| 1370 |
target = cur.get(target_key)
|
| 1371 |
if target is None:
|
| 1372 |
return cur
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1373 |
reciprocal_key = _reciprocal_link_key(table_key, field_key)
|
| 1374 |
reciprocal = _clean_field({
|
| 1375 |
'key': reciprocal_key,
|
|
|
|
| 101 |
return bool(table) and table.get('recordMode') != AUTOMATION_RECORD_MODE
|
| 102 |
|
| 103 |
#: The field types a user table may declare. β Kept a SUBSET of
|
| 104 |
+
#: `aios_grid.CUSTOM_FIELD_TYPES` (gated in verify_api's W18-UT section). `created_time` stays
|
| 105 |
+
#: out (a row-datum kind β a base column of it would have no author);
|
| 106 |
+
#: `image` is unchanged this wave. `automation` JOINED in WAVE 21 (item 7a,
|
| 107 |
#: contract C2): the engine and the automation-column picker read the DEFINITION, so a
|
| 108 |
#: grid-created automation column must be able to live there β the column's CELLS stay
|
| 109 |
#: machine-written (the engine is the writer). Before this, the grid's automation columns
|
|
|
|
| 116 |
#: β 2026-08-07 β `link` and `rollup` JOINED (the relational wave). They belong here for
|
| 117 |
#: `metric`'s reason, not `formula`'s: their cells are MACHINE-COMPUTED SERVER-SIDE and
|
| 118 |
#: materialised into the row, because a rollup reads ANOTHER TABLE'S ROWS β data the client has
|
| 119 |
+
#: not loaded and must not have to.
|
| 120 |
+
#: ββ 2026-08-10 β `formula` JOINED, and the argument that kept it out was answered rather than
|
| 121 |
+
#: overruled. "A base column of it would have no author" was about its VALUES, and that half is
|
| 122 |
+
#: still true: a formula cell is computed in the browser from the row's other cells and is stored
|
| 123 |
+
#: NOWHERE, here or anywhere else. What joins this set is the DEFINITION β the expression, the
|
| 124 |
+
#: label, the column's existence. Excluded, those landed in `<table>_table_workspace`, the
|
| 125 |
+
#: PER-USER overlay: measured on nurilab as `Trimmed reel views`, a column only its creator could
|
| 126 |
+
#: see on a database four people share. That is not a narrower feature, it is the same shape as
|
| 127 |
+
#: the rollup defect one stratum over ([[rollup-lives-in-the-definition-not-the-overlay]]) with a
|
| 128 |
+
#: different consequence β not "nothing can compute it" but "nobody else can SEE it".
|
| 129 |
+
#: β SAY THE LIMIT OUT LOUD, because this line will be read as a bigger promise than it is: the
|
| 130 |
+
#: values still do not exist server-side, so an automation, a rollup, a `where` clause and an
|
| 131 |
+
#: export still cannot read a formula column. Making the definition shared does not make the
|
| 132 |
+
#: number stored. A number the server must read is a `rollup` (link fold) or a `metric`.
|
| 133 |
+
#: β Its cells are therefore in `is_computed_cell` β the WRITE wall. Without that, `grid_events`
|
| 134 |
+
#: would accept a paste into a column whose renderer overwrites it on the next paint.
|
| 135 |
#: β `image` WAS MISSING FROM THIS SET UNTIL WAVE 27, AND THAT WAS A LIVE DEFECT β recorded
|
| 136 |
#: here because the shape repeats and the next kind will be added by somebody reading this line.
|
| 137 |
#: Wave-19 R7 landed `image` on FOUR of the five surfaces (the `FieldType` union, `CREATABLE_TYPES`,
|
|
|
|
| 144 |
#: found it (measured, not reviewed: `_clean_field({'type':'image'})` returned None).
|
| 145 |
UT_FIELD_TYPES = {'text', 'select', 'multiselect', 'user', 'int', 'currency', 'pct', 'date',
|
| 146 |
'checkbox', 'phone', 'email', 'url', 'rating', 'automation', 'json',
|
| 147 |
+
'link', 'rollup', 'code', 'image', 'formula'}
|
| 148 |
#: A cell is still a scalar on the wire (`Row` values are strings/numbers) β what this bounds is
|
| 149 |
#: the DOCUMENT inside it. Source data is one already-paid provider response; keep it whole so a
|
| 150 |
#: provider field is never silently discarded merely because the response is rich. 32 MiB matches
|
|
|
|
| 328 |
return (s or 'table')[:40]
|
| 329 |
|
| 330 |
|
| 331 |
+
def _ag_formula(raw):
|
| 332 |
+
"""`aios_grid._clean_formula`, reached the way this module reaches everything one layer up.
|
| 333 |
+
|
| 334 |
+
β ONE call site for the function-local import, shared by BOTH field doors (`clean_fields` and
|
| 335 |
+
`_clean_field`). `core` must not import `aios_grid` at module level β the API's boot path
|
| 336 |
+
depends on this module staying dependency-light β and the `code` branch already pays that
|
| 337 |
+
cost twice. A third and fourth copy of `import aios_grid as _agX` is how one of them ends up
|
| 338 |
+
calling a different validator.
|
| 339 |
+
|
| 340 |
+
β `valid_keys` IS DELIBERATELY NOT PASSED. See the note at `_clean_field`'s formula branch:
|
| 341 |
+
neither door has reliable sibling-field context, and a second, weaker copy of the ref rule is
|
| 342 |
+
worse than leaving refs to the read-time behaviour `_clean_formula` already documents.
|
| 343 |
+
"""
|
| 344 |
+
import aios_grid as _agf
|
| 345 |
+
return _agf._clean_formula(raw)
|
| 346 |
+
|
| 347 |
+
|
| 348 |
def clean_fields(raw):
|
| 349 |
"""Validate a caller-supplied field list into the stored shape οΏ½οΏ½οΏ½ refuse junk, never store
|
| 350 |
it. Returns a list of `{key,label,type,source}` dicts (source is always 'overlay': every
|
|
|
|
| 425 |
entry = None
|
| 426 |
break
|
| 427 |
entry[bag_key] = bag
|
| 428 |
+
# ββ 2026-08-10 β the FORMULA expression rides this door too, for the fourth time in the
|
| 429 |
+
# same seam (`pinned`, `code`, `link`/`rollup`, now this). A formula column created through
|
| 430 |
+
# `create()`/`set_fields()` with its expression dropped is a permanently blank column that
|
| 431 |
+
# renders, sorts and filters β the exact silent shape the paragraph above describes.
|
| 432 |
+
if entry is not None:
|
| 433 |
+
fx = (_ag_formula(f.get('formula')) if f.get('formula') is not None else None)
|
| 434 |
+
if (ftype == 'formula') != (fx is not None):
|
| 435 |
+
entry = None
|
| 436 |
+
elif fx is not None:
|
| 437 |
+
entry['formula'] = fx
|
| 438 |
if entry is None:
|
| 439 |
seen.discard(key)
|
| 440 |
continue
|
|
|
|
| 1207 |
c = _agc._clean_code(code_raw)
|
| 1208 |
if c:
|
| 1209 |
out['code'] = c
|
| 1210 |
+
# ββ 2026-08-10 β THE FORMULA EXPRESSION. Posture: `link`/`rollup`'s, not `code`'s β a
|
| 1211 |
+
# formula column with no expression is a column that can never show a value, so the pairing is
|
| 1212 |
+
# enforced BOTH WAYS and either half alone refuses the field.
|
| 1213 |
+
#
|
| 1214 |
+
# β `valid_keys` IS DELIBERATELY OMITTED, and it is the one real asymmetry with the overlay
|
| 1215 |
+
# door. `grid_events` passes the workspace's own key set, so a `{ref}` naming no column is
|
| 1216 |
+
# refused at write time there. This function is handed ONE field with no sibling context β
|
| 1217 |
+
# `add_field`/`patch_field` could supply the table's keys, but `clean_fields` validates a list
|
| 1218 |
+
# mid-construction where half the referenced columns do not exist yet, and `clean_machine_
|
| 1219 |
+
# fields` judges a list that has no table at all. A second, weaker copy of the ref rule in one
|
| 1220 |
+
# of the three would be the divergence this module keeps paying for. STRUCTURE is checked here
|
| 1221 |
+
# (charset, length, balanced parens and quotes, well-formed refs); an unresolvable ref blanks
|
| 1222 |
+
# the CELL client-side, which is `_clean_formula`'s own documented read-time behaviour and the
|
| 1223 |
+
# same answer a later-deleted column already produces.
|
| 1224 |
+
# β Reached through `_ag_formula` so BOTH doors call one validator through one import.
|
| 1225 |
+
formula_raw = (raw.get('formula') if 'formula' in raw
|
| 1226 |
+
else (prev.get('formula') if prev_type == ftype else None))
|
| 1227 |
+
if formula_raw is not None:
|
| 1228 |
+
fx = _ag_formula(formula_raw)
|
| 1229 |
+
if fx is None or ftype != 'formula':
|
| 1230 |
+
return None
|
| 1231 |
+
out['formula'] = fx
|
| 1232 |
+
elif ftype == 'formula':
|
| 1233 |
+
return None
|
| 1234 |
return out
|
| 1235 |
|
| 1236 |
|
|
|
|
| 1251 |
The `ut_*` twin of `aios_grid.READONLY_CUSTOM_TYPES`, and deliberately a PREDICATE rather
|
| 1252 |
than a type set: a `link` is read-only when it is derived and editable when it is not, which
|
| 1253 |
a set of type names cannot express. `grid_events` is the wall that reads it.
|
| 1254 |
+
|
| 1255 |
+
ββ 2026-08-10 β `formula` JOINS, and it is the one member here whose value the server does
|
| 1256 |
+
NOT compute. Every other member is refused because the server owns the number; a formula cell
|
| 1257 |
+
is refused because NOBODY owns a stored number β the browser recomputes the column on every
|
| 1258 |
+
paint from the row's other cells, so a value written here is overwritten on screen before it
|
| 1259 |
+
is ever read and sits in the store as a fossil no reader agrees with. The client already
|
| 1260 |
+
declines to offer an editor (`READONLY_CELL_TYPES`) and declines the paste
|
| 1261 |
+
(`coerceClipboardValue`); both are courtesy, and this is the wall
|
| 1262 |
+
([[schema-role-is-not-a-value-wall]] β a courtesy in front of no wall is the shape that
|
| 1263 |
+
keeps shipping).
|
| 1264 |
"""
|
| 1265 |
f = field or {}
|
| 1266 |
+
return (isinstance(f.get('metric'), dict) or f.get('type') in ('rollup', 'formula')
|
| 1267 |
or is_derived_link(f))
|
| 1268 |
|
| 1269 |
|
|
|
|
| 1445 |
target = cur.get(target_key)
|
| 1446 |
if target is None:
|
| 1447 |
return cur
|
| 1448 |
+
# β 2026-08-10 β THE COLUMN CAP APPLIES TO A COLUMN NOBODY ASKED FOR, TOO.
|
| 1449 |
+
#
|
| 1450 |
+
# `add_field` refuses at `MAX_FIELDS`; this function appended straight past it, and the
|
| 1451 |
+
# field it appends lands on a table the user is not even looking at. The IG preset set is
|
| 1452 |
+
# 41 columns against a cap of 60, so a Posts or Comments database is genuinely reachable β
|
| 1453 |
+
# and the failure mode is the worst kind: the source link saves, the target silently grows
|
| 1454 |
+
# its 61st column, and every LATER `add_field` on that table is refused with a sentence
|
| 1455 |
+
# about a cap the user never crossed on purpose.
|
| 1456 |
+
# β THE SOURCE LINK STILL SAVES. Refusing the whole relation because the OTHER database is
|
| 1457 |
+
# full would be a refusal the user cannot act on from where they are standing; an ordinary
|
| 1458 |
+
# link with no reciprocal is exactly what every link was before this function existed, and
|
| 1459 |
+
# it still resolves its own cell. `reciprocal` is simply not stamped on the bag, so the
|
| 1460 |
+
# next `sync` on a table with room creates it β this is a skip, not a tombstone.
|
| 1461 |
+
if len(target.get('fields') or []) >= MAX_FIELDS:
|
| 1462 |
+
return cur
|
| 1463 |
reciprocal_key = _reciprocal_link_key(table_key, field_key)
|
| 1464 |
reciprocal = _clean_field({
|
| 1465 |
'key': reciprocal_key,
|
web/src/customer-grid/ColumnMenu.tsx
CHANGED
|
@@ -4,7 +4,7 @@ import type { AnchorRect } from "./OverlaySurface";
|
|
| 4 |
import { FieldTypeIcon, MenuLabel } from "./icons";
|
| 5 |
import { FieldSelectButton } from "./FieldSelect";
|
| 6 |
import { CODE_LANGUAGE_LABELS, CODE_LANGUAGES, CREATABLE_TYPES, choiceOptions, choiceRenames,
|
| 7 |
-
codeLanguageOf, directionLabel, isMachineOwned,
|
| 8 |
isProfileField, parseOptions, ratingMax, ROLLUP_FN_LABELS, ROLLUP_FNS,
|
| 9 |
ROLLUP_REF_OPS } from "./types";
|
| 10 |
import type { Field, FieldFormat, FieldScope, FieldType, Measure, RollupCondition, RollupFn,
|
|
@@ -1148,6 +1148,24 @@ function ExtraTypeEditor({
|
|
| 1148 |
}))}
|
| 1149 |
/>
|
| 1150 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1151 |
{formulaText.trim() !== "" && formulaError ? (
|
| 1152 |
<div className="cg-field-hint cg-formula-error">{formulaError}</div>
|
| 1153 |
) : showFormulaHelp ? (
|
|
@@ -2300,8 +2318,46 @@ export default function ColumnMenu({
|
|
| 2300 |
// states the consequence rather than the mechanism: clearing this cell also clears the
|
| 2301 |
// columns the enrichment wrote, and a person who does not know that reads the wipe as a bug.
|
| 2302 |
// That is the one fact worth a menu line here (DESIGN.md Β§4 β never over-explain).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2303 |
const typeLineBase = isProfileField(field)
|
| 2304 |
? "Instagram profile Β· clearing it clears the enriched columns"
|
|
|
|
|
|
|
| 2305 |
: isMachineOwned(field)
|
| 2306 |
? "Filled by automation"
|
| 2307 |
: field.measure
|
|
@@ -3373,8 +3429,28 @@ export default function ColumnMenu({
|
|
| 3373 |
type="button"
|
| 3374 |
className="is-danger"
|
| 3375 |
title={
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3376 |
field.measure
|
| 3377 |
? "Removes this formula column from the workspace."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3378 |
: "Removes this field AND its values on every row."
|
| 3379 |
}
|
| 3380 |
onClick={() => (confirmDelete ? onDelete() : setConfirmDelete(true))}
|
|
|
|
| 4 |
import { FieldTypeIcon, MenuLabel } from "./icons";
|
| 5 |
import { FieldSelectButton } from "./FieldSelect";
|
| 6 |
import { CODE_LANGUAGE_LABELS, CODE_LANGUAGES, CREATABLE_TYPES, choiceOptions, choiceRenames,
|
| 7 |
+
codeLanguageOf, directionLabel, isDerivedLink, isMachineOwned,
|
| 8 |
isProfileField, parseOptions, ratingMax, ROLLUP_FN_LABELS, ROLLUP_FNS,
|
| 9 |
ROLLUP_REF_OPS } from "./types";
|
| 10 |
import type { Field, FieldFormat, FieldScope, FieldType, Measure, RollupCondition, RollupFn,
|
|
|
|
| 1148 |
}))}
|
| 1149 |
/>
|
| 1150 |
</div>
|
| 1151 |
+
{/*
|
| 1152 |
+
β 2026-08-10 β THE BLANK TRAP, said before it is hit rather than after.
|
| 1153 |
+
|
| 1154 |
+
`{a} - {b}` is BLANK when `b` is blank, because arithmetic propagates a missing
|
| 1155 |
+
operand β so the trimmed-average chain the owner built ("views minus the outliers")
|
| 1156 |
+
blanks its whole column on exactly the profiles that have NO outlier to subtract,
|
| 1157 |
+
which is the majority of them. That reads as "the formula is broken" and the column
|
| 1158 |
+
it blanks is the one it was built for.
|
| 1159 |
+
|
| 1160 |
+
The idiom is Excel's own: the AGGREGATE functions skip blanks, so `SUM({b}, 0)` is
|
| 1161 |
+
"b, or nothing at all". Shown ALWAYS, not folded into the function list under
|
| 1162 |
+
`showFormulaHelp` β a list of 30 names is reference, and this is the one sentence
|
| 1163 |
+
that changes what somebody types. Kept to one line (DESIGN.md Β§4).
|
| 1164 |
+
*/}
|
| 1165 |
+
<div className="cg-field-hint cg-formula-blank-hint">
|
| 1166 |
+
A blank in any part blanks the whole result. Wrap an optional column as{" "}
|
| 1167 |
+
{"SUM({field}, 0)"} to read it as zero.
|
| 1168 |
+
</div>
|
| 1169 |
{formulaText.trim() !== "" && formulaError ? (
|
| 1170 |
<div className="cg-field-hint cg-formula-error">{formulaError}</div>
|
| 1171 |
) : showFormulaHelp ? (
|
|
|
|
| 2318 |
// states the consequence rather than the mechanism: clearing this cell also clears the
|
| 2319 |
// columns the enrichment wrote, and a person who does not know that reads the wipe as a bug.
|
| 2320 |
// That is the one fact worth a menu line here (DESIGN.md Β§4 β never over-explain).
|
| 2321 |
+
/**
|
| 2322 |
+
* ββ 2026-08-10 β WHICH SIDE OF THE RELATION IS THIS? (owner: "a linked field should spawn in
|
| 2323 |
+
* both databases")
|
| 2324 |
+
*
|
| 2325 |
+
* The spawn itself was already there β `user_tables.sync_reciprocal_link` creates the backlink
|
| 2326 |
+
* on the target for every ordinary link, and the two engines declare BOTH directions of their
|
| 2327 |
+
* derived links themselves. What was missing is the half a user can actually see: three
|
| 2328 |
+
* genuinely different columns all rendered as chips of linked rows and all described as
|
| 2329 |
+
* "Editable overlay field", including the computed reciprocal, which is not editable at all.
|
| 2330 |
+
*
|
| 2331 |
+
* The three, and the one fact that separates them:
|
| 2332 |
+
* ordinary β no `on`, no `inverse`. YOU pick the records. This is the stored truth.
|
| 2333 |
+
* reciprocal β `inverse` names the source field. Computed from the other side's picks;
|
| 2334 |
+
* typing here is refused (`is_computed_cell`), so saying "editable" was a lie.
|
| 2335 |
+
* derived β `on` names a column in the target that already holds this row's key. The
|
| 2336 |
+
* engine owns it; there is no picking on either side.
|
| 2337 |
+
*
|
| 2338 |
+
* β Read through `isDerivedLink`, never a fourth hand-rolled "does the bag have an `on`" β
|
| 2339 |
+
* `user_tables`' own note warns that a fourth reader is how one of them keeps answering yes
|
| 2340 |
+
* after the others stop.
|
| 2341 |
+
* β AHEAD of `isMachineOwned` for links only. "Filled by automation" is TRUE of a preset
|
| 2342 |
+
* derived link and it is the less specific true thing: the reader is deciding whether they can
|
| 2343 |
+
* click into this cell and pick something, and which side they are on is that answer.
|
| 2344 |
+
*/
|
| 2345 |
+
const linkTargetLabel =
|
| 2346 |
+
field.type === "link"
|
| 2347 |
+
? linkTargets.find((t) => t.key === field.link?.table)?.label ?? ""
|
| 2348 |
+
: "";
|
| 2349 |
+
const linkSideLine =
|
| 2350 |
+
field.type !== "link"
|
| 2351 |
+
? null
|
| 2352 |
+
: field.link?.inverse
|
| 2353 |
+
? `Linked from ${linkTargetLabel || "another database"} Β· rows that point here`
|
| 2354 |
+
: isDerivedLink(field)
|
| 2355 |
+
? `Links to ${linkTargetLabel || "another database"} Β· matched automatically`
|
| 2356 |
+
: `Links to ${linkTargetLabel || "another database"} Β· you pick the records`;
|
| 2357 |
const typeLineBase = isProfileField(field)
|
| 2358 |
? "Instagram profile Β· clearing it clears the enriched columns"
|
| 2359 |
+
: linkSideLine
|
| 2360 |
+
? linkSideLine
|
| 2361 |
: isMachineOwned(field)
|
| 2362 |
? "Filled by automation"
|
| 2363 |
: field.measure
|
|
|
|
| 3429 |
type="button"
|
| 3430 |
className="is-danger"
|
| 3431 |
title={
|
| 3432 |
+
/**
|
| 3433 |
+
* β 2026-08-10 β THE PRE-SET ROLLUP COMES BACK, and the honest place to say so is
|
| 3434 |
+
* here rather than in a tombstone.
|
| 3435 |
+
*
|
| 3436 |
+
* A pre-set column carries `automation.preset`, and BOTH reconcilers
|
| 3437 |
+
* (`_reconcile_ig_graph_fields`, `odoo_relational`'s forward migration) re-declare
|
| 3438 |
+
* every field they own on the next run. RECONFIGURING one sticks β the custody
|
| 3439 |
+
* stamp (`userEdited`) switches the reconciler off for that column β but DELETING
|
| 3440 |
+
* one leaves nothing behind to carry a stamp, so it is re-added within a tick.
|
| 3441 |
+
* β NOT FIXED WITH A TOMBSTONE, deliberately: that is a new store key two
|
| 3442 |
+
* reconcilers must both consult, and the custody stamp is the precedent for how
|
| 3443 |
+
* that goes wrong when only one of them reads it. The delete is not broken β it is
|
| 3444 |
+
* a delete of something the product re-declares, and the user is told which.
|
| 3445 |
+
*/
|
| 3446 |
field.measure
|
| 3447 |
? "Removes this formula column from the workspace."
|
| 3448 |
+
: field.automation?.preset === true
|
| 3449 |
+
? "Part of this database's built-in schema β it will be re-created on the " +
|
| 3450 |
+
"next run. Hide it to keep it off the grid."
|
| 3451 |
+
: field.type === "rollup" || field.type === "link" ||
|
| 3452 |
+
field.type === "formula"
|
| 3453 |
+
? "Removes this column. No values are lost β it holds none of its own."
|
| 3454 |
: "Removes this field AND its values on every row."
|
| 3455 |
}
|
| 3456 |
onClick={() => (confirmDelete ? onDelete() : setConfirmDelete(true))}
|
web/src/customer-grid/CustomerGrid.tsx
CHANGED
|
@@ -47,8 +47,8 @@ import { NAV_MINIMIZE_EVENT, ROWS_STALE_EVENT, TOAST_EVENT, VIEW_OPEN_EVENT,
|
|
| 47 |
WORKSPACE_STALE_EVENT, signal }
|
| 48 |
from "../apiContract";
|
| 49 |
import type { ViewOpenDetail } from "../apiContract";
|
| 50 |
-
import { addTableField, addTableRow, deleteTableRow, fetchLinkTargets,
|
| 51 |
-
patchTableField } from "./apiBridge";
|
| 52 |
import type { LinkTarget, RollupSourceOffer } from "./apiBridge";
|
| 53 |
import SelectFromFile from "./SelectFromFile";
|
| 54 |
// Owner item 16 / R4 / C-UNDO β the stack and every inverse. Pure, so a node gate can run it.
|
|
@@ -3704,13 +3704,38 @@ function CustomerGrid({
|
|
| 3704 |
* sending `{key,label,type}` here would trade a silent blank column for a loud 400. The
|
| 3705 |
* bag is on `extra`; `field` already carries it (see `FieldBuildExtra`).
|
| 3706 |
*/
|
| 3707 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3708 |
void addTableField(scope, {
|
| 3709 |
key: field.key,
|
| 3710 |
label: field.label,
|
| 3711 |
type,
|
| 3712 |
...(extra?.link ? { link: extra.link } : {}),
|
| 3713 |
...(extra?.rollup ? { rollup: extra.rollup } : {}),
|
|
|
|
|
|
|
|
|
|
| 3714 |
}).then((made) => {
|
| 3715 |
if (!made) return; // the bridge has already said why
|
| 3716 |
setFields((current) =>
|
|
@@ -3772,7 +3797,9 @@ function CustomerGrid({
|
|
| 3772 |
* The cells arrive on the next read β a rollup is recomputed server-side, never in the browser.
|
| 3773 |
*/
|
| 3774 |
const setFieldConfig = useCallback(
|
| 3775 |
-
(key: string, patch: {
|
|
|
|
|
|
|
| 3776 |
if (!isUserTable) return;
|
| 3777 |
void patchTableField(scope, key, patch as Record<string, unknown>).then((made) => {
|
| 3778 |
if (!made) return; // the bridge has already said why
|
|
@@ -3843,6 +3870,47 @@ function CustomerGrid({
|
|
| 3843 |
[config, updateConfig, order, visible, fieldByKey, lockedKey, stampFieldDelete]
|
| 3844 |
);
|
| 3845 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3846 |
/**
|
| 3847 |
* Change-field's "New field" half (wave-2 item 5): build the overlay field, then swap it into
|
| 3848 |
* the clicked column's slot β one motion, two emits (field_upsert + the config autosave),
|
|
@@ -5455,10 +5523,25 @@ function CustomerGrid({
|
|
| 5455 |
state={columnMenu}
|
| 5456 |
field={menuField}
|
| 5457 |
fields={fields}
|
| 5458 |
-
/
|
| 5459 |
-
|
| 5460 |
-
|
| 5461 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5462 |
rollupSourceOffer={rollupSourceOffer}
|
| 5463 |
locked={menuField.key === lockedKey}
|
| 5464 |
schemaLocked={isSchemaLocked(menuField)}
|
|
@@ -5500,7 +5583,24 @@ function CustomerGrid({
|
|
| 5500 |
onFormula={
|
| 5501 |
// Owner item 8 β edit a created FORMULA field's source in place; the optional
|
| 5502 |
// label rides the SAME upsert (see ColumnMenu's one-upsert rule).
|
| 5503 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5504 |
? (formula, label) =>
|
| 5505 |
saveField({
|
| 5506 |
...menuField,
|
|
@@ -5520,6 +5620,30 @@ function CustomerGrid({
|
|
| 5520 |
deleteField(menuField.key);
|
| 5521 |
setColumnMenu(null);
|
| 5522 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5523 |
: undefined
|
| 5524 |
}
|
| 5525 |
onDuplicate={
|
|
@@ -5615,9 +5739,13 @@ function CustomerGrid({
|
|
| 5615 |
// β TWO THINGS WERE BOTH WRONG (the fetch was gated on `columnMenu` and these props
|
| 5616 |
// were absent), so fixing either alone would still have shipped an empty picker and
|
| 5617 |
// read as "the fix did not work" β [[defects-that-mask-each-other]].
|
| 5618 |
-
// β
|
| 5619 |
-
//
|
| 5620 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5621 |
rollupSourceOffer={rollupSourceOffer}
|
| 5622 |
/>
|
| 5623 |
)}
|
|
|
|
| 47 |
WORKSPACE_STALE_EVENT, signal }
|
| 48 |
from "../apiContract";
|
| 49 |
import type { ViewOpenDetail } from "../apiContract";
|
| 50 |
+
import { addTableField, addTableRow, deleteTableField, deleteTableRow, fetchLinkTargets,
|
| 51 |
+
fetchRollupSources, patchTableField } from "./apiBridge";
|
| 52 |
import type { LinkTarget, RollupSourceOffer } from "./apiBridge";
|
| 53 |
import SelectFromFile from "./SelectFromFile";
|
| 54 |
// Owner item 16 / R4 / C-UNDO β the stack and every inverse. Pure, so a node gate can run it.
|
|
|
|
| 3704 |
* sending `{key,label,type}` here would trade a silent blank column for a loud 400. The
|
| 3705 |
* bag is on `extra`; `field` already carries it (see `FieldBuildExtra`).
|
| 3706 |
*/
|
| 3707 |
+
/**
|
| 3708 |
+
* ββ 2026-08-10 β `formula` JOINS THE SAME ROUTE, on the visibility argument the note
|
| 3709 |
+
* above weighs and the relational note declines to use.
|
| 3710 |
+
*
|
| 3711 |
+
* For `link`/`rollup` visibility was not the point (their cells are computed by something
|
| 3712 |
+
* that reads the definition). For a formula it IS the whole point, and the trade-off falls
|
| 3713 |
+
* the other way from wave 21's read of it: a `ut_*` database is a SHARED database β the
|
| 3714 |
+
* owner builds a column on "IG profile" and expects the four people looking at that
|
| 3715 |
+
* database to see it. In the overlay stratum only its creator ever does. Measured on
|
| 3716 |
+
* nurilab: `Trimmed reel views`, the trimmed-average column the whole rollup chain exists
|
| 3717 |
+
* to produce, was visible to exactly one account.
|
| 3718 |
+
*
|
| 3719 |
+
* β THE VALUES STILL DO NOT MOVE, and this must not be sold as more than it is. A formula
|
| 3720 |
+
* is computed in this browser (`computedRows`) from the row's other cells and is stored
|
| 3721 |
+
* nowhere; what became shared is the EXPRESSION. An automation, a rollup and an export
|
| 3722 |
+
* still cannot read this column. Sharing the definition is not materialising the number.
|
| 3723 |
+
*
|
| 3724 |
+
* β `agg: "sum"` rides along so the totals row behaves identically to the overlay path
|
| 3725 |
+
* (`buildOverlayField` stamps it) β a column that stops totalling because of which door
|
| 3726 |
+
* created it is [[gate-answers-the-wrong-question]] wearing a create route.
|
| 3727 |
+
*/
|
| 3728 |
+
if ((type === "automation" || type === "link" || type === "rollup"
|
| 3729 |
+
|| type === "formula") && isUserTable) {
|
| 3730 |
void addTableField(scope, {
|
| 3731 |
key: field.key,
|
| 3732 |
label: field.label,
|
| 3733 |
type,
|
| 3734 |
...(extra?.link ? { link: extra.link } : {}),
|
| 3735 |
...(extra?.rollup ? { rollup: extra.rollup } : {}),
|
| 3736 |
+
...(type === "formula" && extra?.formula
|
| 3737 |
+
? { formula: extra.formula, agg: "sum" }
|
| 3738 |
+
: {}),
|
| 3739 |
}).then((made) => {
|
| 3740 |
if (!made) return; // the bridge has already said why
|
| 3741 |
setFields((current) =>
|
|
|
|
| 3797 |
* The cells arrive on the next read β a rollup is recomputed server-side, never in the browser.
|
| 3798 |
*/
|
| 3799 |
const setFieldConfig = useCallback(
|
| 3800 |
+
(key: string, patch: {
|
| 3801 |
+
label?: string; link?: unknown; rollup?: unknown; formula?: string;
|
| 3802 |
+
}) => {
|
| 3803 |
if (!isUserTable) return;
|
| 3804 |
void patchTableField(scope, key, patch as Record<string, unknown>).then((made) => {
|
| 3805 |
if (!made) return; // the bridge has already said why
|
|
|
|
| 3870 |
[config, updateConfig, order, visible, fieldByKey, lockedKey, stampFieldDelete]
|
| 3871 |
);
|
| 3872 |
|
| 3873 |
+
/**
|
| 3874 |
+
* ββ 2026-08-10 β DELETE A COLUMN FROM A USER DATABASE'S SHARED DEFINITION.
|
| 3875 |
+
*
|
| 3876 |
+
* `deleteField` above writes the per-user overlay: it emits `field_delete`, which
|
| 3877 |
+
* `grid_events` gates on the `custom_`/`measure_` prefix and applies to
|
| 3878 |
+
* `<table>_table_workspace`. A definition column has a `custom_` key too, so that event is
|
| 3879 |
+
* ACCEPTED and scrubs a bucket the definition never reads β the column disappears for one
|
| 3880 |
+
* paint and is back on the next fetch. That is why this is a different function rather than a
|
| 3881 |
+
* branch: two stores, two truths, and the wrong one succeeds quietly.
|
| 3882 |
+
*
|
| 3883 |
+
* β SERVER FIRST, THEN THE SCREEN. `_field_or_refuse` can say no (a pre-set column, a
|
| 3884 |
+
* non-creator, the last remaining column), and the bridge has already shown its sentence β
|
| 3885 |
+
* removing the column optimistically would leave the user looking at a grid that disagrees
|
| 3886 |
+
* with the store until they reload.
|
| 3887 |
+
* β The VIEW config is scrubbed on the same terms as the overlay delete; a stale `colId` in
|
| 3888 |
+
* another view self-heals on its next autosave, the rule every other delete rides.
|
| 3889 |
+
*/
|
| 3890 |
+
const deleteDefinitionField = useCallback(
|
| 3891 |
+
(key: string) => {
|
| 3892 |
+
if (!isUserTable || key === lockedKey) return;
|
| 3893 |
+
void deleteTableField(scope, key).then((ok) => {
|
| 3894 |
+
if (!ok) return; // the bridge has already said why
|
| 3895 |
+
setFields((current) => current.filter((item) => item.key !== key));
|
| 3896 |
+
const nextWidths = { ...(config.widths ?? {}) };
|
| 3897 |
+
delete nextWidths[key];
|
| 3898 |
+
updateConfig({
|
| 3899 |
+
...config,
|
| 3900 |
+
order: order.filter((k) => k !== key),
|
| 3901 |
+
visible: [...visible].filter((k) => k !== key),
|
| 3902 |
+
widths: nextWidths,
|
| 3903 |
+
sorts: (config.sorts ?? []).filter((s) => s.colId !== key),
|
| 3904 |
+
groupBy: config.groupBy === key ? null : config.groupBy,
|
| 3905 |
+
colorBy: config.colorBy === key ? null : config.colorBy,
|
| 3906 |
+
});
|
| 3907 |
+
signal(WORKSPACE_STALE_EVENT);
|
| 3908 |
+
signal(ROWS_STALE_EVENT);
|
| 3909 |
+
});
|
| 3910 |
+
},
|
| 3911 |
+
[isUserTable, scope, lockedKey, config, updateConfig, order, visible]
|
| 3912 |
+
);
|
| 3913 |
+
|
| 3914 |
/**
|
| 3915 |
* Change-field's "New field" half (wave-2 item 5): build the overlay field, then swap it into
|
| 3916 |
* the clicked column's slot β one motion, two emits (field_upsert + the config autosave),
|
|
|
|
| 5523 |
state={columnMenu}
|
| 5524 |
field={menuField}
|
| 5525 |
fields={fields}
|
| 5526 |
+
/**
|
| 5527 |
+
* β 2026-08-10 β SELF-LINKING, and somebody asked for it (owner, D-113).
|
| 5528 |
+
*
|
| 5529 |
+
* The note this replaces excluded the current database with `linkTargets.filter(t =>
|
| 5530 |
+
* t.key !== scope)` and said so honestly: "a legal relation in Airtable and a confusing
|
| 5531 |
+
* one to explain in a one-line picker β¦ left out until somebody asks". It was a taste
|
| 5532 |
+
* call, not a constraint, and nothing below the picker ever needed it β `_clean_link`
|
| 5533 |
+
* only requires a `ut_*` key, and `sync_reciprocal_link` puts the backlink on the target
|
| 5534 |
+
* whichever table that is. "This lead is a duplicate of that lead" and "this record's
|
| 5535 |
+
* parent" are the ordinary cases, and both were unbuildable.
|
| 5536 |
+
*
|
| 5537 |
+
* β THE UNFILTERED LIST ALSO REPAIRS THE ROLLUP EDITOR, which is the half a one-line
|
| 5538 |
+
* change hides: it resolves the fold's source columns with
|
| 5539 |
+
* `linkTargets.find(t => t.key === chosenLink.link.table)`, so a rollup over a self-link
|
| 5540 |
+
* would have offered an EMPTY column picker and looked like the rollup was broken.
|
| 5541 |
+
* β Both `<ColumnMenu>` renders take the same list β the full menu and the "+" create
|
| 5542 |
+
* menu. One of the two is the half-landing this repo keeps paying for.
|
| 5543 |
+
*/
|
| 5544 |
+
linkTargets={linkTargets}
|
| 5545 |
rollupSourceOffer={rollupSourceOffer}
|
| 5546 |
locked={menuField.key === lockedKey}
|
| 5547 |
schemaLocked={isSchemaLocked(menuField)}
|
|
|
|
| 5583 |
onFormula={
|
| 5584 |
// Owner item 8 β edit a created FORMULA field's source in place; the optional
|
| 5585 |
// label rides the SAME upsert (see ColumnMenu's one-upsert rule).
|
| 5586 |
+
//
|
| 5587 |
+
// ββ 2026-08-10 β TWO STRATA, TWO DOORS, and the gate is `custom` rather than the
|
| 5588 |
+
// type. A formula column on a `ut_*` database now lives in the SHARED definition, and
|
| 5589 |
+
// definition fields carry no `custom` flag (`_clean_field` never stamps one) β so the
|
| 5590 |
+
// old single condition made the expression editor DISAPPEAR for exactly the columns
|
| 5591 |
+
// this change creates: creatable and then permanently frozen, which is a worse state
|
| 5592 |
+
// than the one it replaces. `setFieldConfig` PATCHes the definition; `saveField`
|
| 5593 |
+
// writes this user's overlay, and sending a definition field down that path would
|
| 5594 |
+
// fork the column into a private second copy of itself.
|
| 5595 |
+
menuField.type !== "formula"
|
| 5596 |
+
? undefined
|
| 5597 |
+
: isUserTable && !menuField.custom
|
| 5598 |
+
? (formula, label) =>
|
| 5599 |
+
setFieldConfig(menuField.key, {
|
| 5600 |
+
formula,
|
| 5601 |
+
...(label ? { label } : {}),
|
| 5602 |
+
})
|
| 5603 |
+
: menuField.custom
|
| 5604 |
? (formula, label) =>
|
| 5605 |
saveField({
|
| 5606 |
...menuField,
|
|
|
|
| 5620 |
deleteField(menuField.key);
|
| 5621 |
setColumnMenu(null);
|
| 5622 |
}
|
| 5623 |
+
: /**
|
| 5624 |
+
* ββ 2026-08-10 β the DEFINITION stratum's own delete.
|
| 5625 |
+
*
|
| 5626 |
+
* β NARROWED TO THE THREE KINDS THAT HOLD NO DATA OF THEIR OWN, which is
|
| 5627 |
+
* `preset_editable`'s argument reused rather than a new one: a link, a rollup and
|
| 5628 |
+
* a formula are all QUESTIONS asked of other cells, so removing one destroys no
|
| 5629 |
+
* measurement and can be undone by asking it again. Every other definition column
|
| 5630 |
+
* on a `ut_*` database holds real values, and offering a type-blind Delete over
|
| 5631 |
+
* those is a destructive widening this change has no mandate for (booked as
|
| 5632 |
+
* D-114). It is also exactly the three kinds `createField` now routes to the
|
| 5633 |
+
* definition β so what a user can make here, a user can unmake.
|
| 5634 |
+
* β `schemaLocked` still gates the button inside ColumnMenu, so a pre-set link
|
| 5635 |
+
* never shows it; a pre-set ROLLUP does, by the same owner ruling that made it
|
| 5636 |
+
* editable, and the confirm says it will come back.
|
| 5637 |
+
*/
|
| 5638 |
+
isUserTable &&
|
| 5639 |
+
!menuField.custom &&
|
| 5640 |
+
menuField.key !== lockedKey &&
|
| 5641 |
+
(menuField.type === "link" || menuField.type === "rollup" ||
|
| 5642 |
+
menuField.type === "formula")
|
| 5643 |
+
? () => {
|
| 5644 |
+
deleteDefinitionField(menuField.key);
|
| 5645 |
+
setColumnMenu(null);
|
| 5646 |
+
}
|
| 5647 |
: undefined
|
| 5648 |
}
|
| 5649 |
onDuplicate={
|
|
|
|
| 5739 |
// β TWO THINGS WERE BOTH WRONG (the fetch was gated on `columnMenu` and these props
|
| 5740 |
// were absent), so fixing either alone would still have shipped an empty picker and
|
| 5741 |
// read as "the fix did not work" β [[defects-that-mask-each-other]].
|
| 5742 |
+
// β 2026-08-10 β THE SELF-EXCLUSION IS GONE FROM BOTH SITES (D-113). The line this
|
| 5743 |
+
// replaces said the two call sites "must not disagree about that", and it was right for
|
| 5744 |
+
// a reason it did not anticipate: the exclusion was removed from the sibling first and
|
| 5745 |
+
// this copy kept it, so for one edit the "+" menu and the column menu offered DIFFERENT
|
| 5746 |
+
// databases β caught by grepping the prop rather than by the build, which is happy
|
| 5747 |
+
// either way. See the sibling's note for why self-links are offered now.
|
| 5748 |
+
linkTargets={linkTargets}
|
| 5749 |
rollupSourceOffer={rollupSourceOffer}
|
| 5750 |
/>
|
| 5751 |
)}
|
web/src/customer-grid/apiBridge.ts
CHANGED
|
@@ -497,6 +497,50 @@ export async function patchTableField(
|
|
| 497 |
}
|
| 498 |
}
|
| 499 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 500 |
/**
|
| 501 |
* ββ 2026-08-09 β THE DEFINITION SHAPE, NOT A THREE-KEY SUMMARY.
|
| 502 |
*
|
|
|
|
| 497 |
}
|
| 498 |
}
|
| 499 |
|
| 500 |
+
/**
|
| 501 |
+
* ββ 2026-08-10 β REMOVE a column from a user database's SHARED definition.
|
| 502 |
+
*
|
| 503 |
+
* β THE ROUTE HAS EXISTED SINCE THE DEFINITION DOORS WERE BUILT AND NOTHING EVER CALLED IT β
|
| 504 |
+
* `DELETE /api/v1/tables/{key}/fields/{fkey}`, mounted, guarded by `_field_or_refuse`, and
|
| 505 |
+
* unreachable from the product ([[artifact-with-no-importer]] from the consumer end). The
|
| 506 |
+
* consequence was invisible while only `link`/`rollup` used that stratum, because both arrive as
|
| 507 |
+
* pre-set columns on the databases people actually have. It stops being invisible the moment a
|
| 508 |
+
* FORMULA column lands there: `field_delete` (the overlay event) scrubs a per-user bucket the
|
| 509 |
+
* definition does not read, so the column would come back on the next render and the Delete
|
| 510 |
+
* control would be a button that lies.
|
| 511 |
+
*
|
| 512 |
+
* β NOT optimistic, unlike the overlay delete. The server refuses the last remaining column and
|
| 513 |
+
* refuses a pre-set one (`may_edit_field`), and removing a column from the screen that the store
|
| 514 |
+
* still holds is the same lie in the other direction.
|
| 515 |
+
*/
|
| 516 |
+
export async function deleteTableField(
|
| 517 |
+
tableKey: string,
|
| 518 |
+
fieldKey: string
|
| 519 |
+
): Promise<boolean> {
|
| 520 |
+
try {
|
| 521 |
+
const res = await fetch(
|
| 522 |
+
`${API_V1}/tables/${encodeURIComponent(tableKey)}/fields/${encodeURIComponent(fieldKey)}`,
|
| 523 |
+
{ method: "DELETE", credentials: CREDENTIALS }
|
| 524 |
+
);
|
| 525 |
+
if (handledSession(res)) return false;
|
| 526 |
+
if (!res.ok) {
|
| 527 |
+
const body = (await readJson(res)) as { detail?: { message?: string } } | null;
|
| 528 |
+
signal(TOAST_EVENT, typeof body?.detail?.message === "string"
|
| 529 |
+
? body.detail.message
|
| 530 |
+
: `The server answered ${res.status}.`);
|
| 531 |
+
return false;
|
| 532 |
+
}
|
| 533 |
+
// The schema moved, and a deleted LINK takes its reciprocal and every rollup that folded it
|
| 534 |
+
// with it (`_refresh_relations` runs on this route) β so the cached rows are values behind,
|
| 535 |
+
// not just a column behind. Same line `patchTableField` needed.
|
| 536 |
+
rowsCache.delete(`tables/${tableKey}/rows`);
|
| 537 |
+
return true;
|
| 538 |
+
} catch {
|
| 539 |
+
signal(TOAST_EVENT, "That delete did not reach the server.");
|
| 540 |
+
return false;
|
| 541 |
+
}
|
| 542 |
+
}
|
| 543 |
+
|
| 544 |
/**
|
| 545 |
* ββ 2026-08-09 β THE DEFINITION SHAPE, NOT A THREE-KEY SUMMARY.
|
| 546 |
*
|