@notis_ai/cli 0.2.26 → 0.2.28

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 (51) hide show
  1. package/README.md +2 -2
  2. package/config/notis_app_design_rules.json +5 -123
  3. package/dist/agent-hooks/notis-agent-hook.mjs +84 -14
  4. package/dist/base-skills/notis-spaces/.notis-base-skill.json +1 -1
  5. package/dist/base-skills/notis-spaces/SKILL.md +13 -19
  6. package/dist/base-skills/notis-spaces/references/context.md +3 -0
  7. package/dist/base-skills/notis-spaces/references/design.md +11 -45
  8. package/dist/base-skills/notis-spaces/references/sdk.md +86 -67
  9. package/dist/base-skills/notis-spaces/references/views.md +12 -1
  10. package/dist/sdk/src/components/NotisCommentBoundary.tsx +43 -16
  11. package/dist/sdk/src/components/NotisSelectionBoundary.tsx +105 -26
  12. package/dist/sdk/src/components/SelectionActionBar.tsx +262 -0
  13. package/dist/sdk/src/hooks/useCollectionInteractions.ts +5 -2
  14. package/dist/sdk/src/space.ts +4 -0
  15. package/dist/sdk/src/ui/icons.tsx +11 -2
  16. package/dist/sdk/src/words/actions.ts +9 -1
  17. package/dist/sdk/src/words/keymap.ts +3 -0
  18. package/dist/skill-sync/index.js +81 -11
  19. package/dist/skill-sync-worker.mjs +87 -12
  20. package/dist/space-harness/host.js +172 -134
  21. package/dist/space-sdk/dist/{chunk-BWHAORT4.js → chunk-BFGB6XXC.js} +2 -2
  22. package/dist/space-sdk/dist/index.js +2 -2
  23. package/dist/space-sdk/dist/ui.js +14 -11
  24. package/dist/space-sdk/src/components/NotisSelectionBoundary.d.ts +26 -2
  25. package/dist/space-sdk/src/space.ts +4 -0
  26. package/dist/space-sdk/src/tailwind-candidates.d.ts +124 -14
  27. package/dist/space-sdk/src/ui/blocks/DataTable.d.ts +86 -0
  28. package/dist/space-sdk/src/ui/blocks/InfoTip.d.ts +25 -0
  29. package/dist/space-sdk/src/ui/blocks/Meter.d.ts +39 -0
  30. package/dist/space-sdk/src/ui/blocks/blocks.d.ts +1 -1
  31. package/dist/space-sdk/src/ui/blocks/index.d.ts +6 -0
  32. package/dist/space-sdk/src/ui/charts/Chart.d.ts +15 -2
  33. package/dist/space-sdk/src/ui/charts/StatRow.d.ts +4 -3
  34. package/dist/space-sdk/src/ui/charts/chartData.d.ts +6 -0
  35. package/dist/space-sdk/src/ui/icons.d.ts +1 -1
  36. package/dist/space-sdk/src/ui/index.d.ts +2 -2
  37. package/dist/space-sdk/src/ui/list/Row.d.ts +10 -3
  38. package/dist/space-sdk/src/ui/period/dateFormat.d.ts +14 -0
  39. package/dist/space-sdk/src/words/actions.ts +9 -1
  40. package/dist/space-sdk/src/words/keymap.ts +3 -0
  41. package/dist/view-renderer/dist/host.js +243 -205
  42. package/dist/view-renderer/src/dom.js +15 -2
  43. package/package.json +3 -3
  44. package/skills/notis-cli/AGENT_INSTRUCTIONS.md +1 -1
  45. package/src/command-specs/computer.js +3 -3
  46. package/src/runtime/skill-sync/cloud-client.ts +98 -15
  47. package/src/runtime/skill-sync/index.ts +22 -3
  48. package/src/runtime/skill-sync/types.ts +4 -0
  49. package/src/skill-sync-worker.js +5 -1
  50. package/template/components/ui/button.tsx +1 -1
  51. package/template/components/ui/native-select.tsx +1 -1
@@ -37,60 +37,6 @@ Text a person writes and reviews:
37
37
  are gone reads Text changed. Do not build your own highlights. Pins on a page
38
38
  use `useComments` with `CommentPane` (see Comments under Toolkit pieces).
39
39
 
40
- ## Records and declared reads
41
-
42
- | API | Use |
43
- | --- | --- |
44
- | `useViewParams<typeof definition>()` | `{params, invalid, missing, declared, ready, setParams}` for declared typed URL params. Unknown names are dropped; invalid values use their declared default. `setParams(changes, {replace?})` changes this view's own params (`null` removes one) and keeps the same Space and record open. |
45
- | `useShown<Row>(name, options?)` | Execute the native list in `shows[name]` with current params. Options: `sorts`, `pageSize`, `offset`, `includeContent`, `allPages` (every page, for a whole count or a local search); rows are in `data?.rows` and the schema revision a write needs in `data?.schema_revision`, with `loading`, `hasData`, `isFetching`, `error`, `refetch` (resolves to the read's error, or null when it succeeded; it never rejects). |
46
- | `useShownAvailable(name)` | Check whether this host exposes the declared native list. A record Site can expose only its exact server-pinned row scope. |
47
- | `useAction<Inputs, Result>(name)` / `useActionQuery<Result>(name, inputs, options?)` | Call a declared action (`call(inputs, options)`); read the result of a declared read action. Never call account-wide tools from a Space. When a read action answers with native rows, pass `rows: { binding, at, query? }` (`at`: the answer field holding them, `''` for a bare list; `query`: the native query it runs) so native writes to that database show in it at once too; without it the read only refreshes after the write. A failed call throws a `SpaceActionError`; its `code` is `rate_limited` when the provider refused it for sending too fast (it did not run, and Notis already waited and retried safe calls), so offer a retry after a few seconds instead of adding your own limiter, and `read_timeout` when a read took too long. |
48
- | `useNativeMutation(binding, operation)` | Insert, update or delete one row of a linked database through the action that declares `LOCAL_NOTIS_DATABASE_INSERT`, `_UPDATE` or `_DELETE` on that binding with `request: { $input: 'request' }`. `mutate(input, {schemaRevision, requestId, showIn?})` returns the receipt (`record_key`, `revision`). The write shows in every list of that database at once, before the server answers: an edited row changes where it is (and moves to its sorted place, or leaves a `useNativeDocuments` read whose filter no longer keeps it), a new row joins the reads whose filter it passes and the `shows` lists named by `showIn` (by default the view's only list over that database), and a delete moves the record to the bin and leaves every list. A failed write puts the server's rows back. Do not keep your own copy of the change on top. One new request ID per effect. An insert action takes no `content_markdown`: insert, then save the body with `useNativeDocumentBody` and the record's revision. |
49
- | `useNativeDelete(binding)` | Trash many rows of one linked database (a deck and its slides, a multi-select). `deleteMany(inputs, {schemaRevision, requestId})` hides every row from the lists at once, runs the writes a few at a time, each with the request ID `${requestId}:${record_key}` (a retry with the same `requestId` replays instead of trashing twice), refreshes the lists once at the end and brings back the rows whose write failed. It never throws for a failed row: it resolves to `{done, failed}`; say how many failed. Use it rather than a loop of `mutate`. |
50
- | `useNativeDocumentBody(binding, recordKey, {readAction, writeAction?, enabled?})` | Markdown body adapter. Keep drafts in the view; save with the original content, record/schema revisions and stable request ID. Rich editing normally uses `DocumentEditor`. |
51
- | `useNotis()` | Host resource, Space labels, route and ready state. Use `resource.id` for the current Space identity. |
52
-
53
- Keep hooks unconditional. `loading` means no first successful read;
54
- `isFetching` includes a silent refresh. Do not copy rows into mount-only state
55
- or clear them on error ([loading rules](design.md#loading-empty-and-error)).
56
- `Skeleton` and `ViewSkeleton` come from `@notis/sdk`; `ViewSkeleton`'s `label`
57
- names what loads (`{ en: 'Loading meetings', fr: 'Chargement des réunions' }`),
58
- said in the Space's language, default Loading content. Its shapes are
59
- measured from the view at verify time and drawn from the release; `skeletonKey`
60
- (default `main`) names the region when a view has several separately loading
61
- parts, and `variant` only draws the fallback before the first measured release.
62
-
63
- For another explicitly idempotent read use `useActionQuery`, or
64
- `useQuery(keyArray, readCallback, { readOnly: true })` with every input in the
65
- key. Call declared read actions inside a custom read with
66
- `{ readOnly: true, dedupe: true }`; never mark a whole tool family read-only.
67
- `useQueryClient().prefetch(...)` with the exact foreground key prepares a small
68
- known read after render or on hover; never prefetch a write, a polling action or
69
- a fan-out aggregate. The host keeps one in-memory cache per account, Space,
70
- version and permission; do not add module-global or `localStorage` caches of
71
- user data.
72
-
73
- ## First-party record components
74
-
75
- | Component | Contract |
76
- | --- | --- |
77
- | `<DocumentPage recordKey>` | A record as the view's main content: save state, menu, cover, icon, title, meta, properties that save automatically, collaborative body. Slots `breadcrumb`, `actions`, `menuItems`, `aboveBody`, `belowBody`; toggles `share` (off by default, never for a report record), `header`, `meta`, `properties`, `width` (`standard` 900 px centred column by default, `wide` 1200 px, `full`); `viewer: 'html'` shows a record whose one stored `.html` file is the page; `onSaved`; `layout`. Pair with `DocumentPageSkeleton` and `usePrefetchRecord()`. It is the usual `reader` slot of `ListReader`; there it takes no `breadcrumb`, because the top bar crumb already names the open record. A page with a `breadcrumb` (a record opened from the view) names the top bar crumb leaf with its title itself; `topBarTitle` overrides that, and `onTitle` hears the title. |
78
- | `<DocumentEditor recordKey>` | Native collaborative body, properties, images and attachments. With separate properties use `showProperties={false}`. |
79
- | `<RecordProperties recordKey>` | Native revision-checked property editing. |
80
- | `<HtmlFrame recordKey>` | Attached HTML under viewer CSP and an opaque-origin sandbox. Source cannot relax that boundary. `onReady` is called once per page after it has loaded and painted, or when the record cannot load: keep a slide hidden until then instead of showing a half-drawn page. `presentation={{ onAction }}` turns the pointer into a laser dot inside the page, keeps its buttons and links clickable, and hands the presenter's keys and plain clicks back as `next`, `previous`, `first`, `last` or `stop`; the page can send the same actions, so treat them as navigation only. |
81
- | `<ReportFrame recordKey>` | A report row's saved independent implementation in its database's current view. |
82
- | `<ShareControl recordKey>` | Private/shared record Site, copy link and revoke. |
83
- | `<SpacePageFrame href>` | Another Notis Space page, live in this view: `href` is a Notis link (a path or a full link of this origin, such as a Page property). The Portal shows only that page's view (no sidebar, top bar or chat) with the viewer's own session and permissions. `interactive` (default `false`) lets it take clicks and keys; off, the view around it (a deck's arrows and swipes) keeps them. `title`, `className` (sizes the box it fills). Any other link, and every verify or build preview, shows a card with the title, the path and Open page. |
84
-
85
- In its own Space's view, a record's Site is a row of the top bar Share panel, not
86
- a toolbar button. The published Space declares the database binding; the server
87
- rechecks record scope and binding revision. A Site exposes read-only body and
88
- property snapshots and HTML for its pinned record, including a declared
89
- non-collection record param. A report row cannot be shared as a Site; a report
90
- saved as an HTML file can. A Site has no upload, collaboration credential,
91
- authoring controls or sharing mutation. No credentials or filesystem URLs belong
92
- in component props.
93
-
94
40
  ## Toolkit pieces
95
41
 
96
42
  From `@notis/sdk/ui`. Their props live in the piece types; read them there
@@ -109,7 +55,10 @@ rather than from a copy.
109
55
  `auto` for a move the list makes itself, or `url`), `renderTile` (tiles), `look` (`two-tone` keeps
110
56
  the list tinted) and `autoOpen` (opens the first item). It has no toolbar or
111
57
  header slot. `Row` takes `wrap` (title lines) and `now` (a fixed clock for
112
- relative times). Drag to select is automatic on a list that selects several
58
+ relative times); a `Row` drawn on its own (a short "Needs action" list)
59
+ takes `onPress` and `pressLabel` and opens something on press, so never wrap
60
+ a row in a button of your own. A `labels` entry with a tone draws as a small
61
+ tinted pill. Drag to select is automatic on a list that selects several
113
62
  (`selectable` or a bulk action): a drag from empty space selects the rows
114
63
  under it, as in the Manager; `dragSelect={false}` turns it off. Reorder is
115
64
  off until the view passes `reorder={{ onReorder, canReorder }}`: a row then
@@ -136,17 +85,34 @@ rather than from a copy.
136
85
  only reads. Use it rather than columns of your own.
137
86
  - **Time and numbers**: `PeriodPicker` with `usePeriod`, `DayPicker`,
138
87
  `CalendarView`, `TimelineView`, `Chart`, `StatRow`, `ChartTable`,
139
- `RenderChartData`. `Chart` stacks bars or areas (`stacked`) and runs bars
140
- left to right (`horizontal`): each label on up to two lines before its bar
141
- in a measured axis, and its value after it; `labelFormat` gives that short
88
+ `RenderChartData`, `Meter`, `DataTable`, `formatDuration`. `Chart` stacks
89
+ bars or areas (`stacked`) and runs bars left to right (`horizontal`): each
90
+ label on up to two lines before its bar in a measured axis, and its value after it; `labelFormat` gives that short
142
91
  value ("1.2k") while `format` stays the exact tooltip and table text. Draw
143
92
  category bars this way rather than with your own recharts. For a chart of
144
93
  your own, `ChartContainer` takes `aspect` or `height`; `ChartTooltipContent`
145
94
  and `ChartLegend` also work outside it; `<Bar shape={barShape}
146
95
  label={{ content: barLabel }} />` keeps zero bars and their value labels. A
147
- sparkline `null` is a gap. `PeriodPicker` without the `custom` preset offers
148
- presets only.
149
- - **Floating**: `Menu`, `Popover`, `Tooltip`.
96
+ sparkline `null` is a gap. `domain={[min, max]}` fixes the value scale (a
97
+ percentage on 0 to 100) and `valueAxis` draws it on the left through
98
+ `labelFormat` (without a `domain` its top rises to a round quarter); x labels thin out with the room and never run off the edge. `PeriodPicker` without the `custom` preset offers
99
+ presets only. `Meter` is a labelled capacity bar (`label`, `value`, `max`,
100
+ `valueText`, `hint`); at or past `limit` (a tick named by `limitLabel`) it
101
+ turns destructive. Set `limit` only to a threshold the data has (a memory
102
+ reserve, a quota), never to `max`: a full meter is not red by itself. `DataTable` is a read-only table with the `ChartTable`
103
+ look for rows that are not figures: `columns` (`id`, `label`, `cell`, `align`, `width`,
104
+ `mono`, `primary`, `hideBelow`), `rows` or `groups` (`key`, `label`, `rows`),
105
+ `rowKey`, and `onRowPress` with `rowLabel` to open a row (the primary cell
106
+ then sits inside the row's button: text and icons only, no link). The primary
107
+ column never gets under its `minWidth` (120 px by default): the last
108
+ columns that do not fit hide on their own.
109
+ `formatDuration(ms, locale, { units, smallest })` writes "1 h 31 min" (FR
110
+ "4 j 6 h").
111
+ - **Floating**: `Menu`, `Popover`, `Tooltip`, `InfoTip`. `InfoTip` is the
112
+ info button beside a label (a figure's `about`, a section heading, a meter):
113
+ `label` names what it explains and the children are one or two sentences
114
+ that open on press or tap. A `Tooltip` never shows on touch, so explanations
115
+ go in an `InfoTip`.
150
116
  - **Files and pictures**: `AttachmentGallery` and `ImageViewer`, the ones
151
117
  Notis conversations use. `AttachmentGallery` draws a row of file cards
152
118
  (`items`: `url`, `name`, `type` or `kind`, `size`, `thumbnailUrl`); an
@@ -181,11 +147,10 @@ rather than from a copy.
181
147
  previews, a timer). The browser asks once to place windows on screens; the
182
148
  desktop app never asks. Leaving the view closes the audience window.
183
149
  - **Blocks**: `Section`, `Badge`, `Button`, `ToggleGroup`, `SegmentedControl`,
184
- `NativeSelect`, `EmptyState`, `Notice`, `Metric`. A page is a stack of
185
- `Section`s, full width and without boxes: `kind` is `bar` (period and
186
- filters), `stats`, `chart`, `data` (a table) or `form`, and its head takes
187
- `title`, `count`, `meta`, `tabs` and `actions`. There is no page heading and
188
- no card: the host top bar shows the title. One toggle is a `Button` with
150
+ `NativeSelect`, `EmptyState`, `Notice`, `Metric`. A `Section`'s `kind`
151
+ is `bar` (period and filters), `stats`, `chart`, `data` (a table) or `form`,
152
+ and its head takes `title`, `count`, `meta`, `tabs` and `actions`. There is no
153
+ page heading: the host top bar shows the title. One toggle is a `Button` with
189
154
  `pressed`; several with any number on (filters, chart series) are a
190
155
  `ToggleGroup`; tabs and filters over a whole list or section are pills
191
156
  (`TabRow`); a `SegmentedControl` is only a mode switch inside a section.
@@ -216,7 +181,61 @@ Move to triage, and a Space whose first stop has a name passes
216
181
  A status maps to one of ten groups (`backlog`, `todo`, `active`, `review`,
217
182
  `waiting`, `done`, `cancelled`, `failed`, and `up`/`down` for a service), each
218
183
  with its icon, words and the one status palette: pass the Space's own status to
219
- `Row` or `StatusIcon` (with `label` for its own name), never a colour.
184
+ `Row` or `StatusIcon` (with `label` for its own name).
185
+
186
+ ## Records and declared reads
187
+
188
+ | API | Use |
189
+ | --- | --- |
190
+ | `useViewParams<typeof definition>()` | `{params, invalid, missing, declared, ready, setParams}` for declared typed URL params. Unknown names are dropped; invalid values use their declared default. `setParams(changes, {replace?})` changes this view's own params (`null` removes one) and keeps the same Space and record open. |
191
+ | `useShown<Row>(name, options?)` | Execute the native list in `shows[name]` with current params. Options: `sorts`, `pageSize`, `offset`, `includeContent`, `allPages` (every page, for a whole count or a local search); rows are in `data?.rows` and the schema revision a write needs in `data?.schema_revision`, with `loading`, `hasData`, `isFetching`, `error`, `refetch` (resolves to the read's error, or null when it succeeded; it never rejects). |
192
+ | `useShownAvailable(name)` | Check whether this host exposes the declared native list. A record Site can expose only its exact server-pinned row scope. |
193
+ | `useAction<Inputs, Result>(name)` / `useActionQuery<Result>(name, inputs, options?)` | Call a declared action (`call(inputs, options)`); read the result of a declared read action. Never call account-wide tools from a Space. When a read action answers with native rows, pass `rows: { binding, at, query? }` (`at`: the answer field holding them, `''` for a bare list; `query`: the native query it runs) so native writes to that database show in it at once too; without it the read only refreshes after the write. A failed call throws a `SpaceActionError`; its `code` is `rate_limited` when the provider refused it for sending too fast (it did not run, and Notis already waited and retried safe calls), so offer a retry after a few seconds instead of adding your own limiter, and `read_timeout` when a read took too long. |
194
+ | `useNativeMutation(binding, operation)` | Insert, update or delete one row of a linked database through the action that declares `LOCAL_NOTIS_DATABASE_INSERT`, `_UPDATE` or `_DELETE` on that binding with `request: { $input: 'request' }`. `mutate(input, {schemaRevision, requestId, showIn?})` returns the receipt (`record_key`, `revision`). The write shows in every list of that database at once, before the server answers: an edited row changes where it is (and moves to its sorted place, or leaves a `useNativeDocuments` read whose filter no longer keeps it), a new row joins the reads whose filter it passes and the `shows` lists named by `showIn` (by default the view's only list over that database), and a delete moves the record to the bin and leaves every list. A failed write puts the server's rows back. Do not keep your own copy of the change on top. One new request ID per effect. An insert action takes no `content_markdown`: insert, then save the body with `useNativeDocumentBody` and the record's revision. |
195
+ | `useNativeDelete(binding)` | Trash many rows of one linked database (a deck and its slides, a multi-select). `deleteMany(inputs, {schemaRevision, requestId})` hides every row from the lists at once, runs the writes a few at a time, each with the request ID `${requestId}:${record_key}` (a retry with the same `requestId` replays instead of trashing twice), refreshes the lists once at the end and brings back the rows whose write failed. It never throws for a failed row: it resolves to `{done, failed}`; say how many failed. Use it rather than a loop of `mutate`. |
196
+ | `useNativeDocumentBody(binding, recordKey, {readAction, writeAction?, enabled?})` | Markdown body adapter. Keep drafts in the view; save with the original content, record/schema revisions and stable request ID. Rich editing normally uses `DocumentEditor`. |
197
+ | `useNotis()` | Host resource, Space labels, route and ready state. Use `resource.id` for the current Space identity. |
198
+
199
+ Keep hooks unconditional. `loading` means no first successful read;
200
+ `isFetching` includes a silent refresh. Do not copy rows into mount-only state
201
+ or clear them on error ([loading rules](design.md#loading-empty-and-error)).
202
+ `Skeleton` and `ViewSkeleton` come from `@notis/sdk`; `ViewSkeleton`'s `label`
203
+ names what loads (`{ en: 'Loading meetings', fr: 'Chargement des réunions' }`),
204
+ said in the Space's language, default Loading content. Its shapes are
205
+ measured from the view at verify time and drawn from the release; `skeletonKey`
206
+ (default `main`) names the region when a view has several separately loading
207
+ parts, and `variant` only draws the fallback before the first measured release.
208
+
209
+ For another explicitly idempotent read use `useActionQuery`, or
210
+ `useQuery(keyArray, readCallback, { readOnly: true })` with every input in the
211
+ key. Call declared read actions inside a custom read with
212
+ `{ readOnly: true, dedupe: true }`; never mark a whole tool family read-only.
213
+ `useQueryClient().prefetch(...)` with the exact foreground key prepares a small
214
+ known read after render or on hover; never prefetch a write, a polling action or
215
+ a fan-out aggregate. The host keeps one in-memory cache per account, Space,
216
+ version and permission; do not add module-global or `localStorage` caches of
217
+ user data.
218
+
219
+ ## First-party record components
220
+
221
+ | Component | Contract |
222
+ | --- | --- |
223
+ | `<DocumentPage recordKey>` | A record as the view's main content: save state, menu, cover, icon, title, meta, properties that save automatically, collaborative body. Slots `breadcrumb`, `actions`, `menuItems`, `aboveBody`, `belowBody`; toggles `share` (off by default, never for a report record), `header`, `meta`, `properties`, `width` (`standard` 900 px centred column by default, `wide` 1200 px, `full`); `viewer: 'html'` shows a record whose one stored `.html` file is the page; `onSaved`; `layout`. Pair with `DocumentPageSkeleton` and `usePrefetchRecord()`. It is the usual `reader` slot of `ListReader`; there it takes no `breadcrumb`, because the top bar crumb already names the open record. A page with a `breadcrumb` (a record opened from the view) names the top bar crumb leaf with its title itself; `topBarTitle` overrides that, and `onTitle` hears the title. |
224
+ | `<DocumentEditor recordKey>` | Native collaborative body, properties, images and attachments. With separate properties use `showProperties={false}`. |
225
+ | `<RecordProperties recordKey>` | Native revision-checked property editing. |
226
+ | `<HtmlFrame recordKey>` | Attached HTML under viewer CSP and an opaque-origin sandbox. Source cannot relax that boundary. `onReady` is called once per page after it has loaded and painted, or when the record cannot load: keep a slide hidden until then instead of showing a half-drawn page. `presentation={{ onAction }}` turns the pointer into a laser dot inside the page, keeps its buttons and links clickable, and hands the presenter's keys and plain clicks back as `next`, `previous`, `first`, `last` or `stop`; the page can send the same actions, so treat them as navigation only. |
227
+ | `<ReportFrame recordKey>` | A report row's saved independent implementation in its database's current view. |
228
+ | `<ShareControl recordKey>` | Private/shared record Site, copy link and revoke. |
229
+ | `<SpacePageFrame href>` | Another Notis Space page, live in this view: `href` is a Notis link (a path or a full link of this origin, such as a Page property). The Portal shows only that page's view (no sidebar, top bar or chat) with the viewer's own session and permissions. `interactive` (default `false`) lets it take clicks and keys; off, the view around it (a deck's arrows and swipes) keeps them. `title`, `className` (sizes the box it fills). Any other link, and every verify or build preview, shows a card with the title, the path and Open page. |
230
+
231
+ In its own Space's view, a record's Site is a row of the top bar Share panel, not
232
+ a toolbar button. The published Space declares the database binding; the server
233
+ rechecks record scope and binding revision. A Site exposes read-only body and
234
+ property snapshots and HTML for its pinned record, including a declared
235
+ non-collection record param. A report row cannot be shared as a Site; a report
236
+ saved as an HTML file can. A Site has no upload, collaboration credential,
237
+ authoring controls or sharing mutation. No credentials or filesystem URLs belong
238
+ in component props.
220
239
 
221
240
  ## Navigation
222
241
 
@@ -84,6 +84,17 @@ The saved `read` action is deliberately constrained to one native record for
84
84
  body and record-Site reads; `shows.notes` owns the Editor's collection list. Keep
85
85
  both tied to the same declared resource.
86
86
 
87
+ ## Records in the sidebar
88
+
89
+ `collection` lists the database's records as rows under the Space in the
90
+ sidebar. Declare it only when the list stays short and people navigate it like
91
+ pages: folders of a notes Space, the chapters of a guide, a handful of decks.
92
+ Leave it out when records keep coming (candidates, leads, tickets, meetings,
93
+ logs, anything a skill or automation adds every week): show them in the view
94
+ with `shows` and a `ListReader` or table, which has search, filters and tabs.
95
+ The sidebar lists a row's first 10 records and a Show more row adds 10 at a
96
+ time, so a long collection still works, but it buries every Space below it.
97
+
87
98
  A Site of the whole Space (or of one of its pages) runs each `shows` list
88
99
  through such an action too, and that one-record action refuses the list's
89
100
  request. Publishing is then refused with `site_list_action_required`. For a
@@ -166,7 +177,7 @@ no title, heading or search field of its own. `archive` is a standard action: it
166
177
  brings its own words and key. `pin` is the Space's own: it brings its EN and FR
167
178
  words and a key the clash check accepts. Add `tabs` for real saved filters and
168
179
  `create` for a "+" that makes a record. Other kinds of view start from their own
169
- piece; see [Design](design.md#pick-the-piece).
180
+ piece; see [the toolkit pieces](sdk.md#toolkit-pieces).
170
181
 
171
182
  ## A view of your own
172
183
 
@@ -1,8 +1,11 @@
1
1
  'use client';
2
2
  import React, { useEffect, useRef, useState, type CSSProperties, type ReactNode } from 'react';
3
3
  import type { ContextResource } from '../runtime';
4
- import { NotisSelectionBoundary } from './NotisSelectionBoundary';
4
+ import { NotisSelectionBoundary, quoteResourceFor } from './NotisSelectionBoundary';
5
5
  import { useAgentContext } from '../hooks/useAgentContext';
6
+ import { useNotisRuntime } from '../provider';
7
+ import { COMMENT_GLYPH, QUOTE_GLYPH, SELECTION_BAR_WORDS, SelectionActionBar, clearSelectionIn, getSelectionBarPosition } from './SelectionActionBar';
8
+ import { useToolkitLocale } from '../ui/engine/hooks';
6
9
 
7
10
  export interface NotisCommentBoxProps {
8
11
  quote?: string;
@@ -22,7 +25,7 @@ export function NotisCommentBox({ quote, value, onChange, onSubmit, onCancel, pe
22
25
  className={`flex min-w-0 flex-col gap-2 rounded-xl border p-2.5 text-sm shadow-lg ${className}`}>
23
26
  <div className="flex min-w-0 items-center gap-2">
24
27
  {quote && <blockquote title={quote} className="min-w-0 flex-1 truncate border-l-2 border-current/40 pl-2 opacity-70">{quote}</blockquote>}
25
- <button type="button" aria-label="Cancel comment" onClick={onCancel} disabled={pending} className="ml-auto flex size-7 shrink-0 items-center justify-center rounded-lg opacity-70 hover:bg-white/10 hover:opacity-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-current disabled:opacity-40 [@media(pointer:coarse)]:size-9">
28
+ <button type="button" aria-label="Cancel comment" onClick={onCancel} disabled={pending} className="ml-auto flex size-7 shrink-0 items-center justify-center rounded-lg opacity-70 hover:bg-white/10 hover:opacity-100 disabled:opacity-40 [@media(pointer:coarse)]:size-9">
26
29
  <svg aria-hidden="true" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round"><path d="m6 6 12 12M18 6 6 18" /></svg>
27
30
  </button>
28
31
  </div>
@@ -34,7 +37,7 @@ export function NotisCommentBox({ quote, value, onChange, onSubmit, onCancel, pe
34
37
  <span className="text-xs opacity-60">⌘ / Ctrl ↵ to add</span>
35
38
  <button type="button" disabled={pending || !value.trim()} onClick={onSubmit}
36
39
  style={{ background: 'hsl(var(--sidebar-foreground, 240 4.8% 95.9%))', color: 'hsl(var(--sidebar-background, 0 0% 7.5%))' }}
37
- className="min-h-8 shrink-0 rounded-lg px-2.5 text-sm font-medium hover:opacity-90 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-current disabled:opacity-40 [@media(pointer:coarse)]:min-h-9">{pending ? 'Adding…' : 'Add to chat'}</button>
40
+ className="min-h-8 shrink-0 rounded-lg px-2.5 text-sm font-medium hover:opacity-90 disabled:opacity-40 [@media(pointer:coarse)]:min-h-9">{pending ? 'Adding…' : 'Add to chat'}</button>
38
41
  </div>
39
42
  </div>;
40
43
  }
@@ -88,8 +91,12 @@ export function getOwnedCommentRange(selected: Range, content: Element): Range |
88
91
  /** Selection-to-chat convenience. No annotation database, polling or background attachment. */
89
92
  export function NotisCommentBoundary({ resource, children, className, commentClassName, renderComment }: NotisCommentBoundaryProps) {
90
93
  const context = useAgentContext();
94
+ // A host without a chat (a public Site) offers Comment alone: Cite would have nowhere to go.
95
+ const canCite = Boolean(useNotisRuntime()?.addContext);
91
96
  const root = useRef<HTMLDivElement>(null);
92
- const [selection, setSelection] = useState<{ id: string; text: string; resource?: ContextResource | null; top: number; left: number } | null>(null);
97
+ const [selection, setSelection] = useState<{ id: string; text: string; resource?: ContextResource | null; range: Range; top: number; left: number } | null>(null);
98
+ const locale = useToolkitLocale();
99
+ const [barSize, setBarSize] = useState({ width: 176, height: 32 });
93
100
  const [editing, setEditing] = useState(false);
94
101
  const editingRef = useRef(false);
95
102
  const [comment, setComment] = useState('');
@@ -107,7 +114,12 @@ export function NotisCommentBoundary({ resource, children, className, commentCla
107
114
  const selected = scope.getSelection?.() || document.defaultView?.getSelection();
108
115
  const content = node.firstElementChild;
109
116
  if (!selected?.rangeCount || selected.isCollapsed || !selected.toString().trim()
110
- || !content || !getOwnedCommentRange(selected.getRangeAt(0), content)) setSelection(null);
117
+ || !content || !getOwnedCommentRange(selected.getRangeAt(0), content)) { setSelection(null); return; }
118
+ // A touch selection has no mouse up: show the bar once its handles stop moving (truth PRT-094).
119
+ if (document.defaultView?.matchMedia?.('(pointer: coarse)').matches) {
120
+ document.defaultView.clearTimeout(touchSettle.current);
121
+ touchSettle.current = document.defaultView.setTimeout(() => captureRef.current(null), 450);
122
+ }
111
123
  };
112
124
  document.addEventListener('selectionchange', clearInvalidSelection);
113
125
  if (scope !== (document as unknown as ShadowRoot)) scope.addEventListener('selectionchange', clearInvalidSelection);
@@ -117,9 +129,11 @@ export function NotisCommentBoundary({ resource, children, className, commentCla
117
129
  };
118
130
  }, []);
119
131
  const open = () => { editingRef.current = true; setEditing(true); };
132
+ const touchSettle = useRef<number | undefined>(undefined);
133
+ const captureRef = useRef<(target: EventTarget | null) => void>(() => {});
120
134
  const capture = (target: EventTarget | null) => {
121
135
  // Clicking the action/editor must not unmount it before its click runs.
122
- if (editing || (target instanceof Element && target.closest('[data-notis-comment-ui]'))) return;
136
+ if (editing || (target instanceof Element && target.closest('[data-notis-comment-ui],[data-notis-selection-ui]'))) return;
123
137
  const node = root.current;
124
138
  const scope = node?.getRootNode() as ShadowRoot & { getSelection?: () => Selection | null };
125
139
  const selected = scope?.getSelection?.() || window.getSelection();
@@ -143,9 +157,14 @@ export function NotisCommentBoundary({ resource, children, className, commentCla
143
157
  remainder.setStart(range.endContainer, range.endOffset);
144
158
  trailing.push(...Array.from(remainder.getClientRects?.() || []).filter(line => line.width > 0 && line.height > 0));
145
159
  }
146
- const position = getCommentActionPosition(lines.length ? lines : [rect], { width: window.innerWidth, height: window.innerHeight }, boundary?.width ? boundary.right : window.innerWidth, trailing);
147
- setSelection({ id: crypto.randomUUID(), text: selected.toString().trim(), resource: resource ? JSON.parse(JSON.stringify(resource)) : null, ...position });
160
+ // The bar (Cite, then Comment) sits where the old Comment tile did: after the last line, or below it.
161
+ const position = getSelectionBarPosition(lines.length ? lines : [rect], { width: window.innerWidth, height: window.innerHeight }, barSize,
162
+ { rightBoundary: boundary?.width ? boundary.right : window.innerWidth, trailing, coarse: window.matchMedia?.('(pointer: coarse)').matches });
163
+ setSelection({ id: crypto.randomUUID(), text: selected.toString().trim(), resource: resource ? JSON.parse(JSON.stringify(resource)) : null, range: range.cloneRange(), ...position });
148
164
  };
165
+ captureRef.current = capture;
166
+ // Once the bar measured itself, place it again with its real width.
167
+ useEffect(() => { if (!editingRef.current) captureRef.current(null); }, [barSize.width, barSize.height]);
149
168
  const close = () => { editingRef.current = false; setEditing(false); setSelection(null); setComment(''); setError(''); };
150
169
  const submit = async () => {
151
170
  if (!selection || !comment.trim() || pending) return;
@@ -157,16 +176,24 @@ export function NotisCommentBoundary({ resource, children, className, commentCla
157
176
  } catch (reason) { setError(reason instanceof Error ? reason.message : 'Could not add this comment.'); }
158
177
  finally { setPending(false); }
159
178
  };
179
+ const cite = async () => {
180
+ if (!selection) return;
181
+ const quoted = selection;
182
+ clearSelectionIn(root.current);
183
+ setSelection(null);
184
+ // The quote copy would make: the innermost boundary's resource, else this boundary's.
185
+ const named = quoteResourceFor(quoted.range) ?? quoted.resource ?? null;
186
+ try { await context.add({ id: quoted.id, text: quoted.text, ...(named ? { resource: named } : {}) }); } catch { /* No chat in this host: copy still quotes. */ }
187
+ };
160
188
  const editorProps: NotisCommentBoxProps = { quote: selection?.text, value: comment, onChange: setComment, onSubmit: () => void submit(), onCancel: close, pending, error, className: commentClassName };
161
- return <div ref={root} className="contents" onMouseUp={event => capture(event.target)} onDoubleClick={event => capture(event.target)} onKeyUp={event => { if (!editing && (event.shiftKey || event.key === 'Shift' || ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === 'a'))) capture(event.target); }}>
189
+ return <div ref={root} className="contents" data-notis-comment-boundary onMouseUp={event => capture(event.target)} onDoubleClick={event => capture(event.target)} onKeyUp={event => { if (!editing && (event.shiftKey || event.key === 'Shift' || ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === 'a'))) capture(event.target); }}>
162
190
  <NotisSelectionBoundary resource={resource} className={className} style={className ? undefined : { display: 'contents' }}>{children}</NotisSelectionBoundary>
163
- {selection && <div data-notis-comment-ui className="fixed z-50 max-h-[calc(100dvh-1rem)]" style={{ overflow: editing ? 'auto' : 'visible', top: editing ? Math.min(selection.top, Math.max(8, window.innerHeight - 320)) : selection.top, left: `clamp(8px, ${selection.left}px, calc(100vw - ${editing ? 'min(20rem, calc(100vw - 1rem))' : '2rem'} - 8px))`, width: editing ? 'min(20rem, calc(100vw - 1rem))' : undefined } as CSSProperties}>
164
- {editing ? (renderComment ? renderComment(editorProps) : <NotisCommentBox {...editorProps} />) : <button type="button" aria-label="Comment" title="Comment" onMouseDown={event => event.preventDefault()} onClick={open}
165
- style={{ background: 'hsl(var(--sidebar-background, 0 0% 7.5%))', color: 'hsl(var(--sidebar-foreground, 240 4.8% 95.9%))' }}
166
- className="relative flex size-8 items-center justify-center rounded-lg ring-1 ring-white/15 hover:opacity-90 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-current">
167
- <svg aria-hidden="true" width="18" height="18" viewBox="0 0 256 256" fill="currentColor"><path d="M216,48H40A16,16,0,0,0,24,64V224a15.85,15.85,0,0,0,9.24,14.5A16.13,16.13,0,0,0,40,240a15.89,15.89,0,0,0,10.25-3.78l.09-.07L83,208H216a16,16,0,0,0,16-16V64A16,16,0,0,0,216,48ZM40,224h0ZM216,192H80a8,8,0,0,0-5.23,1.95L40,224V64H216ZM88,112a8,8,0,0,1,8-8h64a8,8,0,0,1,0,16H96A8,8,0,0,1,88,112Zm0,32a8,8,0,0,1,8-8h64a8,8,0,1,1,0,16H96A8,8,0,0,1,88,144Z" /></svg>
168
- <span aria-hidden="true" className="absolute left-1/2 top-1/2 hidden size-12 -translate-x-1/2 -translate-y-1/2 [@media(pointer:coarse)]:block" />
169
- </button>}
191
+ {selection && !editing && <SelectionActionBar anchor={selection} onSize={setBarSize} actions={[
192
+ ...(canCite ? [{ key: 'cite', label: SELECTION_BAR_WORDS.cite[locale], title: SELECTION_BAR_WORDS.citeHint[locale], icon: QUOTE_GLYPH, onSelect: () => void cite() }] : []),
193
+ { key: 'comment', label: SELECTION_BAR_WORDS.comment[locale], icon: COMMENT_GLYPH, onSelect: open },
194
+ ]} />}
195
+ {selection && editing && <div data-notis-comment-ui className="fixed z-50 max-h-[calc(100dvh-1rem)]" style={{ overflow: 'auto', top: Math.min(selection.top, Math.max(8, window.innerHeight - 320)), left: `clamp(8px, ${selection.left}px, calc(100vw - min(20rem, calc(100vw - 1rem)) - 8px))`, width: 'min(20rem, calc(100vw - 1rem))' } as CSSProperties}>
196
+ {renderComment ? renderComment(editorProps) : <NotisCommentBox {...editorProps} />}
170
197
  </div>}
171
198
  </div>;
172
199
  }
@@ -1,7 +1,7 @@
1
1
  import type { CSSProperties, ClipboardEvent, ReactNode } from 'react';
2
2
  import React, { useCallback } from 'react';
3
3
  import { useNotisRuntime } from '../provider';
4
- import type { ContextResource, ContextSelection } from '../runtime';
4
+ import type { ContextResource, ContextSelection, NotisRuntime } from '../runtime';
5
5
 
6
6
  export const NOTIS_CONTEXT_CLIPBOARD_TYPE = 'application/x-notis-context+json';
7
7
 
@@ -18,6 +18,80 @@ function selectionId(): string {
18
18
  : `selection-${Date.now()}-${Math.random().toString(36).slice(2)}`;
19
19
  }
20
20
 
21
+ /** The selection's markup for other paste targets: hidden parts dropped, links made absolute. */
22
+ function selectionHtml(selection: Selection): string {
23
+ if (typeof document === 'undefined') return '';
24
+ const container = document.createElement('div');
25
+ for (let index = 0; index < selection.rangeCount; index += 1) container.appendChild(selection.getRangeAt(index).cloneContents());
26
+ container.querySelectorAll('[hidden],script,style,template').forEach(node => node.remove());
27
+ container.querySelectorAll('[href],[src]').forEach(node => {
28
+ for (const name of ['href', 'src']) {
29
+ const value = node.getAttribute(name);
30
+ if (value === null) continue;
31
+ try { node.setAttribute(name, new URL(value, document.baseURI).href); } catch { node.removeAttribute(name); }
32
+ }
33
+ });
34
+ return container.innerHTML;
35
+ }
36
+
37
+ /**
38
+ * Adds the copied passage as a Notis quote to a copy event that started inside
39
+ * `event.currentTarget`, and returns that quote (null when nothing inside was
40
+ * copied). Text in a rich editor (a Space's MarkdownEditor, Skill and automation
41
+ * instructions) is quoted too: the editor already wrote its own formats, so they
42
+ * stay as written and the quote reads the editor's plain text. Form fields keep
43
+ * plain copy.
44
+ */
45
+ export function addCopiedSelectionToClipboard(
46
+ event: ClipboardEvent<HTMLElement>,
47
+ context: Omit<ContextSelection, 'id' | 'text'> = {},
48
+ ): ContextSelection | null {
49
+ const boundary = event.currentTarget;
50
+ const target = event.target as Element | null;
51
+ if (!event.clipboardData || target?.closest?.('input,textarea')) return null;
52
+ // An inner boundary already quoted this copy: its resource wins over an outer default.
53
+ if (event.clipboardData.getData(NOTIS_CONTEXT_CLIPBOARD_TYPE)) return null;
54
+ const scope = boundary.getRootNode() as ShadowRoot & { getSelection?: () => Selection | null };
55
+ const selection = scope?.getSelection?.() || window.getSelection();
56
+ if (!selection || !boundary.contains(selection.anchorNode) || !boundary.contains(selection.focusNode)) return null;
57
+ const editorWrote = event.nativeEvent?.defaultPrevented ?? event.defaultPrevented;
58
+ const wrotePlain = editorWrote ? event.clipboardData.getData('text/plain') : '';
59
+ // A handler that cancelled the copy and wrote nothing at all blocked it: quote nothing.
60
+ if (editorWrote && !wrotePlain && !event.clipboardData.getData('text/html')) return null;
61
+ const text = wrotePlain || selection.toString();
62
+ if (!text.trim()) return null;
63
+
64
+ const payload: ContextSelection = { ...context, id: selectionId(), text };
65
+ if (!editorWrote) {
66
+ // Keep the copied formatting (links, bold, tables) for every other paste target.
67
+ const html = selectionHtml(selection);
68
+ event.clipboardData.setData('text/plain', text);
69
+ if (html) event.clipboardData.setData('text/html', html);
70
+ event.preventDefault();
71
+ }
72
+ event.clipboardData.setData(NOTIS_CONTEXT_CLIPBOARD_TYPE, JSON.stringify(payload));
73
+ return payload;
74
+ }
75
+
76
+ /**
77
+ * The Space-wide default every view gets from its host: text copied anywhere in
78
+ * the view quotes as the Space itself (its name on the pill, the view as source).
79
+ * A NotisSelectionBoundary inside the view quotes first and names its own resource.
80
+ */
81
+ export function copySpaceSelection(event: ClipboardEvent<HTMLElement>, runtime: QuoteRuntime | null): void {
82
+ const source = runtime?.contextSource;
83
+ captureCopiedSelection(event, runtime, source ? { source, title: source.appName } : {});
84
+ }
85
+
86
+ type QuoteRuntime = Pick<NotisRuntime, 'contextSource' | 'captureContextSelection'>;
87
+
88
+ /** Quotes a copy for the host chat; a public Site's runtime has no chat, so its copy stays the browser's own. */
89
+ function captureCopiedSelection(event: ClipboardEvent<HTMLElement>, runtime: QuoteRuntime | null, context: Omit<ContextSelection, 'id' | 'text'>): void {
90
+ if (!runtime?.captureContextSelection) return;
91
+ const payload = addCopiedSelectionToClipboard(event, context);
92
+ if (payload) runtime.captureContextSelection(payload);
93
+ }
94
+
21
95
  /**
22
96
  * Adds structured provenance to ordinary copied text. Pasting still works in
23
97
  * every app because `text/plain` is preserved; Notis chat additionally reads
@@ -30,30 +104,35 @@ export function NotisSelectionBoundary({
30
104
  style,
31
105
  }: NotisSelectionBoundaryProps) {
32
106
  const runtime = useNotisRuntime();
33
- const onCopy = useCallback((event: ClipboardEvent<HTMLDivElement>) => {
34
- const target = event.target as Element | null;
35
- if (target?.closest?.('input,textarea,[contenteditable="true"]')) return;
36
- const scope = event.currentTarget.getRootNode() as ShadowRoot & { getSelection?: () => Selection | null };
37
- const selection = scope?.getSelection?.() || window.getSelection();
38
- const text = selection?.toString() ?? '';
39
- if (
40
- !text.trim()
41
- || !selection
42
- || !event.currentTarget.contains(selection.anchorNode)
43
- || !event.currentTarget.contains(selection.focusNode)
44
- ) return;
45
-
46
- const payload: ContextSelection = {
47
- id: selectionId(),
48
- text,
49
- ...(runtime?.contextSource ? { source: runtime.contextSource } : {}),
50
- ...(resource ? { resource: { ...resource, snapshot: undefined } } : {}),
51
- };
52
- event.clipboardData.setData('text/plain', text);
53
- event.clipboardData.setData(NOTIS_CONTEXT_CLIPBOARD_TYPE, JSON.stringify(payload));
54
- event.preventDefault();
55
- runtime?.captureContextSelection?.(payload);
56
- }, [resource, runtime]);
107
+ const onCopy = useCallback((event: ClipboardEvent<HTMLDivElement>) => captureCopiedSelection(event, runtime, {
108
+ ...(runtime?.contextSource ? { source: runtime.contextSource } : {}),
109
+ ...(resource ? { resource: { ...resource, snapshot: undefined } } : {}),
110
+ }), [resource, runtime]);
57
111
 
58
- return <div className={className} style={style} onCopy={onCopy}>{children}</div>;
112
+ // Cite reads the same resource as copy: the bar looks it up from the selection (`quoteResourceFor`).
113
+ const marker = resource ? JSON.stringify({ ...resource, snapshot: undefined }) : undefined;
114
+ return <div className={className} style={style} onCopy={onCopy} data-notis-quote-resource={marker}>{children}</div>;
115
+ }
116
+
117
+ /** The resource a Space's own boundary names for the text in `range`, as copy would quote it; null outside one. */
118
+ export function quoteResourceFor(range: Range): ContextResource | null {
119
+ const start = range.commonAncestorContainer;
120
+ const element = start.nodeType === Node.ELEMENT_NODE ? start as Element : start.parentElement;
121
+ const marked = element?.closest('[data-notis-quote-resource]')?.getAttribute('data-notis-quote-resource');
122
+ if (!marked) return null;
123
+ try { return JSON.parse(marked) as ContextResource; } catch { return null; }
124
+ }
125
+
126
+ /**
127
+ * Cite for a Space (truth PRT-087): the selected text goes to chat as the quote copy would make, its Space as source
128
+ * and the boundary's resource when one names it. A Site's runtime has no chat, so it cites nothing.
129
+ */
130
+ export function citeSpaceSelection(runtime: Pick<NotisRuntime, 'contextSource' | 'addContext'> | null, range: Range, text: string): Promise<boolean> {
131
+ if (!runtime?.addContext) return Promise.resolve(false);
132
+ const resource = quoteResourceFor(range);
133
+ const source = runtime.contextSource;
134
+ return runtime.addContext({
135
+ id: selectionId(), text,
136
+ ...(resource ? { resource } : source ? { title: source.appName } : {}),
137
+ });
59
138
  }