oneslash-design-system 2.28.0 → 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.
- package/README.md +1 -1
- package/dist/DESIGN.md +31 -1
- package/dist/cases/about-page.md +2 -0
- package/dist/cases/accept-invite.md +2 -0
- package/dist/cases/account-menu.md +2 -0
- package/dist/cases/activity-timeline.md +2 -0
- package/dist/cases/admin-inbox.md +2 -0
- package/dist/cases/agent-asks-before-risky-action.md +3 -1
- package/dist/cases/agent-cancels-when-unanswered.md +2 -0
- package/dist/cases/agent-changes-review/all-at-once.d.ts +1 -0
- package/dist/cases/agent-changes-review/all-at-once.jsx +238 -0
- package/dist/cases/agent-changes-review/per-change.d.ts +1 -0
- package/dist/cases/agent-changes-review/per-change.jsx +203 -0
- package/dist/cases/agent-changes-review.md +585 -0
- package/dist/cases/agent-handoff/to-agent.d.ts +1 -0
- package/dist/cases/agent-handoff/to-agent.jsx +53 -0
- package/dist/cases/agent-handoff/to-person.d.ts +1 -0
- package/dist/cases/agent-handoff/to-person.jsx +84 -0
- package/dist/cases/agent-handoff.md +231 -0
- package/dist/cases/agent-memory/list.d.ts +1 -0
- package/dist/cases/agent-memory/list.jsx +256 -0
- package/dist/cases/agent-memory.md +354 -0
- package/dist/cases/agent-options.md +2 -0
- package/dist/cases/agent-pending-reply/steps.jsx +70 -21
- package/dist/cases/agent-pending-reply.md +74 -27
- package/dist/cases/agent-permissions/levels.d.ts +3 -0
- package/dist/cases/agent-permissions/levels.jsx +49 -0
- package/dist/cases/agent-permissions/per-tool.d.ts +3 -0
- package/dist/cases/agent-permissions/per-tool.jsx +178 -0
- package/dist/cases/agent-permissions.md +314 -0
- package/dist/cases/agent-plan-proposal/changes.jsx +18 -11
- package/dist/cases/agent-plan-proposal/steps.jsx +11 -4
- package/dist/cases/agent-plan-proposal.md +36 -21
- package/dist/cases/agent-question.md +2 -0
- package/dist/cases/agent-refuses-clearly.md +2 -0
- package/dist/cases/agent-run-failure/limit-reached.d.ts +1 -0
- package/dist/cases/agent-run-failure/limit-reached.jsx +172 -0
- package/dist/cases/agent-run-failure/step-failed.d.ts +3 -0
- package/dist/cases/agent-run-failure/step-failed.jsx +187 -0
- package/dist/cases/agent-run-failure.md +500 -0
- package/dist/cases/agent-says-what-it-is.md +2 -0
- package/dist/cases/agent-says-where-it-stopped.md +27 -0
- package/dist/cases/agent-settings.md +2 -0
- package/dist/cases/agent-shows-progress.md +2 -0
- package/dist/cases/agent-shows-sources.md +2 -0
- package/dist/cases/api-keys/list.jsx +30 -3
- package/dist/cases/api-keys.md +37 -3
- package/dist/cases/app-shell.md +2 -0
- package/dist/cases/artifact-card.md +2 -0
- package/dist/cases/ask-page.md +2 -0
- package/dist/cases/auth-gate-loading.md +2 -0
- package/dist/cases/billing-page.md +2 -0
- package/dist/cases/blog-index.md +2 -0
- package/dist/cases/breadcrumb.md +2 -0
- package/dist/cases/breakdown-list.md +2 -0
- package/dist/cases/bulk-actions/list.d.ts +1 -0
- package/dist/cases/bulk-actions/list.jsx +209 -0
- package/dist/cases/bulk-actions/paged-table.d.ts +1 -0
- package/dist/cases/bulk-actions/paged-table.jsx +246 -0
- package/dist/cases/bulk-actions.md +559 -0
- package/dist/cases/changelog.md +2 -0
- package/dist/cases/chart.md +2 -0
- package/dist/cases/check-your-email.md +2 -0
- package/dist/cases/code-sample.md +2 -0
- package/dist/cases/collapsible-search.md +2 -0
- package/dist/cases/comment-thread.md +2 -0
- package/dist/cases/comparison-page/table.d.ts +1 -0
- package/dist/cases/comparison-page/table.jsx +97 -0
- package/dist/cases/comparison-page.md +156 -0
- package/dist/cases/composer-limit.md +2 -0
- package/dist/cases/confirm-destructive-action.md +2 -0
- package/dist/cases/confirm-dialogs.md +2 -0
- package/dist/cases/connection-status/card.d.ts +1 -0
- package/dist/cases/connection-status/card.jsx +97 -0
- package/dist/cases/connection-status/row.d.ts +1 -0
- package/dist/cases/connection-status/row.jsx +120 -0
- package/dist/cases/connection-status.md +330 -0
- package/dist/cases/contact-page.md +2 -0
- package/dist/cases/conversation-starters.md +2 -0
- package/dist/cases/cookie-choice.md +2 -0
- package/dist/cases/create-modal.md +2 -0
- package/dist/cases/danger-zone.md +2 -0
- package/dist/cases/dashboard.md +2 -0
- package/dist/cases/data-table-page.md +2 -0
- package/dist/cases/date-field.md +2 -0
- package/dist/cases/device-login.md +2 -0
- package/dist/cases/docs-component-page.md +2 -0
- package/dist/cases/email-confirmed.md +2 -0
- package/dist/cases/empty-list.md +2 -0
- package/dist/cases/empty-lists.md +2 -0
- package/dist/cases/empty-not-set-up.md +2 -0
- package/dist/cases/empty-search.md +2 -0
- package/dist/cases/error-page.md +2 -0
- package/dist/cases/faq.md +2 -0
- package/dist/cases/feature-grid.md +2 -0
- package/dist/cases/feedback-form.md +2 -0
- package/dist/cases/file-upload.md +2 -0
- package/dist/cases/filter-menu.md +2 -0
- package/dist/cases/forgot-password.md +2 -0
- package/dist/cases/form-errors.md +2 -0
- package/dist/cases/image-viewer.md +2 -0
- package/dist/cases/import-checklist.md +2 -0
- package/dist/cases/inline-form-feedback.md +2 -0
- package/dist/cases/integrations-list/nested.jsx +1 -1
- package/dist/cases/integrations-list/rows.jsx +1 -1
- package/dist/cases/integrations-list.md +6 -4
- package/dist/cases/invite-member.md +2 -0
- package/dist/cases/invoice-list.md +2 -0
- package/dist/cases/landing-hero.md +2 -0
- package/dist/cases/leaderboard.md +2 -0
- package/dist/cases/legal-page.md +2 -0
- package/dist/cases/load-failure.md +2 -0
- package/dist/cases/log-out-confirm.md +2 -0
- package/dist/cases/login-page.md +2 -0
- package/dist/cases/long-form-page.md +2 -0
- package/dist/cases/master-detail.md +2 -0
- package/dist/cases/members-list/rows.jsx +37 -6
- package/dist/cases/members-list/table.jsx +37 -6
- package/dist/cases/members-list.md +83 -12
- package/dist/cases/mention-list.md +2 -0
- package/dist/cases/message-actions.md +2 -0
- package/dist/cases/message-attachments.md +2 -0
- package/dist/cases/message-composer/with-tools.jsx +17 -7
- package/dist/cases/message-composer.md +28 -11
- package/dist/cases/message-edit.md +2 -0
- package/dist/cases/message-reactions.md +2 -0
- package/dist/cases/message-row.md +2 -0
- package/dist/cases/message-send-failure/needs-a-person.d.ts +1 -0
- package/dist/cases/message-send-failure/needs-a-person.jsx +116 -0
- package/dist/cases/message-send-failure/retrying.d.ts +1 -0
- package/dist/cases/message-send-failure/retrying.jsx +116 -0
- package/dist/cases/message-send-failure.md +308 -0
- package/dist/cases/mobile-menu.md +2 -0
- package/dist/cases/newsletter-signup.md +2 -0
- package/dist/cases/no-access/page.d.ts +1 -0
- package/dist/cases/no-access/page.jsx +37 -0
- package/dist/cases/no-access/read-only.d.ts +1 -0
- package/dist/cases/no-access/read-only.jsx +33 -0
- package/dist/cases/no-access.md +147 -0
- package/dist/cases/not-found-page.md +2 -0
- package/dist/cases/notification-menu.md +2 -0
- package/dist/cases/number-format.md +2 -0
- package/dist/cases/oauth-consent.md +2 -0
- package/dist/cases/on-off-settings.md +2 -0
- package/dist/cases/on-this-page.md +2 -0
- package/dist/cases/onboarding.md +2 -0
- package/dist/cases/one-main-action.md +2 -0
- package/dist/cases/overflow-menu.md +2 -0
- package/dist/cases/page-end.md +2 -0
- package/dist/cases/page-header.md +2 -0
- package/dist/cases/paged-card.md +2 -0
- package/dist/cases/password-gate.md +2 -0
- package/dist/cases/payment-method.md +2 -0
- package/dist/cases/people-row.md +2 -0
- package/dist/cases/phone-navigation.md +2 -0
- package/dist/cases/plan-change-confirm.md +2 -0
- package/dist/cases/plan-comparison.md +3 -1
- package/dist/cases/plan-picker.md +4 -1
- package/dist/cases/plan-sign-off.md +2 -0
- package/dist/cases/pricing-section.md +5 -1
- package/dist/cases/product-cards.md +2 -0
- package/dist/cases/product-demo/scripted.d.ts +3 -0
- package/dist/cases/product-demo/scripted.jsx +95 -0
- package/dist/cases/product-demo/still.d.ts +1 -0
- package/dist/cases/product-demo/still.jsx +20 -0
- package/dist/cases/product-demo.md +221 -0
- package/dist/cases/profile-form.md +2 -0
- package/dist/cases/quick-switcher.md +2 -0
- package/dist/cases/range-switch.md +2 -0
- package/dist/cases/rename.md +2 -0
- package/dist/cases/reply-feedback.md +2 -0
- package/dist/cases/reply-sources.md +2 -0
- package/dist/cases/route-loading.md +2 -0
- package/dist/cases/scope-picker.md +2 -0
- package/dist/cases/section-index.md +2 -0
- package/dist/cases/session-expired/in-place.d.ts +1 -0
- package/dist/cases/session-expired/in-place.jsx +63 -0
- package/dist/cases/session-expired/redirect.d.ts +1 -0
- package/dist/cases/session-expired/redirect.jsx +62 -0
- package/dist/cases/session-expired.md +204 -0
- package/dist/cases/set-new-password.md +2 -0
- package/dist/cases/settings-page.md +2 -0
- package/dist/cases/settings-save.md +2 -0
- package/dist/cases/side-pane.md +2 -0
- package/dist/cases/sidebar-nav.md +2 -0
- package/dist/cases/sign-up-page.md +3 -0
- package/dist/cases/signup-from-site/plain.d.ts +1 -0
- package/dist/cases/signup-from-site/plain.jsx +125 -0
- package/dist/cases/signup-from-site/with-plan.d.ts +4 -0
- package/dist/cases/signup-from-site/with-plan.jsx +151 -0
- package/dist/cases/signup-from-site.md +351 -0
- package/dist/cases/site-footer.md +2 -0
- package/dist/cases/site-header/links.d.ts +3 -1
- package/dist/cases/site-header/links.jsx +6 -2
- package/dist/cases/site-header.md +11 -3
- package/dist/cases/site-matches-app.md +32 -0
- package/dist/cases/site-search.md +2 -0
- package/dist/cases/slash-command-list.md +2 -0
- package/dist/cases/stat-row.md +2 -0
- package/dist/cases/status-label.md +3 -1
- package/dist/cases/success-feedback.md +2 -0
- package/dist/cases/tabbed-panels.md +2 -0
- package/dist/cases/tag-filter.md +2 -0
- package/dist/cases/task-header.md +2 -0
- package/dist/cases/theme-switcher.md +2 -0
- package/dist/cases/type-to-confirm.md +2 -0
- package/dist/cases/typing-and-status.md +2 -0
- package/dist/cases/unsaved-changes-guard.md +2 -0
- package/dist/cases/upgrade-prompt.md +2 -0
- package/dist/cases/usage-meters.md +2 -0
- package/dist/cases.json +1494 -42
- package/dist/components/checkBox.d.ts +5 -1
- package/dist/components/checkBox.jsx +23 -9
- package/dist/components/diff.d.ts +29 -0
- package/dist/components/diff.jsx +35 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/internal/diff.d.ts +17 -0
- package/dist/internal/diff.js +44 -0
- package/dist/native-mapping.json +9 -2
- package/dist/stories/AgentPermissions.probe.stories.d.ts +7 -0
- package/dist/stories/AgentPermissions.probe.stories.jsx +18 -0
- package/dist/stories/AgentRunFailure.probe.stories.d.ts +6 -0
- package/dist/stories/AgentRunFailure.probe.stories.jsx +12 -0
- package/dist/stories/Cases.generated.stories.d.ts +24 -0
- package/dist/stories/Cases.generated.stories.jsx +48 -0
- package/dist/stories/Checkbox.stories.d.ts +2 -0
- package/dist/stories/Checkbox.stories.jsx +18 -0
- package/dist/stories/Diff.stories.d.ts +9 -0
- package/dist/stories/Diff.stories.jsx +40 -0
- package/dist/stories/ProductDemo.probe.stories.d.ts +6 -0
- package/dist/stories/ProductDemo.probe.stories.jsx +12 -0
- package/dist/stories/SignupFromSite.probe.stories.d.ts +7 -0
- package/dist/stories/SignupFromSite.probe.stories.jsx +17 -0
- package/dist/stories/SiteHeader.probe.stories.d.ts +6 -0
- package/dist/stories/SiteHeader.probe.stories.jsx +13 -0
- package/package.json +1 -1
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
The agent is working on a request in the thread, and its reply is not ready yet.
|
|
4
4
|
|
|
5
|
+
For: an agent
|
|
6
|
+
|
|
5
7
|
## Do
|
|
6
8
|
|
|
7
9
|
- Follow the rule 'An agent shows its progress': one row in the thread, where the reply will appear.
|
|
@@ -10,11 +12,12 @@ The agent is working on a request in the thread, and its reply is not ready yet.
|
|
|
10
12
|
- Show the steps in a `StepList`: the finished ones with a check, and the current one running, in plain words.
|
|
11
13
|
- Leave out steps the agent has not started, unless it knows them.
|
|
12
14
|
- Put the only 'Stop' in the row's `footer`, for the whole run, and under the reply while it is written.
|
|
13
|
-
- Make 'Stop' `loading` while the run stops. Once
|
|
15
|
+
- 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.
|
|
14
16
|
- 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.'
|
|
15
17
|
- Say 'Stopped. Nothing was written.' when a streaming reply is stopped before any text.
|
|
16
18
|
- Keep the text and say 'Stopped before the reply was finished.' when a streaming reply is stopped after some text.
|
|
17
|
-
-
|
|
19
|
+
- Follow the case 'Run that stopped short' when a run with steps fails or stops at a limit.
|
|
20
|
+
- 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'.
|
|
18
21
|
- Turn the row into the agent's reply when the run is done, and remove 'Stop'.
|
|
19
22
|
- Move focus to the message box when 'Stop' goes away and no other control takes its place.
|
|
20
23
|
- Announce the changing part politely, such as the running step: the app wraps it in a polite live region, since `StepList` has none.
|
|
@@ -32,7 +35,7 @@ The agent is working on a request in the thread, and its reply is not ready yet.
|
|
|
32
35
|
|
|
33
36
|
Use when: The run has steps to show.
|
|
34
37
|
|
|
35
|
-
Uses: `
|
|
38
|
+
Uses: `Button`, `Center`, `Cluster`, `Heading`, `Message`, `Paragraph`, `Stack`, `StepList`, `Tag`, `TimeStamp`, `UserImage`
|
|
36
39
|
|
|
37
40
|
```tsx
|
|
38
41
|
'use client';
|
|
@@ -45,7 +48,6 @@ import TimeStamp from 'oneslash-design-system/components/timeStamp';
|
|
|
45
48
|
import Heading from 'oneslash-design-system/components/heading';
|
|
46
49
|
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
47
50
|
import Button from 'oneslash-design-system/components/button';
|
|
48
|
-
import Alert from 'oneslash-design-system/components/alert';
|
|
49
51
|
import StepList, { type StepListStep } from 'oneslash-design-system/components/stepList';
|
|
50
52
|
import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
|
|
51
53
|
|
|
@@ -64,13 +66,23 @@ const plan = [
|
|
|
64
66
|
|
|
65
67
|
const reply = "The pricing page still shows last year's prices. Pro is $12 there, and the new plans set it at $15.";
|
|
66
68
|
|
|
69
|
+
// Why the step failed. A real app takes it from the server's answer.
|
|
70
|
+
const failReason = 'Could not open the pricing page. It did not answer in time.';
|
|
71
|
+
|
|
67
72
|
type Phase = 'running' | 'stopping' | 'stopped' | 'failed' | 'done';
|
|
68
73
|
|
|
69
|
-
// Finished steps keep a check, the current one runs, and steps the agent has not started are not shown.
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
);
|
|
74
|
+
// Finished steps keep a check, the current one runs, and while it runs the steps the agent has not started are not shown.
|
|
75
|
+
// A failed step says why, as the case 'Run that stopped short' does, and the steps after it wait. Once the run is
|
|
76
|
+
// stopped, the step it stopped on stays failed after 'Stop Here' and is cancelled after 'Stop', and the steps after it are cancelled.
|
|
77
|
+
function stepsUpTo(current: number, phase: Phase, endedOnFailure: boolean): StepListStep[] {
|
|
78
|
+
const shown = phase === 'failed' || phase === 'stopped' ? plan : plan.slice(0, current + 1);
|
|
79
|
+
return shown.map((s, i) => {
|
|
80
|
+
if (i < current) return { label: s.done, status: 'done' };
|
|
81
|
+
if (i > current) return { label: s.doing, status: phase === 'stopped' ? 'cancelled' : 'waiting' };
|
|
82
|
+
if (phase === 'failed') return { label: s.doing, status: 'failed', detail: failReason };
|
|
83
|
+
if (phase === 'stopped') return { label: s.doing, status: endedOnFailure ? 'failed' : 'cancelled' };
|
|
84
|
+
return { label: s.doing, status: 'running' };
|
|
85
|
+
});
|
|
74
86
|
}
|
|
75
87
|
|
|
76
88
|
function secondsLine(seconds: number) {
|
|
@@ -99,9 +111,13 @@ export default function AgentPendingReplySteps() {
|
|
|
99
111
|
const step = useRef<ReturnType<typeof setTimeout>>();
|
|
100
112
|
const cancel = useRef<ReturnType<typeof setTimeout>>();
|
|
101
113
|
const runAgainButton = useRef<HTMLButtonElement | HTMLAnchorElement>(null);
|
|
114
|
+
const stopHereButton = useRef<HTMLButtonElement | HTMLAnchorElement>(null);
|
|
115
|
+
const stopButton = useRef<HTMLButtonElement | HTMLAnchorElement>(null);
|
|
116
|
+
// Whether the run ended on the failed step ('Stop Here') or was stopped while a step ran ('Stop').
|
|
117
|
+
const [endedOnFailure, setEndedOnFailure] = useState(false);
|
|
102
118
|
// Where focus goes after the next render, once the element it goes to is on screen.
|
|
103
119
|
const focusNext = useRef<() => void>();
|
|
104
|
-
// The first live run fails at the pricing page, so the example shows the failed row; 'Try Again' then works.
|
|
120
|
+
// The first live run fails at the pricing page, so the example shows the failed row; 'Try Step Again' then works.
|
|
105
121
|
const triedAgain = useRef(false);
|
|
106
122
|
|
|
107
123
|
// On unmount it stops the run, its clock and the cancel request.
|
|
@@ -128,6 +144,8 @@ export default function AgentPendingReplySteps() {
|
|
|
128
144
|
if (at === 2 && !triedAgain.current) {
|
|
129
145
|
stopTimers();
|
|
130
146
|
setPhase('failed');
|
|
147
|
+
// 'Stop' had focus and is gone, so focus goes to the row's first Button.
|
|
148
|
+
focusNext.current = () => stopHereButton.current?.focus();
|
|
131
149
|
return;
|
|
132
150
|
}
|
|
133
151
|
if (at === plan.length - 1) {
|
|
@@ -140,19 +158,36 @@ export default function AgentPendingReplySteps() {
|
|
|
140
158
|
}, 1500);
|
|
141
159
|
}
|
|
142
160
|
|
|
143
|
-
|
|
161
|
+
// Runs from `from` on. The steps before it are done and stay done.
|
|
162
|
+
function runFrom(from: number) {
|
|
144
163
|
stopTimers();
|
|
145
164
|
setPhase('running');
|
|
146
|
-
|
|
165
|
+
setEndedOnFailure(false);
|
|
166
|
+
setCurrent(from);
|
|
147
167
|
setSeconds(0);
|
|
148
168
|
setStartedAt(new Date());
|
|
149
169
|
tick.current = setInterval(() => setSeconds((s) => s + 1), 1000);
|
|
150
|
-
advance(
|
|
170
|
+
advance(from);
|
|
151
171
|
}
|
|
152
172
|
|
|
153
|
-
function
|
|
173
|
+
function runLive() {
|
|
174
|
+
runFrom(0);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// Only the failed step and the ones after it run again. 'Stop' takes the place of the Buttons, so it gets focus.
|
|
178
|
+
function tryStepAgain() {
|
|
179
|
+
if (phase !== 'failed') return;
|
|
154
180
|
triedAgain.current = true;
|
|
155
|
-
|
|
181
|
+
runFrom(current);
|
|
182
|
+
focusNext.current = () => stopButton.current?.focus();
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// The run ends on the failed step. 'Run Again' takes the place of the Buttons; in a real app, the message box.
|
|
186
|
+
function stopHere() {
|
|
187
|
+
if (phase !== 'failed') return;
|
|
188
|
+
setEndedOnFailure(true);
|
|
189
|
+
setPhase('stopped');
|
|
190
|
+
focusNext.current = () => runAgainButton.current?.focus();
|
|
156
191
|
}
|
|
157
192
|
|
|
158
193
|
// Stop asks the server to end the run. The row says it stopped only once the run has ended.
|
|
@@ -171,6 +206,16 @@ export default function AgentPendingReplySteps() {
|
|
|
171
206
|
|
|
172
207
|
const working = phase === 'running' || phase === 'stopping';
|
|
173
208
|
|
|
209
|
+
// What was done, under the list. Empty while the run goes on. A real app takes the count from the server's answer.
|
|
210
|
+
const statusLine =
|
|
211
|
+
phase === 'failed'
|
|
212
|
+
? `${current} of ${plan.length} steps are done. Nothing was changed.`
|
|
213
|
+
: phase === 'stopped'
|
|
214
|
+
? current === 0
|
|
215
|
+
? 'Stopped. Nothing was changed.'
|
|
216
|
+
: `Stopped after ${current} of ${plan.length} steps. The rest of the plan was not done. Nothing was changed.`
|
|
217
|
+
: '';
|
|
218
|
+
|
|
174
219
|
return (
|
|
175
220
|
<Center width="page">
|
|
176
221
|
<Stack gap="large">
|
|
@@ -194,12 +239,17 @@ export default function AgentPendingReplySteps() {
|
|
|
194
239
|
working ? (
|
|
195
240
|
// The only Stop, on the row for the whole run. It shows loading while the run is stopping.
|
|
196
241
|
<Cluster>
|
|
197
|
-
<Button size="small" type="secondary" state="enabled" label="Stop" loading={phase === 'stopping'} onClickButton={stop} />
|
|
242
|
+
<Button ref={stopButton} size="small" type="secondary" state="enabled" label="Stop" loading={phase === 'stopping'} onClickButton={stop} />
|
|
198
243
|
</Cluster>
|
|
199
244
|
) : phase === 'failed' ? (
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
245
|
+
// As in the case 'Run that stopped short': how long it waits, then 'Stop Here' and 'Try Step Again' as the primary Button.
|
|
246
|
+
<Stack gap="small">
|
|
247
|
+
<Paragraph size="caption" tone="secondary" measure="none">Waits 10 more minutes, then stops here.</Paragraph>
|
|
248
|
+
<Cluster gap="small">
|
|
249
|
+
<Button ref={stopHereButton} size="small" type="tertiary" state="enabled" label="Stop Here" onClickButton={stopHere} />
|
|
250
|
+
<Button size="small" type="primary" state="enabled" label="Try Step Again" onClickButton={tryStepAgain} />
|
|
251
|
+
</Cluster>
|
|
252
|
+
</Stack>
|
|
203
253
|
) : phase === 'stopped' ? (
|
|
204
254
|
<Cluster>
|
|
205
255
|
<Button ref={runAgainButton} size="small" type="secondary" state="enabled" label="Run Again" onClickButton={runLive} />
|
|
@@ -210,17 +260,14 @@ export default function AgentPendingReplySteps() {
|
|
|
210
260
|
{phase === 'done' ? (
|
|
211
261
|
// The run is over: the row is the reply, and Stop is gone. A real app moves focus to the message box.
|
|
212
262
|
<Paragraph measure="none">{reply}</Paragraph>
|
|
213
|
-
) : phase === 'stopped' ? (
|
|
214
|
-
<Paragraph measure="none">Stopped. Nothing was changed.</Paragraph>
|
|
215
263
|
) : (
|
|
216
|
-
// A real app wraps
|
|
264
|
+
// A real app wraps the running step in a polite live region, since StepList has none.
|
|
265
|
+
// After a stop the steps stay, as the rule 'An agent that stops short says what it finished and what is left' says.
|
|
217
266
|
<Stack gap="medium">
|
|
218
267
|
{working && <Paragraph size="caption" tone="secondary" measure="none">{secondsLine(seconds)}</Paragraph>}
|
|
219
|
-
<StepList aria-label="Acme Agent's steps" steps={stepsUpTo(current, phase
|
|
220
|
-
{
|
|
221
|
-
|
|
222
|
-
<Alert type="error" variant="inline" autoDismiss={false} message="Acme Agent could not open the pricing page. Nothing was changed." />
|
|
223
|
-
)}
|
|
268
|
+
<StepList aria-label="Acme Agent's steps" steps={stepsUpTo(current, phase, endedOnFailure)} />
|
|
269
|
+
{/* 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. */}
|
|
270
|
+
<Paragraph role="status" measure="none">{statusLine}</Paragraph>
|
|
224
271
|
</Stack>
|
|
225
272
|
)}
|
|
226
273
|
</Message>
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import Heading from '../../components/heading';
|
|
4
|
+
import Paragraph from '../../components/paragraph';
|
|
5
|
+
import FormField from '../../components/formField';
|
|
6
|
+
import RadioGroup from '../../components/radioGroup';
|
|
7
|
+
import SettingsSection from '../../components/settingsSection';
|
|
8
|
+
import { Center, Stack } from '../../components/layout';
|
|
9
|
+
// Three levels, each named for what the agent does at it, with an example. No level lets it do a risky action alone.
|
|
10
|
+
var levels = [
|
|
11
|
+
{ value: 'suggest', label: 'Only suggest changes', secondLabel: 'It drafts a fix and proposes it in the thread. It changes nothing itself.' },
|
|
12
|
+
{ value: 'ask-every', label: 'Ask before every change', secondLabel: 'It asks before every change, even to its own drafts.' },
|
|
13
|
+
{ 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.' },
|
|
14
|
+
];
|
|
15
|
+
// A real app reads `canChange` from the person's role. Only an admin can change how the agent works.
|
|
16
|
+
// The example shows an admin's view. A real app passes `canChange` from the person's role.
|
|
17
|
+
export default function AgentPermissionsLevels(_a) {
|
|
18
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.canChange, canChange = _c === void 0 ? true : _c;
|
|
19
|
+
var _d = useState('ask-every'), level = _d[0], setLevel = _d[1];
|
|
20
|
+
var _e = useState(false), saving = _e[0], setSaving = _e[1];
|
|
21
|
+
var timer = useRef();
|
|
22
|
+
// Stops the request if the example goes away before it ends.
|
|
23
|
+
useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
|
|
24
|
+
// The choice stands alone, so it saves as soon as it is made. Nothing shows when it works.
|
|
25
|
+
// While the request runs the group is disabled. A real app puts the old level back if the save fails,
|
|
26
|
+
// and says why in the FormField's error line: 'Could not save. Try again.'
|
|
27
|
+
function choose(next) {
|
|
28
|
+
if (saving || next === level)
|
|
29
|
+
return;
|
|
30
|
+
setLevel(next);
|
|
31
|
+
setSaving(true);
|
|
32
|
+
// Stands in for the request to the server.
|
|
33
|
+
timer.current = setTimeout(function () { return setSaving(false); }, 900);
|
|
34
|
+
}
|
|
35
|
+
return (<Center width="page">
|
|
36
|
+
<Stack gap="xlarge">
|
|
37
|
+
<Stack gap="small">
|
|
38
|
+
<Heading level={1} size="h5">Agent</Heading>
|
|
39
|
+
<Paragraph tone="secondary" size="body2" measure="none">How Acme Agent works for everyone in this workspace.</Paragraph>
|
|
40
|
+
{!canChange && <Paragraph tone="secondary" size="body2" measure="none">Only admins can change these settings. Your admin is Dana Lee.</Paragraph>}
|
|
41
|
+
</Stack>
|
|
42
|
+
<SettingsSection title="What Acme Agent does alone" description="Your choice saves as soon as you make it.">
|
|
43
|
+
<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.">
|
|
44
|
+
{function (f) { return (<RadioGroup id={f.id} aria-describedby={f['aria-describedby']} aria-label="Level" options={levels} selectedValue={level} disabled={!canChange || saving} onChange={choose}/>); }}
|
|
45
|
+
</FormField>
|
|
46
|
+
</SettingsSection>
|
|
47
|
+
</Stack>
|
|
48
|
+
</Center>);
|
|
49
|
+
}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
import { useEffect, useRef, useState } from 'react';
|
|
14
|
+
import Toaster, { toast, dismissToast } from '../../components/toaster';
|
|
15
|
+
import Heading from '../../components/heading';
|
|
16
|
+
import Paragraph from '../../components/paragraph';
|
|
17
|
+
import SegmentedControl from '../../components/segmentedControl';
|
|
18
|
+
import SettingsSection from '../../components/settingsSection';
|
|
19
|
+
import TableContainer from '../../components/tableContainer';
|
|
20
|
+
import TableHeader from '../../components/tableHeader';
|
|
21
|
+
import TableHeaderCell from '../../components/tableHeaderCell';
|
|
22
|
+
import TableRow from '../../components/tableRow';
|
|
23
|
+
import TableCell from '../../components/tableCell';
|
|
24
|
+
import EmptyBox from '../../components/emptyBox';
|
|
25
|
+
import Button from '../../components/button';
|
|
26
|
+
import { Center, Cluster, Stack } from '../../components/layout';
|
|
27
|
+
var tools = [
|
|
28
|
+
{ id: 'read', name: 'Read pages and files', does: 'Reads the workspace to answer and to plan.' },
|
|
29
|
+
{ id: 'post', name: 'Post in threads', does: 'Posts replies and updates in Acme threads.' },
|
|
30
|
+
{ 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.' },
|
|
31
|
+
{ 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.' },
|
|
32
|
+
{ 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.' },
|
|
33
|
+
{ 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.' },
|
|
34
|
+
];
|
|
35
|
+
var allOptions = [
|
|
36
|
+
{ value: 'allow', label: 'Allow' },
|
|
37
|
+
{ value: 'ask', label: 'Ask' },
|
|
38
|
+
{ value: 'never', label: 'Never' },
|
|
39
|
+
];
|
|
40
|
+
// A risky tool offers no 'Allow'.
|
|
41
|
+
var riskyOptions = allOptions.filter(function (o) { return o.value !== 'allow'; });
|
|
42
|
+
var firstClients = [
|
|
43
|
+
{ id: 'cli', name: 'Acme CLI', connected: 'Connected by Ben Carter on Oct 3, 2026' },
|
|
44
|
+
{ id: 'slack', name: 'Acme for Slack', connected: 'Connected by Dana Lee on Aug 19, 2026' },
|
|
45
|
+
{ id: 'reports', name: 'Reporting script', connected: 'Connected by Omar Reyes on Nov 2, 2026' },
|
|
46
|
+
];
|
|
47
|
+
// A real app reads `canChange` from the person's role. Only an admin can change the tools.
|
|
48
|
+
// The example shows an admin's view. A real app passes `canChange` from the person's role.
|
|
49
|
+
export default function AgentPermissionsPerTool(_a) {
|
|
50
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.canChange, canChange = _c === void 0 ? true : _c;
|
|
51
|
+
var _d = useState({ read: 'allow', post: 'allow', edit: 'ask', pull: 'ask', deploy: 'ask', delete: 'never' }), settings = _d[0], setSettings = _d[1];
|
|
52
|
+
var _e = useState(null), savingTool = _e[0], setSavingTool = _e[1];
|
|
53
|
+
var _f = useState(firstClients), clients = _f[0], setClients = _f[1];
|
|
54
|
+
var _g = useState(null), confirming = _g[0], setConfirming = _g[1];
|
|
55
|
+
var _h = useState(null), revoking = _h[0], setRevoking = _h[1];
|
|
56
|
+
var timers = useRef([]);
|
|
57
|
+
var toastIds = useRef([]);
|
|
58
|
+
var cancelRevoke = useRef(null);
|
|
59
|
+
var guideButton = useRef(null);
|
|
60
|
+
// Each row's Revoke button by client id, so focus can move to one when the button that had it is gone.
|
|
61
|
+
var revokeButtons = useRef({});
|
|
62
|
+
// Where focus goes after the next render, once the element it goes to is on screen.
|
|
63
|
+
var focusNext = useRef();
|
|
64
|
+
// On unmount it stops every request and closes every toast it opened.
|
|
65
|
+
useEffect(function () { return function () {
|
|
66
|
+
timers.current.forEach(clearTimeout);
|
|
67
|
+
toastIds.current.forEach(function (id) { return dismissToast(id); });
|
|
68
|
+
toastIds.current = [];
|
|
69
|
+
}; }, []);
|
|
70
|
+
useEffect(function () {
|
|
71
|
+
var move = focusNext.current;
|
|
72
|
+
focusNext.current = undefined;
|
|
73
|
+
move === null || move === void 0 ? void 0 : move();
|
|
74
|
+
});
|
|
75
|
+
// Stands in for the request to the server.
|
|
76
|
+
function later(callback, ms) {
|
|
77
|
+
timers.current.push(setTimeout(callback, ms));
|
|
78
|
+
}
|
|
79
|
+
// Each row's choice stands alone, so it saves as soon as it is made, and shows nothing when it works.
|
|
80
|
+
// SegmentedControl cannot be disabled, so a press on a row that is still saving does nothing.
|
|
81
|
+
function choose(tool, next) {
|
|
82
|
+
if (!canChange || savingTool === tool.id || next === settings[tool.id])
|
|
83
|
+
return;
|
|
84
|
+
setSettings(function (current) {
|
|
85
|
+
var _a;
|
|
86
|
+
return (__assign(__assign({}, current), (_a = {}, _a[tool.id] = next, _a)));
|
|
87
|
+
});
|
|
88
|
+
setSavingTool(tool.id);
|
|
89
|
+
later(function () { return setSavingTool(function (id) { return (id === tool.id ? null : id); }); }, 900);
|
|
90
|
+
}
|
|
91
|
+
// The confirm opens in the row, with focus on 'Cancel'.
|
|
92
|
+
function askToRevoke(c) {
|
|
93
|
+
setConfirming(c.id);
|
|
94
|
+
focusNext.current = function () { var _a; return (_a = cancelRevoke.current) === null || _a === void 0 ? void 0 : _a.focus(); };
|
|
95
|
+
}
|
|
96
|
+
// 'Cancel' goes away with the confirm, so focus goes back to the row's Revoke button.
|
|
97
|
+
function keepClient(c) {
|
|
98
|
+
if (revoking)
|
|
99
|
+
return;
|
|
100
|
+
setConfirming(null);
|
|
101
|
+
focusNext.current = function () { var _a; return (_a = revokeButtons.current[c.id]) === null || _a === void 0 ? void 0 : _a.focus(); };
|
|
102
|
+
}
|
|
103
|
+
function revoke(c) {
|
|
104
|
+
var _a;
|
|
105
|
+
if (revoking)
|
|
106
|
+
return;
|
|
107
|
+
var at = clients.findIndex(function (x) { return x.id === c.id; });
|
|
108
|
+
var neighbor = (_a = clients[at + 1]) !== null && _a !== void 0 ? _a : clients[at - 1];
|
|
109
|
+
setRevoking(c.id);
|
|
110
|
+
later(function () {
|
|
111
|
+
setRevoking(null);
|
|
112
|
+
setConfirming(null);
|
|
113
|
+
setClients(function (list) { return list.filter(function (x) { return x.id !== c.id; }); });
|
|
114
|
+
// The row is gone: focus goes to the next row's Revoke, or the one before it when it was the last.
|
|
115
|
+
// With no client left, it goes to the guide Button in the empty list.
|
|
116
|
+
focusNext.current = function () { var _a; return (_a = (neighbor ? revokeButtons.current[neighbor.id] : guideButton.current)) === null || _a === void 0 ? void 0 : _a.focus(); };
|
|
117
|
+
toastIds.current.push(toast({ type: 'success', message: "".concat(c.name, " revoked.") }));
|
|
118
|
+
}, 1200);
|
|
119
|
+
}
|
|
120
|
+
return (<Center width="page">
|
|
121
|
+
{/* A real app mounts one Toaster near its root. */}
|
|
122
|
+
<Toaster />
|
|
123
|
+
<Stack gap="xlarge">
|
|
124
|
+
<Stack gap="small">
|
|
125
|
+
<Heading level={1} size="h5">Agent tools</Heading>
|
|
126
|
+
<Paragraph tone="secondary" size="body2" measure="none">What Acme Agent may do in this workspace, for everyone.</Paragraph>
|
|
127
|
+
{!canChange && <Paragraph tone="secondary" size="body2" measure="none">Only admins can change these settings. Your admin is Dana Lee.</Paragraph>}
|
|
128
|
+
</Stack>
|
|
129
|
+
|
|
130
|
+
<SettingsSection title="Tools" description="Each choice saves as soon as you make it. Ask means Acme Agent asks before each use.">
|
|
131
|
+
<TableContainer>
|
|
132
|
+
<TableHeader>
|
|
133
|
+
<TableRow>
|
|
134
|
+
<TableHeaderCell>Tool</TableHeaderCell>
|
|
135
|
+
<TableHeaderCell width="184px">Setting</TableHeaderCell>
|
|
136
|
+
</TableRow>
|
|
137
|
+
</TableHeader>
|
|
138
|
+
{tools.map(function (t) {
|
|
139
|
+
var _a;
|
|
140
|
+
return (<TableRow key={t.id}>
|
|
141
|
+
<TableCell>
|
|
142
|
+
<Stack gap="small">
|
|
143
|
+
{t.name}
|
|
144
|
+
<Paragraph size="body2" tone="secondary" measure="none">{(_a = t.risky) !== null && _a !== void 0 ? _a : t.does}</Paragraph>
|
|
145
|
+
</Stack>
|
|
146
|
+
</TableCell>
|
|
147
|
+
<TableCell width="184px">
|
|
148
|
+
<SegmentedControl size="small" aria-label={t.name} options={t.risky ? riskyOptions : allOptions} value={settings[t.id]} onChange={function (next) { return choose(t, next); }}/>
|
|
149
|
+
</TableCell>
|
|
150
|
+
</TableRow>);
|
|
151
|
+
})}
|
|
152
|
+
</TableContainer>
|
|
153
|
+
</SettingsSection>
|
|
154
|
+
|
|
155
|
+
<SettingsSection title="Connected apps" description="Apps that use Acme Agent from outside Acme. They can use the tools above.">
|
|
156
|
+
{clients.length > 0 ? (<TableContainer>
|
|
157
|
+
{clients.map(function (c) { return (<TableRow key={c.id}>
|
|
158
|
+
<TableCell>
|
|
159
|
+
<Stack gap="small">
|
|
160
|
+
{c.name}
|
|
161
|
+
<Paragraph size="body2" tone="secondary" measure="none">{confirming === c.id ? "Revoke ".concat(c.name, "? It stops working until someone connects it again.") : c.connected}</Paragraph>
|
|
162
|
+
</Stack>
|
|
163
|
+
</TableCell>
|
|
164
|
+
{/* A fixed last column keeps every row's Buttons in one place, so they do not jump when they change. */}
|
|
165
|
+
<TableCell width="168px" align="right">
|
|
166
|
+
{confirming === c.id ? (<Cluster gap="small" justify="end">
|
|
167
|
+
<Button ref={cancelRevoke} size="small" type="tertiary" state={revoking ? 'disabled' : 'enabled'} label="Cancel" aria-label={"Cancel revoking ".concat(c.name)} onClickButton={function () { return keepClient(c); }}/>
|
|
168
|
+
<Button size="small" type="primary" color="danger" state="enabled" label="Revoke" aria-label={"Revoke ".concat(c.name)} loading={revoking === c.id} onClickButton={function () { return revoke(c); }}/>
|
|
169
|
+
</Cluster>) : (canChange && (<Cluster justify="end">
|
|
170
|
+
<Button ref={function (el) { revokeButtons.current[c.id] = el; }} size="small" type="tertiary" state={revoking ? 'disabled' : 'enabled'} label="Revoke" aria-label={"Revoke ".concat(c.name)} onClickButton={function () { return askToRevoke(c); }}/>
|
|
171
|
+
</Cluster>))}
|
|
172
|
+
</TableCell>
|
|
173
|
+
</TableRow>); })}
|
|
174
|
+
</TableContainer>) : (<EmptyBox size="small" icon="Plug" text="No connected apps" secondText="Apps you connect to Acme Agent appear here." action={<Button ref={guideButton} size="small" type="secondary" state="enabled" label="Read the Setup Guide" href="/docs/agent/clients"/>}/>)}
|
|
175
|
+
</SettingsSection>
|
|
176
|
+
</Stack>
|
|
177
|
+
</Center>);
|
|
178
|
+
}
|