From f85cbaf312958a8f7aec23798a1ecc3bb0e5ed4c Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 02:54:59 +0000 Subject: [PATCH 1/6] feat(app-shell): the action result dialog draws the table answer format Claude-Session: https://claude.ai/code/session_01ADHkmSYVw1sqCsaHSJS9JC Co-authored-by: Claude --- .../src/views/ActionResultDialog.tsx | 184 +++++++++++++++++- 1 file changed, 174 insertions(+), 10 deletions(-) diff --git a/ui/packages/app-shell/src/views/ActionResultDialog.tsx b/ui/packages/app-shell/src/views/ActionResultDialog.tsx index da5cb73c291..eea0d1ad063 100644 --- a/ui/packages/app-shell/src/views/ActionResultDialog.tsx +++ b/ui/packages/app-shell/src/views/ActionResultDialog.tsx @@ -9,8 +9,8 @@ * Contract (mirrors `Action.resultDialog` in @objectstack/spec): * - `spec.fields[]` selects what to render. Each entry has a dot `path` * into `data` and an optional `format` (qrcode/code-list/secret/ - * text/json). When `fields` is omitted, the dialog renders the whole - * payload as JSON. Entries whose `path` does not resolve in the payload + * text/json/table; `table` with its `columns`, objectstack#33187). When + * `fields` is omitted, the dialog renders the whole payload as JSON. Entries whose `path` does not resolve in the payload * are skipped — the response shape varies per request (e.g. no * `temporaryPassword` when the admin typed one), and a labelled * `undefined` row would be noise. @@ -33,6 +33,12 @@ import { DialogHeader, DialogTitle, Button, + Table, + TableBody, + TableCell, + TableHead, + TableHeader, + TableRow, } from '@object-ui/components'; import { useObjectTranslation } from '@object-ui/i18n'; import { useActionDialogReturnFocus } from './actionDialogReturnFocus.js'; @@ -44,6 +50,7 @@ import { toCanvas } from 'qrcode'; // confusable and answer wrongly for each other's input (objectui#4167), and // `resultDialog`'s label members are the INLINE form. import { resolveI18nLabel as resolveInlineI18nLabel } from '@objectstack/spec/ui'; +import type { Action as SpecAction } from '@objectstack/spec/ui'; import type { ResultDialogSpec, ResultDialogFieldSpec } from '@object-ui/core'; export interface ResultDialogState { @@ -59,6 +66,18 @@ interface ActionResultDialogProps { } type FieldFormat = NonNullable; +/** A `table` column, derived from the contract's answer-field row (objectstack#34391). */ +type AnswerTableColumn = NonNullable< + NonNullable['fields']>[number]['columns'] +>[number]; +/** + * One answer field as this renderer reads it: the runner's field spec plus the + * contract's `columns`, which `format: 'table'` requires. Both callers hand + * the declared row through whole (the result dialog's localized spec spreads + * each row; the preflight panel's rows are the contract's own), so `columns` + * arrives as written. + */ +type AnswerField = ResultDialogFieldSpec & { columns?: AnswerTableColumn[] }; function readPath(root: unknown, path: string): unknown { if (root == null) return undefined; @@ -96,8 +115,8 @@ export function ActionResultDialog({ state, onAcknowledge }: ActionResultDialogP // path does not resolve in the payload are dropped: the value is // response-shape dependent (e.g. `temporaryPassword` only exists when the // server generated one), and a labelled `undefined` row helps nobody. - const fields = useMemo>(() => { - const declared: ResultDialogFieldSpec[] = + const fields = useMemo>(() => { + const declared: AnswerField[] = spec?.fields && spec.fields.length > 0 ? spec.fields : [{ path: '', label: undefined, format: spec?.format ?? 'json' }]; @@ -108,6 +127,9 @@ export function ActionResultDialog({ state, onAcknowledge }: ActionResultDialogP })) .filter(({ field, value }) => field.path === '' || value !== undefined); }, [spec, data]); + // A table of several columns does not fit the narrow reveal dialog; the + // dialog widens when it draws one. + const drawsTable = fields.some(({ field, value }) => field.format === 'table' && Array.isArray(value)); return ( e.preventDefault()} onEscapeKeyDown={(e) => e.preventDefault()} - className="max-w-lg" + className={drawsTable ? 'max-w-3xl' : 'max-w-lg'} > @@ -163,7 +185,7 @@ export function ResultField({ value, defaultFormat, }: { - field: ResultDialogFieldSpec; + field: AnswerField; value: unknown; defaultFormat?: FieldFormat; }) { @@ -185,11 +207,12 @@ export function ResultField({ // Type-guard each renderer rather than crash if the server returned an // unexpected shape (e.g. format=qrcode but value is undefined). We // degrade gracefully to JSON so the user can still recover the value. + // `table` draws an array (the contract: a value that is not an array draws + // as `json`, as `code-list` does); every other format is the contract's fit + // test, the one a table cell applies too. const safeFormat: FieldFormat = (() => { - if (format === 'qrcode' && typeof value !== 'string') return 'json'; - if (format === 'code-list' && !Array.isArray(value)) return 'json'; - if ((format === 'secret' || format === 'text') && typeof value !== 'string') return 'json'; - return format; + if (format === 'table') return Array.isArray(value) ? 'table' : 'json'; + return valueFitsFormat(format, value) ? format : 'json'; })(); return ( @@ -204,10 +227,151 @@ export function ResultField({ {safeFormat === 'secret' ? : null} {safeFormat === 'text' ? : null} {safeFormat === 'json' ? : null} + {safeFormat === 'table' ? ( + + ) : null} + + ); +} + +/** + * Whether a present value fits a format the way the contract's renderer + * contract says (`resultDialog` in `@objectstack/spec`): `qrcode`, `secret` + * and `text` take a string, `code-list` an array of strings, `json` anything. + * A value that does not fit draws as JSON instead. + */ +function valueFitsFormat(format: Exclude, value: unknown): boolean { + switch (format) { + case 'qrcode': + case 'secret': + case 'text': + return typeof value === 'string'; + case 'code-list': + return Array.isArray(value) && value.every((item) => typeof item === 'string'); + case 'json': + return true; + } +} + +/** A plain object: the only element a column `path` is read in. */ +function isPlainObject(value: unknown): value is Record { + return typeof value === 'object' && value !== null && !Array.isArray(value); +} + +/** One line of JSON text: how `json`, and any value that does not fit its format, draws in a cell. */ +function compactJson(value: unknown): string { + try { + return JSON.stringify(value) ?? String(value); + } catch { + return String(value); + } +} + +/** + * `format: 'table'` (objectstack#34391): each element of the array is one row + * and each entry of `columns` one cell, in `columns` order, under a header + * that is the column's `label`, falling back to its `path`. A cell reads the + * column's dot `path` in the element; a path that resolves to nothing, or to + * `null`, draws an empty cell. An element that is not a plain object has no + * paths to read, so its row draws the element itself as compact JSON text in + * the first cell and leaves the others empty. `[]` draws the header row over + * an empty-state line. + */ +function TableBlock({ + rows, + columns, + label, +}: { + rows: unknown[]; + columns: AnswerTableColumn[]; + label: string | undefined; +}) { + const { t, language } = useObjectTranslation(); + const headers = columns.map((column) => resolveInlineI18nLabel(column.label, language) || column.path); + return ( +
+ + + + {columns.map((column, index) => ( + {headers[index]} + ))} + + + + {rows.length === 0 ? ( + + + {t('table.noRows')} + + + ) : ( + rows.map((element, rowIndex) => ( + + {columns.map((column, columnIndex) => { + if (!isPlainObject(element)) { + return ( + + {columnIndex === 0 ? : null} + + ); + } + const cellName = label ? `${label}, ${headers[columnIndex]}` : headers[columnIndex]!; + return ( + + + + ); + })} + + )) + )} + +
); } +/** + * One cell of a table. Missing and `null` draw nothing; a value that fits the + * column's format draws in it; any other value, and every `json` cell, draws + * as compact JSON text. Inside a row a cell is compact: `text` and + * `code-list` draw the value alone, while `secret` keeps its mask and reveal + * toggle and `qrcode` its code, each with its copy button. + */ +function TableCellValue({ + value, + format, + copyName, +}: { + value: unknown; + format: Exclude; + copyName: string; +}) { + if (value === undefined || value === null) return null; + if (format === 'json' || !valueFitsFormat(format, value)) return ; + if (format === 'text') return {value as string}; + if (format === 'secret') return ; + if (format === 'qrcode') return ; + return ( +
    + {(value as string[]).map((code, i) => ( +
  • + {code} +
  • + ))} +
+ ); +} + +function CompactJson({ value }: { value: unknown }) { + return {compactJson(value)}; +} + function useCopy(value: string | undefined) { const [copied, setCopied] = useState(false); useEffect(() => { From ae12b3f42f843d4cdc3edef8d9fde9c8f43b0540 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 02:56:53 +0000 Subject: [PATCH 2/6] feat(platform-objects,spec): the import answer draws as a table; columns is live Claude-Session: https://claude.ai/code/session_01ADHkmSYVw1sqCsaHSJS9JC Co-authored-by: Claude --- .../src/identity/sys-user.object.ts | 23 +++++++++++++++- packages/spec/liveness/action.json | 27 ++++++++++--------- packages/spec/src/ui/action.zod.ts | 25 ++++++++--------- 3 files changed, 49 insertions(+), 26 deletions(-) diff --git a/packages/platform-objects/src/identity/sys-user.object.ts b/packages/platform-objects/src/identity/sys-user.object.ts index 1c836e0edfb..0295e08ef5c 100644 --- a/packages/platform-objects/src/identity/sys-user.object.ts +++ b/packages/platform-objects/src/identity/sys-user.object.ts @@ -548,11 +548,32 @@ export const SysUser = ObjectSchema.create({ resultDialog: { title: 'Import Finished', acknowledge: 'Done', + // `rows` is the door's per-row report (plugin-auth + // `ImportSsoUserRowResult`), drawn as a table: one row per CSV line, a + // cell per answer member. A member a row does not carry draws an empty + // cell: `alreadyPending` and `host` only on a row that was added, + // `error` only on one that was not, `notApplied` only on a re-add that + // sent columns, `managerError` only when no manager was linked. fields: [ { path: 'summary.added', label: 'Added', format: 'text' }, { path: 'summary.alreadyPending', label: 'Already pending, told again', format: 'text' }, { path: 'summary.failed', label: 'Not added', format: 'text' }, - { path: 'rows', label: 'Result per row', format: 'json' }, + { + path: 'rows', + label: 'Result per row', + format: 'table', + columns: [ + { path: 'row', label: 'Row', format: 'json' }, + { path: 'email', label: 'Email' }, + { path: 'ok', label: 'Succeeded', format: 'json' }, + { path: 'alreadyPending', label: 'Already pending, told again', format: 'json' }, + { path: 'host.notified', label: 'Hosting organization told', format: 'json' }, + { path: 'host.reason', label: 'Why not told' }, + { path: 'error.message', label: 'Not added because' }, + { path: 'notApplied', label: 'Not applied (set these on the record)', format: 'code-list' }, + { path: 'managerError', label: 'Manager' }, + ], + }, ], }, }, diff --git a/packages/spec/liveness/action.json b/packages/spec/liveness/action.json index 6e15ce14fdb..dd8c0aa2b49 100644 --- a/packages/spec/liveness/action.json +++ b/packages/spec/liveness/action.json @@ -277,7 +277,7 @@ }, "resultDialog": { "status": "live", - "note": "objectui one-shot result reveal {title,description,acknowledge,format,fields}. `fields[].format: 'table'` and its `columns` (#34391) are PLANNED until the console reader #33187 lands (see `preflight.fields.columns`, the same row): the spec refuses the contradictions at parse, and the console draws a `table` row's label alone today." + "note": "objectui one-shot result reveal {title,description,acknowledge,format,fields}. `fields[].format: 'table'` and its `columns` (#34391) are LIVE since the console reader #33187 (see `preflight.fields.columns`, the same row): the spec refuses the contradictions at parse, and the console's `ResultField` draws a `table` row as a table, one row per element and one cell per column." }, "preflight": { "status": "live", @@ -327,24 +327,25 @@ "note": "Live with its container `preflight.fields`: the row's display format, from resultDialog's format set." }, "columns": { - "status": "planned", - "verifiedAt": "2026-11-16", - "note": "PLANNED (spec card #34391; reader #33187, maintainer ruling A 6915677641). The cells of a `format: 'table'` row, `[{ path, label?, format? }]`, from the row builder `resultDialog.fields` shares (packages/spec/src/ui/action.zod.ts#actionAnswerFieldRow). Enforced at parse today: required by `table`, refused beside any other format (#refuseTableColumnContradictions), and a cell takes the field formats minus `table`. NOT yet drawn: the console's `ResultField` (ui/packages/app-shell/src/views/ActionResultDialog.tsx) has no `table` branch, so until #33187 lands a `table` row draws its label alone. Re-grade `live` in the PR that lands that renderer.", + "status": "live", + "verifiedAt": "2026-11-17", + "evidence": "ui/packages/app-shell/src/views/ActionResultDialog.tsx#ResultField (the `table` branch: an array value draws through `TableBlock`, any other value as `json`); ui/packages/app-shell/src/views/ActionResultDialog.tsx#TableBlock (one row per element, one cell per entry of `columns`, in order); ui/packages/app-shell/src/views/ActionResultDialog.tsx#TableCellValue (the cell, in the column's format or as compact JSON); ui/packages/app-shell/src/views/ActionParamDialog.tsx#PreflightPanel (each preflight `fields` row through the same `ResultField`)", + "note": "LIVE (spec card #34391; reader #33187, maintainer ruling A 6915677641). The cells of a `format: 'table'` row, `[{ path, label?, format? }]`, from the row builder `resultDialog.fields` shares (packages/spec/src/ui/action.zod.ts#actionAnswerFieldRow). Enforced at parse: required by `table`, refused beside any other format (#refuseTableColumnContradictions), and a cell takes the field formats minus `table`. Drawn by the console's `ResultField`, which the result dialog and the preflight panel share, by the `table` bullet of the `resultDialog` renderer contract; pinned in ui/packages/app-shell/src/views/__tests__/ActionResultDialog.test.tsx. First producer: `sys_user.import_sso_users`, whose per-row report draws as a table (packages/platform-objects/src/identity/sys-user.object.ts).", "children": { "path": { - "status": "planned", - "verifiedAt": "2026-11-16", - "note": "Planned with its container `preflight.fields.columns`: the dot path, in ONE element of the array, of the value a cell draws; a path that resolves to nothing draws an empty cell, and an element that is not an object draws as compact JSON text in its row's first cell." + "status": "live", + "verifiedAt": "2026-11-17", + "note": "Live with its container `preflight.fields.columns`: the dot path, in ONE element of the array, of the value a cell draws; a path that resolves to nothing or to `null` draws an empty cell, and an element that is not a plain object draws as compact JSON text in its row's first cell." }, "label": { - "status": "planned", - "verifiedAt": "2026-11-16", - "note": "Planned with its container `preflight.fields.columns`: the column header; omitted, the header is the column's `path`." + "status": "live", + "verifiedAt": "2026-11-17", + "note": "Live with its container `preflight.fields.columns`: the column header; omitted, the header is the column's `path`." }, "format": { - "status": "planned", - "verifiedAt": "2026-11-16", - "note": "Planned with its container `preflight.fields.columns`: the cell format, the field formats minus `table` (refused at parse: a table does not nest); omitted, `text`. A value that does not fit the cell's format, whatever it is, draws as compact JSON text, and a missing value draws an empty cell (the `table` bullet of the `resultDialog` renderer contract)." + "status": "live", + "verifiedAt": "2026-11-17", + "note": "Live with its container `preflight.fields.columns`: the cell format, the field formats minus `table` (refused at parse: a table does not nest); omitted, `text`. A value that does not fit the cell's format, whatever it is, draws as compact JSON text, and a missing or `null` value draws an empty cell (the `table` bullet of the `resultDialog` renderer contract)." } } } diff --git a/packages/spec/src/ui/action.zod.ts b/packages/spec/src/ui/action.zod.ts index 18c781bd295..5101ce62a17 100644 --- a/packages/spec/src/ui/action.zod.ts +++ b/packages/spec/src/ui/action.zod.ts @@ -873,7 +873,7 @@ const ActionAnswerTableColumnSchema = strictObject({ '`table` is a field format, not a cell format: a cell draws one value of one row, and a table does not ' + 'nest. Drop `format` (a cell value that does not fit its format, an object or an array included, draws as compact JSON text), or ' + "write `format: 'json'`.", - ).optional().describe('Cell format: the field formats minus `table`; omitted, `text`. A value that does not fit the cell\'s format, whatever it is (an object or an array under `text`, a number under `secret`), draws as compact JSON text; a missing value draws an empty cell.'), + ).optional().describe('Cell format: the field formats minus `table`; omitted, `text`. A value that does not fit the cell\'s format, whatever it is (an object or an array under `text`, a number under `secret`), draws as compact JSON text; a missing or `null` value draws an empty cell.'), }); /** @@ -935,8 +935,8 @@ function actionAnswerFieldRow(surface: string, pathDescription: string) { }, { path: z.string().describe(pathDescription), label: I18nLabelSchema.optional(), - format: ActionAnswerFieldFormatSchema.optional().describe('Per-field format override. `table` [PLANNED — not yet rendered] draws an array as rows and requires `columns`.'), - columns: z.array(ActionAnswerTableColumnSchema).optional().describe("[PLANNED — not yet rendered] The cells of a `format: 'table'` field, in order: `[{ path, label?, format? }]`, `path` read in ONE element of the array. Required by `table` (never guessed from the element's keys) and refused beside any other format. Until the console's table renderer lands, a `table` field draws its label alone."), + format: ActionAnswerFieldFormatSchema.optional().describe('Per-field format override. `table` draws an array as rows and requires `columns`.'), + columns: z.array(ActionAnswerTableColumnSchema).optional().describe("The cells of a `format: 'table'` field, in order: `[{ path, label?, format? }]`, `path` read in ONE element of the array. Required by `table` (never guessed from the element's keys) and refused beside any other format."), }).superRefine(refuseTableColumnContradictions); } @@ -1809,15 +1809,16 @@ const actionObject = () => strictObject({ * each entry of the field's `columns` one cell, in `columns` order. The * header of a column is its `label`, falling back to its `path`. A cell * reads the column's dot `path` in the element; a missing value (the - * path resolves to `undefined`) draws an empty cell. A present value - * draws in the column's `format` (omitted: `text`) when it fits that - * format the way a field's value must: `qrcode`, `secret` and `text` take - * a string, `code-list` an array of strings. Any value that does not fit, - * whatever the column's format (an object or an array under the omitted - * `text`, a number under `secret`), draws as compact JSON text, which is - * also how `json` draws in a cell. An element that is not an object has no - * paths to read: its row draws the element itself as compact JSON text in - * the first cell and leaves the other cells empty. `[]` draws the header + * path resolves to `undefined`) and a `null` draw an empty cell. A + * present value draws in the column's `format` (omitted: `text`) when it + * fits that format the way a field's value must: `qrcode`, `secret` and + * `text` take a string, `code-list` an array of strings. Any value that + * does not fit, whatever the column's format (an object or an array under + * the omitted `text`, a number under `secret`), draws as compact JSON + * text, which is also how `json` draws in a cell. An element that is not + * a plain object (an array, `null` or a scalar) has no paths to read: its + * row draws the element itself as compact JSON text in the first cell and + * leaves the other cells empty. `[]` draws the header * row over an empty-state line. A field value that is missing is skipped * like any other field's, and one that is not an array draws as `json`, * as `code-list` does. From ab02a3e4d3a012166d2d6151cbf813482ee7e078 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 03:06:33 +0000 Subject: [PATCH 3/6] test(app-shell,platform-objects): pin the table renderer and the import table; changeset Claude-Session: https://claude.ai/code/session_01ADHkmSYVw1sqCsaHSJS9JC Co-authored-by: Claude --- .../33187-action-answer-table-renderer.md | 18 ++ .../identity/cloud-managed-visibility.test.ts | 42 +++++ packages/spec/liveness/state-counts/action.md | 2 +- .../__tests__/ActionResultDialog.test.tsx | 163 +++++++++++++++++- 4 files changed, 223 insertions(+), 2 deletions(-) create mode 100644 .changeset/33187-action-answer-table-renderer.md diff --git a/.changeset/33187-action-answer-table-renderer.md b/.changeset/33187-action-answer-table-renderer.md new file mode 100644 index 00000000000..75b95cf5b98 --- /dev/null +++ b/.changeset/33187-action-answer-table-renderer.md @@ -0,0 +1,18 @@ +--- +'@object-ui/app-shell': patch +'@objectstack/platform-objects': patch +'@objectstack/spec': patch +--- + +feat(app-shell): the action result dialog draws a `table` answer field as rows, and Import Users shows its result per row in one + +Clause-②: yes (widening) — the console now draws `format: 'table'` fields (declared since the spec half) instead of their label alone, and `sys_user.import_sso_users` draws its per-row report as a table instead of JSON; no input is refused that was accepted before +Metadata-protocol: none + +The console's action result dialog, and the param dialog's preflight panel that shares its field renderer, draw a field with `format: 'table'` as a table: one row per element of the array, one cell per entry of the field's `columns`, in order, under the column's `label` (or its `path`). A cell reads its `path` in the element; a missing key or a `null` draws an empty cell, a value that fits the column's `format` draws in it, and anything else draws as one line of JSON. An element that is not a plain object draws as JSON in its row's first cell. An empty array draws the header over a "No rows to display" line. The dialog widens when it draws a table. + +A `code-list` field now draws as a code list only when its value is an array of strings, as the renderer contract says; any other array draws as JSON. + +`@objectstack/platform-objects`: on a cloud-managed environment, the Import Users result shows one row per CSV line, with the email, whether it succeeded, whether the address was already pending, whether the hosting organization was told and why not, why a row was not added, the columns that were not applied, and a manager that was not linked. The summary counts stay above it. + +`@objectstack/spec`: `columns` is no longer marked `[PLANNED — not yet rendered]`, and the renderer contract now says that a `null` cell value draws an empty cell and that only a plain object is read by column paths (an array or `null` element draws as JSON). Its liveness rows are `live`. diff --git a/packages/platform-objects/src/identity/cloud-managed-visibility.test.ts b/packages/platform-objects/src/identity/cloud-managed-visibility.test.ts index fdaca70b925..ca20e917797 100644 --- a/packages/platform-objects/src/identity/cloud-managed-visibility.test.ts +++ b/packages/platform-objects/src/identity/cloud-managed-visibility.test.ts @@ -293,3 +293,45 @@ describe('features.cloudManaged hides every other action whose door writes or de expect(offeredOn(SysInvitation, 'reject_invitation', INVITATION_ROW, { ...MULTI, cloudManaged: true })).toBe(true); }); }); + +/** + * objectstack#33187: the import door answers one report row per CSV line + * (plugin-auth `ImportSsoUserRowResult`: `row`, `email`, `ok`, + * `alreadyPending`, `host`, `error`, `notApplied`, `managerError`), and the + * result dialog draws that report as a `table`, one cell per member a reader + * needs, instead of a block of JSON. The columns are the contract's + * (`resultDialog.fields[].columns`), so the declaration parses as the + * console's `ResultField` reads it. + */ +describe('import_sso_users draws the per-row report as a table', () => { + const rowsField = () => { + const dialog = declared('import_sso_users').resultDialog as { fields?: Array> }; + return (dialog.fields ?? []).find((field) => field.path === 'rows'); + }; + + it('declares `rows` as a `table` whose columns read the door row members, in reading order', () => { + const field = rowsField(); + expect(field?.format).toBe('table'); + expect((field?.columns as Array<{ path: string }>).map((column) => column.path)).toEqual([ + 'row', + 'email', + 'ok', + 'alreadyPending', + 'host.notified', + 'host.reason', + 'error.message', + 'notApplied', + 'managerError', + ]); + }); + + it('CONTROL: the summary counts stay fields of their own, ahead of the table', () => { + const dialog = declared('import_sso_users').resultDialog as { fields?: Array<{ path: string; format?: string }> }; + expect(dialog.fields?.map((field) => [field.path, field.format])).toEqual([ + ['summary.added', 'text'], + ['summary.alreadyPending', 'text'], + ['summary.failed', 'text'], + ['rows', 'table'], + ]); + }); +}); diff --git a/packages/spec/liveness/state-counts/action.md b/packages/spec/liveness/state-counts/action.md index 5ab922ebcfd..4c65dc20ed8 100644 --- a/packages/spec/liveness/state-counts/action.md +++ b/packages/spec/liveness/state-counts/action.md @@ -12,4 +12,4 @@ committed anywhere: `check:liveness` sums the shards when it reads them. | Type | live | exp | elsewhere | dead | planned | classified | |---|---|---|---|---|---|---| -| `action` | 79 | 0 | 0 | 1 | 5 | 85 | +| `action` | 82 | 0 | 0 | 1 | 2 | 85 | diff --git a/ui/packages/app-shell/src/views/__tests__/ActionResultDialog.test.tsx b/ui/packages/app-shell/src/views/__tests__/ActionResultDialog.test.tsx index 93b1c47df15..60f83361df4 100644 --- a/ui/packages/app-shell/src/views/__tests__/ActionResultDialog.test.tsx +++ b/ui/packages/app-shell/src/views/__tests__/ActionResultDialog.test.tsx @@ -3,7 +3,7 @@ import { describe, it, expect, vi } from 'vitest'; import { render, screen, fireEvent, act, within } from '@testing-library/react'; import type { ResultDialogSpec } from '@object-ui/core'; -import { ActionResultDialog } from '../ActionResultDialog'; +import { ActionResultDialog, ResultField } from '../ActionResultDialog'; /** * The display language the dialog resolves an `I18nLabel` against, mutable per @@ -239,3 +239,164 @@ describe('ActionResultDialog — every copy button has an accessible name', () = expect(region).toHaveTextContent('actions.resultDialog.copied'); }); }); + +/** + * objectstack#33187 — `format: 'table'` (the contract's `table` bullet on + * `resultDialog`, objectstack#34391): an array drawn as rows, one cell per + * entry of the field's `columns`, in order. The five formats above are the + * CONTROL: they draw as they did. + */ +describe('ActionResultDialog — a `table` field draws its array as rows', () => { + const columns = [ + { path: 'row', label: 'Row', format: 'json' as const }, + { path: 'email', label: 'Email' }, + { path: 'host.reason' }, + { path: 'notApplied', label: 'Not applied', format: 'code-list' as const }, + ]; + const tableSpec = (cols: unknown[] = columns): ResultDialogSpec => ({ + title: 'Import Finished', + fields: [{ path: 'rows', label: 'Result per row', format: 'table', columns: cols } as never], + }); + const bodyRows = () => within(screen.getByTestId('result-table')).getAllByRole('row').slice(1); + const cellsOf = (row: HTMLElement) => within(row).getAllByRole('cell').map((cell) => cell.textContent); + + it('draws a header per column, its label or else its path, in `columns` order', () => { + i18nState.language = 'en'; + open(tableSpec(), { rows: [{ row: 1, email: 'a@example.com' }] }); + + const headers = within(screen.getByTestId('result-table')).getAllByRole('columnheader'); + expect(headers.map((h) => h.textContent)).toEqual(['Row', 'Email', 'host.reason', 'Not applied']); + // The field's own label still heads the block. + expect(screen.getByText('Result per row')).toBeInTheDocument(); + }); + + it('draws one row per element, a cell per column read at its path in that element', () => { + i18nState.language = 'en'; + open(tableSpec(), { + rows: [ + { row: 1, email: 'a@example.com', host: { notified: false, reason: 'no_host' } }, + { row: 2, email: 'b@example.com', notApplied: ['positions', 'manager'] }, + ], + }); + + const rows = bodyRows(); + expect(rows).toHaveLength(2); + expect(cellsOf(rows[0]!)).toEqual(['1', 'a@example.com', 'no_host', '']); + // A `code-list` cell draws each string of the array. + expect(cellsOf(rows[1]!)).toEqual(['2', 'b@example.com', '', 'positionsmanager']); + expect(within(rows[1]!).getAllByRole('listitem').map((li) => li.textContent)).toEqual(['positions', 'manager']); + }); + + it('draws an empty cell for a key the element does not carry, and for `null` — never the text `null`', () => { + i18nState.language = 'en'; + open(tableSpec(), { rows: [{ row: 1, email: null, host: null }] }); + + expect(cellsOf(bodyRows()[0]!)).toEqual(['1', '', '', '']); + expect(screen.queryByText('null')).not.toBeInTheDocument(); + }); + + it('draws a value that does not fit its cell format as compact JSON text', () => { + i18nState.language = 'en'; + open( + tableSpec([ + { path: 'flag' }, + { path: 'meta' }, + { path: 'codes', format: 'code-list' }, + { path: 'pin', format: 'secret' }, + ]), + { rows: [{ flag: true, meta: { a: 1 }, codes: [1, 2], pin: 42 }] }, + ); + + expect(cellsOf(bodyRows()[0]!)).toEqual(['true', '{"a":1}', '[1,2]', '42']); + }); + + it('keeps a `secret` cell masked until revealed', () => { + i18nState.language = 'en'; + open(tableSpec([{ path: 'pin', label: 'PIN', format: 'secret' }]), { rows: [{ pin: 'abcd' }] }); + + expect(screen.getByText('••••')).toBeInTheDocument(); + expect(screen.queryByText('abcd')).not.toBeInTheDocument(); + expect( + screen.getByRole('button', { name: 'actions.resultDialog.copyFieldItem(label=Result per row, PIN, index=1)' }), + ).toBeInTheDocument(); + }); + + it('draws an element that is not a plain object as compact JSON in the first cell, the others empty', () => { + i18nState.language = 'en'; + open(tableSpec(), { rows: [['x', 1], null, 'plain', 7] }); + + expect(bodyRows().map(cellsOf)).toEqual([ + ['["x",1]', '', '', ''], + ['null', '', '', ''], + ['"plain"', '', '', ''], + ['7', '', '', ''], + ]); + }); + + it('draws `[]` as the header row over an empty-state line', () => { + i18nState.language = 'en'; + open(tableSpec(), { rows: [] }); + + const table = screen.getByTestId('result-table'); + expect(within(table).getAllByRole('columnheader')).toHaveLength(4); + expect(within(table).getByText('table.noRows')).toBeInTheDocument(); + }); + + it('draws a value that is not an array as `json`, and skips a missing one', () => { + i18nState.language = 'en'; + open(tableSpec(), { rows: { not: 'an array' } }); + + expect(screen.queryByTestId('result-table')).not.toBeInTheDocument(); + expect(screen.getByText(/"not": "an array"/)).toBeInTheDocument(); + }); + + it('skips a `table` field whose path the answer does not carry, like any other field', () => { + i18nState.language = 'en'; + open(tableSpec(), { summary: { added: 1 } }); + + expect(screen.queryByText('Result per row')).not.toBeInTheDocument(); + expect(screen.queryByTestId('result-table')).not.toBeInTheDocument(); + }); + + it('resolves an inline per-locale column label against the display language', () => { + i18nState.language = 'zh-CN'; + open(tableSpec([{ path: 'email', label: { en: 'Email', 'zh-CN': '邮箱' } }]), { rows: [{ email: 'a@example.com' }] }); + + expect(within(screen.getByTestId('result-table')).getByRole('columnheader').textContent).toBe('邮箱'); + i18nState.language = 'en'; + }); + + it('draws in the preflight panel too: `ResultField` takes the same row', () => { + i18nState.language = 'en'; + render( + , + ); + + const rows = within(screen.getByTestId('result-table')).getAllByRole('row'); + expect(cellsOf(rows[1]!)).toEqual(['crm_lead', 'drop']); + }); +}); + +/** + * objectstack#33187 (renderer note on the `code-list` fit test): the contract + * fits `code-list` to an array of STRINGS. Any other array draws as JSON. + */ +describe('ActionResultDialog — a `code-list` field fits an array of strings only', () => { + it('draws an array that holds a non-string as JSON, not as a code list', () => { + i18nState.language = 'en'; + open({ title: 'Codes', fields: [{ path: 'codes', label: 'Codes', format: 'code-list' }] }, { codes: ['a', { b: 1 }] }); + + expect(screen.queryByRole('button', { name: 'actions.resultDialog.copyAll' })).not.toBeInTheDocument(); + expect(screen.getByText(/"b": 1/)).toBeInTheDocument(); + }); + + it('CONTROL: an array of strings still draws as a code list', () => { + i18nState.language = 'en'; + open({ title: 'Codes', fields: [{ path: 'codes', label: 'Codes', format: 'code-list' }] }, { codes: ['a', 'b'] }); + + expect(screen.getByRole('button', { name: 'actions.resultDialog.copyAll' })).toBeInTheDocument(); + }); +}); From 02ecb82378588ae80fed7e621c5450a276ff6b2e Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 05:44:42 +0000 Subject: [PATCH 4/6] docs(spec): say which cell formats keep their copy control; list table in the actions page Claude-Session: https://claude.ai/code/session_01ADHkmSYVw1sqCsaHSJS9JC Co-authored-by: Claude --- content/docs/protocol/objectui/actions.mdx | 2 +- packages/spec/src/ui/action.zod.ts | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/content/docs/protocol/objectui/actions.mdx b/content/docs/protocol/objectui/actions.mdx index 0810fef374e..7e2caebbb14 100644 --- a/content/docs/protocol/objectui/actions.mdx +++ b/content/docs/protocol/objectui/actions.mdx @@ -480,7 +480,7 @@ resultDialog: - { path: client.client_secret, label: Client Secret, format: secret } ``` -Each `fields[].path` is a dot path into `result.data`. The per-field `format` (`qrcode`, `code-list`, `secret`, `text`, `json`) controls rendering. +Each `fields[].path` is a dot path into `result.data`. The per-field `format` (`qrcode`, `code-list`, `secret`, `text`, `json`, `table`) controls rendering. `table` draws an array as rows and requires `columns: [{ path, label?, format? }]`, one entry per cell, with `path` read in one element of the array; `columns` is refused beside any other format, and a cell takes any format but `table`. #### ⚠️ That `target` is not interchangeable with the SDK's registration door diff --git a/packages/spec/src/ui/action.zod.ts b/packages/spec/src/ui/action.zod.ts index 5101ce62a17..3a8e81f1439 100644 --- a/packages/spec/src/ui/action.zod.ts +++ b/packages/spec/src/ui/action.zod.ts @@ -873,7 +873,7 @@ const ActionAnswerTableColumnSchema = strictObject({ '`table` is a field format, not a cell format: a cell draws one value of one row, and a table does not ' + 'nest. Drop `format` (a cell value that does not fit its format, an object or an array included, draws as compact JSON text), or ' + "write `format: 'json'`.", - ).optional().describe('Cell format: the field formats minus `table`; omitted, `text`. A value that does not fit the cell\'s format, whatever it is (an object or an array under `text`, a number under `secret`), draws as compact JSON text; a missing or `null` value draws an empty cell.'), + ).optional().describe('Cell format: the field formats minus `table`; omitted, `text`. A value that does not fit the cell\'s format, whatever it is (an object or an array under `text`, a number under `secret`), draws as compact JSON text; a missing or `null` value draws an empty cell. Inside a cell, `text` and `code-list` draw the value alone with no copy control, while `secret` keeps its mask, reveal and copy and `qrcode` keeps its code and copy.'), }); /** @@ -1815,7 +1815,10 @@ const actionObject = () => strictObject({ * `text` take a string, `code-list` an array of strings. Any value that * does not fit, whatever the column's format (an object or an array under * the omitted `text`, a number under `secret`), draws as compact JSON - * text, which is also how `json` draws in a cell. An element that is not + * text, which is also how `json` draws in a cell. Inside a cell, `text` + * and `code-list` draw the value alone with no copy control, while + * `secret` keeps its mask, reveal and copy and `qrcode` keeps its code + * and copy. An element that is not * a plain object (an array, `null` or a scalar) has no paths to read: its * row draws the element itself as compact JSON text in the first cell and * leaves the other cells empty. `[]` draws the header From d4a79d7fee16a6d1dde66c5f8bb47094f846e8b4 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 05:45:20 +0000 Subject: [PATCH 5/6] fix(core): ResultDialogFieldSpec derives columns from the contract Claude-Session: https://claude.ai/code/session_01ADHkmSYVw1sqCsaHSJS9JC Co-authored-by: Claude --- .../src/views/ActionResultDialog.tsx | 23 ++++++-------- .../__tests__/ActionResultDialog.test.tsx | 8 ++--- ui/packages/core/src/actions/ActionRunner.ts | 5 ++++ .../ActionRunner.resultDialog.test.ts | 30 +++++++++++++++++++ 4 files changed, 48 insertions(+), 18 deletions(-) diff --git a/ui/packages/app-shell/src/views/ActionResultDialog.tsx b/ui/packages/app-shell/src/views/ActionResultDialog.tsx index eea0d1ad063..e5ae90fbf50 100644 --- a/ui/packages/app-shell/src/views/ActionResultDialog.tsx +++ b/ui/packages/app-shell/src/views/ActionResultDialog.tsx @@ -50,7 +50,6 @@ import { toCanvas } from 'qrcode'; // confusable and answer wrongly for each other's input (objectui#4167), and // `resultDialog`'s label members are the INLINE form. import { resolveI18nLabel as resolveInlineI18nLabel } from '@objectstack/spec/ui'; -import type { Action as SpecAction } from '@objectstack/spec/ui'; import type { ResultDialogSpec, ResultDialogFieldSpec } from '@object-ui/core'; export interface ResultDialogState { @@ -66,18 +65,14 @@ interface ActionResultDialogProps { } type FieldFormat = NonNullable; -/** A `table` column, derived from the contract's answer-field row (objectstack#34391). */ -type AnswerTableColumn = NonNullable< - NonNullable['fields']>[number]['columns'] ->[number]; /** - * One answer field as this renderer reads it: the runner's field spec plus the - * contract's `columns`, which `format: 'table'` requires. Both callers hand - * the declared row through whole (the result dialog's localized spec spreads - * each row; the preflight panel's rows are the contract's own), so `columns` - * arrives as written. + * A `table` column, as the runner's field spec derives it from the contract's + * answer-field row (objectstack#34391). Both callers hand the declared row + * through whole (the result dialog's localized spec spreads each row; the + * preflight panel's rows are the contract's own), so `columns` arrives as + * written. */ -type AnswerField = ResultDialogFieldSpec & { columns?: AnswerTableColumn[] }; +type AnswerTableColumn = NonNullable[number]; function readPath(root: unknown, path: string): unknown { if (root == null) return undefined; @@ -115,8 +110,8 @@ export function ActionResultDialog({ state, onAcknowledge }: ActionResultDialogP // path does not resolve in the payload are dropped: the value is // response-shape dependent (e.g. `temporaryPassword` only exists when the // server generated one), and a labelled `undefined` row helps nobody. - const fields = useMemo>(() => { - const declared: AnswerField[] = + const fields = useMemo>(() => { + const declared: ResultDialogFieldSpec[] = spec?.fields && spec.fields.length > 0 ? spec.fields : [{ path: '', label: undefined, format: spec?.format ?? 'json' }]; @@ -185,7 +180,7 @@ export function ResultField({ value, defaultFormat, }: { - field: AnswerField; + field: ResultDialogFieldSpec; value: unknown; defaultFormat?: FieldFormat; }) { diff --git a/ui/packages/app-shell/src/views/__tests__/ActionResultDialog.test.tsx b/ui/packages/app-shell/src/views/__tests__/ActionResultDialog.test.tsx index 60f83361df4..b6157193fcd 100644 --- a/ui/packages/app-shell/src/views/__tests__/ActionResultDialog.test.tsx +++ b/ui/packages/app-shell/src/views/__tests__/ActionResultDialog.test.tsx @@ -2,7 +2,7 @@ import { describe, it, expect, vi } from 'vitest'; import { render, screen, fireEvent, act, within } from '@testing-library/react'; -import type { ResultDialogSpec } from '@object-ui/core'; +import type { ResultDialogSpec, ResultDialogFieldSpec } from '@object-ui/core'; import { ActionResultDialog, ResultField } from '../ActionResultDialog'; /** @@ -253,9 +253,9 @@ describe('ActionResultDialog — a `table` field draws its array as rows', () => { path: 'host.reason' }, { path: 'notApplied', label: 'Not applied', format: 'code-list' as const }, ]; - const tableSpec = (cols: unknown[] = columns): ResultDialogSpec => ({ + const tableSpec = (cols: NonNullable = columns): ResultDialogSpec => ({ title: 'Import Finished', - fields: [{ path: 'rows', label: 'Result per row', format: 'table', columns: cols } as never], + fields: [{ path: 'rows', label: 'Result per row', format: 'table', columns: cols }], }); const bodyRows = () => within(screen.getByTestId('result-table')).getAllByRole('row').slice(1); const cellsOf = (row: HTMLElement) => within(row).getAllByRole('cell').map((cell) => cell.textContent); @@ -370,7 +370,7 @@ describe('ActionResultDialog — a `table` field draws its array as rows', () => i18nState.language = 'en'; render( , ); diff --git a/ui/packages/core/src/actions/ActionRunner.ts b/ui/packages/core/src/actions/ActionRunner.ts index 43ef8dcbb50..f47c1e3b971 100644 --- a/ui/packages/core/src/actions/ActionRunner.ts +++ b/ui/packages/core/src/actions/ActionRunner.ts @@ -823,6 +823,11 @@ export interface ResultDialogFieldSpec { label?: SpecResultDialogField['label']; /** Derived, like `label`: the contract's field format set (`table` included). */ format?: SpecResultDialogField['format']; + /** + * Derived, like `format`: the cells of a `format: 'table'` field, + * `[{ path, label?, format? }]`, `path` read in one element of the array. + */ + columns?: SpecResultDialogField['columns']; } export interface ResultDialogSpec { /** Derived `I18nLabel` — see `ResultDialogFieldSpec.label` on resolving it. */ diff --git a/ui/packages/core/src/actions/__tests__/ActionRunner.resultDialog.test.ts b/ui/packages/core/src/actions/__tests__/ActionRunner.resultDialog.test.ts index afb089571e6..ced7f87738e 100644 --- a/ui/packages/core/src/actions/__tests__/ActionRunner.resultDialog.test.ts +++ b/ui/packages/core/src/actions/__tests__/ActionRunner.resultDialog.test.ts @@ -18,9 +18,11 @@ * `encodeURIComponent`, and degrades missing keys to empty string. */ import { describe, it, expect, vi, beforeEach, type Mock } from 'vitest'; +import type { Action as SpecAction } from '@objectstack/spec/ui'; import { ActionRunner, type ActionDef, + type ResultDialogFieldSpec, type ResultDialogHandler, type ToastHandler, } from '../ActionRunner'; @@ -282,3 +284,31 @@ describe('ActionRunner - target interpolation', () => { fetchSpy.mockRestore(); }); }); + +/** + * objectstack#33187 — `ResultDialogFieldSpec.columns` is DERIVED from the + * contract's answer-field row, like `label` and `format` beside it, so the + * console's `table` renderer reads `columns` off the runner's own type and no + * caller re-declares it. These are TYPES: `tsconfig.test.json` (chained off + * this package's `type-check`) compiles this file, so dropping the member, or + * restating it as a hand-written shape that drifts from the spec, is a compile + * error. The runtime `expect` only makes the case visible to vitest. + */ +type Assert = T; +type IsAny = 0 extends 1 & T ? true : false; +type Equal = (() => T extends A ? 1 : 2) extends () => T extends B ? 1 : 2 ? true : false; +type SpecAnswerField = NonNullable['fields']>[number]; + +describe('ResultDialogFieldSpec carries the contract\'s `columns`', () => { + it('is pinned at compile time', () => { + type _SpecNotAny = Assert, false>>; + type _IsTheSpecColumns = Assert>; + type _Optional = Assert>; + const field: ResultDialogFieldSpec = { + path: 'rows', + format: 'table', + columns: [{ path: 'email', label: 'Email' }, { path: 'notApplied', format: 'code-list' }], + }; + expect(field.columns?.map((column) => column.path)).toEqual(['email', 'notApplied']); + }); +}); From d854d108bdf7ce0bcbcc456fd8ed980eea437147 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 05:45:36 +0000 Subject: [PATCH 6/6] chore(changeset): name the core type and the cell copy sentence Claude-Session: https://claude.ai/code/session_01ADHkmSYVw1sqCsaHSJS9JC Co-authored-by: Claude --- .changeset/33187-action-answer-table-renderer.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.changeset/33187-action-answer-table-renderer.md b/.changeset/33187-action-answer-table-renderer.md index 75b95cf5b98..dc4f78be887 100644 --- a/.changeset/33187-action-answer-table-renderer.md +++ b/.changeset/33187-action-answer-table-renderer.md @@ -1,5 +1,6 @@ --- '@object-ui/app-shell': patch +'@object-ui/core': patch '@objectstack/platform-objects': patch '@objectstack/spec': patch --- @@ -15,4 +16,6 @@ A `code-list` field now draws as a code list only when its value is an array of `@objectstack/platform-objects`: on a cloud-managed environment, the Import Users result shows one row per CSV line, with the email, whether it succeeded, whether the address was already pending, whether the hosting organization was told and why not, why a row was not added, the columns that were not applied, and a manager that was not linked. The summary counts stay above it. -`@objectstack/spec`: `columns` is no longer marked `[PLANNED — not yet rendered]`, and the renderer contract now says that a `null` cell value draws an empty cell and that only a plain object is read by column paths (an array or `null` element draws as JSON). Its liveness rows are `live`. +`@objectstack/spec`: `columns` is no longer marked `[PLANNED — not yet rendered]`, and the renderer contract now says that a `null` cell value draws an empty cell and that only a plain object is read by column paths (an array or `null` element draws as JSON). It also says that inside a table cell `text` and `code-list` draw the value alone with no copy control, while `secret` keeps its mask, reveal and copy and `qrcode` keeps its code and copy. Its liveness rows are `live`. + +`@object-ui/core`: `ResultDialogFieldSpec` gains `columns`, derived from the contract's answer-field row like its `label` and `format`, so the console's table renderer reads it off the runner's own type.