Repository navigation
Commit f66cd5a
fix(app-shell): a parenthesised metadata form condition is evaluated as a group, so the field form offers percent and currency rows only where the type allows (#38262)
<!-- claude-projects-attribution: {"github_login":"os-tesla"} -->
_Requested by **Tesla** · [project
thread](https://claude.ai/code/project/chan_01AXsQkLFKRdQCqQ3RTr6Jao?thread=cmsg_01AXsQkLFKRdQCqQ3RTr6JaoTzqUn46dDyQAFJbmNA3TzE)_
Fixes #38070
repo:objectstack#3 · os-tesla · session_01L9qibyUSf2nKJWW6qBemSU
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 管理员在 Studio
编辑字段时,「百分比显示」只在百分比字段和返回百分比的公式上出现,「货币」设置只在货币字段和返回货币的公式上出现;以前文本、货币、数字公式和空白字段上两组都会出现。
- 替每个打开字段编辑器的管理员解决:表单里带括号的显示条件以前一律被当成「显示」。
- 只改 Studio 表单读条件的方式,读不懂的条件照旧显示(按既有裁决);出问题最多是某行该出现没出现或反之,可以直接撤回。
- 无
## What changes
- `ui/packages/app-shell/src/views/metadata-admin/predicate.ts`: the
Studio metadata form evaluator reads `(expr)` grouping, as CEL does. One
branch in `evalExpr`: when the whole text is one balanced group, it
evaluates the inside. The branch sits after the `||` / `&&` splits,
which already leave a group whole, and before negation, so `!(a && b)`
negates the group. The matching `)` is found quote-aware, by the same
rule `splitTopLevel` uses, so a parenthesis inside a string literal is
never counted. The header's supported-subset list gains the grouping
line, and a new header section says why.
- Unchanged on purpose: a predicate the evaluator still cannot read (an
unbalanced parenthesis, a function call such as `size(data.x)`) still
fails open with the objectstack#6936 warning. The card's ask to make it
fail closed was cut in the claim's `Premise corrected` (comment
7237651782), quoting objectstack#6936 comment 5230638168 (Option C: an
unresolvable path evaluates TRUE, with a development-mode warning) and
ADR-0137 D3 ("A faulting `visibleWhen` shows the field.").
- One existing pin changes its diagnostic, not its verdict. The §9.7 pin
`('admin' in current_user.positions)` used to raise the objectstack#6936
unresolved-root warning, because the whole text was one operand with the
root segment `('admin' in current_user`. With the group stripped first,
the membership sits at depth 0 and raises the more precise objectui#6617
warning instead. The verdict stays `true`, and the §9.3 verdict table
that pins it is untouched. objectui#6617 is diagnostic-only by its
ruling, so this moves no ruled verdict. The header paragraph and the
`carriesTopLevelIn` docblock that called this spelling undetected are
rewritten to match.
- `packages/spec/src/data/field.metadata-form.ts` is not edited:
`percentDisplay` and `currencyConfig` keep their parenthesised CEL,
which now evaluates as written.
- Changeset: `@object-ui/app-shell` patch.
## Tests
`ui/packages/app-shell/src/views/metadata-admin/predicate.test.ts`, a
new top-level `describe` (§10) in the shared harness:
- 10.1 grammar: a whole-text group, a nested group, `!(…)` over a
comparison and over `&&`, `(a || b) && c` against the ungrouped `a || b
&& c`, a nested `a || (b && (c || d))`, an `in` set inside a group, and
`(` / `)` inside a string literal. Each case is true and false on two
drafts, with no warning.
- 10.2 still unreadable, still fail-open: an unbalanced `(`, a group
followed by `== true`, and `size(data.tags) > 0` each evaluate `true`
and warn once.
- 10.3 the two bundled rows, read from `fieldForm` in
`@objectstack/spec/data`: a non-vacuity guard that both still spell a
group, then `percentDisplay` and `currencyConfig` on seven drafts (table
below), with no warning.
- §9.7 pin rewritten as described above.
| draft | `percentDisplay` before → after | `currencyConfig` before →
after |
|---|---|---|
| text | true → **false** | true → **false** |
| percent | true → true | true → **false** |
| currency | true → **false** | true → true |
| formula returning percent | true → true | true → **false** |
| formula returning currency | true → **false** | true → true |
| formula returning number | true → **false** | true → **false** |
| empty draft | true → **false** | true → **false** |
"Before" was measured on `origin/main` bd5407e with a copy of the
evaluator. "After" is the §10.3 pin at this head.
## Acceptance notes
- Seen while measuring, not in this card: some malformed shapes already
evaluate `false` silently, without a throw or a warning. `data.type ==`,
`data.type === 'text'`, `data.type > 3` and `data.type == 'text')` all
behave this way, which does not match the header's "fail-open on any
parse error". Recorded here only, per the claim.
- Grouping is base CEL and the forms declare `dialect: 'cel'`, so this
does not grow the interim evaluator into a second dialect (the claim's
ruling on the route).
## Verification
- Two-minute check: `pnpm --dir ui exec vitest run
packages/app-shell/src/views/metadata-admin/predicate.test.ts`. Expect
173 passed, 24 of them grouping-dependent (§10 and the §9.7 pin).
- Read first: the grouping branch in `evalExpr` and `matchingCloseParen`
(`predicate.ts`), then §10.3 in `predicate.test.ts`.
<details><summary>Local readings at 571bb00</summary>
- `pnpm --dir ui exec vitest run` on `predicate.test.ts`,
`SchemaForm.unresolvedPredicate.test.tsx`,
`SchemaForm.optionVisibleWhen.test.tsx` and
`SchemaForm.nestedAnyOfPredicate-9830.test.tsx`: Test Files 4 passed,
Tests 198 passed.
- Ablation through `scripts/ablation-replace.mjs`: the grouping branch's
condition was prefixed with `false &&` (anchor 1 → 0, blob
`1c645a78f74b` → `f5ef536be108`). `predicate.test.ts` then had 24 failed
and 149 passed: all of 10.1, all seven 10.3 row cases, and the §9.7 pin.
10.2 and the guard stayed green, as expected. Restore: blob == HEAD
(`1c645a78f74b`), `git diff HEAD` empty.
- `eslint` on both source files: 0 errors, 1 warning (the existing `let
cur: any` in `resolveValue`, not this diff).
- `dispatch-gates --commands` derived 38 families, all run with exit
codes recorded (`--ran`: 38 derived, 38 run, 0 NOT-MEASURED, 0 UNRUN).
37 exit 0. `pnpm --dir ui exec vitest run scripts/` exit 1: 7 failed and
5138 passed, in `check-doc-snippet-types.test.ts` (1) and
`spec-symbol-ledger-plugin-detail-7265.test.ts` (6). Both read the built
`@objectstack/spec` type declarations, and this worktree's spec `dist`
comes from an `OS_SKIP_DTS=1` closure build. Neither test reads a file
this diff changes, so treat that red as NOT MEASURED locally. CI's `Test
UI` runs them on a clean build. `pnpm check:changeset-fixed` (run beyond
the derivation) exit 0.
- `@object-ui/app-shell` `type-check`: NOT MEASURED locally, because the
`@object-ui/*` and spec closures carry no type declarations in this
worktree (2606 errors, none in a changed file). CI's `Type Check UI`
decides.
- `overlap-check.mjs`: VERDICT clean exit 0 against origin/main
bd5407e, and 0 open PR heads share a file.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01L9qibxvV3AxCdD5DiVBy6V)_
Co-authored-by: Claude <noreply@anthropic.com>1 parent 73ec085 commit f66cd5a
3 files changed
Lines changed: 191 additions & 19 deletions
File tree
- .changeset
- ui/packages/app-shell/src/views/metadata-admin
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| |||
843 | 843 | | |
844 | 844 | | |
845 | 845 | | |
846 | | - | |
847 | | - | |
848 | | - | |
849 | | - | |
850 | | - | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
851 | 852 | | |
852 | 853 | | |
853 | 854 | | |
854 | 855 | | |
855 | | - | |
856 | | - | |
| 856 | + | |
| 857 | + | |
857 | 858 | | |
858 | 859 | | |
859 | 860 | | |
| |||
863 | 864 | | |
864 | 865 | | |
865 | 866 | | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
209 | 210 | | |
210 | 211 | | |
211 | 212 | | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
219 | 221 | | |
220 | 222 | | |
221 | 223 | | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
222 | 246 | | |
223 | 247 | | |
224 | 248 | | |
| |||
535 | 559 | | |
536 | 560 | | |
537 | 561 | | |
538 | | - | |
539 | | - | |
540 | | - | |
541 | | - | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
542 | 568 | | |
543 | 569 | | |
544 | 570 | | |
| |||
587 | 613 | | |
588 | 614 | | |
589 | 615 | | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
590 | 625 | | |
591 | 626 | | |
592 | 627 | | |
| |||
661 | 696 | | |
662 | 697 | | |
663 | 698 | | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
664 | 731 | | |
665 | 732 | | |
666 | 733 | | |
| |||
0 commit comments