@protobase/cli 0.89.0 → 0.90.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.
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "0.89.0";
2
+ var version = "0.90.0";
3
3
  //#endregion
4
4
  export { version };
@@ -1,4 +1,5 @@
1
1
  import { all, any, anyOf, compare, configFilter, configSort, isTrue, sortText } from "./shape-filters.js";
2
+ import { threadSort } from "@protobase/layout";
2
3
  import { isGroupChart, layoutItems, viewOfList } from "@protobase/schema/internal";
3
4
  //#region src/doctor/view-shapes.ts
4
5
  const numberTypes = [
@@ -127,6 +128,21 @@ const recordChartShapes = (item, owner, models) => {
127
128
  }
128
129
  }];
129
130
  };
131
+ const threadShapes = (item, owner, models) => {
132
+ const target = models[item.resource];
133
+ const field = target?.fields[item.field];
134
+ if (!target || !field || !target.fields[item.time]) return [];
135
+ const sort = configSort(target, threadSort(item.time));
136
+ return [{
137
+ resource: target.name,
138
+ request: request(target.name, `${field.name} = …`, sort),
139
+ from: `thread "${item.title}" on the ${owner} record page`,
140
+ query: {
141
+ filter: compare(field),
142
+ ...sort && { sort }
143
+ }
144
+ }];
145
+ };
130
146
  const displayShapes = (model, view, models) => (view.list?.displays ?? []).flatMap((display) => {
131
147
  if (display.kind === "map") {
132
148
  const latitude = model.fields[display.latitude];
@@ -261,7 +277,7 @@ const listShapes = (model, view, list, models) => [
261
277
  ];
262
278
  /**
263
279
  * The reads a view's pages make: its list in its order, the filter widgets and their counts, its chart per value, its displays' maps,
264
- * board columns and photos, the records of its related sections and charts and the photos of its galleries, the recent records in the sidebar, a saved search's new records and the records sorted by hand.
280
+ * board columns and photos, the records of its related sections, charts and conversations and the photos of its galleries, the recent records in the sidebar, a saved search's new records and the records sorted by hand.
265
281
  */
266
282
  const viewShapes = (view, models) => {
267
283
  const model = models[view.resource];
@@ -270,7 +286,7 @@ const viewShapes = (view, models) => {
270
286
  return [
271
287
  ...listShapes(model, view, list, models),
272
288
  ...(view.lists ?? []).flatMap((named) => listShapes(model, viewOfList(view, named.name), `${list} "${named.name}"`, models)),
273
- ...layoutItems(view.layout).flatMap((item) => item.kind === "related" ? relatedShapes(item, model.name, models) : item.kind === "gallery" ? galleryShapes(item, model.name, models) : item.kind === "chart" ? recordChartShapes(item, model.name, models) : []),
289
+ ...layoutItems(view.layout).flatMap((item) => item.kind === "related" ? relatedShapes(item, model.name, models) : item.kind === "gallery" ? galleryShapes(item, model.name, models) : item.kind === "chart" ? recordChartShapes(item, model.name, models) : item.kind === "thread" ? threadShapes(item, model.name, models) : []),
274
290
  ...recentShapes(model, view),
275
291
  ...searchesShapes(view, models),
276
292
  ...handOrderShapes(model, view, list, models)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@protobase/cli",
3
- "version": "0.89.0",
3
+ "version": "0.90.0",
4
4
  "description": "The protobase command: scaffold, doctor, dev, build and serve a Protobase project.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -43,13 +43,13 @@
43
43
  "dependencies": {
44
44
  "@better-auth/core": "^1.7.12",
45
45
  "@hono/node-server": "^2.1.3",
46
- "@protobase/config": "0.89.0",
47
- "@protobase/layout": "0.89.0",
48
- "@protobase/query": "0.89.0",
49
- "@protobase/schema": "0.89.0",
50
- "@protobase/server": "0.89.0",
51
- "@protobase/ui": "0.89.0",
52
- "@protobase/workflows": "0.89.0",
46
+ "@protobase/config": "0.90.0",
47
+ "@protobase/layout": "0.90.0",
48
+ "@protobase/query": "0.90.0",
49
+ "@protobase/schema": "0.90.0",
50
+ "@protobase/server": "0.90.0",
51
+ "@protobase/ui": "0.90.0",
52
+ "@protobase/workflows": "0.90.0",
53
53
  "@react-email/render": "^2.1.0",
54
54
  "@scalar/hono-api-reference": "^0.12.10",
55
55
  "@sentry/vite-plugin": "^11.10.0",
@@ -13,6 +13,7 @@ Pages of your own, built from blocks in a JSX layout.
13
13
  - [Layout blocks](../reference/blocks.md#layout): Pages, responsive grids, cards and links.
14
14
  - [Full-width pages](../reference/blocks.md#page): A page fills the whole area beside the sidebar instead of a centred column, for a dashboard with many blocks.
15
15
  - [Data blocks](../reference/blocks.md#data): Counts, tables, single records, rows of cards, field values and progress bars.
16
+ - [Row buttons](../reference/blocks.md#row-buttons): A table's rows carry a button to an address their fields name, such as a task's tab, labelled by a field of the row, such as its next step.
16
17
  - [Record rows](../reference/blocks.md#recordrow): A sideways row of cards for a filter, favorites or saved searches, with a count and new-record marks.
17
18
  - [Record cards](../reference/blocks.md#recordcards): Full-width cards with fields and buttons, stacked or in a carousel.
18
19
  - [Chart block](../reference/blocks.md#chart): Counts, sums or averages by value or by date, as bars, lines or a donut, and over time split by a second field.
@@ -4,7 +4,7 @@
4
4
 
5
5
  The page of one record, with its sections, related records, galleries, charts and editing.
6
6
 
7
- - [Record page layout](../reference/ui-config.md#the-record-page): Sections, a summary sidebar, related tables, maps, charts, galleries, history, comments and your own components.
7
+ - [Record page layout](../reference/ui-config.md#the-record-page): Sections, a summary sidebar, related tables, maps, charts, galleries, history, comments, conversations and your own components.
8
8
  - [Full-width record pages](../reference/ui-config.md#page-width): A view's record pages and create form fill the whole area beside the sidebar instead of a centred column, with the sidebar cards still beside the sections.
9
9
  - [Focus pages](../reference/ui-config.md#focus-pages) (beta): A record whose page is one big surface, such as a graph or a board, fills the page under a thin bar with its Save, actions and panels, its form a link away.
10
10
  - [A create address that opens a page](../reference/ui-config.md#focus-pages) (beta): `.createOpens(to)` sends a resource's create address to a page in place of its form, such as a record's focus page with a panel open, filled from the address's values.
@@ -25,8 +25,9 @@ The page of one record, with its sections, related records, galleries, charts an
25
25
  - [Help while editing](../reference/ui-config.md#help-while-editing): Help lines meant for whoever changes a record show only on its form.
26
26
  - [Conditional sections](../reference/ui-config.md#form-and-read-view): Sections and fields show only while editing, only while reading, or only when a condition on the record holds.
27
27
  - [Galleries](../reference/ui-config.md#galleries): A record's photos show as tiles that open a full-screen lightbox, with keyboard and swipe navigation.
28
- - [Related records](../reference/ui-config.md#related-records): Every record page shows how many records point at it, and can list related records, also through a join resource, as a table, another display or cards with buttons.
28
+ - [Related records](../reference/ui-config.md#related-records): Every record page shows how many records point at it, and can list related records, also through a join resource, as a table, another display or cards with buttons, each row or card with a button to an address its fields name.
29
29
  - [Record lines](../reference/ui-config.md#record-lines): The related table a record's view marks as its lines, such as an invoice's, shows all of them on its page, where you edit, add, remove and reorder them, and Save writes the record and its lines together.
30
+ - [Conversations](../reference/ui-config.md#conversations): A record page holds a chat about the record, such as a task's, with its messages in markdown and a box that sends one, declared in its layout with no component of the app's own.
30
31
  - [Charts of samples](../reference/ui-config.md#charts-of-related-records): A record page graphs numeric samples over the last hour, day or week, such as a server's CPU use.
31
32
  - [Fresh data on return](../reference/ui-config.md#the-record-page): Records and lists reload when the browser tab is focused again, keeping unsaved edits.
32
33
  - [Safe deletes](../reference/ui-config.md#deleting-a-record): Deleting asks first, or offers Undo for a soft delete, offers a review when the record changed since it was opened, and names the records that still point at it.
@@ -207,6 +207,7 @@ The first records of a list, drawn the way the resource's list page draws them:
207
207
  | --- | --- |
208
208
  | `resource`, `filter`, `sort` | Which records, in which order. `resource` is required; `sort` defaults to the list's. |
209
209
  | `columns` | Field names for the table; default the view's list columns. |
210
+ | `button` | A [button on each row](#row-buttons) to an address the row's fields name. |
210
211
  | `limit` | How many records it shows; default 10. It has no pages: the rest are in the list. Before 0.13 this was `pageSize`, rows per page; rename it. |
211
212
  | `display` | The display it opens in, such as `cards`; default the list's. |
212
213
  | `title`, `description`, `actions` | The heading. |
@@ -217,6 +218,22 @@ The first records of a list, drawn the way the resource's list page draws them:
217
218
  <Table title="Overdue invoices" resource="invoices" filter="status = 'overdue'" sort="issued_at" columns={['number', 'company_id', 'due_at', 'total']} limit={5} empty="Nothing is overdue." />
218
219
  ```
219
220
 
221
+ #### Row buttons
222
+
223
+ `button: { label, to }` adds a last column with a button on each row: a link, drawn as a button, to `to`, an [address](layouts.md#addresses) in the app, such as a record on one of its [tabs](ui-config.md#tabs). `{field}` in the address or the label is replaced by the row's value, the label's as the record page shows it (an enum value by its label), so each row can name its own next step. A row with no value for a field the button names shows no button. The button is checked when the config loads, and `/meta` gives it, on the block or the related section, to callers who can read the fields it names and follow its address, and leaves it out for the others. A [related section](ui-config.md#related-records) takes the same `button`, on its table's rows or its cards.
224
+
225
+ ```tsx
226
+ <Table
227
+ title="Waiting on you"
228
+ resource="holds"
229
+ filter="state = 'open'"
230
+ columns={['reason', 'task_id']}
231
+ button={{ label: '{verb}', to: { kind: 'record', resource: 'tasks', key: '{task_id}', tab: 'Review' } }}
232
+ />
233
+ ```
234
+
235
+ <gap>A row button cannot show when the table switches to a list display such as cards because drawing it on a display is not implemented.</gap>
236
+
220
237
  ### RecordCard
221
238
 
222
239
  One record and what is inside it: the one `recordKey` names (the key as the record's URL has it), else the first that matches `filter` in `sort` order. Its children and its heading `actions` work on that record.
@@ -341,7 +358,7 @@ Each value takes its colour from the view's `valueColors`, else an enum value's
341
358
 
342
359
  ## Conversation
343
360
 
344
- A chat declared in the layout like any other block: a `Thread` lists the messages of a resource and a `Composer` beneath it sends one, so [`/meta`](api.md#meta-and-openapi-per-caller) describes the conversation and every client can draw it, with no component of the app's own.
361
+ A chat declared in the layout like any other block: a `Thread` lists the messages of a resource and a `Composer` beneath it sends one, so [`/meta`](api.md#meta-and-openapi-per-caller) describes the conversation and every client can draw it, with no component of the app's own. On a record page, [`l.thread` and `l.composer`](ui-config.md#conversations) hold the conversation of that record.
345
362
 
346
363
  ```tsx
347
364
  <Card title="General">
@@ -361,8 +378,8 @@ The latest messages that match `filter`, oldest first, each under its sender's n
361
378
  | `resource`, `filter` | Which messages. `resource` is required. |
362
379
  | `sender` | Who wrote each message: a relation, named as the record it points at, or a text field. Required. |
363
380
  | `time` | When each was sent: a date or timestamp field the API can sort by, which orders them. Required. |
364
- | `text` | The message. Required. |
365
- | `limit` | How many of the latest it shows at first, and how many each **Load earlier messages** adds; default 50. |
381
+ | `text` | The message; shown rendered when the message resource's view marks it [`.markdown()`](ui-config.md#names-and-columns). Required. |
382
+ | `limit` | How many of the latest it shows at first, and how many each **Load earlier messages** adds: 1 to 500, the API's largest page; default 50. |
366
383
  | `title`, `description`, `actions` | The heading; no card is drawn around the thread, so it can sit in a `Card` with its composer. |
367
384
  | `empty` | Text while there are no messages. |
368
385
  | `span` | Width in a grid. |
@@ -105,7 +105,7 @@ Field hints:
105
105
  | `.confirm(question)` | Asks `question` before a person changes the value in a form or a list cell, and Cancel keeps it. See [Confirming a change](#confirming-a-change). |
106
106
  | `.format(format)` | `badge` shows statuses as coloured badges, `code` sets identifiers in monospace, as the list's identifier column too, `percent` adds a % sign, and `signed` shows a whole number in a list with its sign, green above zero and red below, such as a stock change of `+12` or `−3`; it needs an integer field. On a text field, `email`, `phone` and `url` show the value as a link that writes to it (`mailto:`), calls it (`tel:`, its digits and a leading +) or opens it in a new tab (only an `http` or `https` address; anything else stays text), on the record page, in its sidebar and in the list's cells but the title's, which links to the record; forms edit it in an email, phone or web address input, which brings up the keyboard for it on a mobile screen and offers the browser's autofill. Another field type with one of them stops the server at startup. `relative` on a timestamp shows it as "5 minutes ago" or "in 2 hours" in lists and on the record page, with the exact time on hover; `absolute` and `compact` are accepted and carried in `/meta` for apps that render their own lists. <gap>The admin does not use the `absolute` and `compact` formats yet.</gap> |
107
107
  | `.multiline()` | A text of several lines, such as a description: forms edit it in a box that grows with the text, so the page scrolls rather than the box, and the record page's sections, a page's field blocks and a card's subtitle keep its line breaks (a card shows the first three lines); the record's sidebar shows it on one line. On the record page and the create form it takes the whole width of its section. Only a text field takes it; the list's table shows the text on one line. |
108
- | `.markdown()` | Markdown, such as a task's notes: forms edit its source in a box that grows with it, with a Write and Preview switch above it, and store it exactly as typed. The record page's sections and a page's field blocks show it rendered as GitHub does, line breaks kept; raw HTML shows as text, links and images keep only http(s), mailto, tel and relative addresses, and links open in a new tab. A card's subtitle shows its first three lines rendered, its links as text; the list's table, the record's sidebar and a card's other lines show its text on one line without the marks. On the record page and the create form it takes the whole width of its section. Only a text field takes it, and the renderer loads with the first markdown shown. |
108
+ | `.markdown()` | Markdown, such as a task's notes: forms edit its source in a box that grows with it, with a Write and Preview switch above it, and store it exactly as typed. The record page's sections, a page's field blocks and a conversation's messages show it rendered as GitHub does, line breaks kept; raw HTML shows as text, links and images keep only http(s), mailto, tel and relative addresses, and links open in a new tab. A card's subtitle shows its first three lines rendered, its links as text; the list's table, the record's sidebar and a card's other lines show its text on one line without the marks. On the record page and the create form it takes the whole width of its section. Only a text field takes it, and the renderer loads with the first markdown shown. |
109
109
  | `.prefix(text)`, `.suffix(text)`, `.decimals(n)` | Text around a number and its decimals: `€` and `2` show `€1,234.50`, `.suffix(' m²')` shows `120 m²`. They show wherever the number does: records, cards, table cells, forms and the range filter. A prefix is plain text, so a list does not show `€` as money; `.currency()` does. |
110
110
  | `.currency(code)` | The currency a decimal is an amount of, as an ISO 4217 code such as `EUR`: the list shows it as money in that currency, in its table and its range filter. See [Value tones and currencies](#value-tones-and-currencies). |
111
111
  | `.icon(name)` | An icon before the value on a card's meta row: one of the names [actions](layouts.md#named-actions) take, such as `bed`, `calendar` or `cpu`, and above the value in a section of [key facts](#key-facts). Nowhere else shows it. |
@@ -662,6 +662,8 @@ export const repairsView = filtered
662
662
  | `l.custom(Component, { title?, props?, sidebar?, when?, fallback? })` | A [custom component](custom-components.md#record-sections) where it is listed: in the main column under `title`, or with `sidebar: true` as a sidebar card. `fallback` shows in its place where it cannot be drawn. |
663
663
  | `l.map(title, { latitude, longitude, zoom?, sidebar?, when? })` | A map with a pin at the record's position, in the main column or with `sidebar: true` as a sidebar card. See [Maps](#maps). |
664
664
  | `l.chart(title, { resource, field, at, series, range?, help?, when? })` | Line graphs of numbers of the records that point at this one, such as a machine's samples, over the last hour, day or week. See [Charts of related records](#charts-of-related-records). |
665
+ | `l.thread(title, { resource, field, sender, time, text, limit?, empty?, help?, when? })` | The record's conversation: the latest messages that point at it, oldest first, under each sender's name and time. See [Conversations](#conversations). |
666
+ | `l.composer({ resource, field, text, placeholder?, when? })` | A box that sends a message about the record, which the thread then shows. See [Conversations](#conversations). |
665
667
  | `l.gallery(title, { image?, photos?, when? })` | The record's photos as tiles, opening a lightbox. See [Galleries](#galleries). |
666
668
  | `l.history(title?, { limit?, when? })` | The record's changes, newest first, with who made each and the fields before and after; needs `.history()` on the resource, and a view without a layout shows it last by itself. See [Record history](history.md#on-the-record-page). |
667
669
  | `l.comments(title?, { when? })` | The record's comments, oldest first, with a box to write one that @mentions people; needs `.comments()` on the resource, and a view without a layout shows it last by itself. See [Record comments](comments.md#on-the-record-page). |
@@ -953,6 +955,7 @@ Without any configuration, the record page's rail has a **Related records** card
953
955
  | `columns` | Fields of `resource`, through relations too (`unit_id.property_id`); default the view's list columns without `field`. The first links to the record a row opens. With `presentation: 'cards'`, the fields each card shows. |
954
956
  | `presentation` | `'cards'` shows the records as [cards](#related-records-as-cards) instead of the table or display. |
955
957
  | `actions` | Named actions of `resource`'s view, by name, as buttons on each card; only with `presentation: 'cards'`. |
958
+ | `button` | `{ label, to }`: a [button on each row](blocks.md#row-buttons), or each card, to an address the row's fields name, such as `{ label: '{verb}', to: { kind: 'record', resource: 'tasks', key: '{task_id}', tab: 'Review' } }`; a row without a value for a field it names shows none. Not with `lines`. |
956
959
  | `open` | The relation of `resource` whose record a row opens, for rows that link this record to another. By default the one relation in `resource`'s primary key besides `field`, when there is exactly one (a join resource such as `task_dependencies` keyed on `[task_id, type, depends_on_id]`); otherwise rows open their own records. The row's menu then has **Open** for the other record and **Edit** for the link itself. |
957
960
  | `limit` | How many records it shows, 1 to 100; default 10. When there are more, the section says so beside View all, such as "The first 10 of 37.". Before 0.13 this was `pageSize`, rows per page; rename it. |
958
961
  | `display` | The display of `resource`'s list it opens in, and View all opens, such as `cards`; default the list's. |
@@ -1012,7 +1015,7 @@ Every name is checked when the config loads. In `/meta` a caller who cannot read
1012
1015
 
1013
1016
  #### Related records as cards
1014
1017
 
1015
- With `presentation: 'cards'` the section shows each record as a card, the cards stacked full width so a long value has room: the record's title, a link to its page, then each of `columns` under its label as the record page shows it (a markdown field rendered, a relation by its name), leaving out a field the record has no value for, and a button for each of `actions`. A value taller than a few lines is cut short with **Show more**, which shows it all. The buttons run the actions as the record page does: one with `confirm` asks first, one with [inputs](#actions-that-ask-for-input) opens its dialog (a sheet on a phone), and an `a.action` runs the app's handler; a card leaves out an action the user does not get and disables one they cannot run on that record. After an action the section loads again, so a record it no longer matches leaves it, and with `hideEmpty` the section goes once nothing matches.
1018
+ With `presentation: 'cards'` the section shows each record as a card, the cards stacked full width so a long value has room: the record's title, a link to its page, then each of `columns` under its label as the record page shows it (a markdown field rendered, a relation by its name), leaving out a field the record has no value for, a button for each of `actions`, and `button` before them. A value taller than a few lines is cut short with **Show more**, which shows it all. The buttons run the actions as the record page does: one with `confirm` asks first, one with [inputs](#actions-that-ask-for-input) opens its dialog (a sheet on a phone), and an `a.action` runs the app's handler; a card leaves out an action the user does not get and disables one they cannot run on that record. After an action the section loads again, so a record it no longer matches leaves it, and with `hideEmpty` the section goes once nothing matches.
1016
1019
 
1017
1020
  ```ts
1018
1021
  l.related('Waiting on you', {
@@ -1051,6 +1054,43 @@ view<typeof hosts>('hosts').layout((r) => [
1051
1054
 
1052
1055
  Each series is read through [`:aggregate`](api.md), grouped by `at` with `field = <this record's key>` as its filter, so the user's access applies as on the list, and a user who cannot read `field`, `at` or any series gets no chart (one who cannot read some series gets the others). That filter and grouping need an index on `(field, at)`, such as `create index on host_samples (host_id, sampled_at)`, which [`protobase doctor`](cli.md#doctor) checks. A `field` that is no relation to this resource, an `at` that is no timestamp or not filterable, or a series that is no number or is sensitive stops the server at startup. Keeping the samples, and removing old ones, is the app's own work.
1053
1056
 
1057
+ ### Conversations
1058
+
1059
+ `l.thread(title, options)` shows the messages that point at the record on the page, as a task's chat between the people working on it, and `l.composer(options)` below it writes one. They are the record page's form of the [Thread and Composer blocks](blocks.md#conversation) of composed pages, scoped to the record by a relation of the messages: the thread reads only the messages whose `field` holds this record's key, and each message the composer sends gets that key in `field`. [`/meta`](api.md#meta-and-openapi-per-caller) describes both as data, so every client can draw the conversation with no component of the app's own.
1060
+
1061
+ The thread shows the latest messages oldest first, each under its sender's name and the time it was sent, with a line between days, and **Load earlier messages** reads the ones before; it scrolls in a box of its own, opening at the newest and following what arrives, as the [Thread block](blocks.md#thread) does; others' new messages arrive without a reload when the message resource is [live](live.md) (`.live()`), and otherwise once the page is read again. A message whose text field the message resource's view marks [`.markdown()`](#names-and-columns) shows rendered, its raw HTML as text. The composer sends with Enter, starts a new line with Shift+Enter, and keeps a refused message in the box under the reason. A message carries its sender only when the message resource marks its author with [`.author()`](data-config.md#resource), which every create sets to the signed-in user, so the thread's `sender` names that field, such as `author_id`. It sends only `field` and `text`, so every other required field of the message, such as its time, needs a default, such as `sent_at timestamptz not null default now()`.
1062
+
1063
+ | `l.thread` option | |
1064
+ | --- | --- |
1065
+ | `resource` | The message resource, such as `task_messages`. Required. |
1066
+ | `field` | The filterable relation of `resource` that holds this record's key. Required. |
1067
+ | `sender` | Who wrote each message: a relation, named as the record it points at, or a text field. Required. |
1068
+ | `time` | When each was sent: a date or timestamp field the API can sort by, which orders them. Required. |
1069
+ | `text` | The message, a text field. Required. |
1070
+ | `limit` | How many of the latest it shows at first, and how many each **Load earlier messages** adds: 1 to 500, the API's largest page; default 50. |
1071
+ | `empty` | Text while there are no messages. |
1072
+ | `help`, `when` | A line under the title, and whether it shows on the form, the read view or both. |
1073
+
1074
+ | `l.composer` option | |
1075
+ | --- | --- |
1076
+ | `resource` | The message resource. Required. |
1077
+ | `field` | The relation of `resource` each message gets this record's key in. Required. |
1078
+ | `text` | The text field the message goes in. Required. |
1079
+ | `placeholder` | The box's text while empty. |
1080
+ | `when` | Whether it shows on the form, the read view or both. |
1081
+
1082
+ ```ts
1083
+ view<typeof task_messages>('task_messages').fields((r) => ({ body: r.body.markdown() }))
1084
+
1085
+ view<typeof tasks>('tasks').layout((r) => [
1086
+ l.section('Task', [r.title]),
1087
+ l.thread('Conversation', { resource: 'task_messages', field: 'task_id', sender: 'author_id', time: 'sent_at', text: 'body' }),
1088
+ l.composer({ resource: 'task_messages', field: 'task_id', text: 'body', placeholder: 'Message about this task' }),
1089
+ ])
1090
+ ```
1091
+
1092
+ The messages are read with `field = <this record's key>` as the filter, newest first by `time`, so the user's access applies as on the list. That read needs an index on `(field, time)`, such as `create index on task_messages (task_id, sent_at)`, which [`protobase doctor`](cli.md#doctor) checks. A user who cannot read `field`, `sender`, `time` or `text` gets no thread, and one who may not create a message with `field` and `text` gets no composer. A `field` that is no relation to this resource, a `time` that is no date or timestamp the API can sort by, a `sender` that is no relation or text field, a thread `text` that is no text field, a sensitive field in the thread, or a composer `text` that is no writable text field stops the server at startup. As with a related section, the record page's count of the records that point at it leaves out the messages its thread shows.
1093
+
1054
1094
  ## Actions and views per role
1055
1095
 
1056
1096
  ```ts title="docs-examples/bike-shop/step-5.ts"