Skip to content

Commit b7dee0e

Browse files
os-warrenclaude
andauthored
feat(spec,console): ask_ai action type — focus the in-app assistant on a record (#37215)
<!-- claude-projects-attribution: {"github_login":"os-warren"} --> _Requested by **Warren** · [project thread](https://claude.ai/code/project/chan_01U5RdnAAmkSQmZbqh6FtqZ8?thread=cmsg_01U5RdnAAmkSQmZbqh6FtqZ8GQ6AcWeR72ieTBXyYMDAWk)_ Fixes #37142 Fixes #37276 ## 维护者速读 - 做了什么:元数据作者可以在记录页放一个「问 AI」按钮(`type: 'ask_ai'`),点了就把站内助手对准这条记录并展开,不发消息、不调服务端。 - 为什么:专题 #36996 第 6 行,落实 ADR-0160 D7;前置 #36999(助手聚焦)已合。 - 风险:spec 新增一个动作类型(扩宽);`target` 与 `ai.exposed: true` 写在它旁边会在解析时被拒;没有站内助手、或手上不是恰好一条记录(批量栏、相关列表工具栏、列表头未选或多选)时按钮不出现,而不是置灰。 - 要你做什么:暂无。等席位 L1 与 L2 契约审核(spec 面,fable 档)。 ## What changes ADR-0160 D7 — an action on one record that focuses the in-app assistant on that record and opens it. **Spec (`@objectstack/spec`)** - `ActionType` gains `ask_ai`. It is outside the target-required set: it takes no `target`. - `ActionSchema` and `InlineActionSchema` refuse a `target` beside it (inline `to` too) at the `target` path, and `ai.exposed: true` at `ai.exposed` (`false` parses). `body` stays `script`-only. - `DashboardHeaderActionSchema` refuses `actionType: 'ask_ai'` at `actionType`: a header runs on no record. `WidgetActionTypeSchema` stays derived from `ActionType`. - Reference docs regenerated. **Runtime (`@objectstack/runtime`)** - `isHeadlessInvokableAction` answers `false` for `ask_ai`, so MCP `list_actions` skips it and the AI posture of the action door refuses it, whatever a stored row carries beside the type. - `headlessActionTypeError` answers the REST door with a sentence about the in-app assistant instead of the generic "opens its `target`". **Console** - `@object-ui/core`: `ActionRunner` gets an `ask_ai` executor that hands `{ object, id }` to the installed `AssistantFocusHandler` (`setAssistantFocusHandler`) and nothing else: no registered handler, no fetch, no success toast unless `successMessage` is declared. The record is the row a row surface stashed (`recordIdField` honoured), else the page record, else the one selected row. No record, or several selected, is refused before any `confirmText`; so is a launch with no handler installed. `drawsAction()` answers whether an action is drawn; `ActionEngine.getActionsForLocation` and `getBulkActions` leave undrawn actions out. `isAskAiAction` reads `type` and the legacy `actionType`. - `@object-ui/react`: `<ActionProvider onAskAi>` installs the handler (the latest one runs; the gate identity changes only when the handler appears or goes) and `useDrawsAction()` answers for every surface under it; with no provider, `ask_ai` is not drawn. - `@object-ui/app-shell`: `useAskAiHandler` returns `dock.open({ agent, fresh: true })` + `setChatFocus(focus, { follow: true })` only when the layout hosts the chat drawer (`useChatDockControl`, which is null when the AI surface is off) and an agent in the catalog advertises `capabilities.focus` (`useAiSurfaceEnabled().focusServed`); the console action runtime passes it as `onAskAi`. - **No single record ⇒ absent.** The bulk bar never offers an `ask_ai` action (the type of a promoted def is read off its `actionDef`); `ActionRunner.bulkRefusal` refuses a per-row run over a selection (the grid's per-record bulk dispatch asks it), and `ActionEngine.getBulkActions` / `executeBulk` leave it out. A list header draws it only while exactly one row is selected, and leaves it out (not greyed) with none or several. A related list's toolbar leaves it out, because a launch there runs on the parent; its rows still draw it. - **The conversation it opens.** The click opens the drawer on a fresh thread of an agent that declares `capabilities.focus` (`focusAgentName`, an `ask` agent first), so the drawer's pin control, which asks the active agent, is drawn, and pins the record to that thread. `setChatFocus(focus, { follow: true })` (new option): a host showing a conversation keeps that conversation's focus and gives this one to the next conversation it shows; the first send carries it onto the id it mints, and an unsent fresh thread creates nothing. - `resolveAiApiBase` moves to `hooks/aiApiBase.ts` (re-exported from `useAiSurface`), so `useAskAiHandler` does not import a module many layout tests mock. - Every action surface asks `useDrawsAction()` beside its existing gates: record header/`DeclaredActionsBar`, `action:bar`, `action:button`, `action:icon`, `action:group`, `action:menu`, element buttons, container action filters, grid row menu and actions column, data-table row actions, related-list toolbar, bulk action bar. ## Tests - `packages/spec/src/ui/action-ask-ai.test.ts`: member, parses with no target, refusals at `target` / `ai.exposed` (both in one parse), `ai.exposed: false` accepted, `body` refused, inline refusals, neighbours keep their rules. - `packages/spec/src/ui/dashboard-header-ask-ai-37142.test.ts`: header refusal, vocabulary still derived, other types still accepted. - `packages/runtime/src/action-ask-ai-headless.test.ts`: not headless-invokable (with or without automation, and for an at-rest row carrying `target`/`body`/`ai.exposed`), REST sentence. - `ui/packages/core/src/actions/__tests__/ActionRunner.askAi-37142.test.ts`: click hands the record once and sends nothing (fetch stub, script handler, toast unspied), row / scoped / selected record readings, refusals before confirm, not drawn without a handler, `ActionEngine` filtering. - `ui/packages/react/src/context/__tests__/ActionProvider.askAi-37142.test.tsx`: drawn only with `onAskAi`, gate identity, latest handler runs, no provider. - `ui/packages/app-shell/src/hooks/__tests__/useAskAiHandler-37142.test.tsx`, `useAiSurface.test.ts` (`focusServed`), `views/__tests__/DeclaredActionsBar.askAi-37142.test.tsx` (absent without assistant, drawn and focuses with one; ablation of the filter turns it red). - `skills/objectstack-ui/SKILL.md`: one table row and one sentence (164 → 165 lines); the token ratchet stays under its ceiling. - `ui/packages/core/src/actions/__tests__/ActionRunner.askAi-37142.test.ts` adds `bulkRefusal`, `getBulkActions` / `executeBulk` and page-record `recordIdField`; `plugin-grid/src/__tests__/BulkActionBar.askAi-37142.test.tsx`, `plugin-detail/src/__tests__/RelatedList.toolbarAskAi-37142.test.tsx`, `app-shell/src/views/__tests__/objectViewHeaderLaunchGate.askAi-37142.test.tsx` pin the three no-single-record surfaces; `useAskAiHandler-37142` pins the agent it opens. - `ui/packages/app-shell/src/layout/__tests__/chatFocus-36999.test.tsx` (objectstack#37142 block): the real dock body and focus host under a real `useAskAiHandler`; a drawer open on another conversation keeps that conversation's focus and the fresh thread's first send carries the record; a drawer on an unsent thread takes it at once. Ablated: without `follow`, and with `open({ agent })` instead of the fresh thread, the first case fails. - The same block pins N4: after an `ask_ai` click, opening a history conversation before sending shows and sends that conversation's own focus (rec_9 kept), and a conversation with no focus gets none. Ablated: without the target key, both fail. - Updated pins that enumerate `ActionType.options` (spec row-update, undoable, inline; Studio presets and type-switch pins). ## Acceptance notes - Contract review N4 (an unsent fresh thread's carry lands on a history conversation picked before the first send; predates this PR, widened by it): filed as #37276 (claim 7160324153) and fixed here. `useConversationFocus` takes a key of the dock's target and drops a hand-off's carry when it changes, so only the id the target resolves, or the first send mints, takes the carried focus. A pending `follow` is kept across that change. - Studio's action inspector does not offer `ask_ai` in its Type picker (its option list is hand-written); authoring is code / metadata only for now. - `params` beside `ask_ai` are not refused (inert); a record-less location such as `list_toolbar` is not refused at parse — the action is absent there unless exactly one row is selected, and the runner refuses a launch that reaches it anyway. - The global `ConsoleShell` action runtime sits above the chat dock, so `ask_ai` is absent there; per-view runtimes inside the layout get it. Direct `useActionRunner` owners get no handler, so `ask_ai` is absent for them. - `form.tsx` (update-operation actions only) and the managed-by empty state are not gated. - The dashboard-header refusal goes beyond the ADR's words; flagged for L2 (judged justified in record 7152689299). - The SKILL.md row does not name the dashboard-header refusal (R7): adding it puts the file 14 tokens over its ratchet ceiling, so it is left to #37217. ## Verification - `@objectstack/spec`: full suite 892 files / 28329 tests pass. - `@objectstack/runtime`: typecheck pass; ask_ai + declarative-update tests pass. - `@object-ui/core` 4789, `@object-ui/react` 1601, `@object-ui/components` 4966, `@object-ui/plugin-grid` 2783, `@object-ui/plugin-detail` 3941 tests pass; type-check passes on all six ui packages. - `@object-ui/app-shell`: hooks, console, metadata-admin, studio-design and `DeclaredActionsBar` tests pass (1204 files after the two pin fixes). - Review round (R1–R6) and the three CI failures at `076ed686`: `@object-ui/core` 248 files / 4792 pass; plugin-grid `__tests__` + components 272 files pass; plugin-detail RelatedList / RecordRelatedListRenderer 73 files pass; app-shell layout + hooks + console/home 311 files pass, views 220 files pass; `@objectstack/example-showcase` 49 files / 554 pass; type-check passes on core, plugin-grid, plugin-detail, app-shell. New tests each turn red when their fix is removed (list header 3/3, bulk bar 1/1, related-list toolbar 1/1, and the two CI-red AppHeader files fail again with the old import). - Gates derived by `scripts/pm/dispatch-gates.mjs --commands` for this change set (131 commands): all pass except three that could not measure in this container — `check-plugin-teardown-shape --self-test` (needs an unshallow clone), `check:dual-build-cjs-loads` (needs every package's `dist/`); `check:skill-examples` passed on a re-run once the spec build had finished. CI runs them in full. - ESLint on every changed source and test file: 0 errors. Clause-②: yes Metadata-protocol: added Skills-docs: follow-up #37217 ## Human Minimum - [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic. - [x] 2. Every name I added uses the casing for its kind. - [x] 3. No formatter ran; `pnpm lint` passes. - [x] 4. One issue, one branch off an up-to-date `main`, one pull request. - [x] 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset. - [x] 6. `packages/spec` touched: its generated artifacts are regenerated and committed. - [x] 7. No hand edits to `content/docs/references/`, `packages/*/CHANGELOG.md` or `content/docs/releases/`. - [x] 8. Title, body and comments are in English. - [x] The *Before Submitting* list in CONTRIBUTING.md is done. --- _Generated by [Claude Code](https://claude.ai/code)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 012f0a1 commit b7dee0e

61 files changed

Lines changed: 1776 additions & 122 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
'@objectstack/spec': minor
3+
'@objectstack/runtime': patch
4+
'@object-ui/core': minor
5+
'@object-ui/react': minor
6+
'@object-ui/components': patch
7+
'@object-ui/plugin-grid': patch
8+
'@object-ui/plugin-detail': patch
9+
'@object-ui/app-shell': minor
10+
---
11+
12+
feat(actions): `type: 'ask_ai'` — an action that opens the in-app assistant focused on the record it runs on
13+
14+
Clause-②: yes (widening: a new `ActionType` member `ask_ai`, refused beside `target`, `ai.exposed: true` and on a dashboard header)
15+
Metadata-protocol: added
16+
Skills-docs: follow-up #37217
17+
18+
ADR-0160 D7. An author can now put an "Ask AI" button on a record:
19+
20+
```ts
21+
actions: [{ name: 'ask_about_account', label: 'Ask AI', type: 'ask_ai', locations: ['record_header'] }]
22+
```
23+
24+
- **Spec.** `ActionType` gains `ask_ai`. It takes no `target`: the parse refuses one (and its inline spelling `to`) at the `target` path, because what the assistant reads about the record is chosen by the record's context pack, not by the action. It is never an AI tool: `ai.exposed: true` beside it is refused at `ai.exposed` (`false` parses). A dashboard header action cannot be `actionType: 'ask_ai'` (a header runs on no record); `WidgetActionTypeSchema` stays derived from `ActionType` and the header refuses that one member with the reason.
25+
- **Runtime.** `ask_ai` has no server dispatch. `isHeadlessInvokableAction` answers `false` for it, so MCP `list_actions` skips it and the AI action door refuses it, and the REST action door answers with a sentence about the in-app assistant.
26+
- **Console.** A click focuses the in-app assistant on the record (`setChatFocus`) and opens the drawer. It sends no message and makes no server call. The record is the page record, the row a row surface hands over, or the one selected row; with none, or several selected, the click is refused before any `confirmText`. New in `@object-ui/core`: `ActionRunner.setAssistantFocusHandler`, `ActionRunner.drawsAction`, `isAskAiAction`, and the `AssistantFocus` / `AssistantFocusHandler` types; `ActionEngine` leaves undrawn actions out of `getActionsForLocation` and `getBulkActions`. New in `@object-ui/react`: `<ActionProvider onAskAi>` and `useDrawsAction()`. `@object-ui/app-shell` installs the handler (`useAskAiHandler`) only when the layout hosts the assistant drawer, the AI surface is on, and an agent in the catalog advertises `capabilities.focus`.
27+
- **Absent, not disabled.** Where no in-app assistant can take it, an `ask_ai` action is not drawn on any action surface (record header, action bars, row menus, related lists, page action renderers). Where no single record is held it is absent too: the bulk bar never offers it, a related list's toolbar leaves it out (its rows draw it), and a list toolbar draws it only while exactly one row is selected. A launch that reaches the runner anyway is refused, not reported done; `ActionRunner.bulkRefusal` refuses a per-row run over a selection, and `ActionEngine.getBulkActions` / `executeBulk` leave it out.
28+
- **The conversation it opens.** The click opens the drawer on a fresh thread of an agent that declares `capabilities.focus` (an `ask` agent first), so the drawer's own pin control is drawn on the record, and pins the record to that thread; its first send carries the focus and creates the conversation, and an unsent one creates nothing. A conversation the drawer showed before keeps its own focus. So does a history conversation the user opens before the first send: the dock's focus host now drops a hand-off's carry when the drawer is asked for another target. New in `@object-ui/app-shell`: `setChatFocus(focus, { follow: true })`, a pin for the conversation the caller moves the chat to in the same event.

‎content/docs/protocol/objectui/actions.mdx‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ refreshAfter: true
4141

4242
## Action Types
4343

44-
The `type` field selects how an action is dispatched. The complete enum is **`script`, `url`, `modal`, `flow`, `api`, `form`** — there are no other types. `type` defaults to `script` when omitted.
44+
The `type` field selects how an action is dispatched. The complete enum is **`script`, `url`, `modal`, `flow`, `api`, `form`, `ask_ai`** — there are no other types. `type` defaults to `script` when omitted.
4545

4646
| Type | Behavior | `target` required? |
4747
| --- | --- | --- |
@@ -51,6 +51,7 @@ The `type` field selects how an action is dispatched. The complete enum is **`sc
5151
| `modal` | Open a modal/page by name. | Yes |
5252
| `api` | Call an API endpoint (`method` defaults to `POST`). | Yes |
5353
| `form` | Open a FormView by name, routed to `/_console/forms/:name` **inside the console shell**; the submit lands on the created record. | Yes |
54+
| `ask_ai` | Open the console's in-app assistant on a fresh conversation focused on the one record the action runs on (ADR-0160 D7); a conversation the assistant showed before keeps its own focus. Sends no message and calls no server. It is not drawn with no in-app assistant, nor where no single record is held: never in a bulk bar or a related list's toolbar, and in a list toolbar only while exactly one row is selected. A dashboard header refuses it. Never an AI tool: `ai.exposed: true` beside it is refused. | No — a `target` is refused |
5455

5556
The one thing that is not a type: the **declarative single-record field write**. It is spelled `operation: 'update'` + `patch` — the same words a list view's `bulkActionDefs` uses for the bulk form — and it rides the default `script` route: the platform action route performs the write on the data plane **as the caller** (never system-elevated), so the caller's permissions, the object's hooks and its validations fire exactly as for a user edit. Beside `operation: 'update'` an action carries no executor binding of its own — `target`, `body`, `method`, `bodyExtra` and any other explicit `type` are refused — and `patch` is merged under whatever the `params` dialog collects, so a fixed value can be declared without exposing it in the dialog. `undoable` has its anchor here: the capture is the prior value of every field the action writes — the merged bag, `patch` under `params`, not `patch` alone.
5657

@@ -224,7 +225,7 @@ interface Action {
224225
order?: number; // Sort order within a location group (lower = higher)
225226
226227
// Behavior
227-
type?: 'script' | 'url' | 'modal' | 'flow' | 'api' | 'form'; // default 'script'
228+
type?: 'script' | 'url' | 'modal' | 'flow' | 'api' | 'form' | 'ask_ai'; // default 'script'
228229
target?: string; // URL / script / flow / modal / endpoint
229230
operation?: 'update'; // Declarative single-record field write (rides the default script route)
230231
patch?: Record<string, unknown>; // Static field values for operation: 'update', merged under params

‎content/docs/references/data/object.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ const result = ApiMethod.parse(data);
521521
| **icon** | `string` | optional | Icon name |
522522
| **locations** | `Enum<'list_toolbar' \| 'list_item' \| 'record_header' \| 'record_more' \| …>[]` | optional | Locations where this action is visible. `record_section` is drawn only by an authored record page block that renders it; the standard record page (on a phone, in the side preview, and for an object with no authored page) does not draw it, so an action that must reach every surface adds `record_more` as well. |
523523
| **component** | `Enum<'action:button' \| 'action:icon' \| 'action:menu' \| 'action:group'>` | optional | Visual component override |
524-
| **type** | `Enum<'script' \| 'url' \| 'modal' \| 'flow' \| 'api' \| 'form'>` | optional (default: `"script"`) | Action functionality type — the dispatch route. The declarative single-record field write is not a type: it is `operation: 'update'` + `patch` on the default `script` route. |
524+
| **type** | `Enum<'script' \| 'url' \| 'modal' \| 'flow' \| 'api' \| 'form' \| 'ask_ai'>` | optional (default: `"script"`) | Action functionality type — the dispatch route. The declarative single-record field write is not a type: it is `operation: 'update'` + `patch` on the default `script` route. |
525525
| **target** | `string` | optional | URL, Script Name, Flow ID, or API Endpoint. Supports $`{param.X}` and $`{ctx.X}` interpolation. For type:'url': an http:// or https:// URL, a mailto: address, or an in-app path starting with / or ./ (a console route; a record is /apps/APP/OBJECT/record/ID, APP being the app's route segment — see onSuccess.navigate) — every other scheme and a protocol-relative //host are refused. |
526526
| **openIn** | `Enum<'self' \| 'new-tab'>` | optional | For type:'url' — where to open `target`. 'new-tab' opens a new browser tab; 'self' navigates in place. When omitted, external/absolute URLs open in a new tab and relative URLs navigate in place. Static execution option — keep it OUT of `params` (which is user-input-collection only). |
527527
| **body** | `{ language: 'expression'; source: string } \| { language: 'js'; source: string; capabilities?: Enum<'api.read' \| 'api.write' \| 'api.transaction' \| 'crypto.uuid' \| 'log' \| …>[]; timeoutMs?: integer; … }` | optional | Action body — expression (L1) or sandboxed JS (L2). Only used when type is `script`. An action body runs as system, and its update, transfer, delete, purge or restore of an object declared managedBy: 'append-only' is refused with PERMISSION_DENIED; an insert is not judged by this rule. Its system elevation does not lift the organization wall: the body has its reads and writes judged by the invoking user's organization wall. A write whose own data names an organization outside it, or empties a record's organization, is refused with PERMISSION_DENIED. Where the wall denies the user (no active organization under isolated, no membership under group), its reads of an organization's records return none, its deletes remove none, and its other writes are refused with PERMISSION_DENIED. |

‎content/docs/references/kernel/metadata-plugin.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ const result = MetadataBulkResultSchema.parse(data);
329329
| **icon** | `string` | optional | Icon name |
330330
| **locations** | `Enum<'list_toolbar' \| 'list_item' \| 'record_header' \| 'record_more' \| …>[]` | optional | Locations where this action is visible. `record_section` is drawn only by an authored record page block that renders it; the standard record page (on a phone, in the side preview, and for an object with no authored page) does not draw it, so an action that must reach every surface adds `record_more` as well. |
331331
| **component** | `Enum<'action:button' \| 'action:icon' \| 'action:menu' \| 'action:group'>` | optional | Visual component override |
332-
| **type** | `Enum<'script' \| 'url' \| 'modal' \| 'flow' \| 'api' \| 'form'>` | optional (default: `"script"`) | Action functionality type — the dispatch route. The declarative single-record field write is not a type: it is `operation: 'update'` + `patch` on the default `script` route. |
332+
| **type** | `Enum<'script' \| 'url' \| 'modal' \| 'flow' \| 'api' \| 'form' \| 'ask_ai'>` | optional (default: `"script"`) | Action functionality type — the dispatch route. The declarative single-record field write is not a type: it is `operation: 'update'` + `patch` on the default `script` route. |
333333
| **target** | `string` | optional | URL, Script Name, Flow ID, or API Endpoint. Supports $`{param.X}` and $`{ctx.X}` interpolation. For type:'url': an http:// or https:// URL, a mailto: address, or an in-app path starting with / or ./ (a console route; a record is /apps/APP/OBJECT/record/ID, APP being the app's route segment — see onSuccess.navigate) — every other scheme and a protocol-relative //host are refused. |
334334
| **openIn** | `Enum<'self' \| 'new-tab'>` | optional | For type:'url' — where to open `target`. 'new-tab' opens a new browser tab; 'self' navigates in place. When omitted, external/absolute URLs open in a new tab and relative URLs navigate in place. Static execution option — keep it OUT of `params` (which is user-input-collection only). |
335335
| **body** | `{ language: 'expression'; source: string } \| { language: 'js'; source: string; capabilities?: Enum<'api.read' \| 'api.write' \| 'api.transaction' \| 'crypto.uuid' \| 'log' \| …>[]; timeoutMs?: integer; … }` | optional | Action body — expression (L1) or sandboxed JS (L2). Only used when type is `script`. An action body runs as system, and its update, transfer, delete, purge or restore of an object declared managedBy: 'append-only' is refused with PERMISSION_DENIED; an insert is not judged by this rule. Its system elevation does not lift the organization wall: the body has its reads and writes judged by the invoking user's organization wall. A write whose own data names an organization outside it, or empties a record's organization, is refused with PERMISSION_DENIED. Where the wall denies the user (no active organization under isolated, no membership under group), its reads of an organization's records return none, its deletes remove none, and its other writes are refused with PERMISSION_DENIED. |

‎content/docs/references/ui/action.mdx‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const result = ActionSchema.parse(data);
5050
| **icon** | `string` | optional | Icon name |
5151
| **locations** | `Enum<'list_toolbar' \| 'list_item' \| 'record_header' \| 'record_more' \| 'record_related' \| 'record_section'>[]` | optional | Locations where this action is visible. `record_section` is drawn only by an authored record page block that renders it; the standard record page (on a phone, in the side preview, and for an object with no authored page) does not draw it, so an action that must reach every surface adds `record_more` as well. |
5252
| **component** | `Enum<'action:button' \| 'action:icon' \| 'action:menu' \| 'action:group'>` | optional | Visual component override |
53-
| **type** | `Enum<'script' \| 'url' \| 'modal' \| 'flow' \| 'api' \| 'form'>` | optional (default: `"script"`) | Action functionality type — the dispatch route. The declarative single-record field write is not a type: it is `operation: 'update'` + `patch` on the default `script` route. |
53+
| **type** | `Enum<'script' \| 'url' \| 'modal' \| 'flow' \| 'api' \| 'form' \| 'ask_ai'>` | optional (default: `"script"`) | Action functionality type — the dispatch route. The declarative single-record field write is not a type: it is `operation: 'update'` + `patch` on the default `script` route. |
5454
| **target** | `string` | optional | URL, Script Name, Flow ID, or API Endpoint. Supports $`{param.X}` and $`{ctx.X}` interpolation. For type:'url': an http:// or https:// URL, a mailto: address, or an in-app path starting with / or ./ (a console route; a record is /apps/APP/OBJECT/record/ID, APP being the app's route segment — see onSuccess.navigate) — every other scheme and a protocol-relative //host are refused. |
5555
| **openIn** | `Enum<'self' \| 'new-tab'>` | optional | For type:'url' — where to open `target`. 'new-tab' opens a new browser tab; 'self' navigates in place. When omitted, external/absolute URLs open in a new tab and relative URLs navigate in place. Static execution option — keep it OUT of `params` (which is user-input-collection only). |
5656
| **body** | `{ language: 'expression'; source: string } \| { language: 'js'; source: string; capabilities?: Enum<'api.read' \| 'api.write' \| 'api.transaction' \| 'crypto.uuid' \| 'log' \| …>[]; timeoutMs?: integer; … }` | optional | Action body — expression (L1) or sandboxed JS (L2). Only used when type is `script`. An action body runs as system, and its update, transfer, delete, purge or restore of an object declared managedBy: 'append-only' is refused with PERMISSION_DENIED; an insert is not judged by this rule. Its system elevation does not lift the organization wall: the body has its reads and writes judged by the invoking user's organization wall. A write whose own data names an organization outside it, or empties a record's organization, is refused with PERMISSION_DENIED. Where the wall denies the user (no active organization under isolated, no membership under group), its reads of an organization's records return none, its deletes remove none, and its other writes are refused with PERMISSION_DENIED. |
@@ -419,6 +419,7 @@ L2 sandboxed JS body — runs inside an isolated VM with declared capabilities
419419
* `flow`
420420
* `api`
421421
* `form`
422+
* `ask_ai`
422423

423424

424425
---
@@ -429,7 +430,7 @@ L2 sandboxed JS body — runs inside an isolated VM with declared capabilities
429430

430431
| Property | Type | Required | Description |
431432
| :--- | :--- | :--- | :--- |
432-
| **type** | `Enum<'script' \| 'url' \| 'modal' \| 'flow' \| 'api' \| 'form'>` | optional (default: `"script"`) | Action functionality type — the dispatch route. The declarative single-record field write is not a type: it is `operation: 'update'` + `patch` on the default `script` route. |
433+
| **type** | `Enum<'script' \| 'url' \| 'modal' \| 'flow' \| 'api' \| 'form' \| 'ask_ai'>` | optional (default: `"script"`) | Action functionality type — the dispatch route. The declarative single-record field write is not a type: it is `operation: 'update'` + `patch` on the default `script` route. |
433434
| **name** | `string` | optional | Machine name (lowercase snake_case) |
434435
| **label** | `string \| Record<string, string>` | optional | Display label |
435436
| **target** | `string` | optional | URL, Script Name, Flow ID, or API Endpoint. Supports $`{param.X}` and $`{ctx.X}` interpolation. For type:'url': an http:// or https:// URL, a mailto: address, or an in-app path starting with / or ./ (a console route; a record is /apps/APP/OBJECT/record/ID, APP being the app's route segment — see onSuccess.navigate) — every other scheme and a protocol-relative //host are refused. |

‎content/docs/references/ui/component.mdx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,14 +218,14 @@ const result = ActionButtonPropsSchema.parse(data);
218218
| **icon** | `string` | optional | Lucide icon name rendered inside the button, left or right of the label per `iconPosition`. Read on this component — the renderer resolves it through `lucide-react`'s `icons` map via the shared `resolveIcon` helper every `action:*` site uses (a PascalCase normaliser plus a one-entry rename map), NOT the `LazyIcon` slot the container icons use; the two paths accept different spellings, and an unknown name here renders nothing rather than a fallback glyph. |
219219
| **iconPosition** | `Enum<'left' \| 'right'>` | optional (default: `"left"`) | Icon position relative to label |
220220
| **disabled** | `boolean` | optional (default: `false`) | Disable the button |
221-
| **action** | `{ type?: Enum<'script' \| 'url' \| 'modal' \| 'flow' \| 'api' \| 'form'>; name?: string; label?: string \| Record<string, string>; target?: string; … }` | optional | Inline action executed on click |
221+
| **action** | `{ type?: Enum<'script' \| 'url' \| 'modal' \| 'flow' \| 'api' \| 'form' \| 'ask_ai'>; name?: string; label?: string \| Record<string, string>; target?: string; … }` | optional | Inline action executed on click |
222222
| **aria** | `{ ariaLabel?: string \| Record<string, string>; ariaDescribedBy?: string; role?: string }` | optional | ARIA accessibility attributes |
223223

224224
### Nested Shape: `ElementButtonProps.action`
225225

226226
| Property | Type | Required | Description |
227227
| :--- | :--- | :--- | :--- |
228-
| **type** | `Enum<'script' \| 'url' \| 'modal' \| 'flow' \| 'api' \| 'form'>` | optional (default: `"script"`) | Action functionality type — the dispatch route. The declarative single-record field write is not a type: it is `operation: 'update'` + `patch` on the default `script` route. |
228+
| **type** | `Enum<'script' \| 'url' \| 'modal' \| 'flow' \| 'api' \| 'form' \| 'ask_ai'>` | optional (default: `"script"`) | Action functionality type — the dispatch route. The declarative single-record field write is not a type: it is `operation: 'update'` + `patch` on the default `script` route. |
229229
| **name** | `string` | optional | Machine name (lowercase snake_case) |
230230
| **label** | `string \| Record<string, string>` | optional | Display label |
231231
| **target** | `string` | optional | URL, Script Name, Flow ID, or API Endpoint. Supports $`{param.X}` and $`{ctx.X}` interpolation. For type:'url': an http:// or https:// URL, a mailto: address, or an in-app path starting with / or ./ (a console route; a record is /apps/APP/OBJECT/record/ID, APP being the app's route segment — see onSuccess.navigate) — every other scheme and a protocol-relative //host are refused. |

0 commit comments

Comments
 (0)