@tristan2828/ui-foundation 4.136.1 → 4.137.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (163) hide show
  1. package/README.md +7 -6
  2. package/bin/ui-foundation.mjs +1 -1
  3. package/conventions/agents/spec-tester.md +3 -3
  4. package/conventions/docs/add-an-entity.md +722 -714
  5. package/conventions/docs/cell-patterns.md +206 -378
  6. package/conventions/docs/column-options.md +6 -12
  7. package/conventions/docs/design-language.md +293 -515
  8. package/conventions/docs/entity-plan-template.md +9 -7
  9. package/conventions/docs/reminders.md +12 -17
  10. package/conventions/docs/timed-screens.md +17 -20
  11. package/dist/components/app/action-error.js +1 -1
  12. package/dist/components/app/action-hint.js +1 -1
  13. package/dist/components/app/app-shell-bottom-bar.js +4 -4
  14. package/dist/components/app/app-shell-nav.d.ts +1 -1
  15. package/dist/components/app/app-shell-nav.js +1 -1
  16. package/dist/components/app/app-shell.d.ts +1 -1
  17. package/dist/components/app/app-shell.js +9 -9
  18. package/dist/components/app/board.d.ts +13 -13
  19. package/dist/components/app/board.js +3 -3
  20. package/dist/components/app/choice-buttons.d.ts +1 -1
  21. package/dist/components/app/data-table-tools.d.ts +3 -3
  22. package/dist/components/app/data-table.d.ts +11 -13
  23. package/dist/components/app/data-table.js +5 -5
  24. package/dist/components/app/date-field.js +1 -1
  25. package/dist/components/app/delete-action.d.ts +1 -1
  26. package/dist/components/app/delete-action.js +4 -4
  27. package/dist/components/app/edit-caret.js +1 -1
  28. package/dist/components/app/edit-in-place-presets.d.ts +4 -4
  29. package/dist/components/app/edit-in-place-store.d.ts +3 -3
  30. package/dist/components/app/edit-in-place-store.js +7 -7
  31. package/dist/components/app/editable-list.js +2 -3
  32. package/dist/components/app/editable-value.d.ts +2 -2
  33. package/dist/components/app/editable-value.js +20 -20
  34. package/dist/components/app/entity-form.js +2 -2
  35. package/dist/components/app/entity-view-facts.d.ts +12 -12
  36. package/dist/components/app/entity-view-facts.js +1 -1
  37. package/dist/components/app/entity-view.d.ts +16 -16
  38. package/dist/components/app/entity-view.js +28 -33
  39. package/dist/components/app/equal-items.js +4 -4
  40. package/dist/components/app/fact-extras.js +5 -5
  41. package/dist/components/app/field-rows.js +5 -5
  42. package/dist/components/app/fill-in-queue.js +2 -3
  43. package/dist/components/app/filter-bar.d.ts +1 -1
  44. package/dist/components/app/filter-date.js +1 -1
  45. package/dist/components/app/filter-name.js +1 -1
  46. package/dist/components/app/form-dialog.js +2 -2
  47. package/dist/components/app/form-leave-guard.js +2 -2
  48. package/dist/components/app/form-section.js +1 -1
  49. package/dist/components/app/icon-action.d.ts +1 -1
  50. package/dist/components/app/icon-action.js +2 -2
  51. package/dist/components/app/image-field.js +0 -1
  52. package/dist/components/app/keep-pencil-room.js +1 -1
  53. package/dist/components/app/key-stats.d.ts +3 -3
  54. package/dist/components/app/line-chart.d.ts +1 -1
  55. package/dist/components/app/line-chart.js +3 -3
  56. package/dist/components/app/list-editor-rows.js +1 -1
  57. package/dist/components/app/list-editor.js +1 -1
  58. package/dist/components/app/list-header.d.ts +6 -6
  59. package/dist/components/app/list-header.js +8 -8
  60. package/dist/components/app/markdown.js +30 -37
  61. package/dist/components/app/milkdown-editor.js +37 -62
  62. package/dist/components/app/module-card.js +6 -7
  63. package/dist/components/app/month-calendar.d.ts +46 -0
  64. package/dist/components/app/month-calendar.js +160 -0
  65. package/dist/components/app/month-day-field.js +0 -1
  66. package/dist/components/app/multi-choice.d.ts +1 -1
  67. package/dist/components/app/multi-choice.js +3 -3
  68. package/dist/components/app/multi-line-chart.js +1 -1
  69. package/dist/components/app/multi-pick.js +9 -10
  70. package/dist/components/app/multi-reference.js +2 -2
  71. package/dist/components/app/notes-outline.js +0 -1
  72. package/dist/components/app/notify.js +2 -2
  73. package/dist/components/app/offline-notice.js +1 -1
  74. package/dist/components/app/option-icon.js +1 -1
  75. package/dist/components/app/option-select.d.ts +1 -1
  76. package/dist/components/app/overview-page.d.ts +2 -2
  77. package/dist/components/app/overview-page.js +1 -1
  78. package/dist/components/app/page-trail-context.js +1 -1
  79. package/dist/components/app/pill-filter.d.ts +2 -2
  80. package/dist/components/app/prose-look.js +1 -1
  81. package/dist/components/app/rating-input.js +1 -1
  82. package/dist/components/app/rating-score.js +1 -1
  83. package/dist/components/app/record-dialog.js +25 -40
  84. package/dist/components/app/recurrence-field.js +6 -6
  85. package/dist/components/app/reference-combobox.js +1 -2
  86. package/dist/components/app/rich-text-box-anchor.js +0 -1
  87. package/dist/components/app/rich-text-edges.js +2 -2
  88. package/dist/components/app/rich-text-editor.d.ts +2 -3
  89. package/dist/components/app/rich-text-editor.js +19 -32
  90. package/dist/components/app/rich-text-empty-paragraph.d.ts +6 -7
  91. package/dist/components/app/rich-text-empty-paragraph.js +6 -7
  92. package/dist/components/app/rich-text-floating-toolbar.js +0 -1
  93. package/dist/components/app/rich-text-formats.js +2 -2
  94. package/dist/components/app/rich-text-input-rules.js +1 -2
  95. package/dist/components/app/rich-text-keyboard-bar.js +6 -7
  96. package/dist/components/app/rich-text-node-views.js +1 -2
  97. package/dist/components/app/rich-text-shortcuts.js +8 -8
  98. package/dist/components/app/rich-text-slash-menu.js +4 -6
  99. package/dist/components/app/rich-text-slash.d.ts +2 -2
  100. package/dist/components/app/rich-text-slash.js +2 -2
  101. package/dist/components/app/rich-text-table-grips.d.ts +1 -1
  102. package/dist/components/app/rich-text-table-grips.js +1 -2
  103. package/dist/components/app/rich-text-tasks.d.ts +1 -1
  104. package/dist/components/app/rich-text-tasks.js +1 -1
  105. package/dist/components/app/rich-text-touch.js +1 -1
  106. package/dist/components/app/search-palette.js +1 -2
  107. package/dist/components/app/secondary-filters.js +2 -3
  108. package/dist/components/app/session-view.js +1 -1
  109. package/dist/components/app/stacked-area-chart.js +1 -1
  110. package/dist/components/app/step-track.d.ts +1 -1
  111. package/dist/components/app/step-track.js +3 -3
  112. package/dist/components/app/widget-card.js +26 -30
  113. package/dist/components/app/widget-layout-sheet.js +1 -1
  114. package/dist/components/ui/calendar.js +2 -2
  115. package/dist/components/ui/combobox.d.ts +1 -1
  116. package/dist/components/ui/combobox.js +2 -2
  117. package/dist/components/ui/field.d.ts +1 -1
  118. package/dist/components/ui/field.js +6 -6
  119. package/dist/components/ui/skeleton.js +1 -1
  120. package/dist/components/ui/sonner.js +1 -1
  121. package/dist/components/ui/tabs.js +1 -1
  122. package/dist/error-reporting/reporter.d.ts +1 -1
  123. package/dist/error-reporting/reporter.js +1 -1
  124. package/dist/hooks/table-url-changes.d.ts +2 -2
  125. package/dist/hooks/table-url-changes.js +5 -6
  126. package/dist/hooks/use-action.js +1 -1
  127. package/dist/hooks/use-record-update.js +1 -1
  128. package/dist/hooks/use-table-url-state.d.ts +1 -1
  129. package/dist/hooks/use-table-url-state.js +2 -2
  130. package/dist/index.d.ts +1 -0
  131. package/dist/index.js +3 -2
  132. package/dist/lib/audio-cues.js +2 -2
  133. package/dist/lib/connection.js +1 -1
  134. package/dist/lib/date-filter.js +1 -1
  135. package/dist/lib/entity-view-tab.js +1 -1
  136. package/dist/lib/field-rows.js +2 -2
  137. package/dist/lib/form-errors.d.ts +1 -1
  138. package/dist/lib/form-errors.js +1 -1
  139. package/dist/lib/keep-audio-alive.js +1 -1
  140. package/dist/lib/line-chart-layout.js +3 -3
  141. package/dist/lib/markdown-inline.js +0 -2
  142. package/dist/lib/markdown-merge.js +2 -2
  143. package/dist/lib/markdown-table-widths.js +1 -1
  144. package/dist/lib/markdown-table.js +1 -2
  145. package/dist/lib/markdown-toggle.js +1 -1
  146. package/dist/lib/page-leaving.js +1 -1
  147. package/dist/lib/recurrence-format.d.ts +2 -2
  148. package/dist/lib/recurrence-format.js +1 -1
  149. package/dist/lib/recurrence-phrase.d.ts +1 -1
  150. package/dist/lib/recurrence-phrase.js +2 -2
  151. package/dist/lib/recurrence.d.ts +1 -1
  152. package/dist/lib/recurrence.js +2 -2
  153. package/dist/lib/stale-chunk-reload.js +1 -1
  154. package/dist/lib/status-kinds.d.ts +1 -1
  155. package/dist/lib/status-kinds.js +2 -2
  156. package/dist/mocks/start-worker.js +2 -2
  157. package/dist/routes/login.js +1 -1
  158. package/dist/testing/index.d.ts +7 -4
  159. package/dist/testing/index.js +10 -13
  160. package/package.json +1 -1
  161. package/styles/index.css +3 -3
  162. package/styles/theme.css +14 -20
  163. package/vite/pwa.js +1 -1
@@ -3,41 +3,60 @@
3
3
  <!-- index: written by `npm run docs:index` in the package from the headings below; never edit it by hand -->
4
4
  ## Index
5
5
 
6
- - [The reference files](#the-reference-files) · lines 46–68
7
- - [Before anything: the entity plan](#before-anything-the-entity-plan) · lines 70–881
8
- - Step 1: Add `<Entity>` to `openapi.yaml` · lines 112–119
9
- - Step 2: `npm run gen:api` · lines 120–121
10
- - Step 3: Add gateway tests in `tests/gateway/<entity>.test.ts`, derived from the spec · lines 122–133
11
- - Step 4: Add MSW handlers in `src/mocks/<entity>.ts` · lines 134–143
12
- - Step 5: Add a gateway module in `src/api/gateway/<entity>.ts` · lines 144–150
13
- - Step 6: Copy the reference files, one for one, not just the two screens · lines 151–759
14
- - Step 7: Register routes · lines 760–775
15
- - Step 8: Add Playwright specs for all three screens · lines 776–863
16
- - Step 9: Register the nav entry and route names · lines 864–878
17
- - Step 10: `npm run verify`. · lines 879–881
18
- - [How a list opens a record](#how-a-list-opens-a-record) · lines 883–1408
19
- - [The record view](#the-record-view) · lines 1036–1217
20
- - [Forms](#forms) · lines 1219–1307
21
- - [Dialogs](#dialogs) · lines 1309–1342
22
- - [Toasts and feedback](#toasts-and-feedback) · lines 1344–1408
23
- - [What not to copy](#what-not-to-copy) · lines 1410–1445
24
- - [After a commit, in the backend](#after-a-commit-in-the-backend) · lines 1447–1464
25
- - [Saves that don't overwrite](#saves-that-dont-overwrite) · lines 1466–1531
26
- - [Deleting](#deleting) · lines 1533–1564
27
- - [Fields only a script writes](#fields-only-a-script-writes) · lines 1566–1587
28
- - [Searching one part of the app](#searching-one-part-of-the-app) · lines 1589–1598
29
- - [What a chat is told about an entity](#what-a-chat-is-told-about-an-entity) · lines 1601–1643
30
- - [Behind a sign-in proxy](#behind-a-sign-in-proxy) · lines 1645–1681
6
+ - [The reference files](#the-reference-files) · lines 65–87
7
+ - [Before anything: the entity plan](#before-anything-the-entity-plan) · lines 89–129
8
+ - [The steps](#the-steps) · lines 131–351
9
+ - Step 1: Add `<Entity>` to `openapi.yaml` · lines 133–139
10
+ - Step 2: `npm run gen:api` · lines 140–141
11
+ - Step 3: Add gateway tests in `tests/gateway/<entity>.test.ts`, derived from the spec · lines 142–150
12
+ - Step 4: Add MSW handlers in `src/mocks/<entity>.ts` · lines 151–156
13
+ - Step 5: Add a gateway module in `src/api/gateway/<entity>.ts` · lines 157–163
14
+ - Step 6: Copy the reference files, one for one, not just the two screens · lines 164–238
15
+ - Step 7: Register routes · lines 239–254
16
+ - Step 8: Add Playwright specs for all three screens · lines 255–335
17
+ - Step 9: Register the nav entry and route names · lines 336–349
18
+ - Step 10: `npm run verify`. · lines 350–351
19
+ - [Step 6 in detail](#step-6-in-detail) · lines 353–929
20
+ - [A `reference`](#a-reference) · lines 358–360
21
+ - [A `single choice`](#a-single-choice) · lines 362–368
22
+ - [A `date-time`](#a-date-time) · lines 370–373
23
+ - [A `yes/no`](#a-yesno) · lines 375–382
24
+ - [A `multi choice`](#a-multi-choice) · lines 384–391
25
+ - [A `multi reference`](#a-multi-reference) · lines 393–405
26
+ - [Sub-records](#sub-records) · lines 407–423
27
+ - [A `computed` field](#a-computed-field) · lines 425–434
28
+ - [A `date`](#a-date) · lines 436–453
29
+ - [A `month-day`](#a-month-day) · lines 455–475
30
+ - [A `recurrence`](#a-recurrence) · lines 477–498
31
+ - [An image on a record](#an-image-on-a-record) · lines 500–528
32
+ - [A `reference` inside a sub-record item](#a-reference-inside-a-sub-record-item) · lines 530–589
33
+ - [A `yes/no` marked `toggle`](#a-yesno-marked-toggle) · lines 591–606
34
+ - [Keep column definitions stable](#keep-column-definitions-stable) · lines 608–616
35
+ - [The view](#the-view) · lines 618–736
36
+ - [The view: long text and notes](#the-view-long-text-and-notes) · lines 738–792
37
+ - [The view: quick actions and editing in place](#the-view-quick-actions-and-editing-in-place) · lines 794–852
38
+ - [The table opens the view, and the form returns to it](#the-table-opens-the-view-and-the-form-returns-to-it) · lines 854–865
39
+ - [`<SelectValue>` shows the value, not the label](#selectvalue-shows-the-value-not-the-label) · lines 867–913
40
+ - [Choosing how each column looks](#choosing-how-each-column-looks) · lines 915–929
41
+ - [How a list opens a record](#how-a-list-opens-a-record) · lines 931–1435
42
+ - [The record view](#the-record-view) · lines 1074–1254
43
+ - [Forms](#forms) · lines 1256–1339
44
+ - [Dialogs](#dialogs) · lines 1341–1374
45
+ - [Toasts and feedback](#toasts-and-feedback) · lines 1376–1435
46
+ - [What not to copy](#what-not-to-copy) · lines 1437–1464
47
+ - [After a commit, in the backend](#after-a-commit-in-the-backend) · lines 1466–1483
48
+ - [Saves that don't overwrite](#saves-that-dont-overwrite) · lines 1485–1545
49
+ - [Deleting](#deleting) · lines 1547–1577
50
+ - [Fields only a script writes](#fields-only-a-script-writes) · lines 1579–1598
51
+ - [Searching one part of the app](#searching-one-part-of-the-app) · lines 1600–1609
52
+ - [What a chat is told about an entity](#what-a-chat-is-told-about-an-entity) · lines 1612–1654
53
+ - [Behind a sign-in proxy](#behind-a-sign-in-proxy) · lines 1656–1689
31
54
 
32
55
  <!-- /index -->
33
56
 
34
57
  The most-repeated task in this system: add a full CRUD entity — spec, mocks,
35
58
  gateway, tests, table, view, form, routes — following the patterns in
36
- `src/routes/widgets/`. This file is the only copy of the steps, written for
37
- **any AI coding tool or a person**: follow it directly ("add a Game entity
38
- following docs/foundation/add-an-entity.md"). In Claude Code,
39
- `/new-entity <Name>` is a shortcut that runs this same file. It is synced
40
- from `@tristan2828/ui-foundation` — don't edit it here.
59
+ `src/routes/widgets/`. This file is the only copy of the steps.
41
60
 
42
61
  Do not skip steps or reorder them. Replace `<Entity>` with the PascalCase
43
62
  entity name (e.g. `Invoice`) and `<entity>` with its kebab-case form
@@ -109,36 +128,30 @@ is a filled-in example while the Widgets demo is still here).
109
128
  leave prompt, create (Enter, a blank name, a taken one), delete, and
110
129
  the in-place a11y states for a cell open and refused, in both themes.
111
130
 
131
+ ## The steps
132
+
112
133
  1. **Add `<Entity>` to `openapi.yaml`** — schema, list, get, create, update,
113
134
  delete — exactly as the plan specifies: its fields, types, required
114
135
  fields, option lists (as enums) and length/format rules, and a list
115
136
  query parameter for each field the plan marks as a filter. Reuse the
116
137
  `Page` and error components already in the spec; do not redefine
117
138
  pagination or error shapes per entity, and leave the foundation's part
118
- of the spec (`/auth/*`, `/environment`, the error bodies) alone — `ui-foundation
119
- check-contract` fails verify if it changes.
139
+ of the spec alone (AGENTS.md "Hard Rules").
120
140
  2. **`npm run gen:api`** to regenerate `src/api/schema.d.ts`. Never
121
141
  hand-edit it.
122
142
  3. **Add gateway tests in `tests/gateway/<entity>.test.ts`, derived from
123
143
  the spec** — `openapi.yaml` and the UI contracts (`Page<T>`, `AppError`,
124
- `QuerySpec`) only, never the code in `src/api/gateway/`, so the tests assert
125
- what the spec promises, not what an implementation happens to do. Write
144
+ `QuerySpec`) only, never the code in `src/api/gateway/`. Write
126
145
  them to fail first; the gateway that makes them pass doesn't exist yet.
127
- - **If your tool can run an isolated subagent, use one** that can't see
128
- those two folders. In Claude Code that's `spec-tester`
129
- (`.claude/agents/spec-tester.md`), whose hook *blocks* reading it —
130
- the enforced version of this rule.
146
+ - **If your tool can run an isolated subagent, use one** that can't read
147
+ `src/api/gateway/`. In Claude Code that's `spec-tester`
148
+ (`.claude/agents/spec-tester.md`), whose hook *blocks* reading it.
131
149
  - **Otherwise** write the tests yourself, now, before step 5 creates the
132
- gateway, and don't open that folder while writing them. It's the
133
- same rule, kept by discipline instead of a hook.
150
+ gateway, and don't open that folder while writing them.
134
151
  4. **Add MSW handlers in `src/mocks/<entity>.ts`** and register them in
135
152
  `src/mocks/handlers.ts`. **Include one deliberately sparse row** whose
136
153
  every optional field is empty at once (see `Blank Slate` in
137
- `src/mocks/data.ts`). Rows that all populate every field are the reason
138
- an "empty value" path goes untested: nothing ever loads a record with a
139
- field unset, so an em dash that never renders, or a form control showing
140
- a raw sentinel instead of a "not set" label, passes `verify` unnoticed.
141
- One row costs nothing and step 8 asserts it. Extend `tests/mocks/conformance.test.ts` so the
154
+ `src/mocks/data.ts`); step 8 asserts it. Extend `tests/mocks/conformance.test.ts` so the
142
155
  new handlers are validated against `openapi.yaml`, the same way
143
156
  `widgets`/`widget-categories` already are.
144
157
  5. **Add a gateway module in `src/api/gateway/<entity>.ts`** until step 3's
@@ -151,235 +164,10 @@ is a filled-in example while the Widgets demo is still here).
151
164
  6. **Copy the reference files, one for one, not just the two screens**
152
165
  (the Widgets demo's, or the ones the app's `### Reference files` names) — shaped by the plan: table columns and sortable columns from
153
166
  its "List" column, toolbar filters from its "Filter" column, form fields
154
- and labels from its field table, and field types by pattern (a
155
- `reference` field copies Category's searchable combobox, a
156
- `single choice` copies Status's select — each option shows its label,
157
- never its wire value, from one `Record<value, label>`
158
- (`WIDGET_STATUS_LABELS`) read by the options, the trigger (through
159
- `<SelectValue>`'s children, which otherwise shows the raw value), the
160
- toolbar filter and every badge — a `date-time` copies
161
- Available From's date picker, a `date` (a day, no time) is the
162
- foundation's `DateField` (see below), a `yes/no` copies In Stock — a `Switch`
163
- (`@tristan2828/ui-foundation/ui/switch`) in a horizontal `Field` with
164
- its label beside it on the form, cell pattern 12 (the word Yes/No) in
165
- the table, and a three-way toolbar `Select` (either / yes / no) whose URL
166
- value is `'true'`/`'false'` and whose `filters` value is a real boolean,
167
- so `false` reaches the wire — and a `multi choice` copies Tags — the
168
- `<MultiChoice>` control from the foundation on the
169
- form and as a toolbar filter via `useTableUrlState`'s multi filters,
170
- badges in the table, and a `filters` array the gateway sends as a
171
- repeated parameter; each option shows its label, never its wire value
172
- (`quick_win` reads "Quick win"): one `Record<value, label>`
173
- (`WIDGET_TAG_LABELS`) feeds `MultiChoice`'s `getLabel` and the badges — and a `multi reference` copies Extra Categories:
174
- the `<MultiReference>` control on the form and as a toolbar filter, an
175
- array of ids on the wire, a repeated any-of list filter, and names from
176
- a **lookup by id** on the referenced entity
177
- (`GET /widget-categories?ids=1&ids=3`, `getWidgetCategoriesByIds`,
178
- `useWidgetCategoriesByIdsQuery`), and `searching` from the search
179
- query's `isPlaceholderData` so Enter waits for the results that match
180
- what was typed. Add that `ids` parameter to the referenced
181
- entity's list endpoint if it lacks one. Never name a picked id from
182
- search results alone: a saved pick the current search doesn't return
183
- would show without a name. The table looks up every id on its page in
184
- one request; the backend rejects an unknown id as a 422 on the field,
185
- never a foreign-key 500 — and each **sub-records** list copies
186
- Checklist: an array of item objects on the wire, read and written
187
- whole and in order (no item ids), a child table with a `position`
188
- column, react-hook-form's `useFieldArray` feeding the foundation's
189
- `<ListEditor>` inside a `FieldSet`/`FieldLegend` on the form, each row's
190
- controls named by position ("Item 2 text"), a per-item `FieldError`
191
- (a server 422 at `["body", "checklist", 2, "text"]` arrives as
192
- `fieldErrors["checklist.2.text"]` and binds to that row). A list whose
193
- items are rich (five or six fields each) and run to ten or more also
194
- passes `summary={(i) => …}`, one line per item that opens to its
195
- fields, one at a time, and `invalid={(i) => !!errors.<list>?.[i]}` so
196
- an item the save refuses opens to show why. A list whose items repeat
197
- with small changes passes
198
- ``onDuplicate={(i) => insert(i + 1, { ...getValues(`<list>.${i}`) })}``,
199
- leaving out any saved id; the copy lands after its original and opens.
200
- Then a summary
201
- in the table, never the items (an item with a `reference` field
202
- copies Pairings, below) — and a `computed` field copies
203
- Progress (`checklistState`): `readOnly` in `openapi.yaml` and absent
204
- from `<Entity>Create`/`<Entity>Update`, one SQL expression in the
205
- router that the filter and sort use (correlated `EXISTS`, or a scalar
206
- subquery for a count, so they hold across pages), a Python mirror on
207
- the model for the value each row reads back with, a test that the two
208
- agree for every value, the mocks recomputing it on every write and
209
- ignoring any client-sent value, a read-only column and a filter, and
210
- nothing on the form):
211
-
212
- **Keep column definitions stable.** Build them once
213
- (`useMemo(() => build<Entity>Columns(), [])`) from nothing that loads
214
- later. TanStack's `flexRender` treats each column's `cell` as a
215
- component, so rebuilt columns remount every cell: focus is lost and the
216
- table flickers when, say, reference names arrive after the rows. Data
217
- that arrives later reaches the cells through context, as
218
- `category-names.tsx` does for category names.
219
-
220
- **A `date`** (a day with no time: when something was finished, a
221
- due day) is `type: string, format: date` in `openapi.yaml`, so the
222
- wire, the generated type and the form all hold `'YYYY-MM-DD'`, and
223
- `''` on the form for an optional one not set (sent as `null`). No
224
- `Date` object anywhere, so no time zone can move the day. On the form
225
- it's the foundation's `DateField` in a `Controller` (`clearable` when
226
- optional); the schema is the string (`z.string().min(1, …)` when
227
- required). The table and the view show `formatPlainDate(value)`
228
- ("Sep 2, 2026"), the not-set label when empty. `DateField` is typed
229
- (4.88): a box that reads "3/14", "Mar 14", "2026-03-14" or "today",
230
- with the calendar on its button, and something unreadable says "Try a
231
- date like 3/14 or Mar 14" and gives `''`. Editing in place is
232
- `inPlace.date({ value, save })`: Enter or leaving saves the day typed,
233
- a day picked in the calendar saves at once. (`typing={false}` is the
234
- button alone; in place then `editInPlace({ kind: 'choice', ... })` with
235
- `defaultOpen`, `modal={false}` and `onChange={(day) => props.commit(day)}`,
236
- the fixtures' `app/DateField` EditInPlace.) The backend column
237
- is a SQL `date` (`datetime.date` in the model).
238
-
239
- **A `month-day`** (a day that comes round every year, with no year:
240
- when a season starts, a yearly deadline) is `type: string` with
241
- `pattern: '^(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$'` in
242
- `openapi.yaml`, so the wire, the generated type and the form all hold
243
- `'MM-DD'` (`'03-14'`), and `''` on the form for an optional one not set
244
- (sent as `null`). It sorts as text in calendar order. On the form it's
245
- the foundation's `MonthDayField` in a `Controller` (`clearable` when
246
- optional); the schema is the string with
247
- `.refine((v) => v === '' || isMonthDay(v), 'Pick a month and day')`
248
- (`isMonthDay`: February 29 is a day, February 30 isn't), `min(1, …)`
249
- too when required. The table and the view show `formatMonthDay(value)`
250
- ("Mar 14"), the not-set label when empty. Editing in place is
251
- `inPlace.monthDay({ value, save })` (cell pattern 18, "Presets"). The
252
- backend column is `varchar(5)` (`str` in the model) and the router
253
- refuses a day the month can't have as a 422 on the field (the pattern
254
- alone lets `02-30` through). Values typed before as free text are
255
- rewritten to `'MM-DD'` by a migration; one it can't read stays as
256
- written, and the field shows it as written with nothing picked, refused
257
- until a day is picked.
258
-
259
- **A `recurrence`** (how something repeats: a chore, a reminder, a
260
- task) is the foundation's `Recurrence` schema: copy it from the
261
- package's `openapi/foundation.yaml` into `components.schemas` (it's
262
- `x-optional`, so `check-contract` holds it to the foundation's shape
263
- once it's there) and reference it, nullable when it may not repeat.
264
- On the form it's the foundation's `RecurrenceField` in a `Controller`
265
- (presets, a phrase read as it's typed, and a preview of the next five);
266
- the schema checks it with `recurrenceProblem(value)`, and a phrase the
267
- field can't read gives `null`, so a required one is refused. The table
268
- shows `formatRecurrence(value)` and a Next column (cell pattern 27);
269
- editing in place is `inPlace.recurrence({ value, save })`. A record
270
- whose times are fields of its own (an event's start and end) gives the
271
- field and the preset `times={false}`: dates only, no "at". An app whose
272
- weeks start on Sunday gives them `weekStart="SU"`, which adds
273
- `WKST=SU` to the weekly rules they build (reminders.md "Repeating
274
- reminders" says when that moves a day). The backend
275
- column is JSON, read and checked with
276
- `foundation_backend.recurrence.Recurrence` (a 422 on the field for a
277
- rule it refuses); `next_after` and `occurrences` say when it falls
278
- (reminders.md "Repeating reminders").
279
-
280
- **An image on a record** (a photo of it) is the stored file's id on the
281
- wire (`string`, nullable), and on the form the foundation's
282
- `ImageField` in a `Controller` (`z.string().nullable()`): `value` and
283
- `onChange` are the id, `thumbUrl` the record's saved photo,
284
- `onBusyChange` holds the submit while a file uploads (the fixtures'
285
- `app/ImageField`). Its `upload` is the app's own, one function in the
286
- gateway that sends the file to the app's endpoint and resolves to
287
- `{ id, thumbUrl, url }` (the `ImageUploadResult`), rejecting with the
288
- `AppError`; the same function goes to a notes field's
289
- `RichTextEditor`, so pictures in its text use the same storage:
290
-
291
- ```ts
292
- // src/api/gateway/files.ts
293
- export async function uploadImage(file: File): Promise<ImageUploadResult> {
294
- const body = new FormData()
295
- body.append('file', file)
296
- const response = await safeFetch('/files', { method: 'POST', body })
297
- if (response.status !== 201) throw toAppError(response.status, response.body, response.headers)
298
- const { id } = response.body as components['schemas']['File']
299
- return { id, thumbUrl: `/api/files/${id}/content?size=thumb`, url: `/api/files/${id}/content` }
300
- }
301
- ```
302
-
303
- The types it takes default to JPEG, PNG and WebP; never add SVG or
304
- HTML, which run script when served from the app's own domain. The
305
- endpoint, the storage and serving the files are the app's (the
306
- template has none); `<Markdown>` shows an image only from a web
307
- address or a path on the site, so `url` is one of those.
308
-
309
- **A `reference` inside a sub-record item** (a list whose items each
310
- point at another entity's record) copies Pairings, Widget's
311
- `pairings`: Checklist's list, with a reference in each item.
312
- - *Wire:* the item carries the referenced id only, named as a
313
- top-level reference is (`{ categoryId, note }`, `seriesId` for a
314
- Series), never a name or a nested record. Every name, on the form
315
- and on the view, comes from the other entity's lookup by id
316
- (`GET /<other>?ids=…`), as for a `multi reference`; add `ids` to
317
- its list endpoint if it lacks one. An optional text field beside it
318
- is a required `string` that is `""` when empty (`note`), so an item
319
- never holds a null. `openapi.yaml` describes the item as its own
320
- schema (`WidgetPairing`), with `maxItems` on the list.
321
- - *Backend:* a child table like the checklist's (`widget_pairings`:
322
- `position`, and a foreign key to the referenced table, commented),
323
- replaced whole on every write. Before saving, the router checks every
324
- item's id in one query (`_check_item_categories_exist`): one that
325
- isn't there, or, for a per-user entity, isn't this user's, is a 422 at
326
- the item's own path, `["body", "pairings", 2, "categoryId"]`, never a
327
- foreign-key 500. Its tests: order kept with repeats, replace and
328
- clear, the note trimmed, an unknown id refused at its item on create
329
- and on update with nothing saved, `null` and too many refused.
330
- - *The mocks* refuse an unknown id at the same path, and trim the note.
331
- - *The form's row* is one component shared with editing in place
332
- (`WidgetPairingItemFields` in `widget-fields.tsx`): the referenced
333
- record's combobox (`WidgetCategoryCombobox`, the form's Category
334
- combobox with its own search per row, a lookup by id for the picked
335
- record's name, and the picked name not counted as a search, so
336
- opening the list offers every record) and the other fields, each
337
- named by position ("Pairing 2 category"). On the form it sits in a
338
- `Controller` over `<list>.<i>.<field>Id`, the rest `register`ed, and
339
- a server 422 at that path (`fieldErrors["pairings.2.categoryId"]`)
340
- binds to that row's picker. A new row starts with no pick, which the
341
- schema refuses on that row ("Pick a category or remove the
342
- pairing"), so a blank item is never sent.
343
- - *The view* shows each item as the referenced record's name, from the
344
- view's one lookup by id (add every item's id to the ids it already
345
- looks up), then its other fields. The name links to the record's
346
- view when that entity has one (`<Link to={`/<other>/${id}`}>`);
347
- WidgetCategory has none, so Pairings shows it as plain text.
348
- - *Editing in place* is `editInPlace({ kind: 'list', ... })` like
349
- Checklist's (`pairings` in `widgetEdits`): `renderItem` is the
350
- form's row, `renderShown` the item as the view shows it, `newItem`
351
- starts with no pick. In the row, Enter in the open list picks
352
- without saving; Enter in the row's text box saves the item, as does
353
- leaving the row (a click on an option is still inside it), and the
354
- item being added opens again after an Enter, as Checklist's does.
355
- - *Specs* (copy the `pairings` tests): on the form, saved picks load
356
- by name, a pick found by searching saves, a row with no pick is
357
- caught on that row, and a server 422 at the item's reference binds
358
- to that row's picker; on the view, the names and the sparse record's
359
- not-set label; in place (`the pairings edited in place`), an item
360
- added from the keyboard (search, Enter picks, Enter saves) with the
361
- PATCH sending ids, an item's reference changed by a click, move and
362
- remove, no pick never sent, and a refused id staying open with the
363
- reason; and the in-place a11y block for a row open and refused.
364
- - *Not built:* a "New …" option in the item's picker that creates the
365
- referenced record inline. Create it on its own screen (or the
366
- table's `InlineCreate`) first. AI chats (MCP) print an item's
367
- reference as its id, not its name.
368
-
369
- **A `yes/no` marked `toggle`** copies In Stock's cell
370
- (`in-stock-toggle.tsx`, cell pattern 15): a `Switch` in its own
371
- component that PATCHes the one field through `useSaveWidgetField`, the
372
- entity's wrapper of the foundation's `useRecordUpdate` (the row and the
373
- record's view update at once and go back if the save is refused, with
374
- a toast naming the row and the server's reason; the lists refetch
375
- after). Its specs cover a flip that saves, the keyboard, and a failed
376
- save putting the switch back. Copy `useSaveWidgetField` whenever the
377
- plan has a `toggle` or any quick action, and only then. It finds the
378
- record under the entity's own detail and list keys: on a screen that
379
- holds it in a query of its own, a plain change (`{ field: value }`) is
380
- still sent but only shows once that query refetches, and a change
381
- built from the record (`(record) => …`) is refused, with a console
382
- warning naming the keys searched.
167
+ and labels from its field table, and field types by pattern. The rest
168
+ of this step is under [Step 6 in detail](#step-6-in-detail), after
169
+ step 10, and is part of it: a heading for each field type, then the
170
+ view, the way between the screens and the columns. The files:
383
171
  - `src/routes/widgets/use-widgets.ts`, `use-widget-categories.ts` →
384
172
  `src/routes/<entity>/use-<entity>.ts` (TanStack Query hooks over the
385
173
  new gateway module)
@@ -448,315 +236,6 @@ is a filled-in example while the Widgets demo is still here).
448
236
  delete). Swap the zod schema and fields, each `Field` with its
449
237
  `size` and the required ones' `<FieldLabel required>` ("Forms"
450
238
  below). Every way out lands on a view (below).
451
-
452
- **The view** is the read-only page for one record, at `/<entity>/:id`
453
- (apart from the plan's quick actions and fields edited in place, if it
454
- lists any).
455
- `<EntityView>` owns its loading skeleton, its not-found state (another
456
- user's record is the same plain 404, with a way back to the list and
457
- no retry) and its error state with retry. The screen supplies what the
458
- plan's "View screen" section lists:
459
-
460
- - **Title and badges.** The plan's title field is the page's `<h1>`.
461
- Its badge fields sit on its line, after it (`badges`), each the same
462
- `Badge` and variant map as its table cell. Edit (a `Button`
463
- rendering a `Link` to `/<entity>/:id/edit`) and the delete action go
464
- in `actions`, Delete as an `IconAction` (`icon={Trash2Icon}
465
- label="Delete" tone="destructive"`, the dialog's trigger through
466
- `render`).
467
- - **The way back is a trail.** `back={{ to: '/widgets', label:
468
- 'Widgets', trail: [{ label: 'Inventory', href: '/inventory' }, {
469
- label: 'Widgets', href: '/widgets' }] }}`: the crumbs above the
470
- record, from the module down to its list; the record's title follows
471
- them. In `AppShell` it is the trail in the bar ("The sidebar and the
472
- phone's bar" in design-language.md), and the page has no back link;
473
- on a phone the header's back arrow goes to the list. Without `trail`
474
- the view keeps its "← Widgets" link. `to` and `label` are still the
475
- not-found state's way out. Any other page below a nav entry (a
476
- record's sub-page, a step of a task) names its trail with
477
- `usePageTrail([...crumbs, { label: 'This page' }])` in place of a
478
- back link. Once the record has loaded, call
479
- `useRecentRecord({ title, to: `/widgets/${id}`, detail: 'Widget' })`
480
- too, so search lists it before you type.
481
- - **The browser tab** reads the record's title once it loads
482
- ("Wireless Mouse · <app>"): `EntityView` sets it from `title`, and
483
- puts the nav's ("Widgets · <app>") back while loading, on an error
484
- and when you leave. Nothing to add. `documentTitle` names the tab
485
- otherwise, when the title alone wouldn't say what the tab is (a
486
- record named by a date, say: `documentTitle={`Entry ${title}`}`);
487
- `false` leaves the nav's. Any other screen names its tab with
488
- `useDocumentTitle('New Widget')`, which wins over the nav's while the
489
- screen is mounted.
490
- - **Sections**, one per row of the plan's section table, in order.
491
- Fields are label/value rows (`fields`), labelled as on the form. A
492
- section that holds one long text or one sub-record list is a block
493
- (`content`) with no label of its own, since a label would only repeat
494
- the heading.
495
- - **Layout** (the record standard, 4.98: no right rail). Pass no
496
- `layout`: the default, `tabs`, is every record's shape. Give the
497
- section of short facts (the plan's Placement `details`) `placement:
498
- 'rail'`: on a record with tabs it's the last tab, Details, and on
499
- one without, it stays in the column in its place, its labels beside
500
- their values. Widget's view has no tabs, so its Details comes first
501
- in the one column. A few short facts that explain one tab (a dose
502
- beside the notes) can sit in a small box beside that tab's
503
- sections, under them on a phone: `placement: 'rail'` with that
504
- `tab`. Short facts only, never free text. Never `layout="rail"` in a
505
- new view; it's kept for apps not yet moved (consuming.md "4.98").
506
- Never re-order `sections` by the window's width yourself.
507
- - **A subtitle** (`subtitle`), only when the plan names a line that
508
- says what the record is for (a goal, a one-line summary): under the
509
- title in muted body type. When the plan marks it editable, wrap it
510
- in `<EditableValue label=… edit={editInPlace(…)} layout="inline">`.
511
- - **Key numbers** (`strip`), only when the plan names a few figures
512
- read before anything else (done of total, time left, the next
513
- date): `<KeyStats stats={[{ label, value, hint? }]} />`, under the
514
- header, as wide as its numbers (4.98), so on a phone it comes before
515
- the sections. Three to five; more belong in a section.
516
- - **A notice** (`notice`), only when the plan names a state that
517
- decides what you do with the record (held, overdue, archived and
518
- read-only): a `<Notice tone=…>` saying what it means and what to do,
519
- with at most one action. It goes under the header, across the page.
520
- Pass `null` when the state doesn't hold; the view announces it
521
- appearing or clearing. A badge still shows the state itself; the
522
- notice is for the few states a badge is too quiet for.
523
- - **A source credit** (`footer`), only when the record's data comes
524
- from an outside service whose terms ask for one (many free APIs
525
- do: a film database, a games catalogue): `<SourceCredit sources={[{
526
- name, href, note, icon }]} />`, with `note` the sentence the terms ask
527
- for, word for word, and `icon` the service's mark when the app has
528
- one (the same component it shows for that service elsewhere; drawn
529
- before the name, which stays the link's text). Logos and their rules
530
- are the app's own.
531
- - **Every value renders the way its table cell does**: badges, names
532
- of linked records, a done-count, from the shared lookups in
533
- `<entity>-format.ts`. Never re-derive one for the view.
534
- - **An empty value is passed through as it is** (`null`, `''`, or
535
- `list.length > 0 && …`), and `EntityView` shows a dash (read as "Not
536
- set"), never a blank. A field's `emptyLabel` replaces it only where
537
- words say more ("No budget yet"). A yes/no is never empty: it reads
538
- Yes or No (cell pattern 12).
539
- - **A reference links to the referenced record's view** when that
540
- entity has one: the name, from the same lookup by id the table uses,
541
- inside `<Link to={`/<other>/${id}`}>`. Without a view, the plain name
542
- (Widget's categories have none).
543
- - **Sub-records are read-only** unless the plan's `Quick actions`
544
- names the list: the done-count, then each item in order with its
545
- state as a glyph and words, never a checkbox. Widget's checklist is
546
- a quick action, so this is the markup to use (the shape Widget's
547
- view had before it was):
548
-
549
- ```tsx
550
- <div className="flex flex-col gap-2">
551
- <p className="type-caption tabular-nums text-muted-foreground">{checklistDoneCount(items)}</p>
552
- <ul aria-label="Checklist items" className="flex flex-col gap-1.5">
553
- {items.map((item, index) => (
554
- <li key={index} className="flex items-start gap-2">
555
- {item.done ? (
556
- <CircleCheckIcon role="img" aria-label="Done" className="mt-0.5 size-4 shrink-0 text-success-text" />
557
- ) : (
558
- <CircleIcon role="img" aria-label="Not done" className="mt-0.5 size-4 shrink-0 text-muted-foreground" />
559
- )}
560
- <span className={item.done ? 'text-muted-foreground' : undefined}>{item.text}</span>
561
- </li>
562
- ))}
563
- </ul>
564
- </div>
565
- ```
566
-
567
- A list of links: each an
568
- `<a target="_blank" rel="noreferrer">` with an `ExternalLinkIcon`
569
- and a visually hidden "(opens in a new tab)".
570
- - **Long text the plan marks Markdown** renders through the
571
- foundation's `<Markdown>`: headings, lists, tables, callouts
572
- (`> [!NOTE]`) and links, links opening in a new tab; raw HTML shows
573
- as the characters typed, never as markup. The app needs no Markdown dependency of its own. Plain
574
- long text renders as text (`whitespace-pre-line` keeps its line
575
- breaks). Give `<Markdown>` and `RichTextEditor` a `headingLevel` for
576
- where they sit: the default (3) in an `EntityView` section,
577
- `headingLevel={2}` for a `RichTextEditor` on a form straight under
578
- the page's `<h1>`. Text that's imported or pasted from another
579
- tool (often starting at `##`) also gets `headingFrom="text"`.
580
- - **A checklist kept in the text** (`- [ ] item`, `- [x] done`) is
581
- ticked where it's read with `<Markdown onTasksChange={save}>`: each
582
- box a checkbox named for its item, and a tick hands over the whole
583
- text with only that box flipped, for the field's save
584
- (`useEdit<Entity>Field`). Without the prop the boxes are pictures
585
- and the text stays read-only. A list's "2/5" column counts them
586
- with `countTasks(text)` (`{ done, total }`; `total` 0 for none).
587
- - **Pages in the notes** (a record's notes linking to pages of their
588
- own, each a title and its own Markdown at its own URL, and a page's
589
- notes linking to pages under it, to any depth): the app keeps the
590
- pages (a table, an API, a screen per page); the foundation only
591
- draws and makes the links. A page is linked by an ordinary Markdown
592
- link, `[Getting Started](/notes/12/pages/3)`, so the notes stay
593
- Markdown and nothing about how they're stored changes. Give
594
- `<Markdown>` and `RichTextEditor` the same `pageLink={(href) => …}`:
595
- return `{ title, removed, onRestore }` for an address that is one of
596
- the app's pages (look it up in the record's pages, already loaded),
597
- `null` for any other link. A page link shows the page icon and the
598
- page's title and opens it in this tab; alone on its line it's a row
599
- of its own; a removed page (soft-deleted) shows "Page removed" and,
600
- with `onRestore` (the app's undelete, returning its promise),
601
- Restore. Give the editor `onCreatePage={(title) => createPage(title).then((page) => pagePath(page))}`
602
- too: "/page" (and Turn Into Page on selected words) asks for a
603
- title, awaits the new page's address and puts in the link; a
604
- rejection shows in the title box in the gateway's words and leaves
605
- the text as it was. The page's own screen puts `PageTrail` above its
606
- title (`crumbs`: the list, the record, every page above this one,
607
- then this one, last, with no `href`): it folds the middle into a "…"
608
- menu when it doesn't fit. A page's notes take the same two props, so
609
- nothing assumes one level: the app decides where a new page lives
610
- (under the record, or under the page whose note it's in).
611
- - **Notes worth taking on paper** (a visit's prep and questions, a
612
- guide, a checklist to tick by hand): mark each of those sections
613
- `print: true`. The header gets a Print Notes icon (`printLabel`
614
- renames its tooltip and name) that prints the marked sections alone, under the title
615
- and subtitle: no rail, no shell, no buttons, light paper in either
616
- theme, headings and bullets as written, nothing folded, tables
617
- ruled with room in their empty cells. On a phone, whose print()
618
- returns at once and fires `afterprint` before its preview exists, the
619
- copy stays until the person next touches the page or presses a key
620
- (4.124.1), so the preview prints the notes; the browser's own print
621
- (Ctrl+P) in that gap prints them too. `print: { answerSpace: true }`
622
- also leaves space under each item of the section's numbered lists,
623
- for questions answered by hand. A section's own content that should
624
- print differently (a list of sub-items as plain text) reads
625
- `usePrinting()`, true in the printed copy. The browser's own print
626
- (Ctrl+P) still prints the whole page.
627
- - **Quick actions: only the fields the plan's `Quick actions` line
628
- names**, each a control that saves on its own (cell pattern 17,
629
- `widget-quick-actions.tsx`). A `yes/no` is a
630
- `Switch` with its words (`WidgetInStockSwitch`); a sub-record list's
631
- yes/no item field is a checkbox per item in a named group
632
- (`ChecklistItems`), whose change is a function of the record
633
- (`(current) => ({ checklist: ... })`) so quick ticks build on each
634
- other. Each control calls `useSave<Entity>Field(id)` itself and shows
635
- its own "Saving" spinner; nothing is disabled. A control goes where
636
- the field already shows (`badges`, a field's `value`, a section's
637
- `content`): `EntityView` needs nothing new. **With no `Quick actions`
638
- line, every value is read-only** and there is no quick-actions file:
639
- the view is exactly the read-only one above.
640
- - **Edit in place: only the fields the plan's `Edit in place` line
641
- names** (cell pattern 18). Each becomes `editInPlace({ kind, value,
642
- control, schema, save })` (`widgetEdits` in `widget-view.tsx`):
643
- `value` is what the form's control starts from, `control` is the
644
- shared control from `<entity>-fields.tsx` given the props it's
645
- handed (`readOnly={props.disabled}`, `aria-label={props.label}`,
646
- `aria-describedby={props.describedBy}`), `schema` is the form's own
647
- rule (`<entity>FormSchema.shape.<field>`), and `save` is
648
- `useEdit<Entity>Field(id).mutateAsync({ <field>: value })` (copy
649
- `useEditWidgetField`: the single-field save with `optimistic: false,
650
- toastOnError: false`). `kind` follows the control: `text` (one line;
651
- a number or integer too), `long-text` (Markdown, `RichTextEditor`
652
- with `onProblem={props.onProblem}`; notes are `inline: true` by
653
- default, the control passing `inline={props.inline}` and
654
- `toolbar="floating"` (on the form too: "Forms" below) with no
655
- `autoFocus`, as Widget's Description does; a short one opened by a click is
656
- `autosave: true` with `autoFocus`), `choice` (a
657
- select or a single reference: its list opens with the field,
658
- `defaultOpen`, non-modal, `onChange={(v) => props.commit(v)}`,
659
- `onOpenChange={(open) => !open && props.cancel()}`; a yes/no switch
660
- commits on change), `multi` (a multi reference; `isEqual` comparing
661
- ids as a set; a field the plan marks `small` is `MultiPick`, on the
662
- form too, every option loaded once, and saves each click itself:
663
- `value` is the record's, `onPick` the single-field save as a
664
- function of the record, cell pattern 18 "A small set"). A plain
665
- text, number, money, date, single choice or single reference whose
666
- form control is a plain box (no control of the entity's own) can be
667
- the package's preset instead, one line with no control to wrap:
668
- `{ label, edit: inPlace.money({ value, save }) }` (cell pattern 18,
669
- "Presets"); a link with a label is `inPlace.link`, and two fields
670
- that must agree are `inPlace.fields` with its `rule`. A field gets `edit`, a `content` section gets `edit`,
671
- the title gets `titleEdit={{ label, ...edit }}`, and a header badge
672
- wraps itself in `<EditableValue label edit layout="inline">`. The
673
- shown value stays exactly as before. A sub-record list the line
674
- names is `editInPlace({ kind: 'list', ... })` on its `content`
675
- section (cell pattern 18, "A list of sub-items"; copy `checklist` in
676
- `widgetEdits`): the form's row as `renderItem`, from one component
677
- shared with the form (`WidgetChecklistItemFields`), the item as the
678
- view shows it (its quick action, if any) as `renderShown`, the list's
679
- schema, and `save: (change) => edit.mutateAsync((current) => ({
680
- <field>: change(current.<field>) }))` (an item with a reference:
681
- copy `pairings` in `widgetEdits`, above). **With no `Edit in place`
682
- line, nothing is editable in place** and none of this is copied.
683
- Never a computed field.
684
-
685
- **The table opens the view, and the form returns to it.** The title
686
- column's link is the way in (a `yes/no` marked `toggle` stays in its
687
- row). Saving an edit, or cancelling one, goes back to the record's view;
688
- creating opens the new record's view (the id the create returns);
689
- cancelling a create goes back to the list. Each navigates with
690
- `{ replace: true }`, so Back from the view doesn't reopen the form. The
691
- create and update mutations put the saved record into its detail cache
692
- (`setQueryData`), so the view shows the save at once, and the delete
693
- mutation drops it (`removeQueries`), so the view it leaves never
694
- refetches a record that's gone (`use-widgets.ts`).
695
-
696
- **`<SelectValue>` shows the value, not the label.** Base UI renders the
697
- raw *value*, and `placeholder` only applies when the value is `null`.
698
- Any `Select` whose "nothing chosen" state is a sentinel rather than
699
- `null` therefore displays that sentinel on screen unless you pass the
700
- children function. This bit every `Select` in the first app built on
701
- this foundation. Two cases, both needing it:
702
-
703
- - **A toolbar filter**, where "no filter" is `'all'` — copied straight
704
- from `widgets-table.tsx`, which now carries the shape to copy: a
705
- label constant read by both the trigger and its `<SelectItem>`.
706
- - **An optional `single choice` field**, which Widget has no example of
707
- (its `status` is required and its `categoryId` is a combobox). A Base
708
- UI `Select` item's value cannot be `''`, so the field's own unset
709
- value is remapped through a sentinel:
710
-
711
- ```tsx
712
- const UNSET = '__unset__'
713
- const UNSET_LABEL = 'Not set' // the plan's "not set" label
714
- // ...
715
- <Controller
716
- control={form.control}
717
- name="priority"
718
- render={({ field }) => (
719
- <Select
720
- value={field.value === '' ? UNSET : field.value}
721
- onValueChange={(value) => field.onChange(value === UNSET ? '' : value)}
722
- >
723
- <SelectTrigger id="<entity>-priority">
724
- {/* Without this the trigger reads the literal "__unset__" */}
725
- <SelectValue>{(value) => (value === UNSET ? UNSET_LABEL : value)}</SelectValue>
726
- </SelectTrigger>
727
- <SelectContent>
728
- <SelectItem value={UNSET}>{UNSET_LABEL}</SelectItem>
729
- {PRIORITIES.map((option) => (
730
- <SelectItem key={option} value={option}>{option}</SelectItem>
731
- ))}
732
- </SelectContent>
733
- </Select>
734
- )}
735
- />
736
- ```
737
-
738
- The zod schema keeps `''` as the unset value and converts it to
739
- `null` on the way to the wire, the way `widget-schema.ts` already
740
- handles a blank `assigneeEmail`. Step 8's specs must assert the
741
- **unset** display, not only a picked one — a select whose enum values
742
- equal their labels passes either way, which is exactly how this
743
- shipped unnoticed.
744
-
745
- **Choosing how each column looks.** The plan says what a field *means*,
746
- not how its cell should render. For most columns plain text is right and
747
- there is nothing to decide. Where there is:
748
-
749
- - [`cell-patterns.md`](cell-patterns.md) is the catalogue — icon + label,
750
- icon in a badge, icon-only with a tooltip, enum → tone-mapped badge,
751
- clustered multi-value, link button, relative date, ordinal scale,
752
- summary + popover — each with the parts a first attempt gets wrong.
753
- They are markup to copy, not components to import.
754
- - If the developer doesn't have a preference, don't pick for them and
755
- don't guess: follow [`column-options.md`](column-options.md) to build
756
- a short page of numbered options over the same sample rows, and let
757
- them choose. That is how every pattern in the catalogue was picked.
758
- - Any colour involved: [`design-language.md`](design-language.md). Most
759
- values should stay grey, and colour is never the only signal.
760
239
  7. **Register routes** for `/<entity>`, `/<entity>/new`, `/<entity>/:id`
761
240
  (the view) and `/<entity>/:id/edit` in `src/App.tsx`, and add a nav
762
241
  entry to `src/nav.ts`. Its label names the browser tab on the list and
@@ -779,13 +258,7 @@ is a filled-in example while the Widgets demo is still here).
779
258
  `window.__msw` handle from `@tristan2828/ui-foundation/testing`, and
780
259
  `e2e/widgets-table.spec.ts`/`e2e/widget-form.spec.ts`/
781
260
  `e2e/widget-view.spec.ts` for the pattern. Import `test` and
782
- `expect` from there too, not from `@playwright/test`: its page's
783
- `goto()` and `reload()` first wait for the page's `/api/` requests to
784
- settle (150 ms with none in flight, at most 3 s, never a failure), so a
785
- save's follow-up refresh isn't sent past the mocks by the page as it
786
- unloads; then they return once the app has rendered (after MSW's
787
- start), and load once more if the server refused one of its files,
788
- so a spec's first expect never meets an empty page. The view's states are
261
+ `expect` from there too, not from `@playwright/test`. The view's states are
789
262
  loading, not found (a 404: "Not found", the way back, no retry), error
790
263
  (a failed load, then Try Again recovering) and success (every section,
791
264
  each value as its cell shows it), plus the sparse record showing its
@@ -820,7 +293,7 @@ is a filled-in example while the Widgets demo is still here).
820
293
  label sits above its value and nothing scrolls sideways. With a
821
294
  section placed `details`, that test checks its labels sit beside
822
295
  their values, and another on a wide screen that there's no rail (copy
823
- `wide screens: …` in `e2e/widget-view.spec.ts`).
296
+ `wide screens (…)` in `e2e/widget-view.spec.ts`).
824
297
  **A loading test holds the answer, never delays it:**
825
298
  `forceMswOverride(page, override, { hold: true })` returns a
826
299
  `release()`; assert the skeleton, `await release()`, then assert the
@@ -831,8 +304,7 @@ is a filled-in example while the Widgets demo is still here).
831
304
  States forced via a first-load init script (loading, load-time error)
832
305
  need `page.addInitScript` before navigation; states forced after the
833
306
  page is already up (a mutation's error response) can use a
834
- post-navigation `worker.use()` call gated on
835
- `waitForFunction(() => window.__msw !== undefined)`. To stub what an
307
+ post-navigation `worker.use()` call after `waitForMswReady(page)`. To stub what an
836
308
  `<img>` loads (a cover or avatar cell), give the override `bodyBase64`
837
309
  and `contentType` instead of `body` — a JSON body makes the image fire
838
310
  `onError` — and stub it through the override, never `page.route`,
@@ -865,9 +337,8 @@ is a filled-in example while the Widgets demo is still here).
865
337
  `NAV_ENTRIES` so the shell smoke test covers the new screen, add
866
338
  `/<entity>/new` to `e2e/a11y.spec.ts`'s `formRoutes`, and add the view
867
339
  of a full record and of the sparse one to its `viewRoutes` (the table
868
- page comes from `src/nav.ts`, which the suite is given as `nav`: each
869
- nav page is a test of its own, so the suite's time per test stays flat
870
- as the app grows; the form and the view aren't in the nav). An app
340
+ page comes from `src/nav.ts`, which the suite is given as `nav`; the
341
+ form and the view aren't in the nav). An app
871
342
  with one a11y spec per module (`e2e/a11y-<module>.spec.ts`) adds them
872
343
  to its module's file instead, which passes only that module's nav
873
344
  entries with `checkSidebar: false`; one file keeps the whole nav and
@@ -876,14 +347,591 @@ is a filled-in example while the Widgets demo is still here).
876
347
  the rich-text editor, an open list, a list edited in place (an item
877
348
  open, one being added, a refused change), and the leave prompt, in
878
349
  both themes.
879
- 10. **`npm run verify`.** Fix until it passes. Then stop — do not add
880
- anything beyond what this list covers; note ideas in the app's
881
- backlog instead.
350
+ 10. **`npm run verify`.** Fix until it passes. Then stop (AGENTS.md
351
+ "Scope and Stopping").
352
+
353
+ ## Step 6 in detail
354
+
355
+ The rest of step 6: each field type the plan can name, then the view,
356
+ the way between the screens, and the columns.
357
+
358
+ ### A `reference`
359
+
360
+ A `reference` field copies Category's searchable combobox.
361
+
362
+ ### A `single choice`
363
+
364
+ A `single choice` copies Status's select — each option shows its label,
365
+ never its wire value, from one `Record<value, label>`
366
+ (`WIDGET_STATUS_LABELS`) read by the options, the trigger (through
367
+ `<SelectValue>`'s children, which otherwise shows the raw value), the
368
+ toolbar filter and every badge.
369
+
370
+ ### A `date-time`
371
+
372
+ A `date-time` copies Available From's date picker, a `date` (a day, no time)
373
+ is the foundation's `DateField` (see below).
374
+
375
+ ### A `yes/no`
376
+
377
+ A `yes/no` copies In Stock — a `Switch`
378
+ (`@tristan2828/ui-foundation/ui/switch`) in a horizontal `Field` with its
379
+ label beside it on the form, cell pattern 12 (the word Yes/No) in the table,
380
+ and a three-way toolbar `Select` (either / yes / no) whose URL value is
381
+ `'true'`/`'false'` and whose `filters` value is a real boolean, so `false`
382
+ reaches the wire.
383
+
384
+ ### A `multi choice`
385
+
386
+ A `multi choice` copies Tags — the `<MultiChoice>` control from the
387
+ foundation on the form and as a toolbar filter via `useTableUrlState`'s
388
+ multi filters, badges in the table, and a `filters` array the gateway sends
389
+ as a repeated parameter; each option shows its label, never its wire value
390
+ (`quick_win` reads "Quick win"): one `Record<value, label>`
391
+ (`WIDGET_TAG_LABELS`) feeds `MultiChoice`'s `getLabel` and the badges.
392
+
393
+ ### A `multi reference`
394
+
395
+ A `multi reference` copies Extra Categories: the `<MultiReference>` control
396
+ on the form and as a toolbar filter, an array of ids on the wire, a repeated
397
+ any-of list filter, and names from a **lookup by id** on the referenced
398
+ entity (`GET /widget-categories?ids=1&ids=3`, `getWidgetCategoriesByIds`,
399
+ `useWidgetCategoriesByIdsQuery`), and `searching` from the search query's
400
+ `isPlaceholderData` so Enter waits for the results that match what was
401
+ typed. Add that `ids` parameter to the referenced entity's list endpoint if
402
+ it lacks one. Never name a picked id from search results alone: a saved pick
403
+ the current search doesn't return would show without a name. The table looks
404
+ up every id on its page in one request; the backend rejects an unknown id as
405
+ a 422 on the field, never a foreign-key 500.
406
+
407
+ ### Sub-records
408
+
409
+ Each **sub-records** list copies Checklist: an array of item objects on the
410
+ wire, read and written whole and in order (no item ids), a child table with
411
+ a `position` column, react-hook-form's `useFieldArray` feeding the
412
+ foundation's `<ListEditor>` inside a `FieldSet`/`FieldLegend` on the form,
413
+ each row's controls named by position ("Item 2 text"), a per-item
414
+ `FieldError` (a server 422 at `["body", "checklist", 2, "text"]` arrives as
415
+ `fieldErrors["checklist.2.text"]` and binds to that row). A list whose items
416
+ are rich (five or six fields each) and run to ten or more also passes
417
+ `summary={(i) => …}`, one line per item that opens to its fields, one at a
418
+ time, and `invalid={(i) => !!errors.<list>?.[i]}` so an item the save
419
+ refuses opens to show why. A list whose items repeat with small changes
420
+ passes ``onDuplicate={(i) => insert(i + 1, { ...getValues(`<list>.${i}`)
421
+ })}``, leaving out any saved id; the copy lands after its original and
422
+ opens. Then a summary in the table, never the items (an item with a
423
+ `reference` field copies Pairings, below).
424
+
425
+ ### A `computed` field
426
+
427
+ A `computed` field copies Progress (`checklistState`): `readOnly` in
428
+ `openapi.yaml` and absent from `<Entity>Create`/`<Entity>Update`, one SQL
429
+ expression in the router that the filter and sort use (correlated `EXISTS`,
430
+ or a scalar subquery for a count, so they hold across pages), a Python
431
+ mirror on the model for the value each row reads back with, a test that the
432
+ two agree for every value, the mocks recomputing it on every write and
433
+ ignoring any client-sent value, a read-only column and a filter, and nothing
434
+ on the form.
435
+
436
+ ### A `date`
437
+
438
+ **A `date`** (a day with no time: when something was finished, a
439
+ due day) is `type: string, format: date` in `openapi.yaml`, so the
440
+ wire, the generated type and the form all hold `'YYYY-MM-DD'`, and
441
+ `''` on the form for an optional one not set (sent as `null`). No
442
+ `Date` object anywhere, so no time zone can move the day. On the form
443
+ it's the foundation's `DateField` in a `Controller` (`clearable` when
444
+ optional); the schema is the string (`z.string().min(1, …)` when
445
+ required). The table and the view show `formatPlainDate(value)`
446
+ ("Sep 2, 2026"), the not-set label when empty. `DateField` is typed: a box that reads "3/14", "Mar 14", "2026-03-14" or "today",
447
+ with the calendar on its button, and something unreadable says "Try a
448
+ date like 3/14 or Mar 14" and gives `''`. Editing in place is
449
+ `inPlace.date({ value, save })`: Enter or leaving saves the day typed,
450
+ a day picked in the calendar saves at once. (`typing={false}` is the
451
+ button alone; in place then `editInPlace({ kind: 'choice', ... })` with
452
+ `defaultOpen`, `modal={false}` and `onChange={(day) => props.commit(day)}`.) The backend column
453
+ is a SQL `date` (`datetime.date` in the model).
454
+
455
+ ### A `month-day`
456
+
457
+ **A `month-day`** (a day that comes round every year, with no year:
458
+ when a season starts, a yearly deadline) is `type: string` with
459
+ `pattern: '^(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$'` in
460
+ `openapi.yaml`, so the wire, the generated type and the form all hold
461
+ `'MM-DD'` (`'03-14'`), and `''` on the form for an optional one not set
462
+ (sent as `null`). It sorts as text in calendar order. On the form it's
463
+ the foundation's `MonthDayField` in a `Controller` (`clearable` when
464
+ optional); the schema is the string with
465
+ `.refine((v) => v === '' || isMonthDay(v), 'Pick a month and day')`
466
+ (`isMonthDay`: February 29 is a day, February 30 isn't), `min(1, …)`
467
+ too when required. The table and the view show `formatMonthDay(value)`
468
+ ("Mar 14"), the not-set label when empty. Editing in place is
469
+ `inPlace.monthDay({ value, save })` (cell pattern 18, "Presets"). The
470
+ backend column is `varchar(5)` (`str` in the model) and the router
471
+ refuses a day the month can't have as a 422 on the field (the pattern
472
+ alone lets `02-30` through). Values typed before as free text are
473
+ rewritten to `'MM-DD'` by a migration; one it can't read stays as
474
+ written, and the field shows it as written with nothing picked, refused
475
+ until a day is picked.
476
+
477
+ ### A `recurrence`
478
+
479
+ **A `recurrence`** (how something repeats: a chore, a reminder, a
480
+ task) is the foundation's `Recurrence` schema: copy it from the
481
+ package's `openapi/foundation.yaml` into `components.schemas` (it's
482
+ `x-optional`, so `check-contract` holds it to the foundation's shape
483
+ once it's there) and reference it, nullable when it may not repeat.
484
+ On the form it's the foundation's `RecurrenceField` in a `Controller`
485
+ (presets, a phrase read as it's typed, and a preview of the next five);
486
+ the schema checks it with `recurrenceProblem(value)`, and a phrase the
487
+ field can't read gives `null`, so a required one is refused. The table
488
+ shows `formatRecurrence(value)` and a Next column (cell pattern 27);
489
+ editing in place is `inPlace.recurrence({ value, save })`. A record
490
+ whose times are fields of its own (an event's start and end) gives the
491
+ field and the preset `times={false}`: dates only, no "at". An app whose
492
+ weeks start on Sunday gives them `weekStart="SU"`, which adds
493
+ `WKST=SU` to the weekly rules they build (reminders.md "Repeating
494
+ reminders" says when that moves a day). The backend
495
+ column is JSON, read and checked with
496
+ `foundation_backend.recurrence.Recurrence` (a 422 on the field for a
497
+ rule it refuses); `next_after` and `occurrences` say when it falls
498
+ (reminders.md "Repeating reminders").
499
+
500
+ ### An image on a record
501
+
502
+ **An image on a record** (a photo of it) is the stored file's id on the
503
+ wire (`string`, nullable), and on the form the foundation's
504
+ `ImageField` in a `Controller` (`z.string().nullable()`): `value` and
505
+ `onChange` are the id, `thumbUrl` the record's saved photo,
506
+ `onBusyChange` holds the submit while a file uploads. Its `upload` is the app's own, one function in the
507
+ gateway that sends the file to the app's endpoint and resolves to
508
+ `{ id, thumbUrl, url }` (the `ImageUploadResult`), rejecting with the
509
+ `AppError`; the same function goes to a notes field's
510
+ `RichTextEditor`, so pictures in its text use the same storage:
511
+
512
+ ```ts
513
+ // src/api/gateway/files.ts
514
+ export async function uploadImage(file: File): Promise<ImageUploadResult> {
515
+ const body = new FormData()
516
+ body.append('file', file)
517
+ const response = await safeFetch('/files', { method: 'POST', body })
518
+ if (response.status !== 201) throw toAppError(response.status, response.body, response.headers)
519
+ const { id } = response.body as components['schemas']['File']
520
+ return { id, thumbUrl: `/api/files/${id}/content?size=thumb`, url: `/api/files/${id}/content` }
521
+ }
522
+ ```
523
+
524
+ The types it takes default to JPEG, PNG and WebP; never add SVG or
525
+ HTML, which run script when served from the app's own domain. The
526
+ endpoint, the storage and serving the files are the app's (the
527
+ template has none); `<Markdown>` shows an image only from a web
528
+ address or a path on the site, so `url` is one of those.
529
+
530
+ ### A `reference` inside a sub-record item
531
+
532
+ **A `reference` inside a sub-record item** (a list whose items each
533
+ point at another entity's record) copies Pairings, Widget's
534
+ `pairings`: Checklist's list, with a reference in each item.
535
+ - *Wire:* the item carries the referenced id only, named as a
536
+ top-level reference is (`{ categoryId, note }`, `seriesId` for a
537
+ Series), never a name or a nested record. Every name, on the form
538
+ and on the view, comes from the other entity's lookup by id
539
+ (`GET /<other>?ids=…`), as for a `multi reference`. An optional text field beside it
540
+ is a required `string` that is `""` when empty (`note`), so an item
541
+ never holds a null. `openapi.yaml` describes the item as its own
542
+ schema (`WidgetPairing`), with `maxItems` on the list.
543
+ - *Backend:* a child table like the checklist's (`widget_pairings`:
544
+ `position`, and a foreign key to the referenced table, commented),
545
+ replaced whole on every write. Before saving, the router checks every
546
+ item's id in one query (`_check_item_categories_exist`): one that
547
+ isn't there, or, for a per-user entity, isn't this user's, is a 422 at
548
+ the item's own path, `["body", "pairings", 2, "categoryId"]`, never a
549
+ foreign-key 500. Its tests: order kept with repeats, replace and
550
+ clear, the note trimmed, an unknown id refused at its item on create
551
+ and on update with nothing saved, `null` and too many refused.
552
+ - *The mocks* refuse an unknown id at the same path, and trim the note.
553
+ - *The form's row* is one component shared with editing in place
554
+ (`WidgetPairingItemFields` in `widget-fields.tsx`): the referenced
555
+ record's combobox (`WidgetCategoryCombobox`, the form's Category
556
+ combobox with its own search per row, a lookup by id for the picked
557
+ record's name, and the picked name not counted as a search, so
558
+ opening the list offers every record) and the other fields, each
559
+ named by position ("Pairing 2 category"). On the form it sits in a
560
+ `Controller` over `<list>.<i>.<field>Id`, the rest `register`ed, and
561
+ a server 422 at that path (`fieldErrors["pairings.2.categoryId"]`)
562
+ binds to that row's picker. A new row starts with no pick, which the
563
+ schema refuses on that row ("Pick a category or remove the
564
+ pairing"), so a blank item is never sent.
565
+ - *The view* shows each item as the referenced record's name, from the
566
+ view's one lookup by id (add every item's id to the ids it already
567
+ looks up), then its other fields. The name links to the record's
568
+ view when that entity has one (`<Link to={`/<other>/${id}`}>`);
569
+ WidgetCategory has none, so Pairings shows it as plain text.
570
+ - *Editing in place* is `editInPlace({ kind: 'list', ... })` like
571
+ Checklist's (`pairings` in `widgetEdits`): `renderItem` is the
572
+ form's row, `renderShown` the item as the view shows it, `newItem`
573
+ starts with no pick. In the row, Enter in the open list picks
574
+ without saving; Enter in the row's text box saves the item, as does
575
+ leaving the row (a click on an option is still inside it), and the
576
+ item being added opens again after an Enter, as Checklist's does.
577
+ - *Specs* (copy the `pairings` tests): on the form, saved picks load
578
+ by name, a pick found by searching saves, a row with no pick is
579
+ caught on that row, and a server 422 at the item's reference binds
580
+ to that row's picker; on the view, the names and the sparse record's
581
+ not-set label; in place (`the pairings edited in place`), an item
582
+ added from the keyboard (search, Enter picks, Enter saves) with the
583
+ PATCH sending ids, an item's reference changed by a click, move and
584
+ remove, no pick never sent, and a refused id staying open with the
585
+ reason; and the in-place a11y block for a row open and refused.
586
+ - *Not built:* a "New …" option in the item's picker that creates the
587
+ referenced record inline. Create it on its own screen (or the
588
+ table's `InlineCreate`) first. AI chats (MCP) print an item's
589
+ reference as its id, not its name.
590
+
591
+ ### A `yes/no` marked `toggle`
592
+
593
+ **A `yes/no` marked `toggle`** copies In Stock's cell
594
+ (`in-stock-toggle.tsx`, cell pattern 15): a `Switch` in its own
595
+ component that PATCHes the one field through `useSaveWidgetField`, the
596
+ entity's wrapper of the foundation's `useRecordUpdate` (the row and the
597
+ record's view update at once and go back if the save is refused, with
598
+ a toast naming the row and the server's reason; the lists refetch
599
+ after). Its specs cover a flip that saves, the keyboard, and a failed
600
+ save putting the switch back. Copy `useSaveWidgetField` whenever the
601
+ plan has a `toggle` or any quick action, and only then. It finds the
602
+ record under the entity's own detail and list keys: on a screen that
603
+ holds it in a query of its own, a plain change (`{ field: value }`) is
604
+ still sent but only shows once that query refetches, and a change
605
+ built from the record (`(record) => …`) is refused, with a console
606
+ warning naming the keys searched.
607
+
608
+ ### Keep column definitions stable
609
+
610
+ **Keep column definitions stable.** Build them once
611
+ (`useMemo(() => build<Entity>Columns(), [])`) from nothing that loads
612
+ later. TanStack's `flexRender` treats each column's `cell` as a
613
+ component, so rebuilt columns remount every cell: focus is lost and the
614
+ table flickers when, say, reference names arrive after the rows. Data
615
+ that arrives later reaches the cells through context, as
616
+ `category-names.tsx` does for category names.
617
+
618
+ ### The view
619
+
620
+ **The view** is the read-only page for one record, at `/<entity>/:id`
621
+ (apart from the plan's quick actions and fields edited in place, if it
622
+ lists any).
623
+ `<EntityView>` owns its loading skeleton, its not-found state (another
624
+ user's record is the same plain 404, with a way back to the list and
625
+ no retry) and its error state with retry. The screen supplies what the
626
+ plan's "View screen" section lists:
627
+
628
+ - **Title and badges.** The plan's title field is the page's `<h1>`.
629
+ Its badge fields sit on its line, after it (`badges`), each the same
630
+ `Badge` and variant map as its table cell. Edit (a `Button`
631
+ rendering a `Link` to `/<entity>/:id/edit`) and the delete action go
632
+ in `actions`, Delete as an `IconAction` (`icon={Trash2Icon}
633
+ label="Delete" tone="destructive"`, the dialog's trigger through
634
+ `render`).
635
+ - **The way back is a trail.** `back={{ to: '/widgets', label:
636
+ 'Widgets', trail: [{ label: 'Inventory', href: '/inventory' }, {
637
+ label: 'Widgets', href: '/widgets' }] }}`: the crumbs above the
638
+ record, from the module down to its list; the record's title follows
639
+ them. In `AppShell` it is the trail in the bar ("The sidebar and the
640
+ phone's bar" in design-language.md), and the page has no back link;
641
+ on a phone the header's back arrow goes to the list. Without `trail`
642
+ the view keeps its "← Widgets" link. `to` and `label` are still the
643
+ not-found state's way out. Any other page below a nav entry (a
644
+ record's sub-page, a step of a task) names its trail with
645
+ `usePageTrail([...crumbs, { label: 'This page' }])` in place of a
646
+ back link. Once the record has loaded, call
647
+ `useRecentRecord({ title, to: `/widgets/${id}`, detail: 'Widget' })`
648
+ too, so search lists it before you type.
649
+ - **The browser tab** reads the record's title once it loads
650
+ ("Wireless Mouse · <app>"): `EntityView` sets it from `title`, and
651
+ puts the nav's ("Widgets · <app>") back while loading, on an error
652
+ and when you leave. Nothing to add. `documentTitle` names the tab
653
+ otherwise, when the title alone wouldn't say what the tab is (a
654
+ record named by a date, say: `documentTitle={`Entry ${title}`}`);
655
+ `false` leaves the nav's. Any other screen names its tab with
656
+ `useDocumentTitle('New Widget')`, which wins over the nav's while the
657
+ screen is mounted.
658
+ - **Sections**, one per row of the plan's section table, in order.
659
+ Fields are label/value rows (`fields`), labelled as on the form. A
660
+ section that holds one long text or one sub-record list is a block
661
+ (`content`) with no label of its own, since a label would only repeat
662
+ the heading.
663
+ - **Layout** (the record standard: no right rail). Pass no
664
+ `layout`: the default, `tabs`, is every record's shape. Give the
665
+ section of short facts (the plan's Placement `details`) `placement:
666
+ 'rail'`: on a record with tabs it's the last tab, Details, and on
667
+ one without, it stays in the column in its place, its labels beside
668
+ their values. Widget's view has no tabs, so its Details comes first
669
+ in the one column. A few short facts that explain one tab (a dose
670
+ beside the notes) can sit in a small box beside that tab's
671
+ sections, under them on a phone: `placement: 'rail'` with that
672
+ `tab`. Short facts only, never free text. Never `layout="rail"` in a
673
+ new view.
674
+ Never re-order `sections` by the window's width yourself.
675
+ - **A subtitle** (`subtitle`), only when the plan names a line that
676
+ says what the record is for (a goal, a one-line summary): under the
677
+ title in muted body type. When the plan marks it editable, wrap it
678
+ in `<EditableValue label=… edit={editInPlace(…)} layout="inline">`.
679
+ - **Key numbers** (`strip`), only when the plan names a few figures
680
+ read before anything else (done of total, time left, the next
681
+ date): `<KeyStats stats={[{ label, value, hint? }]} />`, under the
682
+ header, as wide as its numbers, so on a phone it comes before
683
+ the sections. Three to five; more belong in a section.
684
+ - **A notice** (`notice`), only when the plan names a state that
685
+ decides what you do with the record (held, overdue, archived and
686
+ read-only): a `<Notice tone=…>` saying what it means and what to do,
687
+ with at most one action. It goes under the header, across the page.
688
+ Pass `null` when the state doesn't hold; the view announces it
689
+ appearing or clearing. A badge still shows the state itself; the
690
+ notice is for the few states a badge is too quiet for.
691
+ - **A source credit** (`footer`), only when the record's data comes
692
+ from an outside service whose terms ask for one (many free APIs
693
+ do: a film database, a games catalogue): `<SourceCredit sources={[{
694
+ name, href, note, icon }]} />`, with `note` the sentence the terms ask
695
+ for, word for word, and `icon` the service's mark when the app has
696
+ one (the same component it shows for that service elsewhere; drawn
697
+ before the name, which stays the link's text). Logos and their rules
698
+ are the app's own.
699
+ - **Every value renders the way its table cell does**: badges, names
700
+ of linked records, a done-count, from the shared lookups in
701
+ `<entity>-format.ts`. Never re-derive one for the view.
702
+ - **An empty value is passed through as it is** (`null`, `''`, or
703
+ `list.length > 0 && …`), and `EntityView` shows a dash (read as "Not
704
+ set"), never a blank. A field's `emptyLabel` replaces it only where
705
+ words say more ("No budget yet"). A yes/no is never empty: it reads
706
+ Yes or No (cell pattern 12).
707
+ - **A reference links to the referenced record's view** when that
708
+ entity has one: the name, from the same lookup by id the table uses,
709
+ inside `<Link to={`/<other>/${id}`}>`. Without a view, the plain name
710
+ (Widget's categories have none).
711
+ - **Sub-records are read-only** unless the plan's `Quick actions`
712
+ names the list: the done-count, then each item in order with its
713
+ state as a glyph and words, never a checkbox. Widget's checklist is
714
+ a quick action, so this is the markup to use:
715
+
716
+ ```tsx
717
+ <div className="flex flex-col gap-2">
718
+ <p className="type-caption tabular-nums text-muted-foreground">{checklistDoneCount(items)}</p>
719
+ <ul aria-label="Checklist items" className="flex flex-col gap-1.5">
720
+ {items.map((item, index) => (
721
+ <li key={index} className="flex items-start gap-2">
722
+ {item.done ? (
723
+ <CircleCheckIcon role="img" aria-label="Done" className="mt-0.5 size-4 shrink-0 text-success-text" />
724
+ ) : (
725
+ <CircleIcon role="img" aria-label="Not done" className="mt-0.5 size-4 shrink-0 text-muted-foreground" />
726
+ )}
727
+ <span className={item.done ? 'text-muted-foreground' : undefined}>{item.text}</span>
728
+ </li>
729
+ ))}
730
+ </ul>
731
+ </div>
732
+ ```
733
+
734
+ A list of links: each an
735
+ `<a target="_blank" rel="noreferrer">` with an `ExternalLinkIcon`
736
+ and a visually hidden "(opens in a new tab)".
737
+
738
+ ### The view: long text and notes
739
+
740
+ - **Long text the plan marks Markdown** renders through the
741
+ foundation's `<Markdown>`: headings, lists, tables, callouts
742
+ (`> [!NOTE]`) and links, links opening in a new tab; raw HTML shows
743
+ as the characters typed, never as markup. The app needs no Markdown dependency of its own. Plain
744
+ long text renders as text (`whitespace-pre-line` keeps its line
745
+ breaks). Give `<Markdown>` and `RichTextEditor` a `headingLevel` for
746
+ where they sit: the default (3) in an `EntityView` section,
747
+ `headingLevel={2}` for a `RichTextEditor` on a form straight under
748
+ the page's `<h1>`. Text that's imported or pasted from another
749
+ tool (often starting at `##`) also gets `headingFrom="text"`.
750
+ - **A checklist kept in the text** (`- [ ] item`, `- [x] done`) is
751
+ ticked where it's read with `<Markdown onTasksChange={save}>`: each
752
+ box a checkbox named for its item, and a tick hands over the whole
753
+ text with only that box flipped, for the field's save
754
+ (`useEdit<Entity>Field`). Without the prop the boxes are pictures
755
+ and the text stays read-only. A list's "2/5" column counts them
756
+ with `countTasks(text)` (`{ done, total }`; `total` 0 for none).
757
+ - **Pages in the notes** (a record's notes linking to pages of their
758
+ own, each a title and its own Markdown at its own URL, and a page's
759
+ notes linking to pages under it, to any depth): the app keeps the
760
+ pages (a table, an API, a screen per page); the foundation only
761
+ draws and makes the links. A page is linked by an ordinary Markdown
762
+ link, `[Getting Started](/notes/12/pages/3)`, so the notes stay
763
+ Markdown and nothing about how they're stored changes. Give
764
+ `<Markdown>` and `RichTextEditor` the same `pageLink={(href) => …}`:
765
+ return `{ title, removed, onRestore }` for an address that is one of
766
+ the app's pages (look it up in the record's pages, already loaded),
767
+ `null` for any other link. A page link shows the page icon and the
768
+ page's title and opens it in this tab; alone on its line it's a row
769
+ of its own; a removed page (soft-deleted) shows "Page removed" and,
770
+ with `onRestore` (the app's undelete, returning its promise),
771
+ Restore. Give the editor `onCreatePage={(title) => createPage(title).then((page) => pagePath(page))}`
772
+ too: "/page" (and Turn Into Page on selected words) asks for a
773
+ title, awaits the new page's address and puts in the link; a
774
+ rejection shows in the title box in the gateway's words and leaves
775
+ the text as it was. The page's own screen puts `PageTrail` above its
776
+ title (`crumbs`: the list, the record, every page above this one,
777
+ then this one, last, with no `href`): it folds the middle into a "…"
778
+ menu when it doesn't fit. A page's notes take the same two props, so
779
+ nothing assumes one level: the app decides where a new page lives
780
+ (under the record, or under the page whose note it's in).
781
+ - **Notes worth taking on paper** (a visit's prep and questions, a
782
+ guide, a checklist to tick by hand): mark each of those sections
783
+ `print: true`. The header gets a Print Notes icon (`printLabel`
784
+ renames its tooltip and name) that prints the marked sections alone, under the title
785
+ and subtitle: no rail, no shell, no buttons, light paper in either
786
+ theme, headings and bullets as written, nothing folded, tables
787
+ ruled with room in their empty cells. `print: { answerSpace: true }`
788
+ also leaves space under each item of the section's numbered lists,
789
+ for questions answered by hand. A section's own content that should
790
+ print differently (a list of sub-items as plain text) reads
791
+ `usePrinting()`, true in the printed copy. The browser's own print
792
+ (Ctrl+P) still prints the whole page.
793
+
794
+ ### The view: quick actions and editing in place
795
+
796
+ - **Quick actions: only the fields the plan's `Quick actions` line
797
+ names**, each a control that saves on its own (cell pattern 17,
798
+ `widget-quick-actions.tsx`). A `yes/no` is a
799
+ `Switch` with its words (`WidgetInStockSwitch`); a sub-record list's
800
+ yes/no item field is a checkbox per item in a named group
801
+ (`ChecklistItem`), whose change is a function of the record
802
+ (`(current) => ({ checklist: ... })`) so quick ticks build on each
803
+ other. Each control calls `useSave<Entity>Field(id)` itself and shows
804
+ its own "Saving" spinner; nothing is disabled. A control goes where
805
+ the field already shows (`badges`, a field's `value`, a section's
806
+ `content`): `EntityView` needs nothing new. **With no `Quick actions`
807
+ line, every value is read-only** and there is no quick-actions file:
808
+ the view is exactly the read-only one above.
809
+ - **Edit in place: only the fields the plan's `Edit in place` line
810
+ names** (cell pattern 18). Each becomes `editInPlace({ kind, value,
811
+ control, schema, save })` (`widgetEdits` in `widget-view.tsx`):
812
+ `value` is what the form's control starts from, `control` is the
813
+ shared control from `<entity>-fields.tsx` given the props it's
814
+ handed (`readOnly={props.disabled}`, `aria-label={props.label}`,
815
+ `aria-describedby={props.describedBy}`), `schema` is the form's own
816
+ rule (`<entity>FormSchema.shape.<field>`), and `save` is
817
+ `useEdit<Entity>Field(id).mutateAsync({ <field>: value })` (copy
818
+ `useEditWidgetField`: the single-field save with `optimistic: false,
819
+ toastOnError: false`). `kind` follows the control: `text` (one line;
820
+ a number or integer too), `long-text` (Markdown, `RichTextEditor`
821
+ with `onProblem={props.onProblem}`; notes are `inline: true` by
822
+ default, the control passing `inline={props.inline}` and
823
+ `toolbar="floating"` (on the form too: "Forms" below) with no
824
+ `autoFocus`, as Widget's Description does; a short one opened by a click is
825
+ `autosave: true` with `autoFocus`), `choice` (a
826
+ select or a single reference: its list opens with the field,
827
+ `defaultOpen`, non-modal, `onChange={(v) => props.commit(v)}`,
828
+ `onOpenChange={(open) => !open && props.cancel()}`; a yes/no switch
829
+ commits on change), `multi` (a multi reference; `isEqual` comparing
830
+ ids as a set; a field the plan marks `small` is `MultiPick`, on the
831
+ form too, every option loaded once, and saves each click itself:
832
+ `value` is the record's, `onPick` the single-field save as a
833
+ function of the record, cell pattern 18 "A small set"). A plain
834
+ text, number, money, date, single choice or single reference whose
835
+ form control is a plain box (no control of the entity's own) can be
836
+ the package's preset instead, one line with no control to wrap:
837
+ `{ label, edit: inPlace.money({ value, save }) }` (cell pattern 18,
838
+ "Presets"); a link with a label is `inPlace.link`, and two fields
839
+ that must agree are `inPlace.fields` with its `rule`. A field gets `edit`, a `content` section gets `edit`,
840
+ the title gets `titleEdit={{ label, ...edit }}`, and a header badge
841
+ wraps itself in `<EditableValue label edit layout="inline">`. The
842
+ shown value stays exactly as before. A sub-record list the line
843
+ names is `editInPlace({ kind: 'list', ... })` on its `content`
844
+ section (cell pattern 18, "A list of sub-items"; copy `checklist` in
845
+ `widgetEdits`): the form's row as `renderItem`, from one component
846
+ shared with the form (`WidgetChecklistItemFields`), the item as the
847
+ view shows it (its quick action, if any) as `renderShown`, the list's
848
+ schema, and `save: (change) => edit.mutateAsync((current) => ({
849
+ <field>: change(current.<field>) }))` (an item with a reference:
850
+ copy `pairings` in `widgetEdits`, above). **With no `Edit in place`
851
+ line, nothing is editable in place** and none of this is copied.
852
+ Never a computed field.
853
+
854
+ ### The table opens the view, and the form returns to it
855
+
856
+ **The table opens the view, and the form returns to it.** The title
857
+ column's link is the way in (a `yes/no` marked `toggle` stays in its
858
+ row). Saving an edit, or cancelling one, goes back to the record's view;
859
+ creating opens the new record's view (the id the create returns);
860
+ cancelling a create goes back to the list. Each navigates with
861
+ `{ replace: true }`, so Back from the view doesn't reopen the form. The
862
+ create and update mutations put the saved record into its detail cache
863
+ (`setQueryData`), so the view shows the save at once, and the delete
864
+ mutation drops it (`removeQueries`), so the view it leaves never
865
+ refetches a record that's gone (`use-widgets.ts`).
866
+
867
+ ### `<SelectValue>` shows the value, not the label
868
+
869
+ **`<SelectValue>` shows the value, not the label.** Base UI renders the
870
+ raw *value*, and `placeholder` only applies when the value is `null`.
871
+ Any `Select` whose "nothing chosen" state is a sentinel rather than
872
+ `null` therefore displays that sentinel on screen unless you pass the
873
+ children function. Two cases, both needing it:
874
+
875
+ - **A toolbar filter**, where "no filter" is `'all'` — copied straight
876
+ from `widgets-table.tsx`: a label constant read by both the trigger and its `<SelectItem>`.
877
+ - **An optional `single choice` field**, which Widget has no example of
878
+ (its `status` is required and its `categoryId` is a combobox). A Base
879
+ UI `Select` item's value cannot be `''`, so the field's own unset
880
+ value is remapped through a sentinel:
881
+
882
+ ```tsx
883
+ const UNSET = '__unset__'
884
+ const UNSET_LABEL = 'Not set' // the plan's "not set" label
885
+ // ...
886
+ <Controller
887
+ control={form.control}
888
+ name="priority"
889
+ render={({ field }) => (
890
+ <Select
891
+ value={field.value === '' ? UNSET : field.value}
892
+ onValueChange={(value) => field.onChange(value === UNSET ? '' : value)}
893
+ >
894
+ <SelectTrigger id="<entity>-priority">
895
+ {/* Without this the trigger reads the literal "__unset__" */}
896
+ <SelectValue>{(value) => (value === UNSET ? UNSET_LABEL : value)}</SelectValue>
897
+ </SelectTrigger>
898
+ <SelectContent>
899
+ <SelectItem value={UNSET}>{UNSET_LABEL}</SelectItem>
900
+ {PRIORITIES.map((option) => (
901
+ <SelectItem key={option} value={option}>{option}</SelectItem>
902
+ ))}
903
+ </SelectContent>
904
+ </Select>
905
+ )}
906
+ />
907
+ ```
908
+
909
+ The zod schema keeps `''` as the unset value and converts it to
910
+ `null` on the way to the wire, the way `widget-schema.ts` already
911
+ handles a blank `assigneeEmail`. Step 8's specs must assert the
912
+ **unset** display, not only a picked one — a select whose enum values
913
+ equal their labels passes either way.
914
+
915
+ ### Choosing how each column looks
916
+
917
+ **Choosing how each column looks.** The plan says what a field *means*,
918
+ not how its cell should render. For most columns plain text is right and
919
+ there is nothing to decide. Where there is:
920
+
921
+ - [`cell-patterns.md`](cell-patterns.md) is the catalogue, each
922
+ pattern with the parts a first attempt gets wrong.
923
+ They are markup to copy, not components to import.
924
+ - If the developer doesn't have a preference, don't pick for them and
925
+ don't guess: follow [`column-options.md`](column-options.md) to build
926
+ a short page of numbered options over the same sample rows, and let
927
+ them choose.
928
+ - Any colour involved: [`design-language.md`](design-language.md). Most
929
+ values should stay grey, and colour is never the only signal.
882
930
 
883
931
  ## How a list opens a record
884
932
 
885
933
  Every list opens its records one of a few ways, and says which on its
886
- `DataTable` with `opens` (4.65), so a change to how the foundation opens
934
+ `DataTable` with `opens`, so a change to how the foundation opens
887
935
  a record reaches every list on the next upgrade. With
888
936
  `uiFoundation({ requireTableOpens: true })` in `eslint.config.js` (the
889
937
  template has it), a `DataTable` without `opens` fails lint. The plan
@@ -925,7 +973,7 @@ plan allows it.
925
973
  <Board renderCard={(item) => <RecordLink to={`/<entity>/${item.id}`}>{item.name}</RecordLink>} … />
926
974
  ```
927
975
 
928
- **A list that isn't the record's parent route** (4.71: the list at
976
+ **A list that isn't the record's parent route** (the list at
929
977
  `/<entity>/list`, the record at `/<entity>/:id`): the route the two share
930
978
  wraps them, with `listPath`. The list's own route has no element (the
931
979
  `list` prop draws it), and every other child is a record. Opened from
@@ -940,7 +988,7 @@ the list, the record is the dialog over it; closing goes back to
940
988
  },
941
989
  ```
942
990
 
943
- **A sub-record over its parent's page** (4.71: a parent's documents,
991
+ **A sub-record over its parent's page** (a parent's documents,
944
992
  `/<parents>/7/<children>/31`): the same dialog one level down. The
945
993
  parent's page is the `list`, the sub-record its child, and
946
994
  `fullPage={false}`, so a reload of the sub-record's address is the dialog
@@ -960,7 +1008,7 @@ the dialog.
960
1008
  { path: '<parents>/:id/edit', element: <<Parent>FormRoute /> }, // a sibling, not a child
961
1009
  ```
962
1010
 
963
- **A new record over its list** (4.82), for a create form of up to about
1011
+ **A new record over its list**, for a create form of up to about
964
1012
  8 fields (a longer one is its own page, `<entity>/new` beside the list as
965
1013
  above): the list's `new` child route, named by `newPath`, is a
966
1014
  `FormDialog` over the list, from the list's New button
@@ -982,8 +1030,8 @@ over the same list, in the form's history entry.
982
1030
  // New<Entity>Route: the form's own fields and react-hook-form, in FormDialog (no `open`).
983
1031
  const created = useNewRecordDialog()
984
1032
  <FormDialog
985
- title="New <entity>"
986
- submitLabel="Add <entity>"
1033
+ title="New <Entity>"
1034
+ submitLabel="Add <Entity>"
987
1035
  onSubmit={form.handleSubmit(async (values) => {
988
1036
  const saved = await create.mutateAsync(values)
989
1037
  created?.openRecord(`/<entity>/${saved.id}`)
@@ -1011,16 +1059,6 @@ const created = useNewRecordDialog()
1011
1059
  other than its list (a link on the home page). With `fullPage={false}`
1012
1060
  there is no page: a deep link or a link from another page opens the
1013
1061
  dialog over its list, at the list's plain address.
1014
- - **The list stays as it was**: mounted underneath, reading the address
1015
- it was opened from, so its search, filters, sort, page and scroll are
1016
- unchanged when the dialog closes.
1017
- - **Closing**: Back, Esc, the backdrop and the dialog's Close all go
1018
- back to the list's entry (over every record opened inside the dialog,
1019
- a linked one included). Focus goes back to the row, on its own link
1020
- when it has one, or the link that opened it.
1021
- - **Open Full Page**, in the dialog's bar (not with `fullPage={false}`),
1022
- swaps the entry for the same address as the full page; Back from there
1023
- is the list.
1024
1062
  - **The view is unchanged.** `EntityView` sees the dialog: its title
1025
1063
  names the dialog (`label` names it while loading or on an error), the
1026
1064
  back link gives way to the dialog's bar, and not found's "Back to …"
@@ -1029,7 +1067,7 @@ const created = useNewRecordDialog()
1029
1067
  `useRecordDialog()` (null on the full page) for its `close`, as a
1030
1068
  Delete should, rather than navigating to the list:
1031
1069
  `onDeleted={() => (dialog ? dialog.close() : navigate('/<entity>'))}`.
1032
- - Specs: the package's own (`e2e/record-dialog.spec.ts`) cover the
1070
+ - Specs: the package's own cover the
1033
1071
  dialog. An app's spec opens a record from the list, checks the
1034
1072
  address, closes it with Escape, and checks the list's filter survived.
1035
1073
 
@@ -1045,19 +1083,19 @@ A record uses the parts it has, in this order:
1045
1083
  - **Header**: the title, edited in place (`titleEdit`); under it a
1046
1084
  one-line summary field, edited in place (`subtitle`: a goal, a
1047
1085
  description); beside it the status as a quick action (a picker saved
1048
- at once), drawn as its `StatusMark` (4.98: icon, colour and word), and
1086
+ at once), drawn as its `StatusMark` (icon, colour and word), and
1049
1087
  other status-like fields as badges, edited in place. A
1050
1088
  record with a face or a mark of its own (a person's avatar, a
1051
- service's logo, a cover) puts it left of all that (`leading`, 4.76).
1052
- `actions` holds the record's own commands in words (Run, New visit),
1089
+ service's logo, a cover) puts it left of all that (`leading`).
1090
+ `actions` holds the record's own commands in words (Run, New Visit),
1053
1091
  then Delete (soft, with Undo) as an `IconAction`, never Edit. Print
1054
1092
  notes is an icon of EntityView's own.
1055
1093
  - **Strip**: the record's key numbers and ratings (`strip`, a
1056
- `KeyStats`, as wide as its numbers since 4.98), each edited in place
1094
+ `KeyStats`, as wide as its numbers), each edited in place
1057
1095
  where it's shown. An inline `EditableValue` there keeps its pencil's room
1058
- at rest (4.115), so nothing moves on hover; an app's own wrapping row of
1096
+ at rest, so nothing moves on hover; an app's own wrapping row of
1059
1097
  inline values passes `keepPencilRoom` for the same.
1060
- - **Sections** (4.98, no right rail): one column. The label/value facts
1098
+ - **Sections** (no right rail): one column. The label/value facts
1061
1099
  are placed `rail`, which makes them the last tab, Details, on a record
1062
1100
  with tabs, and keeps them in the column on one without; the long text
1063
1101
  (notes, a body) is folded by its toggle headings (`foldKey`;
@@ -1066,29 +1104,28 @@ A record uses the parts it has, in this order:
1066
1104
  facts may sit beside the one tab it explains (placed `rail` with that
1067
1105
  `tab`), never free text. Every value edited in place (`edit`), a
1068
1106
  sub-item list included (`editInPlace({ kind: 'list' })`).
1069
- - **Tabs** (4.76), for a main column with **three or more groups of
1107
+ - **Tabs**, for a main column with **three or more groups of
1070
1108
  long content** (the steps, where it's used, the reasoning): a `tab` on
1071
1109
  each main section groups them under a tab list, the selected one in
1072
1110
  `?tab=`. Give each tab that holds records its count (`tabCounts={{
1073
1111
  Updates: updates.length }}`); the bar sticks as the record scrolls,
1074
- with the record's name above it (4.101). Fewer groups stay one scroll, folded by headings. A record's
1112
+ with the record's name above it. Fewer groups stay one scroll, folded by headings. A record's
1075
1113
  Notes stay outside the tabs, above them, unless they are one tab's
1076
1114
  content; the strip never goes in a tab, and the facts are a tab of
1077
1115
  their own (Details, `detailsTab` to name it otherwise).
1078
- - **Facts beside their labels** (`railFields`, `beside` by default since
1079
- 4.81), so the short facts read as a list of pairs rather than a column
1116
+ - **Facts beside their labels** (`railFields`, `beside` by default), so the short facts read as a list of pairs rather than a column
1080
1117
  of labels; keep labels to a word or two.
1081
- - **The facts rail** (4.106, record standard A1): `factsRail` on the
1118
+ - **The facts rail**: `factsRail` on the
1082
1119
  view puts the record's short facts in a 300px column beside the
1083
1120
  record's body where the view has room (60rem: a laptop's page, a record
1084
1121
  dialog), so the page doesn't end 900px in. The strip stays above it at
1085
1122
  full width, and the rail starts level with the first content under the
1086
1123
  strip: the open tab's first section (beside the tab's content, not its
1087
- bar), or the first card when cards come before the tabs (4.108). Beside
1124
+ bar), or the first card when cards come before the tabs. Beside
1088
1125
  the rail the record's cards fill the column up to it, as wide as the
1089
1126
  tab bar (Details too, which elsewhere keeps a 42rem reading width), and
1090
- their rows keep a compact 10rem label so the values get the rest
1091
- (4.112). Only short values go in it,
1127
+ their rows keep a compact 10rem label so the values get the rest.
1128
+ Only short values go in it,
1092
1129
  and the API holds to that: a rail section is `facts`, not `fields`,
1093
1130
  each fact one of a few kinds, never free markup:
1094
1131
 
@@ -1116,7 +1153,7 @@ A record uses the parts it has, in this order:
1116
1153
  nothing isn't drawn. On a phone (or a view under 60rem) the rail's
1117
1154
  sections are back in Details, as rows.
1118
1155
  - `edit` works on a fact as on a field; at rest it's drawn by its kind.
1119
- - **The status first** (4.115): a record's status is the first fact at
1156
+ - **The status first**: a record's status is the first fact at
1120
1157
  the top of the right rail, edited in place there; a status that
1121
1158
  changes only through an action stays read-only, with the action as a
1122
1159
  small button under it and a tooltip saying why. Mark it
@@ -1138,9 +1175,9 @@ A record uses the parts it has, in this order:
1138
1175
  `hint` is an info button after the value, its words in a tooltip on
1139
1176
  hover and keyboard focus, and a line under the value on a touch
1140
1177
  screen. Both are drawn in Details too, where the rail folds.
1141
- - A `badges` item may be `{ label, icon }` (4.115): the icon (a
1178
+ - A `badges` item may be `{ label, icon }`: the icon (a
1142
1179
  component or a node) before the label, in the muted tone. With
1143
- `tone` (4.123: `success`, `warning`, `info`, `destructive`) a label
1180
+ `tone` (`success`, `warning`, `info`, `destructive`) a label
1144
1181
  that is a state ("Pinned", "Overdue") is the outline badge in that
1145
1182
  tone, its icon too; the word still says it. A flag that's set reads
1146
1183
  at a glance this way, edited in place as any badges fact (its `edit`
@@ -1154,11 +1191,11 @@ A record uses the parts it has, in this order:
1154
1191
  { label: 'Flags', kind: 'badges', items: record.flags.map((flag) => FLAG_BADGE[flag]), emptyLabel: 'None',
1155
1192
  edit: editInPlace({ kind: 'multi', value: record.flags, save: (flags) => save({ flags }), control: (props) => <MultiPick options={FLAGS} value={props.value} onValueChange={props.onChange} aria-label={props.label} aria-describedby={props.describedBy} /> }) },
1156
1193
  ```
1157
- - **A rating** (4.117) is `kind: 'rating'`, drawn as the list's cells
1194
+ - **A rating** is `kind: 'rating'`, drawn as the list's cells
1158
1195
  draw it, never as "4 of 5" text: stars (the default) or hearts for a
1159
1196
  score out of `max` (5), the step bar for a quality level. `null` is
1160
1197
  empty (its `emptyLabel`). A score the person gives (my rating) is
1161
- edited in place with **`inPlace.rating`** (4.127): the stars are then
1198
+ edited in place with **`inPlace.rating`**: the stars are then
1162
1199
  the value, a click on one saves it, a second press on the set one
1163
1200
  saves `null`, and an empty one shows five empty stars to click rather
1164
1201
  than its `emptyLabel`. A score that isn't the person's to set (a
@@ -1174,7 +1211,7 @@ A record uses the parts it has, in this order:
1174
1211
 
1175
1212
  A quality level drawn as the step bar is an enum, not a score: edit
1176
1213
  it with `inPlace.select` over its levels.
1177
- - **A yes/no** (4.120) is `kind: 'switch'`, a switch toggled where it
1214
+ - **A yes/no** is `kind: 'switch'`, a switch toggled where it
1178
1215
  is, named by the label, never a two-choice select. Return the save's
1179
1216
  promise: the switch shows the new state while it runs and goes back
1180
1217
  if it fails. `on`/`off` words are optional (both or neither):
@@ -1185,30 +1222,30 @@ A record uses the parts it has, in this order:
1185
1222
  ```
1186
1223
  - **The strip's values** take `info` (a tooltip on an info button) and
1187
1224
  `action` (a small button under the value) as rail facts take `hint`
1188
- and `action` (4.120); a stat's `hint` stays its caption line. A
1225
+ and `action`; a stat's `hint` stays its caption line. A
1189
1226
  header button that needs a short line under it ("12 searches left")
1190
1227
  is wrapped in `<ActionHint hint="…">`. Inline-edited header badges
1191
1228
  keep their pencil's room on their own.
1192
- - **A tiny record** (4.98: a few fields and no notes, like a lookup's
1229
+ - **A tiny record** (a few fields and no notes, like a lookup's
1193
1230
  row) opens as a small card: `RecordDialogRoute look="card"`, usually
1194
1231
  with `fullPage={false}`. A 420px dialog (a sheet on a phone), its
1195
1232
  title, Delete, Open full page and Close on one line, its facts as
1196
- plain rows. The view's `strip` (KeyStats) is left out in the card
1197
- (4.105); `cardStrip` keeps it, and the record's own page still shows it.
1198
- - **Empty fields folded** (`emptyFields="fold"`, 4.81): each card shows
1233
+ plain rows. The view's `strip` (KeyStats) is left out in the card;
1234
+ `cardStrip` keeps it, and the record's own page still shows it.
1235
+ - **Empty fields folded** (`emptyFields="fold"`): each card shows
1199
1236
  what's known, then "N empty" opens the rest, still edited in place.
1200
1237
  - **A few equal things** (a plan's phases, a price at each store, a
1201
- handful of options) are one `EqualItems` (4.93) in a section, one look
1238
+ handful of options) are one `EqualItems` in a section, one look
1202
1239
  per set: `cards` for little to say about each, `table` for things
1203
1240
  compared on the same values, `featured` when one is current or best,
1204
- `panels` when each has several details, `stepper` (4.127) for a
1241
+ `panels` when each has several details, `stepper` for a
1205
1242
  sequence with a current step whose items are looked at one at a time
1206
1243
  (numbered steps picking the one panel shown; design-language.md "A few
1207
1244
  equal things"). The same steps read only, on a list card with a
1208
- caption under the current one ("Day 12"), are `StepTrack` (4.128).
1245
+ caption under the current one ("Day 12"), are `StepTrack`.
1209
1246
  Never hand-made cards, a grid or a stepper of their own. An item
1210
1247
  edited or removed on its own carries its editor as `content` and its
1211
- Edit and Remove as `actions` (4.94), `wide` while the editor is open;
1248
+ Edit and Remove as `actions`, `wide` while the editor is open;
1212
1249
  never an editor put in a field's value.
1213
1250
  - **A big record's own parts** (a drawing, a player, a checklist of
1214
1251
  documents) are sections in the view, not a screen of their own.
@@ -1220,7 +1257,7 @@ place yet; the plan says which, and the gap is raised for the package.
1220
1257
 
1221
1258
  Every create and edit form is an `EntityForm` (a page) or a `FormDialog`
1222
1259
  (up to about eight fields, over its list), and every one has the same
1223
- shape (4.85):
1260
+ shape:
1224
1261
 
1225
1262
  - **One column, short fields sharing a row.** Give each `Field` its
1226
1263
  `size` and the form lays the rows out itself, from the order: `s` a
@@ -1232,21 +1269,17 @@ shape (4.85):
1232
1269
  short one alone where a pairing would read wrong. Under 48rem every
1233
1270
  field takes its own row but two dates or two numbers (`DateField` says
1234
1271
  so itself; a date picker of your own with `kind="date"`). A choice
1235
- (`ChoiceButtons`, found by itself, 4.98, or a `ToggleGroup` that is the
1236
- field's own control, 4.123) shares a row only with another
1272
+ (`ChoiceButtons`, found by itself, or a `ToggleGroup` that is the
1273
+ field's own control) shares a row only with another
1237
1274
  choice, two to a row; on a phone two stay side by side while both
1238
1275
  groups fit, and go one per row when they don't. Never a hand-made
1239
- `sm:grid-cols-2` row. The picked option is in the theme colour (4.105);
1276
+ `sm:grid-cols-2` row. The picked option is in the theme colour;
1240
1277
  a status choice gives each option its `kind`, so its icons are
1241
1278
  `StatusMark`'s in their colours (below).
1242
1279
  - **Order:** required first, the status next, long text last.
1243
1280
  - **Notes** (a Markdown long text: notes, a description, a body) are a
1244
- `RichTextEditor` with `toolbar="floating"` on the form as in place
1245
- (4.127): no bar above the text, the formats over selected words, every
1246
- block in the slash menu ("/"), and Image, Full Screen and (on a narrow
1247
- or touch screen) Indent and Outdent on the small "Editor tools" strip
1248
- while it has focus. On a phone the row pinned to the keyboard carries
1249
- them, Image included, at 40px. Give it the app's `upload` (the one
1281
+ `RichTextEditor` with `toolbar="floating"` on the form as in place.
1282
+ Give it the app's `upload` (the one
1250
1283
  `ImageField` takes) for the Image button and for pasted and dropped
1251
1284
  pictures, which go in as `![](url)`; a refused or failed picture says
1252
1285
  why in a toast. Without `upload` there's no Image button, and a picture
@@ -1263,28 +1296,27 @@ shape (4.85):
1263
1296
  - **Messages say what to do**, in the app's voice: "Give it a title",
1264
1297
  "Enter a full address, starting https://", never "Title is required".
1265
1298
  - **A status** is an `OptionSelect` with the same `render` (its
1266
- `StatusMark`, 4.98) as its cell and the record: `inPlace.select`'s
1299
+ `StatusMark`) as its cell and the record: `inPlace.select`'s
1267
1300
  `{ value, label }` options. A status of two to four is `ChoiceButtons`
1268
- (4.105) with each option's `kind`, its status kind:
1301
+ with each option's `kind`, its status kind:
1269
1302
  `{ value: 'done', label: 'Done', kind: 'done' }` draws the kind's icon
1270
1303
  in its colour before the word, the same as the record's `StatusMark`
1271
1304
  (`icon` overrides the kind's icon; an `icon` with no `kind` stays
1272
1305
  uncoloured). Map the enum to kinds once and use that map for both.
1273
1306
  A status of five or more is an `OptionSelect` with the same `kind` on
1274
- each option (4.109): the kind's icon in its colour before the words, on
1307
+ each option: the kind's icon in its colour before the words, on
1275
1308
  the trigger and on each item in its list (`inPlace.select` passes them
1276
1309
  through). With `kind`, leave out a `render` that draws its own icon
1277
1310
  (a `StatusMark`), or the option shows two.
1278
1311
  A status picked several at once (a multi-value status filter, a
1279
- "statuses" field) is a `MultiChoice` given those same options (4.130):
1312
+ "statuses" field) is a `MultiChoice` given those same options:
1280
1313
  `options={STATUS_OPTIONS}` in place of bare values, so each option's
1281
1314
  kind icon (or `icon`) is drawn before its words in the list, on its
1282
1315
  chip, and on a filter's summary ("Status: ● Active +1"), and its
1283
1316
  `label` names it with no `getLabel`.
1284
- - **The controls** (4.88): a choice of two to four short options is
1317
+ - **The controls**: a choice of two to four short options is
1285
1318
  `ChoiceButtons` (`inPlace.choice` in place), five or more an
1286
- `OptionSelect`. A date is `DateField`, typed ("3/14", "Mar 14",
1287
- "today") with the calendar on its button. A single reference is
1319
+ `OptionSelect`. A date is `DateField`. A single reference is
1288
1320
  `ReferenceCombobox` (`inPlace.reference` in place), several are
1289
1321
  `MultiReference`, and a set the app loads whole (tags, a few dozen
1290
1322
  records from its list query) is `MultiPick`, whose chips wrap and which
@@ -1303,12 +1335,12 @@ shape (4.85):
1303
1335
  "2 to fix". Both come free; the form draws a failed save as a `Notice`
1304
1336
  with Try Again in its bar, which sticks to the window's bottom on a long
1305
1337
  form.
1306
- - **The words:** "New book", "Add book" (the word Add on every create
1338
+ - **The words:** "New Book", "Add Book" (the word Add on every create
1307
1339
  form), and the toast after it "Added The Long Walk".
1308
1340
 
1309
1341
  ### Dialogs
1310
1342
 
1311
- Every dialog is one of three widths, `DialogContent`'s `size` (4.82):
1343
+ Every dialog is one of three widths, `DialogContent`'s `size`:
1312
1344
 
1313
1345
  | `size` | Width | On a phone (under 48rem) | Use it for |
1314
1346
  | --- | --- | --- | --- |
@@ -1317,7 +1349,7 @@ Every dialog is one of three widths, `DialogContent`'s `size` (4.82):
1317
1349
  | `record` | 1,120px | full width, with a 1rem margin round it | a record over its list (`RecordDialogRoute`, which is this size) |
1318
1350
 
1319
1351
  A tiny record (a few fields, no notes) opens in the `confirm` width
1320
- instead, as a small card: `RecordDialogRoute look="card"` (4.98).
1352
+ instead, as a small card: `RecordDialogRoute look="card"`.
1321
1353
 
1322
1354
  - **A dialog's title and buttons are Title Case** ("New Book", "Keep
1323
1355
  Editing"); a question or a message in it is a sentence ("Discard your
@@ -1343,8 +1375,8 @@ instead, as a small card: `RecordDialogRoute look="card"` (4.98).
1343
1375
 
1344
1376
  ### Toasts and feedback
1345
1377
 
1346
- What the app says after something happens (the dialogs and feedback
1347
- standard, 4.90). The rule: **a toast is for what happened out of
1378
+ What the app says after something happens.
1379
+ The rule: **a toast is for what happened out of
1348
1380
  sight.** What happened where the person is looking says so there.
1349
1381
 
1350
1382
  | What happened | What says so |
@@ -1369,10 +1401,10 @@ sight.** What happened where the person is looking says so there.
1369
1401
  `open`/`onOpenChange`, opened by a `DataTable` `rowActions` entry's
1370
1402
  `onSelect` (a row's ⋯ menu). `verb="Retire"` for a retire.
1371
1403
  Never a delete without a confirm, never a hand-written dialog. Its icon
1372
- is named "Delete <name>" (4.123), so several on one page (a record's,
1404
+ is named "Delete <name>", so several on one page (a record's,
1373
1405
  each of its rows') are told apart; its tooltip says "Delete". A test
1374
1406
  finds one by `getByRole('button', { name: 'Delete The Long Walk' })`.
1375
- - **A delete that asks a reason: `DeleteAction reason`** (4.96). One
1407
+ - **A delete that asks a reason: `DeleteAction reason`**. One
1376
1408
  optional field between the sentence and the buttons, a "Why" box:
1377
1409
  `reason={{ label: 'Why remove it?', hint: 'Kept with its history.' }}`
1378
1410
  and `onDelete={(why) => remove({ id, reason: why })}`, `why` trimmed
@@ -1391,12 +1423,7 @@ sight.** What happened where the person is looking says so there.
1391
1423
  `FormDialog` opened from a page), the toast says "Added The Long Walk"
1392
1424
  with an **Open** link to the new record; never a hand-built sonner
1393
1425
  toast. `open` is a path (anything `Link`'s `to` takes) or
1394
- `{ to, label }` for another word ("View"). It is a real link, named
1395
- "Open The Long Walk" for a screen reader, reached from the keyboard
1396
- (Alt+T to the toasts, then Tab), and closes the toast as it goes; the
1397
- toast keeps its 4 seconds. With `undo` too, both show, Open first. A
1398
- create that lands on the record's own
1399
- page doesn't need it: the person is already there.
1426
+ `{ to, label }` for another word ("View"). With `undo` too, both show, Open first.
1400
1427
  - **An error stays beside what failed**: `const save = useAction(mutation)`,
1401
1428
  `save.run(…)` on the button (`disabled={save.pending}`, a `Spinner` in
1402
1429
  it), `<ActionError action={save} />` next to it. Never
@@ -1409,15 +1436,9 @@ sight.** What happened where the person is looking says so there.
1409
1436
 
1410
1437
  ## What not to copy
1411
1438
 
1412
- - `widget-quick-actions.tsx`, its `quick action: …` specs and
1413
- `useSaveWidgetField` unless the plan has a `Quick actions` line (or,
1414
- for the hook, a `yes/no` marked `toggle`). Copy only the controls for
1415
- the fields the line names: a plan naming only its yes/no gets the
1416
- switch, and the checklist's checkboxes are left out.
1417
- - `widgetEdits`, `useEditWidgetField`, `widget-edit-in-place.spec.ts` and
1418
- the in-place a11y block unless the plan has an `Edit in place` line,
1419
- and then only for the fields it names.
1420
-
1439
+ - Quick actions and editing in place (their files, hooks, specs and the
1440
+ in-place a11y block) unless the plan has the line, and then only for
1441
+ the fields it names (step 6).
1421
1442
  - `width="full"` on `DataTable` unless the plan's List screen says
1422
1443
  `Width: full` (`content`, the default, is right for almost every list).
1423
1444
  - The saved-views row in `widgets-table.tsx` (`VIEWS`, the "Saved views"
@@ -1426,23 +1447,21 @@ sight.** What happened where the person is looking says so there.
1426
1447
  takes the views, `activeView` says which one the filters are, and that
1427
1448
  view's `columns` go to `DataTable`'s `visibleColumns` (the table's own
1428
1449
  default list when no view is active, or `undefined` for every column).
1429
- Views fill the filters (4.105): write each view's whole meaning in its
1450
+ Views fill the filters: write each view's whole meaning in its
1430
1451
  `filters` and `multiFilters` (a "Current" view names its statuses, never
1431
1452
  `{}` with the server's default doing the rest), name the one the list
1432
1453
  opens on with `defaultView`, and put what no control can show (a
1433
1454
  computed "overdue") in the view's `rule` (cell-patterns.md "Saved views
1434
- are pills"). The default view's `sort` is its plain address's too
1435
- (4.123): pressing it writes no `?sort=`, and the rows keep that order. A view the plan says
1455
+ are pills"). The default view's `sort` is its plain address's too:
1456
+ pressing it writes no `?sort=`, and the rows keep that order. A view the plan says
1436
1457
  shows a count gets `count` from the app's own query, passed to
1437
1458
  `DataTable`'s `views` (cell-patterns.md "A view can carry a count").
1438
1459
  - `src/api/gateway/widgets.ts`, `src/mocks/data.ts`, `src/mocks/handlers.ts`
1439
1460
  are demo-domain content — write the entity's own versions rather than
1440
1461
  adapting these by find-and-replace.
1441
1462
  - The composites (`DataTable`, `EntityForm`, `EntityView`, `Markdown`,
1442
- `ErrorState`, `AppShell`) are the foundation's and shared by every app. If a new entity needs a
1443
- capability they don't have (a new field-type widget, say), don't copy
1444
- one into `src/` to change it: raise it for the foundation (AGENTS.md
1445
- "Changing the Foundation") and build the screen once the release ships.
1463
+ `ErrorState`, `AppShell`): never copied into `src/` to change one
1464
+ (AGENTS.md "Hard Rules" and "Changing the Foundation").
1446
1465
 
1447
1466
  ## After a commit, in the backend
1448
1467
 
@@ -1466,16 +1485,11 @@ asyncio is a `MissingGreenlet` and a 500.
1466
1485
  ## Saves that don't overwrite
1467
1486
 
1468
1487
  A record edited in more than one place (a laptop tab, a phone, an AI chat
1469
- through MCP) needs a version, or the last save wins: a phone left open on
1470
- a note, typed into after the laptop changed it, replaces the laptop's
1471
- work. The fix is optimistic concurrency, the same for every entity:
1488
+ through MCP) needs a version, or the last save wins. The fix is optimistic concurrency, the same for every entity:
1472
1489
 
1473
1490
  - **The record carries its version: `updatedAt`** (`updated_at`, a
1474
1491
  `timestamptz` every write sets with `foundation_backend.versions.touch()`,
1475
- never null, commented in its migration). Not a counter or an ETag: most
1476
- tables already have one, a person or an AI reading the row knows what it
1477
- means, and it rides in the JSON body, where an MCP tool call can send it
1478
- back too (an `If-Match` header can't reach a chat). It's compared for
1492
+ never null, commented in its migration). It's compared for
1479
1493
  equality, never ordered, so clocks don't matter.
1480
1494
  - **An update may send the version it was built on: `baseUpdatedAt`**, an
1481
1495
  optional field of `<Entity>Update` that isn't a column. The router locks
@@ -1523,9 +1537,9 @@ work. The fix is optimistic concurrency, the same for every entity:
1523
1537
  `baseUpdatedAt`, and a 409 comes back as a refusal that says to fetch
1524
1538
  the record again. `edit_text` is safe without it (its `old` text must
1525
1539
  still be there).
1526
- - **Copy:** `template/backend/app/routers/widgets.py` (`update_widget`),
1540
+ - **Copy:** `backend/app/routers/widgets.py` (`update_widget`),
1527
1541
  migration `0017_widget_updated_at.py`, `WidgetOut.updated_at` and
1528
- `WidgetUpdate.base_updated_at` in `app/schemas.py`, the PATCH mock in
1542
+ `WidgetUpdate.base_updated_at` in `backend/app/schemas.py`, the PATCH mock in
1529
1543
  `src/mocks/handlers.ts`, `withVersion` in `use-widgets.ts`,
1530
1544
  `useFormVersion` in `widget-form.tsx`, and the "two writers" specs in
1531
1545
  `e2e/widget-edit-in-place.spec.ts` and `e2e/widget-form.spec.ts`.
@@ -1541,7 +1555,7 @@ soft one; copy it.
1541
1555
  - *Model and migration:* a nullable `deleted_at timestamptz`, commented
1542
1556
  in the migration (null means live; set by DELETE, cleared by restore).
1543
1557
  It is never on the wire. `backend/app/models.py`,
1544
- `migrations/versions/0012_widget_soft_delete.py`.
1558
+ `backend/migrations/versions/0012_widget_soft_delete.py`.
1545
1559
  - *Router:* `DELETE /<entity>/{id}` sets `deleted_at`; `POST
1546
1560
  /<entity>/{id}/restore` clears it and returns the record (404 unless
1547
1561
  it is deleted); the list leaves deleted records out unless asked
@@ -1551,15 +1565,14 @@ soft one; copy it.
1551
1565
  - *Contract, gateway, mocks:* `restore<Entity>` in `openapi.yaml`, the
1552
1566
  gateway's `restore<Entity>`, a `useRestore<Entity>Mutation`, and mocks
1553
1567
  that move the record aside (`deletedWidgets` in `src/mocks/data.ts`).
1554
- - *Screens:* `DeleteAction kind="soft"`: the dialog says it can be
1555
- undone, and the toast "Deleted <name>" carries an Undo that restores
1556
- (`onRestore`; `delete-widget-action.tsx`).
1568
+ - *Screens:* `DeleteAction kind="soft"` with `onRestore`
1569
+ (`delete-widget-action.tsx`; "Toasts and feedback").
1557
1570
  - *MCP:* give the entity's `McpEntity` `delete` and `restore` (and add
1558
1571
  `deleted` to its filters). Chats then get `delete(url)`, marked
1559
1572
  destructive so the chat asks before each call, and `restore(url)`.
1560
1573
  Both are logged with the whole record.
1561
1574
  - **Hard-deleted:** `DELETE` removes the row. The screens use
1562
- `DeleteAction kind="hard"`: "This can't be undone.", and no Undo. Give the entity no `delete`
1575
+ `DeleteAction kind="hard"` ("Toasts and feedback"). Give the entity no `delete`
1563
1576
  in `mcp_entities.py`: a chat that read planted instructions would
1564
1577
  destroy data that only a backup returns.
1565
1578
 
@@ -1568,9 +1581,7 @@ soft one; copy it.
1568
1581
  Some fields the API takes on create and update are for a script, not for
1569
1582
  the people or chats using the app: an importer that runs again and again
1570
1583
  stores each record's id in the source it came from, so a re-run finds the
1571
- record even after it's renamed. The API has to accept that id, for the
1572
- importer. A chat that changed or cleared it would break the matching, and
1573
- the next run would create the record a second time.
1584
+ record even after it's renamed. A chat that changed or cleared it would break the matching.
1574
1585
 
1575
1586
  - *MCP:* list the field's wire name in the entity's `McpEntity`
1576
1587
  `script_only` (`script_only=("sourceId",)`). Chats still read it
@@ -1600,7 +1611,7 @@ entity with no group is searched only when no group is given.
1600
1611
 
1601
1612
  ## What a chat is told about an entity
1602
1613
 
1603
- Four more things an app sets for AI chats (4.71), each in
1614
+ Four more things an app sets for AI chats, each in
1604
1615
  `backend/app/mcp_entities.py`:
1605
1616
 
1606
1617
  - **`description`** on the `McpEntity`: what the entity is, in a sentence
@@ -1615,7 +1626,7 @@ Four more things an app sets for AI chats (4.71), each in
1615
1626
  end. It saves and logs as `update` does, so a long note isn't sent back
1616
1627
  whole to change a line. A table's widths comment (design-language.md
1617
1628
  "Written text (notes)") is hidden from every read answer and kept
1618
- in what's stored, so an edit never drops it (4.94); `search` leaves
1629
+ in what's stored, so an edit never drops it; `search` leaves
1619
1630
  out a record whose only match is inside it. Each must be a text field of `update_schema`
1620
1631
  and not `script_only`; the backend refuses to start otherwise.
1621
1632
  - **The server's instructions** a chat gets when it connects:
@@ -1648,7 +1659,7 @@ An app put behind an identity-aware proxy that has its own sign-in
1648
1659
  (Cloudflare Access is the usual one; an OAuth proxy or a VPN gateway's
1649
1660
  portal works the same way) can outlive that sign-in: the page stays open,
1650
1661
  the proxy's session lapses, and the next request gets the proxy's answer
1651
- instead of the app's. The foundation handles it (4.107), with nothing for
1662
+ instead of the app's. The foundation handles it, with nothing for
1652
1663
  the app to write:
1653
1664
 
1654
1665
  - **The request asks for JSON as a script.** `safeFetch` sends
@@ -1676,6 +1687,3 @@ the app to write:
1676
1687
  proxy isn't part of the contract. `proxyAuthError()` (from
1677
1688
  `@tristan2828/ui-foundation/gateway`) is the error itself, for a mock or
1678
1689
  a test of a screen's state.
1679
- - **On the proxy's side**, nothing is required. Where it offers a 401 for
1680
- scripts instead of a redirect (Cloudflare Access does for requests with
1681
- `X-Requested-With`), either answer works.