oneslash-design-system 2.28.1 → 2.30.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 (248) hide show
  1. package/README.md +1 -1
  2. package/dist/DESIGN.md +31 -1
  3. package/dist/cases/about-page.md +2 -0
  4. package/dist/cases/accept-invite.md +2 -0
  5. package/dist/cases/account-menu.md +2 -0
  6. package/dist/cases/activity-timeline.md +2 -0
  7. package/dist/cases/admin-inbox.md +2 -0
  8. package/dist/cases/agent-asks-before-risky-action.md +3 -1
  9. package/dist/cases/agent-cancels-when-unanswered.md +2 -0
  10. package/dist/cases/agent-changes-review/all-at-once.d.ts +1 -0
  11. package/dist/cases/agent-changes-review/all-at-once.jsx +238 -0
  12. package/dist/cases/agent-changes-review/per-change.d.ts +1 -0
  13. package/dist/cases/agent-changes-review/per-change.jsx +203 -0
  14. package/dist/cases/agent-changes-review.md +585 -0
  15. package/dist/cases/agent-handoff/to-agent.d.ts +1 -0
  16. package/dist/cases/agent-handoff/to-agent.jsx +53 -0
  17. package/dist/cases/agent-handoff/to-person.d.ts +1 -0
  18. package/dist/cases/agent-handoff/to-person.jsx +84 -0
  19. package/dist/cases/agent-handoff.md +231 -0
  20. package/dist/cases/agent-memory/list.d.ts +1 -0
  21. package/dist/cases/agent-memory/list.jsx +256 -0
  22. package/dist/cases/agent-memory.md +354 -0
  23. package/dist/cases/agent-options.md +2 -0
  24. package/dist/cases/agent-pending-reply/steps.jsx +70 -21
  25. package/dist/cases/agent-pending-reply.md +74 -27
  26. package/dist/cases/agent-permissions/levels.d.ts +3 -0
  27. package/dist/cases/agent-permissions/levels.jsx +51 -0
  28. package/dist/cases/agent-permissions/per-tool.d.ts +3 -0
  29. package/dist/cases/agent-permissions/per-tool.jsx +180 -0
  30. package/dist/cases/agent-permissions.md +319 -0
  31. package/dist/cases/agent-plan-proposal/changes.jsx +18 -11
  32. package/dist/cases/agent-plan-proposal/steps.jsx +11 -4
  33. package/dist/cases/agent-plan-proposal.md +36 -21
  34. package/dist/cases/agent-question.md +2 -0
  35. package/dist/cases/agent-refuses-clearly.md +2 -0
  36. package/dist/cases/agent-run-failure/limit-reached.d.ts +1 -0
  37. package/dist/cases/agent-run-failure/limit-reached.jsx +172 -0
  38. package/dist/cases/agent-run-failure/step-failed.d.ts +3 -0
  39. package/dist/cases/agent-run-failure/step-failed.jsx +187 -0
  40. package/dist/cases/agent-run-failure.md +500 -0
  41. package/dist/cases/agent-says-what-it-is.md +2 -0
  42. package/dist/cases/agent-says-where-it-stopped.md +27 -0
  43. package/dist/cases/agent-settings.md +2 -0
  44. package/dist/cases/agent-shows-progress.md +2 -0
  45. package/dist/cases/agent-shows-sources.md +2 -0
  46. package/dist/cases/api-keys.md +2 -0
  47. package/dist/cases/app-shell.md +2 -0
  48. package/dist/cases/artifact-card.md +2 -0
  49. package/dist/cases/ask-page.md +2 -0
  50. package/dist/cases/auth-gate-loading.md +2 -0
  51. package/dist/cases/billing-page.md +2 -0
  52. package/dist/cases/blog-index.md +2 -0
  53. package/dist/cases/breadcrumb.md +2 -0
  54. package/dist/cases/breakdown-list.md +2 -0
  55. package/dist/cases/bulk-actions/list.d.ts +1 -0
  56. package/dist/cases/bulk-actions/list.jsx +206 -0
  57. package/dist/cases/bulk-actions/paged-table.d.ts +1 -0
  58. package/dist/cases/bulk-actions/paged-table.jsx +243 -0
  59. package/dist/cases/bulk-actions.md +553 -0
  60. package/dist/cases/changelog.md +2 -0
  61. package/dist/cases/chart.md +2 -0
  62. package/dist/cases/check-your-email.md +2 -0
  63. package/dist/cases/code-sample.md +2 -0
  64. package/dist/cases/collapsible-search.md +2 -0
  65. package/dist/cases/comment-thread.md +2 -0
  66. package/dist/cases/comparison-page/table.d.ts +1 -0
  67. package/dist/cases/comparison-page/table.jsx +97 -0
  68. package/dist/cases/comparison-page.md +156 -0
  69. package/dist/cases/composer-limit.md +2 -0
  70. package/dist/cases/confirm-destructive-action.md +2 -0
  71. package/dist/cases/confirm-dialogs.md +2 -0
  72. package/dist/cases/connection-status/card.d.ts +1 -0
  73. package/dist/cases/connection-status/card.jsx +97 -0
  74. package/dist/cases/connection-status/row.d.ts +1 -0
  75. package/dist/cases/connection-status/row.jsx +120 -0
  76. package/dist/cases/connection-status.md +330 -0
  77. package/dist/cases/contact-page.md +2 -0
  78. package/dist/cases/conversation-starters.md +2 -0
  79. package/dist/cases/cookie-choice.md +2 -0
  80. package/dist/cases/create-modal.md +2 -0
  81. package/dist/cases/danger-zone.md +2 -0
  82. package/dist/cases/dashboard.md +2 -0
  83. package/dist/cases/data-table-page.md +2 -0
  84. package/dist/cases/date-field.md +2 -0
  85. package/dist/cases/device-login.md +2 -0
  86. package/dist/cases/docs-component-page.md +2 -0
  87. package/dist/cases/email-confirmed.md +2 -0
  88. package/dist/cases/empty-list.md +2 -0
  89. package/dist/cases/empty-lists.md +2 -0
  90. package/dist/cases/empty-not-set-up.md +2 -0
  91. package/dist/cases/empty-search.md +2 -0
  92. package/dist/cases/error-page.md +2 -0
  93. package/dist/cases/faq.md +2 -0
  94. package/dist/cases/feature-grid.md +2 -0
  95. package/dist/cases/feedback-form.md +2 -0
  96. package/dist/cases/file-upload.md +2 -0
  97. package/dist/cases/filter-menu.md +2 -0
  98. package/dist/cases/forgot-password.md +2 -0
  99. package/dist/cases/form-errors.md +2 -0
  100. package/dist/cases/image-viewer.md +2 -0
  101. package/dist/cases/import-checklist.md +2 -0
  102. package/dist/cases/inline-form-feedback.md +2 -0
  103. package/dist/cases/integrations-list/nested.jsx +1 -1
  104. package/dist/cases/integrations-list/rows.jsx +1 -1
  105. package/dist/cases/integrations-list.md +6 -4
  106. package/dist/cases/invite-member.md +2 -0
  107. package/dist/cases/invoice-list.md +2 -0
  108. package/dist/cases/landing-hero.md +2 -0
  109. package/dist/cases/leaderboard.md +2 -0
  110. package/dist/cases/legal-page.md +2 -0
  111. package/dist/cases/load-failure.md +2 -0
  112. package/dist/cases/log-out-confirm.md +2 -0
  113. package/dist/cases/login-page.md +2 -0
  114. package/dist/cases/long-form-page.md +2 -0
  115. package/dist/cases/master-detail.md +2 -0
  116. package/dist/cases/members-list.md +2 -0
  117. package/dist/cases/mention-list.md +2 -0
  118. package/dist/cases/message-actions.md +2 -0
  119. package/dist/cases/message-attachments.md +2 -0
  120. package/dist/cases/message-composer/with-tools.jsx +17 -7
  121. package/dist/cases/message-composer.md +28 -11
  122. package/dist/cases/message-edit.md +2 -0
  123. package/dist/cases/message-reactions.md +2 -0
  124. package/dist/cases/message-row.md +2 -0
  125. package/dist/cases/message-send-failure/needs-a-person.d.ts +1 -0
  126. package/dist/cases/message-send-failure/needs-a-person.jsx +116 -0
  127. package/dist/cases/message-send-failure/retrying.d.ts +1 -0
  128. package/dist/cases/message-send-failure/retrying.jsx +116 -0
  129. package/dist/cases/message-send-failure.md +308 -0
  130. package/dist/cases/mobile-menu.md +2 -0
  131. package/dist/cases/newsletter-signup.md +2 -0
  132. package/dist/cases/no-access/page.d.ts +1 -0
  133. package/dist/cases/no-access/page.jsx +37 -0
  134. package/dist/cases/no-access/read-only.d.ts +1 -0
  135. package/dist/cases/no-access/read-only.jsx +33 -0
  136. package/dist/cases/no-access.md +147 -0
  137. package/dist/cases/not-found-page.md +2 -0
  138. package/dist/cases/notification-menu.md +2 -0
  139. package/dist/cases/number-format.md +2 -0
  140. package/dist/cases/oauth-consent.md +2 -0
  141. package/dist/cases/on-off-settings.md +2 -0
  142. package/dist/cases/on-this-page.md +2 -0
  143. package/dist/cases/onboarding.md +2 -0
  144. package/dist/cases/one-main-action.md +2 -0
  145. package/dist/cases/overflow-menu.md +2 -0
  146. package/dist/cases/page-end.md +2 -0
  147. package/dist/cases/page-header.md +2 -0
  148. package/dist/cases/paged-card.md +2 -0
  149. package/dist/cases/password-gate.md +2 -0
  150. package/dist/cases/payment-method.md +2 -0
  151. package/dist/cases/people-row.md +2 -0
  152. package/dist/cases/phone-navigation.md +2 -0
  153. package/dist/cases/plan-change-confirm.md +2 -0
  154. package/dist/cases/plan-comparison.md +3 -1
  155. package/dist/cases/plan-picker.md +4 -1
  156. package/dist/cases/plan-sign-off.md +2 -0
  157. package/dist/cases/pricing-section.md +5 -1
  158. package/dist/cases/product-cards.md +2 -0
  159. package/dist/cases/product-demo/scripted.d.ts +1 -0
  160. package/dist/cases/product-demo/scripted.jsx +99 -0
  161. package/dist/cases/product-demo/still.d.ts +1 -0
  162. package/dist/cases/product-demo/still.jsx +20 -0
  163. package/dist/cases/product-demo.md +226 -0
  164. package/dist/cases/profile-form.md +2 -0
  165. package/dist/cases/quick-switcher.md +2 -0
  166. package/dist/cases/range-switch.md +2 -0
  167. package/dist/cases/rename.md +2 -0
  168. package/dist/cases/reply-feedback.md +2 -0
  169. package/dist/cases/reply-sources.md +2 -0
  170. package/dist/cases/route-loading.md +2 -0
  171. package/dist/cases/scope-picker.md +2 -0
  172. package/dist/cases/section-index.md +2 -0
  173. package/dist/cases/session-expired/in-place.d.ts +1 -0
  174. package/dist/cases/session-expired/in-place.jsx +63 -0
  175. package/dist/cases/session-expired/redirect.d.ts +1 -0
  176. package/dist/cases/session-expired/redirect.jsx +62 -0
  177. package/dist/cases/session-expired.md +204 -0
  178. package/dist/cases/set-new-password.md +2 -0
  179. package/dist/cases/settings-page.md +2 -0
  180. package/dist/cases/settings-save.md +2 -0
  181. package/dist/cases/side-pane.md +2 -0
  182. package/dist/cases/sidebar-nav.md +2 -0
  183. package/dist/cases/sign-up-page.md +3 -0
  184. package/dist/cases/signup-from-site/plain.d.ts +1 -0
  185. package/dist/cases/signup-from-site/plain.jsx +125 -0
  186. package/dist/cases/signup-from-site/with-plan.d.ts +4 -0
  187. package/dist/cases/signup-from-site/with-plan.jsx +151 -0
  188. package/dist/cases/signup-from-site.md +351 -0
  189. package/dist/cases/site-footer.md +2 -0
  190. package/dist/cases/site-header/links.d.ts +3 -1
  191. package/dist/cases/site-header/links.jsx +6 -2
  192. package/dist/cases/site-header.md +11 -3
  193. package/dist/cases/site-matches-app.md +32 -0
  194. package/dist/cases/site-search.md +2 -0
  195. package/dist/cases/slash-command-list.md +2 -0
  196. package/dist/cases/stat-row.md +2 -0
  197. package/dist/cases/status-label.md +3 -1
  198. package/dist/cases/success-feedback.md +2 -0
  199. package/dist/cases/tabbed-panels.md +2 -0
  200. package/dist/cases/tag-filter.md +2 -0
  201. package/dist/cases/task-header.md +2 -0
  202. package/dist/cases/theme-switcher.md +2 -0
  203. package/dist/cases/type-to-confirm.md +2 -0
  204. package/dist/cases/typing-and-status.md +2 -0
  205. package/dist/cases/unsaved-changes-guard.md +2 -0
  206. package/dist/cases/upgrade-prompt.md +2 -0
  207. package/dist/cases/usage-meters.md +2 -0
  208. package/dist/cases.json +1492 -39
  209. package/dist/components/checkBox.d.ts +7 -2
  210. package/dist/components/checkBox.jsx +39 -14
  211. package/dist/components/diff.d.ts +32 -0
  212. package/dist/components/diff.jsx +42 -0
  213. package/dist/components/segmentedControl.d.ts +3 -1
  214. package/dist/components/segmentedControl.jsx +8 -6
  215. package/dist/components/slidingIndicator.d.ts +5 -2
  216. package/dist/components/slidingIndicator.jsx +9 -3
  217. package/dist/components/tableContainer.d.ts +1 -1
  218. package/dist/components/tableContainer.jsx +2 -2
  219. package/dist/components/timeStamp.d.ts +3 -1
  220. package/dist/components/timeStamp.jsx +4 -2
  221. package/dist/components/useReducedMotion.d.ts +6 -0
  222. package/dist/components/useReducedMotion.js +19 -0
  223. package/dist/index.d.ts +2 -0
  224. package/dist/index.js +2 -0
  225. package/dist/internal/diff.d.ts +17 -0
  226. package/dist/internal/diff.js +44 -0
  227. package/dist/native-mapping.json +9 -2
  228. package/dist/stories/AgentPermissions.probe.stories.d.ts +7 -0
  229. package/dist/stories/AgentPermissions.probe.stories.jsx +18 -0
  230. package/dist/stories/AgentRunFailure.probe.stories.d.ts +6 -0
  231. package/dist/stories/AgentRunFailure.probe.stories.jsx +12 -0
  232. package/dist/stories/Cases.generated.stories.d.ts +24 -0
  233. package/dist/stories/Cases.generated.stories.jsx +48 -0
  234. package/dist/stories/Checkbox.stories.d.ts +3 -0
  235. package/dist/stories/Checkbox.stories.jsx +38 -0
  236. package/dist/stories/Diff.stories.d.ts +10 -0
  237. package/dist/stories/Diff.stories.jsx +45 -0
  238. package/dist/stories/SegmentedControl.stories.d.ts +1 -0
  239. package/dist/stories/SegmentedControl.stories.jsx +6 -0
  240. package/dist/stories/SignupFromSite.probe.stories.d.ts +7 -0
  241. package/dist/stories/SignupFromSite.probe.stories.jsx +17 -0
  242. package/dist/stories/SiteHeader.probe.stories.d.ts +6 -0
  243. package/dist/stories/SiteHeader.probe.stories.jsx +13 -0
  244. package/dist/stories/Table.stories.d.ts +1 -0
  245. package/dist/stories/Table.stories.jsx +25 -0
  246. package/dist/stories/TimeStamp.stories.d.ts +1 -0
  247. package/dist/stories/TimeStamp.stories.jsx +13 -0
  248. package/package.json +5 -1
package/dist/cases.json CHANGED
@@ -6,6 +6,9 @@
6
6
  "kind": "design",
7
7
  "level": "page",
8
8
  "area": "content",
9
+ "surface": [
10
+ "site"
11
+ ],
9
12
  "situation": "A visitor wants to know who is behind the work and whether to get in touch.",
10
13
  "do": [
11
14
  "Open with a `PageHeader` whose title is the person's name and whose lede says what they do in one sentence.",
@@ -56,6 +59,9 @@
56
59
  "kind": "design",
57
60
  "level": "page",
58
61
  "area": "auth",
62
+ "surface": [
63
+ "app"
64
+ ],
59
65
  "situation": "A person opens an invite link to join a workspace.",
60
66
  "do": [
61
67
  "Name the workspace in a `Heading` with `level={1}`: \"You're invited to Acme Design\".",
@@ -120,6 +126,9 @@
120
126
  "kind": "design",
121
127
  "level": "organism",
122
128
  "area": "menu",
129
+ "surface": [
130
+ "app"
131
+ ],
123
132
  "situation": "A person opens a menu for their own account to change settings, get help or log out.",
124
133
  "do": [
125
134
  "Use a small tertiary `Button` whose label is the person's name, with their `UserImage` as `decoIcon`: `decoIcon={<UserImage userHandle={name} size={20} decorative />}`.",
@@ -168,6 +177,9 @@
168
177
  "kind": "design",
169
178
  "level": "organism",
170
179
  "area": "shell",
180
+ "surface": [
181
+ "app"
182
+ ],
171
183
  "situation": "A person reads what happened on a task, or opens an older version of a document and brings it back.",
172
184
  "do": [
173
185
  "Show the history in a `SidePane` titled 'History' beside the page, as the case 'Side pane' says.",
@@ -248,6 +260,9 @@
248
260
  "kind": "design",
249
261
  "level": "page",
250
262
  "area": "content",
263
+ "surface": [
264
+ "app"
265
+ ],
251
266
  "situation": "The owner of a site reads the messages that visitors sent through its contact form.",
252
267
  "do": [
253
268
  "Open with a `PageHeader` titled 'Messages' and a lede that counts what is unread: '3 of 12 unread'.",
@@ -314,6 +329,9 @@
314
329
  "kind": "rule",
315
330
  "level": "rule",
316
331
  "area": "agent",
332
+ "surface": [
333
+ "agent"
334
+ ],
317
335
  "situation": "The agent is about to do something that changes shared work or is hard to undo.",
318
336
  "answer": "An action is risky when it changes shared work or is hard to undo. In a product that works with code, that includes opening or merging a pull request, deleting files, closing an issue and rolling back a release. Carrying out a plan of several changes is risky too. Before a risky action the agent stops and posts a card with the exact action: every step it will take, or the changes themselves, which the person can open. The agent does nothing until the person presses the approve button.",
319
337
  "why": "A person can only approve what they can see, and an agent's mistake in shared work costs other people.",
@@ -321,7 +339,7 @@
321
339
  "List every step in the card, in the order the agent will do them.",
322
340
  "Offer a way to see the full changes, such as a View Changes button, before the approve button is pressed.",
323
341
  "Let the person edit the plan or cancel it, not only approve it.",
324
- "Mark the card Approved or Cancelled once it is decided, and remove its buttons."
342
+ "Mark the card with the decision once it is made, such as Approved, Applied or Cancelled, and remove its buttons."
325
343
  ],
326
344
  "dont": [
327
345
  "Do not carry out a risky action before the person approves it.",
@@ -336,6 +354,9 @@
336
354
  "kind": "rule",
337
355
  "level": "rule",
338
356
  "area": "agent",
357
+ "surface": [
358
+ "agent"
359
+ ],
339
360
  "situation": "The agent has asked a question or proposed an action, and nobody answers.",
340
361
  "answer": "The agent never takes silence as a yes: while a question or proposal waits, it does nothing that depends on the answer. Each product sets the waiting time and shows it on the waiting card. When the time is up, the agent cancels the request, marks the card Cancelled, and posts one line saying what it did not do. The agent may write a plan that lists the unanswered questions as open questions. It may not carry out anything that depends on an answer.",
341
362
  "why": "An agent that acts on silence does work nobody approved, and one that waits forever leaves work stuck without saying so.",
@@ -350,12 +371,227 @@
350
371
  "Do not cancel a request without saying so in the thread."
351
372
  ]
352
373
  },
374
+ {
375
+ "id": "agent-changes-review",
376
+ "title": "Review of an agent's changes",
377
+ "kind": "design",
378
+ "level": "organism",
379
+ "area": "agent",
380
+ "surface": [
381
+ "agent"
382
+ ],
383
+ "situation": "The agent has changed files or other work and a person reviews the changes before they are applied.",
384
+ "do": [
385
+ "Follow the rule 'An agent asks before a risky action': nothing is applied until the person presses the apply Button.",
386
+ "Show the changes themselves, each file in a `Diff`, not a summary of them. `Diff` marks each line with a `+` or `-` and hidden text, so color is never the only sign.",
387
+ "Put each file in an `Accordion` item titled with its path, with the first one open, when the changes belong together. Say the count in `secondTitle`: '13 added, 3 removed'.",
388
+ "Say the size of the whole change above the files: '3 files, 24 lines added, 6 removed'. Count it from the lines, not by hand.",
389
+ "Order the Buttons 'Cancel', 'Request Changes', then 'Apply Changes' as the primary Button, under the files.",
390
+ "Mark the card 'Cancelled' on 'Cancel', and add one line under it: 'Cancelled. Nothing was changed.'",
391
+ "Show the waiting time above the Buttons while the card is open: 'Waits 10 more minutes, then cancels.'",
392
+ "Open a `Textarea` labelled 'What should change?' on 'Request Changes', with 'Discard' and 'Send', as the case 'Plan proposal' does.",
393
+ "Give each change its own `SettingsSection`, titled with the file or the thing it changes, when each change stands alone. Put its `Diff` and its Buttons in it.",
394
+ "Give each change 'Accept' as a small secondary Button and 'Reject' as a small tertiary one. Name the change in each `aria-label`: 'Accept the change to data/plans.json'.",
395
+ "Show an 'Accepted' or 'Rejected' `Tag` on a decided change, with an 'Undo' tertiary Button in place of its Buttons.",
396
+ "Move focus after 'Accept' or 'Reject' to the next change that is not decided, on its first Button. When none is left, move it to the apply Button.",
397
+ "Move focus to 'Reject All' when none is left and none was accepted, and to the change's 'Accept' after 'Undo'.",
398
+ "Count the accepted changes in the apply Button's label: 'Apply 2 Changes'. With none accepted it is disabled, and a line under the changes says why: 'Accept at least one change to apply it.'",
399
+ "Say how many changes are not decided yet, and that applying leaves them out.",
400
+ "Make the pressed Button `loading` and keep its label. Disable the others while the request runs.",
401
+ "Mark the card with an 'Applied', 'Rejected' or 'Cancelled' `Tag` once it is done, remove its Buttons and say in one line what was applied."
402
+ ],
403
+ "dont": [
404
+ "Do not apply a change on 'Accept'. Applying is one step at the end.",
405
+ "Do not show added and removed lines by color alone.",
406
+ "Do not replace the changes with a list of file names.",
407
+ "Do not change the apply Button's label while it is loading, such as to 'Applying...'.",
408
+ "Do not let a second press on a decided card apply or reject it again."
409
+ ],
410
+ "options": [
411
+ {
412
+ "id": "all-at-once",
413
+ "title": "All at once",
414
+ "useWhen": "The changes belong together, such as one fix across files.",
415
+ "source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport { Bot } from 'lucide-react';\nimport Message from 'oneslash-design-system/components/message';\nimport UserImage from 'oneslash-design-system/components/userImage';\nimport Tag from 'oneslash-design-system/components/tag';\nimport TimeStamp from 'oneslash-design-system/components/timeStamp';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Button from 'oneslash-design-system/components/button';\nimport Surface from 'oneslash-design-system/components/surface';\nimport Accordion from 'oneslash-design-system/components/accordion';\nimport Diff, { diffLines } from 'oneslash-design-system/components/diff';\nimport Textarea from 'oneslash-design-system/components/textarea';\nimport { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';\n\ntype Focusable = HTMLButtonElement | HTMLAnchorElement | null;\n\nconst agentName = 'Acme Agent';\n\nconst request = { from: 'Dana Lee', at: new Date('2026-11-16T14:30:00Z'), text: 'Can you add the Business plan to the pricing page?' };\nconst proposedAt = new Date('2026-11-16T14:34:00Z');\n\n// One change across three files: each file before and after. A real app gets the lines from the server.\nconst files = [\n {\n id: 'plans',\n path: 'data/plans.json',\n before: [\n '[',\n ' { \"id\": \"free\", \"price\": \"$0.00\" },',\n ' { \"id\": \"pro\", \"price\": \"$8.00\" }',\n ']',\n ],\n after: [\n '[',\n ' { \"id\": \"free\", \"price\": \"$0.00\" },',\n ' { \"id\": \"pro\", \"price\": \"$8.00\" },',\n ' { \"id\": \"business\", \"price\": \"$16.00\" }',\n ']',\n ],\n },\n {\n id: 'plan-table',\n path: 'ui/planTable.tsx',\n before: [\n 'const columns = [',\n \" { id: 'free', title: 'Free' },\",\n \" { id: 'pro', title: 'Pro' },\",\n '];',\n '',\n 'const rows = [',\n \" { feature: 'Members', free: '3', pro: '20' },\",\n \" { feature: 'Agent replies', free: '50', pro: '500' },\",\n \" { feature: 'Support', free: 'Email', pro: 'Email' },\",\n '];',\n ],\n after: [\n 'const columns = [',\n \" { id: 'free', title: 'Free' },\",\n \" { id: 'pro', title: 'Pro' },\",\n \" { id: 'business', title: 'Business' },\",\n '];',\n '',\n 'const rows = [',\n ' {',\n \" feature: 'Members',\",\n \" free: '3', pro: '20', business: 'Any',\",\n ' },',\n ' {',\n \" feature: 'Agent replies',\",\n \" free: '50', pro: '500', business: '2,000',\",\n ' },',\n ' {',\n \" feature: 'Support',\",\n \" free: 'Email', pro: 'Email', business: 'Chat',\",\n ' },',\n '];',\n ],\n },\n {\n id: 'pricing',\n path: 'pages/pricing.tsx',\n before: [\n \"import PlanTable from '../ui/planTable';\",\n '',\n 'export default function Pricing() {',\n ' return (',\n ' <Page title=\"Pricing\">',\n ' <PlanTable />',\n ' </Page>',\n ' );',\n '}',\n ],\n after: [\n \"import PlanTable from '../ui/planTable';\",\n \"import ContactSales from '../ui/contactSales';\",\n \"import Faq from '../ui/faq';\",\n '',\n 'export default function Pricing() {',\n ' return (',\n ' <Page title=\"Plans and pricing\">',\n ' <PlanTable highlight=\"business\" />',\n ' <ContactSales',\n ' plan=\"business\"',\n ' title=\"Business for larger teams\"',\n ' />',\n ' <Faq />',\n ' </Page>',\n ' );',\n '}',\n ],\n },\n].map((f) => {\n const lines = diffLines(f.before.join('\\n'), f.after.join('\\n'));\n return {\n id: f.id,\n path: f.path,\n lines,\n added: lines.filter((l) => l.kind === 'added').length,\n removed: lines.filter((l) => l.kind === 'removed').length,\n };\n});\n\n// Counted from the lines, so the summary always matches the files.\nconst added = files.reduce((n, f) => n + f.added, 0);\nconst removed = files.reduce((n, f) => n + f.removed, 0);\nconst summary = `${files.length} files, ${added} lines added, ${removed} removed`;\n\ntype Status = 'open' | 'requesting' | 'redoing' | 'applied' | 'cancelled';\n\n// The agent's marks, as the rule 'An agent says what it is' says.\nfunction agentMeta(at: Date) {\n return (\n <>\n <Tag variant=\"contained\" size=\"small\" label=\"Agent\" />\n <TimeStamp createdAt={at} dateFormat=\"absolute\" data=\"time\" />\n <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">Model name</Paragraph>\n </>\n );\n}\n\nexport default function AgentChangesReviewAllAtOnce() {\n const [status, setStatus] = useState<Status>('open');\n const [pending, setPending] = useState<'apply' | 'cancel' | 'send' | null>(null);\n const [draft, setDraft] = useState('');\n const timer = useRef<ReturnType<typeof setTimeout>>();\n const requestButton = useRef<Focusable>(null);\n // Where focus goes after the next render, once the element it goes to is on screen.\n const focusNext = useRef<() => void>();\n\n // Stops the request if the example goes away before it ends.\n useEffect(() => () => clearTimeout(timer.current), []);\n\n useEffect(() => {\n const move = focusNext.current;\n focusNext.current = undefined;\n move?.();\n });\n\n // Decided once: the Buttons go away, so a second press cannot apply or cancel it again.\n // Nothing takes their place: a real app moves focus to the message box.\n function decide(action: 'apply' | 'cancel') {\n if (pending || status !== 'open') return;\n setPending(action);\n // Stands in for the request to the server.\n timer.current = setTimeout(() => {\n setPending(null);\n setStatus(action === 'apply' ? 'applied' : 'cancelled');\n }, 1200);\n }\n\n function startRequest() {\n if (pending) return;\n setDraft('');\n setStatus('requesting');\n }\n\n // 'Discard' leaves the field and keeps the changes open for review.\n function discard() {\n setStatus('open');\n focusNext.current = () => requestButton.current?.focus();\n }\n\n const empty = draft.trim() === '';\n\n // 'Send' tells the agent what should change. The Buttons go, and the agent redoes the changes.\n // Nothing takes their place: a real app moves focus to the message box.\n function send() {\n if (pending || empty) return;\n setPending('send');\n // Stands in for the request to the server.\n timer.current = setTimeout(() => {\n setPending(null);\n setStatus('redoing');\n }, 1200);\n }\n\n return (\n <Center width=\"page\">\n <Stack gap=\"large\">\n <Heading level={1} size=\"h5\">Launch plan</Heading>\n {/* A real app gives the list that holds the rows role=\"log\". */}\n <Stack gap=\"small\">\n <Message\n aria-label={request.from}\n avatar={<UserImage userHandle={request.from} decorative />}\n name={request.from}\n meta={<TimeStamp createdAt={request.at} dateFormat=\"absolute\" data=\"time\" />}\n >\n <Paragraph measure=\"none\">{request.text}</Paragraph>\n </Message>\n <Message\n aria-label={`${agentName}, agent`}\n avatar={<UserImage userHandle={agentName} icon={Bot} decorative />}\n name={agentName}\n meta={agentMeta(proposedAt)}\n >\n <Surface padding=\"small\">\n <Stack gap=\"medium\">\n {/* A real app announces the decided Tag in a polite live region. */}\n <Cluster gap=\"small\">\n <Heading level={2} size=\"subtitle1\">Changes ready</Heading>\n {status === 'applied' && <Tag variant=\"contained\" size=\"small\" color=\"success\" label=\"Applied\" />}\n {status === 'cancelled' && <Tag variant=\"contained\" size=\"small\" label=\"Cancelled\" />}\n </Cluster>\n <Paragraph measure=\"none\">These changes add the Business plan at $16.00 per member per month to the pricing page. They belong together, so they apply together.</Paragraph>\n <Paragraph size=\"body2\" tone=\"secondary\" measure=\"none\">{summary}</Paragraph>\n {/* The changes themselves, one file per item, the first one open. */}\n <Accordion\n id=\"agent-changes-review-all-at-once-files\"\n headingLevel={3}\n defaultOpen={[files[0].id]}\n items={files.map((f) => ({\n id: f.id,\n title: f.path,\n secondTitle: `${f.added} added, ${f.removed} removed`,\n content: <Diff id={`agent-changes-review-all-at-once-${f.id}`} label={`Changes to ${f.path}`} lines={f.lines} maxRows={16} wrap />,\n }))}\n />\n {status === 'requesting' && (\n <Textarea\n id=\"agent-changes-review-all-at-once-request\"\n label=\"What should change?\"\n value={draft}\n onChange={(e) => setDraft(e.target.value)}\n onSubmit={send}\n autoFocus\n disabled={pending === 'send'}\n />\n )}\n {status === 'redoing' && (\n <Paragraph measure=\"none\">Acme Agent is redoing the changes. It posts a new card when they are ready.</Paragraph>\n )}\n {/* The product sets the waiting time and counts it down. When it is up, nothing is applied. */}\n {(status === 'open' || status === 'requesting') && (\n <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">Waits 10 more minutes, then cancels.</Paragraph>\n )}\n {status === 'open' && (\n <Cluster gap=\"small\">\n <Button size=\"small\" type=\"tertiary\" state={pending === 'apply' ? 'disabled' : 'enabled'} label=\"Cancel\" loading={pending === 'cancel'} onClickButton={() => decide('cancel')} />\n <Button ref={requestButton} size=\"small\" type=\"secondary\" state={pending ? 'disabled' : 'enabled'} label=\"Request Changes\" onClickButton={startRequest} />\n {/* The product writes this label, never the agent. */}\n <Button size=\"small\" type=\"primary\" state={pending === 'cancel' ? 'disabled' : 'enabled'} label=\"Apply Changes\" loading={pending === 'apply'} onClickButton={() => decide('apply')} />\n </Cluster>\n )}\n {status === 'requesting' && (\n <Cluster gap=\"small\">\n <Button size=\"small\" type=\"tertiary\" state={pending === 'send' ? 'disabled' : 'enabled'} label=\"Discard\" onClickButton={discard} />\n <Button size=\"small\" type=\"primary\" state={empty ? 'disabled' : 'enabled'} label=\"Send\" loading={pending === 'send'} onClickButton={send} />\n </Cluster>\n )}\n </Stack>\n </Surface>\n </Message>\n {status === 'applied' && (\n // One line in the thread on what was applied, under the card.\n <Message compact aria-label={`${agentName}, agent`}>\n <Paragraph measure=\"none\">Applied the changes to {files.length} files.</Paragraph>\n </Message>\n )}\n {status === 'cancelled' && (\n // One line in the thread on what was not done, under the card.\n <Message compact aria-label={`${agentName}, agent`}>\n <Paragraph measure=\"none\">Cancelled. Nothing was changed.</Paragraph>\n </Message>\n )}\n </Stack>\n </Stack>\n </Center>\n );\n}\n",
416
+ "uses": [
417
+ "Accordion",
418
+ "Button",
419
+ "Center",
420
+ "Cluster",
421
+ "Diff",
422
+ "Heading",
423
+ "Message",
424
+ "Paragraph",
425
+ "Stack",
426
+ "Surface",
427
+ "Tag",
428
+ "Textarea",
429
+ "TimeStamp",
430
+ "UserImage",
431
+ "diffLines"
432
+ ]
433
+ },
434
+ {
435
+ "id": "per-change",
436
+ "title": "Change by change",
437
+ "useWhen": "Each change stands alone and a person may want only some.",
438
+ "source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport { Bot } from 'lucide-react';\nimport Message from 'oneslash-design-system/components/message';\nimport UserImage from 'oneslash-design-system/components/userImage';\nimport Tag from 'oneslash-design-system/components/tag';\nimport TimeStamp from 'oneslash-design-system/components/timeStamp';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Button from 'oneslash-design-system/components/button';\nimport Surface from 'oneslash-design-system/components/surface';\nimport SettingsSection from 'oneslash-design-system/components/settingsSection';\nimport Diff, { diffLines } from 'oneslash-design-system/components/diff';\nimport { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';\n\ntype Focusable = HTMLButtonElement | HTMLAnchorElement | null;\ntype Decision = 'accepted' | 'rejected';\n\nconst agentName = 'Acme Agent';\n\nconst request = { from: 'Dana Lee', at: new Date('2026-11-16T14:30:00Z'), text: 'Can you check the pricing page for mistakes?' };\nconst proposedAt = new Date('2026-11-16T14:33:00Z');\n\n// Three changes that each stand alone. A real app gets the lines from the server.\nconst changes = [\n {\n id: 'heading',\n path: 'pages/pricing.tsx',\n what: \"Fixes the spelling of 'Business' in a heading.\",\n before: ['<Section>', ' <h2>Busines plan</h2>', ' <PlanTable />', '</Section>'],\n after: ['<Section>', ' <h2>Business plan</h2>', ' <PlanTable />', '</Section>'],\n },\n {\n id: 'price',\n path: 'data/plans.json',\n what: 'Shows the Pro price with cents.',\n before: [' { \"id\": \"free\", \"price\": \"$0.00\" },', ' { \"id\": \"pro\", \"price\": \"$8\" }'],\n after: [' { \"id\": \"free\", \"price\": \"$0.00\" },', ' { \"id\": \"pro\", \"price\": \"$8.00\" }'],\n },\n {\n id: 'terms',\n path: 'components/footer.tsx',\n what: 'Points the Terms link at its new address.',\n before: ['<Link href=\"/terms-of-service\">', ' Terms', '</Link>'],\n after: ['<Link href=\"/legal/terms\">', ' Terms', '</Link>'],\n },\n].map((c) => ({ id: c.id, path: c.path, what: c.what, lines: diffLines(c.before.join('\\n'), c.after.join('\\n')) }));\n\ntype Status = 'open' | 'applied' | 'rejected';\n\nfunction changesWord(n: number) {\n return n === 1 ? 'Change' : 'Changes';\n}\n\n// The agent's marks, as the rule 'An agent says what it is' says.\nfunction agentMeta(at: Date) {\n return (\n <>\n <Tag variant=\"contained\" size=\"small\" label=\"Agent\" />\n <TimeStamp createdAt={at} dateFormat=\"absolute\" data=\"time\" />\n <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">Model name</Paragraph>\n </>\n );\n}\n\nexport default function AgentChangesReviewPerChange() {\n const [decisions, setDecisions] = useState<Record<string, Decision>>({});\n const [status, setStatus] = useState<Status>('open');\n const [pending, setPending] = useState<'apply' | 'reject' | null>(null);\n const timer = useRef<ReturnType<typeof setTimeout>>();\n // Each change's 'Accept' by change id, so focus can move to the next change that is not decided.\n const acceptButtons = useRef<Record<string, Focusable>>({});\n const applyButton = useRef<Focusable>(null);\n const rejectAllButton = useRef<Focusable>(null);\n // Where focus goes after the next render, once the element it goes to is on screen.\n const focusNext = useRef<() => void>();\n\n // Stops the request if the example goes away before it ends.\n useEffect(() => () => clearTimeout(timer.current), []);\n\n useEffect(() => {\n const move = focusNext.current;\n focusNext.current = undefined;\n move?.();\n });\n\n const accepted = changes.filter((c) => decisions[c.id] === 'accepted').length;\n const undecided = changes.filter((c) => !decisions[c.id]).length;\n\n // Deciding only marks the change. Nothing is applied until 'Apply'.\n // The Buttons that had focus are gone, so focus goes to the next change that is not decided, after this one first.\n // When every change is decided it goes to 'Apply', or to 'Reject All' when none was accepted, since 'Apply' is then disabled.\n function decide(id: string, decision: Decision) {\n if (pending || status !== 'open') return;\n const next = { ...decisions, [id]: decision };\n setDecisions(next);\n const at = changes.findIndex((c) => c.id === id);\n const order = [...changes.slice(at + 1), ...changes.slice(0, at)];\n const nextOpen = order.find((c) => !next[c.id]);\n const anyAccepted = changes.some((c) => next[c.id] === 'accepted');\n focusNext.current = () =>\n (nextOpen ? acceptButtons.current[nextOpen.id] : anyAccepted ? applyButton.current : rejectAllButton.current)?.focus();\n }\n\n // 'Undo' goes away with the Tag, so focus goes to the change's 'Accept'.\n function undo(id: string) {\n if (pending || status !== 'open') return;\n setDecisions((current) => {\n const next = { ...current };\n delete next[id];\n return next;\n });\n focusNext.current = () => acceptButtons.current[id]?.focus();\n }\n\n // Done once: the Buttons go away, so a second press cannot apply or reject again.\n // Nothing takes their place: a real app moves focus to the message box.\n function finish(action: 'apply' | 'reject') {\n if (pending || status !== 'open') return;\n if (action === 'apply' && accepted === 0) return;\n setPending(action);\n // Stands in for the request to the server.\n timer.current = setTimeout(() => {\n setPending(null);\n if (action === 'reject') {\n setDecisions(Object.fromEntries(changes.map((c) => [c.id, 'rejected' as Decision])));\n setStatus('rejected');\n return;\n }\n setStatus('applied');\n }, 1200);\n }\n\n const reason =\n accepted === 0\n ? 'Accept at least one change to apply it.'\n : undecided > 0\n ? `${undecided} ${undecided === 1 ? 'change is' : 'changes are'} not decided. Applying leaves ${undecided === 1 ? 'it' : 'them'} out.`\n : `${accepted} of ${changes.length} changes will be applied.`;\n\n const left = changes.length - accepted;\n const doneLine =\n status === 'applied'\n ? `Applied ${accepted} ${changesWord(accepted).toLowerCase()}. ${left} ${left === 1 ? 'change was' : 'changes were'} not applied.`\n : 'Rejected every change. Nothing was changed.';\n\n return (\n <Center width=\"page\">\n <Stack gap=\"large\">\n <Heading level={1} size=\"h5\">Launch plan</Heading>\n {/* A real app gives the list that holds the rows role=\"log\". */}\n <Stack gap=\"small\">\n <Message\n aria-label={request.from}\n avatar={<UserImage userHandle={request.from} decorative />}\n name={request.from}\n meta={<TimeStamp createdAt={request.at} dateFormat=\"absolute\" data=\"time\" />}\n >\n <Paragraph measure=\"none\">{request.text}</Paragraph>\n </Message>\n <Message\n aria-label={`${agentName}, agent`}\n avatar={<UserImage userHandle={agentName} icon={Bot} decorative />}\n name={agentName}\n meta={agentMeta(proposedAt)}\n >\n <Surface padding=\"small\">\n <Stack gap=\"large\">\n <Stack gap=\"small\">\n {/* A real app announces the decided Tag in a polite live region. */}\n <Cluster gap=\"small\">\n <Heading level={2} size=\"h6\">Fixes ready</Heading>\n {status === 'applied' && <Tag variant=\"contained\" size=\"small\" color=\"success\" label=\"Applied\" />}\n {status === 'rejected' && <Tag variant=\"contained\" size=\"small\" label=\"Rejected\" />}\n </Cluster>\n <Paragraph measure=\"none\">I found three mistakes on the pricing page. Each fix stands alone, so pick the ones you want. Nothing changes until you apply.</Paragraph>\n </Stack>\n {changes.map((c) => {\n const decision = decisions[c.id];\n return (\n <SettingsSection key={c.id} level={3} title={c.path} description={c.what}>\n <Diff id={`agent-changes-review-per-change-${c.id}`} label={`Changes to ${c.path}`} lines={c.lines} wrap />\n {decision ? (\n // The Tag says the decision in words, so color is never the only sign.\n <Cluster gap=\"small\">\n <Tag variant=\"contained\" size=\"small\" color={decision === 'accepted' ? 'success' : 'default'} label={decision === 'accepted' ? 'Accepted' : 'Rejected'} />\n {status === 'open' && (\n <Button size=\"small\" type=\"tertiary\" state={pending ? 'disabled' : 'enabled'} label=\"Undo\" aria-label={`Undo the decision on ${c.path}`} onClickButton={() => undo(c.id)} />\n )}\n </Cluster>\n ) : (\n <Cluster gap=\"small\">\n <Button\n ref={(el) => { acceptButtons.current[c.id] = el; }}\n size=\"small\"\n type=\"secondary\"\n state={pending ? 'disabled' : 'enabled'}\n label=\"Accept\"\n aria-label={`Accept the change to ${c.path}`}\n onClickButton={() => decide(c.id, 'accepted')}\n />\n <Button size=\"small\" type=\"tertiary\" state={pending ? 'disabled' : 'enabled'} label=\"Reject\" aria-label={`Reject the change to ${c.path}`} onClickButton={() => decide(c.id, 'rejected')} />\n </Cluster>\n )}\n </SettingsSection>\n );\n })}\n {status === 'open' && (\n <Stack gap=\"small\">\n {/* The product sets the waiting time and counts it down. When it is up, nothing is applied. */}\n <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">Waits 10 more minutes, then cancels.</Paragraph>\n <Paragraph id=\"agent-changes-review-per-change-reason\" size=\"body2\" tone=\"secondary\" measure=\"none\">{reason}</Paragraph>\n <Cluster gap=\"small\">\n <Button ref={rejectAllButton} size=\"small\" type=\"tertiary\" state={pending === 'apply' ? 'disabled' : 'enabled'} label=\"Reject All\" loading={pending === 'reject'} onClickButton={() => finish('reject')} />\n {/* The count is always the accepted count. With none accepted it is disabled, and the line above says why. */}\n <Button\n ref={applyButton}\n size=\"small\"\n type=\"primary\"\n state={accepted === 0 || pending === 'reject' ? 'disabled' : 'enabled'}\n label={`Apply ${accepted} ${changesWord(accepted)}`}\n aria-describedby=\"agent-changes-review-per-change-reason\"\n loading={pending === 'apply'}\n onClickButton={() => finish('apply')}\n />\n </Cluster>\n </Stack>\n )}\n </Stack>\n </Surface>\n </Message>\n {status !== 'open' && (\n // One line in the thread on what was applied, under the card.\n <Message compact aria-label={`${agentName}, agent`}>\n <Paragraph measure=\"none\">{doneLine}</Paragraph>\n </Message>\n )}\n </Stack>\n </Stack>\n </Center>\n );\n}\n",
439
+ "uses": [
440
+ "Button",
441
+ "Center",
442
+ "Cluster",
443
+ "Diff",
444
+ "Heading",
445
+ "Message",
446
+ "Paragraph",
447
+ "SettingsSection",
448
+ "Stack",
449
+ "Surface",
450
+ "Tag",
451
+ "TimeStamp",
452
+ "UserImage",
453
+ "diffLines"
454
+ ]
455
+ }
456
+ ]
457
+ },
458
+ {
459
+ "id": "agent-handoff",
460
+ "title": "Hand-off",
461
+ "kind": "design",
462
+ "level": "organism",
463
+ "area": "agent",
464
+ "surface": [
465
+ "agent"
466
+ ],
467
+ "situation": "The agent cannot finish the work itself and hands it to a named person, or to another agent with a different job.",
468
+ "do": [
469
+ "Hand off in a `Message` from the agent, in the thread where the work is, marked as the rule 'An agent says what it is' says.",
470
+ "Say what the agent did, what it needs and from whom: 'I need Ben Carter to approve the production deploy.'",
471
+ "Mention the person by name, so the product notifies them.",
472
+ "Link the thing they must act on in a `SourceCard`, so they do not have to look for it.",
473
+ "Show who the work waits for in a `Tag`: 'Waiting for Ben Carter'.",
474
+ "Say what happens if nobody acts, as the rule 'An agent cancels and reports when nobody answers' says: 'If nobody approves by 5:00 PM, I cancel the deploy.'",
475
+ "Offer 'Take Over' as a secondary Button to a reader who can do the work. Remove it once it is pressed, put the reader's name in the Tag, say who took over, and move focus to the `SourceCard`.",
476
+ "Say the hand-off to another agent in one line with its reason: 'Handed off to Acme Reviewer. It checks every change before it merges.'",
477
+ "Let the new agent's first message say what it will do. Mark it as the rule 'An agent says what it is' says."
478
+ ],
479
+ "dont": [
480
+ "Do not hand off silently. The thread says who has the work now.",
481
+ "Do not show a bare caption that names the new owner and gives no reason.",
482
+ "Do not hand off to a person without saying what they must do.",
483
+ "Do not let the work wait with no end. Say when it is cancelled."
484
+ ],
485
+ "options": [
486
+ {
487
+ "id": "to-person",
488
+ "title": "To a person",
489
+ "useWhen": "The agent cannot go on and a named person must.",
490
+ "source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport { Bot, Rocket } from 'lucide-react';\nimport Message from 'oneslash-design-system/components/message';\nimport UserImage from 'oneslash-design-system/components/userImage';\nimport Tag from 'oneslash-design-system/components/tag';\nimport TimeStamp from 'oneslash-design-system/components/timeStamp';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Button from 'oneslash-design-system/components/button';\nimport SourceCard from 'oneslash-design-system/components/sourceCard';\nimport { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';\n\ntype Focusable = HTMLButtonElement | HTMLAnchorElement | null;\n\n// A real app reads these from the session and the person's role. Dana Lee can approve deploys too.\nconst me = 'Dana Lee';\nconst canTakeOver = true;\n\nconst agentName = 'Acme Agent';\nconst approver = 'Ben Carter';\n\nconst request = { from: me, at: new Date('2026-11-16T14:30:00Z'), text: 'Can you ship the new pricing page today?' };\nconst handedOffAt = new Date('2026-11-16T14:40:00Z');\n\n// The agent's marks, as the rule 'An agent says what it is' says.\nfunction agentMeta(at: Date) {\n return (\n <>\n <Tag variant=\"contained\" size=\"small\" label=\"Agent\" />\n <TimeStamp createdAt={at} dateFormat=\"absolute\" data=\"time\" />\n <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">Model name</Paragraph>\n </>\n );\n}\n\nexport default function AgentHandoffToPerson() {\n const [takenOver, setTakenOver] = useState(false);\n const [pending, setPending] = useState(false);\n const timer = useRef<ReturnType<typeof setTimeout>>();\n const deployCard = useRef<Focusable>(null);\n // Where focus goes after the next render, once the element it goes to is on screen.\n const focusNext = useRef<() => void>();\n\n // Stops the request if the example goes away before it ends.\n useEffect(() => () => clearTimeout(timer.current), []);\n\n useEffect(() => {\n const move = focusNext.current;\n focusNext.current = undefined;\n move?.();\n });\n\n // The work moves to the reader. 'Take Over' goes away, so focus goes to the deploy they now approve.\n function takeOver() {\n if (pending || takenOver) return;\n setPending(true);\n // Stands in for the request to the server.\n timer.current = setTimeout(() => {\n setPending(false);\n setTakenOver(true);\n focusNext.current = () => deployCard.current?.focus();\n }, 1200);\n }\n\n const waitingFor = takenOver ? me : approver;\n\n return (\n <Center width=\"page\">\n <Stack gap=\"large\">\n <Heading level={1} size=\"h5\">Launch plan</Heading>\n {/* A real app gives the list that holds the rows role=\"log\". */}\n <Stack gap=\"small\">\n <Message\n aria-label={request.from}\n avatar={<UserImage userHandle={request.from} decorative />}\n name={request.from}\n meta={<TimeStamp createdAt={request.at} dateFormat=\"absolute\" data=\"time\" />}\n >\n <Paragraph measure=\"none\">{request.text}</Paragraph>\n </Message>\n <Message\n aria-label={`${agentName}, agent`}\n avatar={<UserImage userHandle={agentName} icon={Bot} decorative />}\n name={agentName}\n meta={agentMeta(handedOffAt)}\n footer={\n canTakeOver && !takenOver ? (\n // Only for a reader who can do the work themselves.\n <Cluster>\n <Button size=\"small\" type=\"secondary\" state=\"enabled\" label=\"Take Over\" loading={pending} onClickButton={takeOver} />\n </Cluster>\n ) : undefined\n }\n >\n <Stack gap=\"medium\">\n <Paragraph measure=\"none\">I merged the pricing changes, and every check passed. Production deploys need a release manager, and I am not one.</Paragraph>\n {/* A real app shows the name as a mention, which notifies Ben Carter. */}\n <Paragraph measure=\"none\">I need {approver} to approve the production deploy.</Paragraph>\n <SourceCard ref={deployCard} icon={Rocket} title=\"Pricing page deploy\" meta=\"Production · Ready to approve\" href=\"/deploys/482\" />\n {/* A real app announces the changed Tag in a polite live region. */}\n <Cluster gap=\"small\">\n <Tag variant=\"contained\" size=\"small\" color=\"warning\" label={`Waiting for ${waitingFor}`} />\n {takenOver && <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">{me} took over from {approver}.</Paragraph>}\n </Cluster>\n <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">If nobody approves by 5:00 PM, I cancel the deploy and say so here. Nothing goes live without an approval.</Paragraph>\n </Stack>\n </Message>\n </Stack>\n </Stack>\n </Center>\n );\n}\n",
491
+ "uses": [
492
+ "Button",
493
+ "Center",
494
+ "Cluster",
495
+ "Heading",
496
+ "Message",
497
+ "Paragraph",
498
+ "SourceCard",
499
+ "Stack",
500
+ "Tag",
501
+ "TimeStamp",
502
+ "UserImage"
503
+ ]
504
+ },
505
+ {
506
+ "id": "to-agent",
507
+ "title": "To another agent",
508
+ "useWhen": "Another agent with a different job takes over.",
509
+ "source": "'use client';\nimport { Bot, GitPullRequest } from 'lucide-react';\nimport Message from 'oneslash-design-system/components/message';\nimport UserImage from 'oneslash-design-system/components/userImage';\nimport Tag from 'oneslash-design-system/components/tag';\nimport TimeStamp from 'oneslash-design-system/components/timeStamp';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport SourceCard from 'oneslash-design-system/components/sourceCard';\nimport { Center, Stack } from 'oneslash-design-system/components/layout';\n\nconst agentName = 'Acme Agent';\nconst reviewerName = 'Acme Reviewer';\n\nconst request = { from: 'Dana Lee', at: new Date('2026-11-16T14:30:00Z'), text: 'Can you fix the broken Terms link in the footer?' };\nconst fixedAt = new Date('2026-11-16T14:36:00Z');\nconst reviewAt = new Date('2026-11-16T14:37:00Z');\n\n// Each agent's marks, as the rule 'An agent says what it is' says.\nfunction agentMeta(at: Date) {\n return (\n <>\n <Tag variant=\"contained\" size=\"small\" label=\"Agent\" />\n <TimeStamp createdAt={at} dateFormat=\"absolute\" data=\"time\" />\n <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">Model name</Paragraph>\n </>\n );\n}\n\nexport default function AgentHandoffToAgent() {\n return (\n <Center width=\"page\">\n <Stack gap=\"large\">\n <Heading level={1} size=\"h5\">Launch plan</Heading>\n {/* A real app gives the list that holds the rows role=\"log\". */}\n <Stack gap=\"small\">\n <Message\n aria-label={request.from}\n avatar={<UserImage userHandle={request.from} decorative />}\n name={request.from}\n meta={<TimeStamp createdAt={request.at} dateFormat=\"absolute\" data=\"time\" />}\n >\n <Paragraph measure=\"none\">{request.text}</Paragraph>\n </Message>\n <Message\n aria-label={`${agentName}, agent`}\n avatar={<UserImage userHandle={agentName} icon={Bot} decorative />}\n name={agentName}\n meta={agentMeta(fixedAt)}\n >\n <Stack gap=\"medium\">\n <Paragraph measure=\"none\">I fixed the Terms link in the footer and opened a pull request.</Paragraph>\n <SourceCard icon={GitPullRequest} title=\"Fix the Terms link\" meta=\"Pull request · Waiting for review\" href=\"/pulls/1187\" />\n </Stack>\n </Message>\n {/* One line, with its reason, so the hand-off is never silent. */}\n <Message compact aria-label={`${agentName}, agent`}>\n <Paragraph size=\"body2\" tone=\"secondary\" measure=\"none\">Handed off to {reviewerName}. It checks every change before it merges.</Paragraph>\n </Message>\n <Message\n aria-label={`${reviewerName}, agent`}\n avatar={<UserImage userHandle={reviewerName} icon={Bot} decorative />}\n name={reviewerName}\n meta={agentMeta(reviewAt)}\n >\n <Stack gap=\"medium\">\n {/* Its first message says what it is and what it will do. */}\n <Paragraph measure=\"none\">I am {reviewerName}, the agent that checks changes before they merge. I am reviewing the fix to the Terms link now, and I will post what I find here.</Paragraph>\n <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">If the review needs a decision and nobody answers by 5:00 PM, I cancel the review and say so here. Nothing merges.</Paragraph>\n </Stack>\n </Message>\n </Stack>\n </Stack>\n </Center>\n );\n}\n",
510
+ "uses": [
511
+ "Center",
512
+ "Heading",
513
+ "Message",
514
+ "Paragraph",
515
+ "SourceCard",
516
+ "Stack",
517
+ "Tag",
518
+ "TimeStamp",
519
+ "UserImage"
520
+ ]
521
+ }
522
+ ]
523
+ },
524
+ {
525
+ "id": "agent-memory",
526
+ "title": "Agent memory",
527
+ "kind": "design",
528
+ "level": "organism",
529
+ "area": "settings",
530
+ "surface": [
531
+ "app",
532
+ "agent"
533
+ ],
534
+ "situation": "A person wants to see what the agent remembers about them or the workspace, and to correct it or have it forgotten.",
535
+ "do": [
536
+ "Put the memories in a `SettingsSection` titled 'What Acme Agent remembers', with a search field above them.",
537
+ "Show each memory in its own row: the memory in plain words, where it came from as a `Link`, and who else can see it.",
538
+ "Link where a memory came from to that place: 'From a chat on Nov 12, 2026'.",
539
+ "Say who can see each memory: 'Only you can see this.' or 'Everyone in Acme can see this.'",
540
+ "Give each row a More menu with 'Edit' and 'Forget', as the case 'More menu' does. Name the More button for its memory.",
541
+ "Turn the row into a field on 'Edit', with 'Cancel' and 'Save'. Focus goes to the field, then back to the row's More button. If the saved row no longer matches the search, focus goes to the search field.",
542
+ "Confirm 'Forget' in the row, as the case 'More menu' confirms a delete. Focus moves to 'Cancel' when the confirm opens, and back to the row's More button on 'Cancel'.",
543
+ "Move focus to the next row's More button after a memory is forgotten, or to the one before it on the last row. With no row left, move it to the search field.",
544
+ "Put 'Forget Everything' in a danger zone, as the case 'Danger zone' says, under the memories. Say what is forgotten and what stays, and confirm it in the section, with 'Cancel' first.",
545
+ "Show an empty list as the rule 'An empty list says what will fill it' says: 'No memories'. A search that finds nothing offers 'Clear Search'."
546
+ ],
547
+ "dont": [
548
+ "Do not show only a count of memories. Show each one.",
549
+ "Do not forget a memory on the first press.",
550
+ "Do not hide who else can see a memory.",
551
+ "Do not put 'Forget Everything' above the list."
552
+ ],
553
+ "options": [
554
+ {
555
+ "id": "list",
556
+ "title": "List of memories",
557
+ "useWhen": "A person sees what the agent remembers about them or the workspace, and corrects it.",
558
+ "source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport Toaster, { toast, dismissToast } from 'oneslash-design-system/components/toaster';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Link from 'oneslash-design-system/components/link';\nimport Button from 'oneslash-design-system/components/button';\nimport IconButton from 'oneslash-design-system/components/iconButton';\nimport Tooltip from 'oneslash-design-system/components/tooltip';\nimport Popover from 'oneslash-design-system/components/popover';\nimport Menu from 'oneslash-design-system/components/menu';\nimport MenuItem from 'oneslash-design-system/components/menuItem';\nimport Line from 'oneslash-design-system/components/line';\nimport TextField from 'oneslash-design-system/components/textField';\nimport EmptyBox from 'oneslash-design-system/components/emptyBox';\nimport SettingsSection from 'oneslash-design-system/components/settingsSection';\nimport TableContainer from 'oneslash-design-system/components/tableContainer';\nimport TableRow from 'oneslash-design-system/components/tableRow';\nimport TableCell from 'oneslash-design-system/components/tableCell';\nimport { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';\n\ntype Focusable = HTMLButtonElement | HTMLAnchorElement | null;\n\ntype Memory = {\n id: string;\n text: string;\n /** Where the agent learned it, with a link to that place. */\n from: string;\n href: string;\n /** Who else can see it. */\n seenBy: 'you' | 'everyone';\n};\n\n// A real app reads these from the server.\nconst firstMemories: Memory[] = [\n { id: 'lead', text: 'Dana Lee leads the pricing work for the launch.', from: 'From a chat on Nov 12, 2026', href: '/chat/launch/m-2210', seenBy: 'everyone' },\n { id: 'short', text: 'Dana prefers short answers with a link to the task.', from: 'From a chat on Nov 10, 2026', href: '/chat/dm/m-1984', seenBy: 'you' },\n { id: 'cents', text: 'Prices are written with cents, such as $8.00.', from: 'From a chat on Nov 3, 2026', href: '/chat/launch/m-1820', seenBy: 'everyone' },\n { id: 'hours', text: 'Dana works from 9:00 AM to 5:00 PM Central time.', from: 'From a chat on Oct 28, 2026', href: '/chat/dm/m-1702', seenBy: 'you' },\n];\n\nconst seenByLine = { you: 'Only you can see this.', everyone: 'Everyone in Acme can see this.' };\n\nexport default function AgentMemoryList() {\n const [memories, setMemories] = useState(firstMemories);\n const [query, setQuery] = useState('');\n // The row whose menu is open, and the More button it opens from. Both stay set while the menu fades out.\n const [menuRow, setMenuRow] = useState<Memory | null>(null);\n const [menuAnchor, setMenuAnchor] = useState<HTMLElement | null>(null);\n const [menuOpen, setMenuOpen] = useState(false);\n // One row at a time asks to confirm 'Forget', or is being edited.\n const [confirmingId, setConfirmingId] = useState<string | null>(null);\n const [editingId, setEditingId] = useState<string | null>(null);\n const [draft, setDraft] = useState('');\n const [pending, setPending] = useState<'forget' | 'save' | 'forget-all' | null>(null);\n const [confirmingAll, setConfirmingAll] = useState(false);\n const timer = useRef<ReturnType<typeof setTimeout>>();\n const toastIds = useRef<string[]>([]);\n const searchField = useRef<HTMLInputElement | HTMLTextAreaElement>(null);\n const cancelForget = useRef<Focusable>(null);\n const editField = useRef<HTMLInputElement | HTMLTextAreaElement>(null);\n const forgetAllButton = useRef<Focusable>(null);\n const cancelForgetAll = useRef<Focusable>(null);\n // Each row's More button by memory id, so focus can move to one when the thing that had it is gone.\n const moreButtons = useRef<Record<string, Focusable>>({});\n // Where focus goes after the next render, once the element it goes to is on screen.\n const focusNext = useRef<() => void>();\n\n // On unmount it stops the request and closes every toast it opened.\n useEffect(() => () => {\n clearTimeout(timer.current);\n toastIds.current.forEach((id) => dismissToast(id));\n toastIds.current = [];\n }, []);\n\n useEffect(() => {\n const move = focusNext.current;\n focusNext.current = undefined;\n move?.();\n });\n\n const words = query.trim().toLowerCase();\n const shown = words === '' ? memories : memories.filter((m) => m.text.toLowerCase().includes(words));\n\n function openMenu(m: Memory, anchor: HTMLElement) {\n if (menuOpen && menuRow?.id === m.id) {\n setMenuOpen(false);\n return;\n }\n setMenuRow(m);\n setMenuAnchor(anchor);\n setMenuOpen(true);\n }\n\n // Every item closes the menu, and Escape and a click outside do too. The Popover gives focus back to More.\n function choose(action: (m: Memory) => void) {\n if (!menuRow) return;\n const m = menuRow;\n setMenuOpen(false);\n action(m);\n }\n\n // The row turns into a field, with focus in it.\n function startEdit(m: Memory) {\n setConfirmingId(null);\n setDraft(m.text);\n setEditingId(m.id);\n focusNext.current = () => editField.current?.focus();\n }\n\n // 'Cancel' and 'Save' go away with the field, so focus goes back to the row's More button.\n function cancelEdit() {\n if (pending || !editingId) return;\n const id = editingId;\n setEditingId(null);\n focusNext.current = () => moreButtons.current[id]?.focus();\n }\n\n function saveEdit() {\n if (pending || !editingId || draft.trim() === '') return;\n const id = editingId;\n const text = draft.trim();\n setPending('save');\n // Stands in for the request to the server.\n timer.current = setTimeout(() => {\n setPending(null);\n setMemories((list) => list.map((m) => (m.id === id ? { ...m, text } : m)));\n setEditingId(null);\n // The row's More button, or the search field when the saved memory no longer matches the search.\n focusNext.current = () => (moreButtons.current[id] ?? searchField.current)?.focus();\n }, 1200);\n }\n\n // The confirm opens in the row, with focus on 'Cancel'.\n function askToForget(m: Memory) {\n setEditingId(null);\n setConfirmingId(m.id);\n focusNext.current = () => cancelForget.current?.focus();\n }\n\n // 'Cancel' goes away with the confirm, so focus goes back to the row's More button.\n function keepMemory() {\n if (pending || !confirmingId) return;\n const id = confirmingId;\n setConfirmingId(null);\n focusNext.current = () => moreButtons.current[id]?.focus();\n }\n\n function confirmForget() {\n if (pending || !confirmingId) return;\n const id = confirmingId;\n const at = shown.findIndex((m) => m.id === id);\n const neighbor = shown[at + 1] ?? shown[at - 1];\n setPending('forget');\n // Stands in for the request to the server.\n timer.current = setTimeout(() => {\n setPending(null);\n setConfirmingId(null);\n setMemories((list) => list.filter((m) => m.id !== id));\n toastIds.current.push(toast({ type: 'success', message: 'Memory forgotten.' }));\n // The row is gone: focus goes to the next row's More button, or the one before it when it was the last.\n // With no row left, it goes to the search field.\n focusNext.current = () => (neighbor ? moreButtons.current[neighbor.id] : searchField.current)?.focus();\n }, 1200);\n }\n\n // The danger zone's confirm opens in place, with focus on 'Cancel'.\n function askToForgetAll() {\n setConfirmingAll(true);\n focusNext.current = () => cancelForgetAll.current?.focus();\n }\n\n function keepAll() {\n if (pending) return;\n setConfirmingAll(false);\n focusNext.current = () => forgetAllButton.current?.focus();\n }\n\n // Every row and the danger zone go away, so focus goes to the search field.\n function forgetAll() {\n if (pending) return;\n setPending('forget-all');\n // Stands in for the request to the server.\n timer.current = setTimeout(() => {\n setPending(null);\n setConfirmingAll(false);\n setConfirmingId(null);\n setEditingId(null);\n setMemories([]);\n setQuery('');\n toastIds.current.push(toast({ type: 'success', message: 'Acme Agent forgot every memory.' }));\n focusNext.current = () => searchField.current?.focus();\n }, 1200);\n }\n\n function clearSearch() {\n setQuery('');\n searchField.current?.focus();\n }\n\n return (\n <Center width=\"page\">\n {/* A real app mounts one Toaster near its root. */}\n <Toaster />\n <Stack gap=\"xlarge\">\n <Stack gap=\"small\">\n <Heading level={1} size=\"h5\">Memory</Heading>\n <Paragraph tone=\"secondary\" size=\"body2\" measure=\"none\">What Acme Agent has learned from your chats. It uses this to answer you.</Paragraph>\n </Stack>\n\n <SettingsSection title=\"What Acme Agent remembers\" description=\"Each memory says where it came from and who else can see it.\">\n <TextField ref={searchField} id=\"agent-memory-list-search\" type=\"search\" label=\"Search memories\" value={query} autoComplete=\"off\" onChange={(e) => setQuery(e.target.value)} />\n {shown.length > 0 ? (\n <TableContainer>\n {shown.map((m) => {\n const confirming = m.id === confirmingId;\n const editing = m.id === editingId;\n return (\n <TableRow key={m.id}>\n <TableCell>\n {editing ? (\n <TextField\n ref={editField}\n id={`agent-memory-list-edit-${m.id}`}\n label=\"Memory\"\n value={draft}\n disabled={pending === 'save'}\n error={draft.trim() === ''}\n errorText={draft.trim() === '' ? 'Write the memory, or use Forget to remove it.' : undefined}\n onChange={(e) => setDraft(e.target.value)}\n />\n ) : (\n <Stack gap=\"small\">\n {m.text}\n {confirming ? (\n <Paragraph size=\"body2\" tone=\"secondary\" measure=\"none\">Forget this memory? Acme Agent stops using it.</Paragraph>\n ) : (\n <Cluster gap=\"small\">\n <Link href={m.href} size=\"caption\">{m.from}</Link>\n <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">{seenByLine[m.seenBy]}</Paragraph>\n </Cluster>\n )}\n </Stack>\n )}\n </TableCell>\n {/* A fixed last column keeps every row's Buttons in one place, so they do not jump when they change. */}\n <TableCell width=\"168px\" align=\"right\">\n {confirming ? (\n <Cluster gap=\"small\" justify=\"end\">\n <Button ref={cancelForget} size=\"small\" type=\"tertiary\" state={pending === 'forget' ? 'disabled' : 'enabled'} label=\"Cancel\" aria-label={`Cancel forgetting ${m.text}`} onClickButton={keepMemory} />\n <Button size=\"small\" type=\"primary\" color=\"danger\" state=\"enabled\" label=\"Forget\" aria-label={`Forget ${m.text}`} loading={pending === 'forget'} onClickButton={confirmForget} />\n </Cluster>\n ) : editing ? (\n <Cluster gap=\"small\" justify=\"end\">\n <Button size=\"small\" type=\"tertiary\" state={pending === 'save' ? 'disabled' : 'enabled'} label=\"Cancel\" aria-label=\"Cancel editing the memory\" onClickButton={cancelEdit} />\n <Button size=\"small\" type=\"primary\" state={draft.trim() === '' ? 'disabled' : 'enabled'} label=\"Save\" aria-label=\"Save the memory\" loading={pending === 'save'} onClickButton={saveEdit} />\n </Cluster>\n ) : (\n <Cluster justify=\"end\">\n <Tooltip title=\"More\">\n <IconButton\n ref={(el) => { moreButtons.current[m.id] = el; }}\n color=\"iconOnly\"\n state={menuOpen && menuRow?.id === m.id ? 'selected' : 'enabled'}\n size=\"small\"\n iconName=\"Ellipsis\"\n ariaLabel={`More actions for ${m.text}`}\n aria-haspopup=\"menu\"\n aria-expanded={menuOpen && menuRow?.id === m.id}\n onClick={(e: { currentTarget: HTMLElement }) => openMenu(m, e.currentTarget)}\n />\n </Tooltip>\n </Cluster>\n )}\n </TableCell>\n </TableRow>\n );\n })}\n </TableContainer>\n ) : memories.length > 0 ? (\n <EmptyBox\n size=\"small\"\n icon=\"Search\"\n text={`No memories match \"${query.trim()}\"`}\n secondText=\"Try other words, or clear the search.\"\n action={<Button size=\"small\" type=\"secondary\" state=\"enabled\" label=\"Clear Search\" onClickButton={clearSearch} />}\n />\n ) : (\n <EmptyBox size=\"small\" icon=\"Brain\" text=\"No memories\" secondText=\"What Acme Agent learns in your chats appears here.\" />\n )}\n </SettingsSection>\n\n {memories.length > 0 && (\n <SettingsSection tone=\"danger\" title=\"Forget everything\" description=\"This cannot be undone.\">\n <Paragraph size=\"body2\" measure=\"none\">Acme Agent forgets every memory listed here. Your chats and files stay.</Paragraph>\n {confirmingAll ? (\n <>\n <Paragraph size=\"body2\" measure=\"none\">Forget all {memories.length} memories?</Paragraph>\n <Cluster gap=\"small\">\n <Button ref={cancelForgetAll} size=\"small\" type=\"tertiary\" state={pending === 'forget-all' ? 'disabled' : 'enabled'} label=\"Cancel\" aria-label=\"Cancel forgetting everything\" onClickButton={keepAll} />\n <Button size=\"small\" type=\"primary\" color=\"danger\" state=\"enabled\" label=\"Forget Everything\" loading={pending === 'forget-all'} onClickButton={forgetAll} />\n </Cluster>\n </>\n ) : (\n <Cluster>\n <Button ref={forgetAllButton} size=\"small\" type=\"secondary\" color=\"danger\" state=\"enabled\" label=\"Forget Everything\" onClickButton={askToForgetAll} />\n </Cluster>\n )}\n </SettingsSection>\n )}\n </Stack>\n <Popover open={menuOpen} anchorEl={menuAnchor} onClose={() => setMenuOpen(false)} returnFocus>\n <Menu navigable aria-label={menuRow ? `Actions for ${menuRow.text}` : 'Memory actions'} width={200}>\n <MenuItem size=\"small\" iconName=\"Pencil\" label=\"Edit\" onClick={() => choose(startEdit)} />\n <Line />\n {/* Forget is last, and danger. */}\n <MenuItem size=\"small\" color=\"danger\" iconName=\"Trash2\" label=\"Forget\" onClick={() => choose(askToForget)} />\n </Menu>\n </Popover>\n </Center>\n );\n}\n",
559
+ "uses": [
560
+ "Button",
561
+ "Center",
562
+ "Cluster",
563
+ "EmptyBox",
564
+ "Heading",
565
+ "IconButton",
566
+ "Line",
567
+ "Link",
568
+ "Menu",
569
+ "MenuItem",
570
+ "Paragraph",
571
+ "Popover",
572
+ "SettingsSection",
573
+ "Stack",
574
+ "TableCell",
575
+ "TableContainer",
576
+ "TableRow",
577
+ "TextField",
578
+ "Toaster",
579
+ "Tooltip",
580
+ "dismissToast",
581
+ "toast"
582
+ ]
583
+ }
584
+ ]
585
+ },
353
586
  {
354
587
  "id": "agent-options",
355
588
  "title": "Agent options",
356
589
  "kind": "design",
357
590
  "level": "organism",
358
591
  "area": "agent",
592
+ "surface": [
593
+ "agent"
594
+ ],
359
595
  "situation": "The agent sees two to four ways forward and needs the person to pick one. These are ways forward for the agent's own work. For a fact or a decision only the person has, see the case 'Agent question'.",
360
596
  "do": [
361
597
  "Put the card in the agent's `Message`, in a `Surface` with the question as its heading.",
@@ -412,6 +648,9 @@
412
648
  "kind": "design",
413
649
  "level": "organism",
414
650
  "area": "agent",
651
+ "surface": [
652
+ "agent"
653
+ ],
415
654
  "situation": "The agent is working on a request in the thread, and its reply is not ready yet.",
416
655
  "do": [
417
656
  "Follow the rule 'An agent shows its progress': one row in the thread, where the reply will appear.",
@@ -420,11 +659,12 @@
420
659
  "Show the steps in a `StepList`: the finished ones with a check, and the current one running, in plain words.",
421
660
  "Leave out steps the agent has not started, unless it knows them.",
422
661
  "Put the only 'Stop' in the row's `footer`, for the whole run, and under the reply while it is written.",
423
- "Make 'Stop' `loading` while the run stops. Once the run has ended, replace the row in place with a note on what was and was not done.",
662
+ "Make 'Stop' `loading` while the run stops. Once it has ended, keep the steps, mark the ones not done cancelled, and add a line on what was done.",
424
663
  "Say 'Stopped. Nothing was changed.' when nothing was. When part was done, say what: 'Stopped after 2 of 4 steps. The rest of the plan was not done.'",
425
664
  "Say 'Stopped. Nothing was written.' when a streaming reply is stopped before any text.",
426
665
  "Keep the text and say 'Stopped before the reply was finished.' when a streaming reply is stopped after some text.",
427
- "Show a failed run in the row: an inline error `Alert` with no close button and `autoDismiss={false}`, the failed step marked, and 'Try Again'.",
666
+ "Follow the case 'Run that stopped short' when a run with steps fails or stops at a limit.",
667
+ "Show a reply that failed with no steps to go back to, such as a streaming reply, in the row. Use an inline error `Alert` that says what went wrong, and one 'Try Again'.",
428
668
  "Turn the row into the agent's reply when the run is done, and remove 'Stop'.",
429
669
  "Move focus to the message box when 'Stop' goes away and no other control takes its place.",
430
670
  "Announce the changing part politely, such as the running step: the app wraps it in a polite live region, since `StepList` has none.",
@@ -442,9 +682,8 @@
442
682
  "id": "steps",
443
683
  "title": "Steps",
444
684
  "useWhen": "The run has steps to show.",
445
- "source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport { Bot } from 'lucide-react';\nimport Message from 'oneslash-design-system/components/message';\nimport UserImage from 'oneslash-design-system/components/userImage';\nimport Tag from 'oneslash-design-system/components/tag';\nimport TimeStamp from 'oneslash-design-system/components/timeStamp';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Button from 'oneslash-design-system/components/button';\nimport Alert from 'oneslash-design-system/components/alert';\nimport StepList, { type StepListStep } from 'oneslash-design-system/components/stepList';\nimport { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';\n\nconst agentName = 'Acme Agent';\n\nconst request = { from: 'Dana Lee', at: new Date('2025-01-15T11:40:00Z'), text: 'Can you check the pricing page against the new plans?' };\nconst runStartedAt = new Date('2025-01-15T11:41:00Z');\n\n// Each step in plain words: what the agent is doing now, and what it did once the step is done.\nconst plan = [\n { doing: 'Reading the thread', done: 'Read the thread' },\n { doing: 'Finding the new plans', done: 'Found the new plans' },\n { doing: 'Reading the pricing page', done: 'Read the pricing page' },\n { doing: 'Comparing the prices', done: 'Compared the prices' },\n];\n\nconst reply = \"The pricing page still shows last year's prices. Pro is $12 there, and the new plans set it at $15.\";\n\ntype Phase = 'running' | 'stopping' | 'stopped' | 'failed' | 'done';\n\n// Finished steps keep a check, the current one runs, and steps the agent has not started are not shown.\nfunction stepsUpTo(current: number, failed: boolean): StepListStep[] {\n return plan.slice(0, current + 1).map((s, i) =>\n i < current ? { label: s.done, status: 'done' } : { label: s.doing, status: failed ? 'failed' : 'running' },\n );\n}\n\nfunction secondsLine(seconds: number) {\n return `Working for ${seconds} ${seconds === 1 ? 'second' : 'seconds'}`;\n}\n\n// The agent's marks, as the rule 'An agent says what it is' says.\nfunction agentMeta(at: Date) {\n return (\n <>\n <Tag variant=\"contained\" size=\"small\" label=\"Agent\" />\n <TimeStamp createdAt={at} dateFormat=\"absolute\" data=\"time\" />\n <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">Model name</Paragraph>\n </>\n );\n}\n\nexport default function AgentPendingReplySteps() {\n // Opens on a still of a run in progress, 12 seconds in, so the picture in the docs does not move.\n // 'Run Again' runs it live: the seconds tick and the steps go on.\n const [phase, setPhase] = useState<Phase>('running');\n const [current, setCurrent] = useState(2);\n const [seconds, setSeconds] = useState(12);\n const [startedAt, setStartedAt] = useState(runStartedAt);\n const tick = useRef<ReturnType<typeof setInterval>>();\n const step = useRef<ReturnType<typeof setTimeout>>();\n const cancel = useRef<ReturnType<typeof setTimeout>>();\n const runAgainButton = useRef<HTMLButtonElement | HTMLAnchorElement>(null);\n // Where focus goes after the next render, once the element it goes to is on screen.\n const focusNext = useRef<() => void>();\n // The first live run fails at the pricing page, so the example shows the failed row; 'Try Again' then works.\n const triedAgain = useRef(false);\n\n // On unmount it stops the run, its clock and the cancel request.\n useEffect(() => () => {\n clearInterval(tick.current);\n clearTimeout(step.current);\n clearTimeout(cancel.current);\n }, []);\n\n useEffect(() => {\n const move = focusNext.current;\n focusNext.current = undefined;\n move?.();\n });\n\n function stopTimers() {\n clearInterval(tick.current);\n clearTimeout(step.current);\n }\n\n // Stands in for the agent's run: one step every 1.5 seconds.\n function advance(at: number) {\n step.current = setTimeout(() => {\n if (at === 2 && !triedAgain.current) {\n stopTimers();\n setPhase('failed');\n return;\n }\n if (at === plan.length - 1) {\n stopTimers();\n setPhase('done');\n return;\n }\n setCurrent(at + 1);\n advance(at + 1);\n }, 1500);\n }\n\n function runLive() {\n stopTimers();\n setPhase('running');\n setCurrent(0);\n setSeconds(0);\n setStartedAt(new Date());\n tick.current = setInterval(() => setSeconds((s) => s + 1), 1000);\n advance(0);\n }\n\n function tryAgain() {\n triedAgain.current = true;\n runLive();\n }\n\n // Stop asks the server to end the run. The row says it stopped only once the run has ended.\n function stop() {\n if (phase !== 'running') return;\n clearTimeout(step.current);\n setPhase('stopping');\n // Stands in for the request to the server.\n cancel.current = setTimeout(() => {\n clearInterval(tick.current);\n setPhase('stopped');\n // 'Stop' had focus and is gone. Here 'Run Again' takes its place; in a real app, the message box.\n focusNext.current = () => runAgainButton.current?.focus();\n }, 1200);\n }\n\n const working = phase === 'running' || phase === 'stopping';\n\n return (\n <Center width=\"page\">\n <Stack gap=\"large\">\n <Heading level={1} size=\"h5\">Launch plan</Heading>\n {/* A real app gives the list that holds the rows role=\"log\". */}\n <Stack gap=\"small\">\n <Message\n aria-label={request.from}\n avatar={<UserImage userHandle={request.from} decorative />}\n name={request.from}\n meta={<TimeStamp createdAt={request.at} dateFormat=\"absolute\" data=\"time\" />}\n >\n <Paragraph measure=\"none\">{request.text}</Paragraph>\n </Message>\n <Message\n aria-label={`${agentName}, agent`}\n avatar={<UserImage userHandle={agentName} icon={Bot} decorative />}\n name={agentName}\n meta={agentMeta(startedAt)}\n footer={\n working ? (\n // The only Stop, on the row for the whole run. It shows loading while the run is stopping.\n <Cluster>\n <Button size=\"small\" type=\"secondary\" state=\"enabled\" label=\"Stop\" loading={phase === 'stopping'} onClickButton={stop} />\n </Cluster>\n ) : phase === 'failed' ? (\n <Cluster>\n <Button size=\"small\" type=\"secondary\" state=\"enabled\" label=\"Try Again\" onClickButton={tryAgain} />\n </Cluster>\n ) : phase === 'stopped' ? (\n <Cluster>\n <Button ref={runAgainButton} size=\"small\" type=\"secondary\" state=\"enabled\" label=\"Run Again\" onClickButton={runLive} />\n </Cluster>\n ) : undefined\n }\n >\n {phase === 'done' ? (\n // The run is over: the row is the reply, and Stop is gone. A real app moves focus to the message box.\n <Paragraph measure=\"none\">{reply}</Paragraph>\n ) : phase === 'stopped' ? (\n <Paragraph measure=\"none\">Stopped. Nothing was changed.</Paragraph>\n ) : (\n // A real app wraps this part in a polite live region, since StepList has none.\n <Stack gap=\"medium\">\n {working && <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">{secondsLine(seconds)}</Paragraph>}\n <StepList aria-label=\"Acme Agent's steps\" steps={stepsUpTo(current, phase === 'failed')} />\n {phase === 'failed' && (\n // It reports where the run stands, so it has no close button and stays.\n <Alert type=\"error\" variant=\"inline\" autoDismiss={false} message=\"Acme Agent could not open the pricing page. Nothing was changed.\" />\n )}\n </Stack>\n )}\n </Message>\n </Stack>\n </Stack>\n </Center>\n );\n}\n",
685
+ "source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport { Bot } from 'lucide-react';\nimport Message from 'oneslash-design-system/components/message';\nimport UserImage from 'oneslash-design-system/components/userImage';\nimport Tag from 'oneslash-design-system/components/tag';\nimport TimeStamp from 'oneslash-design-system/components/timeStamp';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Button from 'oneslash-design-system/components/button';\nimport StepList, { type StepListStep } from 'oneslash-design-system/components/stepList';\nimport { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';\n\nconst agentName = 'Acme Agent';\n\nconst request = { from: 'Dana Lee', at: new Date('2025-01-15T11:40:00Z'), text: 'Can you check the pricing page against the new plans?' };\nconst runStartedAt = new Date('2025-01-15T11:41:00Z');\n\n// Each step in plain words: what the agent is doing now, and what it did once the step is done.\nconst plan = [\n { doing: 'Reading the thread', done: 'Read the thread' },\n { doing: 'Finding the new plans', done: 'Found the new plans' },\n { doing: 'Reading the pricing page', done: 'Read the pricing page' },\n { doing: 'Comparing the prices', done: 'Compared the prices' },\n];\n\nconst reply = \"The pricing page still shows last year's prices. Pro is $12 there, and the new plans set it at $15.\";\n\n// Why the step failed. A real app takes it from the server's answer.\nconst failReason = 'Could not open the pricing page. It did not answer in time.';\n\ntype Phase = 'running' | 'stopping' | 'stopped' | 'failed' | 'done';\n\n// Finished steps keep a check, the current one runs, and while it runs the steps the agent has not started are not shown.\n// A failed step says why, as the case 'Run that stopped short' does, and the steps after it wait. Once the run is\n// stopped, the step it stopped on stays failed after 'Stop Here' and is cancelled after 'Stop', and the steps after it are cancelled.\nfunction stepsUpTo(current: number, phase: Phase, endedOnFailure: boolean): StepListStep[] {\n const shown = phase === 'failed' || phase === 'stopped' ? plan : plan.slice(0, current + 1);\n return shown.map((s, i) => {\n if (i < current) return { label: s.done, status: 'done' };\n if (i > current) return { label: s.doing, status: phase === 'stopped' ? 'cancelled' : 'waiting' };\n if (phase === 'failed') return { label: s.doing, status: 'failed', detail: failReason };\n if (phase === 'stopped') return { label: s.doing, status: endedOnFailure ? 'failed' : 'cancelled' };\n return { label: s.doing, status: 'running' };\n });\n}\n\nfunction secondsLine(seconds: number) {\n return `Working for ${seconds} ${seconds === 1 ? 'second' : 'seconds'}`;\n}\n\n// The agent's marks, as the rule 'An agent says what it is' says.\nfunction agentMeta(at: Date) {\n return (\n <>\n <Tag variant=\"contained\" size=\"small\" label=\"Agent\" />\n <TimeStamp createdAt={at} dateFormat=\"absolute\" data=\"time\" />\n <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">Model name</Paragraph>\n </>\n );\n}\n\nexport default function AgentPendingReplySteps() {\n // Opens on a still of a run in progress, 12 seconds in, so the picture in the docs does not move.\n // 'Run Again' runs it live: the seconds tick and the steps go on.\n const [phase, setPhase] = useState<Phase>('running');\n const [current, setCurrent] = useState(2);\n const [seconds, setSeconds] = useState(12);\n const [startedAt, setStartedAt] = useState(runStartedAt);\n const tick = useRef<ReturnType<typeof setInterval>>();\n const step = useRef<ReturnType<typeof setTimeout>>();\n const cancel = useRef<ReturnType<typeof setTimeout>>();\n const runAgainButton = useRef<HTMLButtonElement | HTMLAnchorElement>(null);\n const stopHereButton = useRef<HTMLButtonElement | HTMLAnchorElement>(null);\n const stopButton = useRef<HTMLButtonElement | HTMLAnchorElement>(null);\n // Whether the run ended on the failed step ('Stop Here') or was stopped while a step ran ('Stop').\n const [endedOnFailure, setEndedOnFailure] = useState(false);\n // Where focus goes after the next render, once the element it goes to is on screen.\n const focusNext = useRef<() => void>();\n // The first live run fails at the pricing page, so the example shows the failed row; 'Try Step Again' then works.\n const triedAgain = useRef(false);\n\n // On unmount it stops the run, its clock and the cancel request.\n useEffect(() => () => {\n clearInterval(tick.current);\n clearTimeout(step.current);\n clearTimeout(cancel.current);\n }, []);\n\n useEffect(() => {\n const move = focusNext.current;\n focusNext.current = undefined;\n move?.();\n });\n\n function stopTimers() {\n clearInterval(tick.current);\n clearTimeout(step.current);\n }\n\n // Stands in for the agent's run: one step every 1.5 seconds.\n function advance(at: number) {\n step.current = setTimeout(() => {\n if (at === 2 && !triedAgain.current) {\n stopTimers();\n setPhase('failed');\n // 'Stop' had focus and is gone, so focus goes to the row's first Button.\n focusNext.current = () => stopHereButton.current?.focus();\n return;\n }\n if (at === plan.length - 1) {\n stopTimers();\n setPhase('done');\n return;\n }\n setCurrent(at + 1);\n advance(at + 1);\n }, 1500);\n }\n\n // Runs from `from` on. The steps before it are done and stay done.\n function runFrom(from: number) {\n stopTimers();\n setPhase('running');\n setEndedOnFailure(false);\n setCurrent(from);\n setSeconds(0);\n setStartedAt(new Date());\n tick.current = setInterval(() => setSeconds((s) => s + 1), 1000);\n advance(from);\n }\n\n function runLive() {\n runFrom(0);\n }\n\n // Only the failed step and the ones after it run again. 'Stop' takes the place of the Buttons, so it gets focus.\n function tryStepAgain() {\n if (phase !== 'failed') return;\n triedAgain.current = true;\n runFrom(current);\n focusNext.current = () => stopButton.current?.focus();\n }\n\n // The run ends on the failed step. 'Run Again' takes the place of the Buttons; in a real app, the message box.\n function stopHere() {\n if (phase !== 'failed') return;\n setEndedOnFailure(true);\n setPhase('stopped');\n focusNext.current = () => runAgainButton.current?.focus();\n }\n\n // Stop asks the server to end the run. The row says it stopped only once the run has ended.\n function stop() {\n if (phase !== 'running') return;\n clearTimeout(step.current);\n setPhase('stopping');\n // Stands in for the request to the server.\n cancel.current = setTimeout(() => {\n clearInterval(tick.current);\n setPhase('stopped');\n // 'Stop' had focus and is gone. Here 'Run Again' takes its place; in a real app, the message box.\n focusNext.current = () => runAgainButton.current?.focus();\n }, 1200);\n }\n\n const working = phase === 'running' || phase === 'stopping';\n\n // What was done, under the list. Empty while the run goes on. A real app takes the count from the server's answer.\n const statusLine =\n phase === 'failed'\n ? `${current} of ${plan.length} steps are done. Nothing was changed.`\n : phase === 'stopped'\n ? current === 0\n ? 'Stopped. Nothing was changed.'\n : `Stopped after ${current} of ${plan.length} steps. The rest of the plan was not done. Nothing was changed.`\n : '';\n\n return (\n <Center width=\"page\">\n <Stack gap=\"large\">\n <Heading level={1} size=\"h5\">Launch plan</Heading>\n {/* A real app gives the list that holds the rows role=\"log\". */}\n <Stack gap=\"small\">\n <Message\n aria-label={request.from}\n avatar={<UserImage userHandle={request.from} decorative />}\n name={request.from}\n meta={<TimeStamp createdAt={request.at} dateFormat=\"absolute\" data=\"time\" />}\n >\n <Paragraph measure=\"none\">{request.text}</Paragraph>\n </Message>\n <Message\n aria-label={`${agentName}, agent`}\n avatar={<UserImage userHandle={agentName} icon={Bot} decorative />}\n name={agentName}\n meta={agentMeta(startedAt)}\n footer={\n working ? (\n // The only Stop, on the row for the whole run. It shows loading while the run is stopping.\n <Cluster>\n <Button ref={stopButton} size=\"small\" type=\"secondary\" state=\"enabled\" label=\"Stop\" loading={phase === 'stopping'} onClickButton={stop} />\n </Cluster>\n ) : phase === 'failed' ? (\n // As in the case 'Run that stopped short': how long it waits, then 'Stop Here' and 'Try Step Again' as the primary Button.\n <Stack gap=\"small\">\n <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">Waits 10 more minutes, then stops here.</Paragraph>\n <Cluster gap=\"small\">\n <Button ref={stopHereButton} size=\"small\" type=\"tertiary\" state=\"enabled\" label=\"Stop Here\" onClickButton={stopHere} />\n <Button size=\"small\" type=\"primary\" state=\"enabled\" label=\"Try Step Again\" onClickButton={tryStepAgain} />\n </Cluster>\n </Stack>\n ) : phase === 'stopped' ? (\n <Cluster>\n <Button ref={runAgainButton} size=\"small\" type=\"secondary\" state=\"enabled\" label=\"Run Again\" onClickButton={runLive} />\n </Cluster>\n ) : undefined\n }\n >\n {phase === 'done' ? (\n // The run is over: the row is the reply, and Stop is gone. A real app moves focus to the message box.\n <Paragraph measure=\"none\">{reply}</Paragraph>\n ) : (\n // A real app wraps the running step in a polite live region, since StepList has none.\n // After a stop the steps stay, as the rule 'An agent that stops short says what it finished and what is left' says.\n <Stack gap=\"medium\">\n {working && <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">{secondsLine(seconds)}</Paragraph>}\n <StepList aria-label=\"Acme Agent's steps\" steps={stepsUpTo(current, phase, endedOnFailure)} />\n {/* What is done, as the case 'Run that stopped short' says. A polite live region, on the page before its text changes, so it is heard. */}\n <Paragraph role=\"status\" measure=\"none\">{statusLine}</Paragraph>\n </Stack>\n )}\n </Message>\n </Stack>\n </Stack>\n </Center>\n );\n}\n",
446
686
  "uses": [
447
- "Alert",
448
687
  "Button",
449
688
  "Center",
450
689
  "Cluster",
@@ -479,27 +718,111 @@
479
718
  }
480
719
  ]
481
720
  },
721
+ {
722
+ "id": "agent-permissions",
723
+ "title": "What an agent may do",
724
+ "kind": "design",
725
+ "level": "organism",
726
+ "area": "settings",
727
+ "surface": [
728
+ "app",
729
+ "agent"
730
+ ],
731
+ "situation": "A person or an admin sets how much the agent does without asking, and which tools it may use.",
732
+ "do": [
733
+ "Follow the rule 'A setting saves in place, or with one Save Button': each choice saves as soon as it is made, and shows nothing when it works.",
734
+ "Offer three levels in a `RadioGroup`, named in plain words for what changes: 'Only suggest changes', 'Ask before every change', 'Ask before risky changes'.",
735
+ "Give each level a `secondLabel` with an example: 'It drafts and checks alone. Every change to shared work, such as a page edit, a pull request or a deploy, waits for a yes.'",
736
+ "Make plain how 'Ask before every change' differs: it asks even before it changes its own drafts.",
737
+ "Say what counts as risky, under the levels.",
738
+ "Keep every risky action behind a yes at every level, as the rule 'An agent asks before a risky action' says.",
739
+ "Disable the group while it saves. When the save fails, put the old level back and say why under it: 'Could not save. Try again.'",
740
+ "List the tools in a `TableContainer`, one row per tool, each with a line on what it does and a `SegmentedControl` of 'Allow', 'Ask' and 'Never'.",
741
+ "Name each `SegmentedControl` for its row: 'Edit pages'.",
742
+ "Offer only 'Ask' and 'Never' on a risky tool, and say why on its row: 'Risky: it changes what customers see, so it cannot be set to Allow.'",
743
+ "List the apps that use these tools under the table, in a section titled 'Connected apps', each with who connected it and when, and 'Revoke'.",
744
+ "Confirm 'Revoke' in the row, as the case 'API keys' does. Focus moves to 'Cancel' when the confirm opens, back to 'Revoke' on 'Cancel', and to the next row's 'Revoke' after the app is gone.",
745
+ "Show everything read-only to a person who cannot change it, as the case 'No access' says."
746
+ ],
747
+ "dont": [
748
+ "Do not ask for blocked tools in a free-text list. List every tool with its own control.",
749
+ "Do not offer four or more levels whose names do not say what the agent does at each one.",
750
+ "Do not let a risky tool be set to 'Allow'.",
751
+ "Do not offer a level that lets the agent do a risky action alone.",
752
+ "Do not revoke an app on the first press."
753
+ ],
754
+ "options": [
755
+ {
756
+ "id": "levels",
757
+ "title": "One level",
758
+ "useWhen": "One setting for how much the agent does without asking is enough.",
759
+ "source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Alert from 'oneslash-design-system/components/alert';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport FormField from 'oneslash-design-system/components/formField';\nimport RadioGroup from 'oneslash-design-system/components/radioGroup';\nimport SettingsSection from 'oneslash-design-system/components/settingsSection';\nimport { Center, Stack } from 'oneslash-design-system/components/layout';\n\n// Three levels, each named for what the agent does at it, with an example. No level lets it do a risky action alone.\nconst levels = [\n { value: 'suggest', label: 'Only suggest changes', secondLabel: 'It drafts a fix and proposes it in the thread. It changes nothing itself.' },\n { value: 'ask-every', label: 'Ask before every change', secondLabel: 'It asks before every change, even to its own drafts.' },\n { value: 'ask-risky', label: 'Ask before risky changes', secondLabel: 'It drafts and checks alone. Every change to shared work, such as a page edit, a pull request or a deploy, waits for a yes.' },\n];\n\n// A real app reads `canChange` from the person's role. Only an admin can change how the agent works.\n// The example shows an admin's view. A real app passes `canChange` from the person's role.\nexport default function AgentPermissionsLevels({ canChange = true }: { canChange?: boolean } = {}) {\n const [level, setLevel] = useState('ask-every');\n const [saving, setSaving] = useState(false);\n const timer = useRef<ReturnType<typeof setTimeout>>();\n\n // Stops the request if the example goes away before it ends.\n useEffect(() => () => clearTimeout(timer.current), []);\n\n // The choice stands alone, so it saves as soon as it is made. Nothing shows when it works.\n // While the request runs the group is disabled. A real app puts the old level back if the save fails,\n // and says why in the FormField's error line: 'Could not save. Try again.'\n function choose(next: string) {\n if (saving || next === level) return;\n setLevel(next);\n setSaving(true);\n // Stands in for the request to the server.\n timer.current = setTimeout(() => setSaving(false), 900);\n }\n\n return (\n <Center width=\"page\">\n <Stack gap=\"xlarge\">\n <Stack gap=\"small\">\n <Heading level={1} size=\"h5\">Agent</Heading>\n <Paragraph tone=\"secondary\" size=\"body2\" measure=\"none\">How Acme Agent works for everyone in this workspace.</Paragraph>\n </Stack>\n {/* One line at the top says why nothing can be changed, and who can. */}\n {!canChange && <Alert type=\"info\" variant=\"inline\" message=\"Only admins can change these settings. Your admin is Dana Lee.\" autoDismiss={false} />}\n <SettingsSection title=\"What Acme Agent does alone\" description=\"Your choice saves as soon as you make it.\">\n <FormField id=\"agent-permissions-levels-level\" label=\"Level\" help=\"Risky changes are any change to shared work, such as a page edit or a pull request, and messages to people outside Acme, deploys and deletes. They wait for a yes at every level.\">\n {(f) => (\n <RadioGroup\n id={f.id}\n aria-describedby={f['aria-describedby']}\n aria-label=\"Level\"\n options={levels}\n selectedValue={level}\n disabled={!canChange || saving}\n onChange={choose}\n />\n )}\n </FormField>\n </SettingsSection>\n </Stack>\n </Center>\n );\n}\n",
760
+ "uses": [
761
+ "Alert",
762
+ "Center",
763
+ "FormField",
764
+ "Heading",
765
+ "Paragraph",
766
+ "RadioGroup",
767
+ "SettingsSection",
768
+ "Stack"
769
+ ]
770
+ },
771
+ {
772
+ "id": "per-tool",
773
+ "title": "Each tool",
774
+ "useWhen": "An admin sets each tool or action on its own.",
775
+ "source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport Toaster, { toast, dismissToast } from 'oneslash-design-system/components/toaster';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Alert from 'oneslash-design-system/components/alert';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport SegmentedControl from 'oneslash-design-system/components/segmentedControl';\nimport SettingsSection from 'oneslash-design-system/components/settingsSection';\nimport TableContainer from 'oneslash-design-system/components/tableContainer';\nimport TableHeader from 'oneslash-design-system/components/tableHeader';\nimport TableHeaderCell from 'oneslash-design-system/components/tableHeaderCell';\nimport TableRow from 'oneslash-design-system/components/tableRow';\nimport TableCell from 'oneslash-design-system/components/tableCell';\nimport EmptyBox from 'oneslash-design-system/components/emptyBox';\nimport Button from 'oneslash-design-system/components/button';\nimport { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';\n\ntype Focusable = HTMLButtonElement | HTMLAnchorElement | null;\ntype Setting = 'allow' | 'ask' | 'never';\n\ntype Tool = { id: string; name: string; does: string; risky?: string };\n\nconst tools: Tool[] = [\n { id: 'read', name: 'Read pages and files', does: 'Reads the workspace to answer and to plan.' },\n { id: 'post', name: 'Post in threads', does: 'Posts replies and updates in Acme threads.' },\n { id: 'edit', name: 'Edit pages', does: 'Changes the text of a page.', risky: 'Risky: it changes shared work, so it cannot be set to Allow.' },\n { id: 'pull', name: 'Open pull requests', does: 'Proposes code changes for review.', risky: 'Risky: it changes shared work, so it cannot be set to Allow.' },\n { id: 'deploy', name: 'Deploy to production', does: 'Puts a change live.', risky: 'Risky: it changes what customers see, so it cannot be set to Allow.' },\n { id: 'delete', name: 'Delete files', does: 'Removes files from the workspace.', risky: 'Risky: a deleted file cannot be brought back, so it cannot be set to Allow.' },\n];\n\nconst allOptions = [\n { value: 'allow', label: 'Allow' },\n { value: 'ask', label: 'Ask' },\n { value: 'never', label: 'Never' },\n];\n// A risky tool offers no 'Allow'.\nconst riskyOptions = allOptions.filter((o) => o.value !== 'allow');\n\ntype Client = { id: string; name: string; connected: string };\n\nconst firstClients: Client[] = [\n { id: 'cli', name: 'Acme CLI', connected: 'Connected by Ben Carter on Oct 3, 2026' },\n { id: 'slack', name: 'Acme for Slack', connected: 'Connected by Dana Lee on Aug 19, 2026' },\n { id: 'reports', name: 'Reporting script', connected: 'Connected by Omar Reyes on Nov 2, 2026' },\n];\n\n// A real app reads `canChange` from the person's role. Only an admin can change the tools.\n// The example shows an admin's view. A real app passes `canChange` from the person's role.\nexport default function AgentPermissionsPerTool({ canChange = true }: { canChange?: boolean } = {}) {\n const [settings, setSettings] = useState<Record<string, Setting>>({ read: 'allow', post: 'allow', edit: 'ask', pull: 'ask', deploy: 'ask', delete: 'never' });\n const [savingTool, setSavingTool] = useState<string | null>(null);\n const [clients, setClients] = useState(firstClients);\n const [confirming, setConfirming] = useState<string | null>(null);\n const [revoking, setRevoking] = useState<string | null>(null);\n const timers = useRef<ReturnType<typeof setTimeout>[]>([]);\n const toastIds = useRef<string[]>([]);\n const cancelRevoke = useRef<Focusable>(null);\n const guideButton = useRef<Focusable>(null);\n // Each row's Revoke button by client id, so focus can move to one when the button that had it is gone.\n const revokeButtons = useRef<Record<string, Focusable>>({});\n // Where focus goes after the next render, once the element it goes to is on screen.\n const focusNext = useRef<() => void>();\n\n // On unmount it stops every request and closes every toast it opened.\n useEffect(() => () => {\n timers.current.forEach(clearTimeout);\n toastIds.current.forEach((id) => dismissToast(id));\n toastIds.current = [];\n }, []);\n\n useEffect(() => {\n const move = focusNext.current;\n focusNext.current = undefined;\n move?.();\n });\n\n // Stands in for the request to the server.\n function later(callback: () => void, ms: number) {\n timers.current.push(setTimeout(callback, ms));\n }\n\n // Each row's choice stands alone, so it saves as soon as it is made, and shows nothing when it works.\n // A press on a row that is still saving does nothing. The row stays enabled, so focus stays on it.\n function choose(tool: Tool, next: string) {\n if (!canChange || savingTool === tool.id || next === settings[tool.id]) return;\n setSettings((current) => ({ ...current, [tool.id]: next as Setting }));\n setSavingTool(tool.id);\n later(() => setSavingTool((id) => (id === tool.id ? null : id)), 900);\n }\n\n // The confirm opens in the row, with focus on 'Cancel'.\n function askToRevoke(c: Client) {\n setConfirming(c.id);\n focusNext.current = () => cancelRevoke.current?.focus();\n }\n\n // 'Cancel' goes away with the confirm, so focus goes back to the row's Revoke button.\n function keepClient(c: Client) {\n if (revoking) return;\n setConfirming(null);\n focusNext.current = () => revokeButtons.current[c.id]?.focus();\n }\n\n function revoke(c: Client) {\n if (revoking) return;\n const at = clients.findIndex((x) => x.id === c.id);\n const neighbor = clients[at + 1] ?? clients[at - 1];\n setRevoking(c.id);\n later(() => {\n setRevoking(null);\n setConfirming(null);\n setClients((list) => list.filter((x) => x.id !== c.id));\n // The row is gone: focus goes to the next row's Revoke, or the one before it when it was the last.\n // With no client left, it goes to the guide Button in the empty list.\n focusNext.current = () => (neighbor ? revokeButtons.current[neighbor.id] : guideButton.current)?.focus();\n toastIds.current.push(toast({ type: 'success', message: `${c.name} revoked.` }));\n }, 1200);\n }\n\n return (\n <Center width=\"page\">\n {/* A real app mounts one Toaster near its root. */}\n <Toaster />\n <Stack gap=\"xlarge\">\n <Stack gap=\"small\">\n <Heading level={1} size=\"h5\">Agent tools</Heading>\n <Paragraph tone=\"secondary\" size=\"body2\" measure=\"none\">What Acme Agent may do in this workspace, for everyone.</Paragraph>\n </Stack>\n {/* One line at the top says why nothing can be changed, and who can. */}\n {!canChange && <Alert type=\"info\" variant=\"inline\" message=\"Only admins can change these settings. Your admin is Dana Lee.\" autoDismiss={false} />}\n\n <SettingsSection title=\"Tools\" description=\"Each choice saves as soon as you make it. Ask means Acme Agent asks before each use.\">\n <TableContainer>\n <TableHeader>\n <TableRow>\n <TableHeaderCell>Tool</TableHeaderCell>\n <TableHeaderCell width=\"184px\">Setting</TableHeaderCell>\n </TableRow>\n </TableHeader>\n {tools.map((t) => (\n <TableRow key={t.id}>\n <TableCell>\n <Stack gap=\"small\">\n {t.name}\n <Paragraph size=\"body2\" tone=\"secondary\" measure=\"none\">{t.risky ?? t.does}</Paragraph>\n </Stack>\n </TableCell>\n <TableCell width=\"184px\">\n <SegmentedControl\n size=\"small\"\n aria-label={t.name}\n options={t.risky ? riskyOptions : allOptions}\n value={settings[t.id]}\n disabled={!canChange}\n onChange={(next) => choose(t, next)}\n />\n </TableCell>\n </TableRow>\n ))}\n </TableContainer>\n </SettingsSection>\n\n <SettingsSection title=\"Connected apps\" description=\"Apps that use Acme Agent from outside Acme. They can use the tools above.\">\n {clients.length > 0 ? (\n <TableContainer>\n {clients.map((c) => (\n <TableRow key={c.id}>\n <TableCell>\n <Stack gap=\"small\">\n {c.name}\n <Paragraph size=\"body2\" tone=\"secondary\" measure=\"none\">{confirming === c.id ? `Revoke ${c.name}? It stops working until someone connects it again.` : c.connected}</Paragraph>\n </Stack>\n </TableCell>\n {/* A fixed last column keeps every row's Buttons in one place, so they do not jump when they change. */}\n <TableCell width=\"168px\" align=\"right\">\n {confirming === c.id ? (\n <Cluster gap=\"small\" justify=\"end\">\n <Button ref={cancelRevoke} size=\"small\" type=\"tertiary\" state={revoking ? 'disabled' : 'enabled'} label=\"Cancel\" aria-label={`Cancel revoking ${c.name}`} onClickButton={() => keepClient(c)} />\n <Button size=\"small\" type=\"primary\" color=\"danger\" state=\"enabled\" label=\"Revoke\" aria-label={`Revoke ${c.name}`} loading={revoking === c.id} onClickButton={() => revoke(c)} />\n </Cluster>\n ) : (\n canChange && (\n <Cluster justify=\"end\">\n <Button ref={(el) => { revokeButtons.current[c.id] = el; }} size=\"small\" type=\"tertiary\" state={revoking ? 'disabled' : 'enabled'} label=\"Revoke\" aria-label={`Revoke ${c.name}`} onClickButton={() => askToRevoke(c)} />\n </Cluster>\n )\n )}\n </TableCell>\n </TableRow>\n ))}\n </TableContainer>\n ) : (\n <EmptyBox\n size=\"small\"\n icon=\"Plug\"\n text=\"No connected apps\"\n secondText=\"Apps you connect to Acme Agent appear here.\"\n action={<Button ref={guideButton} size=\"small\" type=\"secondary\" state=\"enabled\" label=\"Read the Setup Guide\" href=\"/docs/agent/clients\" />}\n />\n )}\n </SettingsSection>\n </Stack>\n </Center>\n );\n}\n",
776
+ "uses": [
777
+ "Alert",
778
+ "Button",
779
+ "Center",
780
+ "Cluster",
781
+ "EmptyBox",
782
+ "Heading",
783
+ "Paragraph",
784
+ "SegmentedControl",
785
+ "SettingsSection",
786
+ "Stack",
787
+ "TableCell",
788
+ "TableContainer",
789
+ "TableHeader",
790
+ "TableHeaderCell",
791
+ "TableRow",
792
+ "Toaster",
793
+ "dismissToast",
794
+ "toast"
795
+ ]
796
+ }
797
+ ]
798
+ },
482
799
  {
483
800
  "id": "agent-plan-proposal",
484
801
  "title": "Plan proposal",
485
802
  "kind": "design",
486
803
  "level": "organism",
487
804
  "area": "agent",
805
+ "surface": [
806
+ "agent"
807
+ ],
488
808
  "situation": "The agent is about to change shared work and needs the person to approve it first.",
489
809
  "do": [
490
- "Follow the rule 'An agent asks before a risky action': the agent does nothing until the person presses 'Approve'.",
810
+ "Follow the rule 'An agent asks before a risky action': the agent does nothing until the person presses 'Approve', or 'Apply Changes' on a changes card.",
491
811
  "Put the card in the agent's `Message`, in a `Surface` with a heading, the plan, then the buttons.",
492
812
  "List every step in a `<StepList numbered>`, in the order the agent will do them, each one waiting.",
813
+ "Say what the run will touch before it starts: the files, tools or people.",
493
814
  "Offer 'View Changes' when the changes are ready, so the person sees them before they approve. It opens a `Modal` that lists them.",
494
- "List each changed file in that Modal with one line on what changes in it. ODS has no diff part yet.",
815
+ "List each changed file in that Modal with one line on what changes in it.",
816
+ "Follow the case 'Review of an agent's changes' when the person needs to read the changed lines.",
495
817
  "Order the steps card's buttons 'Cancel', 'Edit', then 'Approve' as the primary Button, at the start of the row under the plan.",
496
- "Order the changes card's buttons 'Cancel', 'Request Changes', then 'Approve' as the primary Button.",
497
- "Let the product write the label 'Approve'. The agent never writes the label of an approve or merge button.",
818
+ "Order the changes card's buttons 'Cancel', 'Request Changes', then 'Apply Changes' as the primary Button, as the case 'Review of an agent's changes' does.",
819
+ "Let the product write the labels 'Approve' and 'Apply Changes'. The agent never writes the label of an approve or merge button.",
498
820
  "Show the waiting time on the card while it waits, and while the person edits: 'Waits 10 more minutes, then cancels.'",
499
821
  "Notify the person who asked when the agent needs their answer.",
500
822
  "Make the pressed Button `loading` and keep its label. Disable the others while the request runs.",
501
823
  "Keep the card and its buttons when a request fails. Show an inline error `Alert` above the buttons, as the rule 'A form error shows next to the problem' says.",
502
- "Mark the card with an 'Approved' or 'Cancelled' `Tag` once it is decided, and remove its buttons.",
824
+ "Mark a steps card with an 'Approved' or 'Cancelled' `Tag` once it is decided, and remove its buttons.",
825
+ "Mark a changes card with an 'Applied', 'Rejected' or 'Cancelled' `Tag`, as the case 'Review of an agent's changes' does.",
503
826
  "Announce the decided `Tag` politely: the app wraps it in a polite live region.",
504
827
  "Keep an approved card as the record: the steps as they were approved, none running, and no buttons.",
505
828
  "Move the run to its own progress row under the card, as the case 'Agent at work' shows, with its 'Stop'.",
@@ -530,7 +853,7 @@
530
853
  "id": "steps",
531
854
  "title": "Steps",
532
855
  "useWhen": "The agent will carry out a list of steps.",
533
- "source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport { Bot } from 'lucide-react';\nimport Message from 'oneslash-design-system/components/message';\nimport UserImage from 'oneslash-design-system/components/userImage';\nimport Tag from 'oneslash-design-system/components/tag';\nimport TimeStamp from 'oneslash-design-system/components/timeStamp';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Button from 'oneslash-design-system/components/button';\nimport Surface from 'oneslash-design-system/components/surface';\nimport StepList, { type StepListStep } from 'oneslash-design-system/components/stepList';\nimport Textarea from 'oneslash-design-system/components/textarea';\nimport { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';\n\ntype Focusable = HTMLButtonElement | HTMLAnchorElement | null;\n\nconst agentName = 'Acme Agent';\n\nconst request = { from: 'Dana Lee', at: new Date('2025-01-15T11:40:00Z'), text: 'Can you update the pricing page for the new plans?' };\nconst proposedAt = new Date('2025-01-15T11:41:00Z');\n\nconst firstSteps = [\n 'Change the Pro price from $12 to $15',\n 'Add the Team plan at $25 per seat',\n 'Update the plan table on the pricing page',\n 'Open a pull request for review',\n];\n\nconst reply = 'The pricing page is updated, and the pull request is open for review.';\n\ntype Status = 'open' | 'editing' | 'approved' | 'cancelled';\ntype Run = 'running' | 'stopping' | 'stopped' | 'done';\n\n// Finished steps keep a check, the current one runs, and steps the agent has not started are not shown.\nfunction stepsUpTo(steps: string[], current: number): StepListStep[] {\n return steps.slice(0, current + 1).map((label, i) => ({ label, status: i < current ? 'done' : 'running' }));\n}\n\nfunction secondsLine(seconds: number) {\n return `Working for ${seconds} ${seconds === 1 ? 'second' : 'seconds'}`;\n}\n\n// The agent's marks, as the rule 'An agent says what it is' says.\nfunction agentMeta(at: Date) {\n return (\n <>\n <Tag variant=\"contained\" size=\"small\" label=\"Agent\" />\n <TimeStamp createdAt={at} dateFormat=\"absolute\" data=\"time\" />\n <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">Model name</Paragraph>\n </>\n );\n}\n\nexport default function AgentPlanProposalSteps() {\n const [steps, setSteps] = useState(firstSteps);\n const [status, setStatus] = useState<Status>('open');\n const [pending, setPending] = useState<'approve' | 'cancel' | 'save' | null>(null);\n const [draft, setDraft] = useState('');\n // The run after 'Approve', in its own progress row under the card.\n const [run, setRun] = useState<Run | null>(null);\n const [current, setCurrent] = useState(0);\n const [seconds, setSeconds] = useState(0);\n const [startedAt, setStartedAt] = useState(proposedAt);\n const timer = useRef<ReturnType<typeof setTimeout>>();\n const tick = useRef<ReturnType<typeof setInterval>>();\n const step = useRef<ReturnType<typeof setTimeout>>();\n const cancel = useRef<ReturnType<typeof setTimeout>>();\n const editButton = useRef<Focusable>(null);\n const stopButton = useRef<Focusable>(null);\n // Where focus goes after the next render, once the element it goes to is on screen.\n const focusNext = useRef<() => void>();\n\n // On unmount it stops the requests, the run and its clock.\n useEffect(() => () => {\n clearTimeout(timer.current);\n clearInterval(tick.current);\n clearTimeout(step.current);\n clearTimeout(cancel.current);\n }, []);\n\n useEffect(() => {\n const move = focusNext.current;\n focusNext.current = undefined;\n move?.();\n });\n\n // Stands in for the agent's run: one step every 1.5 seconds.\n function advance(at: number) {\n step.current = setTimeout(() => {\n if (at === steps.length - 1) {\n clearInterval(tick.current);\n setRun('done');\n return;\n }\n setCurrent(at + 1);\n advance(at + 1);\n }, 1500);\n }\n\n // The card stays as the record, and the run shows in its own progress row below it.\n // 'Approve' is gone and 'Stop' is the control that took its place, so focus goes to 'Stop'.\n function startRun() {\n setRun('running');\n setCurrent(0);\n setSeconds(0);\n setStartedAt(new Date());\n tick.current = setInterval(() => setSeconds((s) => s + 1), 1000);\n advance(0);\n focusNext.current = () => stopButton.current?.focus();\n }\n\n // Decided once: the buttons go away, so a second click cannot approve or cancel it again.\n // After 'Cancel' nothing takes their place: a real app moves focus to the message box.\n function decide(action: 'approve' | 'cancel') {\n if (pending || status !== 'open') return;\n setPending(action);\n // Stands in for the request to the server.\n timer.current = setTimeout(() => {\n setPending(null);\n if (action === 'cancel') {\n setStatus('cancelled');\n return;\n }\n setStatus('approved');\n startRun();\n }, 1200);\n }\n\n // Stop asks the server to end the run. The row says it stopped only once the run has ended.\n function stop() {\n if (run !== 'running') return;\n clearTimeout(step.current);\n setRun('stopping');\n // Stands in for the request to the server.\n cancel.current = setTimeout(() => {\n clearInterval(tick.current);\n setRun('stopped');\n }, 1200);\n }\n\n function startEditing() {\n if (pending) return;\n setDraft(steps.join('\\n'));\n setStatus('editing');\n }\n\n // 'Discard' leaves the edit and keeps the plan as it was. 'Cancel' would cancel the whole proposal.\n function discard() {\n setStatus('open');\n focusNext.current = () => editButton.current?.focus();\n }\n\n const draftSteps = draft.split('\\n').map((s) => s.trim()).filter((s) => s !== '');\n\n // 'Save' sends the edited steps to the agent. The plan comes back with them, still waiting for a yes.\n function save() {\n if (pending || draftSteps.length === 0) return;\n setPending('save');\n // Stands in for the request to the server.\n timer.current = setTimeout(() => {\n setPending(null);\n setSteps(draftSteps);\n setStatus('open');\n focusNext.current = () => editButton.current?.focus();\n }, 1200);\n }\n\n // A stop says how far the run got, so it never says nothing changed when something did.\n // A real app takes the count from the server's answer, not from the list on screen.\n const stoppedNote = current === 0\n ? 'Stopped. Nothing was changed.'\n : `Stopped after ${current} of ${steps.length} steps. The rest of the plan was not done.`;\n\n return (\n <Center width=\"page\">\n <Stack gap=\"large\">\n <Heading level={1} size=\"h5\">Launch plan</Heading>\n {/* A real app gives the list that holds the rows role=\"log\". */}\n <Stack gap=\"small\">\n <Message\n aria-label={request.from}\n avatar={<UserImage userHandle={request.from} decorative />}\n name={request.from}\n meta={<TimeStamp createdAt={request.at} dateFormat=\"absolute\" data=\"time\" />}\n >\n <Paragraph measure=\"none\">{request.text}</Paragraph>\n </Message>\n <Message\n aria-label={`${agentName}, agent`}\n avatar={<UserImage userHandle={agentName} icon={Bot} decorative />}\n name={agentName}\n meta={agentMeta(proposedAt)}\n >\n <Surface padding=\"small\">\n <Stack gap=\"medium\">\n {/* A real app announces the decided Tag in a polite live region. */}\n <Cluster gap=\"small\">\n <Heading level={2} size=\"subtitle1\">Proposed plan</Heading>\n {status === 'approved' && <Tag variant=\"contained\" size=\"small\" color=\"success\" label=\"Approved\" />}\n {status === 'cancelled' && <Tag variant=\"contained\" size=\"small\" label=\"Cancelled\" />}\n </Cluster>\n {status === 'editing' ? (\n <Textarea\n id=\"agent-plan-proposal-steps\"\n label=\"Steps, one per line\"\n value={draft}\n onChange={(e) => setDraft(e.target.value)}\n onSubmit={save}\n autoFocus\n maxRows={10}\n disabled={pending === 'save'}\n />\n ) : (\n // Every step, in the order the agent will do them. Once decided, the card is the record:\n // an approved plan keeps its steps as they were, and a cancelled one marks each step cancelled.\n <StepList\n numbered\n aria-label=\"Proposed plan\"\n steps={steps.map((label) => ({ label, status: status === 'cancelled' ? 'cancelled' : 'waiting' }))}\n />\n )}\n {/* The product sets the waiting time and counts it down. When it is up, the card is marked Cancelled. */}\n {(status === 'open' || status === 'editing') && (\n <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">Waits 10 more minutes, then cancels.</Paragraph>\n )}\n {status === 'open' && (\n <Cluster gap=\"small\">\n <Button size=\"small\" type=\"tertiary\" state={pending === 'approve' ? 'disabled' : 'enabled'} label=\"Cancel\" loading={pending === 'cancel'} onClickButton={() => decide('cancel')} />\n <Button ref={editButton} size=\"small\" type=\"secondary\" state={pending ? 'disabled' : 'enabled'} label=\"Edit\" onClickButton={startEditing} />\n {/* The product writes this label, never the agent. */}\n <Button size=\"small\" type=\"primary\" state={pending === 'cancel' ? 'disabled' : 'enabled'} label=\"Approve\" loading={pending === 'approve'} onClickButton={() => decide('approve')} />\n </Cluster>\n )}\n {status === 'editing' && (\n <Cluster gap=\"small\">\n <Button size=\"small\" type=\"tertiary\" state={pending === 'save' ? 'disabled' : 'enabled'} label=\"Discard\" onClickButton={discard} />\n <Button size=\"small\" type=\"primary\" state={draftSteps.length === 0 ? 'disabled' : 'enabled'} label=\"Save\" loading={pending === 'save'} onClickButton={save} />\n </Cluster>\n )}\n </Stack>\n </Surface>\n </Message>\n {status === 'cancelled' && (\n // One line in the thread on what was not done, under the card.\n <Message compact aria-label={`${agentName}, agent`}>\n <Paragraph measure=\"none\">Cancelled. Nothing was changed.</Paragraph>\n </Message>\n )}\n {run && (\n // The run's own progress row, as the case 'Agent at work' shows.\n <Message\n aria-label={`${agentName}, agent`}\n avatar={<UserImage userHandle={agentName} icon={Bot} decorative />}\n name={agentName}\n meta={agentMeta(startedAt)}\n footer={\n run === 'running' || run === 'stopping' ? (\n // The only Stop, on the row for the whole run. It shows loading while the run is stopping.\n // When it goes, a real app moves focus to the message box.\n <Cluster>\n <Button ref={stopButton} size=\"small\" type=\"secondary\" state=\"enabled\" label=\"Stop\" loading={run === 'stopping'} onClickButton={stop} />\n </Cluster>\n ) : undefined\n }\n >\n {run === 'done' ? (\n <Paragraph measure=\"none\">{reply}</Paragraph>\n ) : run === 'stopped' ? (\n <Paragraph measure=\"none\">{stoppedNote}</Paragraph>\n ) : (\n // A real app wraps this part in a polite live region, since StepList has none.\n <Stack gap=\"medium\">\n <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">{secondsLine(seconds)}</Paragraph>\n <StepList aria-label=\"Acme Agent's steps\" steps={stepsUpTo(steps, current)} />\n </Stack>\n )}\n </Message>\n )}\n </Stack>\n </Stack>\n </Center>\n );\n}\n",
856
+ "source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport { Bot } from 'lucide-react';\nimport Message from 'oneslash-design-system/components/message';\nimport UserImage from 'oneslash-design-system/components/userImage';\nimport Tag from 'oneslash-design-system/components/tag';\nimport TimeStamp from 'oneslash-design-system/components/timeStamp';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Button from 'oneslash-design-system/components/button';\nimport Surface from 'oneslash-design-system/components/surface';\nimport StepList, { type StepListStep } from 'oneslash-design-system/components/stepList';\nimport Textarea from 'oneslash-design-system/components/textarea';\nimport { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';\n\ntype Focusable = HTMLButtonElement | HTMLAnchorElement | null;\n\nconst agentName = 'Acme Agent';\n\nconst request = { from: 'Dana Lee', at: new Date('2025-01-15T11:40:00Z'), text: 'Can you update the pricing page for the new plans?' };\nconst proposedAt = new Date('2025-01-15T11:41:00Z');\n\nconst firstSteps = [\n 'Change the Pro price from $12 to $15',\n 'Add the Team plan at $25 per seat',\n 'Update the plan table on the pricing page',\n 'Open a pull request for review',\n];\n\nconst reply = 'The pricing page is updated, and the pull request is open for review.';\n\ntype Status = 'open' | 'editing' | 'approved' | 'cancelled';\ntype Run = 'running' | 'stopping' | 'stopped' | 'done';\n\n// Finished steps keep a check, the current one runs, and while it runs the steps the agent has not started are not shown.\n// Once the run is stopped, the whole list shows: the step it stopped on and the steps after it are cancelled.\nfunction stepsUpTo(steps: string[], current: number, stopped = false): StepListStep[] {\n return (stopped ? steps : steps.slice(0, current + 1)).map((label, i) => ({ label, status: i < current ? 'done' : stopped ? 'cancelled' : 'running' }));\n}\n\nfunction secondsLine(seconds: number) {\n return `Working for ${seconds} ${seconds === 1 ? 'second' : 'seconds'}`;\n}\n\n// The agent's marks, as the rule 'An agent says what it is' says.\nfunction agentMeta(at: Date) {\n return (\n <>\n <Tag variant=\"contained\" size=\"small\" label=\"Agent\" />\n <TimeStamp createdAt={at} dateFormat=\"absolute\" data=\"time\" />\n <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">Model name</Paragraph>\n </>\n );\n}\n\nexport default function AgentPlanProposalSteps() {\n const [steps, setSteps] = useState(firstSteps);\n const [status, setStatus] = useState<Status>('open');\n const [pending, setPending] = useState<'approve' | 'cancel' | 'save' | null>(null);\n const [draft, setDraft] = useState('');\n // The run after 'Approve', in its own progress row under the card.\n const [run, setRun] = useState<Run | null>(null);\n const [current, setCurrent] = useState(0);\n const [seconds, setSeconds] = useState(0);\n const [startedAt, setStartedAt] = useState(proposedAt);\n const timer = useRef<ReturnType<typeof setTimeout>>();\n const tick = useRef<ReturnType<typeof setInterval>>();\n const step = useRef<ReturnType<typeof setTimeout>>();\n const cancel = useRef<ReturnType<typeof setTimeout>>();\n const editButton = useRef<Focusable>(null);\n const stopButton = useRef<Focusable>(null);\n // Where focus goes after the next render, once the element it goes to is on screen.\n const focusNext = useRef<() => void>();\n\n // On unmount it stops the requests, the run and its clock.\n useEffect(() => () => {\n clearTimeout(timer.current);\n clearInterval(tick.current);\n clearTimeout(step.current);\n clearTimeout(cancel.current);\n }, []);\n\n useEffect(() => {\n const move = focusNext.current;\n focusNext.current = undefined;\n move?.();\n });\n\n // Stands in for the agent's run: one step every 1.5 seconds.\n function advance(at: number) {\n step.current = setTimeout(() => {\n if (at === steps.length - 1) {\n clearInterval(tick.current);\n setRun('done');\n return;\n }\n setCurrent(at + 1);\n advance(at + 1);\n }, 1500);\n }\n\n // The card stays as the record, and the run shows in its own progress row below it.\n // 'Approve' is gone and 'Stop' is the control that took its place, so focus goes to 'Stop'.\n function startRun() {\n setRun('running');\n setCurrent(0);\n setSeconds(0);\n setStartedAt(new Date());\n tick.current = setInterval(() => setSeconds((s) => s + 1), 1000);\n advance(0);\n focusNext.current = () => stopButton.current?.focus();\n }\n\n // Decided once: the buttons go away, so a second click cannot approve or cancel it again.\n // After 'Cancel' nothing takes their place: a real app moves focus to the message box.\n function decide(action: 'approve' | 'cancel') {\n if (pending || status !== 'open') return;\n setPending(action);\n // Stands in for the request to the server.\n timer.current = setTimeout(() => {\n setPending(null);\n if (action === 'cancel') {\n setStatus('cancelled');\n return;\n }\n setStatus('approved');\n startRun();\n }, 1200);\n }\n\n // Stop asks the server to end the run. The row says it stopped only once the run has ended.\n function stop() {\n if (run !== 'running') return;\n clearTimeout(step.current);\n setRun('stopping');\n // Stands in for the request to the server.\n cancel.current = setTimeout(() => {\n clearInterval(tick.current);\n setRun('stopped');\n }, 1200);\n }\n\n function startEditing() {\n if (pending) return;\n setDraft(steps.join('\\n'));\n setStatus('editing');\n }\n\n // 'Discard' leaves the edit and keeps the plan as it was. 'Cancel' would cancel the whole proposal.\n function discard() {\n setStatus('open');\n focusNext.current = () => editButton.current?.focus();\n }\n\n const draftSteps = draft.split('\\n').map((s) => s.trim()).filter((s) => s !== '');\n\n // 'Save' sends the edited steps to the agent. The plan comes back with them, still waiting for a yes.\n function save() {\n if (pending || draftSteps.length === 0) return;\n setPending('save');\n // Stands in for the request to the server.\n timer.current = setTimeout(() => {\n setPending(null);\n setSteps(draftSteps);\n setStatus('open');\n focusNext.current = () => editButton.current?.focus();\n }, 1200);\n }\n\n // A stop says how far the run got, so it never says nothing changed when something did.\n // A real app takes the count from the server's answer, not from the list on screen.\n const stoppedNote = current === 0\n ? 'Stopped. Nothing was changed.'\n : `Stopped after ${current} of ${steps.length} steps. The rest of the plan was not done.`;\n\n return (\n <Center width=\"page\">\n <Stack gap=\"large\">\n <Heading level={1} size=\"h5\">Launch plan</Heading>\n {/* A real app gives the list that holds the rows role=\"log\". */}\n <Stack gap=\"small\">\n <Message\n aria-label={request.from}\n avatar={<UserImage userHandle={request.from} decorative />}\n name={request.from}\n meta={<TimeStamp createdAt={request.at} dateFormat=\"absolute\" data=\"time\" />}\n >\n <Paragraph measure=\"none\">{request.text}</Paragraph>\n </Message>\n <Message\n aria-label={`${agentName}, agent`}\n avatar={<UserImage userHandle={agentName} icon={Bot} decorative />}\n name={agentName}\n meta={agentMeta(proposedAt)}\n >\n <Surface padding=\"small\">\n <Stack gap=\"medium\">\n {/* A real app announces the decided Tag in a polite live region. */}\n <Cluster gap=\"small\">\n <Heading level={2} size=\"subtitle1\">Proposed plan</Heading>\n {status === 'approved' && <Tag variant=\"contained\" size=\"small\" color=\"success\" label=\"Approved\" />}\n {status === 'cancelled' && <Tag variant=\"contained\" size=\"small\" label=\"Cancelled\" />}\n </Cluster>\n {status === 'editing' ? (\n <Textarea\n id=\"agent-plan-proposal-steps\"\n label=\"Steps, one per line\"\n value={draft}\n onChange={(e) => setDraft(e.target.value)}\n onSubmit={save}\n autoFocus\n maxRows={10}\n disabled={pending === 'save'}\n />\n ) : (\n // Every step, in the order the agent will do them. Once decided, the card is the record:\n // an approved plan keeps its steps as they were, and a cancelled one marks each step cancelled.\n <StepList\n numbered\n aria-label=\"Proposed plan\"\n steps={steps.map((label) => ({ label, status: status === 'cancelled' ? 'cancelled' : 'waiting' }))}\n />\n )}\n {/* The product sets the waiting time and counts it down. When it is up, the card is marked Cancelled. */}\n {(status === 'open' || status === 'editing') && (\n <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">Waits 10 more minutes, then cancels.</Paragraph>\n )}\n {status === 'open' && (\n <Cluster gap=\"small\">\n <Button size=\"small\" type=\"tertiary\" state={pending === 'approve' ? 'disabled' : 'enabled'} label=\"Cancel\" loading={pending === 'cancel'} onClickButton={() => decide('cancel')} />\n <Button ref={editButton} size=\"small\" type=\"secondary\" state={pending ? 'disabled' : 'enabled'} label=\"Edit\" onClickButton={startEditing} />\n {/* The product writes this label, never the agent. */}\n <Button size=\"small\" type=\"primary\" state={pending === 'cancel' ? 'disabled' : 'enabled'} label=\"Approve\" loading={pending === 'approve'} onClickButton={() => decide('approve')} />\n </Cluster>\n )}\n {status === 'editing' && (\n <Cluster gap=\"small\">\n <Button size=\"small\" type=\"tertiary\" state={pending === 'save' ? 'disabled' : 'enabled'} label=\"Discard\" onClickButton={discard} />\n <Button size=\"small\" type=\"primary\" state={draftSteps.length === 0 ? 'disabled' : 'enabled'} label=\"Save\" loading={pending === 'save'} onClickButton={save} />\n </Cluster>\n )}\n </Stack>\n </Surface>\n </Message>\n {status === 'cancelled' && (\n // One line in the thread on what was not done, under the card.\n <Message compact aria-label={`${agentName}, agent`}>\n <Paragraph measure=\"none\">Cancelled. Nothing was changed.</Paragraph>\n </Message>\n )}\n {run && (\n // The run's own progress row, as the case 'Agent at work' shows.\n <Message\n aria-label={`${agentName}, agent`}\n avatar={<UserImage userHandle={agentName} icon={Bot} decorative />}\n name={agentName}\n meta={agentMeta(startedAt)}\n footer={\n run === 'running' || run === 'stopping' ? (\n // The only Stop, on the row for the whole run. It shows loading while the run is stopping.\n // When it goes, a real app moves focus to the message box.\n <Cluster>\n <Button ref={stopButton} size=\"small\" type=\"secondary\" state=\"enabled\" label=\"Stop\" loading={run === 'stopping'} onClickButton={stop} />\n </Cluster>\n ) : undefined\n }\n >\n {run === 'done' ? (\n <Paragraph measure=\"none\">{reply}</Paragraph>\n ) : run === 'stopped' ? (\n // The steps stay, as the rule 'An agent that stops short says what it finished and what is left' says.\n <Stack gap=\"medium\">\n <StepList aria-label=\"Acme Agent's steps\" steps={stepsUpTo(steps, current, true)} />\n <Paragraph measure=\"none\">{stoppedNote}</Paragraph>\n </Stack>\n ) : (\n // A real app wraps this part in a polite live region, since StepList has none.\n <Stack gap=\"medium\">\n <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">{secondsLine(seconds)}</Paragraph>\n <StepList aria-label=\"Acme Agent's steps\" steps={stepsUpTo(steps, current)} />\n </Stack>\n )}\n </Message>\n )}\n </Stack>\n </Stack>\n </Center>\n );\n}\n",
534
857
  "uses": [
535
858
  "Button",
536
859
  "Center",
@@ -550,8 +873,8 @@
550
873
  {
551
874
  "id": "changes",
552
875
  "title": "Changes",
553
- "useWhen": "The agent has changes ready to apply.",
554
- "source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport { Bot } from 'lucide-react';\nimport Message from 'oneslash-design-system/components/message';\nimport UserImage from 'oneslash-design-system/components/userImage';\nimport Tag from 'oneslash-design-system/components/tag';\nimport TimeStamp from 'oneslash-design-system/components/timeStamp';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Button from 'oneslash-design-system/components/button';\nimport Surface from 'oneslash-design-system/components/surface';\nimport Modal from 'oneslash-design-system/components/modal';\nimport List from 'oneslash-design-system/components/list';\nimport StepList, { type StepListStep } from 'oneslash-design-system/components/stepList';\nimport Textarea from 'oneslash-design-system/components/textarea';\nimport { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';\n\ntype Focusable = HTMLButtonElement | HTMLAnchorElement | null;\n\nconst agentName = 'Acme Agent';\n\nconst request = { from: 'Dana Lee', at: new Date('2025-01-15T11:40:00Z'), text: 'Can you update the pricing page for the new plans?' };\nconst proposedAt = new Date('2025-01-15T11:44:00Z');\n\n// ODS has no diff part yet, so the changes are a list of the files they touch, each with what changes in it.\nconst changedFiles = [\n { path: 'pages/pricing.tsx', change: 'Adds the Team plan to the page.' },\n { path: 'data/plans.json', change: 'Sets the Pro price to $15 and adds the Team plan at $25 per seat.' },\n { path: 'components/planTable.tsx', change: 'Adds a column for the Team plan.' },\n];\n\n// The run after 'Approve': one step per file.\nconst runSteps = changedFiles.map((f) => `Change ${f.path}`);\n\nconst reply = 'The three files are changed. The pricing page shows the new plans.';\n\ntype Status = 'open' | 'requesting' | 'redoing' | 'approved' | 'cancelled';\ntype Run = 'running' | 'stopping' | 'stopped' | 'done';\n\n// Finished steps keep a check, the current one runs, and steps the agent has not started are not shown.\nfunction stepsUpTo(current: number): StepListStep[] {\n return runSteps.slice(0, current + 1).map((label, i) => ({ label, status: i < current ? 'done' : 'running' }));\n}\n\nfunction secondsLine(seconds: number) {\n return `Working for ${seconds} ${seconds === 1 ? 'second' : 'seconds'}`;\n}\n\n// The agent's marks, as the rule 'An agent says what it is' says.\nfunction agentMeta(at: Date) {\n return (\n <>\n <Tag variant=\"contained\" size=\"small\" label=\"Agent\" />\n <TimeStamp createdAt={at} dateFormat=\"absolute\" data=\"time\" />\n <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">Model name</Paragraph>\n </>\n );\n}\n\nexport default function AgentPlanProposalChanges() {\n const [status, setStatus] = useState<Status>('open');\n const [pending, setPending] = useState<'approve' | 'cancel' | 'send' | null>(null);\n const [viewing, setViewing] = useState(false);\n const [draft, setDraft] = useState('');\n // The run after 'Approve', in its own progress row under the card.\n const [run, setRun] = useState<Run | null>(null);\n const [current, setCurrent] = useState(0);\n const [seconds, setSeconds] = useState(0);\n const [startedAt, setStartedAt] = useState(proposedAt);\n const timer = useRef<ReturnType<typeof setTimeout>>();\n const tick = useRef<ReturnType<typeof setInterval>>();\n const step = useRef<ReturnType<typeof setTimeout>>();\n const cancel = useRef<ReturnType<typeof setTimeout>>();\n const requestButton = useRef<Focusable>(null);\n const stopButton = useRef<Focusable>(null);\n // Where focus goes after the next render, once the element it goes to is on screen.\n const focusNext = useRef<() => void>();\n\n // On unmount it stops the requests, the run and its clock.\n useEffect(() => () => {\n clearTimeout(timer.current);\n clearInterval(tick.current);\n clearTimeout(step.current);\n clearTimeout(cancel.current);\n }, []);\n\n useEffect(() => {\n const move = focusNext.current;\n focusNext.current = undefined;\n move?.();\n });\n\n // Stands in for the agent's run: one step every 1.5 seconds.\n function advance(at: number) {\n step.current = setTimeout(() => {\n if (at === runSteps.length - 1) {\n clearInterval(tick.current);\n setRun('done');\n return;\n }\n setCurrent(at + 1);\n advance(at + 1);\n }, 1500);\n }\n\n // The card stays as the record, and the run shows in its own progress row below it.\n // 'Approve' is gone and 'Stop' is the control that took its place, so focus goes to 'Stop'.\n function startRun() {\n setRun('running');\n setCurrent(0);\n setSeconds(0);\n setStartedAt(new Date());\n tick.current = setInterval(() => setSeconds((s) => s + 1), 1000);\n advance(0);\n focusNext.current = () => stopButton.current?.focus();\n }\n\n // Decided once: the buttons go away, so a second click cannot approve or cancel it again.\n // After 'Cancel' nothing takes their place: a real app moves focus to the message box.\n function decide(action: 'approve' | 'cancel') {\n if (pending || status !== 'open') return;\n setPending(action);\n // Stands in for the request to the server.\n timer.current = setTimeout(() => {\n setPending(null);\n if (action === 'cancel') {\n setStatus('cancelled');\n return;\n }\n setStatus('approved');\n startRun();\n }, 1200);\n }\n\n // Stop asks the server to end the run. The row says it stopped only once the run has ended.\n function stop() {\n if (run !== 'running') return;\n clearTimeout(step.current);\n setRun('stopping');\n // Stands in for the request to the server.\n cancel.current = setTimeout(() => {\n clearInterval(tick.current);\n setRun('stopped');\n }, 1200);\n }\n\n function startRequest() {\n if (pending) return;\n setDraft('');\n setStatus('requesting');\n }\n\n // 'Discard' leaves the sub-form and keeps the proposal open. 'Cancel' would cancel the whole proposal.\n function discard() {\n setStatus('open');\n focusNext.current = () => requestButton.current?.focus();\n }\n\n const empty = draft.trim() === '';\n\n // 'Send' gives the agent what should change. The card's buttons go, and the agent redoes the changes.\n // Nothing takes their place: a real app moves focus to the message box.\n function send() {\n if (pending || empty) return;\n setPending('send');\n // Stands in for the request to the server.\n timer.current = setTimeout(() => {\n setPending(null);\n setStatus('redoing');\n }, 1200);\n }\n\n // A real app takes the count from the server's answer. Here the file that was being changed when the run\n // stopped may be partly changed, so the note says so and does not claim it is untouched.\n const partFile = changedFiles[current].path;\n const stoppedNote = current === 0\n ? `Stopped before any file was done. ${partFile} may be partly changed. Check it.`\n : `Stopped after ${current} of ${runSteps.length} files. ${partFile} may be partly changed. Check it.`;\n\n return (\n <Center width=\"page\">\n <Stack gap=\"large\">\n <Heading level={1} size=\"h5\">Launch plan</Heading>\n {/* A real app gives the list that holds the rows role=\"log\". */}\n <Stack gap=\"small\">\n <Message\n aria-label={request.from}\n avatar={<UserImage userHandle={request.from} decorative />}\n name={request.from}\n meta={<TimeStamp createdAt={request.at} dateFormat=\"absolute\" data=\"time\" />}\n >\n <Paragraph measure=\"none\">{request.text}</Paragraph>\n </Message>\n <Message\n aria-label={`${agentName}, agent`}\n avatar={<UserImage userHandle={agentName} icon={Bot} decorative />}\n name={agentName}\n meta={agentMeta(proposedAt)}\n >\n <Surface padding=\"small\">\n <Stack gap=\"medium\">\n {/* A real app announces the decided Tag in a polite live region. */}\n <Cluster gap=\"small\">\n <Heading level={2} size=\"subtitle1\">Changes ready</Heading>\n {status === 'approved' && <Tag variant=\"contained\" size=\"small\" color=\"success\" label=\"Approved\" />}\n {status === 'cancelled' && <Tag variant=\"contained\" size=\"small\" label=\"Cancelled\" />}\n </Cluster>\n <Paragraph measure=\"none\">These changes set the Pro price to $15 and add the Team plan to the pricing page. Three files change.</Paragraph>\n {(status === 'open' || status === 'requesting') && (\n <Cluster>\n <Button size=\"small\" type=\"secondary\" state=\"enabled\" label=\"View Changes\" onClickButton={() => setViewing(true)} />\n </Cluster>\n )}\n {status === 'requesting' && (\n <Textarea\n id=\"agent-plan-proposal-change-request\"\n label=\"What should change?\"\n value={draft}\n onChange={(e) => setDraft(e.target.value)}\n onSubmit={send}\n autoFocus\n disabled={pending === 'send'}\n />\n )}\n {status === 'redoing' && (\n <Paragraph measure=\"none\">Acme Agent is redoing the changes. It posts a new card when they are ready.</Paragraph>\n )}\n {/* The product sets the waiting time and counts it down. When it is up, the card is marked Cancelled. */}\n {(status === 'open' || status === 'requesting') && (\n <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">Waits 10 more minutes, then cancels.</Paragraph>\n )}\n {status === 'open' && (\n <Cluster gap=\"small\">\n <Button size=\"small\" type=\"tertiary\" state={pending === 'approve' ? 'disabled' : 'enabled'} label=\"Cancel\" loading={pending === 'cancel'} onClickButton={() => decide('cancel')} />\n <Button ref={requestButton} size=\"small\" type=\"secondary\" state={pending ? 'disabled' : 'enabled'} label=\"Request Changes\" onClickButton={startRequest} />\n {/* The product writes this label, never the agent. */}\n <Button size=\"small\" type=\"primary\" state={pending === 'cancel' ? 'disabled' : 'enabled'} label=\"Approve\" loading={pending === 'approve'} onClickButton={() => decide('approve')} />\n </Cluster>\n )}\n {status === 'requesting' && (\n <Cluster gap=\"small\">\n <Button size=\"small\" type=\"tertiary\" state={pending === 'send' ? 'disabled' : 'enabled'} label=\"Discard\" onClickButton={discard} />\n <Button size=\"small\" type=\"primary\" state={empty ? 'disabled' : 'enabled'} label=\"Send\" loading={pending === 'send'} onClickButton={send} />\n </Cluster>\n )}\n </Stack>\n </Surface>\n </Message>\n {status === 'cancelled' && (\n // One line in the thread on what was not done, under the card.\n <Message compact aria-label={`${agentName}, agent`}>\n <Paragraph measure=\"none\">Cancelled. Nothing was changed.</Paragraph>\n </Message>\n )}\n {run && (\n // The run's own progress row, as the case 'Agent at work' shows.\n <Message\n aria-label={`${agentName}, agent`}\n avatar={<UserImage userHandle={agentName} icon={Bot} decorative />}\n name={agentName}\n meta={agentMeta(startedAt)}\n footer={\n run === 'running' || run === 'stopping' ? (\n // The only Stop, on the row for the whole run. It shows loading while the run is stopping.\n // When it goes, a real app moves focus to the message box.\n <Cluster>\n <Button ref={stopButton} size=\"small\" type=\"secondary\" state=\"enabled\" label=\"Stop\" loading={run === 'stopping'} onClickButton={stop} />\n </Cluster>\n ) : undefined\n }\n >\n {run === 'done' ? (\n <Paragraph measure=\"none\">{reply}</Paragraph>\n ) : run === 'stopped' ? (\n <Paragraph measure=\"none\">{stoppedNote}</Paragraph>\n ) : (\n // A real app wraps this part in a polite live region, since StepList has none.\n <Stack gap=\"medium\">\n <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">{secondsLine(seconds)}</Paragraph>\n <StepList aria-label=\"Acme Agent's steps\" steps={stepsUpTo(current)} />\n </Stack>\n )}\n </Message>\n )}\n </Stack>\n </Stack>\n <Modal\n isOpen={viewing}\n title=\"Changed Files\"\n onClose={() => setViewing(false)}\n actions={<Button size=\"small\" type=\"tertiary\" state=\"enabled\" label=\"Close\" onClickButton={() => setViewing(false)} />}\n >\n <Paragraph measure=\"none\">Approve changes these files.</Paragraph>\n <List\n marker=\"dot\"\n size=\"body1\"\n items={changedFiles.map((f) => (\n <Stack key={f.path} gap=\"small\">\n <Paragraph mono measure=\"none\">{f.path}</Paragraph>\n <Paragraph size=\"body2\" tone=\"secondary\" measure=\"none\">{f.change}</Paragraph>\n </Stack>\n ))}\n />\n </Modal>\n </Center>\n );\n}\n",
876
+ "useWhen": "The agent has changes ready to apply, and one line for each file is enough.",
877
+ "source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport { Bot } from 'lucide-react';\nimport Message from 'oneslash-design-system/components/message';\nimport UserImage from 'oneslash-design-system/components/userImage';\nimport Tag from 'oneslash-design-system/components/tag';\nimport TimeStamp from 'oneslash-design-system/components/timeStamp';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Button from 'oneslash-design-system/components/button';\nimport Surface from 'oneslash-design-system/components/surface';\nimport Modal from 'oneslash-design-system/components/modal';\nimport List from 'oneslash-design-system/components/list';\nimport StepList, { type StepListStep } from 'oneslash-design-system/components/stepList';\nimport Textarea from 'oneslash-design-system/components/textarea';\nimport { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';\n\ntype Focusable = HTMLButtonElement | HTMLAnchorElement | null;\n\nconst agentName = 'Acme Agent';\n\nconst request = { from: 'Dana Lee', at: new Date('2025-01-15T11:40:00Z'), text: 'Can you update the pricing page for the new plans?' };\nconst proposedAt = new Date('2025-01-15T11:44:00Z');\n\n// The changes are a list of the files they touch, each with what changes in it. The case 'Review of an agent's changes' shows the lines with `Diff`.\nconst changedFiles = [\n { path: 'pages/pricing.tsx', change: 'Adds the Team plan to the page.' },\n { path: 'data/plans.json', change: 'Sets the Pro price to $15 and adds the Team plan at $25 per seat.' },\n { path: 'components/planTable.tsx', change: 'Adds a column for the Team plan.' },\n];\n\n// The run after 'Apply Changes': one step per file.\nconst runSteps = changedFiles.map((f) => `Change ${f.path}`);\n\nconst reply = 'The three files are changed. The pricing page shows the new plans.';\n\ntype Status = 'open' | 'requesting' | 'redoing' | 'approved' | 'cancelled';\ntype Run = 'running' | 'stopping' | 'stopped' | 'done';\n\n// Finished steps keep a check, the current one runs, and while it runs the steps the agent has not started are not shown.\n// Once the run is stopped, the whole list shows: the step it stopped on and the steps after it are cancelled.\nfunction stepsUpTo(current: number, stopped = false): StepListStep[] {\n return (stopped ? runSteps : runSteps.slice(0, current + 1)).map((label, i) => ({ label, status: i < current ? 'done' : stopped ? 'cancelled' : 'running' }));\n}\n\nfunction secondsLine(seconds: number) {\n return `Working for ${seconds} ${seconds === 1 ? 'second' : 'seconds'}`;\n}\n\n// The agent's marks, as the rule 'An agent says what it is' says.\nfunction agentMeta(at: Date) {\n return (\n <>\n <Tag variant=\"contained\" size=\"small\" label=\"Agent\" />\n <TimeStamp createdAt={at} dateFormat=\"absolute\" data=\"time\" />\n <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">Model name</Paragraph>\n </>\n );\n}\n\nexport default function AgentPlanProposalChanges() {\n const [status, setStatus] = useState<Status>('open');\n const [pending, setPending] = useState<'approve' | 'cancel' | 'send' | null>(null);\n const [viewing, setViewing] = useState(false);\n const [draft, setDraft] = useState('');\n // The run after 'Apply Changes', in its own progress row under the card.\n const [run, setRun] = useState<Run | null>(null);\n const [current, setCurrent] = useState(0);\n const [seconds, setSeconds] = useState(0);\n const [startedAt, setStartedAt] = useState(proposedAt);\n const timer = useRef<ReturnType<typeof setTimeout>>();\n const tick = useRef<ReturnType<typeof setInterval>>();\n const step = useRef<ReturnType<typeof setTimeout>>();\n const cancel = useRef<ReturnType<typeof setTimeout>>();\n const requestButton = useRef<Focusable>(null);\n const stopButton = useRef<Focusable>(null);\n // Where focus goes after the next render, once the element it goes to is on screen.\n const focusNext = useRef<() => void>();\n\n // On unmount it stops the requests, the run and its clock.\n useEffect(() => () => {\n clearTimeout(timer.current);\n clearInterval(tick.current);\n clearTimeout(step.current);\n clearTimeout(cancel.current);\n }, []);\n\n useEffect(() => {\n const move = focusNext.current;\n focusNext.current = undefined;\n move?.();\n });\n\n // Stands in for the agent's run: one step every 1.5 seconds.\n function advance(at: number) {\n step.current = setTimeout(() => {\n if (at === runSteps.length - 1) {\n clearInterval(tick.current);\n setRun('done');\n return;\n }\n setCurrent(at + 1);\n advance(at + 1);\n }, 1500);\n }\n\n // The card stays as the record, and the run shows in its own progress row below it.\n // 'Apply Changes' is gone and 'Stop' is the control that took its place, so focus goes to 'Stop'.\n function startRun() {\n setRun('running');\n setCurrent(0);\n setSeconds(0);\n setStartedAt(new Date());\n tick.current = setInterval(() => setSeconds((s) => s + 1), 1000);\n advance(0);\n focusNext.current = () => stopButton.current?.focus();\n }\n\n // Decided once: the buttons go away, so a second click cannot approve or cancel it again.\n // After 'Cancel' nothing takes their place: a real app moves focus to the message box.\n function decide(action: 'approve' | 'cancel') {\n if (pending || status !== 'open') return;\n setPending(action);\n // Stands in for the request to the server.\n timer.current = setTimeout(() => {\n setPending(null);\n if (action === 'cancel') {\n setStatus('cancelled');\n return;\n }\n setStatus('approved');\n startRun();\n }, 1200);\n }\n\n // Stop asks the server to end the run. The row says it stopped only once the run has ended.\n function stop() {\n if (run !== 'running') return;\n clearTimeout(step.current);\n setRun('stopping');\n // Stands in for the request to the server.\n cancel.current = setTimeout(() => {\n clearInterval(tick.current);\n setRun('stopped');\n }, 1200);\n }\n\n function startRequest() {\n if (pending) return;\n setDraft('');\n setStatus('requesting');\n }\n\n // 'Discard' leaves the sub-form and keeps the proposal open. 'Cancel' would cancel the whole proposal.\n function discard() {\n setStatus('open');\n focusNext.current = () => requestButton.current?.focus();\n }\n\n const empty = draft.trim() === '';\n\n // 'Send' gives the agent what should change. The card's buttons go, and the agent redoes the changes.\n // Nothing takes their place: a real app moves focus to the message box.\n function send() {\n if (pending || empty) return;\n setPending('send');\n // Stands in for the request to the server.\n timer.current = setTimeout(() => {\n setPending(null);\n setStatus('redoing');\n }, 1200);\n }\n\n // A real app takes the count from the server's answer. Here the file that was being changed when the run\n // stopped may be partly changed, so the note says so and does not claim it is untouched.\n const partFile = changedFiles[current].path;\n const stoppedNote = current === 0\n ? `Stopped before any file was done. ${partFile} may be partly changed. Check it.`\n : `Stopped after ${current} of ${runSteps.length} files. ${partFile} may be partly changed. Check it.`;\n\n return (\n <Center width=\"page\">\n <Stack gap=\"large\">\n <Heading level={1} size=\"h5\">Launch plan</Heading>\n {/* A real app gives the list that holds the rows role=\"log\". */}\n <Stack gap=\"small\">\n <Message\n aria-label={request.from}\n avatar={<UserImage userHandle={request.from} decorative />}\n name={request.from}\n meta={<TimeStamp createdAt={request.at} dateFormat=\"absolute\" data=\"time\" />}\n >\n <Paragraph measure=\"none\">{request.text}</Paragraph>\n </Message>\n <Message\n aria-label={`${agentName}, agent`}\n avatar={<UserImage userHandle={agentName} icon={Bot} decorative />}\n name={agentName}\n meta={agentMeta(proposedAt)}\n >\n <Surface padding=\"small\">\n <Stack gap=\"medium\">\n {/* A real app announces the decided Tag in a polite live region. */}\n <Cluster gap=\"small\">\n <Heading level={2} size=\"subtitle1\">Changes ready</Heading>\n {status === 'approved' && <Tag variant=\"contained\" size=\"small\" color=\"success\" label=\"Applied\" />}\n {status === 'cancelled' && <Tag variant=\"contained\" size=\"small\" label=\"Cancelled\" />}\n </Cluster>\n <Paragraph measure=\"none\">These changes set the Pro price to $15 and add the Team plan to the pricing page. Three files change.</Paragraph>\n {(status === 'open' || status === 'requesting') && (\n <Cluster>\n <Button size=\"small\" type=\"secondary\" state=\"enabled\" label=\"View Changes\" onClickButton={() => setViewing(true)} />\n </Cluster>\n )}\n {status === 'requesting' && (\n <Textarea\n id=\"agent-plan-proposal-change-request\"\n label=\"What should change?\"\n value={draft}\n onChange={(e) => setDraft(e.target.value)}\n onSubmit={send}\n autoFocus\n disabled={pending === 'send'}\n />\n )}\n {status === 'redoing' && (\n <Paragraph measure=\"none\">Acme Agent is redoing the changes. It posts a new card when they are ready.</Paragraph>\n )}\n {/* The product sets the waiting time and counts it down. When it is up, the card is marked Cancelled. */}\n {(status === 'open' || status === 'requesting') && (\n <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">Waits 10 more minutes, then cancels.</Paragraph>\n )}\n {status === 'open' && (\n <Cluster gap=\"small\">\n <Button size=\"small\" type=\"tertiary\" state={pending === 'approve' ? 'disabled' : 'enabled'} label=\"Cancel\" loading={pending === 'cancel'} onClickButton={() => decide('cancel')} />\n <Button ref={requestButton} size=\"small\" type=\"secondary\" state={pending ? 'disabled' : 'enabled'} label=\"Request Changes\" onClickButton={startRequest} />\n {/* The product writes this label, never the agent. */}\n <Button size=\"small\" type=\"primary\" state={pending === 'cancel' ? 'disabled' : 'enabled'} label=\"Apply Changes\" loading={pending === 'approve'} onClickButton={() => decide('approve')} />\n </Cluster>\n )}\n {status === 'requesting' && (\n <Cluster gap=\"small\">\n <Button size=\"small\" type=\"tertiary\" state={pending === 'send' ? 'disabled' : 'enabled'} label=\"Discard\" onClickButton={discard} />\n <Button size=\"small\" type=\"primary\" state={empty ? 'disabled' : 'enabled'} label=\"Send\" loading={pending === 'send'} onClickButton={send} />\n </Cluster>\n )}\n </Stack>\n </Surface>\n </Message>\n {status === 'cancelled' && (\n // One line in the thread on what was not done, under the card.\n <Message compact aria-label={`${agentName}, agent`}>\n <Paragraph measure=\"none\">Cancelled. Nothing was changed.</Paragraph>\n </Message>\n )}\n {run && (\n // The run's own progress row, as the case 'Agent at work' shows.\n <Message\n aria-label={`${agentName}, agent`}\n avatar={<UserImage userHandle={agentName} icon={Bot} decorative />}\n name={agentName}\n meta={agentMeta(startedAt)}\n footer={\n run === 'running' || run === 'stopping' ? (\n // The only Stop, on the row for the whole run. It shows loading while the run is stopping.\n // When it goes, a real app moves focus to the message box.\n <Cluster>\n <Button ref={stopButton} size=\"small\" type=\"secondary\" state=\"enabled\" label=\"Stop\" loading={run === 'stopping'} onClickButton={stop} />\n </Cluster>\n ) : undefined\n }\n >\n {run === 'done' ? (\n <Paragraph measure=\"none\">{reply}</Paragraph>\n ) : run === 'stopped' ? (\n // The steps stay, as the rule 'An agent that stops short says what it finished and what is left' says.\n <Stack gap=\"medium\">\n <StepList aria-label=\"Acme Agent's steps\" steps={stepsUpTo(current, true)} />\n <Paragraph measure=\"none\">{stoppedNote}</Paragraph>\n </Stack>\n ) : (\n // A real app wraps this part in a polite live region, since StepList has none.\n <Stack gap=\"medium\">\n <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">{secondsLine(seconds)}</Paragraph>\n <StepList aria-label=\"Acme Agent's steps\" steps={stepsUpTo(current)} />\n </Stack>\n )}\n </Message>\n )}\n </Stack>\n </Stack>\n <Modal\n isOpen={viewing}\n title=\"Changed Files\"\n onClose={() => setViewing(false)}\n actions={<Button size=\"small\" type=\"tertiary\" state=\"enabled\" label=\"Close\" onClickButton={() => setViewing(false)} />}\n >\n <Paragraph measure=\"none\">These files change when you apply the changes.</Paragraph>\n <List\n marker=\"dot\"\n size=\"body1\"\n items={changedFiles.map((f) => (\n <Stack key={f.path} gap=\"small\">\n <Paragraph mono measure=\"none\">{f.path}</Paragraph>\n <Paragraph size=\"body2\" tone=\"secondary\" measure=\"none\">{f.change}</Paragraph>\n </Stack>\n ))}\n />\n </Modal>\n </Center>\n );\n}\n",
555
878
  "uses": [
556
879
  "Button",
557
880
  "Center",
@@ -578,6 +901,9 @@
578
901
  "kind": "design",
579
902
  "level": "organism",
580
903
  "area": "agent",
904
+ "surface": [
905
+ "agent"
906
+ ],
581
907
  "situation": "The agent needs an answer from the person before it can go on. It needs a fact or a decision only the person has. For ways forward in its own work, see the case 'Agent options'.",
582
908
  "do": [
583
909
  "Put the card in the agent's `Message`, in a `Surface` with the question as its heading.",
@@ -656,6 +982,9 @@
656
982
  "kind": "rule",
657
983
  "level": "rule",
658
984
  "area": "agent",
985
+ "surface": [
986
+ "agent"
987
+ ],
659
988
  "situation": "The product will not let the agent answer a request, for example because the workspace used all its agent replies for the month, reached its spending cap, or sent too many requests at once.",
660
989
  "answer": "The refusal says in one plain sentence which limit was reached, and either who can change it or when to try again. A person who can lift the limit gets the one button that does it, such as Upgrade or Change Budget Cap. When an admin can lift the limit, everyone else is told to ask a workspace admin. A limit that passes with time says when to try again instead.",
661
990
  "why": "A person who is refused needs to know why and what to do next, or they will just send the request again.",
@@ -671,12 +1000,92 @@
671
1000
  ],
672
1001
  "native": "On Apple the refusal is a row above the composer, with an Upgrade or Change Budget Cap button for admins and never a link to a web page."
673
1002
  },
1003
+ {
1004
+ "id": "agent-run-failure",
1005
+ "title": "Run that stopped short",
1006
+ "kind": "design",
1007
+ "level": "organism",
1008
+ "area": "agent",
1009
+ "surface": [
1010
+ "agent"
1011
+ ],
1012
+ "situation": "The agent's run stopped before the end: one step failed, or the run reached a limit of steps, time or budget with work left.",
1013
+ "do": [
1014
+ "Follow the rule 'An agent that stops short says what it finished and what is left'.",
1015
+ "Use this case when a run has steps that can be tried again. The case 'Agent at work' points here for a run that fails or stops at a limit.",
1016
+ "Keep the run's progress row from the case 'Agent at work', with its `StepList` still on screen when the run stops.",
1017
+ "Mark each step done, failed or cancelled, and the steps not started as waiting. `StepList` draws a mark and a word for each, so color is never the only sign.",
1018
+ "Say why in the `detail` of the step that stopped: 'Could not save planTable.tsx. Another change was saving it at the same time.'",
1019
+ "Say under the list what is done and whether anything changed: '2 of 4 steps are done. No files were changed after step 2.' Take it from the server's answer.",
1020
+ "Give that line `role=\"status\"`, so a screen reader hears it once when the run stops.",
1021
+ "Move focus to the row's first Button when the run stops, since 'Stop' had focus and is gone.",
1022
+ "Offer 'Stop Here' and then 'Try Step Again' as the primary Button when one step failed and can run again.",
1023
+ "Run only the failed step and the ones after it on 'Try Step Again'. The steps that are done stay done.",
1024
+ "Offer 'Stop Here' and then 'Continue' as the primary Button when the person can lift the limit. Say what 'Continue' does: 'Continue lets this run go past the budget cap.'",
1025
+ "Offer 'Upgrade to Pro' in place of 'Continue' when the limit is the plan's, as the case 'Upgrade prompt' says, to a person who can upgrade.",
1026
+ "Say who can lift the limit when the person cannot, in the words of the case 'Composer at a limit': 'Ask a workspace admin to raise the budget cap.'",
1027
+ "Show how long the run waits for an answer: 'Waits 10 more minutes, then stops here.' Then mark the steps left cancelled and say so in the thread.",
1028
+ "Mark the steps that will not run cancelled after 'Stop Here', and say what was left undone.",
1029
+ "Move focus to 'Stop' when the run goes on, and to the message box when the row's Buttons go away."
1030
+ ],
1031
+ "dont": [
1032
+ "Do not start again from step one when a person asks to retry.",
1033
+ "Do not end with only 'Something went wrong', or report the stop only in a toast away from the row.",
1034
+ "Do not open an upgrade Modal in the thread when a run reaches a limit.",
1035
+ "Do not hide the steps that are done.",
1036
+ "Do not show 'Continue' to someone who cannot lift the limit."
1037
+ ],
1038
+ "options": [
1039
+ {
1040
+ "id": "step-failed",
1041
+ "title": "A step failed",
1042
+ "useWhen": "One step failed and can be tried again.",
1043
+ "source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport { Bot } from 'lucide-react';\nimport Message from 'oneslash-design-system/components/message';\nimport UserImage from 'oneslash-design-system/components/userImage';\nimport Tag from 'oneslash-design-system/components/tag';\nimport TimeStamp from 'oneslash-design-system/components/timeStamp';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Button from 'oneslash-design-system/components/button';\nimport StepList, { type StepListStep } from 'oneslash-design-system/components/stepList';\nimport { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';\n\ntype Focusable = HTMLButtonElement | HTMLAnchorElement | null;\n\nconst agentName = 'Acme Agent';\n\nconst request = { from: 'Dana Lee', at: new Date('2026-11-16T14:30:00Z'), text: 'Can you add the Business plan to the pricing page and open a pull request?' };\nconst runStartedAt = new Date('2026-11-16T14:31:00Z');\n\nconst plan = [\n 'Read the pricing page',\n 'Add the Business plan to plans.json',\n 'Update the plan table',\n 'Open a pull request',\n];\n\n// The step that fails the first time, and why. A real app takes both from the server's answer.\nconst failingStep = 2;\nconst failReason = 'Could not save planTable.tsx. Another change was saving it at the same time.';\n\nconst reply = 'The Business plan is on the pricing page, and the pull request is open for review.';\n\ntype Phase = 'running' | 'stopping' | 'failed' | 'stopped' | 'done';\n\nfunction secondsLine(seconds: number) {\n return `Working for ${seconds} ${seconds === 1 ? 'second' : 'seconds'}`;\n}\n\n// The agent's marks, as the rule 'An agent says what it is' says.\nfunction agentMeta(at: Date) {\n return (\n <>\n <Tag variant=\"contained\" size=\"small\" label=\"Agent\" />\n <TimeStamp createdAt={at} dateFormat=\"absolute\" data=\"time\" />\n <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">Model name</Paragraph>\n </>\n );\n}\n\n// `live` is for tests only: the run starts at step 1 and fails at step 3, so focus can be seen to move when it stops.\nexport default function AgentRunFailureStepFailed({ live = false }: { live?: boolean } = {}) {\n // Opens on a still of the failed run, so the picture in the docs does not move.\n const [phase, setPhase] = useState<Phase>(live ? 'running' : 'failed');\n const [current, setCurrent] = useState(live ? 0 : failingStep);\n const [seconds, setSeconds] = useState(0);\n const [startedAt, setStartedAt] = useState(runStartedAt);\n const tick = useRef<ReturnType<typeof setInterval>>();\n const step = useRef<ReturnType<typeof setTimeout>>();\n const cancel = useRef<ReturnType<typeof setTimeout>>();\n const firstButton = useRef<Focusable>(null);\n const stopButton = useRef<Focusable>(null);\n // Where focus goes after the next render, once the element it goes to is on screen.\n const focusNext = useRef<() => void>();\n // The failing step fails once. 'Try Step Again' then works.\n const failed = useRef(!live);\n // Whether the run ended on the failed step ('Stop Here') or was stopped while a step ran ('Stop').\n const [endedOnFailure, setEndedOnFailure] = useState(false);\n\n // On unmount it stops the run, its clock and the stop request.\n useEffect(() => () => {\n clearInterval(tick.current);\n clearTimeout(step.current);\n clearTimeout(cancel.current);\n }, []);\n\n useEffect(() => {\n const move = focusNext.current;\n focusNext.current = undefined;\n move?.();\n });\n\n function stopTimers() {\n clearInterval(tick.current);\n clearTimeout(step.current);\n }\n\n // Stands in for the agent's run: one step every 1.5 seconds.\n function advance(at: number) {\n step.current = setTimeout(() => {\n if (at === failingStep && !failed.current) {\n failed.current = true;\n stopTimers();\n setPhase('failed');\n // 'Stop' had focus and is gone, so focus goes to the row's first Button.\n focusNext.current = () => firstButton.current?.focus();\n return;\n }\n if (at === plan.length - 1) {\n stopTimers();\n setPhase('done');\n return;\n }\n setCurrent(at + 1);\n advance(at + 1);\n }, 1500);\n }\n\n // Runs from `from` on. The steps before it are done and stay done.\n function runFrom(from: number) {\n stopTimers();\n setPhase('running');\n setCurrent(from);\n setSeconds(0);\n setStartedAt(new Date());\n tick.current = setInterval(() => setSeconds((s) => s + 1), 1000);\n advance(from);\n }\n\n useEffect(() => {\n // Runs once, on mount.\n if (live) runFrom(0);\n }, []);\n\n // Only the failed step and the ones after it run again. 'Stop' takes the place of the Buttons, so it gets focus.\n function tryStepAgain() {\n if (phase !== 'failed') return;\n runFrom(current);\n focusNext.current = () => stopButton.current?.focus();\n }\n\n // The run ends where it is. The Buttons go and nothing takes their place: a real app moves focus to the message box.\n function stopHere() {\n if (phase !== 'failed') return;\n setEndedOnFailure(true);\n setPhase('stopped');\n }\n\n // Stop asks the server to end the run. The row says it stopped only once the run has ended.\n function stop() {\n if (phase !== 'running') return;\n clearTimeout(step.current);\n setPhase('stopping');\n // Stands in for the request to the server.\n cancel.current = setTimeout(() => {\n clearInterval(tick.current);\n setPhase('stopped');\n }, 1200);\n }\n\n // Done steps keep a check, the step that stopped says why, and the steps after it wait, or are cancelled once the run is over.\n const steps: StepListStep[] = plan.map((label, i) => {\n if (i < current) return { label, status: 'done' };\n if (i === current) {\n if (phase === 'failed') return { label, status: 'failed', detail: failReason };\n if (phase === 'stopped') return { label, status: endedOnFailure ? 'failed' : 'cancelled' };\n return { label, status: 'running' };\n }\n return { label, status: phase === 'stopped' ? 'cancelled' : 'waiting' };\n });\n\n // A real app takes the count, and what changed, from the server's answer.\n const doneLine = `${current} of ${plan.length} steps are done.`;\n const changedLine = current === 0 ? 'Nothing was changed.' : `No files were changed after step ${current}.`;\n const leftLine = current === plan.length - 1 ? `Step ${plan.length} was not done.` : `Steps ${current + 1} to ${plan.length} were not done.`;\n const statusLine =\n phase === 'failed'\n ? `${doneLine} ${changedLine}`\n : phase === 'stopped'\n ? `Stopped at step ${current + 1}. ${doneLine} ${changedLine} ${leftLine}`\n : doneLine;\n\n const working = phase === 'running' || phase === 'stopping';\n\n return (\n <Center width=\"page\">\n <Stack gap=\"large\">\n <Heading level={1} size=\"h5\">Launch plan</Heading>\n {/* A real app gives the list that holds the rows role=\"log\". */}\n <Stack gap=\"small\">\n <Message\n aria-label={request.from}\n avatar={<UserImage userHandle={request.from} decorative />}\n name={request.from}\n meta={<TimeStamp createdAt={request.at} dateFormat=\"absolute\" data=\"time\" />}\n >\n <Paragraph measure=\"none\">{request.text}</Paragraph>\n </Message>\n <Message\n aria-label={`${agentName}, agent`}\n avatar={<UserImage userHandle={agentName} icon={Bot} decorative />}\n name={agentName}\n meta={agentMeta(startedAt)}\n footer={\n working ? (\n // The only Stop, on the row for the whole run. It shows loading while the run is stopping.\n <Cluster>\n <Button ref={stopButton} size=\"small\" type=\"secondary\" state=\"enabled\" label=\"Stop\" loading={phase === 'stopping'} onClickButton={stop} />\n </Cluster>\n ) : phase === 'failed' ? (\n <Stack gap=\"small\">\n {/* The product sets the waiting time and counts it down. When it is up, the steps left are cancelled. */}\n <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">Waits 10 more minutes, then stops here.</Paragraph>\n <Cluster gap=\"small\">\n <Button ref={firstButton} size=\"small\" type=\"tertiary\" state=\"enabled\" label=\"Stop Here\" onClickButton={stopHere} />\n <Button size=\"small\" type=\"primary\" state=\"enabled\" label=\"Try Step Again\" onClickButton={tryStepAgain} />\n </Cluster>\n </Stack>\n ) : undefined\n }\n >\n {phase === 'done' ? (\n // The run is over: the row is the reply, and Stop is gone. A real app moves focus to the message box.\n <Paragraph measure=\"none\">{reply}</Paragraph>\n ) : (\n <Stack gap=\"medium\">\n {working && <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">{secondsLine(seconds)}</Paragraph>}\n <StepList aria-label=\"Acme Agent's steps\" steps={steps} />\n {/* A polite live region, on the page before its text changes, so the stop is heard once. */}\n <Paragraph role=\"status\" measure=\"none\">{statusLine}</Paragraph>\n </Stack>\n )}\n </Message>\n </Stack>\n </Stack>\n </Center>\n );\n}\n",
1044
+ "uses": [
1045
+ "Button",
1046
+ "Center",
1047
+ "Cluster",
1048
+ "Heading",
1049
+ "Message",
1050
+ "Paragraph",
1051
+ "Stack",
1052
+ "StepList",
1053
+ "Tag",
1054
+ "TimeStamp",
1055
+ "UserImage"
1056
+ ]
1057
+ },
1058
+ {
1059
+ "id": "limit-reached",
1060
+ "title": "A limit was reached",
1061
+ "useWhen": "The run stopped at a limit of steps, time or budget with work left.",
1062
+ "source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport { Bot } from 'lucide-react';\nimport Message from 'oneslash-design-system/components/message';\nimport UserImage from 'oneslash-design-system/components/userImage';\nimport Tag from 'oneslash-design-system/components/tag';\nimport TimeStamp from 'oneslash-design-system/components/timeStamp';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Button from 'oneslash-design-system/components/button';\nimport Alert from 'oneslash-design-system/components/alert';\nimport StepList, { type StepListStep } from 'oneslash-design-system/components/stepList';\nimport { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';\n\ntype Focusable = HTMLButtonElement | HTMLAnchorElement | null;\n\n// A real app reads this from the person's role. Only an admin can let a run go past the budget cap.\nconst canLift = true;\n\nconst agentName = 'Acme Agent';\n\nconst request = { from: 'Dana Lee', at: new Date('2026-11-16T14:30:00Z'), text: 'Can you add French and German versions of the pricing page and open a pull request?' };\nconst runStartedAt = new Date('2026-11-16T14:31:00Z');\n\nconst plan = [\n 'Read the pricing page',\n 'Add the French page',\n 'Add the German page',\n 'Open a pull request',\n];\n\n// Where the run stopped, and why. A real app takes both from the server's answer.\nconst limitStep = 2;\nconst limitReason = \"Stopped here. The workspace reached its $200.00 budget cap for November.\";\n\nconst reply = 'The French and German pages are ready, and the pull request is open for review.';\n\ntype Phase = 'limit' | 'running' | 'stopping' | 'stopped' | 'done';\n\nfunction secondsLine(seconds: number) {\n return `Working for ${seconds} ${seconds === 1 ? 'second' : 'seconds'}`;\n}\n\n// The agent's marks, as the rule 'An agent says what it is' says.\nfunction agentMeta(at: Date) {\n return (\n <>\n <Tag variant=\"contained\" size=\"small\" label=\"Agent\" />\n <TimeStamp createdAt={at} dateFormat=\"absolute\" data=\"time\" />\n <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">Model name</Paragraph>\n </>\n );\n}\n\nexport default function AgentRunFailureLimitReached() {\n // Opens on a still of the run stopped at the budget cap, so the picture in the docs does not move.\n const [phase, setPhase] = useState<Phase>('limit');\n const [current, setCurrent] = useState(limitStep);\n const [seconds, setSeconds] = useState(0);\n const [startedAt, setStartedAt] = useState(runStartedAt);\n // Whether the run ended at the limit ('Stop Here') or was stopped while a step ran ('Stop').\n const [endedAtLimit, setEndedAtLimit] = useState(false);\n const tick = useRef<ReturnType<typeof setInterval>>();\n const step = useRef<ReturnType<typeof setTimeout>>();\n const cancel = useRef<ReturnType<typeof setTimeout>>();\n const stopButton = useRef<Focusable>(null);\n // Where focus goes after the next render, once the element it goes to is on screen.\n const focusNext = useRef<() => void>();\n\n // On unmount it stops the run, its clock and the stop request.\n useEffect(() => () => {\n clearInterval(tick.current);\n clearTimeout(step.current);\n clearTimeout(cancel.current);\n }, []);\n\n useEffect(() => {\n const move = focusNext.current;\n focusNext.current = undefined;\n move?.();\n });\n\n function stopTimers() {\n clearInterval(tick.current);\n clearTimeout(step.current);\n }\n\n // Stands in for the agent's run: one step every 1.5 seconds.\n function advance(at: number) {\n step.current = setTimeout(() => {\n if (at === plan.length - 1) {\n stopTimers();\n setPhase('done');\n return;\n }\n setCurrent(at + 1);\n advance(at + 1);\n }, 1500);\n }\n\n // The run goes on from the step that stopped. The steps that are done stay done.\n // 'Stop' takes the place of the Buttons, so it gets focus.\n function continueRun() {\n if (phase !== 'limit' || !canLift) return;\n setPhase('running');\n setSeconds(0);\n setStartedAt(new Date());\n tick.current = setInterval(() => setSeconds((s) => s + 1), 1000);\n advance(current);\n focusNext.current = () => stopButton.current?.focus();\n }\n\n // The run ends where it is. The Buttons go and nothing takes their place: a real app moves focus to the message box.\n function stopHere() {\n if (phase !== 'limit') return;\n setEndedAtLimit(true);\n setPhase('stopped');\n }\n\n // Stop asks the server to end the run. The row says it stopped only once the run has ended.\n function stop() {\n if (phase !== 'running') return;\n clearTimeout(step.current);\n setPhase('stopping');\n // Stands in for the request to the server.\n cancel.current = setTimeout(() => {\n clearInterval(tick.current);\n setPhase('stopped');\n }, 1200);\n }\n\n // Done steps keep a check, the step that stopped says why, and the steps after it wait, or are cancelled once the run is over.\n const steps: StepListStep[] = plan.map((label, i) => {\n if (i < current) return { label, status: 'done' };\n if (i === current) {\n if (phase === 'limit' || (phase === 'stopped' && endedAtLimit)) return { label, status: 'cancelled', detail: limitReason };\n if (phase === 'stopped') return { label, status: 'cancelled' };\n return { label, status: 'running' };\n }\n return { label, status: phase === 'stopped' ? 'cancelled' : 'waiting' };\n });\n\n // A real app takes the count, and what changed, from the server's answer.\n const doneLine = `${current} of ${plan.length} steps are done.`;\n const changedLine = current === limitStep ? 'Only the French page was added.' : `Nothing was changed after step ${current}.`;\n const leftLine = current === plan.length - 1 ? `Step ${plan.length} was not done.` : `Steps ${current + 1} to ${plan.length} were not done.`;\n const statusLine =\n phase === 'limit'\n ? `${doneLine} ${changedLine}`\n : phase === 'stopped'\n ? `Stopped at step ${current + 1}. ${doneLine} ${changedLine} ${leftLine}`\n : doneLine;\n\n const working = phase === 'running' || phase === 'stopping';\n\n return (\n <Center width=\"page\">\n <Stack gap=\"large\">\n <Heading level={1} size=\"h5\">Launch plan</Heading>\n {/* A real app gives the list that holds the rows role=\"log\". */}\n <Stack gap=\"small\">\n <Message\n aria-label={request.from}\n avatar={<UserImage userHandle={request.from} decorative />}\n name={request.from}\n meta={<TimeStamp createdAt={request.at} dateFormat=\"absolute\" data=\"time\" />}\n >\n <Paragraph measure=\"none\">{request.text}</Paragraph>\n </Message>\n <Message\n aria-label={`${agentName}, agent`}\n avatar={<UserImage userHandle={agentName} icon={Bot} decorative />}\n name={agentName}\n meta={agentMeta(startedAt)}\n footer={\n working ? (\n // The only Stop, on the row for the whole run. It shows loading while the run is stopping.\n <Cluster>\n <Button ref={stopButton} size=\"small\" type=\"secondary\" state=\"enabled\" label=\"Stop\" loading={phase === 'stopping'} onClickButton={stop} />\n </Cluster>\n ) : phase === 'limit' ? (\n // In the row, never an upgrade Modal over the thread.\n <Stack gap=\"small\">\n {/* The product sets the waiting time and counts it down. When it is up, the steps left are cancelled. */}\n <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">Waits 10 more minutes, then stops here.</Paragraph>\n {canLift ? (\n <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">Continue lets this run go past the budget cap. The cap stays $200.00 for everything else.</Paragraph>\n ) : (\n // This person cannot lift the limit, so it says who can, in the words of the case 'Composer at a limit'.\n <Alert\n type=\"warning\"\n variant=\"inline\"\n autoDismiss={false}\n message=\"You've used all of this month's $200.00 budget cap.\"\n secondMessage=\"It starts again on Dec 1. Ask a workspace admin to raise the budget cap so Acme Agent can finish.\"\n />\n )}\n <Cluster gap=\"small\">\n <Button size=\"small\" type=\"tertiary\" state=\"enabled\" label=\"Stop Here\" onClickButton={stopHere} />\n {canLift && <Button size=\"small\" type=\"primary\" state=\"enabled\" label=\"Continue\" onClickButton={continueRun} />}\n </Cluster>\n </Stack>\n ) : undefined\n }\n >\n {phase === 'done' ? (\n // The run is over: the row is the reply, and Stop is gone. A real app moves focus to the message box.\n <Paragraph measure=\"none\">{reply}</Paragraph>\n ) : (\n <Stack gap=\"medium\">\n {working && <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">{secondsLine(seconds)}</Paragraph>}\n <StepList aria-label=\"Acme Agent's steps\" steps={steps} />\n {/* A polite live region, on the page before its text changes, so the stop is heard once. */}\n <Paragraph role=\"status\" measure=\"none\">{statusLine}</Paragraph>\n </Stack>\n )}\n </Message>\n </Stack>\n </Stack>\n </Center>\n );\n}\n",
1063
+ "uses": [
1064
+ "Alert",
1065
+ "Button",
1066
+ "Center",
1067
+ "Cluster",
1068
+ "Heading",
1069
+ "Message",
1070
+ "Paragraph",
1071
+ "Stack",
1072
+ "StepList",
1073
+ "Tag",
1074
+ "TimeStamp",
1075
+ "UserImage"
1076
+ ]
1077
+ }
1078
+ ]
1079
+ },
674
1080
  {
675
1081
  "id": "agent-says-what-it-is",
676
1082
  "title": "An agent says what it is",
677
1083
  "kind": "rule",
678
1084
  "level": "rule",
679
1085
  "area": "agent",
1086
+ "surface": [
1087
+ "agent"
1088
+ ],
680
1089
  "situation": "The agent posts in a thread where people also write, or replies to a person.",
681
1090
  "answer": "Every agent message has marks no person's message has. It shows an icon avatar instead of a photo, and the agent's own name. When the product knows which model wrote the reply, it shows the model name in small text next to the time. An agent the workspace connects from outside gets a plain bot icon, not the product's logo.",
682
1091
  "why": "People must see at a glance whether a person or an agent wrote what they are reading, and whose agent it is.",
@@ -692,12 +1101,41 @@
692
1101
  ],
693
1102
  "native": "On Apple an 'Agent' label with a sparkles icon sits next to a named agent's name, and the app draws the agent's avatar itself."
694
1103
  },
1104
+ {
1105
+ "id": "agent-says-where-it-stopped",
1106
+ "title": "An agent that stops short says what it finished and what is left",
1107
+ "kind": "rule",
1108
+ "level": "rule",
1109
+ "area": "agent",
1110
+ "surface": [
1111
+ "agent"
1112
+ ],
1113
+ "situation": "An agent is partway through a run of several steps when the run fails, is stopped, or hits a limit.",
1114
+ "answer": "The agent says which steps are done, which one stopped and why, and which were not started. It offers the next move: try the step again, continue, or leave it. Work that was done stays done, and the agent says so. It also says whether anything was changed.",
1115
+ "why": "A person who reads only 'Something went wrong' cannot tell what changed, so they redo work or undo work that was fine. Starting again from step one repeats changes that were already made.",
1116
+ "do": [
1117
+ "Keep the step list on screen, with each step marked done, failed or cancelled, or not started.",
1118
+ "Say the reason in plain words: 'Stopped at step 3. The workspace reached its budget cap.'",
1119
+ "Say whether anything was changed, and what.",
1120
+ "Offer the next move: try the stopped step again, continue, or leave it.",
1121
+ "Retry from the step that stopped, and keep the steps that are done."
1122
+ ],
1123
+ "dont": [
1124
+ "Do not end with only 'Something went wrong'.",
1125
+ "Do not start again from step one when a person asks to retry.",
1126
+ "Do not hide finished steps."
1127
+ ]
1128
+ },
695
1129
  {
696
1130
  "id": "agent-settings",
697
1131
  "title": "Agent settings",
698
1132
  "kind": "design",
699
1133
  "level": "organism",
700
1134
  "area": "settings",
1135
+ "surface": [
1136
+ "app",
1137
+ "agent"
1138
+ ],
701
1139
  "situation": "An admin sets which model the agent uses, how it picks one, what it should know about the team and how much it may spend.",
702
1140
  "do": [
703
1141
  "Follow the rule 'A setting saves in place, or with one Save Button'. Keep the choices and the two groups of fields in their own `SettingsSection`s.",
@@ -748,6 +1186,9 @@
748
1186
  "kind": "rule",
749
1187
  "level": "rule",
750
1188
  "area": "agent",
1189
+ "surface": [
1190
+ "agent"
1191
+ ],
751
1192
  "situation": "The agent is working on a request and its reply is not ready yet.",
752
1193
  "answer": "While it works, the agent shows a live row in the thread, where its reply will appear: its name, the model, the seconds so far, the steps it has finished with a check mark, and the step it is on now in plain words, such as 'Reading file'. A Stop button stays on that row for the whole run. When the run is stopped, the agent posts a short note that it stopped.",
753
1194
  "why": "A person waiting on an agent needs to know it is still working, what it is doing, and that they can stop it.",
@@ -770,6 +1211,9 @@
770
1211
  "kind": "rule",
771
1212
  "level": "rule",
772
1213
  "area": "agent",
1214
+ "surface": [
1215
+ "agent"
1216
+ ],
773
1217
  "situation": "The agent answers from things it read: documents, files, chat, tasks, or a connected service such as a code host or a design tool.",
774
1218
  "answer": "Under the reply, the agent lists what it used. A small tag names the kinds of source, such as 'From Chat · Knowledge base', and one card per source shows its title, its kind and where it lives. Each card opens the source. A reply that used no sources shows no sources section. When the reply read only the messages already on screen above it, the Tag alone is enough.",
775
1219
  "why": "A person can check an answer only when they can open what it came from.",
@@ -791,6 +1235,9 @@
791
1235
  "kind": "design",
792
1236
  "level": "organism",
793
1237
  "area": "settings",
1238
+ "surface": [
1239
+ "app"
1240
+ ],
794
1241
  "situation": "A person makes keys that let a script or a service use the product as them, and revokes keys they no longer use.",
795
1242
  "do": [
796
1243
  "List each key with its name, the start of the key in the mono face, when it was created and when it was last used. Say 'Never used' when it was not.",
@@ -850,6 +1297,9 @@
850
1297
  "kind": "design",
851
1298
  "level": "page",
852
1299
  "area": "shell",
1300
+ "surface": [
1301
+ "app"
1302
+ ],
853
1303
  "situation": "A person opens the product and moves between its places, such as Inbox, Tasks and Settings, from every page.",
854
1304
  "do": [
855
1305
  "Follow the rule 'On a phone, a sidebar opens as a drawer and a list opens its detail'.",
@@ -931,6 +1381,9 @@
931
1381
  "kind": "design",
932
1382
  "level": "organism",
933
1383
  "area": "agent",
1384
+ "surface": [
1385
+ "agent"
1386
+ ],
934
1387
  "situation": "The agent made a document for the person, such as a plan or a report.",
935
1388
  "do": [
936
1389
  "Keep the reply to one sentence on what the agent made. Then put the card in the reply's `footer`.",
@@ -978,6 +1431,10 @@
978
1431
  "kind": "design",
979
1432
  "level": "organism",
980
1433
  "area": "agent",
1434
+ "surface": [
1435
+ "app",
1436
+ "agent"
1437
+ ],
981
1438
  "situation": "A page where a person asks the agent about their work across one or more workspaces, and reads the answers with their sources.",
982
1439
  "do": [
983
1440
  "Follow the cases 'Conversation starters', 'Scope picker', 'Reply sources' and 'Message composer'.",
@@ -1066,6 +1523,9 @@
1066
1523
  "kind": "design",
1067
1524
  "level": "page",
1068
1525
  "area": "auth",
1526
+ "surface": [
1527
+ "app"
1528
+ ],
1069
1529
  "situation": "The app is checking whether the person is logged in, or running a step such as checking an invite, before it knows what to show.",
1070
1530
  "do": [
1071
1531
  "Show the spinner from the first render, before anything else, as `LoadingScreen` in `Center` with `fill`.",
@@ -1110,6 +1570,9 @@
1110
1570
  "kind": "design",
1111
1571
  "level": "page",
1112
1572
  "area": "dashboard",
1573
+ "surface": [
1574
+ "app"
1575
+ ],
1113
1576
  "situation": "A workspace pays for a plan. One page says what it pays for, what it has used, how it pays and what it has paid.",
1114
1577
  "do": [
1115
1578
  "Follow the rule 'A number shows its unit and never shows 0 for unknown'.",
@@ -1215,6 +1678,9 @@
1215
1678
  "kind": "design",
1216
1679
  "level": "page",
1217
1680
  "area": "content",
1681
+ "surface": [
1682
+ "site"
1683
+ ],
1218
1684
  "situation": "A visitor opens the blog to see what was written lately and to pick a post to read.",
1219
1685
  "do": [
1220
1686
  "Use `PageHeader` with `level={1}`: the title 'Blog' is the one level 1 heading, with a `lede` of one sentence about what the blog is for.",
@@ -1272,6 +1738,10 @@
1272
1738
  "kind": "design",
1273
1739
  "level": "organism",
1274
1740
  "area": "content",
1741
+ "surface": [
1742
+ "site",
1743
+ "app"
1744
+ ],
1275
1745
  "situation": "A page on a site sits under other pages, and the person needs to see where it is and go back up.",
1276
1746
  "do": [
1277
1747
  "Put `Breadcrumb` above the `PageHeader`, from the top level down to this page.",
@@ -1327,6 +1797,9 @@
1327
1797
  "kind": "design",
1328
1798
  "level": "organism",
1329
1799
  "area": "dashboard",
1800
+ "surface": [
1801
+ "app"
1802
+ ],
1330
1803
  "situation": "A page shows how a total splits into parts, such as responses by model or comments by project.",
1331
1804
  "do": [
1332
1805
  "Follow the rule 'A number shows its unit and never shows 0 for unknown'.",
@@ -1384,12 +1857,118 @@
1384
1857
  }
1385
1858
  ]
1386
1859
  },
1860
+ {
1861
+ "id": "bulk-actions",
1862
+ "title": "Bulk actions",
1863
+ "kind": "design",
1864
+ "level": "organism",
1865
+ "area": "dashboard",
1866
+ "surface": [
1867
+ "app"
1868
+ ],
1869
+ "situation": "A person picks several rows of a list or a table and does one thing to all of them at once.",
1870
+ "do": [
1871
+ "Give each row a `Checkbox` named for its row: 'Select Write the launch email'.",
1872
+ "Put a header `Checkbox` above the rows, named for what it picks: 'Select all tasks'. Set `indeterminate` when some rows are picked, and `checked` when all are.",
1873
+ "Pick every row with the header Checkbox when some are picked, and none when all are.",
1874
+ "Replace the toolbar with a bar while any row is picked. It says the count, '3 selected', then up to two Buttons, a More menu and a tertiary 'Clear Selection'.",
1875
+ "Give the count `role=\"status\"` and keep it on the page, so a screen reader hears each new count once.",
1876
+ "Name the More menu for the rows it acts on: 'More actions for 3 tasks'. Follow the case 'More menu'.",
1877
+ "Follow the case 'Data table page' for a table over many pages. The header Checkbox picks the rows of the page shown.",
1878
+ "Offer 'Select All 240' as a tertiary Button in the bar of a paged table, until every row is picked. Focus then goes to 'Clear Selection'.",
1879
+ "Keep the picked rows when the person changes page, sorts or comes back.",
1880
+ "Confirm a delete in a small Modal, as the case 'Delete confirm' does, titled with the count: 'Delete 3 Invoices'.",
1881
+ "Move focus to the header Checkbox after 'Clear Selection' and after a delete, because the bar and its Buttons are gone.",
1882
+ "Stay on the same page after a delete if it still has rows, or go to the last page that does.",
1883
+ "Show the case 'Empty list' in the table's place when a delete leaves no rows. Focus goes to its Button.",
1884
+ "Say what happened in a toast that counts: '3 invoices deleted.'"
1885
+ ],
1886
+ "dont": [
1887
+ "Do not make Cmd-click or Shift-click the only way to pick rows. A Checkbox works for a keyboard, a screen reader and touch.",
1888
+ "Do not make dragging the only way to act on picked rows. Give each action a Button or a menu item.",
1889
+ "Do not drop the picked rows when the page changes.",
1890
+ "Do not say 'Select All' with no count on a paged table. Say how many it picks.",
1891
+ "Do not show the bar and the toolbar at once."
1892
+ ],
1893
+ "native": "On Apple put the list in edit mode with `EditButton`, bind a `Set` of ids to the `List` selection, and show the actions in a bottom toolbar. On Android show a contextual top bar with the count and the actions while any row is picked.",
1894
+ "options": [
1895
+ {
1896
+ "id": "list",
1897
+ "title": "Ticks on one page",
1898
+ "useWhen": "A list whose rows all fit on one page, such as the tasks of a project.",
1899
+ "source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport Toaster, { toast, dismissToast } from 'oneslash-design-system/components/toaster';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Checkbox from 'oneslash-design-system/components/checkBox';\nimport Button from 'oneslash-design-system/components/button';\nimport IconButton from 'oneslash-design-system/components/iconButton';\nimport Tooltip from 'oneslash-design-system/components/tooltip';\nimport Popover from 'oneslash-design-system/components/popover';\nimport Menu from 'oneslash-design-system/components/menu';\nimport MenuItem from 'oneslash-design-system/components/menuItem';\nimport Modal from 'oneslash-design-system/components/modal';\nimport Tag from 'oneslash-design-system/components/tag';\nimport EmptyBox from 'oneslash-design-system/components/emptyBox';\nimport TableContainer from 'oneslash-design-system/components/tableContainer';\nimport TableHeader from 'oneslash-design-system/components/tableHeader';\nimport TableHeaderCell from 'oneslash-design-system/components/tableHeaderCell';\nimport TableRow from 'oneslash-design-system/components/tableRow';\nimport TableCell from 'oneslash-design-system/components/tableCell';\nimport { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';\n\ntype Task = { id: string; title: string; assignee: string | null; done: boolean };\n\n// A real app reads this from the session.\nconst me = 'Dana Lee';\n\n// A real app reads these from the server. They all fit on one page.\nconst firstTasks: Task[] = [\n { id: 't1', title: 'Write the launch email', assignee: 'Ben Carter', done: false },\n { id: 't2', title: 'Update the pricing page', assignee: 'Dana Lee', done: false },\n { id: 't3', title: 'Check the plan table on a phone', assignee: 'Omar Reyes', done: false },\n { id: 't4', title: 'Send the press kit', assignee: 'Mia Park', done: true },\n { id: 't5', title: 'Book the launch call', assignee: null, done: false },\n { id: 't6', title: 'Review the help article', assignee: 'Ben Carter', done: false },\n { id: 't7', title: 'Record the demo video', assignee: 'Omar Reyes', done: false },\n { id: 't8', title: 'Translate the FAQ', assignee: null, done: false },\n];\n\nconst plural = (n: number) => `${n} ${n === 1 ? 'task' : 'tasks'}`;\n\n// Names up to three tasks, then counts the rest: 'A', 'B' and 2 more tasks.\nfunction nameTasks(list: Task[]) {\n const names = list.slice(0, 3).map((t) => `'${t.title}'`);\n const rest = list.length - names.length;\n if (rest > 0) return `${names.join(', ')} and ${rest} more ${rest === 1 ? 'task' : 'tasks'}`;\n if (names.length <= 1) return names[0] ?? '';\n return `${names.slice(0, -1).join(', ')} and ${names[names.length - 1]}`;\n}\n\nexport default function BulkActionsList() {\n const [tasks, setTasks] = useState(firstTasks);\n // Opens with three tasks picked, so the bar shows.\n const [picked, setPicked] = useState<string[]>(['t1', 't3', 't5']);\n const [menuAnchor, setMenuAnchor] = useState<HTMLElement | null>(null);\n const [menuOpen, setMenuOpen] = useState(false);\n // The tasks the confirm names. They stay set while the Modal fades out.\n const [toDelete, setToDelete] = useState<Task[]>([]);\n const [confirming, setConfirming] = useState(false);\n const [deleting, setDeleting] = useState(false);\n const timer = useRef<ReturnType<typeof setTimeout>>();\n const toastIds = useRef<string[]>([]);\n const headerBox = useRef<HTMLInputElement>(null);\n // With no task left there is no header Checkbox, so focus goes to Add Task.\n const addTask = useRef<HTMLButtonElement | HTMLAnchorElement | null>(null);\n // Where focus goes after the next render, once the element it goes to is on screen.\n const focusNext = useRef<() => void>();\n\n // On unmount it stops the request and closes every toast it opened.\n useEffect(() => () => {\n clearTimeout(timer.current);\n toastIds.current.forEach((id) => dismissToast(id));\n toastIds.current = [];\n }, []);\n\n useEffect(() => {\n const move = focusNext.current;\n focusNext.current = undefined;\n move?.();\n });\n\n const headerCheckbox = () => headerBox.current ?? addTask.current;\n const pickedTasks = tasks.filter((t) => picked.includes(t.id));\n const count = pickedTasks.length;\n const all = tasks.length > 0 && count === tasks.length;\n\n function toggle(id: string, on: boolean) {\n setPicked((list) => (on ? [...list, id] : list.filter((x) => x !== id)));\n }\n\n // Mixed or empty: pick every task. All picked: pick none.\n function toggleAll(on: boolean) {\n setPicked(on ? tasks.map((t) => t.id) : []);\n }\n\n // The bar and its Buttons go, so focus goes to the header Checkbox.\n function clearSelection() {\n setPicked([]);\n focusNext.current = () => headerCheckbox()?.focus();\n }\n\n function update(change: (t: Task) => Task, message: string) {\n setTasks((list) => list.map((t) => (picked.includes(t.id) ? change(t) : t)));\n toastIds.current.push(toast({ type: 'success', message }));\n }\n\n function choose(action: () => void) {\n setMenuOpen(false);\n action();\n }\n\n // Escape, a click outside and Cancel all close it, except while the request runs.\n function closeConfirm() {\n if (deleting) return;\n setConfirming(false);\n }\n\n function deletePicked() {\n if (deleting) return;\n const ids = toDelete.map((t) => t.id);\n setDeleting(true);\n // Stands in for the request to the server.\n timer.current = setTimeout(() => {\n setDeleting(false);\n setTasks((list) => list.filter((t) => !ids.includes(t.id)));\n setPicked([]);\n setConfirming(false);\n toastIds.current.push(toast({ type: 'success', message: `${plural(ids.length)} deleted.` }));\n }, 1200);\n }\n\n return (\n <Center width=\"page\">\n {/* A real app mounts one Toaster near its root. */}\n <Toaster />\n <Stack gap=\"large\">\n <Heading level={1} size=\"h5\">Launch tasks</Heading>\n {/* The toolbar. While any task is picked, the bar takes its place. */}\n <Cluster justify=\"between\">\n {/* On the page from the start, so each new count is heard once. */}\n <Paragraph id=\"bulk-actions-list-count\" role=\"status\" size=\"body2\" measure=\"none\">\n {count > 0 ? `${count} selected` : plural(tasks.length)}\n </Paragraph>\n {count > 0 ? (\n <Cluster gap=\"small\">\n <Button size=\"small\" type=\"secondary\" state=\"enabled\" label=\"Mark Done\" onClickButton={() => update((t) => ({ ...t, done: true }), `${plural(count)} marked done.`)} />\n <Button size=\"small\" type=\"secondary\" color=\"danger\" state=\"enabled\" label=\"Delete\" onClickButton={() => { setToDelete(pickedTasks); setConfirming(true); }} />\n <Tooltip title=\"More\">\n <IconButton\n color=\"iconOnly\"\n state={menuOpen ? 'selected' : 'enabled'}\n size=\"small\"\n iconName=\"Ellipsis\"\n ariaLabel={`More actions for ${plural(count)}`}\n aria-haspopup=\"menu\"\n aria-expanded={menuOpen}\n onClick={(e: { currentTarget: HTMLElement }) => {\n setMenuAnchor(e.currentTarget);\n setMenuOpen((o) => !o);\n }}\n />\n </Tooltip>\n <Button size=\"small\" type=\"tertiary\" state=\"enabled\" label=\"Clear Selection\" onClickButton={clearSelection} />\n </Cluster>\n ) : (\n <Button ref={addTask} size=\"small\" type=\"secondary\" state=\"enabled\" label=\"Add Task\" decoIcon=\"Plus\" onClickButton={() => console.info('Open the new task form')} />\n )}\n </Cluster>\n\n {tasks.length === 0 ? (\n <EmptyBox size=\"large\" text=\"No tasks\" secondText=\"Tasks you add to this project appear here.\" />\n ) : (\n <TableContainer aria-label=\"Launch tasks\" minWidth=\"520px\">\n <TableHeader>\n <TableRow>\n <TableHeaderCell width=\"48px\">\n <Checkbox ref={headerBox} aria-label=\"Select all tasks\" checked={all} indeterminate={count > 0 && !all} onChange={toggleAll} />\n </TableHeaderCell>\n <TableHeaderCell>Task</TableHeaderCell>\n <TableHeaderCell width=\"140px\">Assignee</TableHeaderCell>\n <TableHeaderCell width=\"80px\">Status</TableHeaderCell>\n </TableRow>\n </TableHeader>\n {tasks.map((t) => (\n <TableRow key={t.id}>\n <TableCell width=\"48px\">\n <Checkbox aria-label={`Select ${t.title}`} checked={picked.includes(t.id)} onChange={(on) => toggle(t.id, on)} />\n </TableCell>\n <TableCell>{t.title}</TableCell>\n <TableCell width=\"140px\">{t.assignee ?? 'No one'}</TableCell>\n <TableCell width=\"80px\">\n <Tag variant=\"textOnly\" size=\"small\" label={t.done ? 'Done' : 'Open'} />\n </TableCell>\n </TableRow>\n ))}\n </TableContainer>\n )}\n </Stack>\n\n <Popover open={menuOpen} anchorEl={menuAnchor} onClose={() => setMenuOpen(false)} returnFocus>\n <Menu navigable aria-label={`Actions for ${plural(count)}`} width={200}>\n <MenuItem size=\"small\" iconName=\"UserCheck\" label=\"Assign to Me\" onClick={() => choose(() => update((t) => ({ ...t, assignee: me }), `${plural(count)} assigned to you.`))} />\n <MenuItem size=\"small\" iconName=\"UserX\" label=\"Unassign\" onClick={() => choose(() => update((t) => ({ ...t, assignee: null }), `${plural(count)} unassigned.`))} />\n </Menu>\n </Popover>\n\n {/* After a delete the bar is gone, so the Modal gives focus to the header Checkbox. Cancel gives it back to Delete. */}\n <Modal\n isOpen={confirming}\n size=\"small\"\n title={`Delete ${toDelete.length} ${toDelete.length === 1 ? 'Task' : 'Tasks'}`}\n onClose={closeConfirm}\n returnFocus={headerCheckbox}\n actions={\n <>\n <Button size=\"small\" type=\"tertiary\" state={deleting ? 'disabled' : 'enabled'} label=\"Cancel\" onClickButton={closeConfirm} />\n <Button size=\"small\" type=\"primary\" color=\"danger\" state=\"enabled\" label=\"Delete\" loading={deleting} onClickButton={deletePicked} />\n </>\n }\n >\n <Paragraph measure=\"none\">{`This deletes ${nameTasks(toDelete)}.`}</Paragraph>\n <Paragraph tone=\"secondary\" size=\"body2\" measure=\"none\">Their comments and files go too.</Paragraph>\n </Modal>\n </Center>\n );\n}\n",
1900
+ "uses": [
1901
+ "Button",
1902
+ "Center",
1903
+ "Checkbox",
1904
+ "Cluster",
1905
+ "EmptyBox",
1906
+ "Heading",
1907
+ "IconButton",
1908
+ "Menu",
1909
+ "MenuItem",
1910
+ "Modal",
1911
+ "Paragraph",
1912
+ "Popover",
1913
+ "Stack",
1914
+ "TableCell",
1915
+ "TableContainer",
1916
+ "TableHeader",
1917
+ "TableHeaderCell",
1918
+ "TableRow",
1919
+ "Tag",
1920
+ "Toaster",
1921
+ "Tooltip",
1922
+ "dismissToast",
1923
+ "toast"
1924
+ ]
1925
+ },
1926
+ {
1927
+ "id": "paged-table",
1928
+ "title": "Ticks across pages",
1929
+ "useWhen": "A table over many pages, where the person may want every row, not only the ones they see.",
1930
+ "source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport Toaster, { toast, dismissToast } from 'oneslash-design-system/components/toaster';\nimport TitleBar from 'oneslash-design-system/components/titleBar';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Checkbox from 'oneslash-design-system/components/checkBox';\nimport Button from 'oneslash-design-system/components/button';\nimport IconButton from 'oneslash-design-system/components/iconButton';\nimport Tooltip from 'oneslash-design-system/components/tooltip';\nimport Popover from 'oneslash-design-system/components/popover';\nimport Menu from 'oneslash-design-system/components/menu';\nimport MenuItem from 'oneslash-design-system/components/menuItem';\nimport Modal from 'oneslash-design-system/components/modal';\nimport Tag from 'oneslash-design-system/components/tag';\nimport Surface from 'oneslash-design-system/components/surface';\nimport EmptyBox from 'oneslash-design-system/components/emptyBox';\nimport Pagination from 'oneslash-design-system/components/pagination';\nimport TableContainer from 'oneslash-design-system/components/tableContainer';\nimport TableHeader from 'oneslash-design-system/components/tableHeader';\nimport TableHeaderCell from 'oneslash-design-system/components/tableHeaderCell';\nimport TableRow from 'oneslash-design-system/components/tableRow';\nimport TableCell from 'oneslash-design-system/components/tableCell';\nimport { formatCount, formatMoney } from 'oneslash-design-system/components/formatNumber';\nimport { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';\n\ntype Focusable = HTMLButtonElement | HTMLAnchorElement | null;\ntype Status = 'Paid' | 'Past due';\ntype Invoice = { id: string; number: string; customer: string; date: string; cents: number; status: Status };\n\nconst customers = ['Willow Bakery', 'Harbor Studio', 'Lumen Labs', 'Pine and Co', 'Cedar Works', 'Bright Dental', 'Maple Design', 'Atlas Freight'];\nconst monthNames = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];\n\n// A real app asks the server for one page. This makes the 240 invoices the server would hold, newest first.\nconst firstInvoices: Invoice[] = Array.from({ length: 240 }, (_, i) => {\n const day = new Date(Date.UTC(2026, 10, 16 - i));\n return {\n id: `inv-${i}`,\n number: `INV-${1290 - i}`,\n customer: customers[(i * 5 + 1) % customers.length],\n date: `${monthNames[day.getUTCMonth()]} ${day.getUTCDate()}, ${day.getUTCFullYear()}`,\n cents: 2400 + ((i * 5303) % 40000),\n status: i % 11 === 4 ? 'Past due' : 'Paid',\n };\n});\n\nconst PAGE_SIZE = 25;\nconst plural = (n: number) => `${formatCount(n)} ${n === 1 ? 'invoice' : 'invoices'}`;\n\n// Names up to three invoices, then counts the rest: INV-1290, INV-1289 and 23 more.\nfunction nameInvoices(list: Invoice[]) {\n const names = list.slice(0, 3).map((inv) => inv.number);\n const rest = list.length - names.length;\n if (rest > 0) return `${plural(list.length)}: ${names.join(', ')} and ${formatCount(rest)} more`;\n if (names.length <= 1) return names[0] ?? '';\n return `${names.slice(0, -1).join(', ')} and ${names[names.length - 1]}`;\n}\n\nexport default function BulkActionsPagedTable() {\n const [invoices, setInvoices] = useState(firstInvoices);\n const [page, setPage] = useState(1);\n // The picked invoices by id, on any page. Opens with three picked, so the bar shows.\n const [picked, setPicked] = useState<string[]>(['inv-0', 'inv-1', 'inv-3']);\n const [menuAnchor, setMenuAnchor] = useState<HTMLElement | null>(null);\n const [menuOpen, setMenuOpen] = useState(false);\n // The invoices the confirm names. They stay set while the Modal fades out.\n const [toDelete, setToDelete] = useState<Invoice[]>([]);\n const [confirming, setConfirming] = useState(false);\n const [deleting, setDeleting] = useState(false);\n const timer = useRef<ReturnType<typeof setTimeout>>();\n const toastIds = useRef<string[]>([]);\n const clearButton = useRef<Focusable>(null);\n // With no invoice left there is no header Checkbox, so focus goes to the empty state's Button.\n const createButton = useRef<Focusable>(null);\n const headerBox = useRef<HTMLInputElement>(null);\n // Where focus goes after the next render, once the element it goes to is on screen.\n const focusNext = useRef<() => void>();\n\n // On unmount it stops the request and closes every toast it opened.\n useEffect(() => () => {\n clearTimeout(timer.current);\n toastIds.current.forEach((id) => dismissToast(id));\n toastIds.current = [];\n }, []);\n\n useEffect(() => {\n const move = focusNext.current;\n focusNext.current = undefined;\n move?.();\n });\n\n const headerCheckbox = () => headerBox.current ?? createButton.current;\n const pageCount = Math.ceil(invoices.length / PAGE_SIZE);\n const rows = invoices.slice((page - 1) * PAGE_SIZE, page * PAGE_SIZE);\n const pickedInvoices = invoices.filter((inv) => picked.includes(inv.id));\n const count = pickedInvoices.length;\n const everyRow = count > 0 && count === invoices.length;\n // The header Checkbox speaks for the page shown.\n const onPage = rows.filter((inv) => picked.includes(inv.id)).length;\n const wholePage = rows.length > 0 && onPage === rows.length;\n\n function toggle(id: string, on: boolean) {\n setPicked((list) => (on ? [...list, id] : list.filter((x) => x !== id)));\n }\n\n // Mixed or empty: pick every row on this page. All picked: unpick them. Rows on other pages stay as they are.\n function togglePage(on: boolean) {\n const ids = rows.map((inv) => inv.id);\n setPicked((list) => (on ? [...list.filter((x) => !ids.includes(x)), ...ids] : list.filter((x) => !ids.includes(x))));\n }\n\n // 'Select All 240' goes away once every row is picked, so focus goes to 'Clear Selection'.\n function pickEveryRow() {\n setPicked(invoices.map((inv) => inv.id));\n focusNext.current = () => clearButton.current?.focus();\n }\n\n // The bar and its Buttons go, so focus goes to the header Checkbox.\n function clearSelection() {\n setPicked([]);\n focusNext.current = () => headerCheckbox()?.focus();\n }\n\n function choose(action: () => void) {\n setMenuOpen(false);\n action();\n }\n\n function markPaid() {\n setInvoices((list) => list.map((inv) => (picked.includes(inv.id) ? { ...inv, status: 'Paid' } : inv)));\n toastIds.current.push(toast({ type: 'success', message: `${plural(count)} marked as paid.` }));\n }\n\n // Escape, a click outside and Cancel all close it, except while the request runs.\n function closeConfirm() {\n if (deleting) return;\n setConfirming(false);\n }\n\n function deletePicked() {\n if (deleting) return;\n const ids = toDelete.map((inv) => inv.id);\n setDeleting(true);\n // Stands in for the request to the server.\n timer.current = setTimeout(() => {\n setDeleting(false);\n const left = invoices.filter((inv) => !ids.includes(inv.id));\n setInvoices(left);\n // Fewer pages may be left: stay on this page if it still exists, or go to the last one.\n setPage((p) => Math.min(p, Math.max(1, Math.ceil(left.length / PAGE_SIZE))));\n setPicked([]);\n setConfirming(false);\n toastIds.current.push(toast({ type: 'success', message: `${plural(ids.length)} deleted.` }));\n }, 1200);\n }\n\n return (\n <Center width=\"page\">\n {/* A real app mounts one Toaster near its root. */}\n <Toaster />\n <Stack gap=\"large\">\n {/* The case 'Data table page' adds search, a filter and sorting here. */}\n <Stack gap=\"small\">\n <TitleBar title=\"Invoices\" id=\"bulk-actions-paged-table-top\" />\n <Paragraph tone=\"secondary\" size=\"body2\" measure=\"none\">{plural(invoices.length)}</Paragraph>\n </Stack>\n\n {/* The toolbar. While any invoice is picked, the bar takes its place. */}\n <Cluster justify=\"between\">\n <Cluster gap=\"small\">\n {/* On the page from the start, so each new count is heard once. */}\n <Paragraph id=\"bulk-actions-paged-table-count\" role=\"status\" size=\"body2\" measure=\"none\">\n {count > 0 ? `${formatCount(count)} selected` : ''}\n </Paragraph>\n {count > 0 && !everyRow && (\n <Button size=\"small\" type=\"tertiary\" state=\"enabled\" label={`Select All ${formatCount(invoices.length)}`} onClickButton={pickEveryRow} />\n )}\n </Cluster>\n {count > 0 ? (\n <Cluster gap=\"small\">\n <Button size=\"small\" type=\"secondary\" state=\"enabled\" label=\"Export\" onClickButton={() => toastIds.current.push(toast({ type: 'success', message: `Export of ${plural(count)} sent to dana@acme.example.` }))} />\n <Button size=\"small\" type=\"secondary\" color=\"danger\" state=\"enabled\" label=\"Delete\" onClickButton={() => { setToDelete(pickedInvoices); setConfirming(true); }} />\n <Tooltip title=\"More\">\n <IconButton\n color=\"iconOnly\"\n state={menuOpen ? 'selected' : 'enabled'}\n size=\"small\"\n iconName=\"Ellipsis\"\n ariaLabel={`More actions for ${plural(count)}`}\n aria-haspopup=\"menu\"\n aria-expanded={menuOpen}\n onClick={(e: { currentTarget: HTMLElement }) => {\n setMenuAnchor(e.currentTarget);\n setMenuOpen((o) => !o);\n }}\n />\n </Tooltip>\n <Button ref={clearButton} size=\"small\" type=\"tertiary\" state=\"enabled\" label=\"Clear Selection\" onClickButton={clearSelection} />\n </Cluster>\n ) : invoices.length === 0 ? null : (\n <Button size=\"small\" type=\"secondary\" state=\"enabled\" label=\"Export All\" onClickButton={() => toastIds.current.push(toast({ type: 'success', message: `Export of ${plural(invoices.length)} sent to dana@acme.example.` }))} />\n )}\n </Cluster>\n\n {invoices.length === 0 ? (\n // The case 'Empty list' takes the table's place.\n <Surface minHeight=\"tall\" align=\"center\">\n <EmptyBox\n size=\"large\"\n text=\"No invoices yet\"\n secondText=\"Your next invoice appears here after the next payment.\"\n action={<Button ref={createButton} size=\"medium\" type=\"primary\" state=\"enabled\" label=\"Create Invoice\" onClickButton={() => console.info('Open the new invoice form')} />}\n />\n </Surface>\n ) : (\n <TableContainer aria-label=\"Invoices\" minWidth=\"640px\">\n <TableHeader>\n <TableRow>\n <TableHeaderCell width=\"48px\">\n <Checkbox ref={headerBox} aria-label=\"Select all invoices on this page\" checked={wholePage} indeterminate={onPage > 0 && !wholePage} onChange={togglePage} />\n </TableHeaderCell>\n <TableHeaderCell width=\"110px\">Invoice</TableHeaderCell>\n <TableHeaderCell>Customer</TableHeaderCell>\n <TableHeaderCell width=\"130px\">Date</TableHeaderCell>\n <TableHeaderCell width=\"120px\" align=\"right\">Amount</TableHeaderCell>\n <TableHeaderCell width=\"100px\">Status</TableHeaderCell>\n </TableRow>\n </TableHeader>\n {rows.map((inv) => (\n <TableRow key={inv.id}>\n <TableCell width=\"48px\">\n <Checkbox aria-label={`Select ${inv.number}`} checked={picked.includes(inv.id)} onChange={(on) => toggle(inv.id, on)} />\n </TableCell>\n <TableCell width=\"110px\">{inv.number}</TableCell>\n <TableCell>{inv.customer}</TableCell>\n <TableCell width=\"130px\">{inv.date}</TableCell>\n <TableCell width=\"120px\" align=\"right\">{formatMoney(inv.cents / 100)}</TableCell>\n <TableCell width=\"100px\">\n {inv.status === 'Past due' ? <Tag variant=\"dot\" size=\"small\" color=\"error\" label={inv.status} /> : <Tag variant=\"textOnly\" size=\"small\" label={inv.status} />}\n </TableCell>\n </TableRow>\n ))}\n </TableContainer>\n )}\n\n {/* Changing page keeps the picked invoices. A real app also passes `getHref`, so each page has an address. */}\n <Pagination aria-label=\"Invoice pages\" page={page} pageCount={pageCount} onPageChange={setPage} scrollTargetId=\"bulk-actions-paged-table-top\" />\n </Stack>\n\n <Popover open={menuOpen} anchorEl={menuAnchor} onClose={() => setMenuOpen(false)} returnFocus>\n <Menu navigable aria-label={`Actions for ${plural(count)}`} width={200}>\n <MenuItem size=\"small\" iconName=\"Mail\" label=\"Send Receipts\" onClick={() => choose(() => toastIds.current.push(toast({ type: 'success', message: `Receipts for ${plural(count)} sent.` })))} />\n <MenuItem size=\"small\" iconName=\"Check\" label=\"Mark as Paid\" onClick={() => choose(markPaid)} />\n </Menu>\n </Popover>\n\n {/* After a delete the bar is gone, so the Modal gives focus to the header Checkbox. Cancel gives it back to Delete. */}\n <Modal\n isOpen={confirming}\n size=\"small\"\n title={`Delete ${formatCount(toDelete.length)} ${toDelete.length === 1 ? 'Invoice' : 'Invoices'}`}\n onClose={closeConfirm}\n returnFocus={headerCheckbox}\n actions={\n <>\n <Button size=\"small\" type=\"tertiary\" state={deleting ? 'disabled' : 'enabled'} label=\"Cancel\" onClickButton={closeConfirm} />\n <Button size=\"small\" type=\"primary\" color=\"danger\" state=\"enabled\" label=\"Delete\" loading={deleting} onClickButton={deletePicked} />\n </>\n }\n >\n <Paragraph measure=\"none\">{`This deletes ${nameInvoices(toDelete)}.`}</Paragraph>\n <Paragraph tone=\"secondary\" size=\"body2\" measure=\"none\">Payments made on them stay in Payments.</Paragraph>\n </Modal>\n </Center>\n );\n}\n",
1931
+ "uses": [
1932
+ "Button",
1933
+ "Center",
1934
+ "Checkbox",
1935
+ "Cluster",
1936
+ "EmptyBox",
1937
+ "IconButton",
1938
+ "Menu",
1939
+ "MenuItem",
1940
+ "Modal",
1941
+ "Pagination",
1942
+ "Paragraph",
1943
+ "Popover",
1944
+ "Stack",
1945
+ "Surface",
1946
+ "TableCell",
1947
+ "TableContainer",
1948
+ "TableHeader",
1949
+ "TableHeaderCell",
1950
+ "TableRow",
1951
+ "Tag",
1952
+ "TitleBar",
1953
+ "Toaster",
1954
+ "Tooltip",
1955
+ "dismissToast",
1956
+ "formatCount",
1957
+ "formatMoney",
1958
+ "toast"
1959
+ ]
1960
+ }
1961
+ ]
1962
+ },
1387
1963
  {
1388
1964
  "id": "changelog",
1389
1965
  "title": "Changelog",
1390
1966
  "kind": "design",
1391
1967
  "level": "page",
1392
1968
  "area": "content",
1969
+ "surface": [
1970
+ "site"
1971
+ ],
1393
1972
  "situation": "A visitor or a customer wants to know what changed in the product lately, and may be sent to one change from a message.",
1394
1973
  "do": [
1395
1974
  "Use `PageHeader` with `level={1}`: the title 'Changelog' is the one level 1 heading, with a `lede` that says the order.",
@@ -1453,6 +2032,9 @@
1453
2032
  "kind": "design",
1454
2033
  "level": "organism",
1455
2034
  "area": "dashboard",
2035
+ "surface": [
2036
+ "app"
2037
+ ],
1456
2038
  "situation": "A dashboard shows how a count moved over its range, day by day or week by week.",
1457
2039
  "do": [
1458
2040
  "Follow the rule 'A number shows its unit and never shows 0 for unknown'. The axis shows a number from 10,000 up in its short form, and the readout and the table show it exact.",
@@ -1516,6 +2098,9 @@
1516
2098
  "kind": "design",
1517
2099
  "level": "page",
1518
2100
  "area": "auth",
2101
+ "surface": [
2102
+ "app"
2103
+ ],
1519
2104
  "situation": "A person signed up, and the product sent a link to confirm their email.",
1520
2105
  "do": [
1521
2106
  "Name the page 'Check your email' in a `Heading` with `level={1}`, with a `Mail` icon above it.",
@@ -1572,6 +2157,9 @@
1572
2157
  "kind": "design",
1573
2158
  "level": "organism",
1574
2159
  "area": "content",
2160
+ "surface": [
2161
+ "site"
2162
+ ],
1575
2163
  "situation": "A page shows code that a person reads, or copies to run.",
1576
2164
  "do": [
1577
2165
  "Use `CodeBlock` for `block`, with a `label` that names what the code is, such as 'ask.ts' or 'Set up the client'. The label names the block, its scroll region and its Copy Button.",
@@ -1626,6 +2214,9 @@
1626
2214
  "kind": "design",
1627
2215
  "level": "organism",
1628
2216
  "area": "menu",
2217
+ "surface": [
2218
+ "app"
2219
+ ],
1629
2220
  "situation": "A person filters a list by a word, and the list should keep its room when they are not typing.",
1630
2221
  "do": [
1631
2222
  "Use an `IconButton` with `iconName=\"Search\"` beside the list's heading, and open a `<Popover returnFocus aria-label=\"Search\">` with a search `TextField` from it.",
@@ -1676,6 +2267,9 @@
1676
2267
  "kind": "design",
1677
2268
  "level": "organism",
1678
2269
  "area": "chat",
2270
+ "surface": [
2271
+ "app"
2272
+ ],
1679
2273
  "situation": "A person reads comments left on a piece of work, opens one, and reads and answers its thread.",
1680
2274
  "do": [
1681
2275
  "Follow the cases 'Message row' and 'Message composer'.",
@@ -1746,12 +2340,77 @@
1746
2340
  }
1747
2341
  ]
1748
2342
  },
2343
+ {
2344
+ "id": "comparison-page",
2345
+ "title": "Comparison with another product",
2346
+ "kind": "design",
2347
+ "level": "page",
2348
+ "area": "marketing",
2349
+ "surface": [
2350
+ "site"
2351
+ ],
2352
+ "situation": "A visitor to the public site is choosing between this product and one other, and wants a fair side-by-side view.",
2353
+ "do": [
2354
+ "Follow the rule 'A site promises only what the app does, in the app's words': name each feature as the app names it.",
2355
+ "Open the page with `PageHeader` at level 1. Name both products in the title.",
2356
+ "Put a short 'When to pick which' section next, in a `Grid` of two `Surface`s, one for each product.",
2357
+ "Be fair to the other product. Say what it does well, and when a visitor should pick it.",
2358
+ "Put the table in `TableContainer` with an `aria-label` and a `minWidth`, as the case 'Plan comparison' does, so it scrolls in its region on a phone.",
2359
+ "Put each feature in `TableCell rowHeader`, so a screen reader says it with each cell.",
2360
+ "Write 'Yes' and 'No' here, since each column is a product, not a plan. Add a short note when it helps, such as 'Yes, up to 3 members'.",
2361
+ "Give every claim about the other product a source. Name it in the cell by number, such as 'Yes, on Team (Source 5)'.",
2362
+ "List the sources under the table, numbered, as `Link`s with `announceNewTab`. Keep them out of the table, so its region scrolls alone.",
2363
+ "Say when the sources were checked, above the list: 'Checked on Nov 16, 2026, on Northwind's public pages.'",
2364
+ "Ask for one main action, as the rule 'A marketing page asks for one main action, in the same words everywhere' says: 'Sign Up'."
2365
+ ],
2366
+ "dont": [
2367
+ "Do not add a row about the other product with no source.",
2368
+ "Do not show a check mark or a cross with no words.",
2369
+ "Do not leave out the rows where the other product does better.",
2370
+ "Do not compare against a plan or a price of your own that the app does not have.",
2371
+ "Do not compare more than two products on one page. Make one page for each."
2372
+ ],
2373
+ "native": "On Apple and Android an app has no comparison page. It lives on the site.",
2374
+ "options": [
2375
+ {
2376
+ "id": "table",
2377
+ "title": "Table with sources",
2378
+ "useWhen": "A visitor is choosing between this product and one other.",
2379
+ "source": "'use client';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport PageHeader from 'oneslash-design-system/components/pageHeader';\nimport SectionIntro from 'oneslash-design-system/components/sectionIntro';\nimport Surface from 'oneslash-design-system/components/surface';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport List from 'oneslash-design-system/components/list';\nimport Button from 'oneslash-design-system/components/button';\nimport Link from 'oneslash-design-system/components/link';\nimport TableContainer from 'oneslash-design-system/components/tableContainer';\nimport TableHeader from 'oneslash-design-system/components/tableHeader';\nimport TableHeaderCell from 'oneslash-design-system/components/tableHeaderCell';\nimport TableRow from 'oneslash-design-system/components/tableRow';\nimport TableCell from 'oneslash-design-system/components/tableCell';\nimport { formatMoney } from 'oneslash-design-system/components/formatNumber';\nimport { Cluster, Grid, PageSection, Stack } from 'oneslash-design-system/components/layout';\n\n// Fair to both: each says when a visitor should pick it.\nconst picks = [\n {\n name: 'Acme',\n items: ['Your team plans its work in threads.', 'You want an agent that reads the thread and asks before it changes shared work.', 'A small team wants a free plan.'],\n },\n {\n name: 'Northwind',\n items: ['Your team works mostly in long documents.', 'You need single sign-on today.', 'You want a desktop app that works offline.'],\n },\n];\n\n// Every claim about Northwind comes from one of its public pages, listed under the table by number.\nconst sources = [\n { label: 'Northwind pricing', href: 'https://northwind.example/pricing' },\n { label: 'Northwind plan limits', href: 'https://northwind.example/help/limits' },\n { label: 'Northwind agent help', href: 'https://northwind.example/help/agent' },\n { label: 'Northwind export help', href: 'https://northwind.example/help/export' },\n { label: 'Northwind security', href: 'https://northwind.example/security' },\n { label: 'Northwind downloads', href: 'https://northwind.example/download' },\n];\n\n// Acme's cells use the plan names, prices and limits of the cases 'Plan picker' and 'Pricing section'.\n// Each Northwind cell names its source by number, in words a screen reader reads with the cell.\nconst rows: { feature: string; acme: string; northwind: string; source: number }[] = [\n { feature: 'Price', acme: `Pro, ${formatMoney(8)} per member per month`, northwind: `Team, ${formatMoney(10)} per member per month`, source: 1 },\n { feature: 'Free plan', acme: 'Yes, up to 3 members', northwind: 'No, a 30-day trial', source: 1 },\n { feature: 'AI agent responses', acme: '1,000 a month on Pro', northwind: '500 a month on Team', source: 2 },\n { feature: 'Agent asks before it changes work', acme: 'Yes', northwind: 'No', source: 3 },\n { feature: 'Export to PDF', acme: 'Yes, on Pro', northwind: 'Yes, on Team', source: 4 },\n { feature: 'Single sign-on', acme: 'No', northwind: 'Yes, on Team', source: 5 },\n { feature: 'Desktop app that works offline', acme: 'No', northwind: 'Yes', source: 6 },\n];\n\nexport default function ComparisonPageTable() {\n return (\n <PageShell>\n <Stack gap=\"giant\">\n <Stack gap=\"xxlarge\">\n <PageHeader\n level={1}\n eyebrow=\"Compare\"\n title=\"Acme and Northwind\"\n lede=\"Both help a team plan its work with an AI agent. Here is where they differ, so you can pick the one that fits.\"\n />\n {/* The one main action, with the same label as the rest of the site. */}\n <Cluster>\n <Button size=\"large\" type=\"primary\" state=\"enabled\" label=\"Sign Up\" href=\"/sign-up\" />\n </Cluster>\n </Stack>\n <PageSection gap=\"xxlarge\">\n <SectionIntro id=\"comparison-page-pick\" name=\"When to pick which\" />\n <Grid columns={2}>\n {picks.map((p) => (\n <Surface key={p.name} padding=\"medium\">\n <Stack gap=\"medium\">\n <Heading level={3} size=\"h6\">{`Pick ${p.name} when`}</Heading>\n <List items={p.items} size=\"body2\" marker=\"dot\" />\n </Stack>\n </Surface>\n ))}\n </Grid>\n </PageSection>\n <PageSection gap=\"xxlarge\">\n <SectionIntro id=\"comparison-page-features\" name=\"Feature by feature\" />\n <Stack gap=\"medium\">\n {/* A named region that scrolls sideways on a phone, so the page never does. */}\n <TableContainer aria-label=\"Acme and Northwind compared\" minWidth=\"40rem\">\n <TableHeader>\n <TableRow>\n <TableHeaderCell>Feature</TableHeaderCell>\n <TableHeaderCell>Acme</TableHeaderCell>\n <TableHeaderCell>Northwind</TableHeaderCell>\n </TableRow>\n </TableHeader>\n {rows.map((row) => (\n <TableRow key={row.feature}>\n <TableCell rowHeader>{row.feature}</TableCell>\n <TableCell>{row.acme}</TableCell>\n <TableCell>{`${row.northwind} (Source ${row.source})`}</TableCell>\n </TableRow>\n ))}\n </TableContainer>\n {/* The sources sit under the table, out of its scroll region. Another site opens in a new tab and says so. */}\n <Stack gap=\"small\">\n <Paragraph size=\"body2\" tone=\"secondary\" measure=\"none\">Sources for Northwind. Checked on Nov 16, 2026, on Northwind's public pages.</Paragraph>\n <List\n size=\"body2\"\n marker=\"number\"\n items={sources.map((src) => (\n <Link key={src.href} href={src.href} size=\"body2\" openInNewTab announceNewTab>{src.label}</Link>\n ))}\n />\n </Stack>\n </Stack>\n </PageSection>\n </Stack>\n </PageShell>\n );\n}\n",
2380
+ "uses": [
2381
+ "Button",
2382
+ "Cluster",
2383
+ "Grid",
2384
+ "Heading",
2385
+ "Link",
2386
+ "List",
2387
+ "PageHeader",
2388
+ "PageSection",
2389
+ "PageShell",
2390
+ "Paragraph",
2391
+ "SectionIntro",
2392
+ "Stack",
2393
+ "Surface",
2394
+ "TableCell",
2395
+ "TableContainer",
2396
+ "TableHeader",
2397
+ "TableHeaderCell",
2398
+ "TableRow",
2399
+ "formatMoney"
2400
+ ]
2401
+ }
2402
+ ]
2403
+ },
1749
2404
  {
1750
2405
  "id": "composer-limit",
1751
2406
  "title": "Composer at a limit",
1752
2407
  "kind": "design",
1753
2408
  "level": "organism",
1754
2409
  "area": "chat",
2410
+ "surface": [
2411
+ "app",
2412
+ "agent"
2413
+ ],
1755
2414
  "situation": "The agent cannot be called from the composer because the workspace reached a limit, such as its AI agent responses for the month.",
1756
2415
  "do": [
1757
2416
  "Follow the rule 'An agent refuses clearly' word for word: \"You've used all 50 AI agent responses this month.\"",
@@ -1824,6 +2483,9 @@
1824
2483
  "kind": "design",
1825
2484
  "level": "organism",
1826
2485
  "area": "confirm",
2486
+ "surface": [
2487
+ "app"
2488
+ ],
1827
2489
  "situation": "A person asks to delete or remove something, and it cannot be undone.",
1828
2490
  "do": [
1829
2491
  "Follow the rule 'A confirm says exactly what will happen' for the Modal: `size=\"small\"`, 'Cancel' first, then the action with `color=\"danger\"`.",
@@ -1890,6 +2552,10 @@
1890
2552
  "kind": "rule",
1891
2553
  "level": "rule",
1892
2554
  "area": "confirm",
2555
+ "surface": [
2556
+ "site",
2557
+ "app"
2558
+ ],
1893
2559
  "situation": "An action a person takes themselves needs their yes before it happens. An action the agent wants to take follows the rule 'An agent asks before a risky action', a card in the conversation, not this one.",
1894
2560
  "answer": "A confirm is a Modal with `size=\"small\"`. Its title names the action in Title Case, such as 'Delete Project'. The body says in one or two sentences what will happen and what is kept. Two Buttons sit in the Modal's `actions`. 'Cancel' comes first, a `<Button type=\"tertiary\" size=\"small\">`. Then comes the action, a `<Button type=\"primary\" size=\"small\">` labelled in Title Case with the same verb as the title. When the action destroys or removes something, the action Button also has `color=\"danger\"`. One case differs: 'Unsaved changes'. Its guard may have three Buttons, 'Cancel', \"Don't Save\" and 'Save', in that order. When it has two, its safe Button reads 'Keep Editing'. Escape and a click outside the Modal mean Cancel. While the request runs, the action Button is `loading` and keeps its label, and 'Cancel' is `state=\"disabled\"`. The Modal stays open. It still calls `onClose` on Escape or a click outside, and the page ignores that call until the request ends. If the request fails, the Modal stays open and shows an inline error Alert at the top of its body, as the rule 'A form error shows next to the problem' says. When the action works, the Modal closes. If the thing is still on screen, the change shows where it is. If the thing is gone, a toast names it, as the rule 'Success shows where the person is looking' says.",
1895
2561
  "why": "A confirm is the last chance to stop a mistake. It has to say exactly what will happen, and the safe choice has to be easy to find.",
@@ -1910,12 +2576,95 @@
1910
2576
  ],
1911
2577
  "native": "On Apple use a system `confirmationDialog` or `.alert`, with the action in the `.destructive` role when it destroys or removes something. Never build a sheet by hand for a confirm."
1912
2578
  },
2579
+ {
2580
+ "id": "connection-status",
2581
+ "title": "Status of a connected source",
2582
+ "kind": "design",
2583
+ "level": "organism",
2584
+ "area": "settings",
2585
+ "surface": [
2586
+ "app"
2587
+ ],
2588
+ "situation": "A person connected other tools to the product, and wants to know if each one still works, is busy, or needs them.",
2589
+ "do": [
2590
+ "Build on the case 'Integrations': the same rows, logos and names, with the status under the name.",
2591
+ "Show the status as the case 'Status in a row' says: a `Tag` with `variant=\"dot\"` and a word. Use 'Connected', 'Syncing', 'Needs reconnect' or 'Not responding'.",
2592
+ "Keep the grey dot for 'Connected' and 'Syncing'. Color the dot only when a person must act: `warning` for 'Needs reconnect', `error` for 'Not responding'.",
2593
+ "Put a `TimeStamp` beside the status that says when the source last synced: 'Synced 2 minutes ago'.",
2594
+ "Say in the line what is wrong and what fixes it: 'Access ran out on Nov 14, 2026. Reconnect to keep files in sync.'",
2595
+ "Give a source that needs reconnecting a primary 'Reconnect' on its row, named for it: 'Reconnect Figma'. It is `loading` while it runs and keeps its label.",
2596
+ "Give a source that is not responding a secondary 'Try Again', named for it: 'Try again to reach Notion'.",
2597
+ "Show a first import as 'Syncing' with a `Progress` that counts: '12 of 40 files'.",
2598
+ "Show a rate limit as 'Syncing', with a line that says when it goes on: 'GitHub asked Acme to slow down. Syncing again at 2:45 PM.'",
2599
+ "List only the sources that need a person on a dashboard card, with the same words. Say how many there are in the title.",
2600
+ "Say so in one line when every source works: 'All 5 sources are working.'",
2601
+ "Move focus to the row's 'Disconnect' after 'Reconnect' or 'Try Again' works. On the card, the fixed source leaves the list, so focus goes to the next source's Button, or to the card's title when none is left.",
2602
+ "Say in a toast when a source on the dashboard card works again, since it leaves the list there. Name the source in the toast. On a row, the new status is enough."
2603
+ ],
2604
+ "dont": [
2605
+ "Do not blink or pulse the dot. Motion does not say what is wrong.",
2606
+ "Do not show a dot with no word, even on a small card.",
2607
+ "Do not show a rate limit as an error. Nothing is broken and the person cannot fix it.",
2608
+ "Do not hide the time of the last sync. It tells the person how old the data is.",
2609
+ "Do not list every source on a dashboard card. Show only the ones that need a person."
2610
+ ],
2611
+ "native": "On Apple show the status as a `Label` with a small circle and the word under the account's name, with 'Reconnect' as a Button in the row. On Android use a leading dot and the word in a `Text`, and a `LinearProgressIndicator` with the count for a first import.",
2612
+ "options": [
2613
+ {
2614
+ "id": "row",
2615
+ "title": "Status on each account",
2616
+ "useWhen": "On the integrations page, where each connected account has its own row.",
2617
+ "source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport { Figma, FileText, Slack } from 'lucide-react';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport TableContainer from 'oneslash-design-system/components/tableContainer';\nimport TableRow from 'oneslash-design-system/components/tableRow';\nimport TableCell from 'oneslash-design-system/components/tableCell';\nimport BrandIcon from 'oneslash-design-system/components/brandIcon';\nimport Icon from 'oneslash-design-system/components/icon';\nimport Tag from 'oneslash-design-system/components/tag';\nimport TimeStamp from 'oneslash-design-system/components/timeStamp';\nimport Progress from 'oneslash-design-system/components/progress';\nimport Button from 'oneslash-design-system/components/button';\nimport { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';\n\ntype Focusable = HTMLButtonElement | HTMLAnchorElement | null;\ntype Status = 'Connected' | 'Syncing' | 'Needs reconnect' | 'Not responding';\n\ntype Source = {\n id: string;\n name: string;\n status: Status;\n /** Minutes since the last sync. Unset before the first import ends. */\n syncedMinutesAgo?: number;\n /** What is wrong or what is going on, and what fixes it. */\n line?: string;\n /** A first import: how many files have arrived, of how many. */\n imported?: { done: number; total: number };\n brand?: 'google' | 'github';\n};\n\n// A real app reads these from the server.\nconst firstSources: Source[] = [\n { id: 'slack', name: 'Slack', status: 'Connected', syncedMinutesAgo: 2 },\n { id: 'github', name: 'GitHub', status: 'Syncing', syncedMinutesAgo: 12, line: 'GitHub asked Acme to slow down. Syncing again at 2:45 PM.', brand: 'github' },\n { id: 'drive', name: 'Google Drive', status: 'Syncing', line: 'First import. Files show up as they arrive.', imported: { done: 12, total: 40 }, brand: 'google' },\n { id: 'figma', name: 'Figma', status: 'Needs reconnect', syncedMinutesAgo: 2 * 24 * 60, line: 'Access ran out on Nov 14, 2026. Reconnect to keep files in sync.' },\n { id: 'notion', name: 'Notion', status: 'Not responding', syncedMinutesAgo: 35, line: 'Notion has not answered since 2:10 PM. Acme tries again every 10 minutes.' },\n];\n\n// The case 'Status in a row': a grey dot for a usual state, a color only when a person must act.\nconst dotColor: Record<Status, 'default' | 'warning' | 'error'> = {\n Connected: 'default',\n Syncing: 'default',\n 'Needs reconnect': 'warning',\n 'Not responding': 'error',\n};\n\nfunction renderLogo(s: Source) {\n if (s.brand) return <BrandIcon name={s.brand} size={24} />;\n return <Icon icon={s.id === 'slack' ? Slack : s.id === 'figma' ? Figma : FileText} size=\"medium\" color=\"secondary\" />;\n}\n\nexport default function ConnectionStatusRow() {\n const [sources, setSources] = useState(firstSources);\n const [working, setWorking] = useState<string | null>(null);\n // The minutes above count back from when the page opened.\n const [openedAt] = useState(() => Date.now());\n const timers = useRef<ReturnType<typeof setTimeout>[]>([]);\n // Each row's Disconnect by source id, so focus can move there when Reconnect or Try Again goes away.\n const disconnectButtons = useRef<Record<string, Focusable>>({});\n // Where focus goes after the next render, once the element it goes to is on screen.\n const focusNext = useRef<() => void>();\n\n // On unmount it stops every request.\n useEffect(() => () => {\n timers.current.forEach(clearTimeout);\n }, []);\n\n useEffect(() => {\n const move = focusNext.current;\n focusNext.current = undefined;\n move?.();\n });\n\n // 'Reconnect' stands in for the provider's sign-in; 'Try Again' asks the source at once. Both work here.\n function fix(s: Source) {\n if (working) return;\n setWorking(s.id);\n timers.current.push(setTimeout(() => {\n setWorking(null);\n setSources((list) => list.map((x) => (x.id === s.id ? { ...x, status: 'Connected', syncedMinutesAgo: 0, line: undefined } : x)));\n // The row's new status says it works again, so no toast. The Button that had focus is gone,\n // so focus goes to the row's Disconnect.\n focusNext.current = () => disconnectButtons.current[s.id]?.focus();\n }, 1200));\n }\n\n return (\n <Center width=\"page\">\n <Stack gap=\"large\">\n <Stack gap=\"small\">\n <Heading level={1} size=\"h5\">Integrations</Heading>\n <Paragraph tone=\"secondary\" size=\"body2\" measure=\"none\">Connect the tools your team already uses.</Paragraph>\n </Stack>\n {/* A named table scrolls inside its own region on a phone, never the page. */}\n <TableContainer aria-label=\"Connected sources\" minWidth=\"640px\">\n {sources.map((s) => {\n const busy = working === s.id;\n const minutes = s.syncedMinutesAgo;\n return (\n <TableRow key={s.id}>\n <TableCell width=\"56px\">{renderLogo(s)}</TableCell>\n <TableCell>\n <Stack gap=\"small\">\n <Heading level={2} size=\"subtitle1\">{s.name}</Heading>\n <Cluster gap=\"small\">\n <Tag variant=\"dot\" size=\"small\" color={dotColor[s.status]} label={s.status} />\n {minutes !== undefined && (\n <Cluster gap=\"small\">\n <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">Synced</Paragraph>\n <TimeStamp createdAt={openedAt - minutes * 60 * 1000} dateFormat=\"relative\" data={minutes < 24 * 60 ? 'time' : 'date'} />\n </Cluster>\n )}\n </Cluster>\n {s.line && <Paragraph tone=\"secondary\" size=\"body2\" measure=\"none\">{s.line}</Paragraph>}\n {s.imported && (\n <Progress label=\"Importing files\" kind=\"share\" size=\"small\" value={s.imported.done} max={s.imported.total} valueText={`${s.imported.done} of ${s.imported.total} files`} />\n )}\n </Stack>\n </TableCell>\n {/* A fixed last column keeps every row's Buttons in one place. */}\n <TableCell width=\"220px\">\n <Cluster gap=\"small\" justify=\"end\">\n {s.status === 'Needs reconnect' && (\n <Button size=\"small\" type=\"primary\" state={working && !busy ? 'disabled' : 'enabled'} label=\"Reconnect\" aria-label={`Reconnect ${s.name}`} loading={busy} onClickButton={() => fix(s)} />\n )}\n {s.status === 'Not responding' && (\n <Button size=\"small\" type=\"secondary\" state={working && !busy ? 'disabled' : 'enabled'} label=\"Try Again\" aria-label={`Try again to reach ${s.name}`} loading={busy} onClickButton={() => fix(s)} />\n )}\n {/* The case 'Integrations' confirms Disconnect in a small Modal. */}\n <Button\n ref={(el: Focusable) => { disconnectButtons.current[s.id] = el; }}\n size=\"small\"\n type=\"tertiary\"\n state={working ? 'disabled' : 'enabled'}\n label=\"Disconnect\"\n aria-label={`Disconnect ${s.name}`}\n onClickButton={() => console.info(`Ask to disconnect ${s.name}`)}\n />\n </Cluster>\n </TableCell>\n </TableRow>\n );\n })}\n </TableContainer>\n </Stack>\n </Center>\n );\n}\n",
2618
+ "uses": [
2619
+ "BrandIcon",
2620
+ "Button",
2621
+ "Center",
2622
+ "Cluster",
2623
+ "Heading",
2624
+ "Icon",
2625
+ "Paragraph",
2626
+ "Progress",
2627
+ "Stack",
2628
+ "TableCell",
2629
+ "TableContainer",
2630
+ "TableRow",
2631
+ "Tag",
2632
+ "TimeStamp"
2633
+ ]
2634
+ },
2635
+ {
2636
+ "id": "card",
2637
+ "title": "Sources that need a person",
2638
+ "useWhen": "On a dashboard, when a broken source explains why some data is missing.",
2639
+ "source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport { Figma, FileText } from 'lucide-react';\nimport Toaster, { toast, dismissToast } from 'oneslash-design-system/components/toaster';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Link from 'oneslash-design-system/components/link';\nimport Line from 'oneslash-design-system/components/line';\nimport Icon from 'oneslash-design-system/components/icon';\nimport Tag from 'oneslash-design-system/components/tag';\nimport TimeStamp from 'oneslash-design-system/components/timeStamp';\nimport Button from 'oneslash-design-system/components/button';\nimport { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';\n\ntype Focusable = HTMLButtonElement | HTMLAnchorElement | null;\n\ntype Source = {\n id: string;\n name: string;\n status: 'Needs reconnect' | 'Not responding';\n syncedMinutesAgo: number;\n line: string;\n};\n\n// A real app reads these from the server: only the sources that need a person. The other 3 work.\nconst total = 5;\nconst firstSources: Source[] = [\n { id: 'figma', name: 'Figma', status: 'Needs reconnect', syncedMinutesAgo: 2 * 24 * 60, line: 'Access ran out. Design comments since Nov 14, 2026 are missing.' },\n { id: 'notion', name: 'Notion', status: 'Not responding', syncedMinutesAgo: 35, line: 'Notion has not answered since 2:10 PM. Docs may be out of date.' },\n];\n\nexport default function ConnectionStatusCard() {\n const [sources, setSources] = useState(firstSources);\n const [working, setWorking] = useState<string | null>(null);\n // The minutes above count back from when the page opened.\n const [openedAt] = useState(() => Date.now());\n const timers = useRef<ReturnType<typeof setTimeout>[]>([]);\n const toastIds = useRef<string[]>([]);\n const title = useRef<HTMLHeadingElement>(null);\n // Each source's Button by id, so focus can move to the next one when a fixed source leaves the card.\n const buttons = useRef<Record<string, Focusable>>({});\n // Where focus goes after the next render, once the element it goes to is on screen.\n const focusNext = useRef<() => void>();\n\n // On unmount it stops every request and closes every toast it opened.\n useEffect(() => () => {\n timers.current.forEach(clearTimeout);\n toastIds.current.forEach((id) => dismissToast(id));\n toastIds.current = [];\n }, []);\n\n useEffect(() => {\n const move = focusNext.current;\n focusNext.current = undefined;\n move?.();\n });\n\n // 'Reconnect' stands in for the provider's sign-in; 'Try Again' asks the source at once. Both work here.\n function fix(s: Source) {\n if (working) return;\n setWorking(s.id);\n timers.current.push(setTimeout(() => {\n setWorking(null);\n const at = sources.findIndex((x) => x.id === s.id);\n const rest = sources.filter((x) => x.id !== s.id);\n setSources(rest);\n toastIds.current.push(toast({ type: 'success', message: `${s.name} is connected and syncing again.` }));\n // The fixed source leaves the card: focus goes to the next source, the one before on the last row, or the title.\n const neighbor = rest[at] ?? rest[at - 1];\n focusNext.current = () => (neighbor ? buttons.current[neighbor.id] : title.current)?.focus();\n }, 1200));\n }\n\n return (\n <Center width=\"page\">\n {/* A real app mounts one Toaster near its root. */}\n <Toaster />\n <Stack gap=\"medium\">\n <Line />\n <Heading ref={title} tabIndex={-1} level={2} size=\"h6\">\n {sources.length === 0 ? 'Sources' : `${sources.length} ${sources.length === 1 ? 'source needs' : 'sources need'} you`}\n </Heading>\n {sources.length === 0 ? (\n <Paragraph tone=\"secondary\" size=\"body2\" measure=\"none\">{`All ${total} sources are working.`}</Paragraph>\n ) : (\n <Stack gap=\"large\">\n {sources.map((s) => {\n const busy = working === s.id;\n const reconnect = s.status === 'Needs reconnect';\n return (\n <Cluster key={s.id} justify=\"between\" align=\"start\">\n <Stack gap=\"small\">\n <Cluster gap=\"small\">\n <Icon icon={s.id === 'figma' ? Figma : FileText} size=\"small\" color=\"secondary\" />\n <Heading level={3} size=\"subtitle2\">{s.name}</Heading>\n </Cluster>\n <Cluster gap=\"small\">\n <Tag variant=\"dot\" size=\"small\" color={reconnect ? 'warning' : 'error'} label={s.status} />\n <Cluster gap=\"small\">\n <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">Synced</Paragraph>\n <TimeStamp createdAt={openedAt - s.syncedMinutesAgo * 60 * 1000} dateFormat=\"relative\" data={s.syncedMinutesAgo < 24 * 60 ? 'time' : 'date'} />\n </Cluster>\n </Cluster>\n <Paragraph tone=\"secondary\" size=\"body2\" measure=\"none\">{s.line}</Paragraph>\n </Stack>\n <Button\n ref={(el: Focusable) => { buttons.current[s.id] = el; }}\n size=\"small\"\n type={reconnect ? 'primary' : 'secondary'}\n state={working && !busy ? 'disabled' : 'enabled'}\n label={reconnect ? 'Reconnect' : 'Try Again'}\n aria-label={reconnect ? `Reconnect ${s.name}` : `Try again to reach ${s.name}`}\n loading={busy}\n onClickButton={() => fix(s)}\n />\n </Cluster>\n );\n })}\n </Stack>\n )}\n {/* A real app links to its integrations page. Link has no click handler to keep the example here, so it uses '#'. */}\n <Cluster>\n <Link href=\"#\" size=\"body2\">See All Sources</Link>\n </Cluster>\n </Stack>\n </Center>\n );\n}\n",
2640
+ "uses": [
2641
+ "Button",
2642
+ "Center",
2643
+ "Cluster",
2644
+ "Heading",
2645
+ "Icon",
2646
+ "Line",
2647
+ "Link",
2648
+ "Paragraph",
2649
+ "Stack",
2650
+ "Tag",
2651
+ "TimeStamp",
2652
+ "Toaster",
2653
+ "dismissToast",
2654
+ "toast"
2655
+ ]
2656
+ }
2657
+ ]
2658
+ },
1913
2659
  {
1914
2660
  "id": "contact-page",
1915
2661
  "title": "Contact page",
1916
2662
  "kind": "design",
1917
2663
  "level": "page",
1918
2664
  "area": "content",
2665
+ "surface": [
2666
+ "site"
2667
+ ],
1919
2668
  "situation": "A visitor wants to reach the person behind a site.",
1920
2669
  "do": [
1921
2670
  "Use a `Form` for `form`, with Name, Email and Message, and follow the rules 'A form error shows next to the problem' and 'Success shows where the person is looking'.",
@@ -1974,6 +2723,10 @@
1974
2723
  "kind": "design",
1975
2724
  "level": "organism",
1976
2725
  "area": "chat",
2726
+ "surface": [
2727
+ "app",
2728
+ "agent"
2729
+ ],
1977
2730
  "situation": "A thread has no messages yet, and the person may not know what to write first.",
1978
2731
  "do": [
1979
2732
  "Show the empty thread as the rule 'An empty list says what will fill it' says. Use `EmptyBox` with `size=\"large\"`, the `text` 'No messages yet', and a `secondText` that says what to do.",
@@ -2036,6 +2789,9 @@
2036
2789
  "kind": "design",
2037
2790
  "level": "organism",
2038
2791
  "area": "marketing",
2792
+ "surface": [
2793
+ "site"
2794
+ ],
2039
2795
  "situation": "A site sets cookies it does not need to run, and asks the visitor whether it may.",
2040
2796
  "do": [
2041
2797
  "Ask only when the site sets a cookie it does not need. A cookie that keeps a person logged in needs no question.",
@@ -2101,6 +2857,9 @@
2101
2857
  "kind": "design",
2102
2858
  "level": "organism",
2103
2859
  "area": "confirm",
2860
+ "surface": [
2861
+ "app"
2862
+ ],
2104
2863
  "situation": "A person creates something new, such as a project or a task, and it needs a name before it exists.",
2105
2864
  "do": [
2106
2865
  "Title the Modal 'Create' and the thing, such as 'Create Project', and give its action the same verb: 'Create'.",
@@ -2170,6 +2929,9 @@
2170
2929
  "kind": "design",
2171
2930
  "level": "organism",
2172
2931
  "area": "settings",
2932
+ "surface": [
2933
+ "app"
2934
+ ],
2173
2935
  "situation": "A settings page offers actions that are hard or impossible to undo, such as deleting an account or a workspace, or leaving one.",
2174
2936
  "do": [
2175
2937
  "Put the actions in a `SettingsSection tone=\"danger\"` titled 'Danger zone', or titled with the action, such as 'Delete workspace'. It is the last section on the page.",
@@ -2233,6 +2995,9 @@
2233
2995
  "kind": "design",
2234
2996
  "level": "page",
2235
2997
  "area": "dashboard",
2998
+ "surface": [
2999
+ "app"
3000
+ ],
2236
3001
  "situation": "A page that opens an app and says how things are going and what waits on the person.",
2237
3002
  "do": [
2238
3003
  "Follow the rule 'A number shows its unit and never shows 0 for unknown'.",
@@ -2318,6 +3083,9 @@
2318
3083
  "kind": "design",
2319
3084
  "level": "page",
2320
3085
  "area": "dashboard",
3086
+ "surface": [
3087
+ "app"
3088
+ ],
2321
3089
  "situation": "A page is one long table of records, such as invoices or customers, that a person searches, sorts and acts on.",
2322
3090
  "do": [
2323
3091
  "Follow the rule 'A number shows its unit and never shows 0 for unknown'.",
@@ -2430,6 +3198,9 @@
2430
3198
  "kind": "design",
2431
3199
  "level": "organism",
2432
3200
  "area": "settings",
3201
+ "surface": [
3202
+ "app"
3203
+ ],
2433
3204
  "situation": "A person gives one day, such as when a token expires or their date of birth.",
2434
3205
  "do": [
2435
3206
  "Use `DateField`. The person types the date as MM/DD/YYYY, such as '11/16/2026', or picks it from the calendar.",
@@ -2496,6 +3267,9 @@
2496
3267
  "kind": "design",
2497
3268
  "level": "page",
2498
3269
  "area": "auth",
3270
+ "surface": [
3271
+ "app"
3272
+ ],
2499
3273
  "situation": "A CLI, an editor or another app opened the browser so the person can log in, and the login must reach that app.",
2500
3274
  "do": [
2501
3275
  "Say in one line what the login connects: 'This connects Acme CLI on your computer to your account.'",
@@ -2551,6 +3325,9 @@
2551
3325
  "kind": "design",
2552
3326
  "level": "page",
2553
3327
  "area": "content",
3328
+ "surface": [
3329
+ "site"
3330
+ ],
2554
3331
  "situation": "A person opens the page of one part of a design system or a code library to see what it looks like, how to write it and what it takes.",
2555
3332
  "do": [
2556
3333
  "Use `PageHeader` with `level={1}`: the part's name is the one level 1 heading, with a `lede` of one sentence that says what it is for.",
@@ -2609,6 +3386,9 @@
2609
3386
  "kind": "design",
2610
3387
  "level": "page",
2611
3388
  "area": "auth",
3389
+ "surface": [
3390
+ "app"
3391
+ ],
2612
3392
  "situation": "A person opened the link that confirms their email.",
2613
3393
  "do": [
2614
3394
  "Name the page 'Email confirmed' in a `Heading` with `level={1}`.",
@@ -2661,6 +3441,9 @@
2661
3441
  "kind": "design",
2662
3442
  "level": "organism",
2663
3443
  "area": "state",
3444
+ "surface": [
3445
+ "app"
3446
+ ],
2664
3447
  "situation": "A list has loaded, and there is nothing in it yet.",
2665
3448
  "do": [
2666
3449
  "Use `size=\"large\"` when the list is the whole pane, and `size=\"small\"` inside a section.",
@@ -2708,6 +3491,9 @@
2708
3491
  "kind": "rule",
2709
3492
  "level": "rule",
2710
3493
  "area": "state",
3494
+ "surface": [
3495
+ "app"
3496
+ ],
2711
3497
  "situation": "A list, table or pane has nothing to show.",
2712
3498
  "answer": "Use `EmptyBox`, never a bare line of text. Its `size` is `large` when the list fills the whole region and `small` inside a section. The `text` says what is empty, in the person's words and in sentence case: 'No saved comments'. The `secondText` says what will appear here or what to do. When the person can fix it, pass the Button as `action`. The action Button is primary when it fills the list or tries again, and secondary when it is 'Clear Search'. An empty search shows the words searched for and a 'Clear Search' Button. A failed load is not an empty list: say that loading failed and offer a 'Try Again' Button. `EmptyBox` may hold that message, with 'Try Again' as its `action`, but never the empty text.",
2713
3499
  "why": "An empty space looks like something is broken. Saying what is missing and what will fill it tells the person nothing is wrong and what to do next.",
@@ -2733,6 +3519,9 @@
2733
3519
  "kind": "design",
2734
3520
  "level": "organism",
2735
3521
  "area": "state",
3522
+ "surface": [
3523
+ "app"
3524
+ ],
2736
3525
  "situation": "A pane is empty because something it needs is not set up yet, such as a connected account.",
2737
3526
  "do": [
2738
3527
  "Say what is missing: 'No calendar connected'.",
@@ -2779,6 +3568,10 @@
2779
3568
  "kind": "design",
2780
3569
  "level": "organism",
2781
3570
  "area": "state",
3571
+ "surface": [
3572
+ "site",
3573
+ "app"
3574
+ ],
2782
3575
  "situation": "A search or a filter finds nothing.",
2783
3576
  "do": [
2784
3577
  "Use `icon=\"Search\"`, so it reads as a search and not an empty list.",
@@ -2816,6 +3609,10 @@
2816
3609
  "kind": "design",
2817
3610
  "level": "page",
2818
3611
  "area": "state",
3612
+ "surface": [
3613
+ "site",
3614
+ "app"
3615
+ ],
2819
3616
  "situation": "Something broke while showing a page, and the app cannot show it.",
2820
3617
  "do": [
2821
3618
  "Name the page in a `Heading` with `level={1}`: 'Something went wrong'.",
@@ -2869,6 +3666,9 @@
2869
3666
  "kind": "design",
2870
3667
  "level": "organism",
2871
3668
  "area": "marketing",
3669
+ "surface": [
3670
+ "site"
3671
+ ],
2872
3672
  "situation": "A marketing page answers the questions a visitor asks before signing up.",
2873
3673
  "do": [
2874
3674
  "Put the section's name in `SectionIntro`, so the section has a level 2 heading. Write each question as the visitor would ask it, in sentence case, ending in a question mark.",
@@ -2923,6 +3723,9 @@
2923
3723
  "kind": "design",
2924
3724
  "level": "organism",
2925
3725
  "area": "marketing",
3726
+ "surface": [
3727
+ "site"
3728
+ ],
2926
3729
  "situation": "A marketing page lists what the product does, so a visitor can see if it fits.",
2927
3730
  "do": [
2928
3731
  "Follow the rule 'A marketing page asks for one main action, in the same words everywhere'. A feature section does not add its own action. The page's one Button stays in the header, the hero and the end.",
@@ -2980,6 +3783,9 @@
2980
3783
  "kind": "design",
2981
3784
  "level": "organism",
2982
3785
  "area": "confirm",
3786
+ "surface": [
3787
+ "app"
3788
+ ],
2983
3789
  "situation": "A person sends feedback about the product from inside it.",
2984
3790
  "do": [
2985
3791
  "Title the Modal 'Send Feedback' and label its action 'Send', after 'Cancel'.",
@@ -3028,6 +3834,9 @@
3028
3834
  "kind": "design",
3029
3835
  "level": "organism",
3030
3836
  "area": "settings",
3837
+ "surface": [
3838
+ "app"
3839
+ ],
3031
3840
  "situation": "A person adds a file from their device, such as a new profile picture or the receipts for a report.",
3032
3841
  "do": [
3033
3842
  "Use `DropZone`. A person can drop a file on it or choose one with its Button, so it works with a keyboard, a screen reader and touch.",
@@ -3093,6 +3902,9 @@
3093
3902
  "kind": "design",
3094
3903
  "level": "organism",
3095
3904
  "area": "menu",
3905
+ "surface": [
3906
+ "app"
3907
+ ],
3096
3908
  "situation": "A person narrows a list by one choice, such as a date range, or turns the filter off.",
3097
3909
  "do": [
3098
3910
  "Open a navigable menu from an `IconButton`: `<Popover returnFocus>` around `<Menu navigable aria-label=\"Filter by date\">` with `onClick` items.",
@@ -3160,6 +3972,9 @@
3160
3972
  "kind": "design",
3161
3973
  "level": "page",
3162
3974
  "area": "auth",
3975
+ "surface": [
3976
+ "app"
3977
+ ],
3163
3978
  "situation": "A person cannot remember their password and asks for a link to set a new one.",
3164
3979
  "do": [
3165
3980
  "Name the page 'Reset password' in a `Heading` with `level={1}`, and say in one line what happens next.",
@@ -3226,6 +4041,10 @@
3226
4041
  "kind": "rule",
3227
4042
  "level": "rule",
3228
4043
  "area": "state",
4044
+ "surface": [
4045
+ "site",
4046
+ "app"
4047
+ ],
3229
4048
  "situation": "A form was submitted and something is wrong.",
3230
4049
  "answer": "A problem with one field shows under that field, through the field's `error` and `errorText`. A problem with the whole request shows above the fields in `<Alert type=\"error\" variant=\"inline\" showCloseButton>`, so it stays until the person closes it or submits again. Its `onClose` clears the message; if it does not, the Alert comes back. While the request runs, the submit Button is `loading` and keeps its label. The form keeps what the person typed. The next submit clears the old messages. Messages are in sentence case. It is never a colored caption written by hand, and never the browser's `alert()`.",
3231
4050
  "why": "A message next to the problem tells the person what to fix without searching for it. Keeping what they typed means they fix one thing instead of starting again.",
@@ -3251,6 +4070,10 @@
3251
4070
  "kind": "design",
3252
4071
  "level": "organism",
3253
4072
  "area": "content",
4073
+ "surface": [
4074
+ "site",
4075
+ "app"
4076
+ ],
3254
4077
  "situation": "A page shows images small, and a person wants to see one larger without leaving the page.",
3255
4078
  "do": [
3256
4079
  "Show each image as a `LightboxThumbnail` and keep the open state and the index of the shown image in your page. For `gallery`, put the thumbnails in a `Grid compact`, two across on a phone.",
@@ -3327,6 +4150,9 @@
3327
4150
  "kind": "design",
3328
4151
  "level": "organism",
3329
4152
  "area": "confirm",
4153
+ "surface": [
4154
+ "app"
4155
+ ],
3330
4156
  "situation": "A person picks which items to bring in from another place, such as pages from a wiki.",
3331
4157
  "do": [
3332
4158
  "Put a search field at the top, then a count line, then the list of `Checkbox`es.",
@@ -3375,6 +4201,9 @@
3375
4201
  "kind": "design",
3376
4202
  "level": "organism",
3377
4203
  "area": "state",
4204
+ "surface": [
4205
+ "app"
4206
+ ],
3378
4207
  "situation": "A person submits a small form, such as a settings field, and the request ends. The three options are the three outcomes of one save: it worked in place, it failed, or the result is elsewhere.",
3379
4208
  "do": [
3380
4209
  "Show `loading` on the submit Button while the request runs, and keep its label.",
@@ -3450,12 +4279,15 @@
3450
4279
  "kind": "design",
3451
4280
  "level": "organism",
3452
4281
  "area": "settings",
4282
+ "surface": [
4283
+ "app"
4284
+ ],
3453
4285
  "situation": "A person connects the product to other tools, sees which ones are connected and disconnects them.",
3454
4286
  "do": [
3455
4287
  "Show each provider in a row: its logo, its name and one line on what connecting does: 'Link pull requests to tasks and close tasks when they merge.'",
3456
4288
  "Use `BrandIcon` for a logo it has, and a Lucide icon in `Icon` for the others. Both are decorative, because the name sits beside them.",
3457
4289
  "Show 'Connect' on a provider that is not connected, and its account beside 'Disconnect' once it is. Name the provider in each `aria-label`: 'Connect Slack'.",
3458
- "Show a `Tag` with `color=\"warning\"` that reads 'Needs attention', and a primary 'Reconnect', on a connection whose access ran out. Say in the line what is wrong.",
4290
+ "Show a dot `Tag` with `color=\"warning\"` that reads 'Needs reconnect', and a primary 'Reconnect', on a connection whose access ran out. Draw it as the case 'Status in a row' says. Say in the line what is wrong.",
3459
4291
  "Confirm 'Disconnect' in a small Modal, as the rule 'A confirm says exactly what will happen' says, because what it stops does not come back by itself. Title it with the verb and the thing: 'Disconnect Slack', or 'Disconnect acme-labs' for one account. Say what stops and that the person can connect again.",
3460
4292
  "Show `loading` on 'Connect' and 'Reconnect' while the sign-in runs, and keep the label. Disable the other Buttons until it ends.",
3461
4293
  "Group the accounts under their provider, with 'Add Account' on the provider's row, for a provider that holds several. Each account has its own 'Reconnect' and 'Disconnect'.",
@@ -3466,7 +4298,7 @@
3466
4298
  "Do not use an icon-only Button for Disconnect. It names no provider.",
3467
4299
  "Do not label a running Button 'Connecting…'. It keeps its label and shows `loading`.",
3468
4300
  "Do not disconnect on the first click.",
3469
- "Do not show red text as the only sign that access ran out. Add the 'Needs attention' Tag and a 'Reconnect' Button.",
4301
+ "Do not show red text as the only sign that access ran out. Add the 'Needs reconnect' Tag and a 'Reconnect' Button.",
3470
4302
  "Do not give each provider its own page section with a heading and no logo. Put them in one list."
3471
4303
  ],
3472
4304
  "native": "On Apple use a grouped `Form` with one `Section` per provider, 'Connect' as a Button, and 'Disconnect' in the `.destructive` role in a `confirmationDialog`. On Android use a list of rows that opens a confirm.",
@@ -3475,7 +4307,7 @@
3475
4307
  "id": "rows",
3476
4308
  "title": "One row per provider",
3477
4309
  "useWhen": "A few providers, and each one holds a single account.",
3478
- "source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport { Figma, Slack } from 'lucide-react';\nimport Modal from 'oneslash-design-system/components/modal';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport TableContainer from 'oneslash-design-system/components/tableContainer';\nimport TableRow from 'oneslash-design-system/components/tableRow';\nimport TableCell from 'oneslash-design-system/components/tableCell';\nimport BrandIcon from 'oneslash-design-system/components/brandIcon';\nimport Icon from 'oneslash-design-system/components/icon';\nimport Tag from 'oneslash-design-system/components/tag';\nimport Button from 'oneslash-design-system/components/button';\nimport { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';\n\ntype Provider = {\n id: string;\n name: string;\n /** One line on what connecting does. */\n does: string;\n /** What stops when it is disconnected, for the confirm. */\n stops: string;\n /** The account a person connects as, once connected. */\n account: string;\n brand?: 'google' | 'github';\n};\n\nconst providers: Provider[] = [\n { id: 'slack', name: 'Slack', does: 'Post the weekly digest and link previews in your channels.', stops: 'The weekly digest and link previews stop.', account: 'Acme workspace' },\n { id: 'github', name: 'GitHub', does: 'Link pull requests to tasks and close tasks when they merge.', stops: 'Pull requests stop linking to tasks.', account: 'acme', brand: 'github' },\n { id: 'google', name: 'Google Calendar', does: 'Show your calendar events beside your tasks.', stops: 'Calendar events stop showing beside tasks.', account: 'dana@acme.example', brand: 'google' },\n { id: 'figma', name: 'Figma', does: 'Show a preview when someone pastes a Figma link.', stops: 'Figma links stop showing a preview.', account: 'Acme team' },\n];\n\nfunction renderLogo(p: Provider) {\n if (p.brand) return <BrandIcon name={p.brand} size={24} />;\n return <Icon icon={p.id === 'slack' ? Slack : Figma} size=\"medium\" color=\"secondary\" />;\n}\n\nexport default function IntegrationsListRows() {\n // Opens with GitHub needing attention, as if its access ran out.\n const [connected, setConnected] = useState<Record<string, boolean>>({ github: true, google: true });\n const [needsAttention, setNeedsAttention] = useState<Record<string, boolean>>({ github: true });\n const [working, setWorking] = useState<string | null>(null);\n const [confirming, setConfirming] = useState<Provider | null>(null);\n const timers = useRef<ReturnType<typeof setTimeout>[]>([]);\n\n // Stops every request if the example goes away before they end.\n useEffect(() => () => timers.current.forEach(clearTimeout), []);\n\n // Stands in for the sign-in a provider asks for, and the request that follows.\n function later(callback: () => void, ms: number) {\n timers.current.push(setTimeout(callback, ms));\n }\n\n function handleConnect(p: Provider) {\n if (working) return;\n setWorking(p.id);\n later(() => {\n setWorking(null);\n setConnected((current) => ({ ...current, [p.id]: true }));\n setNeedsAttention((current) => ({ ...current, [p.id]: false }));\n }, 1200);\n }\n\n // Escape, a click outside and Cancel all close it, except while the request runs.\n function handleClose() {\n if (working) return;\n setConfirming(null);\n }\n\n function handleDisconnect(p: Provider) {\n if (working) return;\n setWorking(p.id);\n later(() => {\n setWorking(null);\n setConfirming(null);\n setConnected((current) => ({ ...current, [p.id]: false }));\n setNeedsAttention((current) => ({ ...current, [p.id]: false }));\n }, 1200);\n }\n\n return (\n <Center width=\"page\">\n <Stack gap=\"large\">\n <Stack gap=\"small\">\n <Heading level={1} size=\"h5\">Integrations</Heading>\n <Paragraph tone=\"secondary\" size=\"body2\" measure=\"none\">Connect the tools your team already uses.</Paragraph>\n </Stack>\n <TableContainer>\n {providers.map((p) => {\n const isConnected = Boolean(connected[p.id]);\n const attention = isConnected && Boolean(needsAttention[p.id]);\n const busy = working === p.id;\n return (\n <TableRow key={p.id}>\n <TableCell width=\"56px\">{renderLogo(p)}</TableCell>\n <TableCell>\n <Stack gap=\"small\">\n <Cluster gap=\"small\">\n <Heading level={2} size=\"subtitle1\">{p.name}</Heading>\n {attention && <Tag variant=\"contained\" size=\"small\" color=\"warning\" label=\"Needs attention\" />}\n </Cluster>\n <Paragraph tone=\"secondary\" size=\"body2\" measure=\"none\">\n {attention ? 'Access ran out. Reconnect to keep it working.' : p.does}\n </Paragraph>\n </Stack>\n </TableCell>\n {/* A fixed last column keeps every row's Buttons in one place, so they do not jump when they change. */}\n <TableCell width=\"340px\">\n {isConnected ? (\n <Cluster gap=\"small\" justify=\"end\">\n <Paragraph size=\"body2\" measure=\"none\">{p.account}</Paragraph>\n {attention && <Button size=\"small\" type=\"primary\" state={working && !busy ? 'disabled' : 'enabled'} label=\"Reconnect\" aria-label={`Reconnect ${p.name}`} loading={busy} onClickButton={() => handleConnect(p)} />}\n <Button size=\"small\" type=\"tertiary\" state={working ? 'disabled' : 'enabled'} label=\"Disconnect\" aria-label={`Disconnect ${p.name}`} onClickButton={() => setConfirming(p)} />\n </Cluster>\n ) : (\n <Cluster gap=\"small\" justify=\"end\">\n <Button size=\"small\" type=\"secondary\" state={working && !busy ? 'disabled' : 'enabled'} label=\"Connect\" aria-label={`Connect ${p.name}`} loading={busy} onClickButton={() => handleConnect(p)} />\n </Cluster>\n )}\n </TableCell>\n </TableRow>\n );\n })}\n </TableContainer>\n </Stack>\n <Modal\n isOpen={confirming !== null}\n size=\"small\"\n title={confirming ? `Disconnect ${confirming.name}` : 'Disconnect'}\n onClose={handleClose}\n actions={\n <>\n <Button size=\"small\" type=\"tertiary\" state={working ? 'disabled' : 'enabled'} label=\"Cancel\" onClickButton={handleClose} />\n <Button size=\"small\" type=\"primary\" color=\"danger\" state=\"enabled\" label=\"Disconnect\" loading={Boolean(working)} onClickButton={() => confirming && handleDisconnect(confirming)} />\n </>\n }\n >\n {confirming && (\n <Paragraph measure=\"none\">{confirming.stops} You can connect {confirming.name} again any time.</Paragraph>\n )}\n </Modal>\n </Center>\n );\n}\n",
4310
+ "source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport { Figma, Slack } from 'lucide-react';\nimport Modal from 'oneslash-design-system/components/modal';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport TableContainer from 'oneslash-design-system/components/tableContainer';\nimport TableRow from 'oneslash-design-system/components/tableRow';\nimport TableCell from 'oneslash-design-system/components/tableCell';\nimport BrandIcon from 'oneslash-design-system/components/brandIcon';\nimport Icon from 'oneslash-design-system/components/icon';\nimport Tag from 'oneslash-design-system/components/tag';\nimport Button from 'oneslash-design-system/components/button';\nimport { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';\n\ntype Provider = {\n id: string;\n name: string;\n /** One line on what connecting does. */\n does: string;\n /** What stops when it is disconnected, for the confirm. */\n stops: string;\n /** The account a person connects as, once connected. */\n account: string;\n brand?: 'google' | 'github';\n};\n\nconst providers: Provider[] = [\n { id: 'slack', name: 'Slack', does: 'Post the weekly digest and link previews in your channels.', stops: 'The weekly digest and link previews stop.', account: 'Acme workspace' },\n { id: 'github', name: 'GitHub', does: 'Link pull requests to tasks and close tasks when they merge.', stops: 'Pull requests stop linking to tasks.', account: 'acme', brand: 'github' },\n { id: 'google', name: 'Google Calendar', does: 'Show your calendar events beside your tasks.', stops: 'Calendar events stop showing beside tasks.', account: 'dana@acme.example', brand: 'google' },\n { id: 'figma', name: 'Figma', does: 'Show a preview when someone pastes a Figma link.', stops: 'Figma links stop showing a preview.', account: 'Acme team' },\n];\n\nfunction renderLogo(p: Provider) {\n if (p.brand) return <BrandIcon name={p.brand} size={24} />;\n return <Icon icon={p.id === 'slack' ? Slack : Figma} size=\"medium\" color=\"secondary\" />;\n}\n\nexport default function IntegrationsListRows() {\n // Opens with GitHub needing attention, as if its access ran out.\n const [connected, setConnected] = useState<Record<string, boolean>>({ github: true, google: true });\n const [needsAttention, setNeedsAttention] = useState<Record<string, boolean>>({ github: true });\n const [working, setWorking] = useState<string | null>(null);\n const [confirming, setConfirming] = useState<Provider | null>(null);\n const timers = useRef<ReturnType<typeof setTimeout>[]>([]);\n\n // Stops every request if the example goes away before they end.\n useEffect(() => () => timers.current.forEach(clearTimeout), []);\n\n // Stands in for the sign-in a provider asks for, and the request that follows.\n function later(callback: () => void, ms: number) {\n timers.current.push(setTimeout(callback, ms));\n }\n\n function handleConnect(p: Provider) {\n if (working) return;\n setWorking(p.id);\n later(() => {\n setWorking(null);\n setConnected((current) => ({ ...current, [p.id]: true }));\n setNeedsAttention((current) => ({ ...current, [p.id]: false }));\n }, 1200);\n }\n\n // Escape, a click outside and Cancel all close it, except while the request runs.\n function handleClose() {\n if (working) return;\n setConfirming(null);\n }\n\n function handleDisconnect(p: Provider) {\n if (working) return;\n setWorking(p.id);\n later(() => {\n setWorking(null);\n setConfirming(null);\n setConnected((current) => ({ ...current, [p.id]: false }));\n setNeedsAttention((current) => ({ ...current, [p.id]: false }));\n }, 1200);\n }\n\n return (\n <Center width=\"page\">\n <Stack gap=\"large\">\n <Stack gap=\"small\">\n <Heading level={1} size=\"h5\">Integrations</Heading>\n <Paragraph tone=\"secondary\" size=\"body2\" measure=\"none\">Connect the tools your team already uses.</Paragraph>\n </Stack>\n <TableContainer>\n {providers.map((p) => {\n const isConnected = Boolean(connected[p.id]);\n const attention = isConnected && Boolean(needsAttention[p.id]);\n const busy = working === p.id;\n return (\n <TableRow key={p.id}>\n <TableCell width=\"56px\">{renderLogo(p)}</TableCell>\n <TableCell>\n <Stack gap=\"small\">\n <Cluster gap=\"small\">\n <Heading level={2} size=\"subtitle1\">{p.name}</Heading>\n {attention && <Tag variant=\"dot\" size=\"small\" color=\"warning\" label=\"Needs reconnect\" />}\n </Cluster>\n <Paragraph tone=\"secondary\" size=\"body2\" measure=\"none\">\n {attention ? 'Access ran out. Reconnect to keep it working.' : p.does}\n </Paragraph>\n </Stack>\n </TableCell>\n {/* A fixed last column keeps every row's Buttons in one place, so they do not jump when they change. */}\n <TableCell width=\"340px\">\n {isConnected ? (\n <Cluster gap=\"small\" justify=\"end\">\n <Paragraph size=\"body2\" measure=\"none\">{p.account}</Paragraph>\n {attention && <Button size=\"small\" type=\"primary\" state={working && !busy ? 'disabled' : 'enabled'} label=\"Reconnect\" aria-label={`Reconnect ${p.name}`} loading={busy} onClickButton={() => handleConnect(p)} />}\n <Button size=\"small\" type=\"tertiary\" state={working ? 'disabled' : 'enabled'} label=\"Disconnect\" aria-label={`Disconnect ${p.name}`} onClickButton={() => setConfirming(p)} />\n </Cluster>\n ) : (\n <Cluster gap=\"small\" justify=\"end\">\n <Button size=\"small\" type=\"secondary\" state={working && !busy ? 'disabled' : 'enabled'} label=\"Connect\" aria-label={`Connect ${p.name}`} loading={busy} onClickButton={() => handleConnect(p)} />\n </Cluster>\n )}\n </TableCell>\n </TableRow>\n );\n })}\n </TableContainer>\n </Stack>\n <Modal\n isOpen={confirming !== null}\n size=\"small\"\n title={confirming ? `Disconnect ${confirming.name}` : 'Disconnect'}\n onClose={handleClose}\n actions={\n <>\n <Button size=\"small\" type=\"tertiary\" state={working ? 'disabled' : 'enabled'} label=\"Cancel\" onClickButton={handleClose} />\n <Button size=\"small\" type=\"primary\" color=\"danger\" state=\"enabled\" label=\"Disconnect\" loading={Boolean(working)} onClickButton={() => confirming && handleDisconnect(confirming)} />\n </>\n }\n >\n {confirming && (\n <Paragraph measure=\"none\">{confirming.stops} You can connect {confirming.name} again any time.</Paragraph>\n )}\n </Modal>\n </Center>\n );\n}\n",
3479
4311
  "uses": [
3480
4312
  "BrandIcon",
3481
4313
  "Button",
@@ -3496,7 +4328,7 @@
3496
4328
  "id": "nested",
3497
4329
  "title": "Accounts under each provider",
3498
4330
  "useWhen": "A provider can hold several accounts or teams, such as the organizations of one GitHub login.",
3499
- "source": "'use client';\nimport { Fragment, useEffect, useRef, useState } from 'react';\nimport { Slack } from 'lucide-react';\nimport Modal from 'oneslash-design-system/components/modal';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport TableContainer from 'oneslash-design-system/components/tableContainer';\nimport TableRow from 'oneslash-design-system/components/tableRow';\nimport TableCell from 'oneslash-design-system/components/tableCell';\nimport BrandIcon from 'oneslash-design-system/components/brandIcon';\nimport Icon from 'oneslash-design-system/components/icon';\nimport Tag from 'oneslash-design-system/components/tag';\nimport Button from 'oneslash-design-system/components/button';\nimport { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';\n\ntype Account = { id: string; name: string; detail: string; attention?: boolean };\ntype Provider = {\n id: string;\n name: string;\n /** One line on what connecting does. */\n does: string;\n /** What stops when one account is disconnected, for the confirm. */\n stops: string;\n brand?: 'github';\n accounts: Account[];\n};\n\nconst firstProviders: Provider[] = [\n {\n id: 'github',\n name: 'GitHub',\n does: 'Link pull requests to tasks and close tasks when they merge.',\n stops: 'Pull requests from it stop linking to tasks.',\n brand: 'github',\n accounts: [\n { id: 'acme', name: 'acme', detail: 'Connected Oct 3 · 14 repositories' },\n { id: 'acme-labs', name: 'acme-labs', detail: 'Access ran out. Reconnect to keep it working.', attention: true },\n ],\n },\n {\n id: 'slack',\n name: 'Slack',\n does: 'Post the weekly digest and link previews in your channels.',\n stops: 'The digest and link previews stop in its channels.',\n accounts: [],\n },\n];\n\nexport default function IntegrationsListNested() {\n const [providers, setProviders] = useState(firstProviders);\n // Which Button is working: it shows `loading`, and every other Button waits.\n const [working, setWorking] = useState<string | null>(null);\n const [confirming, setConfirming] = useState<{ provider: Provider; account: Account } | null>(null);\n const timers = useRef<ReturnType<typeof setTimeout>[]>([]);\n\n // Stops every request if the example goes away before they end.\n useEffect(() => () => timers.current.forEach(clearTimeout), []);\n\n // Stands in for the sign-in a provider asks for, and the request that follows.\n function later(callback: () => void, ms: number) {\n timers.current.push(setTimeout(callback, ms));\n }\n\n function update(providerId: string, change: (accounts: Account[]) => Account[]) {\n setProviders((list) => list.map((p) => (p.id === providerId ? { ...p, accounts: change(p.accounts) } : p)));\n }\n\n // 'Connect' and 'Add Account' both start a sign-in, and the account that comes back joins its provider.\n function handleAdd(p: Provider) {\n if (working) return;\n setWorking(`add-${p.id}`);\n later(() => {\n setWorking(null);\n const next: Account = p.id === 'github'\n ? { id: 'acme-design', name: 'acme-design', detail: 'Connected today · 3 repositories' }\n : { id: 'acme-slack', name: 'Acme', detail: 'Connected today · 6 channels' };\n update(p.id, (accounts) => [...accounts, next]);\n }, 1200);\n }\n\n function handleReconnect(p: Provider, a: Account) {\n if (working) return;\n setWorking(`reconnect-${a.id}`);\n later(() => {\n setWorking(null);\n update(p.id, (accounts) => accounts.map((x) => (x.id === a.id ? { ...x, detail: 'Connected today · 5 repositories', attention: false } : x)));\n }, 1200);\n }\n\n // Escape, a click outside and Cancel all close it, except while the request runs.\n function handleClose() {\n if (working) return;\n setConfirming(null);\n }\n\n function handleDisconnect(p: Provider, a: Account) {\n if (working) return;\n setWorking(`remove-${a.id}`);\n later(() => {\n setWorking(null);\n setConfirming(null);\n update(p.id, (accounts) => accounts.filter((x) => x.id !== a.id));\n }, 1200);\n }\n\n return (\n <Center width=\"page\">\n <Stack gap=\"large\">\n <Stack gap=\"small\">\n <Heading level={1} size=\"h5\">Integrations</Heading>\n <Paragraph tone=\"secondary\" size=\"body2\" measure=\"none\">A tool can hold several accounts. Each one connects and disconnects on its own.</Paragraph>\n </Stack>\n <TableContainer>\n {providers.map((p) => (\n <Fragment key={p.id}>\n <TableRow>\n <TableCell width=\"56px\">\n {p.brand ? <BrandIcon name={p.brand} size={24} /> : <Icon icon={Slack} size=\"medium\" color=\"secondary\" />}\n </TableCell>\n <TableCell>\n <Stack gap=\"small\">\n <Heading level={2} size=\"subtitle1\">{p.name}</Heading>\n <Paragraph tone=\"secondary\" size=\"body2\" measure=\"none\">{p.does}</Paragraph>\n </Stack>\n </TableCell>\n {/* A fixed last column keeps every row's Buttons in one place, so they do not jump when they change. */}\n <TableCell width=\"240px\">\n <Cluster justify=\"end\">\n <Button\n size=\"small\"\n type=\"secondary\"\n state={working && working !== `add-${p.id}` ? 'disabled' : 'enabled'}\n label={p.accounts.length === 0 ? 'Connect' : 'Add Account'}\n aria-label={p.accounts.length === 0 ? `Connect ${p.name}` : `Add Account to ${p.name}`}\n loading={working === `add-${p.id}`}\n onClickButton={() => handleAdd(p)}\n />\n </Cluster>\n </TableCell>\n </TableRow>\n {/* The accounts sit under their provider, indented by an empty first cell. */}\n {p.accounts.map((a) => (\n <TableRow key={a.id}>\n <TableCell width=\"56px\">{''}</TableCell>\n <TableCell>\n <Stack gap=\"small\">\n <Cluster gap=\"small\">\n <Heading level={3} size=\"subtitle1\">{a.name}</Heading>\n {a.attention && <Tag variant=\"contained\" size=\"small\" color=\"warning\" label=\"Needs attention\" />}\n </Cluster>\n <Paragraph tone=\"secondary\" size=\"body2\" measure=\"none\">{a.detail}</Paragraph>\n </Stack>\n </TableCell>\n <TableCell width=\"240px\">\n <Cluster gap=\"small\" justify=\"end\">\n {a.attention && (\n <Button size=\"small\" type=\"primary\" state={working && working !== `reconnect-${a.id}` ? 'disabled' : 'enabled'} label=\"Reconnect\" aria-label={`Reconnect ${a.name}`} loading={working === `reconnect-${a.id}`} onClickButton={() => handleReconnect(p, a)} />\n )}\n <Button size=\"small\" type=\"tertiary\" state={working ? 'disabled' : 'enabled'} label=\"Disconnect\" aria-label={`Disconnect ${a.name}`} onClickButton={() => setConfirming({ provider: p, account: a })} />\n </Cluster>\n </TableCell>\n </TableRow>\n ))}\n </Fragment>\n ))}\n </TableContainer>\n </Stack>\n <Modal\n isOpen={confirming !== null}\n size=\"small\"\n title={confirming ? `Disconnect ${confirming.account.name}` : 'Disconnect'}\n onClose={handleClose}\n actions={\n <>\n <Button size=\"small\" type=\"tertiary\" state={working ? 'disabled' : 'enabled'} label=\"Cancel\" onClickButton={handleClose} />\n <Button size=\"small\" type=\"primary\" color=\"danger\" state=\"enabled\" label=\"Disconnect\" loading={Boolean(working)} onClickButton={() => confirming && handleDisconnect(confirming.provider, confirming.account)} />\n </>\n }\n >\n {confirming && (\n <Paragraph measure=\"none\">\n {confirming.provider.stops} You can connect {confirming.account.name} again any time.\n </Paragraph>\n )}\n </Modal>\n </Center>\n );\n}\n",
4331
+ "source": "'use client';\nimport { Fragment, useEffect, useRef, useState } from 'react';\nimport { Slack } from 'lucide-react';\nimport Modal from 'oneslash-design-system/components/modal';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport TableContainer from 'oneslash-design-system/components/tableContainer';\nimport TableRow from 'oneslash-design-system/components/tableRow';\nimport TableCell from 'oneslash-design-system/components/tableCell';\nimport BrandIcon from 'oneslash-design-system/components/brandIcon';\nimport Icon from 'oneslash-design-system/components/icon';\nimport Tag from 'oneslash-design-system/components/tag';\nimport Button from 'oneslash-design-system/components/button';\nimport { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';\n\ntype Account = { id: string; name: string; detail: string; attention?: boolean };\ntype Provider = {\n id: string;\n name: string;\n /** One line on what connecting does. */\n does: string;\n /** What stops when one account is disconnected, for the confirm. */\n stops: string;\n brand?: 'github';\n accounts: Account[];\n};\n\nconst firstProviders: Provider[] = [\n {\n id: 'github',\n name: 'GitHub',\n does: 'Link pull requests to tasks and close tasks when they merge.',\n stops: 'Pull requests from it stop linking to tasks.',\n brand: 'github',\n accounts: [\n { id: 'acme', name: 'acme', detail: 'Connected Oct 3 · 14 repositories' },\n { id: 'acme-labs', name: 'acme-labs', detail: 'Access ran out. Reconnect to keep it working.', attention: true },\n ],\n },\n {\n id: 'slack',\n name: 'Slack',\n does: 'Post the weekly digest and link previews in your channels.',\n stops: 'The digest and link previews stop in its channels.',\n accounts: [],\n },\n];\n\nexport default function IntegrationsListNested() {\n const [providers, setProviders] = useState(firstProviders);\n // Which Button is working: it shows `loading`, and every other Button waits.\n const [working, setWorking] = useState<string | null>(null);\n const [confirming, setConfirming] = useState<{ provider: Provider; account: Account } | null>(null);\n const timers = useRef<ReturnType<typeof setTimeout>[]>([]);\n\n // Stops every request if the example goes away before they end.\n useEffect(() => () => timers.current.forEach(clearTimeout), []);\n\n // Stands in for the sign-in a provider asks for, and the request that follows.\n function later(callback: () => void, ms: number) {\n timers.current.push(setTimeout(callback, ms));\n }\n\n function update(providerId: string, change: (accounts: Account[]) => Account[]) {\n setProviders((list) => list.map((p) => (p.id === providerId ? { ...p, accounts: change(p.accounts) } : p)));\n }\n\n // 'Connect' and 'Add Account' both start a sign-in, and the account that comes back joins its provider.\n function handleAdd(p: Provider) {\n if (working) return;\n setWorking(`add-${p.id}`);\n later(() => {\n setWorking(null);\n const next: Account = p.id === 'github'\n ? { id: 'acme-design', name: 'acme-design', detail: 'Connected today · 3 repositories' }\n : { id: 'acme-slack', name: 'Acme', detail: 'Connected today · 6 channels' };\n update(p.id, (accounts) => [...accounts, next]);\n }, 1200);\n }\n\n function handleReconnect(p: Provider, a: Account) {\n if (working) return;\n setWorking(`reconnect-${a.id}`);\n later(() => {\n setWorking(null);\n update(p.id, (accounts) => accounts.map((x) => (x.id === a.id ? { ...x, detail: 'Connected today · 5 repositories', attention: false } : x)));\n }, 1200);\n }\n\n // Escape, a click outside and Cancel all close it, except while the request runs.\n function handleClose() {\n if (working) return;\n setConfirming(null);\n }\n\n function handleDisconnect(p: Provider, a: Account) {\n if (working) return;\n setWorking(`remove-${a.id}`);\n later(() => {\n setWorking(null);\n setConfirming(null);\n update(p.id, (accounts) => accounts.filter((x) => x.id !== a.id));\n }, 1200);\n }\n\n return (\n <Center width=\"page\">\n <Stack gap=\"large\">\n <Stack gap=\"small\">\n <Heading level={1} size=\"h5\">Integrations</Heading>\n <Paragraph tone=\"secondary\" size=\"body2\" measure=\"none\">A tool can hold several accounts. Each one connects and disconnects on its own.</Paragraph>\n </Stack>\n <TableContainer>\n {providers.map((p) => (\n <Fragment key={p.id}>\n <TableRow>\n <TableCell width=\"56px\">\n {p.brand ? <BrandIcon name={p.brand} size={24} /> : <Icon icon={Slack} size=\"medium\" color=\"secondary\" />}\n </TableCell>\n <TableCell>\n <Stack gap=\"small\">\n <Heading level={2} size=\"subtitle1\">{p.name}</Heading>\n <Paragraph tone=\"secondary\" size=\"body2\" measure=\"none\">{p.does}</Paragraph>\n </Stack>\n </TableCell>\n {/* A fixed last column keeps every row's Buttons in one place, so they do not jump when they change. */}\n <TableCell width=\"240px\">\n <Cluster justify=\"end\">\n <Button\n size=\"small\"\n type=\"secondary\"\n state={working && working !== `add-${p.id}` ? 'disabled' : 'enabled'}\n label={p.accounts.length === 0 ? 'Connect' : 'Add Account'}\n aria-label={p.accounts.length === 0 ? `Connect ${p.name}` : `Add Account to ${p.name}`}\n loading={working === `add-${p.id}`}\n onClickButton={() => handleAdd(p)}\n />\n </Cluster>\n </TableCell>\n </TableRow>\n {/* The accounts sit under their provider, indented by an empty first cell. */}\n {p.accounts.map((a) => (\n <TableRow key={a.id}>\n <TableCell width=\"56px\">{''}</TableCell>\n <TableCell>\n <Stack gap=\"small\">\n <Cluster gap=\"small\">\n <Heading level={3} size=\"subtitle1\">{a.name}</Heading>\n {a.attention && <Tag variant=\"dot\" size=\"small\" color=\"warning\" label=\"Needs reconnect\" />}\n </Cluster>\n <Paragraph tone=\"secondary\" size=\"body2\" measure=\"none\">{a.detail}</Paragraph>\n </Stack>\n </TableCell>\n <TableCell width=\"240px\">\n <Cluster gap=\"small\" justify=\"end\">\n {a.attention && (\n <Button size=\"small\" type=\"primary\" state={working && working !== `reconnect-${a.id}` ? 'disabled' : 'enabled'} label=\"Reconnect\" aria-label={`Reconnect ${a.name}`} loading={working === `reconnect-${a.id}`} onClickButton={() => handleReconnect(p, a)} />\n )}\n <Button size=\"small\" type=\"tertiary\" state={working ? 'disabled' : 'enabled'} label=\"Disconnect\" aria-label={`Disconnect ${a.name}`} onClickButton={() => setConfirming({ provider: p, account: a })} />\n </Cluster>\n </TableCell>\n </TableRow>\n ))}\n </Fragment>\n ))}\n </TableContainer>\n </Stack>\n <Modal\n isOpen={confirming !== null}\n size=\"small\"\n title={confirming ? `Disconnect ${confirming.account.name}` : 'Disconnect'}\n onClose={handleClose}\n actions={\n <>\n <Button size=\"small\" type=\"tertiary\" state={working ? 'disabled' : 'enabled'} label=\"Cancel\" onClickButton={handleClose} />\n <Button size=\"small\" type=\"primary\" color=\"danger\" state=\"enabled\" label=\"Disconnect\" loading={Boolean(working)} onClickButton={() => confirming && handleDisconnect(confirming.provider, confirming.account)} />\n </>\n }\n >\n {confirming && (\n <Paragraph measure=\"none\">\n {confirming.provider.stops} You can connect {confirming.account.name} again any time.\n </Paragraph>\n )}\n </Modal>\n </Center>\n );\n}\n",
3500
4332
  "uses": [
3501
4333
  "BrandIcon",
3502
4334
  "Button",
@@ -3521,6 +4353,9 @@
3521
4353
  "kind": "design",
3522
4354
  "level": "organism",
3523
4355
  "area": "confirm",
4356
+ "surface": [
4357
+ "app"
4358
+ ],
3524
4359
  "situation": "A person invites someone to join a workspace.",
3525
4360
  "do": [
3526
4361
  "Title the Modal 'Invite Member' and label its action 'Invite', after 'Cancel'.",
@@ -3601,6 +4436,9 @@
3601
4436
  "kind": "design",
3602
4437
  "level": "organism",
3603
4438
  "area": "dashboard",
4439
+ "surface": [
4440
+ "app"
4441
+ ],
3604
4442
  "situation": "A billing page lists what the workspace has paid, so an admin can find an invoice, check an amount and keep a copy.",
3605
4443
  "do": [
3606
4444
  "Follow the rule 'A number shows its unit and never shows 0 for unknown'.",
@@ -3677,6 +4515,9 @@
3677
4515
  "kind": "design",
3678
4516
  "level": "organism",
3679
4517
  "area": "marketing",
4518
+ "surface": [
4519
+ "site"
4520
+ ],
3680
4521
  "situation": "A marketing page opens by saying what the product is and asking for one thing.",
3681
4522
  "do": [
3682
4523
  "Follow the rule 'A marketing page asks for one main action, in the same words everywhere'.",
@@ -3736,6 +4577,9 @@
3736
4577
  "kind": "design",
3737
4578
  "level": "organism",
3738
4579
  "area": "dashboard",
4580
+ "surface": [
4581
+ "app"
4582
+ ],
3739
4583
  "situation": "A dashboard shows who did the most of something over its range, such as who left the most comments this week.",
3740
4584
  "do": [
3741
4585
  "Follow the rule 'A number shows its unit and never shows 0 for unknown'.",
@@ -3809,6 +4653,9 @@
3809
4653
  "kind": "design",
3810
4654
  "level": "page",
3811
4655
  "area": "content",
4656
+ "surface": [
4657
+ "site"
4658
+ ],
3812
4659
  "situation": "A person reads the terms or the privacy policy to find one answer in it, or reads all of it before they agree.",
3813
4660
  "do": [
3814
4661
  "Put an info `Alert` first with the words 'Sample text. This is not a real agreement.' on any page whose text is an example. Set `autoDismiss={false}`, so it stays. A real page has no such line and uses text written for the company.",
@@ -3853,6 +4700,9 @@
3853
4700
  "kind": "design",
3854
4701
  "level": "organism",
3855
4702
  "area": "state",
4703
+ "surface": [
4704
+ "app"
4705
+ ],
3856
4706
  "situation": "A list or a section could not load.",
3857
4707
  "do": [
3858
4708
  "Say what could not load: 'Could not load projects'.",
@@ -3907,6 +4757,9 @@
3907
4757
  "kind": "design",
3908
4758
  "level": "organism",
3909
4759
  "area": "confirm",
4760
+ "surface": [
4761
+ "app"
4762
+ ],
3910
4763
  "situation": "A person chooses Log Out.",
3911
4764
  "do": [
3912
4765
  "Call it 'Log Out' everywhere: the menu item, the Modal title and the action Button. The way back in is 'Log In'.",
@@ -3946,6 +4799,9 @@
3946
4799
  "kind": "design",
3947
4800
  "level": "page",
3948
4801
  "area": "auth",
4802
+ "surface": [
4803
+ "app"
4804
+ ],
3949
4805
  "situation": "A person who already has an account opens the product and is not logged in.",
3950
4806
  "do": [
3951
4807
  "Show a problem with one field under that field.",
@@ -4045,6 +4901,9 @@
4045
4901
  "kind": "design",
4046
4902
  "level": "page",
4047
4903
  "area": "content",
4904
+ "surface": [
4905
+ "site"
4906
+ ],
4048
4907
  "situation": "A person reads one long piece, such as a post, a case study or a method, from the top down, and may come back to part of it.",
4049
4908
  "do": [
4050
4909
  "Use `PageHeader` with `level={1}`, a `title`, a `lede` of one or two sentences and `facts` for the date, the reading time and the author. The title is the one level 1 heading.",
@@ -4112,6 +4971,9 @@
4112
4971
  "kind": "design",
4113
4972
  "level": "page",
4114
4973
  "area": "shell",
4974
+ "surface": [
4975
+ "app"
4976
+ ],
4115
4977
  "situation": "A person opens an item from a list, such as a message or a report, and reads or acts on it.",
4116
4978
  "do": [
4117
4979
  "Follow the rule 'On a phone, a sidebar opens as a drawer and a list opens its detail'.",
@@ -4175,6 +5037,9 @@
4175
5037
  "kind": "design",
4176
5038
  "level": "organism",
4177
5039
  "area": "settings",
5040
+ "surface": [
5041
+ "app"
5042
+ ],
4178
5043
  "situation": "An admin sees who is in the workspace, changes their roles, removes people and invites more.",
4179
5044
  "do": [
4180
5045
  "Show each member in a row: `UserImage` with `decorative`, the name, the email and the role. The avatar sits beside the same name, so it is hidden from a screen reader.",
@@ -4271,6 +5136,10 @@
4271
5136
  "kind": "design",
4272
5137
  "level": "organism",
4273
5138
  "area": "chat",
5139
+ "surface": [
5140
+ "app",
5141
+ "agent"
5142
+ ],
4274
5143
  "situation": "A person types @ in the message box to name someone, or the agent.",
4275
5144
  "do": [
4276
5145
  "Open the list when the person types @ at the start of the text or after a space. A bare @ opens it, and each letter after it narrows it.",
@@ -4322,6 +5191,10 @@
4322
5191
  "kind": "design",
4323
5192
  "level": "organism",
4324
5193
  "area": "chat",
5194
+ "surface": [
5195
+ "app",
5196
+ "agent"
5197
+ ],
4325
5198
  "situation": "A person acts on one message: reacts to it, copies it, edits or deletes it.",
4326
5199
  "do": [
4327
5200
  "Put the actions in the Message's `actions`. They show while the pointer is on the row or focus is in it.",
@@ -4412,6 +5285,9 @@
4412
5285
  "kind": "design",
4413
5286
  "level": "organism",
4414
5287
  "area": "chat",
5288
+ "surface": [
5289
+ "app"
5290
+ ],
4415
5291
  "situation": "A person adds files to a message, and people open the files in a message that was sent.",
4416
5292
  "do": [
4417
5293
  "Show each waiting file as a `FileChip` in the Composer's `above` slot, with `onRemove`.",
@@ -4489,6 +5365,10 @@
4489
5365
  "kind": "design",
4490
5366
  "level": "organism",
4491
5367
  "area": "chat",
5368
+ "surface": [
5369
+ "app",
5370
+ "agent"
5371
+ ],
4492
5372
  "situation": "A person writes a message at the bottom of a thread.",
4493
5373
  "do": [
4494
5374
  "Use `Composer` under the thread, with an `aria-label`, since it has no visible label.",
@@ -4501,10 +5381,10 @@
4501
5381
  "Pass `onStop` in a conversation with the agent only, so Send becomes Stop.",
4502
5382
  "Show the agent's name, its 'Agent' `Tag`, the model line, the seconds so far and a `StepList` on the progress row. The case 'Agent at work' has the full pattern.",
4503
5383
  "Show 'Working for 12 seconds' in the progress row's body, above the steps.",
4504
- "Show 'Stop' as `loading` until the run has ended. Then 'Stopped. Nothing was changed.' replaces the progress row in the same place.",
5384
+ "Show 'Stop' as `loading` until the run has ended. Then the row keeps its steps and says what was done, as the case 'Agent at work' says.",
4505
5385
  "Move focus to the message box when Stop goes away.",
4506
5386
  "Announce the progress row politely to screen readers: the app wraps the changing part in a polite live region, since the row has none.",
4507
- "Show an inline error Alert above the message box when a message fails to send, as the rule 'A form error shows next to the problem' says. Keep the text so it can be sent again.",
5387
+ "Show a message that did not send in the thread with its reason under it, as the case 'Message that did not send' says. While the app is offline, a warning Alert sits above the message box.",
4508
5388
  "Keep the draft when the person leaves the thread, and show it again when they come back."
4509
5389
  ],
4510
5390
  "dont": [
@@ -4536,7 +5416,7 @@
4536
5416
  "id": "with-tools",
4537
5417
  "title": "Composer with tools",
4538
5418
  "useWhen": "The person can attach files and call the agent.",
4539
- "source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport { Bot } from 'lucide-react';\nimport Message from 'oneslash-design-system/components/message';\nimport UserImage from 'oneslash-design-system/components/userImage';\nimport Tag from 'oneslash-design-system/components/tag';\nimport TimeStamp from 'oneslash-design-system/components/timeStamp';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Composer from 'oneslash-design-system/components/composer';\nimport FileChip from 'oneslash-design-system/components/fileChip';\nimport Button from 'oneslash-design-system/components/button';\nimport IconButton from 'oneslash-design-system/components/iconButton';\nimport Tooltip from 'oneslash-design-system/components/tooltip';\nimport StepList from 'oneslash-design-system/components/stepList';\nimport { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';\n\n// A real app reads this from the session.\nconst me = 'Dana Lee';\nconst agentName = 'Acme Agent';\n\ntype Attachment = { name: string; kind: string; size: string };\n// `progress` marks the agent's row while its run is live. The same row later holds the note or the reply.\ntype Row = { id: string; from: string; agent?: boolean; at: Date; text: string; file?: Attachment; progress?: boolean };\n\nconst sampleFile: Attachment = { name: 'Launch email.pdf', kind: 'PDF', size: '240 KB' };\n\nconst firstThread: Row[] = [\n { id: 'm1', from: 'Ben Carter', at: new Date('2025-01-15T11:40:00Z'), text: 'The launch email is ready for review.' },\n { id: 'm2', from: 'Omar Reyes', at: new Date('2025-01-15T11:42:00Z'), text: 'I will read it after lunch.' },\n];\n\nconst FIVE_MINUTES = 5 * 60 * 1000;\n\n// A follow-on row: the same sender as the row above, less than 5 minutes later and on the same day.\nfunction followsOn(rows: Row[], i: number) {\n const prev = rows[i - 1];\n return (\n !!prev &&\n prev.from === rows[i].from &&\n rows[i].at.getTime() - prev.at.getTime() < FIVE_MINUTES &&\n rows[i].at.toDateString() === prev.at.toDateString()\n );\n}\n\nfunction secondsLine(seconds: number) {\n return `Working for ${seconds} ${seconds === 1 ? 'second' : 'seconds'}`;\n}\n\n// The agent's marks, as the rule 'An agent says what it is' says.\nfunction agentMeta(at: Date) {\n return (\n <>\n <Tag variant=\"contained\" size=\"small\" label=\"Agent\" />\n <TimeStamp createdAt={at} dateFormat=\"absolute\" data=\"time\" />\n <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">Model name</Paragraph>\n </>\n );\n}\n\nexport default function MessageComposerWithTools() {\n const [thread, setThread] = useState(firstThread);\n // A real app keeps the draft per thread, so it is still there when the person comes back.\n const [text, setText] = useState('');\n const [file, setFile] = useState<Attachment | null>(null);\n const [mentionAgent, setMentionAgent] = useState(false);\n // The agent's run while it works: the id of its row in the thread, and whether a stop has been asked for.\n const [run, setRun] = useState<{ rowId: string; stopping: boolean } | null>(null);\n const [seconds, setSeconds] = useState(0);\n const runTimer = useRef<ReturnType<typeof setTimeout>>();\n const cancel = useRef<ReturnType<typeof setTimeout>>();\n const tick = useRef<ReturnType<typeof setInterval>>();\n const field = useRef<HTMLTextAreaElement>(null);\n\n // On unmount it stops the agent's run, its clock and the cancel request.\n useEffect(() => () => {\n clearTimeout(runTimer.current);\n clearTimeout(cancel.current);\n clearInterval(tick.current);\n }, []);\n\n // The run is over: its own row, in the same place and with the same time, now holds the reply or the note.\n function endRun(rowId: string, text: string) {\n clearTimeout(runTimer.current);\n clearInterval(tick.current);\n setRun(null);\n setThread((rows) => rows.map((m) => (m.id === rowId ? { ...m, text, progress: false } : m)));\n }\n\n function addRow(row: Omit<Row, 'id'>) {\n setThread((rows) => [...rows, { ...row, id: `m${rows.length + 1}` }]);\n }\n\n // A real app opens the file picker here; this one attaches a sample file.\n function attach() {\n setFile(sampleFile);\n }\n\n function removeFile() {\n setFile(null);\n field.current?.focus();\n }\n\n // Enter sends and Shift+Enter adds a line. The Composer calls this only when there is something to send.\n function send() {\n // A real app sends the message to the server here and shows it at once.\n addRow({ from: me, at: new Date(), text: text.trim(), file: file ?? undefined });\n setText('');\n setFile(null);\n // One run at a time: a real app queues a second call to the agent.\n if (!mentionAgent || run) return;\n // The run gets one row, added now where the reply will appear. Messages sent during the run go below it.\n const startedAt = new Date();\n const rowId = `run-${startedAt.getTime()}`;\n setThread((rows) => [...rows, { id: rowId, from: agentName, agent: true, at: startedAt, text: '', progress: true }]);\n setRun({ rowId, stopping: false });\n setSeconds(0);\n tick.current = setInterval(() => setSeconds((s) => s + 1), 1000);\n // Stands in for the agent's run.\n runTimer.current = setTimeout(() => {\n endRun(rowId, 'The email reads well. The pricing link in the second paragraph points to last year\\'s page.');\n }, 3000);\n }\n\n // Stop asks the server to end the run, and shows loading until it has. Only then does the note that it\n // stopped replace the progress row, in the same row. Stop is gone, so focus goes to the message box.\n function stop() {\n if (!run || run.stopping) return;\n clearTimeout(runTimer.current);\n setRun({ ...run, stopping: true });\n // Stands in for the request to the server.\n cancel.current = setTimeout(() => {\n endRun(run.rowId, 'Stopped. Nothing was changed.');\n field.current?.focus();\n }, 1200);\n }\n\n return (\n <Center width=\"page\">\n <Stack gap=\"large\">\n <Heading level={1} size=\"h5\">Launch plan</Heading>\n {/* A real app gives the list that holds the rows role=\"log\". */}\n <Stack gap=\"small\">\n {thread.map((m, i) =>\n m.progress && run?.rowId === m.id ? (\n // While the agent works, its row shows where the reply will appear: the seconds so far,\n // the steps, and the only Stop. The case 'Agent at work' has the full pattern.\n <Message\n key={m.id}\n aria-label={`${m.from}, agent`}\n avatar={<UserImage userHandle={m.from} icon={Bot} decorative />}\n name={m.from}\n meta={agentMeta(m.at)}\n footer={\n // It shows loading while the run is stopping.\n <Cluster>\n <Button size=\"small\" type=\"secondary\" state=\"enabled\" label=\"Stop\" loading={run.stopping} onClickButton={stop} />\n </Cluster>\n }\n >\n {/* A real app wraps this part in a polite live region, since StepList has none. */}\n <Stack gap=\"medium\">\n <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">{secondsLine(seconds)}</Paragraph>\n <StepList\n aria-label=\"Acme Agent's steps\"\n steps={[\n { label: 'Read the thread', status: 'done' },\n { label: 'Checking the links in the email', status: 'running' },\n ]}\n />\n </Stack>\n </Message>\n ) : (\n <Message\n key={m.id}\n aria-label={m.agent ? `${m.from}, agent` : m.from}\n compact={followsOn(thread, i)}\n avatar={m.agent ? <UserImage userHandle={m.from} icon={Bot} decorative /> : <UserImage userHandle={m.from} decorative />}\n name={m.from}\n meta={m.agent ? agentMeta(m.at) : <TimeStamp createdAt={m.at} dateFormat=\"absolute\" data=\"time\" />}\n // A sent file opens when its chip is pressed. A real app links to the stored file.\n footer={m.file ? <FileChip name={m.file.name} kind={m.file.kind} meta={m.file.size} href=\"/files/launch-email.pdf\" openInNewTab /> : undefined}\n >\n {m.text && <Paragraph measure=\"none\">{m.text}</Paragraph>}\n </Message>\n ),\n )}\n </Stack>\n {/* On a touch screen, pass submitOnEnter={false} so Return adds a line. */}\n <Composer\n ref={field}\n id=\"message-composer-tools-message\"\n aria-label=\"Message\"\n // The placeholder says who will read the message.\n placeholder={mentionAgent ? `Message ${agentName}` : 'Message the team'}\n value={text}\n onChange={setText}\n onSubmit={send}\n canSubmit={text.trim() !== '' || file !== null}\n // The Composer keeps Send while the agent works, so a message to people still goes. Stop is on the agent's row.\n above={file ? <FileChip name={file.name} kind={file.kind} meta={file.size} onRemove={removeFile} /> : undefined}\n tools={\n <>\n <Tooltip title=\"Attach files\">\n <IconButton color=\"iconOnly\" state=\"enabled\" size=\"small\" iconName=\"Paperclip\" ariaLabel=\"Attach files\" onClick={attach} />\n </Tooltip>\n <Tooltip title=\"Mention the agent\">\n <IconButton\n color=\"iconOnly\"\n state={mentionAgent ? 'selected' : 'enabled'}\n size=\"small\"\n icon={Bot}\n ariaLabel=\"Mention the agent\"\n aria-pressed={mentionAgent}\n onClick={() => setMentionAgent((on) => !on)}\n />\n </Tooltip>\n </>\n }\n />\n </Stack>\n </Center>\n );\n}\n",
5419
+ "source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport { Bot } from 'lucide-react';\nimport Message from 'oneslash-design-system/components/message';\nimport UserImage from 'oneslash-design-system/components/userImage';\nimport Tag from 'oneslash-design-system/components/tag';\nimport TimeStamp from 'oneslash-design-system/components/timeStamp';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Composer from 'oneslash-design-system/components/composer';\nimport FileChip from 'oneslash-design-system/components/fileChip';\nimport Button from 'oneslash-design-system/components/button';\nimport IconButton from 'oneslash-design-system/components/iconButton';\nimport Tooltip from 'oneslash-design-system/components/tooltip';\nimport StepList from 'oneslash-design-system/components/stepList';\nimport { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';\n\n// A real app reads this from the session.\nconst me = 'Dana Lee';\nconst agentName = 'Acme Agent';\n\ntype Attachment = { name: string; kind: string; size: string };\n// `progress` marks the agent's row while its run is live. The same row later holds the reply, or the steps and a note.\ntype Row = { id: string; from: string; agent?: boolean; at: Date; text: string; file?: Attachment; progress?: boolean; stopped?: boolean };\n\nconst sampleFile: Attachment = { name: 'Launch email.pdf', kind: 'PDF', size: '240 KB' };\n\nconst firstThread: Row[] = [\n { id: 'm1', from: 'Ben Carter', at: new Date('2025-01-15T11:40:00Z'), text: 'The launch email is ready for review.' },\n { id: 'm2', from: 'Omar Reyes', at: new Date('2025-01-15T11:42:00Z'), text: 'I will read it after lunch.' },\n];\n\nconst FIVE_MINUTES = 5 * 60 * 1000;\n\n// A follow-on row: the same sender as the row above, less than 5 minutes later and on the same day.\nfunction followsOn(rows: Row[], i: number) {\n const prev = rows[i - 1];\n return (\n !!prev &&\n prev.from === rows[i].from &&\n rows[i].at.getTime() - prev.at.getTime() < FIVE_MINUTES &&\n rows[i].at.toDateString() === prev.at.toDateString()\n );\n}\n\nfunction secondsLine(seconds: number) {\n return `Working for ${seconds} ${seconds === 1 ? 'second' : 'seconds'}`;\n}\n\n// The agent's marks, as the rule 'An agent says what it is' says.\nfunction agentMeta(at: Date) {\n return (\n <>\n <Tag variant=\"contained\" size=\"small\" label=\"Agent\" />\n <TimeStamp createdAt={at} dateFormat=\"absolute\" data=\"time\" />\n <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">Model name</Paragraph>\n </>\n );\n}\n\nexport default function MessageComposerWithTools() {\n const [thread, setThread] = useState(firstThread);\n // A real app keeps the draft per thread, so it is still there when the person comes back.\n const [text, setText] = useState('');\n const [file, setFile] = useState<Attachment | null>(null);\n const [mentionAgent, setMentionAgent] = useState(false);\n // The agent's run while it works: the id of its row in the thread, and whether a stop has been asked for.\n const [run, setRun] = useState<{ rowId: string; stopping: boolean } | null>(null);\n const [seconds, setSeconds] = useState(0);\n const runTimer = useRef<ReturnType<typeof setTimeout>>();\n const cancel = useRef<ReturnType<typeof setTimeout>>();\n const tick = useRef<ReturnType<typeof setInterval>>();\n const field = useRef<HTMLTextAreaElement>(null);\n\n // On unmount it stops the agent's run, its clock and the cancel request.\n useEffect(() => () => {\n clearTimeout(runTimer.current);\n clearTimeout(cancel.current);\n clearInterval(tick.current);\n }, []);\n\n // The run is over: its own row, in the same place and with the same time, now holds the reply, or the steps and a note.\n function endRun(rowId: string, text: string, stopped = false) {\n clearTimeout(runTimer.current);\n clearInterval(tick.current);\n setRun(null);\n setThread((rows) => rows.map((m) => (m.id === rowId ? { ...m, text, progress: false, stopped } : m)));\n }\n\n function addRow(row: Omit<Row, 'id'>) {\n setThread((rows) => [...rows, { ...row, id: `m${rows.length + 1}` }]);\n }\n\n // A real app opens the file picker here; this one attaches a sample file.\n function attach() {\n setFile(sampleFile);\n }\n\n function removeFile() {\n setFile(null);\n field.current?.focus();\n }\n\n // Enter sends and Shift+Enter adds a line. The Composer calls this only when there is something to send.\n function send() {\n // A real app sends the message to the server here and shows it at once.\n addRow({ from: me, at: new Date(), text: text.trim(), file: file ?? undefined });\n setText('');\n setFile(null);\n // One run at a time: a real app queues a second call to the agent.\n if (!mentionAgent || run) return;\n // The run gets one row, added now where the reply will appear. Messages sent during the run go below it.\n const startedAt = new Date();\n const rowId = `run-${startedAt.getTime()}`;\n setThread((rows) => [...rows, { id: rowId, from: agentName, agent: true, at: startedAt, text: '', progress: true }]);\n setRun({ rowId, stopping: false });\n setSeconds(0);\n tick.current = setInterval(() => setSeconds((s) => s + 1), 1000);\n // Stands in for the agent's run.\n runTimer.current = setTimeout(() => {\n endRun(rowId, 'The email reads well. The pricing link in the second paragraph points to last year\\'s page.');\n }, 3000);\n }\n\n // Stop asks the server to end the run, and shows loading until it has. Only then does the row say it\n // stopped: it keeps its steps, the one not done is cancelled, and a line says what was done.\n // Stop is gone, so focus goes to the message box.\n function stop() {\n if (!run || run.stopping) return;\n clearTimeout(runTimer.current);\n setRun({ ...run, stopping: true });\n // Stands in for the request to the server.\n cancel.current = setTimeout(() => {\n endRun(run.rowId, 'Stopped after 1 of 2 steps. Nothing was changed.', true);\n field.current?.focus();\n }, 1200);\n }\n\n return (\n <Center width=\"page\">\n <Stack gap=\"large\">\n <Heading level={1} size=\"h5\">Launch plan</Heading>\n {/* A real app gives the list that holds the rows role=\"log\". */}\n <Stack gap=\"small\">\n {thread.map((m, i) =>\n m.progress && run?.rowId === m.id ? (\n // While the agent works, its row shows where the reply will appear: the seconds so far,\n // the steps, and the only Stop. The case 'Agent at work' has the full pattern.\n <Message\n key={m.id}\n aria-label={`${m.from}, agent`}\n avatar={<UserImage userHandle={m.from} icon={Bot} decorative />}\n name={m.from}\n meta={agentMeta(m.at)}\n footer={\n // It shows loading while the run is stopping.\n <Cluster>\n <Button size=\"small\" type=\"secondary\" state=\"enabled\" label=\"Stop\" loading={run.stopping} onClickButton={stop} />\n </Cluster>\n }\n >\n {/* A real app wraps this part in a polite live region, since StepList has none. */}\n <Stack gap=\"medium\">\n <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">{secondsLine(seconds)}</Paragraph>\n <StepList\n aria-label=\"Acme Agent's steps\"\n steps={[\n { label: 'Read the thread', status: 'done' },\n { label: 'Checking the links in the email', status: 'running' },\n ]}\n />\n </Stack>\n </Message>\n ) : (\n <Message\n key={m.id}\n aria-label={m.agent ? `${m.from}, agent` : m.from}\n compact={followsOn(thread, i)}\n avatar={m.agent ? <UserImage userHandle={m.from} icon={Bot} decorative /> : <UserImage userHandle={m.from} decorative />}\n name={m.from}\n meta={m.agent ? agentMeta(m.at) : <TimeStamp createdAt={m.at} dateFormat=\"absolute\" data=\"time\" />}\n // A sent file opens when its chip is pressed. A real app links to the stored file.\n footer={m.file ? <FileChip name={m.file.name} kind={m.file.kind} meta={m.file.size} href=\"/files/launch-email.pdf\" openInNewTab /> : undefined}\n >\n {m.stopped ? (\n // As in the case 'Agent at work': the steps stay, with the one not done cancelled.\n <Stack gap=\"medium\">\n <StepList\n aria-label=\"Acme Agent's steps\"\n steps={[\n { label: 'Read the thread', status: 'done' },\n { label: 'Checking the links in the email', status: 'cancelled' },\n ]}\n />\n <Paragraph measure=\"none\">{m.text}</Paragraph>\n </Stack>\n ) : (\n m.text && <Paragraph measure=\"none\">{m.text}</Paragraph>\n )}\n </Message>\n ),\n )}\n </Stack>\n {/* On a touch screen, pass submitOnEnter={false} so Return adds a line. */}\n <Composer\n ref={field}\n id=\"message-composer-tools-message\"\n aria-label=\"Message\"\n // The placeholder says who will read the message.\n placeholder={mentionAgent ? `Message ${agentName}` : 'Message the team'}\n value={text}\n onChange={setText}\n onSubmit={send}\n canSubmit={text.trim() !== '' || file !== null}\n // The Composer keeps Send while the agent works, so a message to people still goes. Stop is on the agent's row.\n above={file ? <FileChip name={file.name} kind={file.kind} meta={file.size} onRemove={removeFile} /> : undefined}\n tools={\n <>\n <Tooltip title=\"Attach files\">\n <IconButton color=\"iconOnly\" state=\"enabled\" size=\"small\" iconName=\"Paperclip\" ariaLabel=\"Attach files\" onClick={attach} />\n </Tooltip>\n <Tooltip title=\"Mention the agent\">\n <IconButton\n color=\"iconOnly\"\n state={mentionAgent ? 'selected' : 'enabled'}\n size=\"small\"\n icon={Bot}\n ariaLabel=\"Mention the agent\"\n aria-pressed={mentionAgent}\n onClick={() => setMentionAgent((on) => !on)}\n />\n </Tooltip>\n </>\n }\n />\n </Stack>\n </Center>\n );\n}\n",
4540
5420
  "uses": [
4541
5421
  "Button",
4542
5422
  "Center",
@@ -4563,6 +5443,9 @@
4563
5443
  "kind": "design",
4564
5444
  "level": "organism",
4565
5445
  "area": "chat",
5446
+ "surface": [
5447
+ "app"
5448
+ ],
4566
5449
  "situation": "A person changes the text of a message they sent.",
4567
5450
  "do": [
4568
5451
  "Replace the row's body with a `Composer` that holds the text, and focus it with the caret after the text.",
@@ -4612,6 +5495,9 @@
4612
5495
  "kind": "design",
4613
5496
  "level": "organism",
4614
5497
  "area": "chat",
5498
+ "surface": [
5499
+ "app"
5500
+ ],
4615
5501
  "situation": "People answer a message with an emoji instead of a reply.",
4616
5502
  "do": [
4617
5503
  "Put the reactions in the Message's `footer`: a `Cluster` of `Tag`s, then a small 'Add reaction' `IconButton`.",
@@ -4705,6 +5591,10 @@
4705
5591
  "kind": "design",
4706
5592
  "level": "organism",
4707
5593
  "area": "chat",
5594
+ "surface": [
5595
+ "app",
5596
+ "agent"
5597
+ ],
4708
5598
  "situation": "A thread shows messages from people, and sometimes from an agent.",
4709
5599
  "do": [
4710
5600
  "Show each row with `Message`: the sender's `UserImage`, their name and the time. A person's avatar is their picture or their initial.",
@@ -4729,30 +5619,102 @@
4729
5619
  "native": "On Apple a row shows the avatar, the name and the time, with an 'Agent' label next to an agent's name.",
4730
5620
  "options": [
4731
5621
  {
4732
- "id": "person-and-agent",
4733
- "title": "People and an agent",
4734
- "useWhen": "A thread with gaps between messages: every row shows who and when.",
4735
- "source": "'use client';\nimport { Bot } from 'lucide-react';\nimport Message from 'oneslash-design-system/components/message';\nimport UserImage from 'oneslash-design-system/components/userImage';\nimport Tag from 'oneslash-design-system/components/tag';\nimport TimeStamp from 'oneslash-design-system/components/timeStamp';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport { Center, Stack } from 'oneslash-design-system/components/layout';\n\ntype Row = { id: string; from: string; agent?: boolean; at: Date; text: string };\n\nconst thread: Row[] = [\n { id: 'm1', from: 'Dana Lee', at: new Date('2025-01-15T11:40:00Z'), text: 'Can you list what is still open for the launch?' },\n { id: 'm2', from: 'Acme Agent', agent: true, at: new Date('2025-01-15T11:41:00Z'), text: 'Three tasks are open: the press kit, the pricing page and the launch email.' },\n { id: 'm3', from: 'Ben Carter', at: new Date('2025-01-15T11:44:00Z'), text: 'I can take the press kit.' },\n];\n\nexport default function MessageRowPersonAndAgent() {\n return (\n <Center width=\"page\">\n <Stack gap=\"large\">\n <Heading level={1} size=\"h5\">Launch plan</Heading>\n {/* A real app gives the list that holds the rows role=\"log\". */}\n <Stack gap=\"small\">\n {thread.map((m) =>\n m.agent ? (\n // An agent's row: an icon avatar, its name, an 'Agent' tag, the time and the model line.\n // The product's own agent shows the product's mark; an agent from outside shows a plain bot icon.\n // Acme has no mark here, so Acme Agent uses Bot.\n <Message\n key={m.id}\n aria-label={`${m.from}, agent`}\n avatar={<UserImage userHandle={m.from} icon={Bot} decorative />}\n name={m.from}\n meta={\n <>\n <Tag variant=\"contained\" size=\"small\" label=\"Agent\" />\n <TimeStamp createdAt={m.at} dateFormat=\"absolute\" data=\"time\" />\n <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">Model name</Paragraph>\n </>\n }\n >\n <Paragraph measure=\"none\">{m.text}</Paragraph>\n </Message>\n ) : (\n // A person's row: their picture or initial, their name and the time.\n <Message\n key={m.id}\n aria-label={m.from}\n avatar={<UserImage userHandle={m.from} decorative />}\n name={m.from}\n meta={<TimeStamp createdAt={m.at} dateFormat=\"absolute\" data=\"time\" />}\n >\n <Paragraph measure=\"none\">{m.text}</Paragraph>\n </Message>\n ),\n )}\n </Stack>\n </Stack>\n </Center>\n );\n}\n",
5622
+ "id": "person-and-agent",
5623
+ "title": "People and an agent",
5624
+ "useWhen": "A thread with gaps between messages: every row shows who and when.",
5625
+ "source": "'use client';\nimport { Bot } from 'lucide-react';\nimport Message from 'oneslash-design-system/components/message';\nimport UserImage from 'oneslash-design-system/components/userImage';\nimport Tag from 'oneslash-design-system/components/tag';\nimport TimeStamp from 'oneslash-design-system/components/timeStamp';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport { Center, Stack } from 'oneslash-design-system/components/layout';\n\ntype Row = { id: string; from: string; agent?: boolean; at: Date; text: string };\n\nconst thread: Row[] = [\n { id: 'm1', from: 'Dana Lee', at: new Date('2025-01-15T11:40:00Z'), text: 'Can you list what is still open for the launch?' },\n { id: 'm2', from: 'Acme Agent', agent: true, at: new Date('2025-01-15T11:41:00Z'), text: 'Three tasks are open: the press kit, the pricing page and the launch email.' },\n { id: 'm3', from: 'Ben Carter', at: new Date('2025-01-15T11:44:00Z'), text: 'I can take the press kit.' },\n];\n\nexport default function MessageRowPersonAndAgent() {\n return (\n <Center width=\"page\">\n <Stack gap=\"large\">\n <Heading level={1} size=\"h5\">Launch plan</Heading>\n {/* A real app gives the list that holds the rows role=\"log\". */}\n <Stack gap=\"small\">\n {thread.map((m) =>\n m.agent ? (\n // An agent's row: an icon avatar, its name, an 'Agent' tag, the time and the model line.\n // The product's own agent shows the product's mark; an agent from outside shows a plain bot icon.\n // Acme has no mark here, so Acme Agent uses Bot.\n <Message\n key={m.id}\n aria-label={`${m.from}, agent`}\n avatar={<UserImage userHandle={m.from} icon={Bot} decorative />}\n name={m.from}\n meta={\n <>\n <Tag variant=\"contained\" size=\"small\" label=\"Agent\" />\n <TimeStamp createdAt={m.at} dateFormat=\"absolute\" data=\"time\" />\n <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">Model name</Paragraph>\n </>\n }\n >\n <Paragraph measure=\"none\">{m.text}</Paragraph>\n </Message>\n ) : (\n // A person's row: their picture or initial, their name and the time.\n <Message\n key={m.id}\n aria-label={m.from}\n avatar={<UserImage userHandle={m.from} decorative />}\n name={m.from}\n meta={<TimeStamp createdAt={m.at} dateFormat=\"absolute\" data=\"time\" />}\n >\n <Paragraph measure=\"none\">{m.text}</Paragraph>\n </Message>\n ),\n )}\n </Stack>\n </Stack>\n </Center>\n );\n}\n",
5626
+ "uses": [
5627
+ "Center",
5628
+ "Heading",
5629
+ "Message",
5630
+ "Paragraph",
5631
+ "Stack",
5632
+ "Tag",
5633
+ "TimeStamp",
5634
+ "UserImage"
5635
+ ]
5636
+ },
5637
+ {
5638
+ "id": "grouped",
5639
+ "title": "Grouped rows",
5640
+ "useWhen": "A busy thread: follow-on rows from one sender drop the avatar and the name.",
5641
+ "source": "'use client';\nimport Message from 'oneslash-design-system/components/message';\nimport UserImage from 'oneslash-design-system/components/userImage';\nimport TimeStamp from 'oneslash-design-system/components/timeStamp';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Line from 'oneslash-design-system/components/line';\nimport { Center, Stack } from 'oneslash-design-system/components/layout';\n\ntype Row = { id: string; from: string; at: Date; text: string };\n\n// A real app builds each date line from the message times, in the reader's time zone, and labels the\n// days 'Today', 'Yesterday', or the full date with the year. These lines are fixed, so the times sit\n// near midday UTC, where the date is the same in most time zones.\nconst days: { label: string; rows: Row[] }[] = [\n {\n label: 'Monday, January 13, 2025',\n rows: [\n { id: 'm1', from: 'Ben Carter', at: new Date('2025-01-13T12:10:00Z'), text: 'I sent the pricing page draft to legal.' },\n { id: 'm2', from: 'Ben Carter', at: new Date('2025-01-13T12:12:00Z'), text: 'They usually answer within a day.' },\n ],\n },\n {\n label: 'Today',\n rows: [\n { id: 'm3', from: 'Ben Carter', at: new Date('2025-01-15T11:30:00Z'), text: 'Legal approved the pricing page.' },\n { id: 'm4', from: 'Ben Carter', at: new Date('2025-01-15T11:31:00Z'), text: 'They asked for two small wording changes, both in the footer.' },\n { id: 'm5', from: 'Ben Carter', at: new Date('2025-01-15T11:33:00Z'), text: 'I made them already.' },\n { id: 'm6', from: 'Dana Lee', at: new Date('2025-01-15T11:45:00Z'), text: 'Thanks. I will publish it this afternoon.' },\n ],\n },\n];\n\nconst FIVE_MINUTES = 5 * 60 * 1000;\n\n// A follow-on row: the same sender as the row above, less than 5 minutes later and on the same day.\nfunction followsOn(rows: Row[], i: number) {\n const prev = rows[i - 1];\n return (\n !!prev &&\n prev.from === rows[i].from &&\n rows[i].at.getTime() - prev.at.getTime() < FIVE_MINUTES &&\n rows[i].at.toDateString() === prev.at.toDateString()\n );\n}\n\nexport default function MessageRowGrouped() {\n return (\n <Center width=\"page\">\n <Stack gap=\"large\">\n <Heading level={1} size=\"h5\">Launch plan</Heading>\n {/* A real app gives the list that holds the rows role=\"log\". */}\n <Stack gap=\"medium\">\n {days.map((day) => (\n <Stack key={day.label} gap=\"small\">\n <Line label={day.label} />\n {day.rows.map((m, i) => (\n <Message\n key={m.id}\n // A compact row shows no name, so its aria-label carries it.\n aria-label={m.from}\n compact={followsOn(day.rows, i)}\n avatar={<UserImage userHandle={m.from} decorative />}\n name={m.from}\n meta={<TimeStamp createdAt={m.at} dateFormat=\"absolute\" data=\"time\" />}\n >\n <Paragraph measure=\"none\">{m.text}</Paragraph>\n </Message>\n ))}\n </Stack>\n ))}\n </Stack>\n </Stack>\n </Center>\n );\n}\n",
5642
+ "uses": [
5643
+ "Center",
5644
+ "Heading",
5645
+ "Line",
5646
+ "Message",
5647
+ "Paragraph",
5648
+ "Stack",
5649
+ "TimeStamp",
5650
+ "UserImage"
5651
+ ]
5652
+ }
5653
+ ]
5654
+ },
5655
+ {
5656
+ "id": "message-send-failure",
5657
+ "title": "Message that did not send",
5658
+ "kind": "design",
5659
+ "level": "organism",
5660
+ "area": "chat",
5661
+ "surface": [
5662
+ "app",
5663
+ "agent"
5664
+ ],
5665
+ "situation": "A person sent a message and it did not reach the people it was for, because the app is offline or because something needs fixing first.",
5666
+ "do": [
5667
+ "Keep the message in the thread as a `Message`, where the person wrote it, with a line in its `footer` that says it did not send.",
5668
+ "Write 'Not sent yet. Trying again.' when the app will send it by itself, with 'Send Now' and 'Discard'.",
5669
+ "Say why it did not send and what fixes it when it needs the person: 'Not sent. Reconnect Figma, then send again.' Link the fix to the place that does it, with 'Try Again' and 'Discard'.",
5670
+ "Make the line's Buttons `size=\"small\"`, with an `aria-label` that names the message: 'Send now: Can you check the plan table on…'.",
5671
+ "Show a warning `Alert` above the `Composer` while the app is offline: 'You are offline. Messages send when you are back.' Give it no close button and `autoDismiss={false}`.",
5672
+ "Keep the `Composer` working. The person can type and send more, and each new message waits in the thread too.",
5673
+ "Show 'Send Now' and 'Try Again' as `loading` while they send, and keep their labels.",
5674
+ "Move focus to the `Composer` when the message sends or is discarded, because the line and its Buttons are gone.",
5675
+ "Send focus to the `Composer` after 'Discard', not to the next row as the case 'Message actions' does after a delete. A failed message is usually the last one.",
5676
+ "Say in a polite status line, once, when waiting messages have sent: 'Back online. 2 messages sent.'"
5677
+ ],
5678
+ "dont": [
5679
+ "Do not fade the text as the only sign that it did not send. Say it in words under the message.",
5680
+ "Do not show a toast for a failure that stays. The line stays with the message until it sends or is discarded.",
5681
+ "Do not lose the text. It stays in the thread until it sends or the person discards it.",
5682
+ "Do not show the error's own message, such as 'Request failed with status 401'.",
5683
+ "Do not block the Composer while one message waits."
5684
+ ],
5685
+ "native": "On Apple show the line under the message in a footnote style, with 'Send Now' and 'Discard' as Buttons and a banner above the text field while offline. On Android use the same line under the message, and a `Snackbar` only for a failure that clears itself.",
5686
+ "options": [
5687
+ {
5688
+ "id": "retrying",
5689
+ "title": "Sends again by itself",
5690
+ "useWhen": "The app can send it again without help, such as when it is offline.",
5691
+ "source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport Message from 'oneslash-design-system/components/message';\nimport UserImage from 'oneslash-design-system/components/userImage';\nimport TimeStamp from 'oneslash-design-system/components/timeStamp';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Alert from 'oneslash-design-system/components/alert';\nimport Button from 'oneslash-design-system/components/button';\nimport Composer from 'oneslash-design-system/components/composer';\nimport { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';\n\n// A real app reads this from the session.\nconst me = 'Dana Lee';\n\ntype Row = { id: string; from: string; at: Date; text: string; state: 'sent' | 'waiting' | 'sending' };\n\n// Opens offline, with Dana's last message waiting to go.\nconst firstThread: Row[] = [\n { id: 'm1', from: 'Ben Carter', at: new Date('2026-11-16T14:31:00'), text: 'The pricing page is ready for a last look.', state: 'sent' },\n { id: 'm2', from: 'Omar Reyes', at: new Date('2026-11-16T14:35:00'), text: 'I fixed the plan table on phones.', state: 'sent' },\n { id: 'm3', from: me, at: new Date('2026-11-16T14:40:00'), text: 'Can you check the plan table on a phone before 4:00 PM?', state: 'waiting' },\n];\n\n// Names a message by its first words, for the Buttons under it.\nconst firstWords = (text: string) => (text.length > 32 ? `${text.slice(0, 32).trimEnd()}…` : text);\n\nexport default function MessageSendFailureRetrying() {\n const [thread, setThread] = useState(firstThread);\n const [online, setOnline] = useState(false);\n const [text, setText] = useState('');\n // Said once, in the polite status line, when the waiting messages have gone.\n const [status, setStatus] = useState('');\n const timer = useRef<ReturnType<typeof setTimeout>>();\n const composer = useRef<HTMLTextAreaElement>(null);\n // Each new message gets its own id, so no two rows share one after a discard.\n const nextId = useRef(firstThread.length + 1);\n // The thread as last drawn, for the request that ends later.\n const latest = useRef(thread);\n latest.current = thread;\n // Where focus goes after the next render, once the element it goes to is on screen.\n const focusNext = useRef<() => void>();\n\n // Stops the request if the example goes away before it ends.\n useEffect(() => () => clearTimeout(timer.current), []);\n\n useEffect(() => {\n const move = focusNext.current;\n focusNext.current = undefined;\n move?.();\n });\n\n // The Composer keeps working while a message waits. Offline, a new message waits in the thread too.\n function send() {\n const id = `m${nextId.current++}`;\n setThread((rows) => [...rows, { id, from: me, at: new Date(), text: text.trim(), state: online ? 'sent' : 'waiting' }]);\n setText('');\n }\n\n // Sends at once. Here the connection is back, so every waiting message goes with it.\n function sendNow(id: string) {\n if (thread.some((m) => m.state === 'sending')) return;\n setThread((rows) => rows.map((m) => (m.id === id ? { ...m, state: 'sending' } : m)));\n // Stands in for the request to the server.\n timer.current = setTimeout(() => {\n const waiting = latest.current.filter((m) => m.state !== 'sent').length;\n setThread((rows) => rows.map((m) => ({ ...m, state: 'sent' })));\n setOnline(true);\n setStatus(`Back online. ${waiting} ${waiting === 1 ? 'message' : 'messages'} sent.`);\n // The line and its Buttons are gone, so focus goes to the message box.\n focusNext.current = () => composer.current?.focus();\n }, 1200);\n }\n\n // Takes the message out of the thread. It was never sent, so no one else saw it.\n function discard(id: string) {\n setThread((rows) => rows.filter((m) => m.id !== id));\n focusNext.current = () => composer.current?.focus();\n }\n\n return (\n <Center width=\"page\">\n <Stack gap=\"large\">\n <Heading level={1} size=\"h5\">Launch plan</Heading>\n {/* A real app gives the list that holds the rows role=\"log\". */}\n <Stack gap=\"small\">\n {thread.map((m) => {\n const notSent = m.state !== 'sent';\n return (\n <Message\n key={m.id}\n aria-label={notSent ? `${m.from}, not sent yet` : m.from}\n avatar={<UserImage userHandle={m.from} decorative />}\n name={m.from}\n meta={<TimeStamp createdAt={m.at} dateFormat=\"absolute\" data=\"time\" />}\n footer={\n notSent ? (\n <Stack gap=\"small\">\n <Paragraph size=\"body2\" tone=\"secondary\" measure=\"none\">Not sent yet. Trying again.</Paragraph>\n <Cluster gap=\"small\">\n <Button size=\"small\" type=\"secondary\" state=\"enabled\" label=\"Send Now\" aria-label={`Send now: ${firstWords(m.text)}`} loading={m.state === 'sending'} onClickButton={() => sendNow(m.id)} />\n <Button size=\"small\" type=\"tertiary\" state={m.state === 'sending' ? 'disabled' : 'enabled'} label=\"Discard\" aria-label={`Discard: ${firstWords(m.text)}`} onClickButton={() => discard(m.id)} />\n </Cluster>\n </Stack>\n ) : undefined\n }\n >\n <Paragraph measure=\"none\">{m.text}</Paragraph>\n </Message>\n );\n })}\n </Stack>\n <Stack gap=\"small\">\n {!online && <Alert type=\"warning\" variant=\"inline\" message=\"You are offline. Messages send when you are back.\" autoDismiss={false} />}\n {/* On the page from the start, so it is heard once when the messages go. */}\n <Paragraph role=\"status\" size=\"body2\" tone=\"secondary\" measure=\"none\">{status}</Paragraph>\n <Composer\n ref={composer}\n id=\"message-send-failure-retrying-message\"\n aria-label=\"Message\"\n placeholder=\"Message the team\"\n value={text}\n onChange={setText}\n onSubmit={send}\n />\n </Stack>\n </Stack>\n </Center>\n );\n}\n",
4736
5692
  "uses": [
5693
+ "Alert",
5694
+ "Button",
4737
5695
  "Center",
5696
+ "Cluster",
5697
+ "Composer",
4738
5698
  "Heading",
4739
5699
  "Message",
4740
5700
  "Paragraph",
4741
5701
  "Stack",
4742
- "Tag",
4743
5702
  "TimeStamp",
4744
5703
  "UserImage"
4745
5704
  ]
4746
5705
  },
4747
5706
  {
4748
- "id": "grouped",
4749
- "title": "Grouped rows",
4750
- "useWhen": "A busy thread: follow-on rows from one sender drop the avatar and the name.",
4751
- "source": "'use client';\nimport Message from 'oneslash-design-system/components/message';\nimport UserImage from 'oneslash-design-system/components/userImage';\nimport TimeStamp from 'oneslash-design-system/components/timeStamp';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Line from 'oneslash-design-system/components/line';\nimport { Center, Stack } from 'oneslash-design-system/components/layout';\n\ntype Row = { id: string; from: string; at: Date; text: string };\n\n// A real app builds each date line from the message times, in the reader's time zone, and labels the\n// days 'Today', 'Yesterday', or the full date with the year. These lines are fixed, so the times sit\n// near midday UTC, where the date is the same in most time zones.\nconst days: { label: string; rows: Row[] }[] = [\n {\n label: 'Monday, January 13, 2025',\n rows: [\n { id: 'm1', from: 'Ben Carter', at: new Date('2025-01-13T12:10:00Z'), text: 'I sent the pricing page draft to legal.' },\n { id: 'm2', from: 'Ben Carter', at: new Date('2025-01-13T12:12:00Z'), text: 'They usually answer within a day.' },\n ],\n },\n {\n label: 'Today',\n rows: [\n { id: 'm3', from: 'Ben Carter', at: new Date('2025-01-15T11:30:00Z'), text: 'Legal approved the pricing page.' },\n { id: 'm4', from: 'Ben Carter', at: new Date('2025-01-15T11:31:00Z'), text: 'They asked for two small wording changes, both in the footer.' },\n { id: 'm5', from: 'Ben Carter', at: new Date('2025-01-15T11:33:00Z'), text: 'I made them already.' },\n { id: 'm6', from: 'Dana Lee', at: new Date('2025-01-15T11:45:00Z'), text: 'Thanks. I will publish it this afternoon.' },\n ],\n },\n];\n\nconst FIVE_MINUTES = 5 * 60 * 1000;\n\n// A follow-on row: the same sender as the row above, less than 5 minutes later and on the same day.\nfunction followsOn(rows: Row[], i: number) {\n const prev = rows[i - 1];\n return (\n !!prev &&\n prev.from === rows[i].from &&\n rows[i].at.getTime() - prev.at.getTime() < FIVE_MINUTES &&\n rows[i].at.toDateString() === prev.at.toDateString()\n );\n}\n\nexport default function MessageRowGrouped() {\n return (\n <Center width=\"page\">\n <Stack gap=\"large\">\n <Heading level={1} size=\"h5\">Launch plan</Heading>\n {/* A real app gives the list that holds the rows role=\"log\". */}\n <Stack gap=\"medium\">\n {days.map((day) => (\n <Stack key={day.label} gap=\"small\">\n <Line label={day.label} />\n {day.rows.map((m, i) => (\n <Message\n key={m.id}\n // A compact row shows no name, so its aria-label carries it.\n aria-label={m.from}\n compact={followsOn(day.rows, i)}\n avatar={<UserImage userHandle={m.from} decorative />}\n name={m.from}\n meta={<TimeStamp createdAt={m.at} dateFormat=\"absolute\" data=\"time\" />}\n >\n <Paragraph measure=\"none\">{m.text}</Paragraph>\n </Message>\n ))}\n </Stack>\n ))}\n </Stack>\n </Stack>\n </Center>\n );\n}\n",
5707
+ "id": "needs-a-person",
5708
+ "title": "Waits for a fix",
5709
+ "useWhen": "Sending cannot work until the person does something, such as reconnect an account.",
5710
+ "source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport Message from 'oneslash-design-system/components/message';\nimport UserImage from 'oneslash-design-system/components/userImage';\nimport TimeStamp from 'oneslash-design-system/components/timeStamp';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Link from 'oneslash-design-system/components/link';\nimport Button from 'oneslash-design-system/components/button';\nimport Composer from 'oneslash-design-system/components/composer';\nimport { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';\n\n// A real app reads this from the session.\nconst me = 'Dana Lee';\n\ntype Row = { id: string; from: string; at: Date; text: string; state: 'sent' | 'failed' | 'sending' };\n\n// This thread is shared with a Figma file. Dana's access to Figma ran out, so her last reply did not send.\nconst firstThread: Row[] = [\n { id: 'm1', from: 'Ben Carter', at: new Date('2026-11-16T14:31:00'), text: 'The hero image is too dark on phones.', state: 'sent' },\n { id: 'm2', from: 'Omar Reyes', at: new Date('2026-11-16T14:35:00'), text: 'I can try a lighter one this afternoon.', state: 'sent' },\n { id: 'm3', from: me, at: new Date('2026-11-16T14:40:00'), text: 'Yes, try the lighter one and we check it on Monday.', state: 'failed' },\n];\n\n// Names a message by its first words, for the Buttons under it.\nconst firstWords = (text: string) => (text.length > 32 ? `${text.slice(0, 32).trimEnd()}…` : text);\n\nexport default function MessageSendFailureNeedsAPerson() {\n const [thread, setThread] = useState(firstThread);\n const [connected, setConnected] = useState(false);\n const [text, setText] = useState('');\n // Said once, in the polite status line, when a message has gone.\n const [status, setStatus] = useState('');\n const timer = useRef<ReturnType<typeof setTimeout>>();\n const composer = useRef<HTMLTextAreaElement>(null);\n // Each new message gets its own id, so no two rows share one after a discard.\n const nextId = useRef(firstThread.length + 1);\n // Where focus goes after the next render, once the element it goes to is on screen.\n const focusNext = useRef<() => void>();\n\n // Stops the request if the example goes away before it ends.\n useEffect(() => () => clearTimeout(timer.current), []);\n\n useEffect(() => {\n const move = focusNext.current;\n focusNext.current = undefined;\n move?.();\n });\n\n // The Composer keeps working. Until Figma is reconnected, a new reply cannot send either, and says so.\n function send() {\n const id = `m${nextId.current++}`;\n setThread((rows) => [...rows, { id, from: me, at: new Date(), text: text.trim(), state: connected ? 'sent' : 'failed' }]);\n setText('');\n }\n\n // Stands in for a person who reconnected Figma first, so it sends.\n function tryAgain(id: string) {\n if (thread.some((m) => m.state === 'sending')) return;\n setThread((rows) => rows.map((m) => (m.id === id ? { ...m, state: 'sending' } : m)));\n timer.current = setTimeout(() => {\n setThread((rows) => rows.map((m) => (m.id === id ? { ...m, state: 'sent' } : m)));\n setConnected(true);\n setStatus('Message sent.');\n // The line and its Buttons are gone, so focus goes to the message box.\n focusNext.current = () => composer.current?.focus();\n }, 1200);\n }\n\n // Takes the message out of the thread. It was never sent, so no one else saw it.\n function discard(id: string) {\n setThread((rows) => rows.filter((m) => m.id !== id));\n focusNext.current = () => composer.current?.focus();\n }\n\n return (\n <Center width=\"page\">\n <Stack gap=\"large\">\n <Stack gap=\"small\">\n <Heading level={1} size=\"h5\">Homepage hero</Heading>\n <Paragraph tone=\"secondary\" size=\"body2\" measure=\"none\">Replies here also go to the comments on the Figma file.</Paragraph>\n </Stack>\n {/* A real app gives the list that holds the rows role=\"log\". */}\n <Stack gap=\"small\">\n {thread.map((m) => {\n const notSent = m.state !== 'sent';\n return (\n <Message\n key={m.id}\n aria-label={notSent ? `${m.from}, not sent` : m.from}\n avatar={<UserImage userHandle={m.from} decorative />}\n name={m.from}\n meta={<TimeStamp createdAt={m.at} dateFormat=\"absolute\" data=\"time\" />}\n footer={\n notSent ? (\n <Stack gap=\"small\">\n {/* The reason and its fix. The link goes where the fix is done. */}\n <Paragraph size=\"body2\" tone=\"secondary\" measure=\"none\">\n Not sent. <Link href=\"/settings/integrations\" size=\"body2\">Reconnect Figma</Link>, then send again.\n </Paragraph>\n <Cluster gap=\"small\">\n <Button size=\"small\" type=\"secondary\" state=\"enabled\" label=\"Try Again\" aria-label={`Try again: ${firstWords(m.text)}`} loading={m.state === 'sending'} onClickButton={() => tryAgain(m.id)} />\n <Button size=\"small\" type=\"tertiary\" state={m.state === 'sending' ? 'disabled' : 'enabled'} label=\"Discard\" aria-label={`Discard: ${firstWords(m.text)}`} onClickButton={() => discard(m.id)} />\n </Cluster>\n </Stack>\n ) : undefined\n }\n >\n <Paragraph measure=\"none\">{m.text}</Paragraph>\n </Message>\n );\n })}\n </Stack>\n <Stack gap=\"small\">\n {/* On the page from the start, so it is heard once when the message goes. */}\n <Paragraph role=\"status\" size=\"body2\" tone=\"secondary\" measure=\"none\">{status}</Paragraph>\n <Composer\n ref={composer}\n id=\"message-send-failure-needs-a-person-message\"\n aria-label=\"Message\"\n placeholder=\"Message the team\"\n value={text}\n onChange={setText}\n onSubmit={send}\n />\n </Stack>\n </Stack>\n </Center>\n );\n}\n",
4752
5711
  "uses": [
5712
+ "Button",
4753
5713
  "Center",
5714
+ "Cluster",
5715
+ "Composer",
4754
5716
  "Heading",
4755
- "Line",
5717
+ "Link",
4756
5718
  "Message",
4757
5719
  "Paragraph",
4758
5720
  "Stack",
@@ -4768,6 +5730,10 @@
4768
5730
  "kind": "design",
4769
5731
  "level": "organism",
4770
5732
  "area": "shell",
5733
+ "surface": [
5734
+ "site",
5735
+ "app"
5736
+ ],
4771
5737
  "situation": "A site's links and actions do not fit in the bar on a phone, and the person still needs to reach every one.",
4772
5738
  "do": [
4773
5739
  "Follow the rule 'On a phone, a sidebar opens as a drawer and a list opens its detail'. The menu is a `Drawer` from the start side.",
@@ -4830,6 +5796,9 @@
4830
5796
  "kind": "design",
4831
5797
  "level": "organism",
4832
5798
  "area": "marketing",
5799
+ "surface": [
5800
+ "site"
5801
+ ],
4833
5802
  "situation": "A reader of the public site wants to hear about the product by email, without making an account.",
4834
5803
  "do": [
4835
5804
  "Follow the rules 'A form error shows next to the problem' and 'Success shows where the person is looking'.",
@@ -4888,12 +5857,78 @@
4888
5857
  }
4889
5858
  ]
4890
5859
  },
5860
+ {
5861
+ "id": "no-access",
5862
+ "title": "No access",
5863
+ "kind": "design",
5864
+ "level": "organism",
5865
+ "area": "state",
5866
+ "surface": [
5867
+ "app"
5868
+ ],
5869
+ "situation": "A person reaches a page or a setting that their role does not let them see or change, often by a link someone sent.",
5870
+ "do": [
5871
+ "Keep the shell and the navigation, as the case 'Error page' does inside the shell. Name the page in the `TitleBar`, so the person knows the link was right.",
5872
+ "Show an `EmptyBox` in the page's place that names what they cannot see: 'You do not have access to Billing'.",
5873
+ "Say who can give access, by name: 'Ask an admin: Dana Lee'.",
5874
+ "Offer one way out, 'Go Home', as the `EmptyBox` action.",
5875
+ "Show one info `Alert` at the top of a settings page the person can only read: 'Only admins can change these settings. Your admin is Dana Lee.' Give it no close button and `autoDismiss={false}`.",
5876
+ "Show the fields with `readOnly`, so the person can still read, select and copy the values.",
5877
+ "Show a choice that has no read-only state, such as a `RadioGroup`, disabled, under the line that says who can change it.",
5878
+ "Leave out the Save Button and every Button that would change a setting."
5879
+ ],
5880
+ "dont": [
5881
+ "Do not show a 404 for a page that exists. Say it is there and who can open it.",
5882
+ "Do not hide a navigation item and leave the page blank when a person followed a link to it. Say why they cannot see it.",
5883
+ "Do not show disabled Buttons with no reason. Leave them out, and say once at the top who can change things.",
5884
+ "Do not use `disabled` fields for a page the person can read. Disabled text is faint and cannot be focused.",
5885
+ "Do not say 'Contact your admin' on a page the person cannot change without saying who that is."
5886
+ ],
5887
+ "native": "On Apple use `ContentUnavailableView` with a lock image, the line on who can give access, and 'Go Home' in its `actions`. For a read-only settings screen, show `LabeledContent` rows in place of controls, with one footer line on who can change them.",
5888
+ "options": [
5889
+ {
5890
+ "id": "page",
5891
+ "title": "Page they cannot see",
5892
+ "useWhen": "The person opened a page their role cannot see.",
5893
+ "source": "'use client';\nimport { useState } from 'react';\nimport AppShell from 'oneslash-design-system/components/appShell';\nimport Navigation from 'oneslash-design-system/components/navigation';\nimport MenuItem from 'oneslash-design-system/components/menuItem';\nimport TitleBar from 'oneslash-design-system/components/titleBar';\nimport Surface from 'oneslash-design-system/components/surface';\nimport EmptyBox from 'oneslash-design-system/components/emptyBox';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Button from 'oneslash-design-system/components/button';\nimport { Stack } from 'oneslash-design-system/components/layout';\n\n// The places a member can open. Billing is for admins, so it is not in the list:\n// the person reached it by a link, and the page says why they cannot see it.\nconst places = [\n { label: 'Home', icon: 'House', href: '/' },\n { label: 'Invoices', icon: 'FileText', href: '/invoices' },\n { label: 'Settings', icon: 'Settings', href: '/settings' },\n];\n\nconst sidebar = (\n <Navigation aria-label=\"Main\">\n <Paragraph size=\"body1\" measure=\"none\">Acme</Paragraph>\n {places.map((p) => (\n <MenuItem\n key={p.href}\n size=\"small\"\n label={p.label}\n iconName={p.icon}\n href={p.href}\n isSelected={false}\n // A real app lets the link go to its page.\n onClick={(event: { preventDefault: () => void }) => event.preventDefault()}\n />\n ))}\n </Navigation>\n);\n\nexport default function NoAccessPage() {\n // Below md the sidebar is a Drawer; this says whether it is open.\n const [navOpen, setNavOpen] = useState(false);\n return (\n <AppShell title=\"Billing\" navOpen={navOpen} onNavOpenChange={setNavOpen} sidebar={sidebar}>\n <Stack gap=\"large\">\n {/* The page exists, so it keeps its name. It is not a 404. */}\n <TitleBar title=\"Billing\" />\n <Surface minHeight=\"tall\" align=\"center\">\n <EmptyBox\n size=\"large\"\n icon=\"Lock\"\n text=\"You do not have access to Billing\"\n secondText=\"Ask an admin: Dana Lee\"\n action={<Button size=\"medium\" type=\"secondary\" state=\"enabled\" label=\"Go Home\" href=\"/\" />}\n />\n </Surface>\n </Stack>\n </AppShell>\n );\n}\n",
5894
+ "uses": [
5895
+ "AppShell",
5896
+ "Button",
5897
+ "EmptyBox",
5898
+ "MenuItem",
5899
+ "Navigation",
5900
+ "Paragraph",
5901
+ "Stack",
5902
+ "Surface",
5903
+ "TitleBar"
5904
+ ]
5905
+ },
5906
+ {
5907
+ "id": "read-only",
5908
+ "title": "Settings they cannot change",
5909
+ "useWhen": "The person can see a settings page but cannot change it.",
5910
+ "source": "'use client';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Alert from 'oneslash-design-system/components/alert';\nimport SettingsSection from 'oneslash-design-system/components/settingsSection';\nimport TextField from 'oneslash-design-system/components/textField';\nimport { Center, Stack } from 'oneslash-design-system/components/layout';\n\n// A real app reads these from the server. Ben Carter is a member, so he can read them and not change them.\nconst general = [\n { id: 'no-access-name', label: 'Workspace name', value: 'Acme' },\n { id: 'no-access-email', label: 'Billing email', value: 'billing@acme.example' },\n { id: 'no-access-time-zone', label: 'Time zone', value: 'Central Time (US and Canada)' },\n];\nconst members = [\n { id: 'no-access-invite', label: 'Who can invite members', value: 'Admins only' },\n { id: 'no-access-domain', label: 'Email domain for new members', value: 'acme.example' },\n];\n\n// A read-only field changes nothing.\nconst unchanged = () => {};\n\nexport default function NoAccessReadOnly() {\n return (\n <Center>\n <Stack gap=\"xlarge\">\n <Heading level={1} size=\"h5\">Workspace settings</Heading>\n {/* One line at the top says why nothing can be changed, and who can. No Save Button, no disabled Buttons. */}\n <Alert type=\"info\" variant=\"inline\" message=\"Only admins can change these settings. Your admin is Dana Lee.\" autoDismiss={false} />\n <SettingsSection title=\"General\">\n {general.map((f) => (\n <TextField key={f.id} id={f.id} label={f.label} value={f.value} readOnly onChange={unchanged} />\n ))}\n </SettingsSection>\n <SettingsSection title=\"Members\">\n {members.map((f) => (\n <TextField key={f.id} id={f.id} label={f.label} value={f.value} readOnly onChange={unchanged} />\n ))}\n </SettingsSection>\n </Stack>\n </Center>\n );\n}\n",
5911
+ "uses": [
5912
+ "Alert",
5913
+ "Center",
5914
+ "Heading",
5915
+ "SettingsSection",
5916
+ "Stack",
5917
+ "TextField"
5918
+ ]
5919
+ }
5920
+ ]
5921
+ },
4891
5922
  {
4892
5923
  "id": "not-found-page",
4893
5924
  "title": "Page not found",
4894
5925
  "kind": "design",
4895
5926
  "level": "page",
4896
5927
  "area": "state",
5928
+ "surface": [
5929
+ "site",
5930
+ "app"
5931
+ ],
4897
5932
  "situation": "A person opens a link to a page that does not exist.",
4898
5933
  "do": [
4899
5934
  "Say 'Page not found' in a `Heading` with `level={1}`.",
@@ -4946,6 +5981,9 @@
4946
5981
  "kind": "design",
4947
5982
  "level": "organism",
4948
5983
  "area": "menu",
5984
+ "surface": [
5985
+ "app"
5986
+ ],
4949
5987
  "situation": "A person chooses how much a channel or a thread notifies them.",
4950
5988
  "do": [
4951
5989
  "Use an `IconButton` with `iconName=\"Bell\"`, and `BellOff` when the channel is muted.",
@@ -4996,6 +6034,10 @@
4996
6034
  "kind": "rule",
4997
6035
  "level": "rule",
4998
6036
  "area": "dashboard",
6037
+ "surface": [
6038
+ "site",
6039
+ "app"
6040
+ ],
4999
6041
  "situation": "A page shows counts, money, sizes, shares or changes.",
5000
6042
  "answer": "Use the helpers in `formatNumber` (`formatCount`, `formatMoney`, `formatPercent`, `formatBytes`, `formatDuration`), `StatTile` and `Progress`. A count is whole and grouped: '1,240'. In a tile, a count or an amount from 10,000 up shows its short form: '12.4K', '$12.4K'. A table shows the exact number, right-aligned. On a chart's axis, a number from 10,000 up shows its short form too: '12.4K'. The chart's readout and its table show the exact number. Money has its symbol and its currency's decimals: '$1,240.00', '¥1,240', 'KWD 1,240.000'. A cost under the smallest unit reads '< $0.01'. A share is a whole percent, and a small one reads '< 1%'. A size is base 1024: '52 MB', '1.2 GB'. A time reads '340 ms', '1.2 s', '2 h 24 min'. The unit is in the label or after the number in words: 'Responses', '7 of 8 seats', '340 responses, no limit'. A bare number is never shown, and a unit is never only in a tooltip. A change says its direction, its size and what it compares with: 'Up 12% from last week'. It reads 'New this week' when there was nothing before. A change in a percent is in points: 'Up 3 pts from last week'. A refund in a list of charges has a minus: '-$12.00'. In a sentence, say the word: 'Refunded $12.00'. A change has no color, because more is not good or bad by itself. Unknown is never 0. `formatNumber` shows '–' for a value it cannot read. `StatTile` shows 'No data yet'. While a number loads, a `Skeleton` holds its place. On a failure, show the case 'Load failure'. A limit is a `Progress`, which says 'Limit reached' in words.",
5001
6043
  "why": "One page that rounds a cost to four decimals and another that rounds it to two make the same bill look like two different amounts. A 0 shown while a number loads reads as a real answer, so the person believes something that is not true.",
@@ -5032,6 +6074,10 @@
5032
6074
  "kind": "design",
5033
6075
  "level": "page",
5034
6076
  "area": "auth",
6077
+ "surface": [
6078
+ "app",
6079
+ "agent"
6080
+ ],
5035
6081
  "situation": "Another app, such as a CLI or an MCP client, asks to act for a person who is logged in, and the person must allow it.",
5036
6082
  "do": [
5037
6083
  "Name the app in a `Heading` with `level={1}`: 'Acme CLI wants to connect to Acme'.",
@@ -5101,6 +6147,9 @@
5101
6147
  "kind": "design",
5102
6148
  "level": "organism",
5103
6149
  "area": "settings",
6150
+ "surface": [
6151
+ "app"
6152
+ ],
5104
6153
  "situation": "A person turns things on and off, such as which notifications they get.",
5105
6154
  "do": [
5106
6155
  "Follow the rule 'A setting saves in place, or with one Save Button'. Every `Switch` saves as soon as it changes, and the page has no Save Button.",
@@ -5143,6 +6192,10 @@
5143
6192
  "kind": "design",
5144
6193
  "level": "organism",
5145
6194
  "area": "shell",
6195
+ "surface": [
6196
+ "site",
6197
+ "app"
6198
+ ],
5146
6199
  "situation": "A person reads a long page and wants to see its sections, jump to one and know which one they are in.",
5147
6200
  "do": [
5148
6201
  "Put `OnThisPage` in the `aside` of `PageShell`. It sticks below a `SiteHeader` and shows from `xl`. `PageShell` gives each level 2 and 3 heading with an `id` a scroll margin, so `#sharing` lands below the header.",
@@ -5186,6 +6239,9 @@
5186
6239
  "kind": "design",
5187
6240
  "level": "organism",
5188
6241
  "area": "auth",
6242
+ "surface": [
6243
+ "app"
6244
+ ],
5189
6245
  "situation": "A person has just signed up, and the app needs a few things from them before it works or before it is fully set up.",
5190
6246
  "do": [
5191
6247
  "Follow the rule 'A form error shows next to the problem'.",
@@ -5262,6 +6318,9 @@
5262
6318
  "kind": "rule",
5263
6319
  "level": "rule",
5264
6320
  "area": "marketing",
6321
+ "surface": [
6322
+ "site"
6323
+ ],
5265
6324
  "situation": "A marketing page asks the visitor to do something: sign up, open the app, buy a plan.",
5266
6325
  "answer": "A page has one main action. It is a primary `Button` with the same label in the header, the hero, the pricing section and the end of the page: 'Sign Up', or 'Sign Up for Pro' on a plan. A second action is a secondary `Button`, or a `Link` that teaches, such as 'See How It Works'. It is never a second primary. Write the label as the move, in Title Case, with short prepositions lowercase. Do not write 'Get Started Free' in one place and 'Try It' in another. The main action and the second action open in the same tab, unless one goes to a store or starts a download. A link to another site, in a list or a footer, uses `external`, as the case 'Site footer' says.",
5267
6326
  "why": "A visitor who sees three names for one move wonders if they are three moves. One label everywhere tells them where every button goes, and one primary Button tells them which one matters.",
@@ -5289,6 +6348,9 @@
5289
6348
  "kind": "design",
5290
6349
  "level": "organism",
5291
6350
  "area": "menu",
6351
+ "surface": [
6352
+ "app"
6353
+ ],
5292
6354
  "situation": "A person opens a menu of less common actions, behind one button, for a thing or for the page.",
5293
6355
  "do": [
5294
6356
  "Use an `IconButton` with `iconName=\"Ellipsis\"` and a `Tooltip` of 'More'.",
@@ -5375,6 +6437,9 @@
5375
6437
  "kind": "design",
5376
6438
  "level": "organism",
5377
6439
  "area": "marketing",
6440
+ "surface": [
6441
+ "site"
6442
+ ],
5378
6443
  "situation": "A page has said what it had to say, and its last block decides what the visitor does next.",
5379
6444
  "do": [
5380
6445
  "Follow the rule 'A marketing page asks for one main action, in the same words everywhere'. The closing block uses the same labels as the header and the hero.",
@@ -5427,6 +6492,9 @@
5427
6492
  "kind": "design",
5428
6493
  "level": "organism",
5429
6494
  "area": "shell",
6495
+ "surface": [
6496
+ "app"
6497
+ ],
5430
6498
  "situation": "A page names itself at the top and offers what the person can do with it.",
5431
6499
  "do": [
5432
6500
  "Follow the rule 'On a phone, a sidebar opens as a drawer and a list opens its detail'.",
@@ -5491,6 +6559,9 @@
5491
6559
  "kind": "design",
5492
6560
  "level": "organism",
5493
6561
  "area": "dashboard",
6562
+ "surface": [
6563
+ "app"
6564
+ ],
5494
6565
  "situation": "A dashboard section lists things that wait on the person, such as questions or comments, and the list may be longer than the section.",
5495
6566
  "do": [
5496
6567
  "Follow the rule 'A number shows its unit and never shows 0 for unknown'.",
@@ -5551,6 +6622,9 @@
5551
6622
  "kind": "design",
5552
6623
  "level": "organism",
5553
6624
  "area": "content",
6625
+ "surface": [
6626
+ "site"
6627
+ ],
5554
6628
  "situation": "Some work is private. A visitor needs the password to read it, and someone who does not have it needs to know how to ask.",
5555
6629
  "do": [
5556
6630
  "Put the gate in a `Surface` with a heading that says what is behind it: 'This case study needs a password'. It is the h1 on a whole page and an h2 inside a page.",
@@ -5636,6 +6710,9 @@
5636
6710
  "kind": "design",
5637
6711
  "level": "organism",
5638
6712
  "area": "dashboard",
6713
+ "surface": [
6714
+ "app"
6715
+ ],
5639
6716
  "situation": "A workspace pays by card. The admin sees which card, changes it or removes it.",
5640
6717
  "do": [
5641
6718
  "Follow the rule 'A number shows its unit and never shows 0 for unknown'.",
@@ -5701,6 +6778,9 @@
5701
6778
  "kind": "design",
5702
6779
  "level": "organism",
5703
6780
  "area": "chat",
6781
+ "surface": [
6782
+ "app"
6783
+ ],
5704
6784
  "situation": "A thread or a task shows who is on it, and the person can find out who they all are.",
5705
6785
  "do": [
5706
6786
  "Use `AvatarStack` for four or more people. Past `max` its last circle counts the rest, such as '+3'.",
@@ -5754,6 +6834,10 @@
5754
6834
  "kind": "rule",
5755
6835
  "level": "rule",
5756
6836
  "area": "shell",
6837
+ "surface": [
6838
+ "site",
6839
+ "app"
6840
+ ],
5757
6841
  "situation": "A layout with a sidebar, a list beside its detail, or a side pane meets a phone screen.",
5758
6842
  "answer": "An app's sidebar opens in a `Drawer` from the start side, from a 'Menu' `IconButton` at the start of a top bar that names the place. `AppShell` does this. The Drawer closes on a choice, on Close, on Escape, on the scrim and when the window widens. A list beside its detail becomes two screens: the list, then the detail with a Back Button named for the list, as `SettingsLayout` does. A settings nav is such a list. A side pane takes the whole content area and has Close. It is never squeezed beside the content. A site's links go into the same kind of menu, and one main action may stay in the bar. Nothing is hidden on a phone without a way to reach it. There is no bottom tab bar on the web.",
5759
6843
  "why": "A drawer opens over the page, so the person still sees where they are, and closing it puts them back on the same page. One drawer, built into `AppShell`, works the same way in every app.",
@@ -5780,6 +6864,9 @@
5780
6864
  "kind": "design",
5781
6865
  "level": "organism",
5782
6866
  "area": "dashboard",
6867
+ "surface": [
6868
+ "app"
6869
+ ],
5783
6870
  "situation": "An admin chose another plan. Before anything changes they need to know what it costs and when it starts.",
5784
6871
  "do": [
5785
6872
  "Follow the rule 'A number shows its unit and never shows 0 for unknown'.",
@@ -5862,6 +6949,9 @@
5862
6949
  "kind": "design",
5863
6950
  "level": "organism",
5864
6951
  "area": "marketing",
6952
+ "surface": [
6953
+ "site"
6954
+ ],
5865
6955
  "situation": "A visitor to the public site wants to see every limit of every plan side by side before signing up.",
5866
6956
  "do": [
5867
6957
  "Follow the rule 'A number shows its unit and never shows 0 for unknown'.",
@@ -5878,7 +6968,7 @@
5878
6968
  "Do not build the table from a grid of boxes. A screen reader cannot read it as a table.",
5879
6969
  "Do not hide the header row on a phone. Let the table scroll sideways in its region.",
5880
6970
  "Do not put a Button in every column.",
5881
- "Do not change a price or a limit here without changing it in the cases 'Plan picker' and 'Pricing section' too.",
6971
+ "Do not change a price or a limit here without changing it in the cases 'Plan picker', 'Pricing section', 'Comparison with another product' and 'Sign-up from the site' too.",
5882
6972
  "Do not dim the other columns with tabs. Every plan stays in view."
5883
6973
  ],
5884
6974
  "native": "On Apple an app has no pricing page. The plans are in the app as a `List` with the system purchase sheet, as the case 'Plan picker' says. On iPad or Mac, a `Table` with the plans as columns works too.",
@@ -5908,6 +6998,9 @@
5908
6998
  "kind": "design",
5909
6999
  "level": "organism",
5910
7000
  "area": "dashboard",
7001
+ "surface": [
7002
+ "app"
7003
+ ],
5911
7004
  "situation": "An admin compares the plans a workspace can be on and chooses one.",
5912
7005
  "do": [
5913
7006
  "Follow the rule 'A number shows its unit and never shows 0 for unknown'.",
@@ -5917,7 +7010,8 @@
5917
7010
  "Give every other plan one Button named for the move: 'Upgrade to Pro' as primary, 'Downgrade to Free' as tertiary. It opens the case 'Plan change confirm'.",
5918
7011
  "Say a change that starts later with a Tag 'Starts Dec 1' on the new plan, and a line under the heading: 'Acme is on Pro until Dec 1, 2026, then Free.'",
5919
7012
  "Open the picker from 'Change Plan' on the case 'Billing page'. Show it only to a person who can change the plan.",
5920
- "Add a `SegmentedControl` as the case 'Range switch' says once the plans bill by the year too. Leave it out while every plan bills monthly."
7013
+ "Add a `SegmentedControl` as the case 'Range switch' says once the plans bill by the year too. Leave it out while every plan bills monthly.",
7014
+ "Use the same plan names, prices and limits on the site and in the app, as the rule 'A site promises only what the app does, in the app's words' says."
5921
7015
  ],
5922
7016
  "dont": [
5923
7017
  "Do not make a card clickable as a whole. Its Button is the one control, so a keyboard and a screen reader find it.",
@@ -5926,7 +7020,7 @@
5926
7020
  "Do not add a monthly and yearly switch when no plan bills yearly.",
5927
7021
  "Do not change a Button label to show it is busy, such as to 'Checking...'.",
5928
7022
  "Do not charge or change the plan from this page. The confirm does that.",
5929
- "Do not change a price or a limit here without changing it in the cases 'Pricing section' and 'Plan comparison' too."
7023
+ "Do not change a price or a limit here without changing it in the cases 'Pricing section', 'Plan comparison', 'Comparison with another product' and 'Sign-up from the site' too."
5930
7024
  ],
5931
7025
  "native": "On Apple use a `List` of plans with the system purchase sheet, and mark the current plan with a checkmark and the words 'Current plan'. Never build a card by hand.",
5932
7026
  "options": [
@@ -5979,6 +7073,9 @@
5979
7073
  "kind": "design",
5980
7074
  "level": "organism",
5981
7075
  "area": "agent",
7076
+ "surface": [
7077
+ "agent"
7078
+ ],
5982
7079
  "situation": "The agent wrote a plan for a task, and people approve it before the agent starts the work.",
5983
7080
  "do": [
5984
7081
  "Follow the rule 'An agent asks before a risky action': the agent starts nothing until every required person has said yes.",
@@ -6066,6 +7163,9 @@
6066
7163
  "kind": "design",
6067
7164
  "level": "organism",
6068
7165
  "area": "marketing",
7166
+ "surface": [
7167
+ "site"
7168
+ ],
6069
7169
  "situation": "A visitor to the public site compares the plans and signs up for one.",
6070
7170
  "do": [
6071
7171
  "Follow the rule 'A marketing page asks for one main action, in the same words everywhere'.",
@@ -6075,13 +7175,15 @@
6075
7175
  "Make the Button of the plan most visitors start on primary, and the others secondary. A visitor has no current plan, so no card carries 'Current plan'.",
6076
7176
  "Put the section's name in `SectionIntro`, so the section has a level 2 heading and a link of its own.",
6077
7177
  "Put one line under the cards that says what the prices are in and who pays: 'Prices in USD. Pro and Business bill each member monthly.'",
6078
- "Add a `SegmentedControl` for monthly and yearly as the case 'Range switch' says once a plan bills by the year. Leave it out while every plan bills monthly."
7178
+ "Add a `SegmentedControl` for monthly and yearly as the case 'Range switch' says once a plan bills by the year. Leave it out while every plan bills monthly.",
7179
+ "Use the same plan names, prices and limits on the site and in the app, as the rule 'A site promises only what the app does, in the app's words' says.",
7180
+ "Send a paid plan's Button to sign-up with that plan, as the case 'Sign-up from the site' says."
6079
7181
  ],
6080
7182
  "dont": [
6081
7183
  "Do not name a Button 'Get Started', 'Choose' or 'Select'. Name the plan it signs up for.",
6082
7184
  "Do not open the sign-up page in a new tab.",
6083
7185
  "Do not give two plans a primary Button.",
6084
- "Do not change a price or a limit here without changing it in the cases 'Plan picker' and 'Plan comparison' too. A visitor sees one set of plans.",
7186
+ "Do not change a price or a limit here without changing it in the cases 'Plan picker', 'Plan comparison', 'Comparison with another product' and 'Sign-up from the site' too. A visitor sees one set of plans.",
6085
7187
  "Do not make a card clickable as a whole. Its Button is the one control."
6086
7188
  ],
6087
7189
  "native": "On Apple an app has no pricing section. The plans are in the app as a `List` with the system purchase sheet, as the case 'Plan picker' says.",
@@ -6113,6 +7215,9 @@
6113
7215
  "kind": "design",
6114
7216
  "level": "organism",
6115
7217
  "area": "marketing",
7218
+ "surface": [
7219
+ "site"
7220
+ ],
6116
7221
  "situation": "A maker lists its products on one page, and each product has its own site.",
6117
7222
  "do": [
6118
7223
  "Follow the rule 'A marketing page asks for one main action, in the same words everywhere'. A list of products has no main action of its own: each card is a link, not a Button.",
@@ -6146,12 +7251,87 @@
6146
7251
  }
6147
7252
  ]
6148
7253
  },
7254
+ {
7255
+ "id": "product-demo",
7256
+ "title": "Product demo on a site",
7257
+ "kind": "design",
7258
+ "level": "organism",
7259
+ "area": "marketing",
7260
+ "surface": [
7261
+ "site"
7262
+ ],
7263
+ "situation": "A page on the public site shows the product at work, so a visitor sees what it does before they sign up.",
7264
+ "do": [
7265
+ "Follow the rule 'A site promises only what the app does, in the app's words': show only the controls, labels and features the app has.",
7266
+ "Mark the demo as an example. Put a `Tag` 'Example' on a scripted demo, and say it in the caption of a picture.",
7267
+ "Use made-up people and made-up work in the demo, never a real customer.",
7268
+ "Put a picture in a `Figure` with a caption that says what it shows. Give the `Image` an `alt` that says the same for a screen reader.",
7269
+ "Build a scripted demo from the real parts, such as `Message`, `StepList` and `SourceCard`, in a `Surface`. Then it looks like the app and changes with it.",
7270
+ "Put one Button first, before the scenes and apart from them. It reads 'Pause' while the demo plays and 'Play' while it does not. This label says what a press does next, as 'Show Danger Zone' does. It is not a status, so it may change.",
7271
+ "Keep it the same Button when its label changes, so focus stays on it.",
7272
+ "Let the visitor pick a scene with a `SegmentedControl`. Picking a scene pauses the demo.",
7273
+ "Start a scripted demo stopped, with 'Play', when the visitor asks for reduced motion. It plays only when they press 'Play'.",
7274
+ "Show each scene for at least 6 seconds, so a visitor can read it.",
7275
+ "Keep the demo out of live regions, so a screen reader is not read each scene as it changes.",
7276
+ "Stop the timers when the demo leaves the page."
7277
+ ],
7278
+ "dont": [
7279
+ "Do not pause the demo on hover only. A keyboard or touch visitor cannot hover.",
7280
+ "Do not rotate words in the page's h1.",
7281
+ "Do not show a control, a label or a plan the app does not have.",
7282
+ "Do not add a message box or other field a visitor might try to type into."
7283
+ ],
7284
+ "native": "On Apple and Android an app has no product demo. The store page shows screenshots and an app preview video, with only what the app has.",
7285
+ "options": [
7286
+ {
7287
+ "id": "still",
7288
+ "title": "One picture",
7289
+ "useWhen": "One picture of the product says enough.",
7290
+ "source": "'use client';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport SectionIntro from 'oneslash-design-system/components/sectionIntro';\nimport Figure from 'oneslash-design-system/components/figure';\nimport Image from 'oneslash-design-system/components/image';\nimport { PageSection } from 'oneslash-design-system/components/layout';\n\n// A stand-in for a screenshot of the app: a thread with a question, the agent's reply and two source cards.\n// A real page passes a screenshot of the app as it is today, with made-up people and work in it.\nconst threadPicture =\n \"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 640 400'%3E%3Crect width='640' height='400' fill='%23eef2f6'/%3E%3Crect width='150' height='400' fill='%23dfe7ef'/%3E%3Crect x='20' y='28' width='80' height='12' rx='6' fill='%23aab8c6'/%3E%3Crect x='20' y='68' width='100' height='10' rx='5' fill='%23c2cfdb'/%3E%3Crect x='20' y='94' width='90' height='10' rx='5' fill='%23c2cfdb'/%3E%3Ccircle cx='190' cy='52' r='12' fill='%23aab8c6'/%3E%3Crect x='212' y='44' width='120' height='10' rx='5' fill='%23aab8c6'/%3E%3Crect x='212' y='64' width='300' height='10' rx='5' fill='%23c2cfdb'/%3E%3Ccircle cx='190' cy='132' r='12' fill='%232f6b4f'/%3E%3Crect x='212' y='124' width='100' height='10' rx='5' fill='%232f6b4f'/%3E%3Crect x='212' y='144' width='360' height='10' rx='5' fill='%23c2cfdb'/%3E%3Crect x='212' y='164' width='280' height='10' rx='5' fill='%23c2cfdb'/%3E%3Crect x='212' y='192' width='170' height='48' rx='10' fill='%23ffffff'/%3E%3Crect x='392' y='192' width='170' height='48' rx='10' fill='%23ffffff'/%3E%3Crect x='170' y='336' width='440' height='40' rx='10' fill='%23ffffff'/%3E%3C/svg%3E\";\n\nexport default function ProductDemoStill() {\n return (\n <PageShell>\n <PageSection gap=\"xxlarge\">\n <SectionIntro id=\"product-demo-still\" name=\"Ask the agent in the thread\" statement=\"Acme Agent reads the thread and the docs, then answers with its sources.\" />\n {/* The caption says what the picture shows and that it is an example. The alt says it for a screen reader. */}\n <Figure crop={16 / 10} caption=\"Example: Dana asks when the pricing page goes live, and Acme Agent answers with two sources. The names are made up.\">\n <Image\n src={threadPicture}\n alt=\"A thread in Acme. Dana Lee asks when the new pricing page goes live. Acme Agent answers Nov 20, 2026, and links the launch plan and a message in the launch channel.\"\n width={640}\n height={400}\n />\n </Figure>\n </PageSection>\n </PageShell>\n );\n}\n",
7291
+ "uses": [
7292
+ "Figure",
7293
+ "Image",
7294
+ "PageSection",
7295
+ "PageShell",
7296
+ "SectionIntro"
7297
+ ]
7298
+ },
7299
+ {
7300
+ "id": "scripted",
7301
+ "title": "Scripted scenes",
7302
+ "useWhen": "The product is about a flow, such as asking an agent and getting an answer.",
7303
+ "source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport { BookOpen, Bot, MessageSquare } from 'lucide-react';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport SectionIntro from 'oneslash-design-system/components/sectionIntro';\nimport Surface from 'oneslash-design-system/components/surface';\nimport Message from 'oneslash-design-system/components/message';\nimport UserImage from 'oneslash-design-system/components/userImage';\nimport Tag from 'oneslash-design-system/components/tag';\nimport TimeStamp from 'oneslash-design-system/components/timeStamp';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Button from 'oneslash-design-system/components/button';\nimport SegmentedControl from 'oneslash-design-system/components/segmentedControl';\nimport StepList from 'oneslash-design-system/components/stepList';\nimport SourceCard from 'oneslash-design-system/components/sourceCard';\nimport useReducedMotion from 'oneslash-design-system/components/useReducedMotion';\nimport { Cluster, Grid, PageSection, Stack } from 'oneslash-design-system/components/layout';\n\nconst agentName = 'Acme Agent';\n\n// A made-up thread. Every label in it is one the app has: the agent's marks, its steps and its source cards.\nconst request = { from: 'Dana Lee', at: new Date('2026-11-16T14:30:00Z'), text: 'When does the new pricing page go live?' };\nconst repliedAt = new Date('2026-11-16T14:31:00Z');\nconst reply = 'The new pricing page goes live on Nov 20, 2026. Ben moved it two days to finish the plan table.';\n\nconst scenes = [\n { value: 'ask', label: 'Ask' },\n { value: 'work', label: 'Work' },\n { value: 'answer', label: 'Answer' },\n];\n\n// Long enough to read each scene.\nconst sceneTime = 6000;\n\n// The agent's marks, as the rule 'An agent says what it is' says.\nfunction agentMeta(at: Date) {\n return (\n <>\n <Tag variant=\"contained\" size=\"small\" label=\"Agent\" />\n <TimeStamp createdAt={at} dateFormat=\"absolute\" data=\"time\" />\n <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">Model name</Paragraph>\n </>\n );\n}\n\nexport default function ProductDemoScripted() {\n // The scenes start when the page opens, unless the visitor asks for reduced motion. Then the demo waits for\n // 'Play' and shows the answer. Once the visitor plays, pauses or picks a scene, their choice stands.\n const reducedMotion = useReducedMotion();\n const [chosenPaused, setChosenPaused] = useState<boolean | null>(null);\n const [chosenScene, setChosenScene] = useState<string | null>(null);\n const paused = chosenPaused ?? reducedMotion;\n const scene = chosenScene ?? (paused ? 'answer' : 'ask');\n const setPaused = setChosenPaused;\n const timer = useRef<ReturnType<typeof setInterval>>();\n\n // Moves to the next scene while the demo plays, and stops when it is paused or leaves the page.\n useEffect(() => {\n if (paused) return undefined;\n timer.current = setInterval(() => {\n setChosenScene(scenes[(scenes.findIndex((x) => x.value === scene) + 1) % scenes.length].value);\n }, sceneTime);\n return () => clearInterval(timer.current);\n }, [paused, scene]);\n\n const at = scenes.findIndex((x) => x.value === scene);\n\n return (\n <PageShell>\n <PageSection gap=\"xxlarge\">\n <SectionIntro id=\"product-demo-scripted\" name=\"Ask the agent in the thread\" statement=\"Acme Agent reads the thread and the docs, then answers with its sources.\" />\n {/* No live region: a screen reader is not read each scene as it changes. */}\n <Surface padding=\"medium\">\n <Stack gap=\"large\">\n {/* Play or Pause comes first, so a keyboard reaches it before anything moves. It is one Button whose label\n says what pressing it does, so focus stays on it when the label changes. Picking a scene pauses too. */}\n <Cluster justify=\"between\">\n <Cluster gap=\"xlarge\">\n <Button\n size=\"small\"\n type=\"secondary\"\n state=\"enabled\"\n label={paused ? 'Play' : 'Pause'}\n onClickButton={() => setPaused(!paused)}\n />\n <SegmentedControl\n size=\"small\"\n width=\"fit\"\n aria-label=\"Scene\"\n options={scenes}\n value={scene}\n onChange={(value) => {\n setPaused(true);\n setChosenScene(value);\n }}\n />\n </Cluster>\n <Tag variant=\"textOnly\" size=\"small\" label=\"Example\" />\n </Cluster>\n <Stack gap=\"small\">\n <Message\n aria-label={request.from}\n avatar={<UserImage userHandle={request.from} decorative />}\n name={request.from}\n meta={<TimeStamp createdAt={request.at} dateFormat=\"absolute\" data=\"time\" />}\n >\n <Paragraph measure=\"none\">{request.text}</Paragraph>\n </Message>\n {at >= 1 && (\n <Message\n aria-label={`${agentName}, agent`}\n avatar={<UserImage userHandle={agentName} icon={Bot} decorative />}\n name={agentName}\n meta={agentMeta(repliedAt)}\n footer={\n at === 2 ? (\n // Plain cards: a demo on the site opens nothing.\n <Grid columns={2} gap=\"medium\">\n <SourceCard icon={BookOpen} title=\"Launch plan\" meta=\"Docs · Nov 14, 2026\" />\n <SourceCard icon={MessageSquare} title=\"Pricing page date\" meta=\"#launch · Nov 15, 2026\" />\n </Grid>\n ) : undefined\n }\n >\n {at === 2 ? (\n <Paragraph measure=\"none\">{reply}</Paragraph>\n ) : (\n <Stack gap=\"medium\">\n <Paragraph size=\"caption\" tone=\"secondary\" measure=\"none\">Working for 4 seconds</Paragraph>\n <StepList\n aria-label=\"Acme Agent's steps\"\n steps={[\n { label: 'Read the thread in #launch', status: 'done' },\n { label: 'Read the launch plan', status: 'running' },\n ]}\n />\n </Stack>\n )}\n </Message>\n )}\n </Stack>\n </Stack>\n </Surface>\n </PageSection>\n </PageShell>\n );\n}\n",
7304
+ "uses": [
7305
+ "Button",
7306
+ "Cluster",
7307
+ "Grid",
7308
+ "Message",
7309
+ "PageSection",
7310
+ "PageShell",
7311
+ "Paragraph",
7312
+ "SectionIntro",
7313
+ "SegmentedControl",
7314
+ "SourceCard",
7315
+ "Stack",
7316
+ "StepList",
7317
+ "Surface",
7318
+ "Tag",
7319
+ "TimeStamp",
7320
+ "UserImage",
7321
+ "useReducedMotion"
7322
+ ]
7323
+ }
7324
+ ]
7325
+ },
6149
7326
  {
6150
7327
  "id": "profile-form",
6151
7328
  "title": "Profile",
6152
7329
  "kind": "design",
6153
7330
  "level": "organism",
6154
7331
  "area": "settings",
7332
+ "surface": [
7333
+ "app"
7334
+ ],
6155
7335
  "situation": "A person changes how they appear and how they sign in: their picture, their name and their password.",
6156
7336
  "do": [
6157
7337
  "Follow the rule 'A setting saves in place, or with one Save Button'.",
@@ -6206,6 +7386,9 @@
6206
7386
  "kind": "design",
6207
7387
  "level": "organism",
6208
7388
  "area": "menu",
7389
+ "surface": [
7390
+ "app"
7391
+ ],
6209
7392
  "situation": "A person jumps to a channel, task or document by typing part of its name, from anywhere in the product.",
6210
7393
  "do": [
6211
7394
  "Open it with Cmd+K, or Ctrl+K on Windows, and with a visible 'Go to' Button. A shortcut alone is not found.",
@@ -6257,6 +7440,10 @@
6257
7440
  "kind": "design",
6258
7441
  "level": "organism",
6259
7442
  "area": "menu",
7443
+ "surface": [
7444
+ "site",
7445
+ "app"
7446
+ ],
6260
7447
  "situation": "A person changes the time range of the numbers or a list on the same page, such as Week, Month or Quarter.",
6261
7448
  "do": [
6262
7449
  "Follow the rule 'A number shows its unit and never shows 0 for unknown'.",
@@ -6297,6 +7484,9 @@
6297
7484
  "kind": "design",
6298
7485
  "level": "organism",
6299
7486
  "area": "confirm",
7487
+ "surface": [
7488
+ "app"
7489
+ ],
6300
7490
  "situation": "A person renames something, such as a project or a channel.",
6301
7491
  "do": [
6302
7492
  "Title the Modal 'Rename' and the thing, such as 'Rename Project', and give its action the same verb: 'Rename'.",
@@ -6355,6 +7545,9 @@
6355
7545
  "kind": "design",
6356
7546
  "level": "organism",
6357
7547
  "area": "agent",
7548
+ "surface": [
7549
+ "agent"
7550
+ ],
6358
7551
  "situation": "The agent has replied, and the person can say whether the reply helped.",
6359
7552
  "do": [
6360
7553
  "Put a row of small `IconButton`s with Tooltips in the agent reply's `footer`: thumbs up, thumbs down, Copy, then Regenerate.",
@@ -6434,6 +7627,9 @@
6434
7627
  "kind": "design",
6435
7628
  "level": "organism",
6436
7629
  "area": "agent",
7630
+ "surface": [
7631
+ "agent"
7632
+ ],
6437
7633
  "situation": "The agent answered from things it read, and the person may want to check them.",
6438
7634
  "do": [
6439
7635
  "Follow the rule 'An agent shows its sources': put the sources in the reply's `footer`, directly under the reply.",
@@ -6503,6 +7699,10 @@
6503
7699
  "kind": "design",
6504
7700
  "level": "page",
6505
7701
  "area": "state",
7702
+ "surface": [
7703
+ "site",
7704
+ "app"
7705
+ ],
6506
7706
  "situation": "A page or a pane is loading, and there is nothing to show yet.",
6507
7707
  "do": [
6508
7708
  "Show the shell as soon as it can, and the spinner only where content is loading.",
@@ -6551,6 +7751,9 @@
6551
7751
  "kind": "design",
6552
7752
  "level": "organism",
6553
7753
  "area": "menu",
7754
+ "surface": [
7755
+ "app"
7756
+ ],
6554
7757
  "situation": "A person chooses where a search or a question looks, such as one workspace or all of them.",
6555
7758
  "do": [
6556
7759
  "Use a small tertiary `Button` whose label is the current scope, with `actionIcon=\"ChevronDown\"` so it looks like it opens a menu.",
@@ -6595,6 +7798,9 @@
6595
7798
  "kind": "design",
6596
7799
  "level": "organism",
6597
7800
  "area": "content",
7801
+ "surface": [
7802
+ "site"
7803
+ ],
6598
7804
  "situation": "A section of a site, such as the guides, has its own first page that shows the places inside it, so a person can pick one.",
6599
7805
  "do": [
6600
7806
  "Use `PageHeader` with `level={1}`: the section's name is the one level 1 heading, with a `lede` of one sentence.",
@@ -6645,12 +7851,79 @@
6645
7851
  }
6646
7852
  ]
6647
7853
  },
7854
+ {
7855
+ "id": "session-expired",
7856
+ "title": "Session that ended",
7857
+ "kind": "design",
7858
+ "level": "organism",
7859
+ "area": "state",
7860
+ "surface": [
7861
+ "app"
7862
+ ],
7863
+ "situation": "A person is using the app when their login ends, such as after a long break or a password change somewhere else.",
7864
+ "do": [
7865
+ "Follow the case 'Login page' for the fields, the errors and the loading Button.",
7866
+ "Open a small `Modal` titled 'Log In Again' over the page when the person has unsaved work, so the work stays where it is.",
7867
+ "Say whose login ended and that the work is safe: 'Log in as dana@acme.example to keep working. Your note stays on this page.'",
7868
+ "Ask only for the password in the Modal, or show the provider's Button, such as 'Continue with Google', for a person who logs in that way.",
7869
+ "Show 'Log In' as `loading` while it runs, and keep its label.",
7870
+ "Return focus to where it was when the Modal closes, such as the field with the typed text.",
7871
+ "Open the login page with an info `Alert` when nothing would be lost: 'You were logged out. Log in to go back to Invoices.'",
7872
+ "Keep the page the person was on in the address, and go back to it after they log in.",
7873
+ "Fill in the email the person used, so they only type the password."
7874
+ ],
7875
+ "dont": [
7876
+ "Do not send the person to the login page without a word, and drop what they typed.",
7877
+ "Do not close the Modal on Escape or a click outside. The page cannot save until the person logs in.",
7878
+ "Do not land on the home page after the login when the person came from another page.",
7879
+ "Do not say 'Session expired' or 'Token invalid'. Say they were logged out and what to do."
7880
+ ],
7881
+ "native": "On Apple show the login as a sheet over the screen with the password field, so the screen behind keeps its state; use `ASWebAuthenticationSession` for a provider. On Android show a dialog with the password field, and keep the screen's state in its `ViewModel`.",
7882
+ "options": [
7883
+ {
7884
+ "id": "in-place",
7885
+ "title": "Log in over the page",
7886
+ "useWhen": "The person has unsaved work on the page, such as text they typed.",
7887
+ "source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport TitleBar from 'oneslash-design-system/components/titleBar';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport TextField from 'oneslash-design-system/components/textField';\nimport Button from 'oneslash-design-system/components/button';\nimport Modal from 'oneslash-design-system/components/modal';\nimport { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';\n\n// A real app reads this from the session that ended.\nconst email = 'dana@acme.example';\n\nexport default function SessionExpiredInPlace() {\n // Dana was typing a note when her login ended. The note stays on the page behind the Modal.\n const [note, setNote] = useState('Thanks for the order. The second box ships on Nov 20, 2026, and the invoice covers both.');\n // Opens on the Modal, as if the login just ended.\n const [loggedOut, setLoggedOut] = useState(true);\n const [password, setPassword] = useState('');\n const [passwordError, setPasswordError] = useState('');\n const [loading, setLoading] = useState(false);\n const timer = useRef<ReturnType<typeof setTimeout>>();\n\n // Stops the request if the example goes away before it ends.\n useEffect(() => () => clearTimeout(timer.current), []);\n\n function logIn() {\n if (loading) return;\n if (!password) {\n setPasswordError('Enter your password.');\n return;\n }\n setPasswordError('');\n setLoading(true);\n // Stands in for the request to the server.\n timer.current = setTimeout(() => {\n setLoading(false);\n setPassword('');\n // The Modal gives focus back to the field the person was typing in.\n setLoggedOut(false);\n }, 1200);\n }\n\n return (\n <Center width=\"page\">\n <Stack gap=\"large\">\n <TitleBar title=\"INV-1291\" />\n <Stack gap=\"medium\">\n {/* The field had focus when the login ended. A real app does not move it. */}\n <TextField id=\"session-expired-note\" label=\"Note to the customer\" multiline maxRows={6} autoFocus value={note} onChange={(e) => setNote(e.target.value)} />\n <Cluster>\n <Button size=\"medium\" type=\"primary\" state=\"enabled\" label=\"Save Note\" onClickButton={() => console.info('Save the note')} />\n </Cluster>\n </Stack>\n </Stack>\n {/* The page cannot save until the person logs in, so Escape and a click outside do not close it. */}\n <Modal\n isOpen={loggedOut}\n size=\"small\"\n title=\"Log In Again\"\n initialFocus=\"body\"\n onClose={() => {}}\n actions={<Button size=\"small\" type=\"primary\" state=\"enabled\" label=\"Log In\" loading={loading} onClickButton={logIn} />}\n >\n <Paragraph measure=\"none\">{`Log in as ${email} to keep working. Your note stays on this page.`}</Paragraph>\n <TextField\n id=\"session-expired-password\"\n label=\"Password\"\n type=\"password\"\n autoComplete=\"current-password\"\n value={password}\n disabled={loading}\n error={Boolean(passwordError)}\n errorText={passwordError}\n onChange={(e) => { setPassword(e.target.value); setPasswordError(''); }}\n onKeyDown={(e) => {\n if (e.key === 'Enter') {\n e.preventDefault();\n logIn();\n }\n }}\n />\n {/* A new tab, so the note stays on this page. */}\n <Button size=\"small\" type=\"textOnly\" state={loading ? 'disabled' : 'enabled'} label=\"Forgot Password?\" href=\"/forgot-password\" openInNewTab />\n </Modal>\n </Center>\n );\n}\n",
7888
+ "uses": [
7889
+ "Button",
7890
+ "Center",
7891
+ "Cluster",
7892
+ "Modal",
7893
+ "Paragraph",
7894
+ "Stack",
7895
+ "TextField",
7896
+ "TitleBar"
7897
+ ]
7898
+ },
7899
+ {
7900
+ "id": "redirect",
7901
+ "title": "Log in, then go back",
7902
+ "useWhen": "Nothing on the page would be lost, so the login page can take its place.",
7903
+ "source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport Image from 'oneslash-design-system/components/image';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Form from 'oneslash-design-system/components/form';\nimport Alert from 'oneslash-design-system/components/alert';\nimport TextField from 'oneslash-design-system/components/textField';\nimport Button from 'oneslash-design-system/components/button';\nimport Line from 'oneslash-design-system/components/line';\nimport BrandIcon from 'oneslash-design-system/components/brandIcon';\nimport { Center } from 'oneslash-design-system/components/layout';\n\n// The product's mark. A real app passes its own file.\nconst productMark =\n \"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Crect width='40' height='40' rx='10' fill='%232f6b4f'/%3E%3Cpath d='M20 9 31 31h-6l-5-11-5 11H9z' fill='%23fff'/%3E%3C/svg%3E\";\n\n// A real app passes the router from its framework, such as Next's useRouter().\nconst router = { push: (url: string) => console.info(`Go to ${url}`) };\n\n// The app sent the person here from '/invoices' with '/login?next=%2Finvoices'. A real app reads it from the address,\n// and goes back only to a page of its own.\nconst next = { path: '/invoices', name: 'Invoices' };\n\nexport default function SessionExpiredRedirect() {\n // The email the person used last, so they only type the password.\n const [email, setEmail] = useState('dana@acme.example');\n const [password, setPassword] = useState('');\n const [emailError, setEmailError] = useState('');\n const [passwordError, setPasswordError] = useState('');\n const [loading, setLoading] = useState(false);\n const timer = useRef<ReturnType<typeof setTimeout>>();\n\n // Stops the request if the example goes away before it ends.\n useEffect(() => () => clearTimeout(timer.current), []);\n\n function handleSubmit() {\n if (loading) return;\n setEmailError('');\n setPasswordError('');\n if (!email.trim()) {\n setEmailError('Enter your email.');\n return;\n }\n if (!password) {\n setPasswordError('Enter your password.');\n return;\n }\n setLoading(true);\n // Stands in for the request to the server. After it, the person goes back to the page they were on.\n timer.current = setTimeout(() => {\n setLoading(false);\n router.push(next.path);\n }, 1200);\n }\n\n return (\n <Center fill>\n <Image src={productMark} alt=\"Acme\" width={40} height={40} />\n <Heading level={1} size=\"h5\">Log in to Acme</Heading>\n <Form aria-label=\"Log in\" onSubmit={handleSubmit}>\n <Alert type=\"info\" variant=\"inline\" message={`You were logged out. Log in to go back to ${next.name}.`} autoDismiss={false} />\n <TextField id=\"session-expired-email\" label=\"Email\" type=\"email\" autoComplete=\"username\" value={email} disabled={loading} error={Boolean(emailError)} errorText={emailError} onChange={(e) => { setEmail(e.target.value); setEmailError(''); }} />\n <TextField id=\"session-expired-login-password\" label=\"Password\" type=\"password\" autoComplete=\"current-password\" value={password} disabled={loading} error={Boolean(passwordError)} errorText={passwordError} onChange={(e) => { setPassword(e.target.value); setPasswordError(''); }} />\n <Button size=\"medium\" type=\"primary\" state=\"enabled\" label=\"Log In\" htmlType=\"submit\" loading={loading} />\n <Button size=\"medium\" type=\"textOnly\" state={loading ? 'disabled' : 'enabled'} label=\"Forgot Password?\" />\n </Form>\n <Line label=\"or\" />\n <Button size=\"medium\" type=\"secondary\" state=\"enabled\" label=\"Continue with Google\" decoIcon={<BrandIcon name=\"google\" />} />\n </Center>\n );\n}\n",
7904
+ "uses": [
7905
+ "Alert",
7906
+ "BrandIcon",
7907
+ "Button",
7908
+ "Center",
7909
+ "Form",
7910
+ "Heading",
7911
+ "Image",
7912
+ "Line",
7913
+ "TextField"
7914
+ ]
7915
+ }
7916
+ ]
7917
+ },
6648
7918
  {
6649
7919
  "id": "set-new-password",
6650
7920
  "title": "Set new password",
6651
7921
  "kind": "design",
6652
7922
  "level": "page",
6653
7923
  "area": "auth",
7924
+ "surface": [
7925
+ "app"
7926
+ ],
6654
7927
  "situation": "A person opened the link to reset their password and now chooses a new one.",
6655
7928
  "do": [
6656
7929
  "Name the page 'Set new password' in a `Heading` with `level={1}`, and name the account it is for.",
@@ -6714,6 +7987,9 @@
6714
7987
  "kind": "design",
6715
7988
  "level": "page",
6716
7989
  "area": "settings",
7990
+ "surface": [
7991
+ "app"
7992
+ ],
6717
7993
  "situation": "A person opens the settings of the product and looks for one area, such as Profile or Billing.",
6718
7994
  "do": [
6719
7995
  "Title the page 'Settings' with a level 1 `Heading`.",
@@ -6794,6 +8070,10 @@
6794
8070
  "kind": "rule",
6795
8071
  "level": "rule",
6796
8072
  "area": "settings",
8073
+ "surface": [
8074
+ "site",
8075
+ "app"
8076
+ ],
6797
8077
  "situation": "A person changes a setting.",
6798
8078
  "answer": "A control that stands alone saves as soon as it changes: a `Switch`, a choice in a `RadioGroup` or a `Select`, or a picture the person chooses. It shows nothing on success, because the control already shows the new value. While the request runs it is busy: a `Switch` takes `busy`, and a `RadioGroup` or `Select` is disabled. If the save fails, the control goes back to its old value and says why next to itself: in a Switch's `error`, in the error line of its `FormField`, or in an inline error `Alert` under a control with no visible label, such as a role in a row. A group of fields that belong together, such as a name, a profile, instructions or a budget, has one Save Button for the whole group. The Button is `loading` while it saves, keeps its label, then reads 'Saved' for 2 seconds. It is disabled while nothing has changed. A group that fails to save follows the rule 'A form error shows next to the problem'. Leaving with unsaved changes follows the case 'Unsaved changes'. Never mix both in one group: a Switch beside a Save Button leaves the person unsure which one is saved. Never show a toast for a setting saved in place. The one exception is a setting chosen from a menu: the menu closes, so a failed save shows in a toast and the control goes back to its old value. A person who cannot change a setting sees it read-only, with one line that says who can change it.",
6799
8079
  "why": "A control that saves by itself needs no button, and a group needs one place to say it is saved. Mixing the two makes people guess what is saved and what is not.",
@@ -6823,6 +8103,9 @@
6823
8103
  "kind": "design",
6824
8104
  "level": "organism",
6825
8105
  "area": "shell",
8106
+ "surface": [
8107
+ "app"
8108
+ ],
6826
8109
  "situation": "A person opens more about the page, such as its members, its history or a document, without leaving the page.",
6827
8110
  "do": [
6828
8111
  "Follow the rule 'On a phone, a sidebar opens as a drawer and a list opens its detail': on a phone a pane takes the whole content area.",
@@ -6892,6 +8175,9 @@
6892
8175
  "kind": "design",
6893
8176
  "level": "organism",
6894
8177
  "area": "shell",
8178
+ "surface": [
8179
+ "app"
8180
+ ],
6895
8181
  "situation": "A person looks down the sidebar for a place, and for what has something new in it.",
6896
8182
  "do": [
6897
8183
  "Follow the rule 'On a phone, a sidebar opens as a drawer and a list opens its detail'.",
@@ -6952,6 +8238,9 @@
6952
8238
  "kind": "design",
6953
8239
  "level": "page",
6954
8240
  "area": "auth",
8241
+ "surface": [
8242
+ "app"
8243
+ ],
6955
8244
  "situation": "A person who has no account yet opens the product and wants one.",
6956
8245
  "do": [
6957
8246
  "Ask only for what the account needs: name, email and password.",
@@ -6964,7 +8253,8 @@
6964
8253
  "Show the check-your-email view in place of the form when the email must be confirmed, for every address, even one that already has an account. Tell that person by email that they can log in.",
6965
8254
  "Keep the submit Button loading until the check-your-email view shows.",
6966
8255
  "Name the provider on its button: 'Continue with Google'.",
6967
- "Link or tab to login for people who already have an account."
8256
+ "Link or tab to login for people who already have an account.",
8257
+ "Follow the case 'Sign-up from the site' when the visitor chose a plan first."
6968
8258
  ],
6969
8259
  "dont": [
6970
8260
  "Do not ask for anything the account can do without, such as a username or the password twice.",
@@ -7042,12 +8332,97 @@
7042
8332
  }
7043
8333
  ]
7044
8334
  },
8335
+ {
8336
+ "id": "signup-from-site",
8337
+ "title": "Sign-up from the site",
8338
+ "kind": "design",
8339
+ "level": "page",
8340
+ "area": "auth",
8341
+ "surface": [
8342
+ "site",
8343
+ "app"
8344
+ ],
8345
+ "situation": "A visitor pressed a Button on the public site and lands on the app's sign-up page, sometimes with a paid plan already picked.",
8346
+ "do": [
8347
+ "Follow the rule 'A site promises only what the app does, in the app's words': 'Sign Up' lands on sign-up, and a picked plan comes with it.",
8348
+ "Follow the case 'Sign-up page' in 'Centered column' for the fields, the errors and the loading Button.",
8349
+ "Open the 'Sign Up' tab, not 'Log In', when the visitor pressed 'Sign Up'.",
8350
+ "Carry the plan in the address, such as '/sign-up?plan=pro', and read it on the sign-up page.",
8351
+ "Put an info line above the form that names the plan, its price and when the person pays: 'You picked Pro, $8.00 per member per month. You pay after a 14-day trial.'",
8352
+ "Put a `Link` 'Change Plan' under that line. It goes back to the pricing section.",
8353
+ "Use the plan names and prices of the case 'Plan picker', word for word.",
8354
+ "Keep the plan when a submit fails, with the line and the fields as they were.",
8355
+ "Show the plan again on the first page after sign-up, so the person sees it was kept.",
8356
+ "Keep the plan in the 'Log In' tab's address too, for a visitor who already has an account.",
8357
+ "Show the plain sign-up for Free, and for a plan the app does not know.",
8358
+ "Carry the plan through a provider's sign-in, such as 'Continue with Google', too."
8359
+ ],
8360
+ "dont": [
8361
+ "Do not ask for a card before the account exists.",
8362
+ "Do not drop a picked plan without a word. Say it, or keep it.",
8363
+ "Do not send a 'Sign Up' Button to the login page.",
8364
+ "Do not show a plan line for a plan the app does not have."
8365
+ ],
8366
+ "native": "On Apple and Android the store page is the site. A plan is bought in the app with the system purchase sheet, after the account exists.",
8367
+ "options": [
8368
+ {
8369
+ "id": "plain",
8370
+ "title": "From Sign Up",
8371
+ "useWhen": "The visitor pressed 'Sign Up' on the site.",
8372
+ "source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport { Mail } from 'lucide-react';\nimport Image from 'oneslash-design-system/components/image';\nimport TabsContainer from 'oneslash-design-system/components/tabsContainer';\nimport Tab from 'oneslash-design-system/components/tab';\nimport Form from 'oneslash-design-system/components/form';\nimport Alert from 'oneslash-design-system/components/alert';\nimport TextField from 'oneslash-design-system/components/textField';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Icon from 'oneslash-design-system/components/icon';\nimport Button from 'oneslash-design-system/components/button';\nimport Line from 'oneslash-design-system/components/line';\nimport BrandIcon from 'oneslash-design-system/components/brandIcon';\nimport { Center, Stack } from 'oneslash-design-system/components/layout';\n\n// The product's mark. A real app passes its own file.\nconst productMark =\n \"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Crect width='40' height='40' rx='10' fill='%232f6b4f'/%3E%3Cpath d='M20 9 31 31h-6l-5-11-5 11H9z' fill='%23fff'/%3E%3C/svg%3E\";\n\n// A real app passes the router from its framework, such as Next's useRouter().\nconst router = { push: (url: string) => console.info(`Go to ${url}`) };\n\n// A small check: some text, an @, then some text.\nfunction looksLikeEmail(value: string) {\n return /^[^@\\s]+@[^@\\s]+$/.test(value);\n}\n\n// The visitor pressed 'Sign Up' on the site, which links to '/sign-up', so the page opens on the Sign Up tab.\nexport default function SignupFromSitePlain() {\n const [name, setName] = useState('Dana Lee');\n const [email, setEmail] = useState('dana@acme.example');\n const [password, setPassword] = useState('');\n const [error, setError] = useState('');\n const [nameError, setNameError] = useState('');\n const [emailError, setEmailError] = useState('');\n const [passwordError, setPasswordError] = useState('');\n const [loading, setLoading] = useState(false);\n // The address the link went to. Set once the account request ends, which shows the check-your-email view.\n const [sentTo, setSentTo] = useState('');\n const [resending, setResending] = useState(false);\n const [resent, setResent] = useState(false);\n const timer = useRef<ReturnType<typeof setTimeout>>();\n\n // Stops the request if the example goes away before it ends.\n useEffect(() => () => clearTimeout(timer.current), []);\n\n // 'Sent' shows for 2 seconds, then the Button reads 'Send Again'.\n useEffect(() => {\n if (!resent) return;\n const timer = setTimeout(() => setResent(false), 2000);\n return () => clearTimeout(timer);\n }, [resent]);\n\n function handleSubmit() {\n if (loading) return;\n setError('');\n setNameError('');\n setEmailError('');\n setPasswordError('');\n if (!name.trim()) {\n setNameError('Enter your name.');\n return;\n }\n if (!email.trim()) {\n setEmailError('Enter your email.');\n return;\n }\n if (!looksLikeEmail(email.trim())) {\n setEmailError('Enter an email address, like name@example.com.');\n return;\n }\n if (password.length < 8) {\n setPasswordError('Use at least 8 characters.');\n return;\n }\n setLoading(true);\n const address = email.trim();\n // Stands in for the request to the server.\n // A failed request calls setError with one sentence instead, such as 'Your account was not created. Try again.'\n timer.current = setTimeout(() => {\n // Every address goes on to the same view, so the page never says whether it has an account.\n // The Button stays loading until the view changes.\n setLoading(false);\n setSentTo(address);\n }, 1200);\n }\n\n function handleSendAgain() {\n // One click sends one email: clicks while it sends or reads 'Sent' do nothing.\n if (resending || resent) return;\n setResending(true);\n // Stands in for the request to the server.\n // A failed request shows an inline error Alert above the Buttons, such as 'The email was not sent. Try again.'\n timer.current = setTimeout(() => {\n setResending(false);\n setResent(true);\n }, 1200);\n }\n\n // The same view as the 'Check your email' case, in place of the form.\n if (sentTo) {\n return (\n <Center fill>\n <Icon icon={Mail} size=\"large\" color=\"secondary\" />\n <Stack gap=\"medium\">\n <Heading level={1} size=\"h5\">Check your email</Heading>\n <Paragraph tone=\"secondary\" measure=\"none\">We sent a link to {sentTo}. Open it to continue.</Paragraph>\n </Stack>\n <Stack gap=\"large\">\n <Button size=\"medium\" type=\"secondary\" state=\"enabled\" label={resent ? 'Sent' : 'Send Again'} loading={resending} onClickButton={handleSendAgain} />\n <Button size=\"medium\" type=\"textOnly\" state=\"enabled\" label=\"Back to Login\" onClickButton={() => router.push('/login')} />\n </Stack>\n </Center>\n );\n }\n\n return (\n <Center fill>\n <Image src={productMark} alt=\"Acme\" width={40} height={40} />\n <TabsContainer fill>\n <Tab label=\"Log In\" isSelected={false} href=\"/login\" router={router} onClickTab={() => {}} />\n <Tab label=\"Sign Up\" isSelected onClickTab={() => {}} />\n </TabsContainer>\n <Form aria-label=\"Sign up\" onSubmit={handleSubmit}>\n {error && <Alert type=\"error\" variant=\"inline\" message={error} showCloseButton onClose={() => setError('')} />}\n <TextField id=\"signup-from-site-name\" label=\"Name\" autoComplete=\"name\" value={name} disabled={loading} error={Boolean(nameError)} errorText={nameError} onChange={(e) => { setName(e.target.value); setNameError(''); }} />\n <TextField id=\"signup-from-site-email\" label=\"Email\" type=\"email\" autoComplete=\"username\" value={email} disabled={loading} error={Boolean(emailError)} errorText={emailError} onChange={(e) => { setEmail(e.target.value); setEmailError(''); }} />\n <TextField id=\"signup-from-site-password\" label=\"Password\" type=\"password\" autoComplete=\"new-password\" value={password} disabled={loading} error={Boolean(passwordError)} errorText={passwordError} helperText=\"Use at least 8 characters.\" onChange={(e) => { setPassword(e.target.value); setPasswordError(''); }} />\n <Button size=\"medium\" type=\"primary\" state=\"enabled\" label=\"Sign Up\" htmlType=\"submit\" loading={loading} />\n </Form>\n <Line label=\"or\" />\n <Button size=\"medium\" type=\"secondary\" state=\"enabled\" label=\"Continue with Google\" decoIcon={<BrandIcon name=\"google\" />} />\n </Center>\n );\n}\n",
8373
+ "uses": [
8374
+ "Alert",
8375
+ "BrandIcon",
8376
+ "Button",
8377
+ "Center",
8378
+ "Form",
8379
+ "Heading",
8380
+ "Icon",
8381
+ "Image",
8382
+ "Line",
8383
+ "Paragraph",
8384
+ "Stack",
8385
+ "Tab",
8386
+ "TabsContainer",
8387
+ "TextField"
8388
+ ]
8389
+ },
8390
+ {
8391
+ "id": "with-plan",
8392
+ "title": "With a plan",
8393
+ "useWhen": "The visitor chose a paid plan on the site, such as 'Sign Up for Pro'.",
8394
+ "source": "'use client';\nimport { useEffect, useRef, useState } from 'react';\nimport { Mail } from 'lucide-react';\nimport Image from 'oneslash-design-system/components/image';\nimport TabsContainer from 'oneslash-design-system/components/tabsContainer';\nimport Tab from 'oneslash-design-system/components/tab';\nimport Form from 'oneslash-design-system/components/form';\nimport Alert from 'oneslash-design-system/components/alert';\nimport TextField from 'oneslash-design-system/components/textField';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Icon from 'oneslash-design-system/components/icon';\nimport Button from 'oneslash-design-system/components/button';\nimport Link from 'oneslash-design-system/components/link';\nimport Line from 'oneslash-design-system/components/line';\nimport BrandIcon from 'oneslash-design-system/components/brandIcon';\nimport { formatMoney } from 'oneslash-design-system/components/formatNumber';\nimport { Center, Stack } from 'oneslash-design-system/components/layout';\n\n// The product's mark. A real app passes its own file.\nconst productMark =\n \"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Crect width='40' height='40' rx='10' fill='%232f6b4f'/%3E%3Cpath d='M20 9 31 31h-6l-5-11-5 11H9z' fill='%23fff'/%3E%3C/svg%3E\";\n\n// A real app passes the router from its framework, such as Next's useRouter().\nconst router = { push: (url: string) => console.info(`Go to ${url}`) };\n\n// The paid plans, with the names and prices of the case 'Plan picker'. A real app reads them from the same place.\n// Free needs no line: it is what the plain sign-up gives.\nconst paidPlans: Record<string, { name: string; price: number }> = {\n pro: { name: 'Pro', price: 8 },\n business: { name: 'Business', price: 16 },\n};\n\nconst trialDays = 14;\n\n// A small check: some text, an @, then some text.\nfunction looksLikeEmail(value: string) {\n return /^[^@\\s]+@[^@\\s]+$/.test(value);\n}\n\n// `plan` is read from the address, such as '/sign-up?plan=pro'. A plan the app does not know shows the plain sign-up.\n// `failOnce` is for tests only: the first request fails, so the plan can be seen to stay.\nexport default function SignupFromSiteWithPlan({ plan = 'pro', failOnce = false }: { plan?: string; failOnce?: boolean } = {}) {\n const picked = Object.prototype.hasOwnProperty.call(paidPlans, plan) ? paidPlans[plan] : undefined;\n const [name, setName] = useState('Dana Lee');\n const [email, setEmail] = useState('dana@acme.example');\n const [password, setPassword] = useState('');\n const [error, setError] = useState('');\n const [nameError, setNameError] = useState('');\n const [emailError, setEmailError] = useState('');\n const [passwordError, setPasswordError] = useState('');\n const [loading, setLoading] = useState(false);\n // The address the link went to. Set once the account request ends, which shows the check-your-email view.\n const [sentTo, setSentTo] = useState('');\n const [resending, setResending] = useState(false);\n const [resent, setResent] = useState(false);\n const timer = useRef<ReturnType<typeof setTimeout>>();\n const failNext = useRef(failOnce);\n\n // Stops the request if the example goes away before it ends.\n useEffect(() => () => clearTimeout(timer.current), []);\n\n // 'Sent' shows for 2 seconds, then the Button reads 'Send Again'.\n useEffect(() => {\n if (!resent) return;\n const timer = setTimeout(() => setResent(false), 2000);\n return () => clearTimeout(timer);\n }, [resent]);\n\n function handleSubmit() {\n if (loading) return;\n setError('');\n setNameError('');\n setEmailError('');\n setPasswordError('');\n if (!name.trim()) {\n setNameError('Enter your name.');\n return;\n }\n if (!email.trim()) {\n setEmailError('Enter your email.');\n return;\n }\n if (!looksLikeEmail(email.trim())) {\n setEmailError('Enter an email address, like name@example.com.');\n return;\n }\n if (password.length < 8) {\n setPasswordError('Use at least 8 characters.');\n return;\n }\n setLoading(true);\n const address = email.trim();\n // Stands in for the request to the server. It sends the plan with the account, so the app starts the trial on it.\n timer.current = setTimeout(() => {\n setLoading(false);\n if (failNext.current) {\n failNext.current = false;\n // The plan line, the plan and the fields stay as they were.\n setError('Your account was not created. Try again.');\n return;\n }\n // Every address goes on to the same view, so the page never says whether it has an account.\n // The Button stays loading until the view changes.\n setSentTo(address);\n }, 1200);\n }\n\n function handleSendAgain() {\n // One click sends one email: clicks while it sends or reads 'Sent' do nothing.\n if (resending || resent) return;\n setResending(true);\n // Stands in for the request to the server.\n // A failed request shows an inline error Alert above the Buttons, such as 'The email was not sent. Try again.'\n timer.current = setTimeout(() => {\n setResending(false);\n setResent(true);\n }, 1200);\n }\n\n // The first page after sign-up says the plan again, so the person sees it was kept.\n if (sentTo) {\n return (\n <Center fill>\n <Icon icon={Mail} size=\"large\" color=\"secondary\" />\n <Stack gap=\"medium\">\n <Heading level={1} size=\"h5\">Check your email</Heading>\n <Paragraph tone=\"secondary\" measure=\"none\">We sent a link to {sentTo}. Open it to continue.</Paragraph>\n {picked && <Paragraph tone=\"secondary\" measure=\"none\">{`Your plan is ${picked.name}. The ${trialDays}-day trial starts when you open the link.`}</Paragraph>}\n </Stack>\n <Stack gap=\"large\">\n <Button size=\"medium\" type=\"secondary\" state=\"enabled\" label={resent ? 'Sent' : 'Send Again'} loading={resending} onClickButton={handleSendAgain} />\n <Button size=\"medium\" type=\"textOnly\" state=\"enabled\" label=\"Back to Login\" onClickButton={() => router.push('/login')} />\n </Stack>\n </Center>\n );\n }\n\n return (\n <Center fill>\n <Image src={productMark} alt=\"Acme\" width={40} height={40} />\n <TabsContainer fill>\n {/* Log In keeps the plan too, for a visitor who already has an account. */}\n <Tab label=\"Log In\" isSelected={false} href={picked ? `/login?plan=${plan}` : '/login'} router={router} onClickTab={() => {}} />\n <Tab label=\"Sign Up\" isSelected onClickTab={() => {}} />\n </TabsContainer>\n {picked && (\n // No card here: the person pays after the trial, once the account exists.\n <Stack gap=\"small\">\n <Alert type=\"info\" variant=\"inline\" message={`You picked ${picked.name}, ${formatMoney(picked.price)} per member per month. You pay after a ${trialDays}-day trial.`} autoDismiss={false} />\n <Link href=\"/#pricing\" size=\"body2\">Change Plan</Link>\n </Stack>\n )}\n <Form aria-label=\"Sign up\" onSubmit={handleSubmit}>\n {error && <Alert type=\"error\" variant=\"inline\" message={error} showCloseButton onClose={() => setError('')} />}\n <TextField id=\"signup-from-site-name\" label=\"Name\" autoComplete=\"name\" value={name} disabled={loading} error={Boolean(nameError)} errorText={nameError} onChange={(e) => { setName(e.target.value); setNameError(''); }} />\n <TextField id=\"signup-from-site-email\" label=\"Email\" type=\"email\" autoComplete=\"username\" value={email} disabled={loading} error={Boolean(emailError)} errorText={emailError} onChange={(e) => { setEmail(e.target.value); setEmailError(''); }} />\n <TextField id=\"signup-from-site-password\" label=\"Password\" type=\"password\" autoComplete=\"new-password\" value={password} disabled={loading} error={Boolean(passwordError)} errorText={passwordError} helperText=\"Use at least 8 characters.\" onChange={(e) => { setPassword(e.target.value); setPasswordError(''); }} />\n <Button size=\"medium\" type=\"primary\" state=\"enabled\" label=\"Sign Up\" htmlType=\"submit\" loading={loading} />\n </Form>\n <Line label=\"or\" />\n <Button size=\"medium\" type=\"secondary\" state=\"enabled\" label=\"Continue with Google\" decoIcon={<BrandIcon name=\"google\" />} />\n </Center>\n );\n}\n",
8395
+ "uses": [
8396
+ "Alert",
8397
+ "BrandIcon",
8398
+ "Button",
8399
+ "Center",
8400
+ "Form",
8401
+ "Heading",
8402
+ "Icon",
8403
+ "Image",
8404
+ "Line",
8405
+ "Link",
8406
+ "Paragraph",
8407
+ "Stack",
8408
+ "Tab",
8409
+ "TabsContainer",
8410
+ "TextField",
8411
+ "formatMoney"
8412
+ ]
8413
+ }
8414
+ ]
8415
+ },
7045
8416
  {
7046
8417
  "id": "site-footer",
7047
8418
  "title": "Site footer",
7048
8419
  "kind": "design",
7049
8420
  "level": "organism",
7050
8421
  "area": "shell",
8422
+ "surface": [
8423
+ "site",
8424
+ "app"
8425
+ ],
7051
8426
  "situation": "A person reaches the end of a site's page and looks for the pages that are not in the header, and who runs the site.",
7052
8427
  "do": [
7053
8428
  "Use `SiteFooter` at the end of the page, after `PageShell`. It is a `<footer>` with a `<nav aria-label=\"Footer\">`.",
@@ -7101,6 +8476,10 @@
7101
8476
  "kind": "design",
7102
8477
  "level": "organism",
7103
8478
  "area": "shell",
8479
+ "surface": [
8480
+ "site",
8481
+ "app"
8482
+ ],
7104
8483
  "situation": "A site's pages name the site at the top and show the person where to go and what to do next.",
7105
8484
  "do": [
7106
8485
  "Follow the rule 'On a phone, a sidebar opens as a drawer and a list opens its detail': below `md` the links go into a menu and one main action stays in the bar.",
@@ -7111,7 +8490,8 @@
7111
8490
  "Give a site with sections one `TabsContainer` of `Tab`s with `href`, four sections or fewer and one short word each. Pass it as `nav` to `SiteHeader` with `links` empty: it is a second row of the bar at every width.",
7112
8491
  "Pass search and the theme menu as `phoneAction`, so they stay at the end of the bar on a phone. With no `links` and no `actions` there is no menu.",
7113
8492
  "Keep the section tabs in the bar, so no section is hidden. On a phone, put the pages of the open section in a menu, as the case 'Menu on a phone' shows in 'Sections with their pages'.",
7114
- "Open the theme menu as the case 'Theme switcher' says, and open search as the case 'Site search' says."
8493
+ "Open the theme menu as the case 'Theme switcher' says, and open search as the case 'Site search' says.",
8494
+ "Show a logged-in visitor one Button, 'Open App', in place of 'Log In' and 'Sign Up'."
7115
8495
  ],
7116
8496
  "dont": [
7117
8497
  "Do not show more than five links in the bar.",
@@ -7126,7 +8506,7 @@
7126
8506
  "id": "links",
7127
8507
  "title": "Links and one main action",
7128
8508
  "useWhen": "A product site has a few pages and one main action, such as 'Sign Up'.",
7129
- "source": "'use client';\nimport SiteHeader from 'oneslash-design-system/components/siteHeader';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport Button from 'oneslash-design-system/components/button';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport { Stack } from 'oneslash-design-system/components/layout';\n\nconst links = [\n { label: 'Features', href: '#features' },\n { label: 'Pricing', href: '#pricing', current: true },\n { label: 'Changelog', href: '#changelog' },\n { label: 'Docs', href: '#docs' },\n];\n\nexport default function SiteHeaderLinks() {\n return (\n <>\n {/* From md the links are a row in the bar. Below md they and 'Log In' are in the Menu; Sign Up stays beside it. */}\n <SiteHeader\n brand={{ href: '#top', name: 'Acme' }}\n links={links}\n actions={<Button size=\"medium\" type=\"tertiary\" state=\"enabled\" label=\"Log In\" href=\"#log-in\" />}\n phoneAction={<Button size=\"medium\" type=\"primary\" state=\"enabled\" label=\"Sign Up\" href=\"#sign-up\" />}\n mainId=\"site-header-main\"\n />\n {/* The skip link goes here: the id matches mainId, and tabIndex -1 lets focus move in. */}\n <PageShell id=\"site-header-main\" tabIndex={-1}>\n <Stack gap=\"large\">\n <Heading level={1} size=\"h5\">Pricing</Heading>\n <Paragraph tone=\"secondary\" measure=\"none\">Acme is free for up to three people. Add more people when your team grows.</Paragraph>\n </Stack>\n </PageShell>\n </>\n );\n}\n",
8509
+ "source": "'use client';\nimport SiteHeader from 'oneslash-design-system/components/siteHeader';\nimport PageShell from 'oneslash-design-system/components/pageShell';\nimport Button from 'oneslash-design-system/components/button';\nimport Heading from 'oneslash-design-system/components/heading';\nimport Paragraph from 'oneslash-design-system/components/paragraph';\nimport { Stack } from 'oneslash-design-system/components/layout';\n\nconst links = [\n { label: 'Features', href: '#features' },\n { label: 'Pricing', href: '#pricing', current: true },\n { label: 'Changelog', href: '#changelog' },\n { label: 'Docs', href: '#docs' },\n];\n\n// `loggedIn` is for a visitor who has an account and is logged in: one 'Open App' takes the place of 'Log In' and 'Sign Up'.\nexport default function SiteHeaderLinks({ loggedIn }: { loggedIn?: boolean } = {}) {\n return (\n <>\n {/* From md the links are a row in the bar. Below md they and 'Log In' are in the Menu; Sign Up stays beside it. */}\n <SiteHeader\n brand={{ href: '#top', name: 'Acme' }}\n links={links}\n actions={loggedIn ? undefined : <Button size=\"medium\" type=\"tertiary\" state=\"enabled\" label=\"Log In\" href=\"#log-in\" />}\n phoneAction={\n loggedIn\n ? <Button size=\"medium\" type=\"primary\" state=\"enabled\" label=\"Open App\" href=\"#app\" />\n : <Button size=\"medium\" type=\"primary\" state=\"enabled\" label=\"Sign Up\" href=\"#sign-up\" />\n }\n mainId=\"site-header-main\"\n />\n {/* The skip link goes here: the id matches mainId, and tabIndex -1 lets focus move in. */}\n <PageShell id=\"site-header-main\" tabIndex={-1}>\n <Stack gap=\"large\">\n <Heading level={1} size=\"h5\">Pricing</Heading>\n <Paragraph tone=\"secondary\" measure=\"none\">Acme is free for up to three people. Add more people when your team grows.</Paragraph>\n </Stack>\n </PageShell>\n </>\n );\n}\n",
7130
8510
  "uses": [
7131
8511
  "Button",
7132
8512
  "Heading",
@@ -7158,12 +8538,43 @@
7158
8538
  }
7159
8539
  ]
7160
8540
  },
8541
+ {
8542
+ "id": "site-matches-app",
8543
+ "title": "A site promises only what the app does, in the app's words",
8544
+ "kind": "rule",
8545
+ "level": "rule",
8546
+ "area": "marketing",
8547
+ "surface": [
8548
+ "site",
8549
+ "app"
8550
+ ],
8551
+ "situation": "A product has a public site and an app. The site names the plans, shows the app and sends visitors into it.",
8552
+ "answer": "The site and the app use the same plan names, prices, limits and feature names. A button on the site lands on the page it names and carries the choice: 'Sign Up for Pro' opens the sign-up page with Pro chosen. A visitor who is logged in sees 'Open App' instead of 'Sign Up'. A demo of the app is marked as an example, and anything on the site that looks like the app shows only what the app has.",
8553
+ "why": "A visitor who signs up for what the site promised and finds less in the app stops trusting both. A button that lands on the wrong page, or forgets the plan, makes them choose again.",
8554
+ "do": [
8555
+ "Take plan names, prices and limits from one source, so the site and the app cannot differ.",
8556
+ "Use the feature names the app uses, word for word.",
8557
+ "Send 'Sign Up' to the sign-up page.",
8558
+ "Carry a chosen plan into sign-up: 'Sign Up for Pro' opens sign-up with Pro chosen.",
8559
+ "Show a logged-in visitor 'Open App' in place of 'Sign Up'.",
8560
+ "Mark a demo of the app as an example, and show only what the app has."
8561
+ ],
8562
+ "dont": [
8563
+ "Do not list a feature a plan does not include.",
8564
+ "Do not show a control in a demo that the app does not have.",
8565
+ "Do not send a 'Sign Up' button to the login page."
8566
+ ],
8567
+ "native": "On Apple and Android the store page is the site. Its screenshots show only what the app has, with the same plan names and prices as the app."
8568
+ },
7161
8569
  {
7162
8570
  "id": "site-search",
7163
8571
  "title": "Site search",
7164
8572
  "kind": "design",
7165
8573
  "level": "organism",
7166
8574
  "area": "content",
8575
+ "surface": [
8576
+ "site"
8577
+ ],
7167
8578
  "situation": "A site has many pages, and a person wants to reach one by its name or by a word in it, from any page.",
7168
8579
  "do": [
7169
8580
  "Put a 'Search' `Button` with `decoIcon=\"Search\"` in the `SiteHeader`, in `phoneAction`, so it stays in the bar at every width. Give it `aria-haspopup=\"dialog\"` and `aria-keyshortcuts=\"Meta+K Control+K\"`.",
@@ -7211,6 +8622,10 @@
7211
8622
  "kind": "design",
7212
8623
  "level": "organism",
7213
8624
  "area": "chat",
8625
+ "surface": [
8626
+ "app",
8627
+ "agent"
8628
+ ],
7214
8629
  "situation": "A person types / at the start of the message box to run a command.",
7215
8630
  "do": [
7216
8631
  "Open the list when the text starts with /. A bare / opens it, each letter after it narrows it, and a space closes it.",
@@ -7261,6 +8676,9 @@
7261
8676
  "kind": "design",
7262
8677
  "level": "organism",
7263
8678
  "area": "dashboard",
8679
+ "surface": [
8680
+ "app"
8681
+ ],
7264
8682
  "situation": "A page opens with the few numbers that say how things are going, counted over one range.",
7265
8683
  "do": [
7266
8684
  "Follow the rule 'A number shows its unit and never shows 0 for unknown'. Use `StatTile`, which does.",
@@ -7320,6 +8738,9 @@
7320
8738
  "kind": "design",
7321
8739
  "level": "organism",
7322
8740
  "area": "dashboard",
8741
+ "surface": [
8742
+ "app"
8743
+ ],
7323
8744
  "situation": "A row in a table or a list says what state its thing is in, such as an invoice, a plan or a connection. ODS has no separate Badge part, because `Tag` does a Badge's job.",
7324
8745
  "do": [
7325
8746
  "Use `Tag` for a state in a row, with `size=\"small\"`. ODS has no Badge part: a second part for the same job would mark the same states two ways.",
@@ -7327,7 +8748,7 @@
7327
8748
  "Use `variant=\"dot\"` for a state that changes and may need the person: 'Past due', 'Canceling', 'Connected'.",
7328
8749
  "Give the dot a color only when the state needs action: `color=\"error\"` for 'Past due', `color=\"warning\"` for 'Canceling'. One exception: `color=\"info\"` for a charge that has not happened yet, 'Upcoming', so it does not read as paid. A usual state, such as 'Connected', keeps the grey dot.",
7329
8750
  "Use `variant=\"textOnly\"` with no color for a settled record: 'Paid', 'Refunded'.",
7330
- "Write one word or two, in sentence case: 'Past due', 'Needs reconnecting'.",
8751
+ "Write one word or two, in sentence case: 'Past due', 'Needs reconnect'.",
7331
8752
  "Put the Tag in a 'Status' column, or at the end of the row's text. It is not clickable."
7332
8753
  ],
7333
8754
  "dont": [
@@ -7383,6 +8804,10 @@
7383
8804
  "kind": "rule",
7384
8805
  "level": "rule",
7385
8806
  "area": "state",
8807
+ "surface": [
8808
+ "site",
8809
+ "app"
8810
+ ],
7386
8811
  "situation": "Something the person did has worked.",
7387
8812
  "answer": "The feedback depends on where the result shows. A Button that is `loading` keeps its label, and the spinner shows that it is working. Only success changes a label, and there are three success labels: 'Saved', 'Copied' and 'Sent', each for 2 seconds. When a form saves in place, its Button is `loading`, then reads 'Saved' for 2 seconds, then its own label again. There is no toast. Sometimes the result is somewhere else or gone. Something was deleted, sent, moved or duplicated somewhere else, or a long job has finished. Then call `toast({ type: 'success', message: '…' })` with one short sentence in the past tense, in sentence case. It closes after 5 seconds. When something is copied to the clipboard, a Button reads 'Copied' for 2 seconds, and an IconButton swaps its icon to `Check` for 2 seconds. When Copy is a menu item, the menu closes, so a toast says 'Message copied.' instead. When a Button sends an email again, it reads 'Sent' for 2 seconds. The message names the thing and does not say 'successfully'.",
7388
8813
  "why": "Feedback belongs where the person is looking. A change they can see needs only a word on the Button, and a result they cannot see needs a short message that names it.",
@@ -7408,6 +8833,9 @@
7408
8833
  "kind": "design",
7409
8834
  "level": "organism",
7410
8835
  "area": "marketing",
8836
+ "surface": [
8837
+ "site"
8838
+ ],
7411
8839
  "situation": "A page shows several views of one thing, and a visitor reads one of them at a time.",
7412
8840
  "do": [
7413
8841
  "Put the section's name in `SectionIntro`, so the section has a level 2 heading. Give the panel's title a level 3 `Heading`.",
@@ -7454,6 +8882,9 @@
7454
8882
  "kind": "design",
7455
8883
  "level": "organism",
7456
8884
  "area": "menu",
8885
+ "surface": [
8886
+ "app"
8887
+ ],
7457
8888
  "situation": "A person filters a list by a tag, and adds, renames and deletes the tags themselves.",
7458
8889
  "do": [
7459
8890
  "Use a row of `Tag` with `variant=\"contained\"` and `size=\"medium\"` in a `Cluster`. Put 'All' first, then each tag. The row wraps.",
@@ -7514,6 +8945,9 @@
7514
8945
  "kind": "design",
7515
8946
  "level": "organism",
7516
8947
  "area": "shell",
8948
+ "surface": [
8949
+ "app"
8950
+ ],
7517
8951
  "situation": "A task page shows its name, its state, who is on it and when it is due, with the panes and actions for it.",
7518
8952
  "do": [
7519
8953
  "Follow the case 'Page header with actions': `TitleBar` with the task's name as the one level 1 heading.",
@@ -7606,6 +9040,10 @@
7606
9040
  "kind": "design",
7607
9041
  "level": "organism",
7608
9042
  "area": "shell",
9043
+ "surface": [
9044
+ "site",
9045
+ "app"
9046
+ ],
7609
9047
  "situation": "A person chooses between a light page, a dark page, or the one their device uses.",
7610
9048
  "do": [
7611
9049
  "Offer three choices, in this order: 'Light', 'Dark' and 'System'. 'System' follows the device and is the default.",
@@ -7669,6 +9107,9 @@
7669
9107
  "kind": "design",
7670
9108
  "level": "organism",
7671
9109
  "area": "confirm",
9110
+ "surface": [
9111
+ "app"
9112
+ ],
7672
9113
  "situation": "A person asks to delete something large that cannot be brought back, such as a workspace or an account.",
7673
9114
  "do": [
7674
9115
  "Ask for typing only when the loss is permanent and large, such as a workspace with everything in it, or an account.",
@@ -7731,6 +9172,9 @@
7731
9172
  "kind": "design",
7732
9173
  "level": "organism",
7733
9174
  "area": "chat",
9175
+ "surface": [
9176
+ "app"
9177
+ ],
7734
9178
  "situation": "Other people in the thread are writing a message that has not arrived yet.",
7735
9179
  "do": [
7736
9180
  "Show one line just above the Composer, in small secondary text: `<Paragraph size=\"caption\" tone=\"secondary\">`.",
@@ -7772,6 +9216,9 @@
7772
9216
  "kind": "design",
7773
9217
  "level": "organism",
7774
9218
  "area": "confirm",
9219
+ "surface": [
9220
+ "app"
9221
+ ],
7775
9222
  "situation": "A person closes or leaves something they changed and did not save.",
7776
9223
  "do": [
7777
9224
  "Ask only when there are changes. With nothing changed, close at once.",
@@ -7830,6 +9277,9 @@
7830
9277
  "kind": "design",
7831
9278
  "level": "organism",
7832
9279
  "area": "confirm",
9280
+ "surface": [
9281
+ "app"
9282
+ ],
7833
9283
  "situation": "A person reaches something their plan does not include, or a limit of their plan.",
7834
9284
  "do": [
7835
9285
  "Say what is locked and which plan unlocks it: 'Exporting to PDF is part of the Pro plan.'",
@@ -7892,6 +9342,9 @@
7892
9342
  "kind": "design",
7893
9343
  "level": "organism",
7894
9344
  "area": "dashboard",
9345
+ "surface": [
9346
+ "app"
9347
+ ],
7895
9348
  "situation": "A plan limits some things, such as AI agent responses, members and storage. The admin checks how close the workspace is.",
7896
9349
  "do": [
7897
9350
  "Follow the rule 'A number shows its unit and never shows 0 for unknown'.",