oneslash-design-system 2.28.1 → 2.29.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 (234) 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 +49 -0
  28. package/dist/cases/agent-permissions/per-tool.d.ts +3 -0
  29. package/dist/cases/agent-permissions/per-tool.jsx +178 -0
  30. package/dist/cases/agent-permissions.md +314 -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 +209 -0
  57. package/dist/cases/bulk-actions/paged-table.d.ts +1 -0
  58. package/dist/cases/bulk-actions/paged-table.jsx +246 -0
  59. package/dist/cases/bulk-actions.md +559 -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 +3 -0
  160. package/dist/cases/product-demo/scripted.jsx +95 -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 +221 -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 +1489 -39
  209. package/dist/components/checkBox.d.ts +5 -1
  210. package/dist/components/checkBox.jsx +23 -9
  211. package/dist/components/diff.d.ts +29 -0
  212. package/dist/components/diff.jsx +35 -0
  213. package/dist/index.d.ts +1 -0
  214. package/dist/index.js +1 -0
  215. package/dist/internal/diff.d.ts +17 -0
  216. package/dist/internal/diff.js +44 -0
  217. package/dist/native-mapping.json +9 -2
  218. package/dist/stories/AgentPermissions.probe.stories.d.ts +7 -0
  219. package/dist/stories/AgentPermissions.probe.stories.jsx +18 -0
  220. package/dist/stories/AgentRunFailure.probe.stories.d.ts +6 -0
  221. package/dist/stories/AgentRunFailure.probe.stories.jsx +12 -0
  222. package/dist/stories/Cases.generated.stories.d.ts +24 -0
  223. package/dist/stories/Cases.generated.stories.jsx +48 -0
  224. package/dist/stories/Checkbox.stories.d.ts +2 -0
  225. package/dist/stories/Checkbox.stories.jsx +18 -0
  226. package/dist/stories/Diff.stories.d.ts +9 -0
  227. package/dist/stories/Diff.stories.jsx +40 -0
  228. package/dist/stories/ProductDemo.probe.stories.d.ts +6 -0
  229. package/dist/stories/ProductDemo.probe.stories.jsx +12 -0
  230. package/dist/stories/SignupFromSite.probe.stories.d.ts +7 -0
  231. package/dist/stories/SignupFromSite.probe.stories.jsx +17 -0
  232. package/dist/stories/SiteHeader.probe.stories.d.ts +6 -0
  233. package/dist/stories/SiteHeader.probe.stories.jsx +13 -0
  234. package/package.json +1 -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,109 @@
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 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 {!canChange && <Paragraph tone=\"secondary\" size=\"body2\" measure=\"none\">Only admins can change these settings. Your admin is Dana Lee.</Paragraph>}\n </Stack>\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
+ "Center",
762
+ "FormField",
763
+ "Heading",
764
+ "Paragraph",
765
+ "RadioGroup",
766
+ "SettingsSection",
767
+ "Stack"
768
+ ]
769
+ },
770
+ {
771
+ "id": "per-tool",
772
+ "title": "Each tool",
773
+ "useWhen": "An admin sets each tool or action on its own.",
774
+ "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 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 // SegmentedControl cannot be disabled, so a press on a row that is still saving does nothing.\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 {!canChange && <Paragraph tone=\"secondary\" size=\"body2\" measure=\"none\">Only admins can change these settings. Your admin is Dana Lee.</Paragraph>}\n </Stack>\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 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",
775
+ "uses": [
776
+ "Button",
777
+ "Center",
778
+ "Cluster",
779
+ "EmptyBox",
780
+ "Heading",
781
+ "Paragraph",
782
+ "SegmentedControl",
783
+ "SettingsSection",
784
+ "Stack",
785
+ "TableCell",
786
+ "TableContainer",
787
+ "TableHeader",
788
+ "TableHeaderCell",
789
+ "TableRow",
790
+ "Toaster",
791
+ "dismissToast",
792
+ "toast"
793
+ ]
794
+ }
795
+ ]
796
+ },
482
797
  {
483
798
  "id": "agent-plan-proposal",
484
799
  "title": "Plan proposal",
485
800
  "kind": "design",
486
801
  "level": "organism",
487
802
  "area": "agent",
803
+ "surface": [
804
+ "agent"
805
+ ],
488
806
  "situation": "The agent is about to change shared work and needs the person to approve it first.",
489
807
  "do": [
490
- "Follow the rule 'An agent asks before a risky action': the agent does nothing until the person presses 'Approve'.",
808
+ "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
809
  "Put the card in the agent's `Message`, in a `Surface` with a heading, the plan, then the buttons.",
492
810
  "List every step in a `<StepList numbered>`, in the order the agent will do them, each one waiting.",
811
+ "Say what the run will touch before it starts: the files, tools or people.",
493
812
  "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.",
813
+ "List each changed file in that Modal with one line on what changes in it.",
814
+ "Follow the case 'Review of an agent's changes' when the person needs to read the changed lines.",
495
815
  "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.",
816
+ "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.",
817
+ "Let the product write the labels 'Approve' and 'Apply Changes'. The agent never writes the label of an approve or merge button.",
498
818
  "Show the waiting time on the card while it waits, and while the person edits: 'Waits 10 more minutes, then cancels.'",
499
819
  "Notify the person who asked when the agent needs their answer.",
500
820
  "Make the pressed Button `loading` and keep its label. Disable the others while the request runs.",
501
821
  "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.",
822
+ "Mark a steps card with an 'Approved' or 'Cancelled' `Tag` once it is decided, and remove its buttons.",
823
+ "Mark a changes card with an 'Applied', 'Rejected' or 'Cancelled' `Tag`, as the case 'Review of an agent's changes' does.",
503
824
  "Announce the decided `Tag` politely: the app wraps it in a polite live region.",
504
825
  "Keep an approved card as the record: the steps as they were approved, none running, and no buttons.",
505
826
  "Move the run to its own progress row under the card, as the case 'Agent at work' shows, with its 'Stop'.",
@@ -530,7 +851,7 @@
530
851
  "id": "steps",
531
852
  "title": "Steps",
532
853
  "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",
854
+ "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
855
  "uses": [
535
856
  "Button",
536
857
  "Center",
@@ -550,8 +871,8 @@
550
871
  {
551
872
  "id": "changes",
552
873
  "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",
874
+ "useWhen": "The agent has changes ready to apply, and one line for each file is enough.",
875
+ "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
876
  "uses": [
556
877
  "Button",
557
878
  "Center",
@@ -578,6 +899,9 @@
578
899
  "kind": "design",
579
900
  "level": "organism",
580
901
  "area": "agent",
902
+ "surface": [
903
+ "agent"
904
+ ],
581
905
  "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
906
  "do": [
583
907
  "Put the card in the agent's `Message`, in a `Surface` with the question as its heading.",
@@ -656,6 +980,9 @@
656
980
  "kind": "rule",
657
981
  "level": "rule",
658
982
  "area": "agent",
983
+ "surface": [
984
+ "agent"
985
+ ],
659
986
  "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
987
  "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
988
  "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 +998,92 @@
671
998
  ],
672
999
  "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
1000
  },
1001
+ {
1002
+ "id": "agent-run-failure",
1003
+ "title": "Run that stopped short",
1004
+ "kind": "design",
1005
+ "level": "organism",
1006
+ "area": "agent",
1007
+ "surface": [
1008
+ "agent"
1009
+ ],
1010
+ "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.",
1011
+ "do": [
1012
+ "Follow the rule 'An agent that stops short says what it finished and what is left'.",
1013
+ "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.",
1014
+ "Keep the run's progress row from the case 'Agent at work', with its `StepList` still on screen when the run stops.",
1015
+ "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.",
1016
+ "Say why in the `detail` of the step that stopped: 'Could not save planTable.tsx. Another change was saving it at the same time.'",
1017
+ "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.",
1018
+ "Give that line `role=\"status\"`, so a screen reader hears it once when the run stops.",
1019
+ "Move focus to the row's first Button when the run stops, since 'Stop' had focus and is gone.",
1020
+ "Offer 'Stop Here' and then 'Try Step Again' as the primary Button when one step failed and can run again.",
1021
+ "Run only the failed step and the ones after it on 'Try Step Again'. The steps that are done stay done.",
1022
+ "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.'",
1023
+ "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.",
1024
+ "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.'",
1025
+ "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.",
1026
+ "Mark the steps that will not run cancelled after 'Stop Here', and say what was left undone.",
1027
+ "Move focus to 'Stop' when the run goes on, and to the message box when the row's Buttons go away."
1028
+ ],
1029
+ "dont": [
1030
+ "Do not start again from step one when a person asks to retry.",
1031
+ "Do not end with only 'Something went wrong', or report the stop only in a toast away from the row.",
1032
+ "Do not open an upgrade Modal in the thread when a run reaches a limit.",
1033
+ "Do not hide the steps that are done.",
1034
+ "Do not show 'Continue' to someone who cannot lift the limit."
1035
+ ],
1036
+ "options": [
1037
+ {
1038
+ "id": "step-failed",
1039
+ "title": "A step failed",
1040
+ "useWhen": "One step failed and can be tried again.",
1041
+ "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",
1042
+ "uses": [
1043
+ "Button",
1044
+ "Center",
1045
+ "Cluster",
1046
+ "Heading",
1047
+ "Message",
1048
+ "Paragraph",
1049
+ "Stack",
1050
+ "StepList",
1051
+ "Tag",
1052
+ "TimeStamp",
1053
+ "UserImage"
1054
+ ]
1055
+ },
1056
+ {
1057
+ "id": "limit-reached",
1058
+ "title": "A limit was reached",
1059
+ "useWhen": "The run stopped at a limit of steps, time or budget with work left.",
1060
+ "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",
1061
+ "uses": [
1062
+ "Alert",
1063
+ "Button",
1064
+ "Center",
1065
+ "Cluster",
1066
+ "Heading",
1067
+ "Message",
1068
+ "Paragraph",
1069
+ "Stack",
1070
+ "StepList",
1071
+ "Tag",
1072
+ "TimeStamp",
1073
+ "UserImage"
1074
+ ]
1075
+ }
1076
+ ]
1077
+ },
674
1078
  {
675
1079
  "id": "agent-says-what-it-is",
676
1080
  "title": "An agent says what it is",
677
1081
  "kind": "rule",
678
1082
  "level": "rule",
679
1083
  "area": "agent",
1084
+ "surface": [
1085
+ "agent"
1086
+ ],
680
1087
  "situation": "The agent posts in a thread where people also write, or replies to a person.",
681
1088
  "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
1089
  "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 +1099,41 @@
692
1099
  ],
693
1100
  "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
1101
  },
1102
+ {
1103
+ "id": "agent-says-where-it-stopped",
1104
+ "title": "An agent that stops short says what it finished and what is left",
1105
+ "kind": "rule",
1106
+ "level": "rule",
1107
+ "area": "agent",
1108
+ "surface": [
1109
+ "agent"
1110
+ ],
1111
+ "situation": "An agent is partway through a run of several steps when the run fails, is stopped, or hits a limit.",
1112
+ "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.",
1113
+ "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.",
1114
+ "do": [
1115
+ "Keep the step list on screen, with each step marked done, failed or cancelled, or not started.",
1116
+ "Say the reason in plain words: 'Stopped at step 3. The workspace reached its budget cap.'",
1117
+ "Say whether anything was changed, and what.",
1118
+ "Offer the next move: try the stopped step again, continue, or leave it.",
1119
+ "Retry from the step that stopped, and keep the steps that are done."
1120
+ ],
1121
+ "dont": [
1122
+ "Do not end with only 'Something went wrong'.",
1123
+ "Do not start again from step one when a person asks to retry.",
1124
+ "Do not hide finished steps."
1125
+ ]
1126
+ },
695
1127
  {
696
1128
  "id": "agent-settings",
697
1129
  "title": "Agent settings",
698
1130
  "kind": "design",
699
1131
  "level": "organism",
700
1132
  "area": "settings",
1133
+ "surface": [
1134
+ "app",
1135
+ "agent"
1136
+ ],
701
1137
  "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
1138
  "do": [
703
1139
  "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 +1184,9 @@
748
1184
  "kind": "rule",
749
1185
  "level": "rule",
750
1186
  "area": "agent",
1187
+ "surface": [
1188
+ "agent"
1189
+ ],
751
1190
  "situation": "The agent is working on a request and its reply is not ready yet.",
752
1191
  "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
1192
  "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 +1209,9 @@
770
1209
  "kind": "rule",
771
1210
  "level": "rule",
772
1211
  "area": "agent",
1212
+ "surface": [
1213
+ "agent"
1214
+ ],
773
1215
  "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
1216
  "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
1217
  "why": "A person can check an answer only when they can open what it came from.",
@@ -791,6 +1233,9 @@
791
1233
  "kind": "design",
792
1234
  "level": "organism",
793
1235
  "area": "settings",
1236
+ "surface": [
1237
+ "app"
1238
+ ],
794
1239
  "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
1240
  "do": [
796
1241
  "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 +1295,9 @@
850
1295
  "kind": "design",
851
1296
  "level": "page",
852
1297
  "area": "shell",
1298
+ "surface": [
1299
+ "app"
1300
+ ],
853
1301
  "situation": "A person opens the product and moves between its places, such as Inbox, Tasks and Settings, from every page.",
854
1302
  "do": [
855
1303
  "Follow the rule 'On a phone, a sidebar opens as a drawer and a list opens its detail'.",
@@ -931,6 +1379,9 @@
931
1379
  "kind": "design",
932
1380
  "level": "organism",
933
1381
  "area": "agent",
1382
+ "surface": [
1383
+ "agent"
1384
+ ],
934
1385
  "situation": "The agent made a document for the person, such as a plan or a report.",
935
1386
  "do": [
936
1387
  "Keep the reply to one sentence on what the agent made. Then put the card in the reply's `footer`.",
@@ -978,6 +1429,10 @@
978
1429
  "kind": "design",
979
1430
  "level": "organism",
980
1431
  "area": "agent",
1432
+ "surface": [
1433
+ "app",
1434
+ "agent"
1435
+ ],
981
1436
  "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
1437
  "do": [
983
1438
  "Follow the cases 'Conversation starters', 'Scope picker', 'Reply sources' and 'Message composer'.",
@@ -1066,6 +1521,9 @@
1066
1521
  "kind": "design",
1067
1522
  "level": "page",
1068
1523
  "area": "auth",
1524
+ "surface": [
1525
+ "app"
1526
+ ],
1069
1527
  "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
1528
  "do": [
1071
1529
  "Show the spinner from the first render, before anything else, as `LoadingScreen` in `Center` with `fill`.",
@@ -1110,6 +1568,9 @@
1110
1568
  "kind": "design",
1111
1569
  "level": "page",
1112
1570
  "area": "dashboard",
1571
+ "surface": [
1572
+ "app"
1573
+ ],
1113
1574
  "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
1575
  "do": [
1115
1576
  "Follow the rule 'A number shows its unit and never shows 0 for unknown'.",
@@ -1215,6 +1676,9 @@
1215
1676
  "kind": "design",
1216
1677
  "level": "page",
1217
1678
  "area": "content",
1679
+ "surface": [
1680
+ "site"
1681
+ ],
1218
1682
  "situation": "A visitor opens the blog to see what was written lately and to pick a post to read.",
1219
1683
  "do": [
1220
1684
  "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 +1736,10 @@
1272
1736
  "kind": "design",
1273
1737
  "level": "organism",
1274
1738
  "area": "content",
1739
+ "surface": [
1740
+ "site",
1741
+ "app"
1742
+ ],
1275
1743
  "situation": "A page on a site sits under other pages, and the person needs to see where it is and go back up.",
1276
1744
  "do": [
1277
1745
  "Put `Breadcrumb` above the `PageHeader`, from the top level down to this page.",
@@ -1327,6 +1795,9 @@
1327
1795
  "kind": "design",
1328
1796
  "level": "organism",
1329
1797
  "area": "dashboard",
1798
+ "surface": [
1799
+ "app"
1800
+ ],
1330
1801
  "situation": "A page shows how a total splits into parts, such as responses by model or comments by project.",
1331
1802
  "do": [
1332
1803
  "Follow the rule 'A number shows its unit and never shows 0 for unknown'.",
@@ -1384,12 +1855,118 @@
1384
1855
  }
1385
1856
  ]
1386
1857
  },
1858
+ {
1859
+ "id": "bulk-actions",
1860
+ "title": "Bulk actions",
1861
+ "kind": "design",
1862
+ "level": "organism",
1863
+ "area": "dashboard",
1864
+ "surface": [
1865
+ "app"
1866
+ ],
1867
+ "situation": "A person picks several rows of a list or a table and does one thing to all of them at once.",
1868
+ "do": [
1869
+ "Give each row a `Checkbox` named for its row: 'Select Write the launch email'.",
1870
+ "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.",
1871
+ "Pick every row with the header Checkbox when some are picked, and none when all are.",
1872
+ "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'.",
1873
+ "Give the count `role=\"status\"` and keep it on the page, so a screen reader hears each new count once.",
1874
+ "Name the More menu for the rows it acts on: 'More actions for 3 tasks'. Follow the case 'More menu'.",
1875
+ "Follow the case 'Data table page' for a table over many pages. The header Checkbox picks the rows of the page shown.",
1876
+ "Offer 'Select All 240' as a text Button in the bar of a paged table, until every row is picked. Focus then goes to 'Clear Selection'.",
1877
+ "Keep the picked rows when the person changes page, sorts or comes back.",
1878
+ "Confirm a delete in a small Modal, as the case 'Delete confirm' does, titled with the count: 'Delete 3 Invoices'.",
1879
+ "Move focus to the header Checkbox after 'Clear Selection' and after a delete, because the bar and its Buttons are gone.",
1880
+ "Stay on the same page after a delete if it still has rows, or go to the last page that does.",
1881
+ "Show the case 'Empty list' in the table's place when a delete leaves no rows. Focus goes to its Button.",
1882
+ "Say what happened in a toast that counts: '3 invoices deleted.'"
1883
+ ],
1884
+ "dont": [
1885
+ "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.",
1886
+ "Do not make dragging the only way to act on picked rows. Give each action a Button or a menu item.",
1887
+ "Do not drop the picked rows when the page changes.",
1888
+ "Do not say 'Select All' with no count on a paged table. Say how many it picks.",
1889
+ "Do not show the bar and the toolbar at once."
1890
+ ],
1891
+ "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.",
1892
+ "options": [
1893
+ {
1894
+ "id": "list",
1895
+ "title": "Ticks on one page",
1896
+ "useWhen": "A list whose rows all fit on one page, such as the tasks of a project.",
1897
+ "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 // Holds the header Checkbox. Checkbox takes no ref, so focus goes to the box inside this line.\n const headerBox = useRef<HTMLParagraphElement>(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?.querySelector('input') ?? 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 <Paragraph ref={headerBox} measure=\"none\">\n <Checkbox aria-label=\"Select all tasks\" checked={all} indeterminate={count > 0 && !all} onChange={toggleAll} />\n </Paragraph>\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",
1898
+ "uses": [
1899
+ "Button",
1900
+ "Center",
1901
+ "Checkbox",
1902
+ "Cluster",
1903
+ "EmptyBox",
1904
+ "Heading",
1905
+ "IconButton",
1906
+ "Menu",
1907
+ "MenuItem",
1908
+ "Modal",
1909
+ "Paragraph",
1910
+ "Popover",
1911
+ "Stack",
1912
+ "TableCell",
1913
+ "TableContainer",
1914
+ "TableHeader",
1915
+ "TableHeaderCell",
1916
+ "TableRow",
1917
+ "Tag",
1918
+ "Toaster",
1919
+ "Tooltip",
1920
+ "dismissToast",
1921
+ "toast"
1922
+ ]
1923
+ },
1924
+ {
1925
+ "id": "paged-table",
1926
+ "title": "Ticks across pages",
1927
+ "useWhen": "A table over many pages, where the person may want every row, not only the ones they see.",
1928
+ "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 // Holds the header Checkbox. Checkbox takes no ref, so focus goes to the box inside this line.\n const headerBox = useRef<HTMLParagraphElement>(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?.querySelector('input') ?? 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=\"textOnly\" 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 <Paragraph ref={headerBox} measure=\"none\">\n <Checkbox aria-label=\"Select all invoices on this page\" checked={wholePage} indeterminate={onPage > 0 && !wholePage} onChange={togglePage} />\n </Paragraph>\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",
1929
+ "uses": [
1930
+ "Button",
1931
+ "Center",
1932
+ "Checkbox",
1933
+ "Cluster",
1934
+ "EmptyBox",
1935
+ "IconButton",
1936
+ "Menu",
1937
+ "MenuItem",
1938
+ "Modal",
1939
+ "Pagination",
1940
+ "Paragraph",
1941
+ "Popover",
1942
+ "Stack",
1943
+ "Surface",
1944
+ "TableCell",
1945
+ "TableContainer",
1946
+ "TableHeader",
1947
+ "TableHeaderCell",
1948
+ "TableRow",
1949
+ "Tag",
1950
+ "TitleBar",
1951
+ "Toaster",
1952
+ "Tooltip",
1953
+ "dismissToast",
1954
+ "formatCount",
1955
+ "formatMoney",
1956
+ "toast"
1957
+ ]
1958
+ }
1959
+ ]
1960
+ },
1387
1961
  {
1388
1962
  "id": "changelog",
1389
1963
  "title": "Changelog",
1390
1964
  "kind": "design",
1391
1965
  "level": "page",
1392
1966
  "area": "content",
1967
+ "surface": [
1968
+ "site"
1969
+ ],
1393
1970
  "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
1971
  "do": [
1395
1972
  "Use `PageHeader` with `level={1}`: the title 'Changelog' is the one level 1 heading, with a `lede` that says the order.",
@@ -1453,6 +2030,9 @@
1453
2030
  "kind": "design",
1454
2031
  "level": "organism",
1455
2032
  "area": "dashboard",
2033
+ "surface": [
2034
+ "app"
2035
+ ],
1456
2036
  "situation": "A dashboard shows how a count moved over its range, day by day or week by week.",
1457
2037
  "do": [
1458
2038
  "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 +2096,9 @@
1516
2096
  "kind": "design",
1517
2097
  "level": "page",
1518
2098
  "area": "auth",
2099
+ "surface": [
2100
+ "app"
2101
+ ],
1519
2102
  "situation": "A person signed up, and the product sent a link to confirm their email.",
1520
2103
  "do": [
1521
2104
  "Name the page 'Check your email' in a `Heading` with `level={1}`, with a `Mail` icon above it.",
@@ -1572,6 +2155,9 @@
1572
2155
  "kind": "design",
1573
2156
  "level": "organism",
1574
2157
  "area": "content",
2158
+ "surface": [
2159
+ "site"
2160
+ ],
1575
2161
  "situation": "A page shows code that a person reads, or copies to run.",
1576
2162
  "do": [
1577
2163
  "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 +2212,9 @@
1626
2212
  "kind": "design",
1627
2213
  "level": "organism",
1628
2214
  "area": "menu",
2215
+ "surface": [
2216
+ "app"
2217
+ ],
1629
2218
  "situation": "A person filters a list by a word, and the list should keep its room when they are not typing.",
1630
2219
  "do": [
1631
2220
  "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 +2265,9 @@
1676
2265
  "kind": "design",
1677
2266
  "level": "organism",
1678
2267
  "area": "chat",
2268
+ "surface": [
2269
+ "app"
2270
+ ],
1679
2271
  "situation": "A person reads comments left on a piece of work, opens one, and reads and answers its thread.",
1680
2272
  "do": [
1681
2273
  "Follow the cases 'Message row' and 'Message composer'.",
@@ -1746,12 +2338,77 @@
1746
2338
  }
1747
2339
  ]
1748
2340
  },
2341
+ {
2342
+ "id": "comparison-page",
2343
+ "title": "Comparison with another product",
2344
+ "kind": "design",
2345
+ "level": "page",
2346
+ "area": "marketing",
2347
+ "surface": [
2348
+ "site"
2349
+ ],
2350
+ "situation": "A visitor to the public site is choosing between this product and one other, and wants a fair side-by-side view.",
2351
+ "do": [
2352
+ "Follow the rule 'A site promises only what the app does, in the app's words': name each feature as the app names it.",
2353
+ "Open the page with `PageHeader` at level 1. Name both products in the title.",
2354
+ "Put a short 'When to pick which' section next, in a `Grid` of two `Surface`s, one for each product.",
2355
+ "Be fair to the other product. Say what it does well, and when a visitor should pick it.",
2356
+ "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.",
2357
+ "Put each feature in `TableCell rowHeader`, so a screen reader says it with each cell.",
2358
+ "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'.",
2359
+ "Give every claim about the other product a source. Name it in the cell by number, such as 'Yes, on Team (Source 5)'.",
2360
+ "List the sources under the table, numbered, as `Link`s with `announceNewTab`. Keep them out of the table, so its region scrolls alone.",
2361
+ "Say when the sources were checked, above the list: 'Checked on Nov 16, 2026, on Northwind's public pages.'",
2362
+ "Ask for one main action, as the rule 'A marketing page asks for one main action, in the same words everywhere' says: 'Sign Up'."
2363
+ ],
2364
+ "dont": [
2365
+ "Do not add a row about the other product with no source.",
2366
+ "Do not show a check mark or a cross with no words.",
2367
+ "Do not leave out the rows where the other product does better.",
2368
+ "Do not compare against a plan or a price of your own that the app does not have.",
2369
+ "Do not compare more than two products on one page. Make one page for each."
2370
+ ],
2371
+ "native": "On Apple and Android an app has no comparison page. It lives on the site.",
2372
+ "options": [
2373
+ {
2374
+ "id": "table",
2375
+ "title": "Table with sources",
2376
+ "useWhen": "A visitor is choosing between this product and one other.",
2377
+ "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",
2378
+ "uses": [
2379
+ "Button",
2380
+ "Cluster",
2381
+ "Grid",
2382
+ "Heading",
2383
+ "Link",
2384
+ "List",
2385
+ "PageHeader",
2386
+ "PageSection",
2387
+ "PageShell",
2388
+ "Paragraph",
2389
+ "SectionIntro",
2390
+ "Stack",
2391
+ "Surface",
2392
+ "TableCell",
2393
+ "TableContainer",
2394
+ "TableHeader",
2395
+ "TableHeaderCell",
2396
+ "TableRow",
2397
+ "formatMoney"
2398
+ ]
2399
+ }
2400
+ ]
2401
+ },
1749
2402
  {
1750
2403
  "id": "composer-limit",
1751
2404
  "title": "Composer at a limit",
1752
2405
  "kind": "design",
1753
2406
  "level": "organism",
1754
2407
  "area": "chat",
2408
+ "surface": [
2409
+ "app",
2410
+ "agent"
2411
+ ],
1755
2412
  "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
2413
  "do": [
1757
2414
  "Follow the rule 'An agent refuses clearly' word for word: \"You've used all 50 AI agent responses this month.\"",
@@ -1824,6 +2481,9 @@
1824
2481
  "kind": "design",
1825
2482
  "level": "organism",
1826
2483
  "area": "confirm",
2484
+ "surface": [
2485
+ "app"
2486
+ ],
1827
2487
  "situation": "A person asks to delete or remove something, and it cannot be undone.",
1828
2488
  "do": [
1829
2489
  "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 +2550,10 @@
1890
2550
  "kind": "rule",
1891
2551
  "level": "rule",
1892
2552
  "area": "confirm",
2553
+ "surface": [
2554
+ "site",
2555
+ "app"
2556
+ ],
1893
2557
  "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
2558
  "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
2559
  "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 +2574,95 @@
1910
2574
  ],
1911
2575
  "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
2576
  },
2577
+ {
2578
+ "id": "connection-status",
2579
+ "title": "Status of a connected source",
2580
+ "kind": "design",
2581
+ "level": "organism",
2582
+ "area": "settings",
2583
+ "surface": [
2584
+ "app"
2585
+ ],
2586
+ "situation": "A person connected other tools to the product, and wants to know if each one still works, is busy, or needs them.",
2587
+ "do": [
2588
+ "Build on the case 'Integrations': the same rows, logos and names, with the status under the name.",
2589
+ "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'.",
2590
+ "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'.",
2591
+ "Put a `TimeStamp` beside the status that says when the source last synced: 'Synced 2 minutes ago'.",
2592
+ "Say in the line what is wrong and what fixes it: 'Access ran out on Nov 14, 2026. Reconnect to keep files in sync.'",
2593
+ "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.",
2594
+ "Give a source that is not responding a secondary 'Try Again', named for it: 'Try again to reach Notion'.",
2595
+ "Show a first import as 'Syncing' with a `Progress` that counts: '12 of 40 files'.",
2596
+ "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.'",
2597
+ "List only the sources that need a person on a dashboard card, with the same words. Say how many there are in the title.",
2598
+ "Say so in one line when every source works: 'All 5 sources are working.'",
2599
+ "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.",
2600
+ "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."
2601
+ ],
2602
+ "dont": [
2603
+ "Do not blink or pulse the dot. Motion does not say what is wrong.",
2604
+ "Do not show a dot with no word, even on a small card.",
2605
+ "Do not show a rate limit as an error. Nothing is broken and the person cannot fix it.",
2606
+ "Do not hide the time of the last sync. It tells the person how old the data is.",
2607
+ "Do not list every source on a dashboard card. Show only the ones that need a person."
2608
+ ],
2609
+ "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.",
2610
+ "options": [
2611
+ {
2612
+ "id": "row",
2613
+ "title": "Status on each account",
2614
+ "useWhen": "On the integrations page, where each connected account has its own row.",
2615
+ "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",
2616
+ "uses": [
2617
+ "BrandIcon",
2618
+ "Button",
2619
+ "Center",
2620
+ "Cluster",
2621
+ "Heading",
2622
+ "Icon",
2623
+ "Paragraph",
2624
+ "Progress",
2625
+ "Stack",
2626
+ "TableCell",
2627
+ "TableContainer",
2628
+ "TableRow",
2629
+ "Tag",
2630
+ "TimeStamp"
2631
+ ]
2632
+ },
2633
+ {
2634
+ "id": "card",
2635
+ "title": "Sources that need a person",
2636
+ "useWhen": "On a dashboard, when a broken source explains why some data is missing.",
2637
+ "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",
2638
+ "uses": [
2639
+ "Button",
2640
+ "Center",
2641
+ "Cluster",
2642
+ "Heading",
2643
+ "Icon",
2644
+ "Line",
2645
+ "Link",
2646
+ "Paragraph",
2647
+ "Stack",
2648
+ "Tag",
2649
+ "TimeStamp",
2650
+ "Toaster",
2651
+ "dismissToast",
2652
+ "toast"
2653
+ ]
2654
+ }
2655
+ ]
2656
+ },
1913
2657
  {
1914
2658
  "id": "contact-page",
1915
2659
  "title": "Contact page",
1916
2660
  "kind": "design",
1917
2661
  "level": "page",
1918
2662
  "area": "content",
2663
+ "surface": [
2664
+ "site"
2665
+ ],
1919
2666
  "situation": "A visitor wants to reach the person behind a site.",
1920
2667
  "do": [
1921
2668
  "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 +2721,10 @@
1974
2721
  "kind": "design",
1975
2722
  "level": "organism",
1976
2723
  "area": "chat",
2724
+ "surface": [
2725
+ "app",
2726
+ "agent"
2727
+ ],
1977
2728
  "situation": "A thread has no messages yet, and the person may not know what to write first.",
1978
2729
  "do": [
1979
2730
  "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 +2787,9 @@
2036
2787
  "kind": "design",
2037
2788
  "level": "organism",
2038
2789
  "area": "marketing",
2790
+ "surface": [
2791
+ "site"
2792
+ ],
2039
2793
  "situation": "A site sets cookies it does not need to run, and asks the visitor whether it may.",
2040
2794
  "do": [
2041
2795
  "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 +2855,9 @@
2101
2855
  "kind": "design",
2102
2856
  "level": "organism",
2103
2857
  "area": "confirm",
2858
+ "surface": [
2859
+ "app"
2860
+ ],
2104
2861
  "situation": "A person creates something new, such as a project or a task, and it needs a name before it exists.",
2105
2862
  "do": [
2106
2863
  "Title the Modal 'Create' and the thing, such as 'Create Project', and give its action the same verb: 'Create'.",
@@ -2170,6 +2927,9 @@
2170
2927
  "kind": "design",
2171
2928
  "level": "organism",
2172
2929
  "area": "settings",
2930
+ "surface": [
2931
+ "app"
2932
+ ],
2173
2933
  "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
2934
  "do": [
2175
2935
  "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 +2993,9 @@
2233
2993
  "kind": "design",
2234
2994
  "level": "page",
2235
2995
  "area": "dashboard",
2996
+ "surface": [
2997
+ "app"
2998
+ ],
2236
2999
  "situation": "A page that opens an app and says how things are going and what waits on the person.",
2237
3000
  "do": [
2238
3001
  "Follow the rule 'A number shows its unit and never shows 0 for unknown'.",
@@ -2318,6 +3081,9 @@
2318
3081
  "kind": "design",
2319
3082
  "level": "page",
2320
3083
  "area": "dashboard",
3084
+ "surface": [
3085
+ "app"
3086
+ ],
2321
3087
  "situation": "A page is one long table of records, such as invoices or customers, that a person searches, sorts and acts on.",
2322
3088
  "do": [
2323
3089
  "Follow the rule 'A number shows its unit and never shows 0 for unknown'.",
@@ -2430,6 +3196,9 @@
2430
3196
  "kind": "design",
2431
3197
  "level": "organism",
2432
3198
  "area": "settings",
3199
+ "surface": [
3200
+ "app"
3201
+ ],
2433
3202
  "situation": "A person gives one day, such as when a token expires or their date of birth.",
2434
3203
  "do": [
2435
3204
  "Use `DateField`. The person types the date as MM/DD/YYYY, such as '11/16/2026', or picks it from the calendar.",
@@ -2496,6 +3265,9 @@
2496
3265
  "kind": "design",
2497
3266
  "level": "page",
2498
3267
  "area": "auth",
3268
+ "surface": [
3269
+ "app"
3270
+ ],
2499
3271
  "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
3272
  "do": [
2501
3273
  "Say in one line what the login connects: 'This connects Acme CLI on your computer to your account.'",
@@ -2551,6 +3323,9 @@
2551
3323
  "kind": "design",
2552
3324
  "level": "page",
2553
3325
  "area": "content",
3326
+ "surface": [
3327
+ "site"
3328
+ ],
2554
3329
  "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
3330
  "do": [
2556
3331
  "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 +3384,9 @@
2609
3384
  "kind": "design",
2610
3385
  "level": "page",
2611
3386
  "area": "auth",
3387
+ "surface": [
3388
+ "app"
3389
+ ],
2612
3390
  "situation": "A person opened the link that confirms their email.",
2613
3391
  "do": [
2614
3392
  "Name the page 'Email confirmed' in a `Heading` with `level={1}`.",
@@ -2661,6 +3439,9 @@
2661
3439
  "kind": "design",
2662
3440
  "level": "organism",
2663
3441
  "area": "state",
3442
+ "surface": [
3443
+ "app"
3444
+ ],
2664
3445
  "situation": "A list has loaded, and there is nothing in it yet.",
2665
3446
  "do": [
2666
3447
  "Use `size=\"large\"` when the list is the whole pane, and `size=\"small\"` inside a section.",
@@ -2708,6 +3489,9 @@
2708
3489
  "kind": "rule",
2709
3490
  "level": "rule",
2710
3491
  "area": "state",
3492
+ "surface": [
3493
+ "app"
3494
+ ],
2711
3495
  "situation": "A list, table or pane has nothing to show.",
2712
3496
  "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
3497
  "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 +3517,9 @@
2733
3517
  "kind": "design",
2734
3518
  "level": "organism",
2735
3519
  "area": "state",
3520
+ "surface": [
3521
+ "app"
3522
+ ],
2736
3523
  "situation": "A pane is empty because something it needs is not set up yet, such as a connected account.",
2737
3524
  "do": [
2738
3525
  "Say what is missing: 'No calendar connected'.",
@@ -2779,6 +3566,10 @@
2779
3566
  "kind": "design",
2780
3567
  "level": "organism",
2781
3568
  "area": "state",
3569
+ "surface": [
3570
+ "site",
3571
+ "app"
3572
+ ],
2782
3573
  "situation": "A search or a filter finds nothing.",
2783
3574
  "do": [
2784
3575
  "Use `icon=\"Search\"`, so it reads as a search and not an empty list.",
@@ -2816,6 +3607,10 @@
2816
3607
  "kind": "design",
2817
3608
  "level": "page",
2818
3609
  "area": "state",
3610
+ "surface": [
3611
+ "site",
3612
+ "app"
3613
+ ],
2819
3614
  "situation": "Something broke while showing a page, and the app cannot show it.",
2820
3615
  "do": [
2821
3616
  "Name the page in a `Heading` with `level={1}`: 'Something went wrong'.",
@@ -2869,6 +3664,9 @@
2869
3664
  "kind": "design",
2870
3665
  "level": "organism",
2871
3666
  "area": "marketing",
3667
+ "surface": [
3668
+ "site"
3669
+ ],
2872
3670
  "situation": "A marketing page answers the questions a visitor asks before signing up.",
2873
3671
  "do": [
2874
3672
  "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 +3721,9 @@
2923
3721
  "kind": "design",
2924
3722
  "level": "organism",
2925
3723
  "area": "marketing",
3724
+ "surface": [
3725
+ "site"
3726
+ ],
2926
3727
  "situation": "A marketing page lists what the product does, so a visitor can see if it fits.",
2927
3728
  "do": [
2928
3729
  "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 +3781,9 @@
2980
3781
  "kind": "design",
2981
3782
  "level": "organism",
2982
3783
  "area": "confirm",
3784
+ "surface": [
3785
+ "app"
3786
+ ],
2983
3787
  "situation": "A person sends feedback about the product from inside it.",
2984
3788
  "do": [
2985
3789
  "Title the Modal 'Send Feedback' and label its action 'Send', after 'Cancel'.",
@@ -3028,6 +3832,9 @@
3028
3832
  "kind": "design",
3029
3833
  "level": "organism",
3030
3834
  "area": "settings",
3835
+ "surface": [
3836
+ "app"
3837
+ ],
3031
3838
  "situation": "A person adds a file from their device, such as a new profile picture or the receipts for a report.",
3032
3839
  "do": [
3033
3840
  "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 +3900,9 @@
3093
3900
  "kind": "design",
3094
3901
  "level": "organism",
3095
3902
  "area": "menu",
3903
+ "surface": [
3904
+ "app"
3905
+ ],
3096
3906
  "situation": "A person narrows a list by one choice, such as a date range, or turns the filter off.",
3097
3907
  "do": [
3098
3908
  "Open a navigable menu from an `IconButton`: `<Popover returnFocus>` around `<Menu navigable aria-label=\"Filter by date\">` with `onClick` items.",
@@ -3160,6 +3970,9 @@
3160
3970
  "kind": "design",
3161
3971
  "level": "page",
3162
3972
  "area": "auth",
3973
+ "surface": [
3974
+ "app"
3975
+ ],
3163
3976
  "situation": "A person cannot remember their password and asks for a link to set a new one.",
3164
3977
  "do": [
3165
3978
  "Name the page 'Reset password' in a `Heading` with `level={1}`, and say in one line what happens next.",
@@ -3226,6 +4039,10 @@
3226
4039
  "kind": "rule",
3227
4040
  "level": "rule",
3228
4041
  "area": "state",
4042
+ "surface": [
4043
+ "site",
4044
+ "app"
4045
+ ],
3229
4046
  "situation": "A form was submitted and something is wrong.",
3230
4047
  "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
4048
  "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 +4068,10 @@
3251
4068
  "kind": "design",
3252
4069
  "level": "organism",
3253
4070
  "area": "content",
4071
+ "surface": [
4072
+ "site",
4073
+ "app"
4074
+ ],
3254
4075
  "situation": "A page shows images small, and a person wants to see one larger without leaving the page.",
3255
4076
  "do": [
3256
4077
  "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 +4148,9 @@
3327
4148
  "kind": "design",
3328
4149
  "level": "organism",
3329
4150
  "area": "confirm",
4151
+ "surface": [
4152
+ "app"
4153
+ ],
3330
4154
  "situation": "A person picks which items to bring in from another place, such as pages from a wiki.",
3331
4155
  "do": [
3332
4156
  "Put a search field at the top, then a count line, then the list of `Checkbox`es.",
@@ -3375,6 +4199,9 @@
3375
4199
  "kind": "design",
3376
4200
  "level": "organism",
3377
4201
  "area": "state",
4202
+ "surface": [
4203
+ "app"
4204
+ ],
3378
4205
  "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
4206
  "do": [
3380
4207
  "Show `loading` on the submit Button while the request runs, and keep its label.",
@@ -3450,12 +4277,15 @@
3450
4277
  "kind": "design",
3451
4278
  "level": "organism",
3452
4279
  "area": "settings",
4280
+ "surface": [
4281
+ "app"
4282
+ ],
3453
4283
  "situation": "A person connects the product to other tools, sees which ones are connected and disconnects them.",
3454
4284
  "do": [
3455
4285
  "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
4286
  "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
4287
  "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.",
4288
+ "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
4289
  "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
4290
  "Show `loading` on 'Connect' and 'Reconnect' while the sign-in runs, and keep the label. Disable the other Buttons until it ends.",
3461
4291
  "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 +4296,7 @@
3466
4296
  "Do not use an icon-only Button for Disconnect. It names no provider.",
3467
4297
  "Do not label a running Button 'Connecting…'. It keeps its label and shows `loading`.",
3468
4298
  "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.",
4299
+ "Do not show red text as the only sign that access ran out. Add the 'Needs reconnect' Tag and a 'Reconnect' Button.",
3470
4300
  "Do not give each provider its own page section with a heading and no logo. Put them in one list."
3471
4301
  ],
3472
4302
  "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 +4305,7 @@
3475
4305
  "id": "rows",
3476
4306
  "title": "One row per provider",
3477
4307
  "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",
4308
+ "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
4309
  "uses": [
3480
4310
  "BrandIcon",
3481
4311
  "Button",
@@ -3496,7 +4326,7 @@
3496
4326
  "id": "nested",
3497
4327
  "title": "Accounts under each provider",
3498
4328
  "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",
4329
+ "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
4330
  "uses": [
3501
4331
  "BrandIcon",
3502
4332
  "Button",
@@ -3521,6 +4351,9 @@
3521
4351
  "kind": "design",
3522
4352
  "level": "organism",
3523
4353
  "area": "confirm",
4354
+ "surface": [
4355
+ "app"
4356
+ ],
3524
4357
  "situation": "A person invites someone to join a workspace.",
3525
4358
  "do": [
3526
4359
  "Title the Modal 'Invite Member' and label its action 'Invite', after 'Cancel'.",
@@ -3601,6 +4434,9 @@
3601
4434
  "kind": "design",
3602
4435
  "level": "organism",
3603
4436
  "area": "dashboard",
4437
+ "surface": [
4438
+ "app"
4439
+ ],
3604
4440
  "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
4441
  "do": [
3606
4442
  "Follow the rule 'A number shows its unit and never shows 0 for unknown'.",
@@ -3677,6 +4513,9 @@
3677
4513
  "kind": "design",
3678
4514
  "level": "organism",
3679
4515
  "area": "marketing",
4516
+ "surface": [
4517
+ "site"
4518
+ ],
3680
4519
  "situation": "A marketing page opens by saying what the product is and asking for one thing.",
3681
4520
  "do": [
3682
4521
  "Follow the rule 'A marketing page asks for one main action, in the same words everywhere'.",
@@ -3736,6 +4575,9 @@
3736
4575
  "kind": "design",
3737
4576
  "level": "organism",
3738
4577
  "area": "dashboard",
4578
+ "surface": [
4579
+ "app"
4580
+ ],
3739
4581
  "situation": "A dashboard shows who did the most of something over its range, such as who left the most comments this week.",
3740
4582
  "do": [
3741
4583
  "Follow the rule 'A number shows its unit and never shows 0 for unknown'.",
@@ -3809,6 +4651,9 @@
3809
4651
  "kind": "design",
3810
4652
  "level": "page",
3811
4653
  "area": "content",
4654
+ "surface": [
4655
+ "site"
4656
+ ],
3812
4657
  "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
4658
  "do": [
3814
4659
  "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 +4698,9 @@
3853
4698
  "kind": "design",
3854
4699
  "level": "organism",
3855
4700
  "area": "state",
4701
+ "surface": [
4702
+ "app"
4703
+ ],
3856
4704
  "situation": "A list or a section could not load.",
3857
4705
  "do": [
3858
4706
  "Say what could not load: 'Could not load projects'.",
@@ -3907,6 +4755,9 @@
3907
4755
  "kind": "design",
3908
4756
  "level": "organism",
3909
4757
  "area": "confirm",
4758
+ "surface": [
4759
+ "app"
4760
+ ],
3910
4761
  "situation": "A person chooses Log Out.",
3911
4762
  "do": [
3912
4763
  "Call it 'Log Out' everywhere: the menu item, the Modal title and the action Button. The way back in is 'Log In'.",
@@ -3946,6 +4797,9 @@
3946
4797
  "kind": "design",
3947
4798
  "level": "page",
3948
4799
  "area": "auth",
4800
+ "surface": [
4801
+ "app"
4802
+ ],
3949
4803
  "situation": "A person who already has an account opens the product and is not logged in.",
3950
4804
  "do": [
3951
4805
  "Show a problem with one field under that field.",
@@ -4045,6 +4899,9 @@
4045
4899
  "kind": "design",
4046
4900
  "level": "page",
4047
4901
  "area": "content",
4902
+ "surface": [
4903
+ "site"
4904
+ ],
4048
4905
  "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
4906
  "do": [
4050
4907
  "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 +4969,9 @@
4112
4969
  "kind": "design",
4113
4970
  "level": "page",
4114
4971
  "area": "shell",
4972
+ "surface": [
4973
+ "app"
4974
+ ],
4115
4975
  "situation": "A person opens an item from a list, such as a message or a report, and reads or acts on it.",
4116
4976
  "do": [
4117
4977
  "Follow the rule 'On a phone, a sidebar opens as a drawer and a list opens its detail'.",
@@ -4175,6 +5035,9 @@
4175
5035
  "kind": "design",
4176
5036
  "level": "organism",
4177
5037
  "area": "settings",
5038
+ "surface": [
5039
+ "app"
5040
+ ],
4178
5041
  "situation": "An admin sees who is in the workspace, changes their roles, removes people and invites more.",
4179
5042
  "do": [
4180
5043
  "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 +5134,10 @@
4271
5134
  "kind": "design",
4272
5135
  "level": "organism",
4273
5136
  "area": "chat",
5137
+ "surface": [
5138
+ "app",
5139
+ "agent"
5140
+ ],
4274
5141
  "situation": "A person types @ in the message box to name someone, or the agent.",
4275
5142
  "do": [
4276
5143
  "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 +5189,10 @@
4322
5189
  "kind": "design",
4323
5190
  "level": "organism",
4324
5191
  "area": "chat",
5192
+ "surface": [
5193
+ "app",
5194
+ "agent"
5195
+ ],
4325
5196
  "situation": "A person acts on one message: reacts to it, copies it, edits or deletes it.",
4326
5197
  "do": [
4327
5198
  "Put the actions in the Message's `actions`. They show while the pointer is on the row or focus is in it.",
@@ -4412,6 +5283,9 @@
4412
5283
  "kind": "design",
4413
5284
  "level": "organism",
4414
5285
  "area": "chat",
5286
+ "surface": [
5287
+ "app"
5288
+ ],
4415
5289
  "situation": "A person adds files to a message, and people open the files in a message that was sent.",
4416
5290
  "do": [
4417
5291
  "Show each waiting file as a `FileChip` in the Composer's `above` slot, with `onRemove`.",
@@ -4489,6 +5363,10 @@
4489
5363
  "kind": "design",
4490
5364
  "level": "organism",
4491
5365
  "area": "chat",
5366
+ "surface": [
5367
+ "app",
5368
+ "agent"
5369
+ ],
4492
5370
  "situation": "A person writes a message at the bottom of a thread.",
4493
5371
  "do": [
4494
5372
  "Use `Composer` under the thread, with an `aria-label`, since it has no visible label.",
@@ -4501,10 +5379,10 @@
4501
5379
  "Pass `onStop` in a conversation with the agent only, so Send becomes Stop.",
4502
5380
  "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
5381
  "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.",
5382
+ "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
5383
  "Move focus to the message box when Stop goes away.",
4506
5384
  "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.",
5385
+ "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
5386
  "Keep the draft when the person leaves the thread, and show it again when they come back."
4509
5387
  ],
4510
5388
  "dont": [
@@ -4536,7 +5414,7 @@
4536
5414
  "id": "with-tools",
4537
5415
  "title": "Composer with tools",
4538
5416
  "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",
5417
+ "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
5418
  "uses": [
4541
5419
  "Button",
4542
5420
  "Center",
@@ -4563,6 +5441,9 @@
4563
5441
  "kind": "design",
4564
5442
  "level": "organism",
4565
5443
  "area": "chat",
5444
+ "surface": [
5445
+ "app"
5446
+ ],
4566
5447
  "situation": "A person changes the text of a message they sent.",
4567
5448
  "do": [
4568
5449
  "Replace the row's body with a `Composer` that holds the text, and focus it with the caret after the text.",
@@ -4612,6 +5493,9 @@
4612
5493
  "kind": "design",
4613
5494
  "level": "organism",
4614
5495
  "area": "chat",
5496
+ "surface": [
5497
+ "app"
5498
+ ],
4615
5499
  "situation": "People answer a message with an emoji instead of a reply.",
4616
5500
  "do": [
4617
5501
  "Put the reactions in the Message's `footer`: a `Cluster` of `Tag`s, then a small 'Add reaction' `IconButton`.",
@@ -4705,6 +5589,10 @@
4705
5589
  "kind": "design",
4706
5590
  "level": "organism",
4707
5591
  "area": "chat",
5592
+ "surface": [
5593
+ "app",
5594
+ "agent"
5595
+ ],
4708
5596
  "situation": "A thread shows messages from people, and sometimes from an agent.",
4709
5597
  "do": [
4710
5598
  "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 +5617,102 @@
4729
5617
  "native": "On Apple a row shows the avatar, the name and the time, with an 'Agent' label next to an agent's name.",
4730
5618
  "options": [
4731
5619
  {
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",
5620
+ "id": "person-and-agent",
5621
+ "title": "People and an agent",
5622
+ "useWhen": "A thread with gaps between messages: every row shows who and when.",
5623
+ "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",
5624
+ "uses": [
5625
+ "Center",
5626
+ "Heading",
5627
+ "Message",
5628
+ "Paragraph",
5629
+ "Stack",
5630
+ "Tag",
5631
+ "TimeStamp",
5632
+ "UserImage"
5633
+ ]
5634
+ },
5635
+ {
5636
+ "id": "grouped",
5637
+ "title": "Grouped rows",
5638
+ "useWhen": "A busy thread: follow-on rows from one sender drop the avatar and the name.",
5639
+ "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",
5640
+ "uses": [
5641
+ "Center",
5642
+ "Heading",
5643
+ "Line",
5644
+ "Message",
5645
+ "Paragraph",
5646
+ "Stack",
5647
+ "TimeStamp",
5648
+ "UserImage"
5649
+ ]
5650
+ }
5651
+ ]
5652
+ },
5653
+ {
5654
+ "id": "message-send-failure",
5655
+ "title": "Message that did not send",
5656
+ "kind": "design",
5657
+ "level": "organism",
5658
+ "area": "chat",
5659
+ "surface": [
5660
+ "app",
5661
+ "agent"
5662
+ ],
5663
+ "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.",
5664
+ "do": [
5665
+ "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.",
5666
+ "Write 'Not sent yet. Trying again.' when the app will send it by itself, with 'Send Now' and 'Discard'.",
5667
+ "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'.",
5668
+ "Make the line's Buttons `size=\"small\"`, with an `aria-label` that names the message: 'Send now: Can you check the plan table on…'.",
5669
+ "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}`.",
5670
+ "Keep the `Composer` working. The person can type and send more, and each new message waits in the thread too.",
5671
+ "Show 'Send Now' and 'Try Again' as `loading` while they send, and keep their labels.",
5672
+ "Move focus to the `Composer` when the message sends or is discarded, because the line and its Buttons are gone.",
5673
+ "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.",
5674
+ "Say in a polite status line, once, when waiting messages have sent: 'Back online. 2 messages sent.'"
5675
+ ],
5676
+ "dont": [
5677
+ "Do not fade the text as the only sign that it did not send. Say it in words under the message.",
5678
+ "Do not show a toast for a failure that stays. The line stays with the message until it sends or is discarded.",
5679
+ "Do not lose the text. It stays in the thread until it sends or the person discards it.",
5680
+ "Do not show the error's own message, such as 'Request failed with status 401'.",
5681
+ "Do not block the Composer while one message waits."
5682
+ ],
5683
+ "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.",
5684
+ "options": [
5685
+ {
5686
+ "id": "retrying",
5687
+ "title": "Sends again by itself",
5688
+ "useWhen": "The app can send it again without help, such as when it is offline.",
5689
+ "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
5690
  "uses": [
5691
+ "Alert",
5692
+ "Button",
4737
5693
  "Center",
5694
+ "Cluster",
5695
+ "Composer",
4738
5696
  "Heading",
4739
5697
  "Message",
4740
5698
  "Paragraph",
4741
5699
  "Stack",
4742
- "Tag",
4743
5700
  "TimeStamp",
4744
5701
  "UserImage"
4745
5702
  ]
4746
5703
  },
4747
5704
  {
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",
5705
+ "id": "needs-a-person",
5706
+ "title": "Waits for a fix",
5707
+ "useWhen": "Sending cannot work until the person does something, such as reconnect an account.",
5708
+ "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
5709
  "uses": [
5710
+ "Button",
4753
5711
  "Center",
5712
+ "Cluster",
5713
+ "Composer",
4754
5714
  "Heading",
4755
- "Line",
5715
+ "Link",
4756
5716
  "Message",
4757
5717
  "Paragraph",
4758
5718
  "Stack",
@@ -4768,6 +5728,10 @@
4768
5728
  "kind": "design",
4769
5729
  "level": "organism",
4770
5730
  "area": "shell",
5731
+ "surface": [
5732
+ "site",
5733
+ "app"
5734
+ ],
4771
5735
  "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
5736
  "do": [
4773
5737
  "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 +5794,9 @@
4830
5794
  "kind": "design",
4831
5795
  "level": "organism",
4832
5796
  "area": "marketing",
5797
+ "surface": [
5798
+ "site"
5799
+ ],
4833
5800
  "situation": "A reader of the public site wants to hear about the product by email, without making an account.",
4834
5801
  "do": [
4835
5802
  "Follow the rules 'A form error shows next to the problem' and 'Success shows where the person is looking'.",
@@ -4888,12 +5855,78 @@
4888
5855
  }
4889
5856
  ]
4890
5857
  },
5858
+ {
5859
+ "id": "no-access",
5860
+ "title": "No access",
5861
+ "kind": "design",
5862
+ "level": "organism",
5863
+ "area": "state",
5864
+ "surface": [
5865
+ "app"
5866
+ ],
5867
+ "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.",
5868
+ "do": [
5869
+ "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.",
5870
+ "Show an `EmptyBox` in the page's place that names what they cannot see: 'You do not have access to Billing'.",
5871
+ "Say who can give access, by name: 'Ask an admin: Dana Lee'.",
5872
+ "Offer one way out, 'Go Home', as the `EmptyBox` action.",
5873
+ "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}`.",
5874
+ "Show the fields with `readOnly`, so the person can still read, select and copy the values.",
5875
+ "Show a choice that has no read-only state, such as a `RadioGroup`, disabled, under the line that says who can change it.",
5876
+ "Leave out the Save Button and every Button that would change a setting."
5877
+ ],
5878
+ "dont": [
5879
+ "Do not show a 404 for a page that exists. Say it is there and who can open it.",
5880
+ "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.",
5881
+ "Do not show disabled Buttons with no reason. Leave them out, and say once at the top who can change things.",
5882
+ "Do not use `disabled` fields for a page the person can read. Disabled text is faint and cannot be focused.",
5883
+ "Do not say 'Contact your admin' on a page the person cannot change without saying who that is."
5884
+ ],
5885
+ "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.",
5886
+ "options": [
5887
+ {
5888
+ "id": "page",
5889
+ "title": "Page they cannot see",
5890
+ "useWhen": "The person opened a page their role cannot see.",
5891
+ "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",
5892
+ "uses": [
5893
+ "AppShell",
5894
+ "Button",
5895
+ "EmptyBox",
5896
+ "MenuItem",
5897
+ "Navigation",
5898
+ "Paragraph",
5899
+ "Stack",
5900
+ "Surface",
5901
+ "TitleBar"
5902
+ ]
5903
+ },
5904
+ {
5905
+ "id": "read-only",
5906
+ "title": "Settings they cannot change",
5907
+ "useWhen": "The person can see a settings page but cannot change it.",
5908
+ "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",
5909
+ "uses": [
5910
+ "Alert",
5911
+ "Center",
5912
+ "Heading",
5913
+ "SettingsSection",
5914
+ "Stack",
5915
+ "TextField"
5916
+ ]
5917
+ }
5918
+ ]
5919
+ },
4891
5920
  {
4892
5921
  "id": "not-found-page",
4893
5922
  "title": "Page not found",
4894
5923
  "kind": "design",
4895
5924
  "level": "page",
4896
5925
  "area": "state",
5926
+ "surface": [
5927
+ "site",
5928
+ "app"
5929
+ ],
4897
5930
  "situation": "A person opens a link to a page that does not exist.",
4898
5931
  "do": [
4899
5932
  "Say 'Page not found' in a `Heading` with `level={1}`.",
@@ -4946,6 +5979,9 @@
4946
5979
  "kind": "design",
4947
5980
  "level": "organism",
4948
5981
  "area": "menu",
5982
+ "surface": [
5983
+ "app"
5984
+ ],
4949
5985
  "situation": "A person chooses how much a channel or a thread notifies them.",
4950
5986
  "do": [
4951
5987
  "Use an `IconButton` with `iconName=\"Bell\"`, and `BellOff` when the channel is muted.",
@@ -4996,6 +6032,10 @@
4996
6032
  "kind": "rule",
4997
6033
  "level": "rule",
4998
6034
  "area": "dashboard",
6035
+ "surface": [
6036
+ "site",
6037
+ "app"
6038
+ ],
4999
6039
  "situation": "A page shows counts, money, sizes, shares or changes.",
5000
6040
  "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
6041
  "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 +6072,10 @@
5032
6072
  "kind": "design",
5033
6073
  "level": "page",
5034
6074
  "area": "auth",
6075
+ "surface": [
6076
+ "app",
6077
+ "agent"
6078
+ ],
5035
6079
  "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
6080
  "do": [
5037
6081
  "Name the app in a `Heading` with `level={1}`: 'Acme CLI wants to connect to Acme'.",
@@ -5101,6 +6145,9 @@
5101
6145
  "kind": "design",
5102
6146
  "level": "organism",
5103
6147
  "area": "settings",
6148
+ "surface": [
6149
+ "app"
6150
+ ],
5104
6151
  "situation": "A person turns things on and off, such as which notifications they get.",
5105
6152
  "do": [
5106
6153
  "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 +6190,10 @@
5143
6190
  "kind": "design",
5144
6191
  "level": "organism",
5145
6192
  "area": "shell",
6193
+ "surface": [
6194
+ "site",
6195
+ "app"
6196
+ ],
5146
6197
  "situation": "A person reads a long page and wants to see its sections, jump to one and know which one they are in.",
5147
6198
  "do": [
5148
6199
  "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 +6237,9 @@
5186
6237
  "kind": "design",
5187
6238
  "level": "organism",
5188
6239
  "area": "auth",
6240
+ "surface": [
6241
+ "app"
6242
+ ],
5189
6243
  "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
6244
  "do": [
5191
6245
  "Follow the rule 'A form error shows next to the problem'.",
@@ -5262,6 +6316,9 @@
5262
6316
  "kind": "rule",
5263
6317
  "level": "rule",
5264
6318
  "area": "marketing",
6319
+ "surface": [
6320
+ "site"
6321
+ ],
5265
6322
  "situation": "A marketing page asks the visitor to do something: sign up, open the app, buy a plan.",
5266
6323
  "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
6324
  "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 +6346,9 @@
5289
6346
  "kind": "design",
5290
6347
  "level": "organism",
5291
6348
  "area": "menu",
6349
+ "surface": [
6350
+ "app"
6351
+ ],
5292
6352
  "situation": "A person opens a menu of less common actions, behind one button, for a thing or for the page.",
5293
6353
  "do": [
5294
6354
  "Use an `IconButton` with `iconName=\"Ellipsis\"` and a `Tooltip` of 'More'.",
@@ -5375,6 +6435,9 @@
5375
6435
  "kind": "design",
5376
6436
  "level": "organism",
5377
6437
  "area": "marketing",
6438
+ "surface": [
6439
+ "site"
6440
+ ],
5378
6441
  "situation": "A page has said what it had to say, and its last block decides what the visitor does next.",
5379
6442
  "do": [
5380
6443
  "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 +6490,9 @@
5427
6490
  "kind": "design",
5428
6491
  "level": "organism",
5429
6492
  "area": "shell",
6493
+ "surface": [
6494
+ "app"
6495
+ ],
5430
6496
  "situation": "A page names itself at the top and offers what the person can do with it.",
5431
6497
  "do": [
5432
6498
  "Follow the rule 'On a phone, a sidebar opens as a drawer and a list opens its detail'.",
@@ -5491,6 +6557,9 @@
5491
6557
  "kind": "design",
5492
6558
  "level": "organism",
5493
6559
  "area": "dashboard",
6560
+ "surface": [
6561
+ "app"
6562
+ ],
5494
6563
  "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
6564
  "do": [
5496
6565
  "Follow the rule 'A number shows its unit and never shows 0 for unknown'.",
@@ -5551,6 +6620,9 @@
5551
6620
  "kind": "design",
5552
6621
  "level": "organism",
5553
6622
  "area": "content",
6623
+ "surface": [
6624
+ "site"
6625
+ ],
5554
6626
  "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
6627
  "do": [
5556
6628
  "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 +6708,9 @@
5636
6708
  "kind": "design",
5637
6709
  "level": "organism",
5638
6710
  "area": "dashboard",
6711
+ "surface": [
6712
+ "app"
6713
+ ],
5639
6714
  "situation": "A workspace pays by card. The admin sees which card, changes it or removes it.",
5640
6715
  "do": [
5641
6716
  "Follow the rule 'A number shows its unit and never shows 0 for unknown'.",
@@ -5701,6 +6776,9 @@
5701
6776
  "kind": "design",
5702
6777
  "level": "organism",
5703
6778
  "area": "chat",
6779
+ "surface": [
6780
+ "app"
6781
+ ],
5704
6782
  "situation": "A thread or a task shows who is on it, and the person can find out who they all are.",
5705
6783
  "do": [
5706
6784
  "Use `AvatarStack` for four or more people. Past `max` its last circle counts the rest, such as '+3'.",
@@ -5754,6 +6832,10 @@
5754
6832
  "kind": "rule",
5755
6833
  "level": "rule",
5756
6834
  "area": "shell",
6835
+ "surface": [
6836
+ "site",
6837
+ "app"
6838
+ ],
5757
6839
  "situation": "A layout with a sidebar, a list beside its detail, or a side pane meets a phone screen.",
5758
6840
  "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
6841
  "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 +6862,9 @@
5780
6862
  "kind": "design",
5781
6863
  "level": "organism",
5782
6864
  "area": "dashboard",
6865
+ "surface": [
6866
+ "app"
6867
+ ],
5783
6868
  "situation": "An admin chose another plan. Before anything changes they need to know what it costs and when it starts.",
5784
6869
  "do": [
5785
6870
  "Follow the rule 'A number shows its unit and never shows 0 for unknown'.",
@@ -5862,6 +6947,9 @@
5862
6947
  "kind": "design",
5863
6948
  "level": "organism",
5864
6949
  "area": "marketing",
6950
+ "surface": [
6951
+ "site"
6952
+ ],
5865
6953
  "situation": "A visitor to the public site wants to see every limit of every plan side by side before signing up.",
5866
6954
  "do": [
5867
6955
  "Follow the rule 'A number shows its unit and never shows 0 for unknown'.",
@@ -5878,7 +6966,7 @@
5878
6966
  "Do not build the table from a grid of boxes. A screen reader cannot read it as a table.",
5879
6967
  "Do not hide the header row on a phone. Let the table scroll sideways in its region.",
5880
6968
  "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.",
6969
+ "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
6970
  "Do not dim the other columns with tabs. Every plan stays in view."
5883
6971
  ],
5884
6972
  "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 +6996,9 @@
5908
6996
  "kind": "design",
5909
6997
  "level": "organism",
5910
6998
  "area": "dashboard",
6999
+ "surface": [
7000
+ "app"
7001
+ ],
5911
7002
  "situation": "An admin compares the plans a workspace can be on and chooses one.",
5912
7003
  "do": [
5913
7004
  "Follow the rule 'A number shows its unit and never shows 0 for unknown'.",
@@ -5917,7 +7008,8 @@
5917
7008
  "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
7009
  "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
7010
  "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."
7011
+ "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.",
7012
+ "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
7013
  ],
5922
7014
  "dont": [
5923
7015
  "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 +7018,7 @@
5926
7018
  "Do not add a monthly and yearly switch when no plan bills yearly.",
5927
7019
  "Do not change a Button label to show it is busy, such as to 'Checking...'.",
5928
7020
  "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."
7021
+ "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
7022
  ],
5931
7023
  "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
7024
  "options": [
@@ -5979,6 +7071,9 @@
5979
7071
  "kind": "design",
5980
7072
  "level": "organism",
5981
7073
  "area": "agent",
7074
+ "surface": [
7075
+ "agent"
7076
+ ],
5982
7077
  "situation": "The agent wrote a plan for a task, and people approve it before the agent starts the work.",
5983
7078
  "do": [
5984
7079
  "Follow the rule 'An agent asks before a risky action': the agent starts nothing until every required person has said yes.",
@@ -6066,6 +7161,9 @@
6066
7161
  "kind": "design",
6067
7162
  "level": "organism",
6068
7163
  "area": "marketing",
7164
+ "surface": [
7165
+ "site"
7166
+ ],
6069
7167
  "situation": "A visitor to the public site compares the plans and signs up for one.",
6070
7168
  "do": [
6071
7169
  "Follow the rule 'A marketing page asks for one main action, in the same words everywhere'.",
@@ -6075,13 +7173,15 @@
6075
7173
  "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
7174
  "Put the section's name in `SectionIntro`, so the section has a level 2 heading and a link of its own.",
6077
7175
  "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."
7176
+ "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.",
7177
+ "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.",
7178
+ "Send a paid plan's Button to sign-up with that plan, as the case 'Sign-up from the site' says."
6079
7179
  ],
6080
7180
  "dont": [
6081
7181
  "Do not name a Button 'Get Started', 'Choose' or 'Select'. Name the plan it signs up for.",
6082
7182
  "Do not open the sign-up page in a new tab.",
6083
7183
  "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.",
7184
+ "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
7185
  "Do not make a card clickable as a whole. Its Button is the one control."
6086
7186
  ],
6087
7187
  "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 +7213,9 @@
6113
7213
  "kind": "design",
6114
7214
  "level": "organism",
6115
7215
  "area": "marketing",
7216
+ "surface": [
7217
+ "site"
7218
+ ],
6116
7219
  "situation": "A maker lists its products on one page, and each product has its own site.",
6117
7220
  "do": [
6118
7221
  "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 +7249,86 @@
6146
7249
  }
6147
7250
  ]
6148
7251
  },
7252
+ {
7253
+ "id": "product-demo",
7254
+ "title": "Product demo on a site",
7255
+ "kind": "design",
7256
+ "level": "organism",
7257
+ "area": "marketing",
7258
+ "surface": [
7259
+ "site"
7260
+ ],
7261
+ "situation": "A page on the public site shows the product at work, so a visitor sees what it does before they sign up.",
7262
+ "do": [
7263
+ "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.",
7264
+ "Mark the demo as an example. Put a `Tag` 'Example' on a scripted demo, and say it in the caption of a picture.",
7265
+ "Use made-up people and made-up work in the demo, never a real customer.",
7266
+ "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.",
7267
+ "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.",
7268
+ "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.",
7269
+ "Keep it the same Button when its label changes, so focus stays on it.",
7270
+ "Let the visitor pick a scene with a `SegmentedControl`. Picking a scene pauses the demo.",
7271
+ "Start a scripted demo stopped, with 'Play', when the visitor asks for reduced motion. It plays only when they press 'Play'.",
7272
+ "Show each scene for at least 6 seconds, so a visitor can read it.",
7273
+ "Keep the demo out of live regions, so a screen reader is not read each scene as it changes.",
7274
+ "Stop the timers when the demo leaves the page."
7275
+ ],
7276
+ "dont": [
7277
+ "Do not pause the demo on hover only. A keyboard or touch visitor cannot hover.",
7278
+ "Do not rotate words in the page's h1.",
7279
+ "Do not show a control, a label or a plan the app does not have.",
7280
+ "Do not add a message box or other field a visitor might try to type into."
7281
+ ],
7282
+ "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.",
7283
+ "options": [
7284
+ {
7285
+ "id": "still",
7286
+ "title": "One picture",
7287
+ "useWhen": "One picture of the product says enough.",
7288
+ "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",
7289
+ "uses": [
7290
+ "Figure",
7291
+ "Image",
7292
+ "PageSection",
7293
+ "PageShell",
7294
+ "SectionIntro"
7295
+ ]
7296
+ },
7297
+ {
7298
+ "id": "scripted",
7299
+ "title": "Scripted scenes",
7300
+ "useWhen": "The product is about a flow, such as asking an agent and getting an answer.",
7301
+ "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 { 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\n// `autoPlay` starts the scenes when the page opens. A real site passes it only when the visitor has not asked for\n// reduced motion, from `matchMedia('(prefers-reduced-motion: reduce)')`. Left out, the demo waits for the visitor.\nexport default function ProductDemoScripted({ autoPlay = false }: { autoPlay?: boolean } = {}) {\n const [scene, setScene] = useState(autoPlay ? 'ask' : 'answer');\n const [paused, setPaused] = useState(!autoPlay);\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 setScene((s) => scenes[(scenes.findIndex((x) => x.value === s) + 1) % scenes.length].value);\n }, sceneTime);\n return () => clearInterval(timer.current);\n }, [paused]);\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((p) => !p)}\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 setScene(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",
7302
+ "uses": [
7303
+ "Button",
7304
+ "Cluster",
7305
+ "Grid",
7306
+ "Message",
7307
+ "PageSection",
7308
+ "PageShell",
7309
+ "Paragraph",
7310
+ "SectionIntro",
7311
+ "SegmentedControl",
7312
+ "SourceCard",
7313
+ "Stack",
7314
+ "StepList",
7315
+ "Surface",
7316
+ "Tag",
7317
+ "TimeStamp",
7318
+ "UserImage"
7319
+ ]
7320
+ }
7321
+ ]
7322
+ },
6149
7323
  {
6150
7324
  "id": "profile-form",
6151
7325
  "title": "Profile",
6152
7326
  "kind": "design",
6153
7327
  "level": "organism",
6154
7328
  "area": "settings",
7329
+ "surface": [
7330
+ "app"
7331
+ ],
6155
7332
  "situation": "A person changes how they appear and how they sign in: their picture, their name and their password.",
6156
7333
  "do": [
6157
7334
  "Follow the rule 'A setting saves in place, or with one Save Button'.",
@@ -6206,6 +7383,9 @@
6206
7383
  "kind": "design",
6207
7384
  "level": "organism",
6208
7385
  "area": "menu",
7386
+ "surface": [
7387
+ "app"
7388
+ ],
6209
7389
  "situation": "A person jumps to a channel, task or document by typing part of its name, from anywhere in the product.",
6210
7390
  "do": [
6211
7391
  "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 +7437,10 @@
6257
7437
  "kind": "design",
6258
7438
  "level": "organism",
6259
7439
  "area": "menu",
7440
+ "surface": [
7441
+ "site",
7442
+ "app"
7443
+ ],
6260
7444
  "situation": "A person changes the time range of the numbers or a list on the same page, such as Week, Month or Quarter.",
6261
7445
  "do": [
6262
7446
  "Follow the rule 'A number shows its unit and never shows 0 for unknown'.",
@@ -6297,6 +7481,9 @@
6297
7481
  "kind": "design",
6298
7482
  "level": "organism",
6299
7483
  "area": "confirm",
7484
+ "surface": [
7485
+ "app"
7486
+ ],
6300
7487
  "situation": "A person renames something, such as a project or a channel.",
6301
7488
  "do": [
6302
7489
  "Title the Modal 'Rename' and the thing, such as 'Rename Project', and give its action the same verb: 'Rename'.",
@@ -6355,6 +7542,9 @@
6355
7542
  "kind": "design",
6356
7543
  "level": "organism",
6357
7544
  "area": "agent",
7545
+ "surface": [
7546
+ "agent"
7547
+ ],
6358
7548
  "situation": "The agent has replied, and the person can say whether the reply helped.",
6359
7549
  "do": [
6360
7550
  "Put a row of small `IconButton`s with Tooltips in the agent reply's `footer`: thumbs up, thumbs down, Copy, then Regenerate.",
@@ -6434,6 +7624,9 @@
6434
7624
  "kind": "design",
6435
7625
  "level": "organism",
6436
7626
  "area": "agent",
7627
+ "surface": [
7628
+ "agent"
7629
+ ],
6437
7630
  "situation": "The agent answered from things it read, and the person may want to check them.",
6438
7631
  "do": [
6439
7632
  "Follow the rule 'An agent shows its sources': put the sources in the reply's `footer`, directly under the reply.",
@@ -6503,6 +7696,10 @@
6503
7696
  "kind": "design",
6504
7697
  "level": "page",
6505
7698
  "area": "state",
7699
+ "surface": [
7700
+ "site",
7701
+ "app"
7702
+ ],
6506
7703
  "situation": "A page or a pane is loading, and there is nothing to show yet.",
6507
7704
  "do": [
6508
7705
  "Show the shell as soon as it can, and the spinner only where content is loading.",
@@ -6551,6 +7748,9 @@
6551
7748
  "kind": "design",
6552
7749
  "level": "organism",
6553
7750
  "area": "menu",
7751
+ "surface": [
7752
+ "app"
7753
+ ],
6554
7754
  "situation": "A person chooses where a search or a question looks, such as one workspace or all of them.",
6555
7755
  "do": [
6556
7756
  "Use a small tertiary `Button` whose label is the current scope, with `actionIcon=\"ChevronDown\"` so it looks like it opens a menu.",
@@ -6595,6 +7795,9 @@
6595
7795
  "kind": "design",
6596
7796
  "level": "organism",
6597
7797
  "area": "content",
7798
+ "surface": [
7799
+ "site"
7800
+ ],
6598
7801
  "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
7802
  "do": [
6600
7803
  "Use `PageHeader` with `level={1}`: the section's name is the one level 1 heading, with a `lede` of one sentence.",
@@ -6645,12 +7848,79 @@
6645
7848
  }
6646
7849
  ]
6647
7850
  },
7851
+ {
7852
+ "id": "session-expired",
7853
+ "title": "Session that ended",
7854
+ "kind": "design",
7855
+ "level": "organism",
7856
+ "area": "state",
7857
+ "surface": [
7858
+ "app"
7859
+ ],
7860
+ "situation": "A person is using the app when their login ends, such as after a long break or a password change somewhere else.",
7861
+ "do": [
7862
+ "Follow the case 'Login page' for the fields, the errors and the loading Button.",
7863
+ "Open a small `Modal` titled 'Log In Again' over the page when the person has unsaved work, so the work stays where it is.",
7864
+ "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.'",
7865
+ "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.",
7866
+ "Show 'Log In' as `loading` while it runs, and keep its label.",
7867
+ "Return focus to where it was when the Modal closes, such as the field with the typed text.",
7868
+ "Open the login page with an info `Alert` when nothing would be lost: 'You were logged out. Log in to go back to Invoices.'",
7869
+ "Keep the page the person was on in the address, and go back to it after they log in.",
7870
+ "Fill in the email the person used, so they only type the password."
7871
+ ],
7872
+ "dont": [
7873
+ "Do not send the person to the login page without a word, and drop what they typed.",
7874
+ "Do not close the Modal on Escape or a click outside. The page cannot save until the person logs in.",
7875
+ "Do not land on the home page after the login when the person came from another page.",
7876
+ "Do not say 'Session expired' or 'Token invalid'. Say they were logged out and what to do."
7877
+ ],
7878
+ "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`.",
7879
+ "options": [
7880
+ {
7881
+ "id": "in-place",
7882
+ "title": "Log in over the page",
7883
+ "useWhen": "The person has unsaved work on the page, such as text they typed.",
7884
+ "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",
7885
+ "uses": [
7886
+ "Button",
7887
+ "Center",
7888
+ "Cluster",
7889
+ "Modal",
7890
+ "Paragraph",
7891
+ "Stack",
7892
+ "TextField",
7893
+ "TitleBar"
7894
+ ]
7895
+ },
7896
+ {
7897
+ "id": "redirect",
7898
+ "title": "Log in, then go back",
7899
+ "useWhen": "Nothing on the page would be lost, so the login page can take its place.",
7900
+ "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",
7901
+ "uses": [
7902
+ "Alert",
7903
+ "BrandIcon",
7904
+ "Button",
7905
+ "Center",
7906
+ "Form",
7907
+ "Heading",
7908
+ "Image",
7909
+ "Line",
7910
+ "TextField"
7911
+ ]
7912
+ }
7913
+ ]
7914
+ },
6648
7915
  {
6649
7916
  "id": "set-new-password",
6650
7917
  "title": "Set new password",
6651
7918
  "kind": "design",
6652
7919
  "level": "page",
6653
7920
  "area": "auth",
7921
+ "surface": [
7922
+ "app"
7923
+ ],
6654
7924
  "situation": "A person opened the link to reset their password and now chooses a new one.",
6655
7925
  "do": [
6656
7926
  "Name the page 'Set new password' in a `Heading` with `level={1}`, and name the account it is for.",
@@ -6714,6 +7984,9 @@
6714
7984
  "kind": "design",
6715
7985
  "level": "page",
6716
7986
  "area": "settings",
7987
+ "surface": [
7988
+ "app"
7989
+ ],
6717
7990
  "situation": "A person opens the settings of the product and looks for one area, such as Profile or Billing.",
6718
7991
  "do": [
6719
7992
  "Title the page 'Settings' with a level 1 `Heading`.",
@@ -6794,6 +8067,10 @@
6794
8067
  "kind": "rule",
6795
8068
  "level": "rule",
6796
8069
  "area": "settings",
8070
+ "surface": [
8071
+ "site",
8072
+ "app"
8073
+ ],
6797
8074
  "situation": "A person changes a setting.",
6798
8075
  "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
8076
  "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 +8100,9 @@
6823
8100
  "kind": "design",
6824
8101
  "level": "organism",
6825
8102
  "area": "shell",
8103
+ "surface": [
8104
+ "app"
8105
+ ],
6826
8106
  "situation": "A person opens more about the page, such as its members, its history or a document, without leaving the page.",
6827
8107
  "do": [
6828
8108
  "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 +8172,9 @@
6892
8172
  "kind": "design",
6893
8173
  "level": "organism",
6894
8174
  "area": "shell",
8175
+ "surface": [
8176
+ "app"
8177
+ ],
6895
8178
  "situation": "A person looks down the sidebar for a place, and for what has something new in it.",
6896
8179
  "do": [
6897
8180
  "Follow the rule 'On a phone, a sidebar opens as a drawer and a list opens its detail'.",
@@ -6952,6 +8235,9 @@
6952
8235
  "kind": "design",
6953
8236
  "level": "page",
6954
8237
  "area": "auth",
8238
+ "surface": [
8239
+ "app"
8240
+ ],
6955
8241
  "situation": "A person who has no account yet opens the product and wants one.",
6956
8242
  "do": [
6957
8243
  "Ask only for what the account needs: name, email and password.",
@@ -6964,7 +8250,8 @@
6964
8250
  "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
8251
  "Keep the submit Button loading until the check-your-email view shows.",
6966
8252
  "Name the provider on its button: 'Continue with Google'.",
6967
- "Link or tab to login for people who already have an account."
8253
+ "Link or tab to login for people who already have an account.",
8254
+ "Follow the case 'Sign-up from the site' when the visitor chose a plan first."
6968
8255
  ],
6969
8256
  "dont": [
6970
8257
  "Do not ask for anything the account can do without, such as a username or the password twice.",
@@ -7042,12 +8329,97 @@
7042
8329
  }
7043
8330
  ]
7044
8331
  },
8332
+ {
8333
+ "id": "signup-from-site",
8334
+ "title": "Sign-up from the site",
8335
+ "kind": "design",
8336
+ "level": "page",
8337
+ "area": "auth",
8338
+ "surface": [
8339
+ "site",
8340
+ "app"
8341
+ ],
8342
+ "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.",
8343
+ "do": [
8344
+ "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.",
8345
+ "Follow the case 'Sign-up page' in 'Centered column' for the fields, the errors and the loading Button.",
8346
+ "Open the 'Sign Up' tab, not 'Log In', when the visitor pressed 'Sign Up'.",
8347
+ "Carry the plan in the address, such as '/sign-up?plan=pro', and read it on the sign-up page.",
8348
+ "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.'",
8349
+ "Put a `Link` 'Change Plan' under that line. It goes back to the pricing section.",
8350
+ "Use the plan names and prices of the case 'Plan picker', word for word.",
8351
+ "Keep the plan when a submit fails, with the line and the fields as they were.",
8352
+ "Show the plan again on the first page after sign-up, so the person sees it was kept.",
8353
+ "Keep the plan in the 'Log In' tab's address too, for a visitor who already has an account.",
8354
+ "Show the plain sign-up for Free, and for a plan the app does not know.",
8355
+ "Carry the plan through a provider's sign-in, such as 'Continue with Google', too."
8356
+ ],
8357
+ "dont": [
8358
+ "Do not ask for a card before the account exists.",
8359
+ "Do not drop a picked plan without a word. Say it, or keep it.",
8360
+ "Do not send a 'Sign Up' Button to the login page.",
8361
+ "Do not show a plan line for a plan the app does not have."
8362
+ ],
8363
+ "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.",
8364
+ "options": [
8365
+ {
8366
+ "id": "plain",
8367
+ "title": "From Sign Up",
8368
+ "useWhen": "The visitor pressed 'Sign Up' on the site.",
8369
+ "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",
8370
+ "uses": [
8371
+ "Alert",
8372
+ "BrandIcon",
8373
+ "Button",
8374
+ "Center",
8375
+ "Form",
8376
+ "Heading",
8377
+ "Icon",
8378
+ "Image",
8379
+ "Line",
8380
+ "Paragraph",
8381
+ "Stack",
8382
+ "Tab",
8383
+ "TabsContainer",
8384
+ "TextField"
8385
+ ]
8386
+ },
8387
+ {
8388
+ "id": "with-plan",
8389
+ "title": "With a plan",
8390
+ "useWhen": "The visitor chose a paid plan on the site, such as 'Sign Up for Pro'.",
8391
+ "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",
8392
+ "uses": [
8393
+ "Alert",
8394
+ "BrandIcon",
8395
+ "Button",
8396
+ "Center",
8397
+ "Form",
8398
+ "Heading",
8399
+ "Icon",
8400
+ "Image",
8401
+ "Line",
8402
+ "Link",
8403
+ "Paragraph",
8404
+ "Stack",
8405
+ "Tab",
8406
+ "TabsContainer",
8407
+ "TextField",
8408
+ "formatMoney"
8409
+ ]
8410
+ }
8411
+ ]
8412
+ },
7045
8413
  {
7046
8414
  "id": "site-footer",
7047
8415
  "title": "Site footer",
7048
8416
  "kind": "design",
7049
8417
  "level": "organism",
7050
8418
  "area": "shell",
8419
+ "surface": [
8420
+ "site",
8421
+ "app"
8422
+ ],
7051
8423
  "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
8424
  "do": [
7053
8425
  "Use `SiteFooter` at the end of the page, after `PageShell`. It is a `<footer>` with a `<nav aria-label=\"Footer\">`.",
@@ -7101,6 +8473,10 @@
7101
8473
  "kind": "design",
7102
8474
  "level": "organism",
7103
8475
  "area": "shell",
8476
+ "surface": [
8477
+ "site",
8478
+ "app"
8479
+ ],
7104
8480
  "situation": "A site's pages name the site at the top and show the person where to go and what to do next.",
7105
8481
  "do": [
7106
8482
  "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 +8487,8 @@
7111
8487
  "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
8488
  "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
8489
  "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."
8490
+ "Open the theme menu as the case 'Theme switcher' says, and open search as the case 'Site search' says.",
8491
+ "Show a logged-in visitor one Button, 'Open App', in place of 'Log In' and 'Sign Up'."
7115
8492
  ],
7116
8493
  "dont": [
7117
8494
  "Do not show more than five links in the bar.",
@@ -7126,7 +8503,7 @@
7126
8503
  "id": "links",
7127
8504
  "title": "Links and one main action",
7128
8505
  "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",
8506
+ "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
8507
  "uses": [
7131
8508
  "Button",
7132
8509
  "Heading",
@@ -7158,12 +8535,43 @@
7158
8535
  }
7159
8536
  ]
7160
8537
  },
8538
+ {
8539
+ "id": "site-matches-app",
8540
+ "title": "A site promises only what the app does, in the app's words",
8541
+ "kind": "rule",
8542
+ "level": "rule",
8543
+ "area": "marketing",
8544
+ "surface": [
8545
+ "site",
8546
+ "app"
8547
+ ],
8548
+ "situation": "A product has a public site and an app. The site names the plans, shows the app and sends visitors into it.",
8549
+ "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.",
8550
+ "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.",
8551
+ "do": [
8552
+ "Take plan names, prices and limits from one source, so the site and the app cannot differ.",
8553
+ "Use the feature names the app uses, word for word.",
8554
+ "Send 'Sign Up' to the sign-up page.",
8555
+ "Carry a chosen plan into sign-up: 'Sign Up for Pro' opens sign-up with Pro chosen.",
8556
+ "Show a logged-in visitor 'Open App' in place of 'Sign Up'.",
8557
+ "Mark a demo of the app as an example, and show only what the app has."
8558
+ ],
8559
+ "dont": [
8560
+ "Do not list a feature a plan does not include.",
8561
+ "Do not show a control in a demo that the app does not have.",
8562
+ "Do not send a 'Sign Up' button to the login page."
8563
+ ],
8564
+ "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."
8565
+ },
7161
8566
  {
7162
8567
  "id": "site-search",
7163
8568
  "title": "Site search",
7164
8569
  "kind": "design",
7165
8570
  "level": "organism",
7166
8571
  "area": "content",
8572
+ "surface": [
8573
+ "site"
8574
+ ],
7167
8575
  "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
8576
  "do": [
7169
8577
  "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 +8619,10 @@
7211
8619
  "kind": "design",
7212
8620
  "level": "organism",
7213
8621
  "area": "chat",
8622
+ "surface": [
8623
+ "app",
8624
+ "agent"
8625
+ ],
7214
8626
  "situation": "A person types / at the start of the message box to run a command.",
7215
8627
  "do": [
7216
8628
  "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 +8673,9 @@
7261
8673
  "kind": "design",
7262
8674
  "level": "organism",
7263
8675
  "area": "dashboard",
8676
+ "surface": [
8677
+ "app"
8678
+ ],
7264
8679
  "situation": "A page opens with the few numbers that say how things are going, counted over one range.",
7265
8680
  "do": [
7266
8681
  "Follow the rule 'A number shows its unit and never shows 0 for unknown'. Use `StatTile`, which does.",
@@ -7320,6 +8735,9 @@
7320
8735
  "kind": "design",
7321
8736
  "level": "organism",
7322
8737
  "area": "dashboard",
8738
+ "surface": [
8739
+ "app"
8740
+ ],
7323
8741
  "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
8742
  "do": [
7325
8743
  "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 +8745,7 @@
7327
8745
  "Use `variant=\"dot\"` for a state that changes and may need the person: 'Past due', 'Canceling', 'Connected'.",
7328
8746
  "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
8747
  "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'.",
8748
+ "Write one word or two, in sentence case: 'Past due', 'Needs reconnect'.",
7331
8749
  "Put the Tag in a 'Status' column, or at the end of the row's text. It is not clickable."
7332
8750
  ],
7333
8751
  "dont": [
@@ -7383,6 +8801,10 @@
7383
8801
  "kind": "rule",
7384
8802
  "level": "rule",
7385
8803
  "area": "state",
8804
+ "surface": [
8805
+ "site",
8806
+ "app"
8807
+ ],
7386
8808
  "situation": "Something the person did has worked.",
7387
8809
  "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
8810
  "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 +8830,9 @@
7408
8830
  "kind": "design",
7409
8831
  "level": "organism",
7410
8832
  "area": "marketing",
8833
+ "surface": [
8834
+ "site"
8835
+ ],
7411
8836
  "situation": "A page shows several views of one thing, and a visitor reads one of them at a time.",
7412
8837
  "do": [
7413
8838
  "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 +8879,9 @@
7454
8879
  "kind": "design",
7455
8880
  "level": "organism",
7456
8881
  "area": "menu",
8882
+ "surface": [
8883
+ "app"
8884
+ ],
7457
8885
  "situation": "A person filters a list by a tag, and adds, renames and deletes the tags themselves.",
7458
8886
  "do": [
7459
8887
  "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 +8942,9 @@
7514
8942
  "kind": "design",
7515
8943
  "level": "organism",
7516
8944
  "area": "shell",
8945
+ "surface": [
8946
+ "app"
8947
+ ],
7517
8948
  "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
8949
  "do": [
7519
8950
  "Follow the case 'Page header with actions': `TitleBar` with the task's name as the one level 1 heading.",
@@ -7606,6 +9037,10 @@
7606
9037
  "kind": "design",
7607
9038
  "level": "organism",
7608
9039
  "area": "shell",
9040
+ "surface": [
9041
+ "site",
9042
+ "app"
9043
+ ],
7609
9044
  "situation": "A person chooses between a light page, a dark page, or the one their device uses.",
7610
9045
  "do": [
7611
9046
  "Offer three choices, in this order: 'Light', 'Dark' and 'System'. 'System' follows the device and is the default.",
@@ -7669,6 +9104,9 @@
7669
9104
  "kind": "design",
7670
9105
  "level": "organism",
7671
9106
  "area": "confirm",
9107
+ "surface": [
9108
+ "app"
9109
+ ],
7672
9110
  "situation": "A person asks to delete something large that cannot be brought back, such as a workspace or an account.",
7673
9111
  "do": [
7674
9112
  "Ask for typing only when the loss is permanent and large, such as a workspace with everything in it, or an account.",
@@ -7731,6 +9169,9 @@
7731
9169
  "kind": "design",
7732
9170
  "level": "organism",
7733
9171
  "area": "chat",
9172
+ "surface": [
9173
+ "app"
9174
+ ],
7734
9175
  "situation": "Other people in the thread are writing a message that has not arrived yet.",
7735
9176
  "do": [
7736
9177
  "Show one line just above the Composer, in small secondary text: `<Paragraph size=\"caption\" tone=\"secondary\">`.",
@@ -7772,6 +9213,9 @@
7772
9213
  "kind": "design",
7773
9214
  "level": "organism",
7774
9215
  "area": "confirm",
9216
+ "surface": [
9217
+ "app"
9218
+ ],
7775
9219
  "situation": "A person closes or leaves something they changed and did not save.",
7776
9220
  "do": [
7777
9221
  "Ask only when there are changes. With nothing changed, close at once.",
@@ -7830,6 +9274,9 @@
7830
9274
  "kind": "design",
7831
9275
  "level": "organism",
7832
9276
  "area": "confirm",
9277
+ "surface": [
9278
+ "app"
9279
+ ],
7833
9280
  "situation": "A person reaches something their plan does not include, or a limit of their plan.",
7834
9281
  "do": [
7835
9282
  "Say what is locked and which plan unlocks it: 'Exporting to PDF is part of the Pro plan.'",
@@ -7892,6 +9339,9 @@
7892
9339
  "kind": "design",
7893
9340
  "level": "organism",
7894
9341
  "area": "dashboard",
9342
+ "surface": [
9343
+ "app"
9344
+ ],
7895
9345
  "situation": "A plan limits some things, such as AI agent responses, members and storage. The admin checks how close the workspace is.",
7896
9346
  "do": [
7897
9347
  "Follow the rule 'A number shows its unit and never shows 0 for unknown'.",