Skip to content

Commit 0de93df

Browse files
fix(studio): the action designer draws refusals and texts from their served rows (#36688)
Fixes #35650 Clause-②: no Metadata-protocol: none ## 维护者速读 - 在 Studio 里编辑脚本类操作时,整页编辑器和对象的"操作"视图把"拒绝目录"和"文本"两项从一大块原始 JSON 改成按条目编辑的表单,并带上说明文字;关联抽屉原本就是这样。 - 属于 Studio 操作设计器的补完:上一轮已经让服务端表单给这两项声明了逐条编辑的样式,这次让作者平时用的编辑器真正用上它。 - 出错时作者在这两项上会看到原来的 JSON 编辑框或少了说明文字,已存的操作内容和服务端校验都不受影响,可以直接撤回。 - 无 ## What changes - `ActionDefaultInspector` (the action designer, mounted by the full-page editor and by the Studio object's Actions view) reads a new optional `serverForm` prop on `MetadataDefaultInspectorProps` and draws the `refusals` and `texts` rows from their served rows: a one-section `SchemaForm` over the served schema, with the row descriptors taken from the served `action` form (`servedFormRows`), placed in the Behavior section beside the script body. The rows bring the key-only record control, their entry rows and help text, and their own `visibleWhen` (script actions only). Both keys are then hidden from "More fields"; with no served form (or a form without the row) they stay in "More fields" exactly as before. - Hosts pass the served form: `ResourceEditPage` (designer branch, `entry?.form`) and `StudioDesignSurface` (a `typeForms` index beside `typeSchemas`, handed to `ObjectActionsPanel` as `actionForm`, then to the inspector as `serverForm`). - The inspector now mounts two whole-draft forms, so their inline-issue rows go through the existing `useIssuePrefixRegister` union instead of one form writing the host's callback directly. - zh-CN overlay (`metadata-form-zh-cn.ts`): `action` gains `refusals`, `refusals.message`, `refusals.status`, `refusals.reasons`, `refusals.reasons.message`, `refusals.params`, `texts`, `texts.message`, `texts.params`; `hook` gains `texts`, `texts.message`, `texts.params`. Labels copied from the platform bundle `zh-CN.metadata-forms.generated.ts` (labels only, as the overlay's header prescribes for these types). - No schema or served-form change: `packages/spec` is untouched; the rows on `actionForm` are read as served. Landing point: `ui/packages/app-shell/src/views/metadata-admin/**` and the Studio mount in `ui/packages/app-shell/src/views/studio-design/**`. `ResourceEditPage.tsx` gains one prop line. Read first (by risk): 1. `inspectors/ActionDefaultInspector.tsx` — the `servedRowsForm` block and the hidden-fields change on the fallback form; the two `useWholeDraftFormIssueRows` setters. 2. `inspectors/servedFormRows.ts` — the row lookup (string rows, `{ group }` sections skipped). 3. `studio-design/StudioDesignSurface.tsx` — `typeForms` and the `actionForm` hand-off. ## Tests - `ResourceEditPage.actionServedRows-35650.test.tsx` (full-page editor, real page with production registrations, type row built from `actionForm` + `ActionSchema` the way the server builds it): no textarea holds either record as JSON; the served help text of both rows is drawn; the key-only control draws `SIGN_IN_REQUIRED` and `email_subject` under their keys; an entry edited through the served row saves, and the saved action passes `ActionSchema.safeParse`. - `DataPillar.actionServedRows-35650.test.tsx` (Studio design surface: the real Data pillar, Actions tab, with the `action` type row served through `useMetadataTypes`): the same face assertions. <details><summary>Ablation (one, on the inspector)</summary> Fix committed first; `ActionDefaultInspector.tsx` restored to `origin/main` (9348f02) in the tree only, both pin files run, then `git checkout HEAD -- PATH`, proven by blob hash (16b6847 before and after) and an empty `git diff HEAD`. - Mutated: 3 of 3 tests red. Both hosts: `expected [ textarea …, …(1) ] to deeply equal []` — the two raw JSON editors holding `refusals` and `texts`, which is the card's premise measured on both hosts. The round-trip test: no `action-served-rows` mount. - Restored: 3 of 3 green. </details> <details><summary>Create page (premise falsified)</summary> The card lists the create page among the hosts. Measured on this branch with a throwaway render (not committed): the action create page renders the flat `createSchema` form, whose rows are `Label*`, `Name*`, `Object`, `Icon`; it mounts no inspector, draws no `refusals`/`texts` row in any face, and holds no textarea. A new action is named there and authored afterwards in the full-page editor, which this PR fixes. No pin is possible that fails on main, so none is added. </details> ## Acceptance notes - The Studio object's Hooks view (`ObjectHooksPanel` mounting `HookDefaultInspector`) draws the hook's `refusals` and `texts` as raw JSON too: measured on this branch with a throwaway render of the real panel, two textareas holding `{ "CONTRACT_LOCKED": … }` and `{ "follow_up_subject": … }`. The card's "hooks are not affected" holds for the hook's full-page editor only. Same defect class; this PR's `serverForm` prop and `servedFormRows` make it a two-file follow-up (the hook inspector reads `serverForm`, the panel is handed `hookForm`). Reported to the seat, not fixed here. - `StudioBundleItemEditor` also mounts registered default inspectors, but no action reaches it (`AREA_FORM_EDITOR_TYPES` is `email_template`, `translation`; `dataset` for customize), so it is left unchanged. ## Verification Two-minute check (from the repository root, after building the closure): `pnpm --dir ui exec vitest run packages/app-shell/src/views/metadata-admin/ResourceEditPage.actionServedRows-35650.test.tsx packages/app-shell/src/views/studio-design/DataPillar.actionServedRows-35650.test.tsx` — expect `Tests 3 passed (3)`. <details><summary>Local readings at dd2958b</summary> - Closure build `pnpm turbo run build --filter='@object-ui/app-shell^...' --concurrency=2`: lock VERDICT command-exit 0, 68/68 tasks. - New pins: Test Files 2 passed, Tests 3 passed (lock VERDICT command-exit 0). - Related suites (the 7 `ActionDefaultInspector.*` tests, `ActionDesigner.paramVocabulary`, `ResourceEditPage.defaultInspectorIssues-35628`, the `ObjectActionsPanel.*` tests, the `DataPillar.action*` tests): Test Files 20 passed, Tests 135 passed. - `pnpm --filter @object-ui/app-shell type-check` (both `tsc --noEmit` and `tsconfig.test.json`, whose include reaches the new test files): VERDICT command-exit 0. - eslint over the 9 changed ui files: 0 errors (warnings only in `ResourceEditPage.tsx` / `StudioDesignSurface.tsx`, none on changed lines). - `node scripts/pm/dispatch-gates.mjs --commands` derived 39 families; 37 exit 0 in the first pass on this head, and the other two exit 0 on re-run: `check:type-check-debt` (first exit 3 inside its own closure-build lock wait, then exit 0) and the ui scripts suite below. `pnpm --dir ui exec vitest run scripts/`: the first run was killed by the box's memory limit (SIGKILL, no verdict); re-run with `--maxWorkers=2`: Test Files 172 passed, 2 skipped; Tests 5127 passed, 2 skipped (lock VERDICT command-exit 0). - `--ran` reconciliation: 39 derived, 39 run, 0 NOT-MEASURED, 0 UNRUN. - `node scripts/pm/overlap-check.mjs`: merges cleanly with origin/main, 0 open PR heads share a file. - Full app-shell `pnpm test` (2444 test files) and every other CI family: declared to CI (Test UI, Type Check UI, Lint UI). </details> --- _Generated by [Claude Code](https://claude.ai/code/session_011y7As6kDA9BVrMsBR9rmrJ)_ --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>
1 parent c54aa57 commit 0de93df

10 files changed

Lines changed: 486 additions & 2 deletions
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
---
4+
5+
fix(studio): the action designer draws a script action's refusal catalogue and declared texts with their served rows
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
The served `action` form gives `refusals` and `texts` the key-only record control (an entry is drawn under its code or key, with its message, status, reasons and params rows) and help text, but only the Related drawer editor read that form. The action's full-page editor and the Studio object's Actions view mount the action designer, whose "More fields" section was handed the bare schema, so both keys read as the raw JSON editor.
11+
12+
The designer now takes the served form from its host (`serverForm` on the default-inspector props) and draws the two rows from it in its Behavior section, beside the script body; the row's own visibility rule shows them on a script action only. A host with no served form keeps both keys in "More fields", as before. Nothing about what an action stores or what the server accepts changes.
13+
14+
The console's zh-CN overlay gains the labels for the action's `refusals` and `texts` rows and the hook's `texts` rows.
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
/**
4+
* objectstack#35650 — the action's full-page editor draws a script action's
5+
* refusal catalogue (`refusals`) and declared texts (`texts`) with their
6+
* served rows: the key-only record control and the row's help text, not the
7+
* raw JSON editor the bare schema gives a record.
8+
*
9+
* The REAL page with the production registrations: `action` registers a
10+
* preview and a default inspector, so the page takes its designer branch and
11+
* the no-selection panel is `ActionDefaultInspector`. The type row is built
12+
* from the spec the way the server builds it: `actionForm` as the form, and
13+
* `ActionSchema` converted with `z.toJSONSchema(…, { io: 'input' })` as the
14+
* schema. The only stand-ins are the metadata client and the network.
15+
*/
16+
17+
import '@testing-library/jest-dom/vitest';
18+
import * as React from 'react';
19+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
20+
import { cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react';
21+
import { MemoryRouter } from 'react-router-dom';
22+
import { z } from 'zod';
23+
import { ActionSchema, actionForm } from '@objectstack/spec/ui';
24+
25+
// Module-scope imports of the engines the page reaches through dynamic
26+
// `import()` (the CEL authoring and the save-time lint): a cold first load
27+
// stays out of every `waitFor` (`check:test-source-alias`).
28+
import '@objectstack/formula';
29+
import '@objectstack/lint';
30+
31+
/** The `action` row's `schema`, converted from the spec the way the server does. */
32+
const ACTION_JSON_SCHEMA = z.toJSONSchema(ActionSchema as unknown as z.ZodType, {
33+
io: 'input',
34+
unrepresentable: 'any',
35+
}) as Record<string, unknown>;
36+
37+
/** The served row of `key`, read off the form the server serves. */
38+
function servedHelpText(key: string): string {
39+
for (const section of actionForm.sections ?? []) {
40+
for (const row of section.fields ?? []) {
41+
if (typeof row !== 'string' && row.field === key) return String(row.helpText);
42+
}
43+
}
44+
throw new Error(`actionForm declares no ${key} row`);
45+
}
46+
47+
const STORED = {
48+
name: 'sign_contract',
49+
label: 'Sign contract',
50+
objectName: 'contract',
51+
type: 'script',
52+
locations: ['record_header'],
53+
body: { language: 'js', source: "throw { code: 'SIGN_IN_REQUIRED' };" },
54+
refusals: { SIGN_IN_REQUIRED: { message: 'Sign in first.', status: 401 } },
55+
texts: { email_subject: { message: 'Contract signed' } },
56+
};
57+
58+
let stored: Record<string, unknown> = STORED;
59+
60+
const mockClient = {
61+
list: vi.fn(async () => []),
62+
listDrafts: vi.fn(async () => []),
63+
layered: vi.fn(async () => ({ effective: stored, code: null, editable: true, deletable: true })),
64+
getDraft: vi.fn(async () => null),
65+
get: vi.fn(async () => stored),
66+
save: vi.fn(async (_type: string, _name: string, item: unknown) => {
67+
stored = item as Record<string, unknown>;
68+
return {};
69+
}),
70+
saveDraft: vi.fn(async () => ({})),
71+
publish: vi.fn(async () => ({ success: true })),
72+
references: vi.fn(async () => []),
73+
history: vi.fn(async () => []),
74+
// The object-scoped field pickers read the bound object through the draft-preview client.
75+
withPreviewDrafts: vi.fn(),
76+
};
77+
mockClient.withPreviewDrafts.mockImplementation(() => mockClient);
78+
79+
vi.mock('./useMetadata', async (importOriginal) => ({
80+
...(await importOriginal<typeof import('./useMetadata')>()),
81+
useMetadataClient: () => mockClient,
82+
useMetadataTypes: () => ({
83+
loading: false,
84+
error: null,
85+
entries: [
86+
{
87+
type: 'action',
88+
name: 'action',
89+
label: 'Action',
90+
domain: 'ui',
91+
allowEnvironmentOverlay: true,
92+
allowRuntimeCreate: true,
93+
schema: ACTION_JSON_SCHEMA,
94+
form: actionForm,
95+
},
96+
],
97+
}),
98+
}));
99+
vi.mock('@monaco-editor/react', () => {
100+
const Editor = () => null;
101+
return { Editor, default: Editor, loader: { init: () => Promise.reject(new Error('offline')) } };
102+
});
103+
vi.mock('@object-ui/plugin-editor', () => ({ configureBundledMonaco: () => Promise.resolve() }));
104+
vi.stubGlobal(
105+
'fetch',
106+
vi.fn(async () => new Response('null', { status: 404, headers: { 'content-type': 'application/json' } })),
107+
);
108+
109+
import { MetadataResourceEditPage } from './ResourceEditPage';
110+
import { t } from './i18n';
111+
// The load-time registrations, exactly as the package entry runs them, so the
112+
// branch this file takes is the branch production takes.
113+
import './register-builtins';
114+
import { registerBuiltinDesigners } from './register-builtin-designers';
115+
registerBuiltinDesigners();
116+
117+
beforeEach(() => {
118+
stored = STORED;
119+
for (const fn of Object.values(mockClient)) (fn as unknown as { mockClear: () => void }).mockClear();
120+
mockClient.withPreviewDrafts.mockImplementation(() => mockClient);
121+
window.localStorage.setItem('metadata-admin:autosave', '0');
122+
});
123+
afterEach(() => {
124+
cleanup();
125+
window.localStorage.removeItem('metadata-admin:autosave');
126+
});
127+
128+
async function openAction(): Promise<void> {
129+
render(
130+
<MemoryRouter initialEntries={['/metadata/action/sign_contract']}>
131+
<MetadataResourceEditPage type="action" name="sign_contract" />
132+
</MemoryRouter>,
133+
);
134+
// The designer branch opens editable: its panel is the inspector itself.
135+
await screen.findByText(t('engine.inspector.moreFields', 'en'), {}, { timeout: 8000 });
136+
137+
}
138+
139+
describe('the action full-page editor draws refusals and texts from their served rows (objectstack#35650)', () => {
140+
it('draws each as the key-only record control with the served help text, and no raw JSON', async () => {
141+
await openAction();
142+
// No editor on the panel holds either record as JSON text (the raw JSON face).
143+
const jsonHolders = Array.from(document.querySelectorAll('textarea')).filter(
144+
(el) => el.value.includes('"SIGN_IN_REQUIRED"') || el.value.includes('"email_subject"'),
145+
);
146+
expect(jsonHolders).toEqual([]);
147+
// The served rows' help text, and the key-only control drawing each entry under its key.
148+
expect(screen.getByText(servedHelpText('refusals'))).toBeInTheDocument();
149+
expect(screen.getByText(servedHelpText('texts'))).toBeInTheDocument();
150+
const rows = screen.getByTestId('action-served-rows');
151+
expect(within(rows).getByText('SIGN_IN_REQUIRED', { selector: 'span' })).toBeInTheDocument();
152+
expect(within(rows).getByText('email_subject', { selector: 'span' })).toBeInTheDocument();
153+
});
154+
155+
it('an entry edited through the served row saves as a spec-valid action', async () => {
156+
await openAction();
157+
const rows = screen.getByTestId('action-served-rows');
158+
fireEvent.click(within(rows).getByText('email_subject', { selector: 'span' }));
159+
const entry = within(rows).getByText('email_subject', { selector: 'span' }).closest('.rounded-md') as HTMLElement;
160+
fireEvent.change(within(entry).getByDisplayValue('Contract signed'), { target: { value: 'Your contract is signed' } });
161+
await waitFor(() => expect(screen.getByTestId('resource-save')).toBeEnabled(), { timeout: 4000 });
162+
fireEvent.click(screen.getByTestId('resource-save'));
163+
await waitFor(() => expect(mockClient.save).toHaveBeenCalledTimes(1), { timeout: 6000 });
164+
const body = JSON.parse(JSON.stringify(mockClient.save.mock.calls[0]![2])) as Record<string, unknown>;
165+
expect(body.texts).toEqual({ email_subject: { message: 'Your contract is signed' } });
166+
expect(body.refusals).toEqual(STORED.refusals);
167+
const parsed = ActionSchema.safeParse(body);
168+
expect(parsed.success, JSON.stringify(parsed.error?.issues)).toBe(true);
169+
});
170+
});

‎ui/packages/app-shell/src/views/metadata-admin/ResourceEditPage.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3812,6 +3812,7 @@ function MetadataResourceEditPageImpl({
38123812
readOnly={formReadOnly}
38133813
locale={locale}
38143814
serverSchema={entry?.schema as Record<string, unknown> | undefined}
3815+
serverForm={entry?.form}
38153816
issues={displayIssues}
38163817
revealIssues={revealIssues}
38173818
onInlineIssueFieldsChange={setInlineIssueFields}

‎ui/packages/app-shell/src/views/metadata-admin/default-inspector-registry.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import type { ComponentType, ReactNode } from 'react';
2424
import type { SupportedLocale } from './i18n.js';
2525
import { createObservableTypeRegistry, type MetadataSelection } from './preview-registry.js';
2626
import type { SchemaFormIssue } from './SchemaForm.js';
27+
import type { FormViewSpec } from './form-spec.js';
2728

2829
export interface MetadataDefaultInspectorProps {
2930
/** Metadata type, e.g. 'view'. */
@@ -73,6 +74,16 @@ export interface MetadataDefaultInspectorProps {
7374
* server schema is available (offline / older server).
7475
*/
7576
serverSchema?: Record<string, unknown>;
77+
/**
78+
* The served FormView layout for this type (`RichMetadataTypeEntry.form`,
79+
* from `/meta/types`), the form a generic host hands `SchemaForm` beside
80+
* {@link serverSchema}. A curated inspector reads the rows it names from it,
81+
* so a row the server declares a face for (a widget, help text, a
82+
* visibility predicate) is drawn with that face rather than the one the
83+
* bare schema implies (objectstack#35650). Undefined when the host has no
84+
* served form: such an inspector draws those keys as it did without one.
85+
*/
86+
serverForm?: FormViewSpec;
7687
/**
7788
* The host's issues on the draft (a refused save, the live pass), paths
7889
* relative to the draft — what the host's fallback form is handed. An

‎ui/packages/app-shell/src/views/metadata-admin/inspectors/ActionDefaultInspector.tsx‎

Lines changed: 70 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@
4141
* control, shared (`ScriptCapabilitiesField`), because both bodies are the
4242
* spec's one `HookBodySchema`. An expression body shows none, and a switch to
4343
* it drops the grant with the other L2-only keys ({@link writeScriptBody}).
44+
*
45+
* A script action's refusal catalogue (`refusals`) and declared texts (`texts`)
46+
* are drawn from their SERVED form rows (objectstack#35650), handed in as
47+
* `serverForm`: the key-only record control, the entry rows and the help text
48+
* the server declares. Fed the bare schema in "More fields" they read as the
49+
* raw JSON editor. A host with no served form keeps them in "More fields".
4450
*/
4551

4652
import * as React from 'react';
@@ -59,6 +65,9 @@ import { usePermissions } from '@object-ui/permissions';
5965
import type { MetadataDefaultInspectorProps } from '../default-inspector-registry.js';
6066
import { SchemaForm } from '../SchemaForm.js';
6167
import { fallbackFormPatch } from './fallbackFormPatch.js';
68+
import { servedFormRows } from './servedFormRows.js';
69+
import { useIssuePrefixRegister } from '../issuePath.js';
70+
import type { FormViewSpec } from '../form-spec.js';
6271
import { t, tFormat, type SupportedLocale } from '../i18n.js';
6372
import {
6473
InspectorShell,
@@ -479,6 +488,19 @@ const CURATED_FIELDS = [
479488
*/
480489
const RETIRED_FIELDS = ['bulkEnabled', 'shortcut'];
481490

491+
/**
492+
* Keys this inspector draws from their SERVED form row (objectstack#35650),
493+
* beside the script body in the Behavior section: the action's refusal
494+
* catalogue and its declared texts. Each is a record keyed by the code or key
495+
* the body uses, and its served row declares the key-only record control, the
496+
* entry's own rows and the help text; the bare schema the fallback form reads
497+
* says only "a record", which is the raw JSON editor. The row's own
498+
* `visibleWhen` (a `script` action) decides when it shows.
499+
*
500+
* A key the served form has no row for stays in the fallback form, as before.
501+
*/
502+
const SERVED_ROW_FIELDS = ['refusals', 'texts'] as const;
503+
482504
/* ─────────────── small helpers ─────────────── */
483505

484506
function SectionHeader({ title, hint }: { title: string; hint?: string }) {
@@ -639,6 +661,23 @@ function ParamOptionsEditor({ options, onCommit, disabled, locale }: {
639661

640662
/* ─────────────── inspector ─────────────── */
641663

664+
/**
665+
* The setter a whole-draft `SchemaForm` reports its inline rows through
666+
* (`onInlineIssueFieldsChange`): each row key is registered, unprefixed, for as
667+
* long as the form reports it, so two such forms on one draft are heard as one
668+
* union rather than the later report replacing the earlier one.
669+
*/
670+
function useWholeDraftFormIssueRows(
671+
register: (prefix: string) => () => void,
672+
): (rows: ReadonlySet<string>) => void {
673+
const [rows, setRows] = React.useState<ReadonlySet<string>>(() => new Set());
674+
React.useEffect(() => {
675+
const offs = [...rows].map((row) => register(row));
676+
return () => offs.forEach((off) => off());
677+
}, [rows, register]);
678+
return setRows;
679+
}
680+
642681
/**
643682
* The CEL editors this inspector mounts, as aggregation keys. Errors are
644683
* counted PER SITE rather than into one running total: the two predicate
@@ -659,8 +698,15 @@ export function ActionDefaultInspector({
659698
issues,
660699
revealIssues,
661700
onInlineIssueFieldsChange,
701+
serverForm,
662702
}: MetadataDefaultInspectorProps) {
663703
const tr = React.useCallback((key: string) => t(key, locale), [locale]);
704+
// Two forms draw rows of this draft (the served rows below and the "More
705+
// fields" fallback), so each registers the rows it draws and the host hears
706+
// the union (objectstack#35628's inline register).
707+
const registerIssuePrefix = useIssuePrefixRegister(onInlineIssueFieldsChange);
708+
const setServedIssueRows = useWholeDraftFormIssueRows(registerIssuePrefix);
709+
const setFallbackIssueRows = useWholeDraftFormIssueRows(registerIssuePrefix);
664710
// objectui#12510 — the Icon label names the icon picker (the shape objectui#12531
665711
// gave the object and app-nav icon fields): the picker is a combobox, which
666712
// takes no name from its content.
@@ -899,6 +945,14 @@ export function ActionDefaultInspector({
899945
};
900946

901947
const fallbackSchema = serverSchema as Record<string, unknown> | undefined;
948+
// objectstack#35650 — the served rows of SERVED_ROW_FIELDS, for the keys the
949+
// served schema declares, as a one-section form over the same schema.
950+
const servedProps = (fallbackSchema?.properties ?? {}) as Record<string, unknown>;
951+
const servedRows = servedFormRows(serverForm, SERVED_ROW_FIELDS).filter((row) => row.field in servedProps);
952+
const servedRowsForm: FormViewSpec | undefined =
953+
serverForm && servedRows.length > 0
954+
? { ...serverForm, type: 'simple', sections: [{ fields: servedRows }], groups: undefined }
955+
: undefined;
902956

903957
return (
904958
<InspectorShell
@@ -1084,6 +1138,20 @@ export function ActionDefaultInspector({
10841138
<div className="text-[11px] text-muted-foreground/70">{tr('engine.inspector.action.bodyShapeHint')}</div>
10851139
</div>
10861140
)}
1141+
{fallbackSchema && servedRowsForm && (
1142+
<div data-testid="action-served-rows">
1143+
<SchemaForm
1144+
schema={fallbackSchema}
1145+
form={servedRowsForm}
1146+
value={draft}
1147+
readOnly={readOnly}
1148+
issues={issues}
1149+
revealIssues={revealIssues}
1150+
onInlineIssueFieldsChange={setServedIssueRows}
1151+
onChange={(next) => onPatch(fallbackFormPatch(draft, next))}
1152+
/>
1153+
</div>
1154+
)}
10871155
</div>
10881156

10891157
{/* 3 ─ Inputs (params) */}
@@ -1272,11 +1340,11 @@ export function ActionDefaultInspector({
12721340
<SchemaForm
12731341
schema={fallbackSchema}
12741342
value={draft}
1275-
hiddenFields={[...CURATED_FIELDS, ...RETIRED_FIELDS]}
1343+
hiddenFields={[...CURATED_FIELDS, ...RETIRED_FIELDS, ...(servedRowsForm ? servedRows.map((row) => row.field) : [])]}
12761344
readOnly={readOnly}
12771345
issues={issues}
12781346
revealIssues={revealIssues}
1279-
onInlineIssueFieldsChange={onInlineIssueFieldsChange}
1347+
onInlineIssueFieldsChange={setFallbackIssueRows}
12801348
onChange={(next) => onPatch(fallbackFormPatch(draft, next))}
12811349
/>
12821350
</div>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
import type { FormFieldSpec, FormViewSpec } from '../form-spec.js';
4+
5+
/**
6+
* The rows the served form declares for `keys`, in the form's own order
7+
* (objectstack#35650).
8+
*
9+
* A curated inspector edits most keys with its own controls and hands the rest
10+
* to a "More fields" `SchemaForm` fed the bare served schema. A key whose
11+
* served row declares its face — a `widget`, help text, nested row
12+
* descriptors, a visibility predicate — loses all of it there: the schema
13+
* alone says only "a record", and a record with no row reads as the raw JSON
14+
* editor. Drawing such a key from its served row is how the inspector reads
15+
* the contract the server already serves, instead of hand-building a second
16+
* face for it.
17+
*
18+
* A key the form declares no row for is not returned, so the caller keeps
19+
* drawing it in its fallback form, as before: nothing is lost when the host
20+
* has no served form, or the server's form predates the row. A `{ group }`
21+
* section names no row by key, so it contributes none here (`SchemaForm`
22+
* resolves such a section when it renders a whole form; this is a lookup).
23+
*/
24+
export function servedFormRows(
25+
form: FormViewSpec | undefined,
26+
keys: readonly string[],
27+
): FormFieldSpec[] {
28+
const rows: FormFieldSpec[] = [];
29+
for (const section of form?.sections ?? form?.groups ?? []) {
30+
if (!Array.isArray(section.fields)) continue;
31+
for (const row of section.fields) {
32+
const spec: FormFieldSpec = typeof row === 'string' ? { field: row } : row;
33+
if (keys.includes(spec.field) && !rows.some((r) => r.field === spec.field)) rows.push(spec);
34+
}
35+
}
36+
return rows;
37+
}

0 commit comments

Comments
 (0)