Repository navigation
Commit 06ce712
fix(console): evaluate a setting's visible predicate with the expression interpreter, and hide it when it does not evaluate (#13432)
<!-- claude-projects-attribution: {"github_login":"os-tesla"} -->
_Requested by **Tesla** · [project
thread](https://claude.ai/code/project/chan_01AXsQkLFKRdQCqQ3RTr6Jao?thread=cmsg_01AXsQkLFKRdQCqQ3RTr6JaoFczGz9PyHzzvPyUf2P99fn)_
- [x] Adds no product-specific widget, dialog, hook or string (see
AGENTS.md › Product-neutral renderer)
## What changes
`SettingsView`'s `evalVisibility` compiled a manifest's `visible` string
into a JavaScript function (`new Function` with a `with (data)` scope)
and showed the setting whenever that failed. It now evaluates the string
with `ExpressionEvaluator` from `@object-ui/core`, the CSP-safe
interpreter (`SafeExpressionParser`) the renderer already uses for every
other `visible` predicate, with the namespace's values bound as `data`.
Called with `throwOnError: true`; a predicate that does not evaluate
**hides** the setting.
## Why hide on error
The server evaluates the same string with its own closed grammar
(`evaluateVisibility` in `@objectstack/service-settings`) and refuses a
save whose `visible` it cannot parse. Showing a field the server treats
as broken was the console disagreeing with the server in the open
direction.
Every predicate the shipped manifests use (comparisons, `&&`, `||`, `!`
over `data.<key>`, for example `${data.lockout_threshold > 0}`)
evaluates as before. A bare identifier without the `data.` prefix no
longer resolves, which matches the server grammar.
## Tests
New `SettingsView.visibleExpression.test.tsx`, four cases: a predicate
that holds and one that does not, the relational and logical operators,
a predicate that does not parse (hidden), and an expression reaching
outside the `data` scope (hidden, and it has no side effect).
Red on `main`, green here: with the fix committed and `SettingsView.tsx`
alone restored from `main` (`2958f17`), the file answers **2 failed / 2
passed** (the two failures are the hide-on-error cases); with the fix,
**4 passed**.
## Local verification
- `pnpm exec vitest run apps/console/src/pages/settings/`: **30 files,
243 passed**
- `node scripts/check-changeset-presence.mjs`, `node
scripts/check-changeset-no-major.mjs`, `pnpm check:new-line-citations`,
`pnpm check:control-bytes`: exit 0
- `pnpm exec eslint` on the two touched files: exit 0 (3 pre-existing
warnings in `SettingsView.tsx`, none on the changed lines)
- NOT MEASURED locally: `@object-ui/console` `type-check`, which needs
the whole workspace built; left to CI's type-check job.
Changeset: `@object-ui/console` patch. No issue is linked: this work was
dispatched directly.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01SNJgKweepTFKCrYgaKeFZK)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 2958f17 commit 06ce712
3 files changed
Lines changed: 125 additions & 10 deletions
File tree
- .changeset
- apps/console/src/pages/settings
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
34 | 41 | | |
35 | 42 | | |
36 | 43 | | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | 44 | | |
41 | | - | |
42 | | - | |
| 45 | + | |
43 | 46 | | |
44 | | - | |
| 47 | + | |
45 | 48 | | |
46 | 49 | | |
47 | 50 | | |
| |||
| 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 | + | |
0 commit comments