Repository navigation
fix(app-shell): the condition builder offers user.isPlatformAdmin instead of user.isAdmin and user.role - #28848
Merged
Conversation
…tead of user.isAdmin and user.role The row builder's default context subjects offered `user.isAdmin`, a member `buildExpressionUser` never puts on the bag (a row on it faults), and `user.role`, better-auth's legacy scalar that reads `user` for a platform admin too. Offer `user.isPlatformAdmin` instead, teach it in the raw editor's example placeholder, and pin every offered `user.*` subject against the real expression scope on the admin, member and anonymous branches. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jSnzNBkkhbAQrfcS1S
Contributor
Author
|
domain:ui#1 · zhuangjianguo · session_01QsR2jUJ19MstFvFhjgiYTu 席位核对 · ACCEPT · 2026-11-02T00:42ZHead-sha:
Generated by Claude Code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Steedos · project thread
Fixes #28833
Clause-②: no
Metadata-protocol: none
维护者速读
user.isAdmin换成user.isPlatformAdmin,去掉user.role;原始 CEL 编辑器的示例占位文字同样改教user.isPlatformAdmin。新增一个测试,把列表里每个user.*主题拿到真实的表达式作用域里求值。buildExpressionUser)根本没有isAdmin,选它建出的行一求值就报错;user.role是 better-auth 的旧字段,平台管理员读出来也是user。两者都建不出「仅管理员可见」的门。ui/packages/app-shell一个源文件里的两个常量和测试,不动 spec、服务端和已存的元数据。已存的user.isAdmin/user.role条件照常以行模式打开,主题原样保留,不会被改写。实测examples/**与平台应用里没有使用这两个主题的条件。回滚 = revert 本 PR。ui/packages/app-shell/src/views/metadata-admin/inspectors/ConditionBuilder.tsx的CONTEXT_SUBJECTS与CEL_EXAMPLE_CLAUSES;再看新测试ConditionBuilder.contextSubjectsBag.test.ts。cd ui && pnpm exec vitest run packages/app-shell/src/views/metadata-admin/inspectors/ConditionBuilder.contextSubjectsBag.test.ts,应 1 个文件 8 个用例全部通过。What changes
CONTEXT_SUBJECTS, the row builder's default context subjects, now offersrecord.id,user.id,user.emailanduser.isPlatformAdmin:user.isAdmin→user.isPlatformAdmin. TheuserobjectbuildExpressionScopebinds (underuser,current_user,ctx.userandos.user) isbuildExpressionUser's output. On both branches its members areid,name,email,role,isPlatformAdminandpositions, and there is noisAdmin.isPlatformAdminis the platform-admin signal. It isfalseon the anonymous branch, so a row on it answers instead of faulting.user.roledropped. It is in the bag, but it is better-auth's legacysys_user.rolescalar. ObjectStack never writes it (ADR-0068 D2), and it readsuserfor a signed-in platform admin too.CEL_EXAMPLE_CLAUSES, the source of the raw editor's placeholder, teachesuser.isPlatformAdmininstead ofuser.isAdmin.Both constants are now exported so the new test can read them. Neither is re-exported by the package entry, so the published surface does not move.
conditionScope.tsneeds no edit. It names nousermember: it hands the server tierRECORD_CONDITION_SUBJECTS(record.idonly), the client tier inheritsCONTEXT_SUBJECTS, and its root lists (CLIENT_CONDITION_ROOTS) are roots, not members. So it follows the list by construction.The card says a row on
user.isAdmin"never opens". The row faults, and what a fault does depends on which gate evaluates the row. An action'svisible/disabledfail closed (useConditionwiththrowOnError,ActionEngine), and navigation withholds (evaluateNavigationVisibility), so on those the gate never opens. An object field'svisiblegoes throughevaluateVisibility, which fails open by documented design, so there it opens for everyone. Either way it never means "admins only".Tests
ConditionBuilder.contextSubjectsBag.test.ts(new, 8 cases,unitproject). It reads the member list offbuildExpressionUserfor a platform admin, a member and an anonymous visitor. It evaluates every offereduser.*subject againstcreateExpressionEvaluator(the real bag) on the evaluator's fail-closed seam. And it checks that a "user.isPlatformAdminis true" row opens for the admin only. Controls:user.isAdminfaults on every branch, anduser.roleresolves touserfor an admin and is not offered. The example placeholder'suserclause evaluates on every branch.ConditionBuilder.subjectVocabulary.test.tsx: the default-subject shape now listsuser.isPlatformAdminand neither removed subject.ConditionBuilder.contextSubjects.test.tsx: the "still offersuser.*" case holdsuser.isPlatformAdmin. Its lint leg passes foruser.isAdmintoo, because the engine lint accepts any member of an accepted root. That is why the new pin evaluates against the bag instead.ConditionWidget.conditionSubjects.test.tsx: one doc comment's example spelling.Ablation (scripts/ablation-replace.mjs, at 8f66ea8)
user.isAdminre-added toCONTEXT_SUBJECTS: 3 failed, 5 passed (each branch:expected [ 'id', 'name', 'email', 'role', …(2) ] to include 'isAdmin'). Restored, blob equal to HEAD.CEL_EXAMPLE_CLAUSESput back touser.isAdmin: 1 failed (the placeholder case), 7 passed. Restored, blob90d12c3fequal to HEAD,git diff HEADempty.Acceptance notes
git grepat2a4c0034overexamples,ui/examples,ui/appsandpackages(non-test, non-markdown) foruser/current_user/ctx.user/os.userwith.isAdminor.role. No authored condition uses either subject. The one hit is a test fixture,packages/metadata/src/__fixtures__/hotcrm-17.1-built-bare-root-predicates.artifact.json(current_user.role == "admin"). The other hits are doc comments inplugin-auth,specandruntimethat describe the legacy scalar.user.isAdminoruser.rolerow still opens in row mode. The builder appends an out-of-vocabulary subject as its own option, as fororg.id(ConditionBuilder.contextSubjects.test.tsx). Nothing is rewritten on open.user.nameanduser.positions, which are not offered. Adding subjects is outside this card.Verification
All on the final head
457b72bb(origin/main892eb668merged, which carries #28832), afterpnpm install --frozen-lockfileandturbo run build --filter='@object-ui/app-shell^...'plus formula, sdui-parser, lint and client (64 tasks, exit 0), underscripts/pm/os-verify-lock.sh.ConditionBuilder,conditionScope,CONTEXT_SUBJECTS,celExampleForRootsorbuildExpressionUser(git grep -l,--maxWorkers=2): 60 files, 667 tests passed. The same set withoutbuildExpressionUserat8f66ea84, before the merge: 53 files, 611 passed. CI's Test UI runs the rest of app-shell.pnpm --filter @object-ui/app-shell run type-check(bothtscprograms, the test one included): exit 0 at457b72bband at8f66ea84.react-refresh/only-export-componentswarnings on the newly exported constants are the same class as the file's existing ones (RECORD_CONDITION_ROOTS,celExampleForRoots).node scripts/pm/dispatch-gates.mjs --commands): 34 of 34 run at457b72bb, each exit 0 (check:type-check-debtunder the lock), includingnode scripts/check-sdui-manifest.mjs,pnpm --dir ui exec vitest run scripts/and the PR-body gates with this body asGITHUB_EVENT_PATH.--ranreconciles 34 derived, 34 run, 0 NOT-MEASURED, 0 UNRUN. Also 34 of 34 at8f66ea84.🤖 Generated with Claude Code
https://claude.ai/code/session_01QsR2jSnzNBkkhbAQrfcS1S