oneslash-design-system 2.17.0 → 2.18.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 (185) hide show
  1. package/README.md +2 -2
  2. package/dist/DESIGN.md +30 -14
  3. package/dist/cases/accept-invite.md +1 -5
  4. package/dist/cases/account-menu/menu.d.ts +1 -0
  5. package/dist/cases/account-menu/menu.jsx +99 -0
  6. package/dist/cases/account-menu.md +164 -0
  7. package/dist/cases/agent-asks-before-risky-action.md +0 -4
  8. package/dist/cases/agent-cancels-when-unanswered.md +0 -4
  9. package/dist/cases/agent-options.md +0 -4
  10. package/dist/cases/agent-pending-reply.md +0 -4
  11. package/dist/cases/agent-plan-proposal.md +0 -4
  12. package/dist/cases/agent-question.md +0 -4
  13. package/dist/cases/agent-refuses-clearly.md +0 -4
  14. package/dist/cases/agent-says-what-it-is.md +0 -2
  15. package/dist/cases/agent-settings/form.d.ts +1 -0
  16. package/dist/cases/agent-settings/form.jsx +164 -0
  17. package/dist/cases/agent-settings.md +259 -0
  18. package/dist/cases/agent-shows-progress.md +0 -2
  19. package/dist/cases/agent-shows-sources.md +0 -2
  20. package/dist/cases/api-keys/list.d.ts +1 -0
  21. package/dist/cases/api-keys/list.jsx +162 -0
  22. package/dist/cases/api-keys.md +229 -0
  23. package/dist/cases/artifact-card.md +0 -4
  24. package/dist/cases/auth-gate-loading.md +0 -4
  25. package/dist/cases/check-your-email.md +0 -4
  26. package/dist/cases/collapsible-search/popover.d.ts +1 -0
  27. package/dist/cases/collapsible-search/popover.jsx +74 -0
  28. package/dist/cases/collapsible-search.md +143 -0
  29. package/dist/cases/composer-limit.md +0 -4
  30. package/dist/cases/confirm-destructive-action.md +0 -4
  31. package/dist/cases/confirm-dialogs.md +0 -4
  32. package/dist/cases/conversation-starters.md +0 -4
  33. package/dist/cases/create-modal.md +0 -4
  34. package/dist/cases/danger-zone/collapsed.d.ts +1 -0
  35. package/dist/cases/danger-zone/collapsed.jsx +75 -0
  36. package/dist/cases/danger-zone/shown.d.ts +1 -0
  37. package/dist/cases/danger-zone/shown.jsx +95 -0
  38. package/dist/cases/danger-zone.md +263 -0
  39. package/dist/cases/device-login.md +0 -4
  40. package/dist/cases/email-confirmed.md +0 -4
  41. package/dist/cases/empty-list.md +0 -4
  42. package/dist/cases/empty-lists.md +0 -4
  43. package/dist/cases/empty-not-set-up.md +0 -4
  44. package/dist/cases/empty-search.md +0 -4
  45. package/dist/cases/error-page.md +0 -4
  46. package/dist/cases/feedback-form.md +0 -4
  47. package/dist/cases/filter-menu/presets.d.ts +1 -0
  48. package/dist/cases/filter-menu/presets.jsx +53 -0
  49. package/dist/cases/filter-menu/with-clear.d.ts +1 -0
  50. package/dist/cases/filter-menu/with-clear.jsx +56 -0
  51. package/dist/cases/filter-menu.md +204 -0
  52. package/dist/cases/forgot-password.md +0 -4
  53. package/dist/cases/form-errors.md +0 -4
  54. package/dist/cases/import-checklist.md +0 -4
  55. package/dist/cases/inline-form-feedback.md +0 -4
  56. package/dist/cases/integrations-list/nested.d.ts +1 -0
  57. package/dist/cases/integrations-list/nested.jsx +164 -0
  58. package/dist/cases/integrations-list/rows.d.ts +1 -0
  59. package/dist/cases/integrations-list/rows.jsx +134 -0
  60. package/dist/cases/integrations-list.md +379 -0
  61. package/dist/cases/invite-member.md +0 -4
  62. package/dist/cases/load-failure.md +0 -4
  63. package/dist/cases/log-out-confirm.md +0 -4
  64. package/dist/cases/login-page.md +0 -4
  65. package/dist/cases/members-list/rows.d.ts +1 -0
  66. package/dist/cases/members-list/rows.jsx +318 -0
  67. package/dist/cases/members-list/table.d.ts +1 -0
  68. package/dist/cases/members-list/table.jsx +351 -0
  69. package/dist/cases/members-list.md +799 -0
  70. package/dist/cases/mention-list.md +0 -4
  71. package/dist/cases/message-actions.md +0 -4
  72. package/dist/cases/message-attachments.md +0 -4
  73. package/dist/cases/message-composer.md +0 -4
  74. package/dist/cases/message-edit.md +0 -4
  75. package/dist/cases/message-reactions.md +0 -4
  76. package/dist/cases/message-row.md +0 -4
  77. package/dist/cases/not-found-page.md +0 -4
  78. package/dist/cases/notification-menu/menu.d.ts +1 -0
  79. package/dist/cases/notification-menu/menu.jsx +74 -0
  80. package/dist/cases/notification-menu.md +135 -0
  81. package/dist/cases/oauth-consent.md +0 -4
  82. package/dist/cases/on-off-settings/list.d.ts +1 -0
  83. package/dist/cases/on-off-settings/list.jsx +97 -0
  84. package/dist/cases/on-off-settings.md +116 -0
  85. package/dist/cases/overflow-menu/in-a-header.d.ts +1 -0
  86. package/dist/cases/overflow-menu/in-a-header.jsx +128 -0
  87. package/dist/cases/overflow-menu/on-a-row.d.ts +1 -0
  88. package/dist/cases/overflow-menu/on-a-row.jsx +183 -0
  89. package/dist/cases/overflow-menu.md +410 -0
  90. package/dist/cases/profile-form/form.d.ts +1 -0
  91. package/dist/cases/profile-form/form.jsx +153 -0
  92. package/dist/cases/profile-form.md +236 -0
  93. package/dist/cases/quick-switcher/modal.d.ts +1 -0
  94. package/dist/cases/quick-switcher/modal.jsx +114 -0
  95. package/dist/cases/quick-switcher.md +205 -0
  96. package/dist/cases/range-switch/segmented.d.ts +1 -0
  97. package/dist/cases/range-switch/segmented.jsx +30 -0
  98. package/dist/cases/range-switch.md +67 -0
  99. package/dist/cases/rename.md +0 -4
  100. package/dist/cases/reply-feedback.md +0 -4
  101. package/dist/cases/reply-sources.md +0 -4
  102. package/dist/cases/route-loading.md +0 -2
  103. package/dist/cases/scope-picker/menu.d.ts +1 -0
  104. package/dist/cases/scope-picker/menu.jsx +47 -0
  105. package/dist/cases/scope-picker.md +97 -0
  106. package/dist/cases/set-new-password.md +0 -4
  107. package/dist/cases/settings-page/side-nav.d.ts +1 -0
  108. package/dist/cases/settings-page/side-nav.jsx +171 -0
  109. package/dist/cases/settings-page/top-tabs.d.ts +1 -0
  110. package/dist/cases/settings-page/top-tabs.jsx +129 -0
  111. package/dist/cases/settings-page.md +378 -0
  112. package/dist/cases/settings-save.md +35 -0
  113. package/dist/cases/sign-up-page.md +1 -5
  114. package/dist/cases/slash-command-list.md +0 -4
  115. package/dist/cases/success-feedback.md +0 -4
  116. package/dist/cases/tag-filter/tags.d.ts +1 -0
  117. package/dist/cases/tag-filter/tags.jsx +226 -0
  118. package/dist/cases/tag-filter.md +298 -0
  119. package/dist/cases/type-to-confirm.md +0 -4
  120. package/dist/cases/typing-and-status.md +0 -4
  121. package/dist/cases/unsaved-changes-guard.md +0 -4
  122. package/dist/cases/upgrade-prompt.md +0 -4
  123. package/dist/cases.json +1038 -263
  124. package/dist/components/alert.d.ts +3 -1
  125. package/dist/components/alert.jsx +2 -2
  126. package/dist/components/button.jsx +5 -2
  127. package/dist/components/checkBox.d.ts +5 -1
  128. package/dist/components/checkBox.jsx +2 -2
  129. package/dist/components/copyField.d.ts +20 -0
  130. package/dist/components/copyField.jsx +99 -0
  131. package/dist/components/formField.d.ts +34 -0
  132. package/dist/components/formField.jsx +28 -0
  133. package/dist/components/heading.d.ts +3 -1
  134. package/dist/components/heading.jsx +2 -2
  135. package/dist/components/menu.jsx +2 -2
  136. package/dist/components/menuItem.d.ts +4 -2
  137. package/dist/components/menuItem.jsx +3 -3
  138. package/dist/components/navigation.d.ts +9 -1
  139. package/dist/components/navigation.jsx +15 -3
  140. package/dist/components/radioGroup.d.ts +5 -1
  141. package/dist/components/radioGroup.jsx +2 -2
  142. package/dist/components/segmentedControl.d.ts +22 -0
  143. package/dist/components/segmentedControl.jsx +54 -0
  144. package/dist/components/select.d.ts +5 -1
  145. package/dist/components/select.jsx +2 -2
  146. package/dist/components/settingsSection.d.ts +31 -0
  147. package/dist/components/settingsSection.jsx +58 -0
  148. package/dist/components/slidingIndicator.d.ts +50 -0
  149. package/dist/components/slidingIndicator.jsx +102 -0
  150. package/dist/components/switch.d.ts +25 -0
  151. package/dist/components/switch.jsx +55 -0
  152. package/dist/components/tab.jsx +5 -11
  153. package/dist/components/tabsContainer.jsx +5 -67
  154. package/dist/components/textField.d.ts +12 -2
  155. package/dist/components/textField.jsx +11 -4
  156. package/dist/components/textarea.d.ts +5 -1
  157. package/dist/components/textarea.jsx +3 -3
  158. package/dist/components/useHotkey.d.ts +7 -0
  159. package/dist/components/useHotkey.js +24 -0
  160. package/dist/index.d.ts +6 -0
  161. package/dist/index.js +6 -0
  162. package/dist/internal/copyField.d.ts +5 -0
  163. package/dist/internal/copyField.js +61 -0
  164. package/dist/internal/hotkey.d.ts +16 -0
  165. package/dist/internal/hotkey.js +20 -0
  166. package/dist/internal/switch.d.ts +5 -0
  167. package/dist/internal/switch.js +9 -0
  168. package/dist/native-mapping.json +30 -0
  169. package/dist/stories/Cases.generated.stories.d.ts +23 -0
  170. package/dist/stories/Cases.generated.stories.jsx +46 -0
  171. package/dist/stories/CopyField.stories.d.ts +11 -0
  172. package/dist/stories/CopyField.stories.jsx +65 -0
  173. package/dist/stories/FormField.stories.d.ts +6 -0
  174. package/dist/stories/FormField.stories.jsx +44 -0
  175. package/dist/stories/Navigation.stories.d.ts +1 -0
  176. package/dist/stories/Navigation.stories.jsx +17 -1
  177. package/dist/stories/SegmentedControl.stories.d.ts +8 -0
  178. package/dist/stories/SegmentedControl.stories.jsx +33 -0
  179. package/dist/stories/SettingsSection.stories.d.ts +11 -0
  180. package/dist/stories/SettingsSection.stories.jsx +64 -0
  181. package/dist/stories/Switch.stories.d.ts +14 -0
  182. package/dist/stories/Switch.stories.jsx +87 -0
  183. package/dist/stories/TextField.stories.d.ts +1 -0
  184. package/dist/stories/TextField.stories.jsx +13 -0
  185. package/package.json +5 -1
@@ -0,0 +1,164 @@
1
+ 'use client';
2
+ import { useEffect, useRef, useState } from 'react';
3
+ import Heading from '../../components/heading';
4
+ import Paragraph from '../../components/paragraph';
5
+ import Form from '../../components/form';
6
+ import FormField from '../../components/formField';
7
+ import RadioGroup from '../../components/radioGroup';
8
+ import Textarea from '../../components/textarea';
9
+ import TextField from '../../components/textField';
10
+ import Button from '../../components/button';
11
+ import SettingsSection from '../../components/settingsSection';
12
+ import { Center, Cluster, Stack } from '../../components/layout';
13
+ // A real app reads this from the person's role. Only an admin can change the agent.
14
+ var canChange = true;
15
+ var providerOptions = [
16
+ { value: 'anthropic', label: 'Anthropic', secondLabel: 'Claude Sonnet, Opus and Haiku' },
17
+ { value: 'openai', label: 'OpenAI', secondLabel: 'GPT-4o and GPT-4.1' },
18
+ { value: 'google', label: 'Google Gemini', secondLabel: 'Gemini Pro and Flash' },
19
+ ];
20
+ // Each choice needs a line that says what it does, so this is a RadioGroup and not a SegmentedControl.
21
+ var routingOptions = [
22
+ { value: 'auto', label: 'Auto', secondLabel: 'The best model for each request. The default.' },
23
+ { value: 'cost', label: 'Lower cost', secondLabel: 'Use cheaper models when they can do the job.' },
24
+ { value: 'quality', label: 'Higher quality', secondLabel: 'Use the most capable model for every request.' },
25
+ ];
26
+ var maxInstructions = 1000;
27
+ var failedMessage = 'Could not save. Try again.';
28
+ export default function AgentSettingsForm() {
29
+ var _a = useState('anthropic'), provider = _a[0], setProvider = _a[1];
30
+ var _b = useState(''), providerError = _b[0], setProviderError = _b[1];
31
+ var _c = useState(false), savingProvider = _c[0], setSavingProvider = _c[1];
32
+ var _d = useState('auto'), routing = _d[0], setRouting = _d[1];
33
+ var _e = useState(''), routingError = _e[0], setRoutingError = _e[1];
34
+ var _f = useState(false), savingRouting = _f[0], setSavingRouting = _f[1];
35
+ var _g = useState('Answer in short sentences. Link the task when you mention one.'), savedInstructions = _g[0], setSavedInstructions = _g[1];
36
+ var _h = useState('Answer in short sentences. Link the task when you mention one.'), instructions = _h[0], setInstructions = _h[1];
37
+ var _j = useState(''), instructionsError = _j[0], setInstructionsError = _j[1];
38
+ var _k = useState(false), savingInstructions = _k[0], setSavingInstructions = _k[1];
39
+ var _l = useState(false), instructionsSaved = _l[0], setInstructionsSaved = _l[1];
40
+ var _m = useState('200'), savedBudget = _m[0], setSavedBudget = _m[1];
41
+ var _o = useState('200'), budget = _o[0], setBudget = _o[1];
42
+ var _p = useState(''), budgetError = _p[0], setBudgetError = _p[1];
43
+ var _q = useState(false), savingBudget = _q[0], setSavingBudget = _q[1];
44
+ var _r = useState(false), budgetSaved = _r[0], setBudgetSaved = _r[1];
45
+ var timers = useRef([]);
46
+ // One 'Saved' timer per group, cleared before a new one starts, so an old one cannot end a new 'Saved' early.
47
+ var instructionsSavedTimer = useRef();
48
+ var budgetSavedTimer = useRef();
49
+ // Stops every request and every 'Saved' if the example goes away before they end.
50
+ useEffect(function () { return function () {
51
+ timers.current.forEach(clearTimeout);
52
+ clearTimeout(instructionsSavedTimer.current);
53
+ clearTimeout(budgetSavedTimer.current);
54
+ }; }, []);
55
+ // Stands in for the request to the server.
56
+ function later(callback, ms) {
57
+ timers.current.push(setTimeout(callback, ms));
58
+ }
59
+ // A choice stands alone, so it saves as soon as it is made. Nothing shows when it works.
60
+ // While the request runs the group is disabled. When it fails, the old choice comes back and a line says why.
61
+ function handleProvider(next) {
62
+ if (savingProvider || next === provider)
63
+ return;
64
+ var before = provider;
65
+ setProviderError('');
66
+ setProvider(next);
67
+ setSavingProvider(true);
68
+ later(function () {
69
+ setSavingProvider(false);
70
+ // Stands in for a connection that is down: Google Gemini never saves.
71
+ if (next === 'google') {
72
+ setProvider(before);
73
+ setProviderError(failedMessage);
74
+ }
75
+ }, 900);
76
+ }
77
+ function handleRouting(next) {
78
+ if (savingRouting || next === routing)
79
+ return;
80
+ setRoutingError('');
81
+ setRouting(next);
82
+ setSavingRouting(true);
83
+ later(function () { return setSavingRouting(false); }, 900);
84
+ }
85
+ // Instructions are a group with one Save Button: 'Saved' shows for 2 seconds, and the Button is disabled while nothing changed.
86
+ function handleSaveInstructions() {
87
+ if (savingInstructions)
88
+ return;
89
+ if (instructions.length > maxInstructions) {
90
+ setInstructionsError("Use up to ".concat(maxInstructions.toLocaleString('en-US'), " characters."));
91
+ return;
92
+ }
93
+ setInstructionsError('');
94
+ setSavingInstructions(true);
95
+ later(function () {
96
+ setSavedInstructions(instructions);
97
+ setSavingInstructions(false);
98
+ setInstructionsSaved(true);
99
+ clearTimeout(instructionsSavedTimer.current);
100
+ instructionsSavedTimer.current = setTimeout(function () { return setInstructionsSaved(false); }, 2000);
101
+ }, 1200);
102
+ }
103
+ function handleSaveBudget() {
104
+ if (savingBudget)
105
+ return;
106
+ if (!/^\d+$/.test(budget.trim())) {
107
+ setBudgetError('Enter a whole number of dollars, like 200.');
108
+ return;
109
+ }
110
+ setBudgetError('');
111
+ setSavingBudget(true);
112
+ later(function () {
113
+ setSavedBudget(budget.trim());
114
+ setBudget(budget.trim());
115
+ setSavingBudget(false);
116
+ setBudgetSaved(true);
117
+ clearTimeout(budgetSavedTimer.current);
118
+ budgetSavedTimer.current = setTimeout(function () { return setBudgetSaved(false); }, 2000);
119
+ }, 1200);
120
+ }
121
+ var instructionsChanged = instructions !== savedInstructions;
122
+ var budgetChanged = budget.trim() !== savedBudget;
123
+ return (<Center width="page">
124
+ <Stack gap="xlarge">
125
+ <Stack gap="small">
126
+ <Heading level={1} size="h5">Agent</Heading>
127
+ <Paragraph tone="secondary" size="body2" measure="none">How the Acme agent works for everyone in this workspace.</Paragraph>
128
+ {!canChange && <Paragraph tone="secondary" size="body2" measure="none">Only admins can change this.</Paragraph>}
129
+ </Stack>
130
+
131
+ {/* Both choices save as soon as they change, so this section has no Save Button. */}
132
+ <SettingsSection title="Model" description="Each choice saves as soon as you make it.">
133
+ <FormField id="agent-settings-provider" label="AI provider" error={providerError}>
134
+ {function (f) { return (<RadioGroup id={f.id} aria-describedby={f['aria-describedby']} aria-label="AI provider" variant="card" options={providerOptions} selectedValue={provider} disabled={!canChange || savingProvider} onChange={handleProvider}/>); }}
135
+ </FormField>
136
+ <FormField id="agent-settings-routing" label="Routing" help="How the agent picks a model for each request." error={routingError}>
137
+ {function (f) { return (<RadioGroup id={f.id} aria-describedby={f['aria-describedby']} aria-label="Routing" options={routingOptions} selectedValue={routing} disabled={!canChange || savingRouting} onChange={handleRouting}/>); }}
138
+ </FormField>
139
+ </SettingsSection>
140
+
141
+ <SettingsSection title="Instructions" description="What the agent should know about how your team works.">
142
+ <Form aria-label="Instructions" gap="medium" onSubmit={handleSaveInstructions}>
143
+ <FormField id="agent-settings-instructions" label="Instructions" help={"Up to ".concat(maxInstructions.toLocaleString('en-US'), " characters. Every conversation uses them.")} error={instructionsError}>
144
+ {function (f) { return (<Textarea id={f.id} aria-describedby={f['aria-describedby']} aria-invalid={f['aria-invalid']} value={instructions} disabled={!canChange || savingInstructions} onChange={function (e) { setInstructions(e.target.value); setInstructionsError(''); setInstructionsSaved(false); }}/>); }}
145
+ </FormField>
146
+ {canChange && (<Cluster>
147
+ <Button size="medium" type="primary" state={instructionsChanged || savingInstructions ? 'enabled' : 'disabled'} label={instructionsSaved ? 'Saved' : 'Save'} aria-label={"".concat(instructionsSaved ? 'Saved' : 'Save', " instructions")} htmlType="submit" loading={savingInstructions}/>
148
+ </Cluster>)}
149
+ </Form>
150
+ </SettingsSection>
151
+
152
+ <SettingsSection title="Budget" description="This month the agent has used $84.">
153
+ <Form aria-label="Budget" gap="medium" onSubmit={handleSaveBudget}>
154
+ <FormField id="agent-settings-budget" label="Monthly cap in US dollars" help="The agent stops when this month's use reaches the cap, and starts again next month." error={budgetError}>
155
+ {function (f) { return (<TextField id={f.id} type="number" aria-describedby={f['aria-describedby']} aria-invalid={f['aria-invalid']} value={budget} disabled={!canChange || savingBudget} autoComplete="off" onChange={function (e) { setBudget(e.target.value); setBudgetError(''); setBudgetSaved(false); }}/>); }}
156
+ </FormField>
157
+ {canChange && (<Cluster>
158
+ <Button size="medium" type="primary" state={budgetChanged || savingBudget ? 'enabled' : 'disabled'} label={budgetSaved ? 'Saved' : 'Save'} aria-label={"".concat(budgetSaved ? 'Saved' : 'Save', " budget")} htmlType="submit" loading={savingBudget}/>
159
+ </Cluster>)}
160
+ </Form>
161
+ </SettingsSection>
162
+ </Stack>
163
+ </Center>);
164
+ }
@@ -0,0 +1,259 @@
1
+ # Agent settings
2
+
3
+ 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.
4
+
5
+ ## Do
6
+
7
+ - 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.
8
+ - Show the provider as `<RadioGroup variant="card">`, with the models in the `secondLabel`. It saves as soon as the person chooses.
9
+ - Disable the group while it saves and show nothing when it works. When the save fails, put the old choice back and say why under it: 'Could not save. Try again.'
10
+ - Show the routing as a `RadioGroup` too. Each choice needs a line that says what it does, such as 'Use cheaper models when they can do the job.' A `SegmentedControl` fits two to four short choices that need no line.
11
+ - Wrap each field in a `FormField` and pass `id` and `aria-describedby` to the control, and `aria-invalid` to a `TextField` or `Textarea`. Give a `RadioGroup` an `aria-label` that starts with the visible label: 'AI provider'.
12
+ - Put the instructions in a `Textarea` inside a `Form` with one Save Button. Say the limit in the help line, and show a problem with it under the field.
13
+ - Put the budget cap in a `TextField type="number"` inside its own `Form` with one Save Button. Say what happens at the cap and when it resets.
14
+ - Keep each Save Button `state="disabled"` while nothing has changed. It shows `loading`, keeps its label, then reads 'Saved' for 2 seconds. Name each one with an `aria-label`: 'Save instructions' and 'Save budget'.
15
+ - Show everything read-only to a person who is not an admin, with one line at the top: 'Only admins can change this.' Remove the Save Buttons.
16
+
17
+ ## Don't
18
+
19
+ - Do not mix a choice that saves on change and a Save Button in one section.
20
+ - Do not label the Button 'Saving…'. It keeps its label.
21
+ - Do not show a toast or a green caption when a setting saves. The control shows the new value, and the Button says Saved.
22
+ - Do not hide a choice from a person who cannot change it with `pointer-events-none`. Show it disabled, with the line.
23
+ - Do not use a `Select` for three choices that need a line each. Show them all in a `RadioGroup`.
24
+ - Do not show a failed save as red text written by hand. Use the error line of `FormField`.
25
+
26
+ ## Example: Choices that save, and two groups with a Save Button
27
+
28
+ Uses: `Button`, `Center`, `Cluster`, `Form`, `FormField`, `Heading`, `Paragraph`, `RadioGroup`, `SettingsSection`, `Stack`, `TextField`, `Textarea`
29
+
30
+ ```tsx
31
+ 'use client';
32
+ import { useEffect, useRef, useState } from 'react';
33
+ import Heading from 'oneslash-design-system/components/heading';
34
+ import Paragraph from 'oneslash-design-system/components/paragraph';
35
+ import Form from 'oneslash-design-system/components/form';
36
+ import FormField from 'oneslash-design-system/components/formField';
37
+ import RadioGroup from 'oneslash-design-system/components/radioGroup';
38
+ import Textarea from 'oneslash-design-system/components/textarea';
39
+ import TextField from 'oneslash-design-system/components/textField';
40
+ import Button from 'oneslash-design-system/components/button';
41
+ import SettingsSection from 'oneslash-design-system/components/settingsSection';
42
+ import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
43
+
44
+ // A real app reads this from the person's role. Only an admin can change the agent.
45
+ const canChange = true;
46
+
47
+ const providerOptions = [
48
+ { value: 'anthropic', label: 'Anthropic', secondLabel: 'Claude Sonnet, Opus and Haiku' },
49
+ { value: 'openai', label: 'OpenAI', secondLabel: 'GPT-4o and GPT-4.1' },
50
+ { value: 'google', label: 'Google Gemini', secondLabel: 'Gemini Pro and Flash' },
51
+ ];
52
+
53
+ // Each choice needs a line that says what it does, so this is a RadioGroup and not a SegmentedControl.
54
+ const routingOptions = [
55
+ { value: 'auto', label: 'Auto', secondLabel: 'The best model for each request. The default.' },
56
+ { value: 'cost', label: 'Lower cost', secondLabel: 'Use cheaper models when they can do the job.' },
57
+ { value: 'quality', label: 'Higher quality', secondLabel: 'Use the most capable model for every request.' },
58
+ ];
59
+
60
+ const maxInstructions = 1000;
61
+ const failedMessage = 'Could not save. Try again.';
62
+
63
+ export default function AgentSettingsForm() {
64
+ const [provider, setProvider] = useState('anthropic');
65
+ const [providerError, setProviderError] = useState('');
66
+ const [savingProvider, setSavingProvider] = useState(false);
67
+
68
+ const [routing, setRouting] = useState('auto');
69
+ const [routingError, setRoutingError] = useState('');
70
+ const [savingRouting, setSavingRouting] = useState(false);
71
+
72
+ const [savedInstructions, setSavedInstructions] = useState('Answer in short sentences. Link the task when you mention one.');
73
+ const [instructions, setInstructions] = useState('Answer in short sentences. Link the task when you mention one.');
74
+ const [instructionsError, setInstructionsError] = useState('');
75
+ const [savingInstructions, setSavingInstructions] = useState(false);
76
+ const [instructionsSaved, setInstructionsSaved] = useState(false);
77
+
78
+ const [savedBudget, setSavedBudget] = useState('200');
79
+ const [budget, setBudget] = useState('200');
80
+ const [budgetError, setBudgetError] = useState('');
81
+ const [savingBudget, setSavingBudget] = useState(false);
82
+ const [budgetSaved, setBudgetSaved] = useState(false);
83
+
84
+ const timers = useRef<ReturnType<typeof setTimeout>[]>([]);
85
+ // One 'Saved' timer per group, cleared before a new one starts, so an old one cannot end a new 'Saved' early.
86
+ const instructionsSavedTimer = useRef<ReturnType<typeof setTimeout>>();
87
+ const budgetSavedTimer = useRef<ReturnType<typeof setTimeout>>();
88
+
89
+ // Stops every request and every 'Saved' if the example goes away before they end.
90
+ useEffect(() => () => {
91
+ timers.current.forEach(clearTimeout);
92
+ clearTimeout(instructionsSavedTimer.current);
93
+ clearTimeout(budgetSavedTimer.current);
94
+ }, []);
95
+
96
+ // Stands in for the request to the server.
97
+ function later(callback: () => void, ms: number) {
98
+ timers.current.push(setTimeout(callback, ms));
99
+ }
100
+
101
+ // A choice stands alone, so it saves as soon as it is made. Nothing shows when it works.
102
+ // While the request runs the group is disabled. When it fails, the old choice comes back and a line says why.
103
+ function handleProvider(next: string) {
104
+ if (savingProvider || next === provider) return;
105
+ const before = provider;
106
+ setProviderError('');
107
+ setProvider(next);
108
+ setSavingProvider(true);
109
+ later(() => {
110
+ setSavingProvider(false);
111
+ // Stands in for a connection that is down: Google Gemini never saves.
112
+ if (next === 'google') {
113
+ setProvider(before);
114
+ setProviderError(failedMessage);
115
+ }
116
+ }, 900);
117
+ }
118
+
119
+ function handleRouting(next: string) {
120
+ if (savingRouting || next === routing) return;
121
+ setRoutingError('');
122
+ setRouting(next);
123
+ setSavingRouting(true);
124
+ later(() => setSavingRouting(false), 900);
125
+ }
126
+
127
+ // Instructions are a group with one Save Button: 'Saved' shows for 2 seconds, and the Button is disabled while nothing changed.
128
+ function handleSaveInstructions() {
129
+ if (savingInstructions) return;
130
+ if (instructions.length > maxInstructions) {
131
+ setInstructionsError(`Use up to ${maxInstructions.toLocaleString('en-US')} characters.`);
132
+ return;
133
+ }
134
+ setInstructionsError('');
135
+ setSavingInstructions(true);
136
+ later(() => {
137
+ setSavedInstructions(instructions);
138
+ setSavingInstructions(false);
139
+ setInstructionsSaved(true);
140
+ clearTimeout(instructionsSavedTimer.current);
141
+ instructionsSavedTimer.current = setTimeout(() => setInstructionsSaved(false), 2000);
142
+ }, 1200);
143
+ }
144
+
145
+ function handleSaveBudget() {
146
+ if (savingBudget) return;
147
+ if (!/^\d+$/.test(budget.trim())) {
148
+ setBudgetError('Enter a whole number of dollars, like 200.');
149
+ return;
150
+ }
151
+ setBudgetError('');
152
+ setSavingBudget(true);
153
+ later(() => {
154
+ setSavedBudget(budget.trim());
155
+ setBudget(budget.trim());
156
+ setSavingBudget(false);
157
+ setBudgetSaved(true);
158
+ clearTimeout(budgetSavedTimer.current);
159
+ budgetSavedTimer.current = setTimeout(() => setBudgetSaved(false), 2000);
160
+ }, 1200);
161
+ }
162
+
163
+ const instructionsChanged = instructions !== savedInstructions;
164
+ const budgetChanged = budget.trim() !== savedBudget;
165
+
166
+ return (
167
+ <Center width="page">
168
+ <Stack gap="xlarge">
169
+ <Stack gap="small">
170
+ <Heading level={1} size="h5">Agent</Heading>
171
+ <Paragraph tone="secondary" size="body2" measure="none">How the Acme agent works for everyone in this workspace.</Paragraph>
172
+ {!canChange && <Paragraph tone="secondary" size="body2" measure="none">Only admins can change this.</Paragraph>}
173
+ </Stack>
174
+
175
+ {/* Both choices save as soon as they change, so this section has no Save Button. */}
176
+ <SettingsSection title="Model" description="Each choice saves as soon as you make it.">
177
+ <FormField id="agent-settings-provider" label="AI provider" error={providerError}>
178
+ {(f) => (
179
+ <RadioGroup
180
+ id={f.id}
181
+ aria-describedby={f['aria-describedby']}
182
+ aria-label="AI provider"
183
+ variant="card"
184
+ options={providerOptions}
185
+ selectedValue={provider}
186
+ disabled={!canChange || savingProvider}
187
+ onChange={handleProvider}
188
+ />
189
+ )}
190
+ </FormField>
191
+ <FormField id="agent-settings-routing" label="Routing" help="How the agent picks a model for each request." error={routingError}>
192
+ {(f) => (
193
+ <RadioGroup
194
+ id={f.id}
195
+ aria-describedby={f['aria-describedby']}
196
+ aria-label="Routing"
197
+ options={routingOptions}
198
+ selectedValue={routing}
199
+ disabled={!canChange || savingRouting}
200
+ onChange={handleRouting}
201
+ />
202
+ )}
203
+ </FormField>
204
+ </SettingsSection>
205
+
206
+ <SettingsSection title="Instructions" description="What the agent should know about how your team works.">
207
+ <Form aria-label="Instructions" gap="medium" onSubmit={handleSaveInstructions}>
208
+ <FormField id="agent-settings-instructions" label="Instructions" help={`Up to ${maxInstructions.toLocaleString('en-US')} characters. Every conversation uses them.`} error={instructionsError}>
209
+ {(f) => (
210
+ <Textarea
211
+ id={f.id}
212
+ aria-describedby={f['aria-describedby']}
213
+ aria-invalid={f['aria-invalid']}
214
+ value={instructions}
215
+ disabled={!canChange || savingInstructions}
216
+ onChange={(e) => { setInstructions(e.target.value); setInstructionsError(''); setInstructionsSaved(false); }}
217
+ />
218
+ )}
219
+ </FormField>
220
+ {canChange && (
221
+ <Cluster>
222
+ <Button size="medium" type="primary" state={instructionsChanged || savingInstructions ? 'enabled' : 'disabled'} label={instructionsSaved ? 'Saved' : 'Save'} aria-label={`${instructionsSaved ? 'Saved' : 'Save'} instructions`} htmlType="submit" loading={savingInstructions} />
223
+ </Cluster>
224
+ )}
225
+ </Form>
226
+ </SettingsSection>
227
+
228
+ <SettingsSection title="Budget" description="This month the agent has used $84.">
229
+ <Form aria-label="Budget" gap="medium" onSubmit={handleSaveBudget}>
230
+ <FormField id="agent-settings-budget" label="Monthly cap in US dollars" help="The agent stops when this month's use reaches the cap, and starts again next month." error={budgetError}>
231
+ {(f) => (
232
+ <TextField
233
+ id={f.id}
234
+ type="number"
235
+ aria-describedby={f['aria-describedby']}
236
+ aria-invalid={f['aria-invalid']}
237
+ value={budget}
238
+ disabled={!canChange || savingBudget}
239
+ autoComplete="off"
240
+ onChange={(e) => { setBudget(e.target.value); setBudgetError(''); setBudgetSaved(false); }}
241
+ />
242
+ )}
243
+ </FormField>
244
+ {canChange && (
245
+ <Cluster>
246
+ <Button size="medium" type="primary" state={budgetChanged || savingBudget ? 'enabled' : 'disabled'} label={budgetSaved ? 'Saved' : 'Save'} aria-label={`${budgetSaved ? 'Saved' : 'Save'} budget`} htmlType="submit" loading={savingBudget} />
247
+ </Cluster>
248
+ )}
249
+ </Form>
250
+ </SettingsSection>
251
+ </Stack>
252
+ </Center>
253
+ );
254
+ }
255
+ ```
256
+
257
+ ## Native
258
+
259
+ On Apple use a grouped `Form` with a `Picker` for the provider and the routing. Use a `TextEditor` for the instructions and a `TextField` for the cap, each with one Save Button.
@@ -26,5 +26,3 @@ A person waiting on an agent needs to know it is still working, what it is doing
26
26
  ## Native
27
27
 
28
28
  On Apple the Send button turns into Stop while the agent works, and the note reads 'Stopped.' only once the run has really ended.
29
-
30
- Seen in: Scindo.
@@ -22,5 +22,3 @@ A person can check an answer only when they can open what it came from.
22
22
  - Do not show a sources section when the reply used no sources.
23
23
  - Do not show source cards on a person's message.
24
24
  - Do not link a source card to any site other than the product or the service the source came from.
25
-
26
- Seen in: Scindo.
@@ -0,0 +1 @@
1
+ export default function ApiKeysList(): import("react").JSX.Element;
@@ -0,0 +1,162 @@
1
+ 'use client';
2
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
+ if (ar || !(i in from)) {
5
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
+ ar[i] = from[i];
7
+ }
8
+ }
9
+ return to.concat(ar || Array.prototype.slice.call(from));
10
+ };
11
+ import { useEffect, useRef, useState } from 'react';
12
+ import Toaster, { toast, dismissToast } from '../../components/toaster';
13
+ import Modal from '../../components/modal';
14
+ import Heading from '../../components/heading';
15
+ import Paragraph from '../../components/paragraph';
16
+ import TableContainer from '../../components/tableContainer';
17
+ import TableHeader from '../../components/tableHeader';
18
+ import TableHeaderCell from '../../components/tableHeaderCell';
19
+ import TableRow from '../../components/tableRow';
20
+ import TableCell from '../../components/tableCell';
21
+ import Form from '../../components/form';
22
+ import TextField from '../../components/textField';
23
+ import CopyField from '../../components/copyField';
24
+ import EmptyBox from '../../components/emptyBox';
25
+ import Button from '../../components/button';
26
+ import { Center, Cluster, Stack } from '../../components/layout';
27
+ var firstKeys = [
28
+ { id: 'k1', name: 'CI pipeline', prefix: 'acme_live_7Hd2', created: 'Oct 3, 2026', lastUsed: 'Today' },
29
+ { id: 'k2', name: 'Reporting script', prefix: 'acme_live_Qm4x', created: 'Aug 19, 2026', lastUsed: 'Nov 20, 2026' },
30
+ ];
31
+ // The key the server made. A real app gets it once, in the reply to the create request, and never again.
32
+ var madeKey = 'acme_live_4f9kQ27xLmT4vB8cRw1ZdN6yHs3P';
33
+ var prefixLength = 14;
34
+ export default function ApiKeysList() {
35
+ // Opens on the new key, as if the person just chose Create. The list already holds it, without the key.
36
+ var _a = useState(function () { return __spreadArray([
37
+ { id: 'k3', name: 'Deploy bot', prefix: madeKey.slice(0, prefixLength), created: 'Today', lastUsed: 'Never used' }
38
+ ], firstKeys, true); }), keys = _a[0], setKeys = _a[1];
39
+ var _b = useState(true), open = _b[0], setOpen = _b[1];
40
+ var _c = useState(madeKey), shownKey = _c[0], setShownKey = _c[1];
41
+ var _d = useState(''), name = _d[0], setName = _d[1];
42
+ var _e = useState(''), nameError = _e[0], setNameError = _e[1];
43
+ var _f = useState(false), creating = _f[0], setCreating = _f[1];
44
+ var _g = useState(null), confirming = _g[0], setConfirming = _g[1];
45
+ var _h = useState(null), revoking = _h[0], setRevoking = _h[1];
46
+ var timers = useRef([]);
47
+ // Gives each new key its own id, so no two rows share a key.
48
+ var keyCount = useRef(0);
49
+ var toastIds = useRef([]);
50
+ // On unmount it stops every request and closes every toast it opened.
51
+ useEffect(function () { return function () {
52
+ timers.current.forEach(clearTimeout);
53
+ toastIds.current.forEach(function (id) { return dismissToast(id); });
54
+ toastIds.current = [];
55
+ }; }, []);
56
+ // Stands in for the request to the server.
57
+ function later(callback, ms) {
58
+ timers.current.push(setTimeout(callback, ms));
59
+ }
60
+ function handleOpen() {
61
+ setName('');
62
+ setNameError('');
63
+ setShownKey(null);
64
+ setOpen(true);
65
+ }
66
+ // Escape, a click outside and Cancel close the first step, except while the request runs.
67
+ // Once the key shows, only 'Done' closes it, so a stray click cannot throw the key away.
68
+ function handleClose() {
69
+ if (creating || shownKey)
70
+ return;
71
+ setOpen(false);
72
+ }
73
+ // 'Done' drops the key from the page. It is not kept anywhere else.
74
+ function handleDone() {
75
+ setOpen(false);
76
+ setShownKey(null);
77
+ }
78
+ function handleCreate() {
79
+ if (creating)
80
+ return;
81
+ if (!name.trim()) {
82
+ setNameError('Enter a name for the key.');
83
+ return;
84
+ }
85
+ setNameError('');
86
+ setCreating(true);
87
+ later(function () {
88
+ setCreating(false);
89
+ keyCount.current += 1;
90
+ var id = "new-".concat(keyCount.current);
91
+ setKeys(function (list) { return __spreadArray([{ id: id, name: name.trim(), prefix: madeKey.slice(0, prefixLength), created: 'Today', lastUsed: 'Never used' }], list, true); });
92
+ setShownKey(madeKey);
93
+ }, 1200);
94
+ }
95
+ function handleRevoke(key) {
96
+ if (revoking)
97
+ return;
98
+ setRevoking(key.id);
99
+ later(function () {
100
+ setRevoking(null);
101
+ setConfirming(null);
102
+ setKeys(function (list) { return list.filter(function (k) { return k.id !== key.id; }); });
103
+ toastIds.current.push(toast({ type: 'success', message: "".concat(key.name, " key revoked.") }));
104
+ }, 1200);
105
+ }
106
+ return (<Center width="page">
107
+ {/* A real app mounts one Toaster near its root. */}
108
+ <Toaster />
109
+ <Stack gap="large">
110
+ <Stack gap="small">
111
+ <Cluster justify="between">
112
+ <Heading level={1} size="h5">API keys</Heading>
113
+ <Button size="small" type="primary" state="enabled" label="Create Key" decoIcon="Plus" onClickButton={handleOpen}/>
114
+ </Cluster>
115
+ <Paragraph tone="secondary" size="body2" measure="none">Keys let a script or a service use Acme as you. The list shows the start of each key, never the whole key.</Paragraph>
116
+ </Stack>
117
+
118
+ {keys.length > 0 ? (<TableContainer>
119
+ <TableHeader>
120
+ <TableRow>
121
+ <TableHeaderCell>Name</TableHeaderCell>
122
+ <TableHeaderCell width="150px">Key</TableHeaderCell>
123
+ <TableHeaderCell width="100px">Created</TableHeaderCell>
124
+ <TableHeaderCell width="100px">Last used</TableHeaderCell>
125
+ <TableHeaderCell width="200px">Actions</TableHeaderCell>
126
+ </TableRow>
127
+ </TableHeader>
128
+ {keys.map(function (k) { return (<TableRow key={k.id}>
129
+ <TableCell>{k.name}</TableCell>
130
+ <TableCell width="150px">
131
+ <Paragraph mono size="body2" measure="none">{k.prefix}…</Paragraph>
132
+ </TableCell>
133
+ <TableCell width="100px">{k.created}</TableCell>
134
+ <TableCell width="100px">{k.lastUsed}</TableCell>
135
+ {/* A fixed last column keeps every row's Buttons in one place, so they do not jump when they change. */}
136
+ <TableCell width="200px">
137
+ {confirming === k.id ? (<Stack gap="small">
138
+ <Paragraph size="body2" measure="none">Revoke {k.name}?</Paragraph>
139
+ <Cluster gap="small">
140
+ <Button size="small" type="tertiary" state={revoking === k.id ? 'disabled' : 'enabled'} label="Cancel" aria-label={"Cancel revoking ".concat(k.name)} onClickButton={function () { return setConfirming(null); }}/>
141
+ <Button size="small" type="primary" color="danger" state="enabled" label="Revoke" aria-label={"Revoke ".concat(k.name)} loading={revoking === k.id} onClickButton={function () { return handleRevoke(k); }}/>
142
+ </Cluster>
143
+ </Stack>) : (<Button size="small" type="tertiary" state={revoking ? 'disabled' : 'enabled'} label="Revoke" aria-label={"Revoke ".concat(k.name)} onClickButton={function () { return setConfirming(k.id); }}/>)}
144
+ </TableCell>
145
+ </TableRow>); })}
146
+ </TableContainer>) : (<EmptyBox size="small" icon="KeyRound" text="No API keys" secondText="Keys you create appear here."/>)}
147
+ </Stack>
148
+
149
+ <Modal isOpen={open} size="medium" initialFocus="body" title={shownKey ? 'Key Created' : 'Create Key'} onClose={handleClose} actions={shownKey ? (<Button size="small" type="primary" state="enabled" label="Done" onClickButton={handleDone}/>) : (<>
150
+ <Button size="small" type="tertiary" state={creating ? 'disabled' : 'enabled'} label="Cancel" onClickButton={handleClose}/>
151
+ <Button size="small" type="primary" state="enabled" label="Create" loading={creating} onClickButton={handleCreate}/>
152
+ </>)}>
153
+ {shownKey ? (<Stack gap="medium">
154
+ <Paragraph measure="none">Use this key where the service asks for one. Anyone who has it can use Acme as you.</Paragraph>
155
+ {/* `reveal="once"` adds the line that says the key will not show again. */}
156
+ <CopyField id="api-keys-key" label="API key" value={shownKey} mono reveal="once"/>
157
+ </Stack>) : (<Form aria-label="Create key" onSubmit={handleCreate}>
158
+ <TextField id="api-keys-name" label="Name" value={name} disabled={creating} error={Boolean(nameError)} errorText={nameError} helperText="Say what will use it, such as CI pipeline." onChange={function (e) { setName(e.target.value); setNameError(''); }}/>
159
+ </Form>)}
160
+ </Modal>
161
+ </Center>);
162
+ }