You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 727f578
Browse filesBrowse the repository at this point in the historyBrowse files
feat(spec): an action can show the reader already pressed it — pressed
ActionSchema gains an optional per-reader pressed-state predicate (CEL over
the visible scope, display only, no boolean arm). The expression lint judges
it in the record scope as a served-row site, so an attachedOnRead block
resolves there. Liveness row planned; console half is a follow-up.
Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L9qibvXVNub8x3B5XhGFrP
`SPEC_ACTION_KEYS` lists `pressed`, the per-reader pressed-state predicate `@objectstack/spec` added to `ActionSchema`. An action that carries it is no longer counted as having an unknown key, and the inventory pin stays green. No surface reads the key yet.
feat(spec): an action can show the reader already pressed it — `pressed`
7
+
8
+
Clause-②: yes (widening)
9
+
Metadata-protocol: added
10
+
11
+
`ActionSchema` gains one optional key, `pressed`: a CEL predicate over the same scope as `visible` (the record and the reader) that says this reader already acted, such as a "Helpful" vote on a knowledge article. While it evaluates TRUE an action surface draws the button pressed (`aria-pressed`). An action that does not declare it parses exactly as before.
-**A CEL predicate, not a boolean.** A string is normalized to the `{ dialect: 'cel', source }` envelope, and the envelope is accepted as written. `pressed: true` / `false` is refused at parse: a constant draws every reader's button the same way, which is a style and not the reader's state. The blank and `ast`-only shapes every evaluated slot refuses are refused here too. `active`, `activeWhen` and `pressedWhen` are renamed onto it.
26
+
-**Display only.** It never gates, greys or routes the action. A pressed action stays runnable, and its own body decides what a second press does.
27
+
-**The reader's own state.** A per-reader fact is usually a child row (one vote per user), not a column. Declare it as a block under the object's `attachedOnRead`, attach it on the serving side for the caller (a service, or an `afterFind` hook that shapes the rows it returns), and read `record.<block>.<leaf>` behind `has()`.
28
+
-**Checked at build (`@objectstack/lint`).**`os build`, `os validate` and the object save door judge the predicate in the `record` scope, as they judge `visible`: a bare field reference is an error. An action's `pressed` is a served-row site, so a block the object declares under `attachedOnRead` resolves there and a misspelt leaf is refused.
29
+
30
+
Nothing draws the pressed face yet. The console's record header buttons and declared actions bar read the key in a follow-up change. Until then the liveness ledger marks it `planned` with `authorWarn`, so `os validate` warns an author who declares it that the button looks the same whatever the predicate answers.
Copy file name to clipboardExpand all lines: content/docs/protocol/objectui/actions.mdx
+21Lines changed: 21 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -246,6 +246,7 @@ interface Action {
246
246
requiresFeature?: string; // Public auth feature flag gate — lowered into `visible` at parse time
247
247
disabled?: boolean | ExpressionInput; // Disabled when TRUE (CEL)
248
248
disabledReason?: I18nLabel; // Why it is greyed — hover title + accessible description (display only)
249
+
pressed?: ExpressionInput; // Drawn as already pressed for this reader when TRUE (CEL; display only)
249
250
250
251
// Bulk
251
252
bulkEnabled?: boolean; // Apply to multiple selected records
@@ -349,6 +350,26 @@ disabledReason: An approved legal review is required before the contract enters
349
350
- A blank string (`''` or whitespace only) is refused at parse. Omit the key to keep the default.
350
351
- It is **display only**. It does not change what `disabled` evaluates to, nothing reads it as a condition, and it is not access control: a call that reaches the server anyway is refused by the action's own rules (its body or hook, `requiredPermissions`), never by this text.
351
352
353
+
#### The reader's own state: `pressed`
354
+
355
+
An action the reader toggles, such as a "Helpful" vote on a knowledge article, says the reader **already acted** with `pressed`, a CEL predicate over the same scope as `visible`. While it is true the button is drawn pressed (`aria-pressed="true"`).
- It is **display only**. A pressed action stays runnable, and the action's own body decides what a second press does (records the vote again, withdraws it, or answers "already").
366
+
- A boolean literal is refused: `pressed: true`would draw the button pressed for every reader, which is a style rather than the reader's state.
367
+
- A per-reader fact is usually not a column of the row (a vote is a child record per user). Declare it as a block under the object's `attachedOnRead`, have the serving side attach it to each row it returns for the caller (a service, or an `afterFind` hook that shapes the rows), and read it as `record.<block>.<leaf>`, guarded with `has()`. `os build` and `os validate` check the leaf against the declared block.
368
+
369
+
<Callout type="info">
370
+
The spec, the build check and this contract are in place; the console's record header and declared actions bar do not draw the pressed face yet, so today the button looks the same whatever the predicate answers.
371
+
</Callout>
372
+
352
373
#### Evaluation context
353
374
354
375
Action predicates evaluate against the **record the action is attached to**. Both `record.<field>` and the bare field name resolve to the current record's value:
note: 'Split from `cel-action-visible` rather than sharing one row with it, for the reason the collision assertion encodes: one classification covering both would have to pick one fail-policy, and the two faces are opposites — a faulting `visible` HIDES the action, a `disabled` the renderer cannot evaluate LEAVES IT RUNNABLE. A single row would have stated one of those and silently spoken for the other. ⛔ NOT MEASURED HERE: the renderer, and the `-log` half of `fail-soft-log` — the reading above establishes the soft DIRECTION from the objectui fix that removed the closed face, not that a line is logged; the same posture, and the same limit, as `cel-row-crud-disabled` on the built-in row buttons.',
431
431
},
432
+
{
433
+
// The key arrived with #27946, its spec half; the console half is a follow-up card.
434
+
id: 'cel-action-pressed',
435
+
summary: 'registered action pressed state (Action.pressed) — the per-reader toggle face of a button, drawn as aria-pressed',
'PARSE ONLY — `EvaluatedExpressionInputSchema` normalizes a bare string to `{dialect:"cel",source}` and refuses a boolean literal, an `ast`-only envelope and a blank source; NO EVALUATOR FOUND: no action surface reads the key yet. The build-time gate is in place ahead of the reader: lint/validate-expressions.ts `checkAction` checks it against the `record` scope on every declared action, as a served-row site where a block the object declares under `attachedOnRead` resolves',
note: 'EXPERIMENTAL until the console draws it: declared spec-first, with the liveness row `planned`. Display only by contract — it never gates, greys or routes the action — so when the reader lands its fault face is a plain, unpressed button, and this row is re-stated as `enforced` with that fail policy, naming the surfaces that evaluate it.',
441
+
},
432
442
{
433
443
id: 'cel-record-alert-visible',
434
444
summary: '`record:alert` banner visibility (RecordAlertProps.visible) — the one record component whose PROPS carry a real predicate',
Copy file name to clipboardExpand all lines: packages/spec/liveness/action.json
+9Lines changed: 9 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -158,6 +158,15 @@
158
158
"evidence": "ui/packages/components/src/renderers/layout/containers.tsx#disabledReasonFor (the record header, inline and in the ⋯ overflow: the declared reason, else `actions.notAvailableForRecord`); ui/packages/plugin-detail/src/renderers/record-quick-actions.tsx#QuickActionButton (the record section bar); ui/packages/app-shell/src/views/DeclaredActionsBar.tsx#DeclaredActionButton (the declared actions bar, button and override-menu item); ui/packages/components/src/renderers/action/disabled-reason.tsx#useDisabledReason (the four `action:*` renderers: `action-button.tsx`, `action-icon.tsx`, `action-group.tsx`, `action-menu.tsx`); ui/packages/react/src/hooks/useActionTextLocalizer.ts#useActionTextLocalizer and ui/packages/i18n/src/useObjectLabel.ts#useObjectLabel (`actionDisabledReason`: the bundle's `_actions.{a}.disabledReason` / `globalActions.{a}.disabledReason`, else the authored I18nLabel collapsed to the active language); packages/spec/src/system/i18n-resolver.ts#translateAction (the served overlay); packages/cli/src/utils/i18n-extract.ts#collectExpectedEntries (the extract).",
159
159
"note": "LIVE since the console half of #26619 (ruling 6442737825, letter A: spec PR #26786 first, this console PR second). Each greyed-action surface shows the declared reason as the hover title and the accessible description (a menu item's second line), only while the DECLARED `disabled` predicate is TRUE, and shows `actions.notAvailableForRecord` (\"Not available for this record\") when the action declares none or a blank one. The record header, the section bar and the declared actions bar run actions through `useActionTextLocalizer`, so the bundle's sentence outranks the authored text; the four `action:*` renderers read the action as authored and honour its inline locale map. `authorWarn` / `authorHint` were dropped in the same edit (a warned `live` row reds this gate, #21127). Display only by contract: never a server admission input, never read as a predicate."
160
160
},
161
+
"pressed": {
162
+
"status": "planned",
163
+
"verifiedAt": "2026-10-30",
164
+
"evidenceScope": "in-repo",
165
+
"authorWarn": true,
166
+
"authorHint": "Kept, but no console surface draws `pressed` yet: the button looks the same whatever the predicate answers. The predicate is still checked at build (record scope, declared fields and `attachedOnRead` blocks), so it is ready when the header buttons read it.",
167
+
"evidence": "packages/spec/src/ui/action.zod.ts#pressed (the parse-time door: `EvaluatedExpressionInputSchema`, a CEL string normalized to the envelope, a boolean literal and the blank shapes refused); packages/lint/src/validate-expressions.ts#checkAction (the authoring gate at `os build` / `os validate` and the object save door: the predicate is judged in the `record` scope, and as a SERVED_ROW_SITES member a block the object declares under `attachedOnRead` resolves)",
168
+
"note": "PLANNED — declared spec-first by #27946 (spec half; the console half is a follow-up domain:ui card). The reader to come is the record page header (`page:header` buttons) and `DeclaredActionsBar`, drawing the button with `aria-pressed` and a pressed face while the predicate is TRUE. Measured in this repo at origin/main 3a2f4c00: no source under ui/ reads `action.pressed` (the one hit is the inventory line in ui/packages/core/src/actions/actionKeys.ts SPEC_ACTION_KEYS, which restates the spec's declared keys and reads nothing), and no other package reads it. So an authored predicate draws nothing today; nothing is gated or stored differently, which is also the contract once it is live (display only). Flip to `live` on the console PR, citing its read points, and drop `authorWarn` / `authorHint` in the same edit (a warned `live` row reds this gate)."
0 commit comments