Skip to content

Commit a64c3b8

Browse files
docs(skills): objectstack-ui actions rule names the selection key a bulk body receives (#36067)
<!-- claude-projects-attribution: {"github_login":"os-elon-musk"} --> _Requested by **Elon** · [project thread](https://claude.ai/code/project/chan_01WedDzV26nniwxv7jC88B9D?thread=cmsg_01WedDzV26nniwxv7jC88B9D4n2wzAmmp4Z6W5jsqtM2qx)_ Fixes #35647 Clause-②: no Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:照着界面技能写「批量操作」的作者,以前会写出一个读不到所选记录的按钮;现在技能教的是两种真正能拿到记录的接法,示例用的是「每条勾选记录执行一次」的那一种。「新标签页打开」的示例也改成了能取到当前记录的写法。 - 为什么做:属于「对外发布的技能包教的内容要和运行时一致」这条线,替按技能生成应用的作者和 AI 解决「按钮点了显示成功、实际一条都没处理」的问题。 - 出错会怎样:只改技能文字、示例和一条评测用例,不动运行时;写错的话作者拿到的仍是一段错误示例,直接回退这个 PR 即可。 - 要你做什么:无。 ## What changes State at head `a7f91e14` (round 3, four commits). One wiring story throughout: a name in the list view's `bulkActions` runs the action once per ticked row and the body reads that row as `ctx.recordId`; a `bulkActionDefs` entry with `operation: 'custom', execution: 'aggregate'` runs it once and the body reads the ids as `input._selectedIds`. `skills/objectstack-ui/rules/actions.md` (published catalog), paid in place: - **Opening paragraph.** The placements a view can give an action now read `rowActions` / `bulkActions` / `bulkActionDefs`; the placement lint counts all three (contract record 7062828763, N2). - **`list_toolbar` row.** It said a bulk action receives `input.selectedIds`; no path delivers that key. The row now reads: toolbar button; one ticked row is its `recordId`, several are refused (no `_selectedIds`) (N1 of the same record). - **Bulk bullet, first sentence.** Names both list-view wirings and what each hands the body, as above. - **`AddToCampaignAction` example.** Declares `execution: 'perRecord'`, carries no `list_toolbar` placement (the list view names it in `bulkActions`), and its body inserts one `campaign_member` row for `ctx.recordId`. The loop over an id array, the `campaignId` alias and the `return { count }` line are gone. - **`PrintA3Action` example** (the fold row on the card: the closed card about the new-tab example). `target` used a `record.id` hole; the runner substitutes only the `param` and `ctx` scopes. It now uses the `ctx.recordId` hole and sits on `record_header`, which has a record. Changeset `.changeset/35647-ui-bulk-selected-ids.md`, `@objectstack/skills` patch. Its sentence now reads: no bulk body receives `input.selectedIds`; a name in `bulkActions` runs the action once per ticked row, its body reading `ctx.recordId`; only a `bulkActionDefs` entry with `operation: 'custom', execution: 'aggregate'` runs it once, the ids in `input._selectedIds`; plus the new-tab example line. Review findings of contract record 7062828763, as closed at this head: - S1: the changeset keeps the two wirings apart (sentence above). - S2: removed the refusal clause (contract record 7062828763). - N1 and N2: folded in (row and opening paragraph above). - N3 not taken: `successMessage` stays on the example. <details><summary>Trace on origin/main 3c06fc5: what a bulk body receives</summary> - Toolbar button: `resolveServerActionRecordId` in `ui/packages/core/src/actions/serverActionHandler.ts`. With no `_selectedIds` in the bag, one ticked row becomes `recordId`, several ticked rows are refused, none sends no record. No id array is sent under any key. - Per-row wiring: `ui/packages/plugin-grid/src/resolveBulkActions.ts` promotes a `bulkActions` name to one dispatch per row; `packages/runtime/src/sandbox/body-runner.ts` hands the body that row's id as `ctx.recordId`. - Aggregate wiring: `wantsAggregateResolve` in `resolveBulkActions.ts` asks for `execution === 'aggregate'`, `operation === 'custom'` and a name; the dispatch adds `_selectedIds` to the params, and the body-runner sets a body's `input` to them. - `execution` on the action: `packages/spec/src/ui/action.zod.ts` describes `'perRecord'` as one dispatch per selected row carrying that row's `recordId`, the `bulkActions` bare-name form. - Placement: `packages/lint/src/validate-action-locations.ts` reads `rowActions`, `bulkActions` and each `bulkActionDefs` entry's name. - URL holes: `interpolateTarget` in `ui/packages/core/src/actions/ActionRunner.ts` builds its scopes from `param` and `ctx`. </details> ## Evals `skills/objectstack-ui/evals/views-apps-actions-pages.json`, case 3 only (Convert plus bulk "Add to campaign"). It pinned the wrong teaching: `must_contain` held `list_toolbar` and `selectedIds`, and the expected answer read `input.selectedIds`. - `expected_output`: the bulk action declares `execution: 'perRecord'`, is wired by the lead list view's `bulkActions`, and its body runs once per ticked row and reads that row's id as `ctx.recordId`. - `must_contain`: `list_toolbar` and `selectedIds` are replaced by `bulkActions` and `ctx.recordId`. - `must_not_contain`: adds `input.selectedIds`. No eval round was run (a round is the eval seat's). The prompt is unchanged; both token lists changed, so earlier records of this case are set apart on a regrade. ## Tests All readings at head `a7f91e14`. <details><summary>Token ratchet, size and line budget</summary> - `node scripts/check-skills-token-ratchet.mjs`: exit 0. `skills/objectstack-ui/rules/actions.md is 3701 tokens (ceiling 3711; headroom 10)`. On the merge base `7ba22bb6ee`: 3708 tokens (14830 bytes; now 14804). No ceiling row moved. - `rules/actions.md` whole file: 261 lines before, 256 after. Every `SKILL.md` summed: 4945 lines before and after (none touched). - Ratcheted authored total 197415 tokens; eval fixtures (measured, not ratcheted) 76671; bundle total 288685. - PR net added lines (`git diff --numstat` against the merge base, changeset included): 20 added, 17 deleted, net +3. Budget 15. </details> <details><summary>Gates run locally</summary> - Derived list (`node scripts/pm/dispatch-gates.mjs --commands`, 47 commands): 41 run, all exit 0, each exit code captured before any pipe. Among them the ratchet and its `--self-test`, `check-empty-changeset`, `check-changeset-no-major`, `check-adr-0087-registration`, `check:skill-links`, `check:skill-identifier-liveness`, `check:skill-compatibility`, `check:skill-frame-sync`, `check:nul-bytes`, `check:pm-skill-id-lint`, `check:doc-authoring`, `check:role-word`, `check:corpus-claim-drift`, `check-closing-keyword-parity`. - `node scripts/pm/dispatch-gates.mjs --ran`: `47 derived, 41 run, 0 NOT-MEASURED, 6 UNRUN`. The six need built `dist/` trees and are left to CI (declared narrowing): `check:doc-formula-expressions`, `check:dts-closure`, `check:dual-build-cjs-loads`, `check:lean-entry-closure`, `check:published-files`, `check:sourcemap-no-sources-content`. - Eval file: parses as JSON, 23 cases; case 3 has every `must_contain` token in its own `expected_output` (0 missing); 0 `must_not_contain` hits across the file. - `node scripts/pm/overlap-check.mjs --branch=claude/area-a4A-35647`: `VERDICT clean exit 0`. - Not re-run locally at this head, left to CI: `check:skill-examples` (the fenced example blocks are byte-identical to `d2db0a8b`, where `Type Check · source gates` concluded success) and the skill-evals vitest file (the eval file did not move after `d2db0a8b`). </details> No ablation: the diff changes prose, an example and an eval fixture, no tested behaviour. ## Acceptance notes - The card's ask was to name the key delivered to a `list_toolbar` bulk handler. Measured answer: a `list_toolbar` placement delivers no id array; the selection reaches a body only through the list view's two wirings. The text teaches those, which is wider than swapping one spelling. - The fold record on the card lists the new-tab example as a row of this card; it is fixed here in place. - A `type: 'url'` action on `list_toolbar` can still carry the selection through the runner's `ctx.selection.ids` hole. The spec's `target` description does not list that hole, so the skill does not teach it. Noted, not filed. - The example action carries no `locations`; the list view naming it is its placement. ## Verification Read first, by risk: 1. `skills/objectstack-ui/rules/actions.md`, the first sentence of the bulk bullet under "Visibility, Disable & Feedback": it carries the wiring contract. 2. Same file, `AddToCampaignAction`: `execution: 'perRecord'` and a body that writes one row for `ctx.recordId`. 3. `skills/objectstack-ui/evals/views-apps-actions-pages.json`, case 3 token lists. Two-minute check: `node scripts/check-skills-token-ratchet.mjs` prints `rules/actions.md is 3701 tokens (ceiling 3711; headroom 10)` and exits 0. --- _Generated by [Claude Code](https://claude.ai/code/session_01FEkQ5krBqrrgxCYgjXmfbv)_ <!-- signed: repo:objectstack#4 · os-project-manager · session_01FEkQ5krBqrrgxCYgjXmfbv --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent f5cfdd2 commit a64c3b8

3 files changed

Lines changed: 20 additions & 17 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
'@objectstack/skills': patch
3+
---
4+
5+
Clause-②: no
6+
Metadata-protocol: none
7+
8+
`objectstack-ui` actions rule: no bulk body receives `input.selectedIds`. A name in the list view's `bulkActions` runs the action once per ticked row, its body reading `ctx.recordId` (how the example now writes rows); only a `bulkActionDefs` entry with `operation: 'custom', execution: 'aggregate'` runs it once, the ids in `input._selectedIds`. Also: the new-tab example's `target` uses `${ctx.recordId}` on `record_header`.

‎skills/objectstack-ui/evals/views-apps-actions-pages.json‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424
{
2525
"id": 3,
2626
"prompt": "Add a Convert action on `lead` — only for qualified, not-yet-converted leads, from the record header and each list row, launching the `crm_lead_conversion` flow — and a bulk 'Add to campaign' that asks which campaign, for the selected rows.",
27-
"expected_output": "Two `defineAction` items. Convert: `type: 'flow'`, `target: 'crm_lead_conversion'`, `locations: ['record_header', 'list_item']`, `visible: P`record.status == \"qualified\" && record.is_converted == false`` (bare CEL, never brace-wrapped), `confirmText`, `successMessage`, `refreshAfter: true`. Bulk: `type: 'script'`, `locations: ['list_toolbar']`, a field-backed `params: [{ field: 'campaign_id', objectOverride: 'campaign', required: true }]`, and a `body` that reads `input.selectedIds`.",
27+
"expected_output": "Two `defineAction` items. Convert: `type: 'flow'`, `target: 'crm_lead_conversion'`, `locations: ['record_header', 'list_item']`, `visible: P`record.status == \"qualified\" && record.is_converted == false`` (bare CEL, never brace-wrapped), `confirmText`, `successMessage`, `refreshAfter: true`. Bulk: `type: 'script'`, `execution: 'perRecord'`, wired by the lead list view's `bulkActions: ['<name>']`, a field-backed `params: [{ field: 'campaign_id', objectOverride: 'campaign', required: true }]`, and a `body` that runs once per ticked row and reads that row's id as `ctx.recordId`.",
2828
"files": [],
2929
"assertions": {
30-
"must_contain": ["defineAction", "locations", "record_header", "list_toolbar", "visible", "successMessage", "selectedIds"],
31-
"must_not_contain": ["{record."]
30+
"must_contain": ["defineAction", "locations", "record_header", "bulkActions", "visible", "successMessage", "ctx.recordId"],
31+
"must_not_contain": ["{record.", "input.selectedIds"]
3232
}
3333
},
3434
{

‎skills/objectstack-ui/rules/actions.md‎

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Register them under `defineStack({ actions: [...] })`; the six types:
99
folds the action into that object's surfaces: `locations` without it
1010
is refused at validate and publish (`action-no-object-binding`; set it, or
1111
`locations: []` if headless). With neither `locations` nor a view naming it in
12-
`rowActions` / `bulkActions` it renders nowhere (`action-no-placement`). A body
12+
`rowActions` / `bulkActions` / `bulkActionDefs` it renders nowhere (`action-no-placement`). A body
1313
that returns or assigns values writes nothing
1414
(`action-record-write-discarded`): it calls `ctx.api.object(...).update(...)`
1515
in `language: 'js'` (an `expression` body has no I/O) with
@@ -24,7 +24,7 @@ in `language: 'js'` (an `expression` body has no I/O) with
2424
| `record_related` | Related-list section inside a record |
2525
| `record_section` | Body section/tab of a record |
2626
| `list_item` | Per-row action in list views |
27-
| `list_toolbar` | Bulk action on selected rows (`input.selectedIds`) |
27+
| `list_toolbar` | Toolbar button; one ticked row is its `recordId`, several are refused (no `_selectedIds`) |
2828

2929
## Visibility, Disable & Feedback
3030

@@ -40,7 +40,7 @@ in `language: 'js'` (an `expression` body has no I/O) with
4040
- Copy holes are `{{ }}`: `confirmText`, `description` (`'Choose the new owner of {{ record.name }}.'`) and a param's `helpText` read `record`; `successMessage` and each `outcomeMessages` entry (`resent: 'Invitation resent to {{ result.email }}'`) read `result` (the handler's answer) and `record`; `errorMessage` takes none. A `bulkActionDefs` entry's `confirmText` reads `{{ count }}` and its params by bare name (`{{ tier }}`). In all of them `${record.name}`, `{name}`, logic in a hole and a blank sentence fail `os validate`.
4141
- A param's `helpText`, like `description`, is a sentence or an inline locale map (`{ en: 'Why {{ record.name }} is paused', 'zh-CN': '暂停原因' }`); the map is how a page button's inline `action` (no bundle reaches it) writes its hint per locale.
4242
- `undoable: true` — an **Undo** in the success toast (and `Ctrl+Z`). Snapshot: runtime on `operation: 'update'`, console on `type: 'api'`; else refused.
43-
- An `execution: 'aggregate'` bulk handler runs once for the selection, its ids in `params._selectedIds` (a script body's `input._selectedIds`). One that wrote some rows and refused others catches per row and RESOLVES with `{ succeeded: string[], failed: [{ id, message }] }` (`BulkActionResult`, `@objectstack/spec/ui`) as its whole return value; a throw means no outcome, reported once for the selection. An id outside `_selectedIds` is dropped, a duplicate counts once, an id in both lists counts as failed, and a selected id in neither is reported as not confirmed. A value with neither member keeps the whole-selection report; one carrying either that does not parse (counts, one list) is reported as unreadable, never as full success.
43+
- A list view's `bulkActions: ['<name>']` runs the action per ticked row (`recordId`); a `bulkActionDefs` entry `{ name, operation: 'custom', execution: 'aggregate' }` runs it once, the ids in `params._selectedIds` (a body's `input._selectedIds`). A handler that wrote some rows and refused others catches per row and RESOLVES with `{ succeeded: string[], failed: [{ id, message }] }` (`BulkActionResult`, `@objectstack/spec/ui`) as its whole return value; a throw means no outcome, reported once for the selection. An id outside `_selectedIds` is dropped, a duplicate counts once, an id in both lists counts as failed, and a selected id in neither is reported as not confirmed. A value with neither member keeps the whole-selection report; one carrying either that does not parse (counts, one list) is reported as unreadable, never as full success.
4444

4545
<!-- os:check -->
4646
```typescript
@@ -99,21 +99,16 @@ export const AddToCampaignAction = defineAction({
9999
objectName: 'lead',
100100
icon: 'send',
101101
type: 'script',
102-
locations: ['list_toolbar'],
102+
execution: 'perRecord',
103103
params: [
104104
{ field: 'campaign_id', objectOverride: 'campaign', required: true },
105105
],
106106
body: {
107107
language: 'js',
108108
source: `
109-
const campaignId = input.campaign_id;
110-
const ids = Array.isArray(input.selectedIds) ? input.selectedIds : [];
111-
for (const leadId of ids) {
112-
await ctx.api.object('campaign_member').insert({
113-
campaign_id: campaignId, lead_id: leadId, status: 'sent',
114-
});
115-
}
116-
return { count: ids.length };
109+
await ctx.api.object('campaign_member').insert({
110+
campaign_id: input.campaign_id, lead_id: ctx.recordId, status: 'sent',
111+
});
117112
`,
118113
capabilities: ['api.write'],
119114
timeoutMs: 10000,
@@ -170,9 +165,9 @@ export const PrintA3Action = defineAction({
170165
label: 'Print Summary Sheet (A3)',
171166
objectName: 'lead',
172167
type: 'url',
173-
target: '/print/a3?id=${record.id}', // interpolated at click
168+
target: '/print/a3?id=${ctx.recordId}', // interpolated at click
174169
openIn: 'new-tab',
175-
locations: ['list_toolbar'],
170+
locations: ['record_header'],
176171
});
177172
```
178173

0 commit comments

Comments
 (0)