Repository navigation
Commit 71e02ff
fix(studio): the CEL condition builder offers membership, not equals, on a list field (#36185)
<!-- claude-projects-attribution: {"github_login":"os-project-manager"}
-->
_Requested by **Leehom** · [project
thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1XP3RHGWUG7UH3fNa4tBa9UC)_
Part of #36167 — the builder half. The card's Done-when also names
`validateExpression` refusing a list compared with a scalar; that half
narrows an accept set and is not built here: the seat picked option A on
the card (7068927390), and area a4-C claimed it (7068951634) under its
own `Part of #36167`.
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 在 Studio 里给多值字段(多选、标签、多选人员或多选关联)写条件时,操作符从「等于 / 不等于」换成「包含 / 不包含 / 为空 /
不为空」;单值字段不变。
- 属于 Studio 条件编辑器:多值字段上的「等于」永远不成立、作者毫无提示,这次让编辑器只给出能真正命中的写法。
- 已保存的「多值字段 等于 某值」条件会改为在表达式框里原样打开,不会被改写;若有问题,作者看到的是表达式框而非行编辑器,可直接撤回本改动。
- 要你做的:决定是否另做「保存时拒绝多值字段与单值比较」的那一半(见卡片报告里的待决问题)。
## What changes
- `ConditionBuilder` (the Studio CEL condition builder behind hook,
validation-rule, action visibility, page-block and flow entry
conditions) now offers a **list subject** (a `multiselect` /
`checkboxes` / `tags`, or a `select` / `lookup` / `user` declared
`multiple: true`) exactly what the shared filter builder offers it:
contains, does not contain, is empty, is not empty. `==` / `!=` /
ordering are no longer offered there. Which operators a list takes is
read from `jsonColumnFilterOperators` (through the new
`listSubjectOperators`), not restated; a small table only translates
those names onto the builder's own operator values.
- Contains writes `S != null && V in S`, does not contain writes `S ==
null || !(V in S)`. That is the spelling the flow edge's rows shipped;
it now lives in one module, `inspectors/cel-list-membership.ts`
(`listMembershipCel` / `readListMembership` / `listSubjectOperators`),
and `flow-edge-condition-rows.ts` writes through it too (its output is
byte-for-byte unchanged; its existing pins hold).
- A row moved onto a list subject leaves `equals` for `contains`; moved
off a list, membership becomes `equals`. An operator offered on both
sides (is empty / is not empty) stays, re-spelled for the new field.
- A stored condition whose row uses an operator its subject is not
offered (for example `record.labels == 'frontend'` on a list, or
membership on a single-value field) opens in the raw expression editor
exactly as stored: never rewritten, nothing emitted.
- New studio locale key `engine.inspector.condition.op.notContains` (en,
zh).
## Tests
- New pin `ConditionBuilder.listSubject-36167.test.tsx` (27 tests): each
of six list subjects offers the shared builder's list set and nothing
else; three single-value controls keep equals / not equals and get no
membership; the written CEL equals what the flow edge's `rowsToCel`
writes for the same row and is evaluated by `celEngine` (member true,
non-member false, `[]` and `null` null-safe both ways); stored
membership round-trips; stored `==` / `!=` on a list and membership on a
single-value field open raw and verbatim; an instrument control shows
the replaced `==` answering a constant.
- Fixture triage: three existing pins
(`ConditionBuilder.typedEmptyOps-11894`, two cases;
`ObjectValidationsPanel.typedEmptyOps-11894`, one case) seeded a list
subject's row as `S == 'x'` only to reach its operator dropdown. That
seed now opens in the raw editor, so it became the membership row; what
each case pins (the empty check on a list, and that `multiple` reaches
the builder) is unchanged and still needs the flag to reach the builder.
## Acceptance notes
- Re-measured under `celEngine` (objectstack tree at this branch): `'a'
in S` with `S = null` faults (no such overload for `string in` a null
dyn), with `S = []` answers false; `S == 'a'` is false for `['a','b']`
and for `null`; `S.contains('a')` faults on a list. Hence the null guard
on both membership spellings.
- A stored `S == null` / `S != null` on a list subject also opens raw
now (the builder's own spelling for it is is empty / is not empty).
Unchanged bytes, by the round-trip rule.
- The schema-driven condition widget's catalog (`ResourceEditPage`'s
object fetch) dropped `multiple` on this branch's base. #36182 (merged
to `main` as 865df27) closes it: the fetch now goes through
`objectCatalogOf`, which carries `multiple: true`, and the condition
widget hands that catalog to `ConditionBuilder` unprojected, so after
this PR lands a `select` / `lookup` / `user` declared `multiple: true`
is a list subject at that mount too. `multiselect` / `checkboxes` /
`tags` are lists by type alone. The hook, page-block, action, flow-entry
and validation-panel mounts carry `multiple`.
- `node scripts/pm/overlap-check.mjs` reports a textual overlap with
draft PR #35923 on the studio en / zh catalogues (different keys). Not
merged around.
## Verification
Read first (risk order):
1.
`ui/packages/app-shell/src/views/metadata-admin/inspectors/ConditionBuilder.tsx`:
`initFrom` (the new offered-operator check that sends a stored row to
the raw editor) and `withOfferedOp` on a subject change.
2.
`ui/packages/app-shell/src/views/metadata-admin/inspectors/cel-list-membership.ts`:
the shared spelling and reader.
3.
`ui/packages/app-shell/src/views/metadata-admin/inspectors/flow-edge-condition-rows.ts`:
now writes through the shared module.
Two-minute check: `pnpm --dir ui exec vitest run
packages/app-shell/src/views/metadata-admin/inspectors/ConditionBuilder.listSubject-36167.test.tsx`
— expect 27 passed.
Local readings at `ef21bbcb31` (objectstack tree):
<details><summary>Tests, type-check, ablation</summary>
- `ConditionBuilder.listSubject-36167.test.tsx`: 27 passed. All
`inspectors/ConditionBuilder*`, `flow-edge-condition-rows*`,
`FlowEdgeInspector*` suites: 22 files, 262 tests passed (two locked
runs; five suites first failed to collect on an unbuilt
`@objectstack/client`, passed once it was built).
- Mount-site suites (`ObjectValidationsPanel*`, `FlowNodeConfigField*`,
`HookDefaultInspector*`, `ActionDefaultInspector*`,
`PageBlockInspector.visibleWhen*`, `FlowNodeInspector.entryCondition*`,
`widgets*ondition*`): 33 files, 323 passed, 1 failed before triage (the
`ObjectValidationsPanel.typedEmptyOps-11894` list seed); after triage
that file passes, run with `packages/i18n/` (106 files, 1967 passed) and
with `ui/scripts/` (175 files, 5126 passed).
- `pnpm --filter @object-ui/app-shell type-check` and `pnpm --filter
@object-ui/i18n type-check`: exit 0 (lock VERDICT command-exit 0).
- Ablation (one-off, restored byte-identical to the HEAD blob): deleting
the list branch of `opChoicesFor` through `scripts/ablation-replace.mjs`
(anchor 1 to 0) turns the new pin 19 failed / 8 passed of 27; the 8 are
the single-value controls, the instrument control and the raw-open
cases.
</details>
<details><summary>Gates</summary>
`node scripts/pm/dispatch-gates.mjs --commands` (diff-derived, 38
families) all exit 0 at `ef21bbcb31`; `--ran` reconciliation: 38
derived, 38 run, 0 NOT-MEASURED (a derived zero). `pnpm --dir ui
check:new-line-citations`: 0 new. ESLint on the changed files: 0 errors
(warnings pre-existing). CI runs the full farm.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01FEkQ5okniknzVVR3KTSVr1)_
<!-- signed: repo:objectstack#4 · os-project-manager ·
session_01FEkQ5okniknzVVR3KTSVr1 -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 1d06026 commit 71e02ff
9 files changed
Lines changed: 470 additions & 27 deletions
File tree
- .changeset
- ui/packages
- app-shell/src/views
- metadata-admin/inspectors
- studio-design
- i18n/src/namespaces/studio
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
0 commit comments