From b2fbb50ba520fee2aacee7598c5fb38d7c849400 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 30 Nov 2026 14:27:18 +0000 Subject: [PATCH 1/4] docs(skills): objectstack-ui teaches a form as a form item in forms:, views: as lists only ADR-0159 D1 and D5. rules/list-views.md: Form Views becomes Forms and teaches the form item (defineForm, name OBJECT.KEY, object, the body at the top level), the two refusals an author meets, the forms translation family, and one sentence on a form found inside a view. No example authors a form inside a view. SKILL.md and rules/navigation.md name the form item. The evals exercise an action-opened form item (case 25) and a public one (case 28). Paid by deletion in the same file; the three token ceilings follow their files down (list-views 4510 to 4509, SKILL.md 2228 to 2227, navigation 2559 to 2556). Claude-Session: https://claude.ai/code/session_01ADHkmPDtfMCw4FJfyFfQ7v Co-authored-by: Claude --- .changeset/37105-skills-teach-forms.md | 26 ++++++ scripts/check-skills-token-ratchet.mjs | 24 +++++- skills/objectstack-ui/SKILL.md | 10 +-- skills/objectstack-ui/evals/README.md | 3 +- .../evals/views-apps-actions-pages.json | 26 ++++-- skills/objectstack-ui/rules/list-views.md | 84 +++++++++---------- skills/objectstack-ui/rules/navigation.md | 6 +- 7 files changed, 115 insertions(+), 64 deletions(-) create mode 100644 .changeset/37105-skills-teach-forms.md diff --git a/.changeset/37105-skills-teach-forms.md b/.changeset/37105-skills-teach-forms.md new file mode 100644 index 00000000000..568350cc596 --- /dev/null +++ b/.changeset/37105-skills-teach-forms.md @@ -0,0 +1,26 @@ +--- +'@objectstack/skills': patch +--- + +docs(skills): `objectstack-ui` teaches a form as a `form` item in `forms:`, and `views:` as lists only + +Clause-②: no +Metadata-protocol: none + +ADR-0159 makes a form a metadata type of its own. The published skill now teaches that one shape and no other. + +`skills/objectstack-ui/rules/list-views.md`: the section *Form Views* is now *Forms*. A form is a `form` item in the stack's `forms:`, written with `defineForm` in a `*.form.ts`: `name` (`OBJECT.KEY`, its prefix equal to `object`), `object`, and the form body at the top level. It is a form something opens, either a public form (it declares `sharing.publicLink`) or one an action of `type: 'form'` opens by its `target`; `os validate` warns `form-consumer-less` on a form with neither. The record's New and Edit forms stay the object's `fieldGroups` and are never a `form` item. The section carries one type-checked `defineForm` example and teaches: + +- `viewKind`, `config` and `data` are refused on a `form` item: a form is bound with `object`. +- A form left open on a public address another form holds is refused, naming both forms (`form-public-address-taken` from `os validate`, `409 FORM_ADDRESS_TAKEN` from a save). A form holds its address while its `publicLink` names it, switched on or off. +- Translations sit under `forms.NAME` (`.label`, `.title`, `.description`, `.submitBehavior.*`, `.sections.SECTION.*`); a section with no key there reads `objects.OBJECT._sections.SECTION`. + +No example authors a form inside a view any more: the `defineView` container example lists `list` and `listViews` only, and one sentence says a form found inside a view (a container's `form:` or `formViews`, a `viewKind: 'form'` item) moves to `forms:`. + +`skills/objectstack-ui/SKILL.md`: Trap 1, the routing table's form row (`*.form.ts`) and the Action Types `form` row name the `form` item. `rules/navigation.md` says `form` item and links the renamed heading. + +A reader who linked `rules/list-views.md#form-views` or `#field-conditional-rules-in-forms` finds those headings gone: the first is `#forms`, and the second is one clause of the Forms paragraph that points at objectstack-data's Conditional Field Rules. + +The words are paid for in the same file, and the three token ceilings follow their files down: `rules/list-views.md` 4510 to 4509, `SKILL.md` 2228 to 2227, `rules/navigation.md` 2559 to 2556. Cut from `rules/list-views.md`: the *Field Conditional Rules in Forms* section, the third copy of the `defineView` scaffold (the `userActions: { search: false }` example, now its one key inline), and a sentence of Master-Detail item 1 that `SKILL.md` Trap 2 states word for word. + +`evals/views-apps-actions-pages.json`: case 25 now expects a `form` item an action opens, with its sections' `columns`; new case 28 expects a public `form` item and the answer that the address is held by a switched-off form that keeps its link. Cases 1, 6 and 19 keep their prompts and no longer name a form authored inside a view. diff --git a/scripts/check-skills-token-ratchet.mjs b/scripts/check-skills-token-ratchet.mjs index 95419ecaa85..d16337d7ec4 100644 --- a/scripts/check-skills-token-ratchet.mjs +++ b/scripts/check-skills-token-ratchet.mjs @@ -1354,7 +1354,11 @@ export const CEILINGS = new Map([ // 2262 -> 2228: the Action Types table drops its `ask_ai` row and the footnote under it // drops the same name, the type having left `ActionType` (ADR-0160 D7). 9075 bytes (9048 // priced) -> 8937 (8910 priced) -> 2228 tokens; the row follows the measurement down. - ['skills/objectstack-ui/SKILL.md', 2228], // -34 to the measurement (was 2262) + // 2228 -> 2227 (#37105, ADR-0159 card 4, the skill): Trap 1, the routing table's form row + // and the Action Types `form` row name the `form` item (`forms:`, `defineForm`, + // `*.form.ts`) where they named a form view. 8937 bytes (8910 priced) -> 8933 (8906 + // priced) -> 2227 tokens; net shrink, so the row follows the measurement down. + ['skills/objectstack-ui/SKILL.md', 2227], // -1 to the measurement (was 2228) // 8333 -> 6193: RE-LOCK at the landed count after the #19715 split (decision // batch #213 item 1, maintainer 「1 2 4 同意」): the worked R1, the report // template and the v17-canonical shapes block moved VERBATIM into @@ -2114,7 +2118,17 @@ export const CEILINGS = new Map([ // line into `skills/objectstack-ui`; it authorises its own measured delta and no more. // 17790 -> 18039 bytes (+249) -> 4510 tokens, ceiling +62, pinned AT the measurement. // ceil($(wc -c < skills/objectstack-ui/rules/list-views.md) / 4) == ceil(18039 / 4) - ['skills/objectstack-ui/rules/list-views.md', 4510], + // 4510 -> 4509 (#37105, ADR-0159 card 4, the skill): `## Form Views` becomes `## Forms` and + // teaches the `form` item: one checked `defineForm` example, the top-level body, the two + // refusals an author meets, the `forms` translation family, and one sentence on a form + // found inside a view. The container example loses its form member. PAID BY DELETION in + // this file: `## Field Conditional Rules in Forms` folds into one clause of the Forms + // paragraph, the third copy of the container scaffold (the `userActions: { search: false }` + // example) becomes its one key inline, and Master-Detail item 1 drops the sentence + // SKILL.md Trap 2 states word for word. 18039 -> 18036 bytes -> 4509 tokens; net shrink, + // so the row follows the measurement down. + // ceil($(wc -c < skills/objectstack-ui/rules/list-views.md) / 4) == ceil(18036 / 4) + ['skills/objectstack-ui/rules/list-views.md', 4509], // -1 to the measurement (was 4510) // 2273 -> 2196 (#27059): LOWERED. The Surface bullet points at `rules/record-page.md`, // says create / edit is a modal or the `editMode: 'page'` route, and the Overlay-width // bullet moved there whole (the `size` bucket, the deprecated pixel keys); the ceiling @@ -2134,7 +2148,11 @@ export const CEILINGS = new Map([ // absorbed, ceiling +380, pinned AT the measurement. Authority as the `rules/actions.md` // row above. // ceil($(wc -c < skills/objectstack-ui/rules/navigation.md) / 4) == ceil(10255 / 4) - ['skills/objectstack-ui/rules/navigation.md', 2559], // -5 to the measurement (was 2564) + // 2559 -> 2556 (#37105): Record Presentation says `form` item where it said form view, + // and links `list-views.md#forms`, the heading that card renames. 10235 -> 10222 bytes + // -> 2556 tokens; the row follows the measurement down. + // ceil($(wc -c < skills/objectstack-ui/rules/navigation.md) / 4) == ceil(10222 / 4) + ['skills/objectstack-ui/rules/navigation.md', 2556], // -3 to the measurement (was 2559) // 5501 -> 5692 (#19715, card item 4): a 5-line table of contents at the top, // anchors to the file's existing headings, nothing else changed. +191 tokens, // zero headroom to absorb any of it, ceiling +191. Maintainer ruling diff --git a/skills/objectstack-ui/SKILL.md b/skills/objectstack-ui/SKILL.md index f853fe3ceba..380e0ba8c73 100644 --- a/skills/objectstack-ui/SKILL.md +++ b/skills/objectstack-ui/SKILL.md @@ -41,10 +41,10 @@ metadata: Two more: [List Views](#list-views), [Actions](#actions). -1. **New and Edit are the object's fields and `fieldGroups`, never a form - view**: they load no `form` or `formViews.create`, which parse. +1. **New and Edit are the object's fields and `fieldGroups`, never a `form` + item**: they load no `form` item, which parses. `showOnCreate: false` keeps a field off every create surface (refused - beside `required: true`): [Form Views](./rules/list-views.md#form-views). + beside `required: true`): [Forms](./rules/list-views.md#forms). 2. **A record entered with its line items is a parent field group naming the child** (`fieldGroups: [{ key: 'lines', label: 'Lines', relatedList: 'invoice_line' }]`), before any custom page; without it nothing changes: @@ -74,7 +74,7 @@ Two more: [List Views](#list-views), [Actions](#actions). | Authoring | In | Open first | |:--|:--|:--| | A list, board, calendar, gallery or gantt: columns, `filter`, quick filters, toolbar search, sorting, grouping | `src/views/*.view.ts` | [List Views](./rules/list-views.md) | -| New / Edit form (field groups, `showOnCreate`, line items, field rules); a named or public form | the object; `src/views/*.view.ts` | [Form Views](./rules/list-views.md#form-views) | +| New / Edit form (field groups, `showOnCreate`, line items, field rules); a public or action-opened form (`defineForm`, `forms:`) | the object; `*.form.ts` | [Forms](./rules/list-views.md#forms) | | An app and its navigation; who sees or opens it; object nav, a `filters` slice or an interface page | `src/apps/*.app.ts` | [Navigation](./rules/navigation.md) | | What a record page shows: related lists, a slotted or full page; how a record opens | the object | [Record Page](./rules/record-page.md) | | A button or operation: `locations`, visibility, dialog and toast copy, params, new tab, the body's `ctx`, refusing by code (`refusals`) | `src/actions/*.action.ts`, `*.actions.ts` | [Actions](./rules/actions.md) | @@ -147,7 +147,7 @@ never its label ([Actions](./rules/actions.md)): | `modal` | Open the page named by `target`; a `body` runs only on `script` | | `flow` | Launch a screen/auto-launched flow by name; a multi-step operation is this, with a flow you also author | | `api` | Call a registered API endpoint | -| `form` | Open a FormView by name (routed to `/_console/forms/:name`) | +| `form` | Open the `form` item `target` names (`OBJECT.KEY`) on its own page | Every type but `script` requires `target`. diff --git a/skills/objectstack-ui/evals/README.md b/skills/objectstack-ui/evals/README.md index 7c479af0f52..ccee86dcd7c 100644 --- a/skills/objectstack-ui/evals/README.md +++ b/skills/objectstack-ui/evals/README.md @@ -25,7 +25,8 @@ view / page / dashboard / report metadata. - `views-apps-actions-pages.json` — `defineView` containers, `App.create` navigation, `defineAction` surfaces, record / interface pages, package docs, the New and Edit form built from the object (field groups, - `showOnCreate`, line items), a named form's section `columns`, a view added + `showOnCreate`, line items), a `form` item an action opens and its section + `columns`, a public `form` item on an address another form holds, a view added beside the list (and the empty board over a field added with it), a write button whose body writes, the view kind the request names, an AI-exposed delete gated by `ai.requiresConfirmation`, not `confirmText`. diff --git a/skills/objectstack-ui/evals/views-apps-actions-pages.json b/skills/objectstack-ui/evals/views-apps-actions-pages.json index 8172c250de2..8e22b42557f 100644 --- a/skills/objectstack-ui/evals/views-apps-actions-pages.json +++ b/skills/objectstack-ui/evals/views-apps-actions-pages.json @@ -4,11 +4,11 @@ { "id": 1, "prompt": "Create `src/views/support-case.view.ts`: a default grid (subject linking to the record, status, priority, owner, due date), a 'My Open Cases' list, a kanban by status, and a simple edit form with the case details in one section. None of the project's files are in this directory: write the file in your answer.", - "expected_output": "One `defineView({ list, listViews })` container — never a bare flat view object. `data: { provider: 'object', object: 'support_case' }`, `columns` with `link: true` on `subject`, the owner column is the injected `owner_id` (never an `assigned_to` field), a `listViews.my_open` entry with `filter` triples (`{ field: 'owner_id', operator: 'equals', value: '{current_user_id}' }`), a kanban entry with the required top-level `columns` plus `kanban: { groupByField: 'status' }` (no top-level `groupBy`). No `form` in the container: the edit form is built from the object, so the answer says its section is a `fieldGroups` entry of `support_case` (an internal `form` parses and is not loaded).", + "expected_output": "One `defineView({ list, listViews })` container — never a bare flat view object. `data: { provider: 'object', object: 'support_case' }`, `columns` with `link: true` on `subject`, the owner column is the injected `owner_id` (never an `assigned_to` field), a `listViews.my_open` entry with `filter` triples (`{ field: 'owner_id', operator: 'equals', value: '{current_user_id}' }`), a kanban entry with the required top-level `columns` plus `kanban: { groupByField: 'status' }` (no top-level `groupBy`). No form in the container and no `form` item: the edit form is built from the object, so the answer says its section is a `fieldGroups` entry of `support_case` (a `form` item is a public form or one an action opens; New and Edit load none).", "files": [], "assertions": { "must_contain": ["defineView", "provider: 'object'", "listViews", "groupByField", "link: true", "{current_user_id}", "owner_id"], - "must_not_contain": ["groupBy:", "conditionalRequired:", "'assigned_to'", "form: {"] + "must_not_contain": ["groupBy:", "conditionalRequired:", "'assigned_to'", "form: {", "defineForm("] } }, { @@ -54,7 +54,7 @@ { "id": 6, "prompt": "Invoice entry as a stepped form — header, then line items, then review — saving the invoice and its lines together.", - "expected_output": "No form view and no screen flow (nothing branches): the invoice's New form is built from the object, so header, then lines, then the rest is the order of `invoice`'s `fieldGroups`. Line items come from the DATA MODEL: a field group naming the `master_detail` child (`fieldGroups: [{ key: 'header', ... }, { key: 'lines', label: 'Lines', relatedList: 'invoice_line' }, ...]`), which draws the editable grid in the form and saves parent + children in one atomic `/api/v1/batch`; without the group the form has no lines, whatever `inlineEdit` says. The hand-over says the steps are sections of one form, not a wizard: a `formViews` wizard is not loaded by New or Edit, and a named form an action opens draws no line items. No custom page, and no 'Add line' button (the ghost row exists).", + "expected_output": "No form view and no screen flow (nothing branches): the invoice's New form is built from the object, so header, then lines, then the rest is the order of `invoice`'s `fieldGroups`. Line items come from the DATA MODEL: a field group naming the `master_detail` child (`fieldGroups: [{ key: 'header', ... }, { key: 'lines', label: 'Lines', relatedList: 'invoice_line' }, ...]`), which draws the editable grid in the form and saves parent + children in one atomic `/api/v1/batch`; without the group the form has no lines, whatever `inlineEdit` says. The hand-over says the steps are sections of one form, not a wizard: a wizard `form` item is not loaded by New or Edit, and a form an action opens draws no line items. No custom page, and no 'Add line' button (the ghost row exists).", "files": [], "assertions": { "must_contain": ["fieldGroups", "relatedList", "master_detail"], @@ -184,7 +184,7 @@ { "id": 19, "prompt": "Shape the New and Edit form of `opportunity`: 42 fields in six sections (Basics, Amounts, Dates, Partner, Shipping, Internal Notes). Reps fill Basics and Amounts on every create and the other four rarely, and `loss_reason` is never known at create. The form opens in the New dialog, mostly on wide screens.", - "expected_output": "No form view: New and Edit are built from the object. Six `fieldGroups` entries on `opportunity` in that order, with `collapse: 'collapsed'` on the four rarely filled ones, and `showOnCreate: false` on `loss_reason`, which edit, the record page and lists still show (it must not be `required: true`: the pair is refused). Not a `form`, `formViews.default` or `formViews.create` (each parses and is not loaded), and no `modalSize` or `columns`: the dialog's size and column count are derived.", + "expected_output": "No form view: New and Edit are built from the object. Six `fieldGroups` entries on `opportunity` in that order, with `collapse: 'collapsed'` on the four rarely filled ones, and `showOnCreate: false` on `loss_reason`, which edit, the record page and lists still show (it must not be `required: true`: the pair is refused). Not a `form` item (it parses, and New and Edit load none), and no `modalSize` or `columns`: the dialog's size and column count are derived.", "files": [], "assertions": { "must_contain": ["fieldGroups", "collapse: 'collapsed'", "showOnCreate: false"], @@ -244,11 +244,12 @@ { "id": 25, "prompt": "`crm_account` declares the field groups `basic_info` and `contact_info`. A 'New Intake' button opens an intake form on its own page; the team wants each group two columns wide there, and asks for the same two columns in the ordinary New dialog. Write the metadata and say what each surface does.", - "expected_output": "A named form under `formViews` whose sections reference the groups and declare the count, `sections: [{ group: 'basic_info', columns: 2 }, { group: 'contact_info', columns: 2 }]`, opened by a `type: 'form'` action whose `target` names it. The answer says the form page reads each section's `columns` (1 to 4, one column on a phone), and that the New and Edit dialog is built from the object's `fieldGroups`, never from this form view, at a column count the platform derives and nobody authors. Not `columns` on the form view itself (the form page does not read it), not a `columns` key on a `fieldGroups` entry, not `modalSize`, and not an answer that two columns cannot be authored anywhere.", + "expected_output": "A `form` item in the stack's `forms:`, `defineForm({ name: 'crm_account.intake', object: 'crm_account', sections: [{ group: 'basic_info', columns: 2 }, { group: 'contact_info', columns: 2 }] })`: the name is `OBJECT.KEY` with the form's `object` as its prefix, and the body is at the top level (no `viewKind`, no `config`, and no `data`, which is refused: a form is bound with `object`). A `type: 'form'` action whose `target` is `crm_account.intake` opens it. The answer says the form page reads each section's `columns` (1 to 4, one column on a phone), and that the New and Edit dialog is built from the object's `fieldGroups`, never from a `form` item, at a column count the platform derives and nobody authors. Not a form authored inside a `defineView` container, not `columns` on the form itself (the form page does not read it), not a `columns` key on a `fieldGroups` entry, not `modalSize`, and not an answer that two columns cannot be authored anywhere.", "files": [], "assertions": { - "must_contain": ["formViews", "group: 'contact_info', columns: 2", "type: 'form'", "fieldGroups"], - "must_not_contain": ["modalSize:", "formViews.default"] + "must_contain": ["object: 'crm_account'", "'crm_account.", "group: 'contact_info', columns: 2", "type: 'form'", "fieldGroups"], + "must_contain_any": [["defineForm", "forms:"]], + "must_not_contain": ["modalSize:", "defineView(", "provider: 'object'"] } }, { @@ -270,6 +271,17 @@ "must_contain": ["groupByField", "summary", "avg", "estimate_hours", "showFieldLabels: false", "hideEmptyFields: false"], "must_not_contain": ["showFieldLabels: true"] } + }, + { + "id": 28, + "prompt": "Publish a 'Contact us' web form on `crm_lead` that anonymous visitors fill in at `/forms/contact-us`: name, email and message. The retired form `crm_lead.old_contact` is switched off (`sharing.enabled: false`) and still declares `publicLink: 'contact-us'`. Write the metadata and say what `os validate` answers.", + "expected_output": "One `form` item in the stack's `forms:`: `defineForm({ name: 'crm_lead.contact_us', object: 'crm_lead', sections: [{ fields: ['name', 'email', 'message'] }], sharing: { enabled: true, allowAnonymous: true, publicLink: 'contact-us' } })`. The name is `OBJECT.KEY` with the form's `object` as its prefix, and the body is at the top level (no `data`: a form is bound with `object`). Visitors read it at `GET /api/v1/forms/contact-us` and submit to `POST /api/v1/forms/contact-us/submit`. The answer says `os validate` refuses the new form with `form-public-address-taken`, naming both forms: the retired form holds its address while its `publicLink` names it, switched on or off, so its link is cleared first (until then a save of the new form answers `409 FORM_ADDRESS_TAKEN`). Not a form authored inside a `defineView` container, not a second form left on the address, and not a claim that switching the old form off frees the address.", + "files": [], + "assertions": { + "must_contain": ["object: 'crm_lead'", "'crm_lead.", "enabled: true", "allowAnonymous: true", "publicLink"], + "must_contain_any": [["defineForm", "forms:"], ["form-public-address-taken", "FORM_ADDRESS_TAKEN", "holds its address"]], + "must_not_contain": ["defineView(", "provider: 'object'"] + } } ] } diff --git a/skills/objectstack-ui/rules/list-views.md b/skills/objectstack-ui/rules/list-views.md index 4d360aaee1e..3dd26ba5012 100644 --- a/skills/objectstack-ui/rules/list-views.md +++ b/skills/objectstack-ui/rules/list-views.md @@ -5,14 +5,14 @@ - [End-User Quick Filters](#end-user-quick-filters-userfilters-adr-0047) · [Toolbar Search](#toolbar-search-searchablefields-adr-0061) - [Configuring Kanban Views](#configuring-kanban-views) - [Configuring Gantt Views](#configuring-gantt-views) -- [Form Views](#form-views) · [Master-Detail Forms](#master-detail-forms-parent--child-line-items) +- [Forms](#forms) · [Master-Detail Forms](#master-detail-forms-parent--child-line-items) ## Configuring a List View ### The `defineView` container (`*.view.ts` file shape) Views ship **inside a `defineView` container** — one per object, aggregating -the default `list`, named `listViews` and named `formViews`. The loader +the default `list` and named `listViews`. The loader expands it into `.` view items that power the view switcher. @@ -27,9 +27,6 @@ export const CaseViews = defineView({ open: { label: 'Open', type: 'grid', data, columns: ['subject', 'status'], filter: [{ field: 'status', operator: 'equals', value: 'open' }] }, }, - formViews: { // named: a `form` action targets `support_case.triage` - triage: { type: 'simple', data, sections: [{ group: 'case_detail' }] }, - }, }); ``` @@ -203,22 +200,7 @@ ingress gate refuses any entry outside the allowed set before the engine runs. Both diagnostics are **errors**: `os validate` fails the build. -To remove the search box, toggle the affordance instead: - - -```typescript -import { defineView } from '@objectstack/spec'; - -const data = { provider: 'object' as const, object: 'support_case' }; - -export const AuditViews = defineView({ - list: { - label: 'Audit Log', type: 'grid', data, - columns: ['case_number', 'status'], - userActions: { search: false }, - }, -}); -``` +To remove the search box instead: `userActions: { search: false }` on the list. **Searching by a related record's title:** mirror it into a **stored** field and narrow to that (objectstack-data → Search Fields). @@ -346,12 +328,13 @@ group, **no resize handles**. Leaf tasks resize unless `locked: true`. --- -## Form Views +## Forms -**An object's New and Edit forms are not form views.** The dialogs, the +**An object's New and Edit forms are not `form` items.** The dialogs, the full-page form (`editMode: 'page'`) and a create or edit an action opens are built from the object: its fields, sectioned by `fieldGroups` in array order, -following each field's own rules. Authored there: +following each field's own rules (`visibleWhen`, `readonlyWhen`, +`requiredWhen`: objectstack-data → Conditional Field Rules). Authored there: - `collapse: 'collapsed'` on a `fieldGroups` entry folds a rarely filled section. @@ -361,20 +344,39 @@ following each field's own rules. Authored there: - Dialog size and column count are derived, never authored: [Record Presentation](./navigation.md#record-presentation--surface-width--columns-are-auto-derived). -A container's `form`, `formViews.default` and `formViews.create` still parse -and steer no create or edit form; `os validate` warns -`form-view-internal-not-loaded` unless a `type: 'form'` action's literal -`target` names it: it loads as a named form. These load: +**A form is a `form` item in the stack's `forms:`** (`defineForm`, a +`*.form.ts`); `views:` holds lists only. It is a form something opens: a +public form (it declares `sharing.publicLink`), or one an action of +`type: 'form'` opens on its own page, its `target` the form's name. With +neither, `os validate` warns `form-consumer-less`. -**A named form** is a `formViews` entry under any other key, registered as -`OBJECT.key`; an action of `type: 'form'` whose `target` is that name opens it -on its own page (`/forms/:name`). Its `type` is `simple` (stacked sections, the -default), `tabbed` (a tab per section) or `wizard` (a step per section, each -listing `fields`, never `{ group }`). It draws no child line items. + +```typescript +import { defineForm } from '@objectstack/spec'; + +export const WebToLead = defineForm({ + name: 'crm_lead.web_to_lead', // OBJECT.KEY: the prefix equals `object` + object: 'crm_lead', + sections: [{ group: 'contact_info', columns: 2 }], + // public: GET /api/v1/forms/contact-us, POST …/contact-us/submit + sharing: { enabled: true, allowAnonymous: true, publicLink: 'contact-us' }, +}); +``` -**A public form** is a form view with -`sharing: { enabled: true, allowAnonymous: true, publicLink: 'slug' }`: -Web-to-Lead at `GET/POST /api/v1/forms/:slug`. +- The body is at the top level. `viewKind`, `config` and `data` are refused: + a form is bound with `object`. +- `type`: `simple` (stacked sections, the default), `tabbed` (a tab per + section) or `wizard` (a step per section, each listing `fields`, never + `{ group }`). A form draws no child line items. +- A form left open on a public address another form holds is refused, naming + both (`form-public-address-taken`; a save answers `409 FORM_ADDRESS_TAKEN`). + A form holds its address while `publicLink` names it, switched on or off: + clear the retired form's link. +- Translate under `forms.NAME`: `.label`, `.title`, `.description`, + `.submitBehavior.*`, `.sections.SECTION.*`; a section with no key there + reads `objects.OBJECT._sections.SECTION`. +- ⛔ Never author a form inside a view (a container's `form:` or `formViews`, + a `viewKind: 'form'` item): move one you find to `forms:`. ## Master-Detail Forms (parent + child line items) @@ -386,8 +388,7 @@ custom page. Prefer, in order: MODEL, the parent declares `fieldGroups: [{ key: 'lines', label: 'Lines', relatedList: 'invoice_line' }]`. Its standard New/Edit forms (modal, drawer, full-page) then draw the children there and save parent + children - in one atomic `/api/v1/batch`. Without the group nothing changes: the child - is a tab and the form has no lines. A parent or child + in one atomic `/api/v1/batch`. A parent or child declaring `enable.apiMethods` must list `'bulk'`, or that save is refused `405 OBJECT_API_METHOD_NOT_ALLOWED`. `inlineEdit` only picks how rows are edited, `'grid'` / `'form'` or left out: @@ -405,10 +406,3 @@ authored on this side: a trailing **ghost** row always exists, so never add an untouched one is never persisted; a record-header action that inserts a priced line is [Actions](./actions.md)); `autofill: false` opts one column out of the typeahead copy; and that page block's `taxRateField` overrides which parent field drives the totals. - -## Field Conditional Rules in Forms - -Conditions that belong to a field's lifecycle — `visibleWhen`, `readonlyWhen`, -`requiredWhen` — are declared on the **DATA MODEL field**, not in the form view; -ObjectUI forms consume them. Their semantics and server behaviour: -[objectstack-data → Conditional Field Rules](../../objectstack-data/SKILL.md#conditional-field-rules). diff --git a/skills/objectstack-ui/rules/navigation.md b/skills/objectstack-ui/rules/navigation.md index c5cfc836749..a429ad5f76c 100644 --- a/skills/objectstack-ui/rules/navigation.md +++ b/skills/objectstack-ui/rules/navigation.md @@ -161,7 +161,7 @@ export const TaskWorkbenchPage = definePage({ ## Record Presentation — surface, width & columns are auto-derived -An object's New / Edit / detail is built from its `fieldGroups`, never a form view: +An object's New / Edit / detail is built from its `fieldGroups`, never a `form` item: you do **not** author its surface, overlay width or column count, all derived from the client's screen. **Write the data (fields, `fieldGroups`); let the platform lay it out.** @@ -178,10 +178,10 @@ it out.** - **Column count.** On those forms, not authored: the grid follows its **real rendered width**, 1 column in a narrow drawer to 4 on a wide page. On a named or public form, authored per section: `{ group: 'contact_info', columns: 2 }` - (1–4; 1 on a phone). A form view's own `columns` is not read by the form page + (1–4; 1 on a phone). A form's own `columns` is not read by the form page today. - **`sections` are the escape hatch — reach for them last.** New and Edit - never read them ([Form Views](./list-views.md#form-views)); a named or + never read them ([Forms](./list-views.md#forms)); a named or public form and a page's `record:details` or form block do. The ladder: (1) **derive** — declare `fieldGroups`, author no `sections`; (2) **reference** — a section names a declared group, `{ group: 'contact_info' }`, From b3d7dc22cfee6a24545f36af0459aee27f8132c6 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 30 Nov 2026 15:30:35 +0000 Subject: [PATCH 2/4] chore(scripts): the navigation ceiling note names the renamed heading in words check:scripts-symbol-anchors read the path-and-fragment spelling in the note as a file anchor with no tracked file behind it. Claude-Session: https://claude.ai/code/session_01ADHkmPDtfMCw4FJfyFfQ7v Co-authored-by: Claude --- scripts/check-skills-token-ratchet.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/check-skills-token-ratchet.mjs b/scripts/check-skills-token-ratchet.mjs index d16337d7ec4..5a67991673c 100644 --- a/scripts/check-skills-token-ratchet.mjs +++ b/scripts/check-skills-token-ratchet.mjs @@ -2149,8 +2149,8 @@ export const CEILINGS = new Map([ // row above. // ceil($(wc -c < skills/objectstack-ui/rules/navigation.md) / 4) == ceil(10255 / 4) // 2559 -> 2556 (#37105): Record Presentation says `form` item where it said form view, - // and links `list-views.md#forms`, the heading that card renames. 10235 -> 10222 bytes - // -> 2556 tokens; the row follows the measurement down. + // and its link follows the list-views heading that card renames to Forms. 10235 -> 10222 + // bytes -> 2556 tokens; the row follows the measurement down. // ceil($(wc -c < skills/objectstack-ui/rules/navigation.md) / 4) == ceil(10222 / 4) ['skills/objectstack-ui/rules/navigation.md', 2556], // -3 to the measurement (was 2559) // 5501 -> 5692 (#19715, card item 4): a 5-line table of contents at the top, From 5a3a19bd1639d2a490a2aab93d3deac99ec9f820 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 30 Nov 2026 17:05:34 +0000 Subject: [PATCH 3/4] docs(skills): the form-in-a-view bullet moves only a form something opens, and deletes the rest A form in a record-form slot that no action opens and that declares no publicLink is deleted, not moved: New and Edit never loaded it, and its layout is the object's fieldGroups (ADR-0159, internal record forms are not moved). The bullet said to move every form found in a view. The clause is paid for in the same section; rules/list-views.md stays at its ceiling (18036 to 18035 bytes, 4509 tokens). Claude-Session: https://claude.ai/code/session_01ADHkmPDtfMCw4FJfyFfQ7v Co-authored-by: Claude --- .changeset/37105-skills-teach-forms.md | 2 +- skills/objectstack-ui/rules/list-views.md | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.changeset/37105-skills-teach-forms.md b/.changeset/37105-skills-teach-forms.md index 568350cc596..390ee2e4da4 100644 --- a/.changeset/37105-skills-teach-forms.md +++ b/.changeset/37105-skills-teach-forms.md @@ -15,7 +15,7 @@ ADR-0159 makes a form a metadata type of its own. The published skill now teache - A form left open on a public address another form holds is refused, naming both forms (`form-public-address-taken` from `os validate`, `409 FORM_ADDRESS_TAKEN` from a save). A form holds its address while its `publicLink` names it, switched on or off. - Translations sit under `forms.NAME` (`.label`, `.title`, `.description`, `.submitBehavior.*`, `.sections.SECTION.*`); a section with no key there reads `objects.OBJECT._sections.SECTION`. -No example authors a form inside a view any more: the `defineView` container example lists `list` and `listViews` only, and one sentence says a form found inside a view (a container's `form:` or `formViews`, a `viewKind: 'form'` item) moves to `forms:`. +No example authors a form inside a view any more: the `defineView` container example lists `list` and `listViews` only, and one sentence says never to author a form inside a view (a container's `form:` or `formViews`, a `viewKind: 'form'` item): one an action opens or that declares a `publicLink` moves to `forms:`, and any other is deleted, since New and Edit never loaded it. `skills/objectstack-ui/SKILL.md`: Trap 1, the routing table's form row (`*.form.ts`) and the Action Types `form` row name the `form` item. `rules/navigation.md` says `form` item and links the renamed heading. diff --git a/skills/objectstack-ui/rules/list-views.md b/skills/objectstack-ui/rules/list-views.md index 3dd26ba5012..592519f99ef 100644 --- a/skills/objectstack-ui/rules/list-views.md +++ b/skills/objectstack-ui/rules/list-views.md @@ -332,22 +332,21 @@ group, **no resize handles**. Leaf tasks resize unless `locked: true`. **An object's New and Edit forms are not `form` items.** The dialogs, the full-page form (`editMode: 'page'`) and a create or edit an action opens are -built from the object: its fields, sectioned by `fieldGroups` in array order, -following each field's own rules (`visibleWhen`, `readonlyWhen`, +built from its fields, sectioned by `fieldGroups` in array order, +following each field's rules (`visibleWhen`, `readonlyWhen`, `requiredWhen`: objectstack-data → Conditional Field Rules). Authored there: -- `collapse: 'collapsed'` on a `fieldGroups` entry folds a rarely filled - section. -- `showOnCreate: false` on a field leaves it off every create surface; edit, +- `collapse: 'collapsed'` on a `fieldGroups` entry folds its section. +- `showOnCreate: false` leaves a field off every create surface; edit, the record page and lists keep it. Beside `required: true` it is refused, whatever its `defaultValue`: keep it on create, or make it `requiredWhen`. -- Dialog size and column count are derived, never authored: +- Dialog size and columns are derived, never authored: [Record Presentation](./navigation.md#record-presentation--surface-width--columns-are-auto-derived). **A form is a `form` item in the stack's `forms:`** (`defineForm`, a -`*.form.ts`); `views:` holds lists only. It is a form something opens: a +`*.form.ts`); `views:` holds lists only. Something opens it: a public form (it declares `sharing.publicLink`), or one an action of -`type: 'form'` opens on its own page, its `target` the form's name. With +`type: 'form'` opens, its `target` the form's name. With neither, `os validate` warns `form-consumer-less`. @@ -365,9 +364,9 @@ export const WebToLead = defineForm({ - The body is at the top level. `viewKind`, `config` and `data` are refused: a form is bound with `object`. -- `type`: `simple` (stacked sections, the default), `tabbed` (a tab per +- `type`: `simple` (stacked, the default), `tabbed` (a tab per section) or `wizard` (a step per section, each listing `fields`, never - `{ group }`). A form draws no child line items. + `{ group }`). A form draws no child lines. - A form left open on a public address another form holds is refused, naming both (`form-public-address-taken`; a save answers `409 FORM_ADDRESS_TAKEN`). A form holds its address while `publicLink` names it, switched on or off: @@ -376,7 +375,8 @@ export const WebToLead = defineForm({ `.submitBehavior.*`, `.sections.SECTION.*`; a section with no key there reads `objects.OBJECT._sections.SECTION`. - ⛔ Never author a form inside a view (a container's `form:` or `formViews`, - a `viewKind: 'form'` item): move one you find to `forms:`. + a `viewKind: 'form'` item). Move one an action opens or with a `publicLink` + to `forms:`; delete any other: New and Edit never loaded it. ## Master-Detail Forms (parent + child line items) From 8cd68a8e37a77d681d55a8cc7b677e925d72651b Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 30 Nov 2026 18:13:35 +0000 Subject: [PATCH 4/4] docs(skills): a form that declares overrides moves too; only the rest is deleted The form-in-a-view bullet told the reader to delete every form that no action opens and that declares no publicLink. ADR-0159 D7-b: a form held under an overrides declaration moves to forms whatever its body and slot, and nothing prescribes deleting it, because an override with no link over a base form that declares one is what keeps the base's address closed. The bullet now moves it with the other two and deletes only the rest. Same section: "the object's fields" and "a rarely filled section" are back. The clause and the two restorations are paid for there, with no rule removed; rules/list-views.md stays at 18035 bytes, 4509 tokens, and its row is not moved. The row's comment now carries the final byte count. Claude-Session: https://claude.ai/code/session_01ADHkmPDtfMCw4FJfyFfQ7v Co-authored-by: Claude --- .changeset/37105-skills-teach-forms.md | 2 +- scripts/check-skills-token-ratchet.mjs | 4 ++-- skills/objectstack-ui/rules/list-views.md | 19 +++++++++---------- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/.changeset/37105-skills-teach-forms.md b/.changeset/37105-skills-teach-forms.md index 390ee2e4da4..c1d040baf56 100644 --- a/.changeset/37105-skills-teach-forms.md +++ b/.changeset/37105-skills-teach-forms.md @@ -15,7 +15,7 @@ ADR-0159 makes a form a metadata type of its own. The published skill now teache - A form left open on a public address another form holds is refused, naming both forms (`form-public-address-taken` from `os validate`, `409 FORM_ADDRESS_TAKEN` from a save). A form holds its address while its `publicLink` names it, switched on or off. - Translations sit under `forms.NAME` (`.label`, `.title`, `.description`, `.submitBehavior.*`, `.sections.SECTION.*`); a section with no key there reads `objects.OBJECT._sections.SECTION`. -No example authors a form inside a view any more: the `defineView` container example lists `list` and `listViews` only, and one sentence says never to author a form inside a view (a container's `form:` or `formViews`, a `viewKind: 'form'` item): one an action opens or that declares a `publicLink` moves to `forms:`, and any other is deleted, since New and Edit never loaded it. +No example authors a form inside a view any more: the `defineView` container example lists `list` and `listViews` only, and one sentence says never to author a form inside a view (a container's `form:` or `formViews`, a `viewKind: 'form'` item): one an action opens, or that declares a `publicLink` or `overrides`, moves to `forms:`, and only the rest is deleted, since New and Edit never loaded it. `skills/objectstack-ui/SKILL.md`: Trap 1, the routing table's form row (`*.form.ts`) and the Action Types `form` row name the `form` item. `rules/navigation.md` says `form` item and links the renamed heading. diff --git a/scripts/check-skills-token-ratchet.mjs b/scripts/check-skills-token-ratchet.mjs index 5a67991673c..ebf29198239 100644 --- a/scripts/check-skills-token-ratchet.mjs +++ b/scripts/check-skills-token-ratchet.mjs @@ -2125,9 +2125,9 @@ export const CEILINGS = new Map([ // this file: `## Field Conditional Rules in Forms` folds into one clause of the Forms // paragraph, the third copy of the container scaffold (the `userActions: { search: false }` // example) becomes its one key inline, and Master-Detail item 1 drops the sentence - // SKILL.md Trap 2 states word for word. 18039 -> 18036 bytes -> 4509 tokens; net shrink, + // SKILL.md Trap 2 states word for word. 18039 -> 18035 bytes -> 4509 tokens; net shrink, // so the row follows the measurement down. - // ceil($(wc -c < skills/objectstack-ui/rules/list-views.md) / 4) == ceil(18036 / 4) + // ceil($(wc -c < skills/objectstack-ui/rules/list-views.md) / 4) == ceil(18035 / 4) ['skills/objectstack-ui/rules/list-views.md', 4509], // -1 to the measurement (was 4510) // 2273 -> 2196 (#27059): LOWERED. The Surface bullet points at `rules/record-page.md`, // says create / edit is a modal or the `editMode: 'page'` route, and the Overlay-width diff --git a/skills/objectstack-ui/rules/list-views.md b/skills/objectstack-ui/rules/list-views.md index 592519f99ef..2e11a57663d 100644 --- a/skills/objectstack-ui/rules/list-views.md +++ b/skills/objectstack-ui/rules/list-views.md @@ -331,23 +331,22 @@ group, **no resize handles**. Leaf tasks resize unless `locked: true`. ## Forms **An object's New and Edit forms are not `form` items.** The dialogs, the -full-page form (`editMode: 'page'`) and a create or edit an action opens are -built from its fields, sectioned by `fieldGroups` in array order, +full-page form (`editMode: 'page'`) and an action's create or edit are +built from the object's fields, sectioned by `fieldGroups` in array order, following each field's rules (`visibleWhen`, `readonlyWhen`, `requiredWhen`: objectstack-data → Conditional Field Rules). Authored there: -- `collapse: 'collapsed'` on a `fieldGroups` entry folds its section. +- `collapse: 'collapsed'` on a `fieldGroups` entry folds a rarely filled section. - `showOnCreate: false` leaves a field off every create surface; edit, the record page and lists keep it. Beside `required: true` it is refused, whatever its `defaultValue`: keep it on create, or make it `requiredWhen`. - Dialog size and columns are derived, never authored: [Record Presentation](./navigation.md#record-presentation--surface-width--columns-are-auto-derived). -**A form is a `form` item in the stack's `forms:`** (`defineForm`, a +**A form is a `form` item in the stack's `forms:`** (`defineForm`, `*.form.ts`); `views:` holds lists only. Something opens it: a -public form (it declares `sharing.publicLink`), or one an action of -`type: 'form'` opens, its `target` the form's name. With -neither, `os validate` warns `form-consumer-less`. +`sharing.publicLink` (a public form), or an action of `type: 'form'` whose +`target` is its name. With neither, `os validate` warns `form-consumer-less`. ```typescript @@ -357,7 +356,7 @@ export const WebToLead = defineForm({ name: 'crm_lead.web_to_lead', // OBJECT.KEY: the prefix equals `object` object: 'crm_lead', sections: [{ group: 'contact_info', columns: 2 }], - // public: GET /api/v1/forms/contact-us, POST …/contact-us/submit + // public: GET /api/v1/forms/contact-us, POST …/submit sharing: { enabled: true, allowAnonymous: true, publicLink: 'contact-us' }, }); ``` @@ -375,8 +374,8 @@ export const WebToLead = defineForm({ `.submitBehavior.*`, `.sections.SECTION.*`; a section with no key there reads `objects.OBJECT._sections.SECTION`. - ⛔ Never author a form inside a view (a container's `form:` or `formViews`, - a `viewKind: 'form'` item). Move one an action opens or with a `publicLink` - to `forms:`; delete any other: New and Edit never loaded it. + a `viewKind: 'form'` item). Move one an action opens, or with a `publicLink` + or `overrides`, to `forms:`; delete only the rest: New and Edit never loaded it. ## Master-Detail Forms (parent + child line items)