Skip to content
This repository was archived by the owner on Nov 4, 2026. It is now read-only.

Commit 18d1a0a

Browse files
fix(plugin-grid,components,react): row-menu and data-table row-action disabled gates fail closed while permissions load, and ActionProvider binds current_user on its runner (objectui#11242) (#11268)
Fixes #11242 Clause-②: yes (widening) Rider 1 of objectui#4421 on the last two authored-action `disabled` legs, and the "one bag" rule (objectui#6493) for the shared action runner. The ruling, verbatim: "permission-shaped bindings are **fail-closed while the permissions payload has not loaded** — the opposite of the predicate default — or the first-paint leak reappears. Pin this." For a `disabled` gate, closed means DISABLED. ## What changed Measured through the real `MePermissionsProvider`, `ExpressionProvider`, `ActionProvider` and the production renderers, one verb (`delete`), three states. The "before" column was measured at the base `615346d61` with the new pin copied into an unmodified tree, before any source edit: exactly the 6 arms marked in capitals were red there. | leg | before: not loaded / granted / denied | after | |:--|:--|:--| | row menu item (`RowActionMenu`), `disabled: !current_user.can('account', 'delete')` | ENABLED / enabled / disabled | DISABLED / enabled / disabled | | data-table row action (`data-table`, a related list's rows), same gate | ENABLED / enabled / disabled | DISABLED / enabled / disabled | | built-in Delete `disabledWhen`, both menus (the control) | enabled / enabled / disabled | unchanged | | runner `disabled` re-check through `useAction()`, no action-engine block on the page | refused / REFUSED / refused | refused / runs / refused | | `page:header` click, granted, no action-engine block on the page | button enabled, runner REFUSED | button enabled, runner runs | - **Row menu item (`@object-ui/plugin-grid`) and data-table row action (`@object-ui/components`).** The same mechanism PR objectui#11237 gave `page:header`'s `disabled` leg: the caller passes its key's own fail direction (`fallback: true`) to the row-predicate entry, and the policy is per key, not a `can()` special case. That entry's fallback also answers an ABSENT predicate, so the verdict counts only where a gate is declared, read through core's one definition of that question (`hasDeclaredPredicate`). An absent, empty or blank `disabled` stays not disabled (pinned). - **Scope question (not-loaded only, or every fault?).** Every fault, as PR objectui#11237 did for `page:header`: a `disabled` that faults on an unbound root (`nope.deep == 1`) is DISABLED on both legs (pinned). - **Built-in `disabledWhen` (`RowActionMenu`, `data-table`) is untouched** and stays fail-soft, as documented and pinned since PR objectui#4515 (option B was not taken). The `BuiltinRowActionPredicates` docblock in `RowActionMenu.tsx` said that posture renders the item disabled; it leaves it enabled (the spec's own wording, and the existing `RowActionMenu.test.tsx` pin). The docblock is corrected in the file this PR already edits, and now says where the two families part. - **`ActionProvider` (`@object-ui/react`)** binds the predicate scope's subject (`usePredicateScope().current_user`) as `current_user` on its runner: the same object, not a copy, bound during render and keyed on the subject's serialisable fields and its permissions map, never on its identity (AGENTS.md #10). The runner's `user` / `ctx.user` / `os.user` stay the host's object. So every `execute` gate under a provider mounted inside the scope answers `current_user`, whatever else the page mounts. - **`useActionEngine`'s PR objectui#11237 write is KEPT, because it is measured still needed** (ablation legs A4 and A5 below). Under a provider mounted inside the scope it only re-binds the object the provider already bound (A4: 0 red). It is the only writer for two runners: the hook's own standalone runner (A5: the standalone arm goes red), and a shared runner whose provider sits ABOVE the scope (probe P1: `record:quick_actions` GRANTED reads HIDDEN without it). The console's global provider is that shape: `GlobalActionRuntimeProvider` wraps the routes and `ExpressionProvider` is mounted inside them. Only its comment changed. - **`ActionRunner.execute`'s `disabled`-gate comment (`@object-ui/core`), comment only.** It said a fault "defaults to NOT-disabled". `evaluateCondition` handles its own faults and answers its fail-soft `true`, which on this key refuses the action; the `catch` is reached only by a throw from outside that handling. The code is right. - **Docs (`content/docs/layout/page-header.mdx`).** The row menu's items now take the same `disabled` direction as the header, in a grid and in a related list's table, and the built-in `disabledWhen` is named as the exception. The page also states that on the runner's own gates `current_user.can(…)` answers while `user.can(…)`, `ctx.user.can(…)` and `os.user.can(…)` fault (probe P3), as the review of PR objectui#11237 noted. No `user` binding is added. ## Mechanism assumptions (PM Zone 2), measured - PR objectui#11237 is on `main` as `8bab1571d` (`merge-base --is-ancestor` exit 0), and its diff and review were read first. - `usePredicateScope` is exported from `packages/react/src/hooks/useExpression.ts`, same package as `ActionProvider`: held. - The not-loaded reach is the one objectui#11212 measured (outside `MePermissionsProvider`: `/forms/:name`, standalone embeds). It was not re-measured through the real `App` here. ## Ablation (HEAD `17a2920d9`, fix committed first) Every mutation went through `ablation-replace.mjs` (the anchor had to hit once, the landing was proven by the anchor count and the blob hash, and each restore was proven as blob == HEAD with an empty `git diff HEAD`). Each leg ran 7 files, 100 tests: this pin, the objectui#11212 and objectui#4421 pins, `RowActionMenu.test.tsx`, two data-table row-action suites, and the throwaway probe. The red counts were written down before the run, and all eight matched: | leg | predicted | red | |:--|:--|:--| | A1 row-menu `fallback: true` back to `false` | row menu NOT LOADED, unbound | 2, exactly those | | A2 data-table `fallback: true` back to `false` | data-table NOT LOADED, unbound | 2, exactly those | | A3 `ActionProvider` binding off | runner GRANTED, header click GRANTED | 2, exactly those | | A4 `useActionEngine` shared-runner write off | 0; P1 prints HIDDEN | 0; P1 HIDDEN | | A5 `useActionEngine` standalone binding off | standalone quick_actions GRANTED | 1, exactly that | | A6 row-menu declared-gate check off | row menu NOT LOADED (companion), absent/blank | 2, exactly those | | A7 data-table declared-gate check off | same two, data-table | 2, exactly those | | A8 A3 and A4 together | A3's two, plus objectui#11212 quick_actions GRANTED and DENIED | 4, exactly those | All four mutated files ended as their HEAD blobs, and the tree was clean afterwards. ## Tests and gates (HEAD `17a2920d9`, clean tree, heavy runs through the shared verify lock) - New pin `packages/app-shell/src/providers/__tests__/currentUserCan-disabledLegs-11242.render.test.tsx`, 23 tests: both legs × three states, plus unbound and absent/blank arms; the built-in control × two menus × three states; the runner gate × three states, plus a real `page:header` click; and `record:quick_actions` with no provider × three states. Each arm has an ungated companion and its own action name. - Union, `pnpm exec vitest run` from the root, in chunks under `timeout 300`, every chunk exit 0: - `packages/plugin-grid/src/`: 174 files, 1595 tests, all passed (two halves: 87 / 758 and 87 / 837). A first single-chunk attempt hit the `timeout 300` wall after 125 files with 0 failures and was replaced by the two halves. - `packages/components/src/__tests__/` and `packages/components/src/renderers/complex/`: `Test Files 105 passed | 1 skipped (106)`, `Tests 1158 passed | 7 skipped`; then `Test Files 106 passed (106)`, `Tests 905 passed`. - `packages/react/src/` and `packages/app-shell/src/providers/`: `Test Files 129 passed (129)`, `Tests 1609 passed`. - 87 consumer test files outside those trees that name `ActionProvider`, `useActionEngine`, `RowActionMenu`, `DataTableRowActionItem` or `rowActionDefs` (app-shell views, plugin-detail, plugin-view, plugin-dashboard, core, …): `Test Files 87 passed (87)`, `Tests 957 passed`. - Root `scripts/__tests__/` (this diff edits markdown): `Test Files 177 passed | 2 skipped (179)`, `Tests 5371 passed | 2 skipped`. - Build: `turbo run build --filter='@object-ui/app-shell^...' --concurrency=2`, 28 tasks successful (after the `plugin-grid^...` closure, 13 tasks). - `type-check` exit 0 for `@object-ui/core`, `@object-ui/react`, `@object-ui/components`, `@object-ui/plugin-grid` and `@object-ui/app-shell` (its `tsconfig.test.json` includes `src/**/*.test.tsx`, so the new pin is typed). - eslint on the 6 changed source and test files: 0 errors. Warnings per file equal the base counts; the new pin has 2 (`registered()`'s `ComponentType` of any, as in the objectui#11212 pin). - Exit 0: `node scripts/check-changeset-presence.mjs`, `check:control-bytes`, `check:new-line-citations`, `changeset:check`, `check:changeset-claims` (report-only), `check:pending-changeset-literals`, `check:doc-types`, `check:doc-fences`, `check:doc-example-ids`, `docs:check-links`, `node scripts/markdown-test-inputs.mjs --audit`, `check:action-forward-parity`, `check:test-path-roots`. `check-governed-queue-guard.mjs --test` over the 8 paths: NOT GOVERNED. - NOT MEASURED: `check:doc-snippets` and `check:doc-examples`. Both printed PRECONDITION NOT MET (exit 2): they need the 36-package docs build filter, and this tree has the 28-package closure. The doc edit adds prose only, with no fenced code. ## Acceptance notes (not filed) - **Open for the seat: the console's global runner.** `ActionProvider` binds only from a scope above it. The console's `GlobalActionRuntimeProvider` sits above `ExpressionProvider`, so probe P2 (provider above the scope, no engine block) still refuses a grant holder at this head. The routes that execute through that runner alone (dashboard, report, component, `/forms/:name`) answer `current_user` on `execute` gates only after an engine consumer has mounted, as before. No authored gate there was found to reach it: dashboard header defs carry only name, type, target and label. The options are in the report. - **Inline primary row action ignores `disabled`.** `RowActionInlineButton` (`RowActionMenu.tsx`) never reads the key. Probe P4: `disabled: true` and a denied `disabled: !current_user.can(…)` both render an enabled button, and only the runner refuses the click. This is the declared-gate class (objectui#3812), not this card's fault-policy class, and no producer of a primary `list_item` action with `disabled` was found. The docs above say "the row menu's items" deliberately. Carrier: none. - **`page:header` renders a BLANK `disabled` disabled.** Probe P5: `disabled: ' '` and a `{ dialect: 'cel', source: ' ' }` envelope render DISABLED. `''` and the empty-source envelope render enabled. `resolveDisabled` tests `!src` without trimming, and since PR objectui#11237 the blank branch of the row-predicate entry returns the header's `true` fallback. Core's `hasDeclaredPredicate` (objectui#3850 / objectui#3960) calls both values not declared, as `ActionRunner`, `action:button` and now both row legs do. So on a blank `disabled` the header and the row menu disagree. `containers.tsx` is outside this claim. Carrier: none. --- _Generated by [Claude Code](https://claude.ai/code/session_011p7ikEivgXefNDaE5S5Uec)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 7d074ba commit 18d1a0a

8 files changed

Lines changed: 541 additions & 21 deletions

File tree

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
'@object-ui/components': minor
3+
'@object-ui/plugin-grid': minor
4+
'@object-ui/react': minor
5+
---
6+
7+
fix: a row-menu action gated through `disabled` stays disabled until the permissions payload has loaded, in a grid and in a related list's table, and an `<ActionProvider>` answers `current_user` in the runner's own gates
8+
9+
A custom row action whose `disabled` asks `current_user.can(...)` has no answer until the
10+
signed-in user's permissions have loaded. In the row menu of a grid (`RowActionMenu`) and
11+
of a data table (the related list's rows), that unanswerable gate used to leave the item
12+
ENABLED, so `disabled: "!current_user.can('account', 'delete')"` offered the action to
13+
everyone while the page loaded, and kept offering it where the permissions never load (the
14+
`/forms/:name` route, a standalone embed). Both menus now render a `disabled` predicate that
15+
cannot be evaluated as DISABLED, the way `page:header` already does, and the console names
16+
it once. This is the rule for the key, not a special case for `can`: a `disabled` that
17+
faults for any other reason (a misspelled root such as `nope.x == 1`) is disabled too,
18+
where it used to be enabled. An absent, empty or blank `disabled` is still not disabled.
19+
The built-in Edit and Delete keep their fail-soft `disabledWhen`.
20+
21+
`<ActionProvider>` (`@object-ui/react`) now binds the signed-in user from the surrounding
22+
`ExpressionProvider` as `current_user` on its runner. The runner checks an action's
23+
`disabled` again when the action runs, and that check used to fault on `current_user` unless
24+
the page also mounted `record:quick_actions`, `record:alert` or a dashboard, so a user who
25+
held the permission clicked an enabled header action and was told "Action is disabled".
26+
The check now answers `current_user.can(...)` under any provider mounted inside the
27+
predicate scope. On the runner's gates `user.can(...)`, `ctx.user.can(...)` and
28+
`os.user.can(...)` still fault, because there `user` is the host's own user object; write
29+
`current_user.can(...)`.

‎content/docs/layout/page-header.mdx‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,14 +156,22 @@ declaration gates both places.
156156
`OBJECT_PERMISSION_VERBS` in `@objectstack/spec/security`; a verb outside it is a fault,
157157
not a `false`.
158158
- Call it on the signed-in user. `user.can(…)`, `ctx.user.can(…)` and `os.user.can(…)`
159-
are the same call; a bare `can(…)`, or `record.can(…)`, is a fault.
159+
are the same call wherever an action is drawn; a bare `can(…)`, or `record.can(…)`, is
160+
a fault.
161+
- The action runner evaluates some gates against its own context: `record:quick_actions`
162+
filters its `visible` there, and the runner checks `disabled` again when the action is
163+
clicked. That context answers `current_user.can(…)`, but `user`, `ctx.user` and
164+
`os.user` there are the host's own user object, so `user.can(…)`, `ctx.user.can(…)` and
165+
`os.user.can(…)` fault on those gates. Write `current_user.can(…)`.
160166
- Until the permissions payload has loaded there is no answer: the call faults, and the
161167
gate stays closed. A header action whose `visible` faults is not rendered (see above),
162168
and one whose `disabled` faults is rendered disabled, so
163169
`disabled: "!current_user.can('account', 'delete')"` shows a greyed-out button until the
164-
answer arrives. The action renderers that draw actions elsewhere (`action:button`,
165-
`action:group`, `action:icon`, a related list's toolbar, `record:quick_actions`) hide a
166-
faulting `visible` the same way.
170+
answer arrives. The row menu's items do the same for the same `disabled`, in a grid
171+
and in a related list's table. The action renderers that draw actions elsewhere
172+
(`action:button`, `action:group`, `action:icon`, a related list's toolbar,
173+
`record:quick_actions`) hide a faulting `visible` the same way. The built-in Edit and
174+
Delete are different: their `disabledWhen` is left enabled when it faults.
167175
- `requiredPermissions` is a different gate: it names system capabilities, which the
168176
platform action route enforces as well as the UI. `current_user.can` asks about
169177
object permissions and does nothing on the server.

0 commit comments

Comments
 (0)