Skip to content

Commit 57b06e3

Browse files
committed
feat(ui): carry an action param's widget to the dialog field
ActionParamDef gains widget; resolveActionParam copies the param's own widget (field-backed: the field's while the param inherits its type) and paramToField draws a registered widget in place of the type widget. The spec liveness row params.widget flips to live and the zod describe drops its not-read-yet sentence. Claude-Session: https://claude.ai/code/session_01L6bhgXcNPmrQhpwYYn7fEq Co-authored-by: Claude <noreply@anthropic.com>
1 parent f6faf75 commit 57b06e3

5 files changed

Lines changed: 96 additions & 13 deletions

File tree

‎packages/spec/liveness/action.json‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
"verifiedAt": "2026-09-15",
9696
"evidenceScope": "cross-repo",
9797
"evidence": "cloud @cb8ee7ff: packages/service-ai/src/tools/action-tools.ts#buildParametersSchema — each declared param becomes one JSON Schema property on the exposed tool.",
98-
"note": "field/objectOverride/defaultFromRow/options/placeholder/helpText/defaultValue/required all consumed. DRILLED 2026-11-05 (#30259): each member now carries its own verdict and in-repo evidence (the console resolver, the param dialog, paramToField, and the dispatcher's ADR-0104 D2 check), and the container left the undrilled-containers baseline. The container's own row keeps its cross-repo AI-tool evidence. `widget` is this type's planned member, with authorWarn, until #30260 gives it a reader.",
98+
"note": "field/objectOverride/defaultFromRow/options/placeholder/helpText/defaultValue/required all consumed. DRILLED 2026-11-05 (#30259): each member now carries its own verdict and in-repo evidence (the console resolver, the param dialog, paramToField, and the dispatcher's ADR-0104 D2 check), and the container left the undrilled-containers baseline. The container's own row keeps its cross-repo AI-tool evidence. `widget` gained its console reader in #30260.",
9999
"children": {
100100
"name": {
101101
"status": "live",
@@ -129,12 +129,11 @@
129129
"evidence": "ui/packages/fields/src/resolveActionParams.ts#resolveActionParam (`param.type ?? 'text'` inline, `param.type ?? field.type` field-backed); ui/packages/app-shell/src/utils/paramToField.ts#paramToField (folds the type to the widget that draws it); packages/runtime/src/action-execution.ts#resolveDeclaredActionParams and packages/spec/src/ui/action-params.zod.ts#validateActionParams (the submitted value is checked against `valueSchemaFor` of this type, ADR-0104 D2)"
130130
},
131131
"widget": {
132-
"status": "planned",
132+
"status": "live",
133133
"verifiedAt": "2026-11-05",
134134
"evidenceScope": "in-repo",
135-
"authorWarn": true,
136-
"authorHint": "Keep it, but nothing reads it yet: the console's action dialog draws the param with its `type` widget until the dialog passes `widget` through, so a param naming `permission-ref` is a text box for now.",
137-
"note": "PLANNED RECORD (#30259, ADR-0131 D4): the widget override, the same key, vocabulary and meaning as FieldSchema.widget, declared spec-first so a param can ask for the `permission-ref` picker the grant column uses. Accepted by the parse door and carried in the parsed param; read by nothing yet, measured: the console's resolveActionParam builds an ActionParamDef from named members and copies no `widget`, paramToField sets a field widget only for `boolean`, and the dispatcher's resolveDeclaredActionParams copies five named members and validates by `type`, so the value contract is unchanged. The reader is #30260 (the resolveActionParams / paramToField pass-through); flip this row to live there. Create User's permissionSet param switches to it in #30117's server PR."
135+
"evidence": "ui/packages/fields/src/resolveActionParams.ts#resolveActionParam (copies the param's `widget` onto the resolved ActionParamDef inline; field-backed, the param's own else the field's FieldSchema.widget while the param inherits the field's `type`, via inheritedWidget); ui/packages/app-shell/src/utils/paramToField.ts#paramToField (a `widget` naming a registered field widget replaces the `type` widget key the dialog mounts through getLazyFieldWidget; an unregistered name keeps the `type` widget, via authoredWidgetKey)",
136+
"note": "Declared spec-first by #30259 (ADR-0131 D4) so a param can ask for the `permission-ref` picker the grant column uses; the console reader landed in #30260, which flipped this row from planned and dropped its authorWarn. The value contract is unchanged: the dispatcher's resolveDeclaredActionParams still validates the submitted value by `type`, so a widget only changes how the value is picked. Create User's permissionSet param switches to it in #30117's server PR. Not read by the selection bar's bulk dialog (plugin-grid bulkParamToField), whose BulkActionParam shape carries no widget."
138137
},
139138
"required": {
140139
"status": "live",

‎packages/spec/src/ui/action.zod.ts‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -253,17 +253,16 @@ export const ActionParamSchema = lazySchema(() => strictObject(
253253
*
254254
* Like the field key it is an open string, not an enum: an unregistered name
255255
* is kept and the dialog draws the `type` renderer instead, so it degrades
256-
* safely. Planned: the console's param resolver does not carry it to the
257-
* widget yet (#30260); until it does, the param draws its `type` renderer
258-
* and its value is submitted as before.
256+
* safely. The console reads it (#30260): `resolveActionParams` carries it
257+
* onto the resolved param — a field-backed param that inherits its `type`
258+
* inherits the field's `widget` with it — and `paramToField` draws the named
259+
* widget. The server still validates the submitted value by `type`.
259260
*/
260-
// The describe's "Not read yet" sentence comes off when #30260's pass-through lands.
261261
widget: z.string().optional().describe(
262262
'Widget override for this param — names a registered field component (resolved as `field:<widget>`) '
263263
+ 'to draw it instead of the `type` default; same key and vocabulary as FieldSchema.widget, and `type` '
264264
+ 'stays the value\'s type. e.g. "permission-ref" on a text param picks a permission set by name '
265-
+ '(ADR-0131 D4). Degrades to the `type` renderer when unregistered. Not read yet: until the console\'s '
266-
+ 'action dialog passes it through, the dialog draws every param with its `type` renderer whatever this names.',
265+
+ '(ADR-0131 D4). Degrades to the `type` renderer when unregistered.',
267266
).meta({ title: 'Widget' }),
268267
/**
269268
* Required override; when omitted defaults to `false`. Consumers that wish

‎ui/packages/app-shell/src/utils/paramToField.ts‎

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,34 @@ import { EXPANDABLE_FIELD_TYPES, type ActionParamDef } from '@object-ui/core';
1717
// beside the resolver that reads it first (objectui#12105). This adapter asks
1818
// the same question one step later, so it reads the same function — never a
1919
// local copy of the table.
20-
import { resolveParamWidgetType } from '@object-ui/fields';
20+
import { resolveFormWidgetType, resolveParamWidgetType } from '@object-ui/fields';
21+
22+
/**
23+
* What `resolveFormWidgetType` answers for a spelling nothing registers — its
24+
* documented `text` fallback. Read by {@link authoredWidgetKey} alone.
25+
*/
26+
const UNKNOWN_SPELLING_WIDGET = 'text';
27+
28+
/**
29+
* The widget key an authored `widget` names, or `undefined` when it names no
30+
* registered widget (or the param authored none).
31+
*
32+
* `ActionParamDef.widget` is the spec's `ActionParamSchema.widget`, which
33+
* shares `FieldSchema.widget`'s key, vocabulary and meaning: a REGISTERED name
34+
* wins over `type` outright, and an unregistered one "degrades to the `type`
35+
* renderer". So the answer is the shared resolver's own, read for its one
36+
* documented fallback: a spelling it answers with `text`, when the author did
37+
* not write `text`, named nothing — the same reading the console's `FormPage`
38+
* makes of a field's `widget` (`namesRegisteredWidget` there). ⛔ No list of
39+
* widgets lives here. A retired spelling resolves to itself, so its tombstone
40+
* still refuses visibly rather than degrading.
41+
*/
42+
function authoredWidgetKey(param: ActionParamDef): string | undefined {
43+
const widget = param.widget;
44+
if (!widget) return undefined;
45+
const key = resolveFormWidgetType(widget);
46+
return key !== UNKNOWN_SPELLING_WIDGET || widget === UNKNOWN_SPELLING_WIDGET ? key : undefined;
47+
}
2148

2249
/**
2350
* Widget keys whose picker cannot query without an explicitly DECLARED target,
@@ -60,6 +87,9 @@ const LOOKUP_WIDGET_TYPES = new Set(['lookup', 'master_detail']);
6087
* for why `user` must never degrade.
6188
*/
6289
export function paramDegradesWithoutTarget(param: ActionParamDef): boolean {
90+
// A registered authored `widget` replaces the `type` widget before the
91+
// fallback is ever considered, so such a param never degrades.
92+
if (authoredWidgetKey(param) !== undefined) return false;
6393
return LOOKUP_WIDGET_TYPES.has(resolveParamWidgetType(param.type)) && !param.referenceTo;
6494
}
6595

@@ -81,7 +111,9 @@ export function paramDegradesWithoutTarget(param: ActionParamDef): boolean {
81111
* the user a box that wants a raw UUID.
82112
*/
83113
export function paramToField(param: ActionParamDef): Record<string, any> {
84-
let type = resolveParamWidgetType(param.type);
114+
// An authored `widget` that names a registered widget draws the param;
115+
// otherwise its `type` does (see {@link authoredWidgetKey}).
116+
let type = authoredWidgetKey(param) ?? resolveParamWidgetType(param.type);
85117
if (paramDegradesWithoutTarget(param)) {
86118
if (process.env.NODE_ENV !== 'production') {
87119
console.warn(

‎ui/packages/core/src/actions/ActionRunner.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -884,6 +884,19 @@ export interface ActionParamDef {
884884
// `ActionParamDialog` renders every param through the same field widgets
885885
// the object form uses (ADR-0059), so params carry the widget-relevant
886886
// config for their type. Mirrors `ActionParamSchema` in @objectstack/spec.
887+
/**
888+
* Widget override — `@objectstack/spec`'s `ActionParamSchema.widget`, the
889+
* same key, vocabulary and meaning as `FieldSchema.widget`: it names a
890+
* registered field widget that draws this param instead of the `type`
891+
* default (`'permission-ref'` on a `text` param picks a permission set by
892+
* its machine name, ADR-0131 D4). `type` stays the VALUE's type.
893+
*
894+
* Set by `resolveActionParams()` — the param's own `widget`, else, for a
895+
* field-backed param that also inherits its `type`, the field's. Read by
896+
* app-shell's `paramToField()`, which draws the named widget when it is
897+
* registered and the `type` widget when it is not.
898+
*/
899+
widget?: string;
887900
/** Accepted upload types (MIME types / extensions) for `file`/`image` params. */
888901
accept?: string[];
889902
/** Max upload size in bytes for `file`/`image` params. */

‎ui/packages/fields/src/resolveActionParams.ts‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,14 @@ export interface RawActionParam {
162162
*/
163163
label?: I18nLabel;
164164
type?: string;
165+
/**
166+
* Widget override — the spec's `ActionParamSchema.widget`, the same key and
167+
* meaning as `FieldSchema.widget`: a registered field widget that draws the
168+
* param instead of its `type` default (`'permission-ref'` on a `text`
169+
* param). Copied onto `ActionParamDef.widget`; `paramToField()` decides
170+
* whether it names a registered widget.
171+
*/
172+
widget?: string;
165173
required?: boolean;
166174
/**
167175
* Option list authored inline on the param. Speaks the same vocabulary as the
@@ -355,6 +363,12 @@ function warnResolvedOnlyKeys(param: RawActionParam): void {
355363
/** Field metadata as exposed by `useMetadata().objects[].fields`. */
356364
interface RuntimeField {
357365
type?: string;
366+
/**
367+
* `@objectstack/spec`'s `FieldSchema.widget`, the field's input override.
368+
* A field-backed param that inherits the field's `type` inherits this with
369+
* it (see {@link inheritedWidget}).
370+
*/
371+
widget?: string;
358372
label?: string;
359373
required?: boolean;
360374
placeholder?: string;
@@ -572,6 +586,25 @@ function storedRow(
572586
return toPredicateRecord(row, rowObject?.fields);
573587
}
574588

589+
/**
590+
* The widget a FIELD-BACKED param is drawn with: its own `widget`, else the
591+
* field's — but the field's only while the param also inherits the field's
592+
* `type`.
593+
*
594+
* The spec resolves a field-backed param's "widget mapping from object
595+
* metadata" (`ActionParamSchema`), and the field's `widget` is that mapping.
596+
* (A param that restates the field's own `type` still inherits it.)
597+
* It is a mapping FOR the field's type, though: the record form draws it over
598+
* a value of that type, and the server validates the param's value by the
599+
* param's `type` (ADR-0104 D2). A param that overrides `type` asks for a
600+
* different value, so a widget picked for the field's value is not inherited
601+
* onto it; the param names its own `widget` if it wants one.
602+
*/
603+
function inheritedWidget(param: RawActionParam, field: RuntimeField): string | undefined {
604+
if (param.widget !== undefined) return param.widget;
605+
return param.type === undefined || param.type === field.type ? field.widget : undefined;
606+
}
607+
575608
/**
576609
* Resolve a single raw param against object metadata. Inline params pass
577610
* through (with safe defaults); field-backed params inherit from the
@@ -622,6 +655,9 @@ export function resolveActionParam(
622655
// copied here never reaches the dialog — which is how `carryOver` went
623656
// unhonoured until objectui#6246. Same line on the two branches below.
624657
carryOver: param.carryOver,
658+
// Same key-by-key copy: without this line an authored `widget` never
659+
// reached the dialog, which drew the `type` widget whatever it named.
660+
widget: param.widget,
625661
multiple: param.multiple,
626662
accept: param.accept,
627663
maxSize: param.maxSize,
@@ -679,6 +715,9 @@ export function resolveActionParam(
679715
defaultValue: rowDefault ?? param.defaultValue,
680716
visible: normaliseVisible(param.visible),
681717
carryOver: param.carryOver,
718+
// Kept for parity; the dialog refuses an unresolved param before it
719+
// builds any widget, so nothing draws it.
720+
widget: param.widget,
682721
multiple: param.multiple,
683722
accept: param.accept,
684723
maxSize: param.maxSize,
@@ -845,6 +884,7 @@ export function resolveActionParam(
845884
visible: normaliseVisible(param.visible),
846885
// A declaration of the PARAM, never inherited from the field.
847886
carryOver: param.carryOver,
887+
widget: inheritedWidget(param, field),
848888
// Widget config inherited from the field for every type (not just
849889
// lookup): multi-value shape and upload constraints (ADR-0059).
850890
multiple: param.multiple ?? field.multiple,

0 commit comments

Comments
 (0)