Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
62 changes: 62 additions & 0 deletions .changeset/36495-action-locations-acted-on.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
'@objectstack/spec': major
'@object-ui/types': major
'@objectstack/lint': minor
'@objectstack/runtime': minor
'@objectstack/platform-objects': minor
'@object-ui/core': minor
'@object-ui/components': minor
'@object-ui/plugin-detail': minor
'@object-ui/app-shell': minor
'@object-ui/i18n': minor
'@objectstack/cli': patch
'@objectstack/cloud-connection': patch
'@objectstack/objectql': patch
'@objectstack/metadata-protocol': patch
'@objectstack/plugin-approvals': patch
'@objectstack/scenarios': patch
'@objectstack/service-datasource': patch
'@objectstack/service-messaging': patch
'@objectstack/verify': patch
'@object-ui/console': patch
'@object-ui/fields': patch
'@object-ui/layout': patch
'@object-ui/plugin-grid': patch
'@object-ui/plugin-list': patch
'@object-ui/react': patch
---

feat(spec)!: an action's `locations` say what it acts on, not the part of the page it sits in

**BREAKING** (19.0.0): `ACTION_LOCATIONS` is `list`, `record`, `record_page`, `record_row`, `record_related`, `record_section`. The four words that named a part of a page are retired: `list_toolbar`, `list_item`, `record_header` and `record_more`. `record` is new: the action acts on one record, so it is drawn on the record page's header and in each list row's menu. Which actions are buttons and in what order stays the object's `actionLayout`.

Clause-②: yes (narrowing)
Metadata-protocol: narrowed
Skills-docs: follow-up #37895

<!-- adr-0087: registered action-locations-acted-on -->

A replacement with a registered conversion, so `yes (narrowing)` as on main's precedents (`.changeset/pre/37086-define-metadata-form-rename.md`, `.changeset/pre/37304-knowledge-source-governed-type.md`). Narrowed: the four retired words are refused wherever a location is read. Widened in the same change: the four newly accepted values `list`, `record`, `record_page` and `record_row` at the same positions; the new `@object-ui/types` export `actionFoldedIntoMenu`; and eight new `@object-ui/i18n` Studio keys for the location labels (en, zh), which replace the eight keys of the retired words.

FROM → TO (each action is drawn in exactly the places it was drawn before):

- `locations: ['list_toolbar']` → `locations: ['list']`.
- `locations: ['list_item']` → `locations: ['record_row']`.
- `locations: ['record_header']` or `['record_more']` → `locations: ['record_page']`.
- `record_header` or `record_more` beside `list_item` → `locations: ['record']`.
- `locations: ['record_more']` without `record_header` (the action lived only in the record header's ⋯ menu) → `locations: ['record_page'], component: 'action:menu'`. The fold is the action's `component`, the key that already sends an action into an action bar's overflow menu.
- A component's single `location` (`record:quick_actions`, `action:group`, `action:bar`): `list_toolbar` → `list`, `list_item` → `record_row`, `record_header` → `record_page`.

An old word is refused at authoring with the word to write instead. `os migrate meta --from 18 --write` rewrites sources (ADR-0087 conversion `action-locations-acted-on`, retired from the load path from day one, as every protocol-19 entry). Stored items (`applyConversionsToStoredItem`, `os migrate meta --stored`) and built artifacts replay the same conversion. It leaves a TODO, and changes nothing, where no lossless rewrite exists: a `record_more`-only action also on `list_toolbar` that does not already carry `component: 'action:menu'` (the list toolbar folds `action:menu` too); an action at `record_header` with an authored `component: 'action:menu'` (the record page header folded it into its ⋯ menu while a `record:quick_actions` bar at `record_header` drew it as a button, and `record_page` has one state for both); a component whose `location` is `record_more`; and an `action:group` at `record_header` with a `record_more`-only member. A site left as stored keeps its old word, which a protocol-19 runtime matches to no surface: that action or block is drawn nowhere until it is rewritten by hand. The protocol-19 upgrade guide carries the same step as the semantic entry `action-locations-page-parts-retired`.

Also in this change:

- `@object-ui/types`: `actionRendersAt` reads `record` as covering `record_page` and `record_row`. The new `actionFoldedIntoMenu(action)` answers whether an action is folded into the ⋯ (`component: 'action:menu'`). `arrangedHeaderActions` pins and unpins through `component` and no longer writes locations.
- `@object-ui/components`: the record `page:header` routes every folded action to its ⋯ menu, and every other `record_page` action takes the inline budget, as `record_header` actions did.
- `@object-ui/plugin-detail`: `record:quick_actions` defaults to `record_page` and leaves folded actions out at that location, as it left out `record_more`-only ones. The related list reads `record` as a row action.
- `@object-ui/core`, `@objectstack/runtime`: the record-scoped checks (`isRecordScopedAction`, `requiresRecord`) accept `record`.
- `@objectstack/lint`: the record-page header, related-list and action-layout rules read the new words.
- Studio: the action inspector, the `record:quick_actions` location dropdown and the action preview offer `record` and draw the fold as "record_page · ⋯".
- `@objectstack/platform-objects`, the examples and every other package: declarations and prose rewritten to the new words. The packages listed as `patch` change comments, test fixtures or authoring copy, except three that ship rewritten words: `@objectstack/plugin-approvals` and `@objectstack/service-datasource` (their declared actions' `locations`) and `@object-ui/layout` (a location literal it passes at runtime).

Not moved: #37895 (the `skills/**` teaching of the new words; Blocked-by this change).
2 changes: 1 addition & 1 deletion content/docs/getting-started/build-with-claude-code.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export const ResolveTicketAction = defineAction({
// to write or register; the platform performs the update.
operation: 'update',
patch: { status: 'resolved' },
locations: ['record_header', 'list_item'],
locations: ['record'],
// Only offer "Resolve" on tickets that aren't already resolved or closed.
// Predicates are CEL, record-scoped — `record.status`, never bare `status`.
// `has()` guards the sparse list row; the rule and its guard table live in
Expand Down
30 changes: 15 additions & 15 deletions content/docs/protocol/objectui/actions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ refreshAfter: true
**Request body shaping:**
- `bodyShape` — `'flat'` (default) sends collected params at the top level; `{ wrap: 'data' }` nests user params under that key.
- `bodyExtra` — constant fields merged into the request, applied last so they always win (e.g. `bodyExtra: { resend: true }`).
- `recordIdParam` / `recordIdField` — inject the current row id (or another row field) into a body key when the action runs from a `list_item` location.
- `recordIdParam` / `recordIdField` — inject the current row id (or another row field) into a body key when the action runs from a `record_row` location.

### Form Actions

Expand Down Expand Up @@ -273,15 +273,15 @@ Action `name` is the configuration ID and **must** be lowercase `snake_case` (`a

### Action Locations

The `locations` array declares where an action surfaces. The canonical enum (`ACTION_LOCATIONS`) is:
The `locations` array declares what an action acts on, and so where it surfaces. The canonical enum (`ACTION_LOCATIONS`) is:

| Location | Where it renders |
| --- | --- |
| `list_toolbar` | Header/toolbar of a list view (bulk actions, "New", export) |
| `list_item` | Per-row action on a list/grid row |
| `record_header` | Primary actions in the record-detail title bar |
| `record_more` | Overflow ("More" / ⋯) menu on a record |
| `record_related` | Per-row action on each row of a related-list section inside a parent record, in that parent's context only — unlike `list_item`, never on the object's own list views. Declared, not yet placed: the console does not render it on those rows yet |
| `list` | Header/toolbar of a list view (bulk actions, "New", export) — acts on no record |
| `record` | Both record surfaces: the record-detail title bar and each list/grid row |
| `record_page` | Actions in the record-detail title bar; with `component: 'action:menu'`, straight into its overflow ("More" / ⋯) menu |
| `record_row` | Per-row action on a list/grid row |
| `record_related` | Per-row action on each row of a related-list section inside a parent record, in that parent's context only — unlike `record_row`, never on the object's own list views. Declared, not yet placed: the console does not render it on those rows yet |
| `record_section` | Actions inside a body section/tab of a record |

```yaml
Expand All @@ -290,18 +290,18 @@ label: Export
icon: download
type: api
target: /api/customers/export
locations: [list_toolbar]
locations: [list]
```

### Ordering & the Primary Button

Within each location group, actions render in **`order`** sequence — **lower comes first / more prominent**. In `record_header` the first visible action becomes the **primary button** and the rest fall into the `⋯` overflow menu, so `order` is how you decide which action holds the primary slot.
Within each location group, actions render in **`order`** sequence — **lower comes first / more prominent**. In `record_page` the first visible action becomes the **primary button** and the rest fall into the `⋯` overflow menu, so `order` is how you decide which action holds the primary slot.

```yaml
# Approve holds the primary button even though the app action registered first.
name: approve_request
label: Approve
locations: [record_header]
locations: [record_page]
variant: primary
order: -10 # negative → floats ahead of app actions (order defaults to 0)
```
Expand Down Expand Up @@ -364,7 +364,7 @@ An action the reader toggles, such as a "Helpful" vote on a knowledge article, s
name: mark_article_helpful
label: Helpful
type: script
locations: [record_header]
locations: [record_page]
pressed: "has(record.viewer) && record.viewer.vote == 'helpful'"
```

Expand All @@ -382,14 +382,14 @@ disabled: "record.status == 'converted'" # preferred — works on every surfac
disabled: "status == 'converted'" # bare field — also resolves to the record
```

Prefer the `record.<field>` form: it reads unambiguously and resolves identically on **every** surface an action renders (`record_header`, `record_more`, `list_item`, related lists). The bare-field form is supported for brevity but is easy to confuse with a local variable.
Prefer the `record.<field>` form: it reads unambiguously and resolves identically on **every** surface an action renders (`record`, `record_page`, `record_row`, related lists). The bare-field form is supported for brevity but is easy to confuse with a local variable.

Beyond `record`, action predicates also expose the authenticated user as `ctx.user` (e.g. `record.id == ctx.user.id`) and public feature flags as `features.*` (see [Capability gates](#capability-gates-requiresfeature)) — they are not limited to the record. [record-alert](/docs/protocol/objectui/record-alert) conditions surface the analogous identity values under the `os.*` namespace (`os.user` / `os.org` / `os.env`) instead.

<Callout type="warn">
**The bound record is SPARSE — guard every read with `has()`.** Unlike a
validation or hook predicate, an action predicate is evaluated against whatever
record the client already fetched. On `list_item` that is the row the view's
record the client already fetched. On `record_row` that is the row the view's
`$select` projected, so a column the view did not ask for is **absent**, not
`null` — and CEL aborts the whole expression at key resolution (`No such key:
status`). The abort is fail-closed, so the button simply is not offered, which
Expand Down Expand Up @@ -630,7 +630,7 @@ ai:
icon: pause-circle
variant: secondary
mode: custom
locations: [list_item, record_header]
locations: [record_row, record_page]
type: api
method: POST
target: /api/v1/auth/admin/oauth2/toggle-disabled
Expand All @@ -650,7 +650,7 @@ ai:
icon: refresh-cw
variant: secondary
mode: custom
locations: [record_header, record_more]
locations: [record, record_page]
type: api
method: POST
target: /api/v1/auth/sys-oauth-application/rotate-secret
Expand Down
2 changes: 1 addition & 1 deletion content/docs/protocol/objectui/concept.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ actions:
**1. The predicate is bare CEL, and the bound record is sparse — guard every read with**
**`has()`.** A filter object (`{ status: { $ne: 'locked' } }` — Mongo query syntax) is in
none of the three arms `visible`/`disabled` declare, so it is a parse error. And the
record an action predicate sees is whatever the client already fetched: on `list_item`
record an action predicate sees is whatever the client already fetched: on `record_row`
that is only what the view's `$select` projected, so an unprojected column is *absent*,
not `null`, and CEL aborts the whole expression at key resolution. Here the abort is
**fail-closed** — the button is simply not offered, which looks exactly like the
Expand Down
9 changes: 4 additions & 5 deletions content/docs/protocol/objectui/layout-dsl.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,11 @@ each holding typed `components`. There is no `context:` key — the binding is
of actions declared on that object — there is no built-in id registry, so
`edit` / `delete` / `share` resolve nowhere (the host draws its own Edit /
Delete chrome). The list is the whole set the header draws: an action that
declares `record_header` but is not named is not drawn there, and a header with
declares `record_page` but is not named is not drawn there, and a header with
no `actions` draws none of the object's own actions. `placedActions: true` in
place of the list asks for every action placed at `record_header` /
`record_more`, read live, so an action another package places on the object is
place of the list asks for every action placed at `record` / `record_page`, read live, so an action another package places on the object is
drawn without editing the page; it is refused beside a list. Declare the action,
placed at `record_header`, then name it:
placed at `record_page`, then name it:

{/* os:check-yaml action */}
```yaml
Expand All @@ -104,7 +103,7 @@ label: Send Statement
objectName: account
type: flow
target: account_statement
locations: [record_header]
locations: [record_page]
```

{/* os:check-yaml page */}
Expand Down
Loading
Loading