oneslash-design-system 2.28.1 → 2.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (248) hide show
  1. package/README.md +1 -1
  2. package/dist/DESIGN.md +31 -1
  3. package/dist/cases/about-page.md +2 -0
  4. package/dist/cases/accept-invite.md +2 -0
  5. package/dist/cases/account-menu.md +2 -0
  6. package/dist/cases/activity-timeline.md +2 -0
  7. package/dist/cases/admin-inbox.md +2 -0
  8. package/dist/cases/agent-asks-before-risky-action.md +3 -1
  9. package/dist/cases/agent-cancels-when-unanswered.md +2 -0
  10. package/dist/cases/agent-changes-review/all-at-once.d.ts +1 -0
  11. package/dist/cases/agent-changes-review/all-at-once.jsx +238 -0
  12. package/dist/cases/agent-changes-review/per-change.d.ts +1 -0
  13. package/dist/cases/agent-changes-review/per-change.jsx +203 -0
  14. package/dist/cases/agent-changes-review.md +585 -0
  15. package/dist/cases/agent-handoff/to-agent.d.ts +1 -0
  16. package/dist/cases/agent-handoff/to-agent.jsx +53 -0
  17. package/dist/cases/agent-handoff/to-person.d.ts +1 -0
  18. package/dist/cases/agent-handoff/to-person.jsx +84 -0
  19. package/dist/cases/agent-handoff.md +231 -0
  20. package/dist/cases/agent-memory/list.d.ts +1 -0
  21. package/dist/cases/agent-memory/list.jsx +256 -0
  22. package/dist/cases/agent-memory.md +354 -0
  23. package/dist/cases/agent-options.md +2 -0
  24. package/dist/cases/agent-pending-reply/steps.jsx +70 -21
  25. package/dist/cases/agent-pending-reply.md +74 -27
  26. package/dist/cases/agent-permissions/levels.d.ts +3 -0
  27. package/dist/cases/agent-permissions/levels.jsx +51 -0
  28. package/dist/cases/agent-permissions/per-tool.d.ts +3 -0
  29. package/dist/cases/agent-permissions/per-tool.jsx +180 -0
  30. package/dist/cases/agent-permissions.md +319 -0
  31. package/dist/cases/agent-plan-proposal/changes.jsx +18 -11
  32. package/dist/cases/agent-plan-proposal/steps.jsx +11 -4
  33. package/dist/cases/agent-plan-proposal.md +36 -21
  34. package/dist/cases/agent-question.md +2 -0
  35. package/dist/cases/agent-refuses-clearly.md +2 -0
  36. package/dist/cases/agent-run-failure/limit-reached.d.ts +1 -0
  37. package/dist/cases/agent-run-failure/limit-reached.jsx +172 -0
  38. package/dist/cases/agent-run-failure/step-failed.d.ts +3 -0
  39. package/dist/cases/agent-run-failure/step-failed.jsx +187 -0
  40. package/dist/cases/agent-run-failure.md +500 -0
  41. package/dist/cases/agent-says-what-it-is.md +2 -0
  42. package/dist/cases/agent-says-where-it-stopped.md +27 -0
  43. package/dist/cases/agent-settings.md +2 -0
  44. package/dist/cases/agent-shows-progress.md +2 -0
  45. package/dist/cases/agent-shows-sources.md +2 -0
  46. package/dist/cases/api-keys.md +2 -0
  47. package/dist/cases/app-shell.md +2 -0
  48. package/dist/cases/artifact-card.md +2 -0
  49. package/dist/cases/ask-page.md +2 -0
  50. package/dist/cases/auth-gate-loading.md +2 -0
  51. package/dist/cases/billing-page.md +2 -0
  52. package/dist/cases/blog-index.md +2 -0
  53. package/dist/cases/breadcrumb.md +2 -0
  54. package/dist/cases/breakdown-list.md +2 -0
  55. package/dist/cases/bulk-actions/list.d.ts +1 -0
  56. package/dist/cases/bulk-actions/list.jsx +206 -0
  57. package/dist/cases/bulk-actions/paged-table.d.ts +1 -0
  58. package/dist/cases/bulk-actions/paged-table.jsx +243 -0
  59. package/dist/cases/bulk-actions.md +553 -0
  60. package/dist/cases/changelog.md +2 -0
  61. package/dist/cases/chart.md +2 -0
  62. package/dist/cases/check-your-email.md +2 -0
  63. package/dist/cases/code-sample.md +2 -0
  64. package/dist/cases/collapsible-search.md +2 -0
  65. package/dist/cases/comment-thread.md +2 -0
  66. package/dist/cases/comparison-page/table.d.ts +1 -0
  67. package/dist/cases/comparison-page/table.jsx +97 -0
  68. package/dist/cases/comparison-page.md +156 -0
  69. package/dist/cases/composer-limit.md +2 -0
  70. package/dist/cases/confirm-destructive-action.md +2 -0
  71. package/dist/cases/confirm-dialogs.md +2 -0
  72. package/dist/cases/connection-status/card.d.ts +1 -0
  73. package/dist/cases/connection-status/card.jsx +97 -0
  74. package/dist/cases/connection-status/row.d.ts +1 -0
  75. package/dist/cases/connection-status/row.jsx +120 -0
  76. package/dist/cases/connection-status.md +330 -0
  77. package/dist/cases/contact-page.md +2 -0
  78. package/dist/cases/conversation-starters.md +2 -0
  79. package/dist/cases/cookie-choice.md +2 -0
  80. package/dist/cases/create-modal.md +2 -0
  81. package/dist/cases/danger-zone.md +2 -0
  82. package/dist/cases/dashboard.md +2 -0
  83. package/dist/cases/data-table-page.md +2 -0
  84. package/dist/cases/date-field.md +2 -0
  85. package/dist/cases/device-login.md +2 -0
  86. package/dist/cases/docs-component-page.md +2 -0
  87. package/dist/cases/email-confirmed.md +2 -0
  88. package/dist/cases/empty-list.md +2 -0
  89. package/dist/cases/empty-lists.md +2 -0
  90. package/dist/cases/empty-not-set-up.md +2 -0
  91. package/dist/cases/empty-search.md +2 -0
  92. package/dist/cases/error-page.md +2 -0
  93. package/dist/cases/faq.md +2 -0
  94. package/dist/cases/feature-grid.md +2 -0
  95. package/dist/cases/feedback-form.md +2 -0
  96. package/dist/cases/file-upload.md +2 -0
  97. package/dist/cases/filter-menu.md +2 -0
  98. package/dist/cases/forgot-password.md +2 -0
  99. package/dist/cases/form-errors.md +2 -0
  100. package/dist/cases/image-viewer.md +2 -0
  101. package/dist/cases/import-checklist.md +2 -0
  102. package/dist/cases/inline-form-feedback.md +2 -0
  103. package/dist/cases/integrations-list/nested.jsx +1 -1
  104. package/dist/cases/integrations-list/rows.jsx +1 -1
  105. package/dist/cases/integrations-list.md +6 -4
  106. package/dist/cases/invite-member.md +2 -0
  107. package/dist/cases/invoice-list.md +2 -0
  108. package/dist/cases/landing-hero.md +2 -0
  109. package/dist/cases/leaderboard.md +2 -0
  110. package/dist/cases/legal-page.md +2 -0
  111. package/dist/cases/load-failure.md +2 -0
  112. package/dist/cases/log-out-confirm.md +2 -0
  113. package/dist/cases/login-page.md +2 -0
  114. package/dist/cases/long-form-page.md +2 -0
  115. package/dist/cases/master-detail.md +2 -0
  116. package/dist/cases/members-list.md +2 -0
  117. package/dist/cases/mention-list.md +2 -0
  118. package/dist/cases/message-actions.md +2 -0
  119. package/dist/cases/message-attachments.md +2 -0
  120. package/dist/cases/message-composer/with-tools.jsx +17 -7
  121. package/dist/cases/message-composer.md +28 -11
  122. package/dist/cases/message-edit.md +2 -0
  123. package/dist/cases/message-reactions.md +2 -0
  124. package/dist/cases/message-row.md +2 -0
  125. package/dist/cases/message-send-failure/needs-a-person.d.ts +1 -0
  126. package/dist/cases/message-send-failure/needs-a-person.jsx +116 -0
  127. package/dist/cases/message-send-failure/retrying.d.ts +1 -0
  128. package/dist/cases/message-send-failure/retrying.jsx +116 -0
  129. package/dist/cases/message-send-failure.md +308 -0
  130. package/dist/cases/mobile-menu.md +2 -0
  131. package/dist/cases/newsletter-signup.md +2 -0
  132. package/dist/cases/no-access/page.d.ts +1 -0
  133. package/dist/cases/no-access/page.jsx +37 -0
  134. package/dist/cases/no-access/read-only.d.ts +1 -0
  135. package/dist/cases/no-access/read-only.jsx +33 -0
  136. package/dist/cases/no-access.md +147 -0
  137. package/dist/cases/not-found-page.md +2 -0
  138. package/dist/cases/notification-menu.md +2 -0
  139. package/dist/cases/number-format.md +2 -0
  140. package/dist/cases/oauth-consent.md +2 -0
  141. package/dist/cases/on-off-settings.md +2 -0
  142. package/dist/cases/on-this-page.md +2 -0
  143. package/dist/cases/onboarding.md +2 -0
  144. package/dist/cases/one-main-action.md +2 -0
  145. package/dist/cases/overflow-menu.md +2 -0
  146. package/dist/cases/page-end.md +2 -0
  147. package/dist/cases/page-header.md +2 -0
  148. package/dist/cases/paged-card.md +2 -0
  149. package/dist/cases/password-gate.md +2 -0
  150. package/dist/cases/payment-method.md +2 -0
  151. package/dist/cases/people-row.md +2 -0
  152. package/dist/cases/phone-navigation.md +2 -0
  153. package/dist/cases/plan-change-confirm.md +2 -0
  154. package/dist/cases/plan-comparison.md +3 -1
  155. package/dist/cases/plan-picker.md +4 -1
  156. package/dist/cases/plan-sign-off.md +2 -0
  157. package/dist/cases/pricing-section.md +5 -1
  158. package/dist/cases/product-cards.md +2 -0
  159. package/dist/cases/product-demo/scripted.d.ts +1 -0
  160. package/dist/cases/product-demo/scripted.jsx +99 -0
  161. package/dist/cases/product-demo/still.d.ts +1 -0
  162. package/dist/cases/product-demo/still.jsx +20 -0
  163. package/dist/cases/product-demo.md +226 -0
  164. package/dist/cases/profile-form.md +2 -0
  165. package/dist/cases/quick-switcher.md +2 -0
  166. package/dist/cases/range-switch.md +2 -0
  167. package/dist/cases/rename.md +2 -0
  168. package/dist/cases/reply-feedback.md +2 -0
  169. package/dist/cases/reply-sources.md +2 -0
  170. package/dist/cases/route-loading.md +2 -0
  171. package/dist/cases/scope-picker.md +2 -0
  172. package/dist/cases/section-index.md +2 -0
  173. package/dist/cases/session-expired/in-place.d.ts +1 -0
  174. package/dist/cases/session-expired/in-place.jsx +63 -0
  175. package/dist/cases/session-expired/redirect.d.ts +1 -0
  176. package/dist/cases/session-expired/redirect.jsx +62 -0
  177. package/dist/cases/session-expired.md +204 -0
  178. package/dist/cases/set-new-password.md +2 -0
  179. package/dist/cases/settings-page.md +2 -0
  180. package/dist/cases/settings-save.md +2 -0
  181. package/dist/cases/side-pane.md +2 -0
  182. package/dist/cases/sidebar-nav.md +2 -0
  183. package/dist/cases/sign-up-page.md +3 -0
  184. package/dist/cases/signup-from-site/plain.d.ts +1 -0
  185. package/dist/cases/signup-from-site/plain.jsx +125 -0
  186. package/dist/cases/signup-from-site/with-plan.d.ts +4 -0
  187. package/dist/cases/signup-from-site/with-plan.jsx +151 -0
  188. package/dist/cases/signup-from-site.md +351 -0
  189. package/dist/cases/site-footer.md +2 -0
  190. package/dist/cases/site-header/links.d.ts +3 -1
  191. package/dist/cases/site-header/links.jsx +6 -2
  192. package/dist/cases/site-header.md +11 -3
  193. package/dist/cases/site-matches-app.md +32 -0
  194. package/dist/cases/site-search.md +2 -0
  195. package/dist/cases/slash-command-list.md +2 -0
  196. package/dist/cases/stat-row.md +2 -0
  197. package/dist/cases/status-label.md +3 -1
  198. package/dist/cases/success-feedback.md +2 -0
  199. package/dist/cases/tabbed-panels.md +2 -0
  200. package/dist/cases/tag-filter.md +2 -0
  201. package/dist/cases/task-header.md +2 -0
  202. package/dist/cases/theme-switcher.md +2 -0
  203. package/dist/cases/type-to-confirm.md +2 -0
  204. package/dist/cases/typing-and-status.md +2 -0
  205. package/dist/cases/unsaved-changes-guard.md +2 -0
  206. package/dist/cases/upgrade-prompt.md +2 -0
  207. package/dist/cases/usage-meters.md +2 -0
  208. package/dist/cases.json +1492 -39
  209. package/dist/components/checkBox.d.ts +7 -2
  210. package/dist/components/checkBox.jsx +39 -14
  211. package/dist/components/diff.d.ts +32 -0
  212. package/dist/components/diff.jsx +42 -0
  213. package/dist/components/segmentedControl.d.ts +3 -1
  214. package/dist/components/segmentedControl.jsx +8 -6
  215. package/dist/components/slidingIndicator.d.ts +5 -2
  216. package/dist/components/slidingIndicator.jsx +9 -3
  217. package/dist/components/tableContainer.d.ts +1 -1
  218. package/dist/components/tableContainer.jsx +2 -2
  219. package/dist/components/timeStamp.d.ts +3 -1
  220. package/dist/components/timeStamp.jsx +4 -2
  221. package/dist/components/useReducedMotion.d.ts +6 -0
  222. package/dist/components/useReducedMotion.js +19 -0
  223. package/dist/index.d.ts +2 -0
  224. package/dist/index.js +2 -0
  225. package/dist/internal/diff.d.ts +17 -0
  226. package/dist/internal/diff.js +44 -0
  227. package/dist/native-mapping.json +9 -2
  228. package/dist/stories/AgentPermissions.probe.stories.d.ts +7 -0
  229. package/dist/stories/AgentPermissions.probe.stories.jsx +18 -0
  230. package/dist/stories/AgentRunFailure.probe.stories.d.ts +6 -0
  231. package/dist/stories/AgentRunFailure.probe.stories.jsx +12 -0
  232. package/dist/stories/Cases.generated.stories.d.ts +24 -0
  233. package/dist/stories/Cases.generated.stories.jsx +48 -0
  234. package/dist/stories/Checkbox.stories.d.ts +3 -0
  235. package/dist/stories/Checkbox.stories.jsx +38 -0
  236. package/dist/stories/Diff.stories.d.ts +10 -0
  237. package/dist/stories/Diff.stories.jsx +45 -0
  238. package/dist/stories/SegmentedControl.stories.d.ts +1 -0
  239. package/dist/stories/SegmentedControl.stories.jsx +6 -0
  240. package/dist/stories/SignupFromSite.probe.stories.d.ts +7 -0
  241. package/dist/stories/SignupFromSite.probe.stories.jsx +17 -0
  242. package/dist/stories/SiteHeader.probe.stories.d.ts +6 -0
  243. package/dist/stories/SiteHeader.probe.stories.jsx +13 -0
  244. package/dist/stories/Table.stories.d.ts +1 -0
  245. package/dist/stories/Table.stories.jsx +25 -0
  246. package/dist/stories/TimeStamp.stories.d.ts +1 -0
  247. package/dist/stories/TimeStamp.stories.jsx +13 -0
  248. package/package.json +5 -1
@@ -0,0 +1,354 @@
1
+ # Agent memory
2
+
3
+ A person wants to see what the agent remembers about them or the workspace, and to correct it or have it forgotten.
4
+
5
+ For: an app, an agent
6
+
7
+ ## Do
8
+
9
+ - Put the memories in a `SettingsSection` titled 'What Acme Agent remembers', with a search field above them.
10
+ - 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.
11
+ - Link where a memory came from to that place: 'From a chat on Nov 12, 2026'.
12
+ - Say who can see each memory: 'Only you can see this.' or 'Everyone in Acme can see this.'
13
+ - Give each row a More menu with 'Edit' and 'Forget', as the case 'More menu' does. Name the More button for its memory.
14
+ - 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.
15
+ - 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'.
16
+ - 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.
17
+ - 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.
18
+ - 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'.
19
+
20
+ ## Don't
21
+
22
+ - Do not show only a count of memories. Show each one.
23
+ - Do not forget a memory on the first press.
24
+ - Do not hide who else can see a memory.
25
+ - Do not put 'Forget Everything' above the list.
26
+
27
+ ## Example: List of memories
28
+
29
+ Uses: `Button`, `Center`, `Cluster`, `EmptyBox`, `Heading`, `IconButton`, `Line`, `Link`, `Menu`, `MenuItem`, `Paragraph`, `Popover`, `SettingsSection`, `Stack`, `TableCell`, `TableContainer`, `TableRow`, `TextField`, `Toaster`, `Tooltip`, `dismissToast`, `toast`
30
+
31
+ ```tsx
32
+ 'use client';
33
+ import { useEffect, useRef, useState } from 'react';
34
+ import Toaster, { toast, dismissToast } from 'oneslash-design-system/components/toaster';
35
+ import Heading from 'oneslash-design-system/components/heading';
36
+ import Paragraph from 'oneslash-design-system/components/paragraph';
37
+ import Link from 'oneslash-design-system/components/link';
38
+ import Button from 'oneslash-design-system/components/button';
39
+ import IconButton from 'oneslash-design-system/components/iconButton';
40
+ import Tooltip from 'oneslash-design-system/components/tooltip';
41
+ import Popover from 'oneslash-design-system/components/popover';
42
+ import Menu from 'oneslash-design-system/components/menu';
43
+ import MenuItem from 'oneslash-design-system/components/menuItem';
44
+ import Line from 'oneslash-design-system/components/line';
45
+ import TextField from 'oneslash-design-system/components/textField';
46
+ import EmptyBox from 'oneslash-design-system/components/emptyBox';
47
+ import SettingsSection from 'oneslash-design-system/components/settingsSection';
48
+ import TableContainer from 'oneslash-design-system/components/tableContainer';
49
+ import TableRow from 'oneslash-design-system/components/tableRow';
50
+ import TableCell from 'oneslash-design-system/components/tableCell';
51
+ import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
52
+
53
+ type Focusable = HTMLButtonElement | HTMLAnchorElement | null;
54
+
55
+ type Memory = {
56
+ id: string;
57
+ text: string;
58
+ /** Where the agent learned it, with a link to that place. */
59
+ from: string;
60
+ href: string;
61
+ /** Who else can see it. */
62
+ seenBy: 'you' | 'everyone';
63
+ };
64
+
65
+ // A real app reads these from the server.
66
+ const firstMemories: Memory[] = [
67
+ { 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' },
68
+ { 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' },
69
+ { 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' },
70
+ { 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' },
71
+ ];
72
+
73
+ const seenByLine = { you: 'Only you can see this.', everyone: 'Everyone in Acme can see this.' };
74
+
75
+ export default function AgentMemoryList() {
76
+ const [memories, setMemories] = useState(firstMemories);
77
+ const [query, setQuery] = useState('');
78
+ // The row whose menu is open, and the More button it opens from. Both stay set while the menu fades out.
79
+ const [menuRow, setMenuRow] = useState<Memory | null>(null);
80
+ const [menuAnchor, setMenuAnchor] = useState<HTMLElement | null>(null);
81
+ const [menuOpen, setMenuOpen] = useState(false);
82
+ // One row at a time asks to confirm 'Forget', or is being edited.
83
+ const [confirmingId, setConfirmingId] = useState<string | null>(null);
84
+ const [editingId, setEditingId] = useState<string | null>(null);
85
+ const [draft, setDraft] = useState('');
86
+ const [pending, setPending] = useState<'forget' | 'save' | 'forget-all' | null>(null);
87
+ const [confirmingAll, setConfirmingAll] = useState(false);
88
+ const timer = useRef<ReturnType<typeof setTimeout>>();
89
+ const toastIds = useRef<string[]>([]);
90
+ const searchField = useRef<HTMLInputElement | HTMLTextAreaElement>(null);
91
+ const cancelForget = useRef<Focusable>(null);
92
+ const editField = useRef<HTMLInputElement | HTMLTextAreaElement>(null);
93
+ const forgetAllButton = useRef<Focusable>(null);
94
+ const cancelForgetAll = useRef<Focusable>(null);
95
+ // Each row's More button by memory id, so focus can move to one when the thing that had it is gone.
96
+ const moreButtons = useRef<Record<string, Focusable>>({});
97
+ // Where focus goes after the next render, once the element it goes to is on screen.
98
+ const focusNext = useRef<() => void>();
99
+
100
+ // On unmount it stops the request and closes every toast it opened.
101
+ useEffect(() => () => {
102
+ clearTimeout(timer.current);
103
+ toastIds.current.forEach((id) => dismissToast(id));
104
+ toastIds.current = [];
105
+ }, []);
106
+
107
+ useEffect(() => {
108
+ const move = focusNext.current;
109
+ focusNext.current = undefined;
110
+ move?.();
111
+ });
112
+
113
+ const words = query.trim().toLowerCase();
114
+ const shown = words === '' ? memories : memories.filter((m) => m.text.toLowerCase().includes(words));
115
+
116
+ function openMenu(m: Memory, anchor: HTMLElement) {
117
+ if (menuOpen && menuRow?.id === m.id) {
118
+ setMenuOpen(false);
119
+ return;
120
+ }
121
+ setMenuRow(m);
122
+ setMenuAnchor(anchor);
123
+ setMenuOpen(true);
124
+ }
125
+
126
+ // Every item closes the menu, and Escape and a click outside do too. The Popover gives focus back to More.
127
+ function choose(action: (m: Memory) => void) {
128
+ if (!menuRow) return;
129
+ const m = menuRow;
130
+ setMenuOpen(false);
131
+ action(m);
132
+ }
133
+
134
+ // The row turns into a field, with focus in it.
135
+ function startEdit(m: Memory) {
136
+ setConfirmingId(null);
137
+ setDraft(m.text);
138
+ setEditingId(m.id);
139
+ focusNext.current = () => editField.current?.focus();
140
+ }
141
+
142
+ // 'Cancel' and 'Save' go away with the field, so focus goes back to the row's More button.
143
+ function cancelEdit() {
144
+ if (pending || !editingId) return;
145
+ const id = editingId;
146
+ setEditingId(null);
147
+ focusNext.current = () => moreButtons.current[id]?.focus();
148
+ }
149
+
150
+ function saveEdit() {
151
+ if (pending || !editingId || draft.trim() === '') return;
152
+ const id = editingId;
153
+ const text = draft.trim();
154
+ setPending('save');
155
+ // Stands in for the request to the server.
156
+ timer.current = setTimeout(() => {
157
+ setPending(null);
158
+ setMemories((list) => list.map((m) => (m.id === id ? { ...m, text } : m)));
159
+ setEditingId(null);
160
+ // The row's More button, or the search field when the saved memory no longer matches the search.
161
+ focusNext.current = () => (moreButtons.current[id] ?? searchField.current)?.focus();
162
+ }, 1200);
163
+ }
164
+
165
+ // The confirm opens in the row, with focus on 'Cancel'.
166
+ function askToForget(m: Memory) {
167
+ setEditingId(null);
168
+ setConfirmingId(m.id);
169
+ focusNext.current = () => cancelForget.current?.focus();
170
+ }
171
+
172
+ // 'Cancel' goes away with the confirm, so focus goes back to the row's More button.
173
+ function keepMemory() {
174
+ if (pending || !confirmingId) return;
175
+ const id = confirmingId;
176
+ setConfirmingId(null);
177
+ focusNext.current = () => moreButtons.current[id]?.focus();
178
+ }
179
+
180
+ function confirmForget() {
181
+ if (pending || !confirmingId) return;
182
+ const id = confirmingId;
183
+ const at = shown.findIndex((m) => m.id === id);
184
+ const neighbor = shown[at + 1] ?? shown[at - 1];
185
+ setPending('forget');
186
+ // Stands in for the request to the server.
187
+ timer.current = setTimeout(() => {
188
+ setPending(null);
189
+ setConfirmingId(null);
190
+ setMemories((list) => list.filter((m) => m.id !== id));
191
+ toastIds.current.push(toast({ type: 'success', message: 'Memory forgotten.' }));
192
+ // The row is gone: focus goes to the next row's More button, or the one before it when it was the last.
193
+ // With no row left, it goes to the search field.
194
+ focusNext.current = () => (neighbor ? moreButtons.current[neighbor.id] : searchField.current)?.focus();
195
+ }, 1200);
196
+ }
197
+
198
+ // The danger zone's confirm opens in place, with focus on 'Cancel'.
199
+ function askToForgetAll() {
200
+ setConfirmingAll(true);
201
+ focusNext.current = () => cancelForgetAll.current?.focus();
202
+ }
203
+
204
+ function keepAll() {
205
+ if (pending) return;
206
+ setConfirmingAll(false);
207
+ focusNext.current = () => forgetAllButton.current?.focus();
208
+ }
209
+
210
+ // Every row and the danger zone go away, so focus goes to the search field.
211
+ function forgetAll() {
212
+ if (pending) return;
213
+ setPending('forget-all');
214
+ // Stands in for the request to the server.
215
+ timer.current = setTimeout(() => {
216
+ setPending(null);
217
+ setConfirmingAll(false);
218
+ setConfirmingId(null);
219
+ setEditingId(null);
220
+ setMemories([]);
221
+ setQuery('');
222
+ toastIds.current.push(toast({ type: 'success', message: 'Acme Agent forgot every memory.' }));
223
+ focusNext.current = () => searchField.current?.focus();
224
+ }, 1200);
225
+ }
226
+
227
+ function clearSearch() {
228
+ setQuery('');
229
+ searchField.current?.focus();
230
+ }
231
+
232
+ return (
233
+ <Center width="page">
234
+ {/* A real app mounts one Toaster near its root. */}
235
+ <Toaster />
236
+ <Stack gap="xlarge">
237
+ <Stack gap="small">
238
+ <Heading level={1} size="h5">Memory</Heading>
239
+ <Paragraph tone="secondary" size="body2" measure="none">What Acme Agent has learned from your chats. It uses this to answer you.</Paragraph>
240
+ </Stack>
241
+
242
+ <SettingsSection title="What Acme Agent remembers" description="Each memory says where it came from and who else can see it.">
243
+ <TextField ref={searchField} id="agent-memory-list-search" type="search" label="Search memories" value={query} autoComplete="off" onChange={(e) => setQuery(e.target.value)} />
244
+ {shown.length > 0 ? (
245
+ <TableContainer>
246
+ {shown.map((m) => {
247
+ const confirming = m.id === confirmingId;
248
+ const editing = m.id === editingId;
249
+ return (
250
+ <TableRow key={m.id}>
251
+ <TableCell>
252
+ {editing ? (
253
+ <TextField
254
+ ref={editField}
255
+ id={`agent-memory-list-edit-${m.id}`}
256
+ label="Memory"
257
+ value={draft}
258
+ disabled={pending === 'save'}
259
+ error={draft.trim() === ''}
260
+ errorText={draft.trim() === '' ? 'Write the memory, or use Forget to remove it.' : undefined}
261
+ onChange={(e) => setDraft(e.target.value)}
262
+ />
263
+ ) : (
264
+ <Stack gap="small">
265
+ {m.text}
266
+ {confirming ? (
267
+ <Paragraph size="body2" tone="secondary" measure="none">Forget this memory? Acme Agent stops using it.</Paragraph>
268
+ ) : (
269
+ <Cluster gap="small">
270
+ <Link href={m.href} size="caption">{m.from}</Link>
271
+ <Paragraph size="caption" tone="secondary" measure="none">{seenByLine[m.seenBy]}</Paragraph>
272
+ </Cluster>
273
+ )}
274
+ </Stack>
275
+ )}
276
+ </TableCell>
277
+ {/* A fixed last column keeps every row's Buttons in one place, so they do not jump when they change. */}
278
+ <TableCell width="168px" align="right">
279
+ {confirming ? (
280
+ <Cluster gap="small" justify="end">
281
+ <Button ref={cancelForget} size="small" type="tertiary" state={pending === 'forget' ? 'disabled' : 'enabled'} label="Cancel" aria-label={`Cancel forgetting ${m.text}`} onClickButton={keepMemory} />
282
+ <Button size="small" type="primary" color="danger" state="enabled" label="Forget" aria-label={`Forget ${m.text}`} loading={pending === 'forget'} onClickButton={confirmForget} />
283
+ </Cluster>
284
+ ) : editing ? (
285
+ <Cluster gap="small" justify="end">
286
+ <Button size="small" type="tertiary" state={pending === 'save' ? 'disabled' : 'enabled'} label="Cancel" aria-label="Cancel editing the memory" onClickButton={cancelEdit} />
287
+ <Button size="small" type="primary" state={draft.trim() === '' ? 'disabled' : 'enabled'} label="Save" aria-label="Save the memory" loading={pending === 'save'} onClickButton={saveEdit} />
288
+ </Cluster>
289
+ ) : (
290
+ <Cluster justify="end">
291
+ <Tooltip title="More">
292
+ <IconButton
293
+ ref={(el) => { moreButtons.current[m.id] = el; }}
294
+ color="iconOnly"
295
+ state={menuOpen && menuRow?.id === m.id ? 'selected' : 'enabled'}
296
+ size="small"
297
+ iconName="Ellipsis"
298
+ ariaLabel={`More actions for ${m.text}`}
299
+ aria-haspopup="menu"
300
+ aria-expanded={menuOpen && menuRow?.id === m.id}
301
+ onClick={(e: { currentTarget: HTMLElement }) => openMenu(m, e.currentTarget)}
302
+ />
303
+ </Tooltip>
304
+ </Cluster>
305
+ )}
306
+ </TableCell>
307
+ </TableRow>
308
+ );
309
+ })}
310
+ </TableContainer>
311
+ ) : memories.length > 0 ? (
312
+ <EmptyBox
313
+ size="small"
314
+ icon="Search"
315
+ text={`No memories match "${query.trim()}"`}
316
+ secondText="Try other words, or clear the search."
317
+ action={<Button size="small" type="secondary" state="enabled" label="Clear Search" onClickButton={clearSearch} />}
318
+ />
319
+ ) : (
320
+ <EmptyBox size="small" icon="Brain" text="No memories" secondText="What Acme Agent learns in your chats appears here." />
321
+ )}
322
+ </SettingsSection>
323
+
324
+ {memories.length > 0 && (
325
+ <SettingsSection tone="danger" title="Forget everything" description="This cannot be undone.">
326
+ <Paragraph size="body2" measure="none">Acme Agent forgets every memory listed here. Your chats and files stay.</Paragraph>
327
+ {confirmingAll ? (
328
+ <>
329
+ <Paragraph size="body2" measure="none">Forget all {memories.length} memories?</Paragraph>
330
+ <Cluster gap="small">
331
+ <Button ref={cancelForgetAll} size="small" type="tertiary" state={pending === 'forget-all' ? 'disabled' : 'enabled'} label="Cancel" aria-label="Cancel forgetting everything" onClickButton={keepAll} />
332
+ <Button size="small" type="primary" color="danger" state="enabled" label="Forget Everything" loading={pending === 'forget-all'} onClickButton={forgetAll} />
333
+ </Cluster>
334
+ </>
335
+ ) : (
336
+ <Cluster>
337
+ <Button ref={forgetAllButton} size="small" type="secondary" color="danger" state="enabled" label="Forget Everything" onClickButton={askToForgetAll} />
338
+ </Cluster>
339
+ )}
340
+ </SettingsSection>
341
+ )}
342
+ </Stack>
343
+ <Popover open={menuOpen} anchorEl={menuAnchor} onClose={() => setMenuOpen(false)} returnFocus>
344
+ <Menu navigable aria-label={menuRow ? `Actions for ${menuRow.text}` : 'Memory actions'} width={200}>
345
+ <MenuItem size="small" iconName="Pencil" label="Edit" onClick={() => choose(startEdit)} />
346
+ <Line />
347
+ {/* Forget is last, and danger. */}
348
+ <MenuItem size="small" color="danger" iconName="Trash2" label="Forget" onClick={() => choose(askToForget)} />
349
+ </Menu>
350
+ </Popover>
351
+ </Center>
352
+ );
353
+ }
354
+ ```
@@ -2,6 +2,8 @@
2
2
 
3
3
  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'.
4
4
 
5
+ For: an agent
6
+
5
7
  ## Do
6
8
 
7
9
  - Put the card in the agent's `Message`, in a `Surface` with the question as its heading.
@@ -8,7 +8,6 @@ import TimeStamp from '../../components/timeStamp';
8
8
  import Heading from '../../components/heading';
9
9
  import Paragraph from '../../components/paragraph';
10
10
  import Button from '../../components/button';
11
- import Alert from '../../components/alert';
12
11
  import StepList from '../../components/stepList';
13
12
  import { Center, Cluster, Stack } from '../../components/layout';
14
13
  var agentName = 'Acme Agent';
@@ -22,10 +21,23 @@ var plan = [
22
21
  { doing: 'Comparing the prices', done: 'Compared the prices' },
23
22
  ];
24
23
  var reply = "The pricing page still shows last year's prices. Pro is $12 there, and the new plans set it at $15.";
25
- // Finished steps keep a check, the current one runs, and steps the agent has not started are not shown.
26
- function stepsUpTo(current, failed) {
27
- return plan.slice(0, current + 1).map(function (s, i) {
28
- return i < current ? { label: s.done, status: 'done' } : { label: s.doing, status: failed ? 'failed' : 'running' };
24
+ // Why the step failed. A real app takes it from the server's answer.
25
+ var failReason = 'Could not open the pricing page. It did not answer in time.';
26
+ // Finished steps keep a check, the current one runs, and while it runs the steps the agent has not started are not shown.
27
+ // A failed step says why, as the case 'Run that stopped short' does, and the steps after it wait. Once the run is
28
+ // stopped, the step it stopped on stays failed after 'Stop Here' and is cancelled after 'Stop', and the steps after it are cancelled.
29
+ function stepsUpTo(current, phase, endedOnFailure) {
30
+ var shown = phase === 'failed' || phase === 'stopped' ? plan : plan.slice(0, current + 1);
31
+ return shown.map(function (s, i) {
32
+ if (i < current)
33
+ return { label: s.done, status: 'done' };
34
+ if (i > current)
35
+ return { label: s.doing, status: phase === 'stopped' ? 'cancelled' : 'waiting' };
36
+ if (phase === 'failed')
37
+ return { label: s.doing, status: 'failed', detail: failReason };
38
+ if (phase === 'stopped')
39
+ return { label: s.doing, status: endedOnFailure ? 'failed' : 'cancelled' };
40
+ return { label: s.doing, status: 'running' };
29
41
  });
30
42
  }
31
43
  function secondsLine(seconds) {
@@ -50,9 +62,13 @@ export default function AgentPendingReplySteps() {
50
62
  var step = useRef();
51
63
  var cancel = useRef();
52
64
  var runAgainButton = useRef(null);
65
+ var stopHereButton = useRef(null);
66
+ var stopButton = useRef(null);
67
+ // Whether the run ended on the failed step ('Stop Here') or was stopped while a step ran ('Stop').
68
+ var _e = useState(false), endedOnFailure = _e[0], setEndedOnFailure = _e[1];
53
69
  // Where focus goes after the next render, once the element it goes to is on screen.
54
70
  var focusNext = useRef();
55
- // The first live run fails at the pricing page, so the example shows the failed row; 'Try Again' then works.
71
+ // The first live run fails at the pricing page, so the example shows the failed row; 'Try Step Again' then works.
56
72
  var triedAgain = useRef(false);
57
73
  // On unmount it stops the run, its clock and the cancel request.
58
74
  useEffect(function () { return function () {
@@ -75,6 +91,8 @@ export default function AgentPendingReplySteps() {
75
91
  if (at === 2 && !triedAgain.current) {
76
92
  stopTimers();
77
93
  setPhase('failed');
94
+ // 'Stop' had focus and is gone, so focus goes to the row's first Button.
95
+ focusNext.current = function () { var _a; return (_a = stopHereButton.current) === null || _a === void 0 ? void 0 : _a.focus(); };
78
96
  return;
79
97
  }
80
98
  if (at === plan.length - 1) {
@@ -86,18 +104,35 @@ export default function AgentPendingReplySteps() {
86
104
  advance(at + 1);
87
105
  }, 1500);
88
106
  }
89
- function runLive() {
107
+ // Runs from `from` on. The steps before it are done and stay done.
108
+ function runFrom(from) {
90
109
  stopTimers();
91
110
  setPhase('running');
92
- setCurrent(0);
111
+ setEndedOnFailure(false);
112
+ setCurrent(from);
93
113
  setSeconds(0);
94
114
  setStartedAt(new Date());
95
115
  tick.current = setInterval(function () { return setSeconds(function (s) { return s + 1; }); }, 1000);
96
- advance(0);
116
+ advance(from);
117
+ }
118
+ function runLive() {
119
+ runFrom(0);
97
120
  }
98
- function tryAgain() {
121
+ // Only the failed step and the ones after it run again. 'Stop' takes the place of the Buttons, so it gets focus.
122
+ function tryStepAgain() {
123
+ if (phase !== 'failed')
124
+ return;
99
125
  triedAgain.current = true;
100
- runLive();
126
+ runFrom(current);
127
+ focusNext.current = function () { var _a; return (_a = stopButton.current) === null || _a === void 0 ? void 0 : _a.focus(); };
128
+ }
129
+ // The run ends on the failed step. 'Run Again' takes the place of the Buttons; in a real app, the message box.
130
+ function stopHere() {
131
+ if (phase !== 'failed')
132
+ return;
133
+ setEndedOnFailure(true);
134
+ setPhase('stopped');
135
+ focusNext.current = function () { var _a; return (_a = runAgainButton.current) === null || _a === void 0 ? void 0 : _a.focus(); };
101
136
  }
102
137
  // Stop asks the server to end the run. The row says it stopped only once the run has ended.
103
138
  function stop() {
@@ -114,6 +149,14 @@ export default function AgentPendingReplySteps() {
114
149
  }, 1200);
115
150
  }
116
151
  var working = phase === 'running' || phase === 'stopping';
152
+ // What was done, under the list. Empty while the run goes on. A real app takes the count from the server's answer.
153
+ var statusLine = phase === 'failed'
154
+ ? "".concat(current, " of ").concat(plan.length, " steps are done. Nothing was changed.")
155
+ : phase === 'stopped'
156
+ ? current === 0
157
+ ? 'Stopped. Nothing was changed.'
158
+ : "Stopped after ".concat(current, " of ").concat(plan.length, " steps. The rest of the plan was not done. Nothing was changed.")
159
+ : '';
117
160
  return (<Center width="page">
118
161
  <Stack gap="large">
119
162
  <Heading level={1} size="h5">Launch plan</Heading>
@@ -125,22 +168,28 @@ export default function AgentPendingReplySteps() {
125
168
  <Message aria-label={"".concat(agentName, ", agent")} avatar={<UserImage userHandle={agentName} icon={Bot} decorative/>} name={agentName} meta={agentMeta(startedAt)} footer={working ? (
126
169
  // The only Stop, on the row for the whole run. It shows loading while the run is stopping.
127
170
  <Cluster>
128
- <Button size="small" type="secondary" state="enabled" label="Stop" loading={phase === 'stopping'} onClickButton={stop}/>
129
- </Cluster>) : phase === 'failed' ? (<Cluster>
130
- <Button size="small" type="secondary" state="enabled" label="Try Again" onClickButton={tryAgain}/>
131
- </Cluster>) : phase === 'stopped' ? (<Cluster>
171
+ <Button ref={stopButton} size="small" type="secondary" state="enabled" label="Stop" loading={phase === 'stopping'} onClickButton={stop}/>
172
+ </Cluster>) : phase === 'failed' ? (
173
+ // As in the case 'Run that stopped short': how long it waits, then 'Stop Here' and 'Try Step Again' as the primary Button.
174
+ <Stack gap="small">
175
+ <Paragraph size="caption" tone="secondary" measure="none">Waits 10 more minutes, then stops here.</Paragraph>
176
+ <Cluster gap="small">
177
+ <Button ref={stopHereButton} size="small" type="tertiary" state="enabled" label="Stop Here" onClickButton={stopHere}/>
178
+ <Button size="small" type="primary" state="enabled" label="Try Step Again" onClickButton={tryStepAgain}/>
179
+ </Cluster>
180
+ </Stack>) : phase === 'stopped' ? (<Cluster>
132
181
  <Button ref={runAgainButton} size="small" type="secondary" state="enabled" label="Run Again" onClickButton={runLive}/>
133
182
  </Cluster>) : undefined}>
134
183
  {phase === 'done' ? (
135
184
  // The run is over: the row is the reply, and Stop is gone. A real app moves focus to the message box.
136
- <Paragraph measure="none">{reply}</Paragraph>) : phase === 'stopped' ? (<Paragraph measure="none">Stopped. Nothing was changed.</Paragraph>) : (
137
- // A real app wraps this part in a polite live region, since StepList has none.
185
+ <Paragraph measure="none">{reply}</Paragraph>) : (
186
+ // A real app wraps the running step in a polite live region, since StepList has none.
187
+ // After a stop the steps stay, as the rule 'An agent that stops short says what it finished and what is left' says.
138
188
  <Stack gap="medium">
139
189
  {working && <Paragraph size="caption" tone="secondary" measure="none">{secondsLine(seconds)}</Paragraph>}
140
- <StepList aria-label="Acme Agent's steps" steps={stepsUpTo(current, phase === 'failed')}/>
141
- {phase === 'failed' && (
142
- // It reports where the run stands, so it has no close button and stays.
143
- <Alert type="error" variant="inline" autoDismiss={false} message="Acme Agent could not open the pricing page. Nothing was changed."/>)}
190
+ <StepList aria-label="Acme Agent's steps" steps={stepsUpTo(current, phase, endedOnFailure)}/>
191
+ {/* 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. */}
192
+ <Paragraph role="status" measure="none">{statusLine}</Paragraph>
144
193
  </Stack>)}
145
194
  </Message>
146
195
  </Stack>