oneslash-design-system 2.16.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.
- package/README.md +2 -2
- package/dist/DESIGN.md +56 -17
- package/dist/cases/accept-invite/signed-in.jsx +1 -1
- package/dist/cases/accept-invite/signed-out.jsx +1 -1
- package/dist/cases/accept-invite.md +3 -7
- package/dist/cases/account-menu/menu.d.ts +1 -0
- package/dist/cases/account-menu/menu.jsx +99 -0
- package/dist/cases/account-menu.md +164 -0
- package/dist/cases/agent-asks-before-risky-action.md +0 -4
- package/dist/cases/agent-cancels-when-unanswered.md +0 -4
- package/dist/cases/agent-options/cards.d.ts +1 -0
- package/dist/cases/agent-options/cards.jsx +91 -0
- package/dist/cases/agent-options.md +164 -0
- package/dist/cases/agent-pending-reply/steps.d.ts +1 -0
- package/dist/cases/agent-pending-reply/steps.jsx +149 -0
- package/dist/cases/agent-pending-reply/streaming.d.ts +1 -0
- package/dist/cases/agent-pending-reply/streaming.jsx +146 -0
- package/dist/cases/agent-pending-reply.md +428 -0
- package/dist/cases/agent-plan-proposal/changes.d.ts +1 -0
- package/dist/cases/agent-plan-proposal/changes.jsx +224 -0
- package/dist/cases/agent-plan-proposal/steps.d.ts +1 -0
- package/dist/cases/agent-plan-proposal/steps.jsx +211 -0
- package/dist/cases/agent-plan-proposal.md +652 -0
- package/dist/cases/agent-question/choices.d.ts +1 -0
- package/dist/cases/agent-question/choices.jsx +132 -0
- package/dist/cases/agent-question/free-text.d.ts +1 -0
- package/dist/cases/agent-question/free-text.jsx +81 -0
- package/dist/cases/agent-question.md +334 -0
- package/dist/cases/agent-refuses-clearly.md +0 -4
- package/dist/cases/agent-says-what-it-is.md +0 -2
- package/dist/cases/agent-settings/form.d.ts +1 -0
- package/dist/cases/agent-settings/form.jsx +164 -0
- package/dist/cases/agent-settings.md +259 -0
- package/dist/cases/agent-shows-progress.md +0 -2
- package/dist/cases/agent-shows-sources.md +2 -4
- package/dist/cases/api-keys/list.d.ts +1 -0
- package/dist/cases/api-keys/list.jsx +162 -0
- package/dist/cases/api-keys.md +229 -0
- package/dist/cases/artifact-card/card.d.ts +1 -0
- package/dist/cases/artifact-card/card.jsx +45 -0
- package/dist/cases/artifact-card.md +99 -0
- package/dist/cases/auth-gate-loading.md +0 -4
- package/dist/cases/check-your-email.md +0 -4
- package/dist/cases/collapsible-search/popover.d.ts +1 -0
- package/dist/cases/collapsible-search/popover.jsx +74 -0
- package/dist/cases/collapsible-search.md +143 -0
- package/dist/cases/composer-limit/notice-with-action.d.ts +1 -0
- package/dist/cases/composer-limit/notice-with-action.jsx +87 -0
- package/dist/cases/composer-limit/notice.d.ts +1 -0
- package/dist/cases/composer-limit/notice.jsx +84 -0
- package/dist/cases/composer-limit.md +282 -0
- package/dist/cases/confirm-destructive-action.md +0 -4
- package/dist/cases/confirm-dialogs.md +0 -4
- package/dist/cases/conversation-starters/chips.d.ts +1 -0
- package/dist/cases/conversation-starters/chips.jsx +69 -0
- package/dist/cases/conversation-starters/none.d.ts +1 -0
- package/dist/cases/conversation-starters/none.jsx +45 -0
- package/dist/cases/conversation-starters.md +204 -0
- package/dist/cases/create-modal.md +0 -4
- package/dist/cases/danger-zone/collapsed.d.ts +1 -0
- package/dist/cases/danger-zone/collapsed.jsx +75 -0
- package/dist/cases/danger-zone/shown.d.ts +1 -0
- package/dist/cases/danger-zone/shown.jsx +95 -0
- package/dist/cases/danger-zone.md +263 -0
- package/dist/cases/device-login.md +0 -4
- package/dist/cases/email-confirmed.md +0 -4
- package/dist/cases/empty-list.md +0 -4
- package/dist/cases/empty-lists.md +0 -4
- package/dist/cases/empty-not-set-up.md +0 -4
- package/dist/cases/empty-search.md +0 -4
- package/dist/cases/error-page.md +0 -4
- package/dist/cases/feedback-form.md +0 -4
- package/dist/cases/filter-menu/presets.d.ts +1 -0
- package/dist/cases/filter-menu/presets.jsx +53 -0
- package/dist/cases/filter-menu/with-clear.d.ts +1 -0
- package/dist/cases/filter-menu/with-clear.jsx +56 -0
- package/dist/cases/filter-menu.md +204 -0
- package/dist/cases/forgot-password.md +0 -4
- package/dist/cases/form-errors.md +0 -4
- package/dist/cases/import-checklist.md +0 -4
- package/dist/cases/inline-form-feedback.md +0 -4
- package/dist/cases/integrations-list/nested.d.ts +1 -0
- package/dist/cases/integrations-list/nested.jsx +164 -0
- package/dist/cases/integrations-list/rows.d.ts +1 -0
- package/dist/cases/integrations-list/rows.jsx +134 -0
- package/dist/cases/integrations-list.md +379 -0
- package/dist/cases/invite-member.md +0 -4
- package/dist/cases/load-failure.md +0 -4
- package/dist/cases/log-out-confirm.md +0 -4
- package/dist/cases/login-page.md +0 -4
- package/dist/cases/members-list/rows.d.ts +1 -0
- package/dist/cases/members-list/rows.jsx +318 -0
- package/dist/cases/members-list/table.d.ts +1 -0
- package/dist/cases/members-list/table.jsx +351 -0
- package/dist/cases/members-list.md +799 -0
- package/dist/cases/mention-list/in-composer.d.ts +1 -0
- package/dist/cases/mention-list/in-composer.jsx +169 -0
- package/dist/cases/mention-list.md +248 -0
- package/dist/cases/message-actions/hover-toolbar.d.ts +1 -0
- package/dist/cases/message-actions/hover-toolbar.jsx +229 -0
- package/dist/cases/message-actions/menu.d.ts +1 -0
- package/dist/cases/message-actions/menu.jsx +258 -0
- package/dist/cases/message-actions.md +647 -0
- package/dist/cases/message-attachments/in-composer.d.ts +1 -0
- package/dist/cases/message-attachments/in-composer.jsx +134 -0
- package/dist/cases/message-attachments/in-message.d.ts +1 -0
- package/dist/cases/message-attachments/in-message.jsx +46 -0
- package/dist/cases/message-attachments.md +306 -0
- package/dist/cases/message-composer/plain.d.ts +1 -0
- package/dist/cases/message-composer/plain.jsx +57 -0
- package/dist/cases/message-composer/with-tools.d.ts +1 -0
- package/dist/cases/message-composer/with-tools.jsx +182 -0
- package/dist/cases/message-composer.md +352 -0
- package/dist/cases/message-edit/in-place.d.ts +1 -0
- package/dist/cases/message-edit/in-place.jsx +99 -0
- package/dist/cases/message-edit.md +175 -0
- package/dist/cases/message-reactions/chips.d.ts +1 -0
- package/dist/cases/message-reactions/chips.jsx +118 -0
- package/dist/cases/message-reactions/quick-pick.d.ts +1 -0
- package/dist/cases/message-reactions/quick-pick.jsx +155 -0
- package/dist/cases/message-reactions.md +367 -0
- package/dist/cases/message-row/grouped.d.ts +1 -0
- package/dist/cases/message-row/grouped.jsx +56 -0
- package/dist/cases/message-row/person-and-agent.d.ts +1 -0
- package/dist/cases/message-row/person-and-agent.jsx +41 -0
- package/dist/cases/message-row.md +185 -0
- package/dist/cases/not-found-page.md +0 -4
- package/dist/cases/notification-menu/menu.d.ts +1 -0
- package/dist/cases/notification-menu/menu.jsx +74 -0
- package/dist/cases/notification-menu.md +135 -0
- package/dist/cases/oauth-consent.md +0 -4
- package/dist/cases/on-off-settings/list.d.ts +1 -0
- package/dist/cases/on-off-settings/list.jsx +97 -0
- package/dist/cases/on-off-settings.md +116 -0
- package/dist/cases/overflow-menu/in-a-header.d.ts +1 -0
- package/dist/cases/overflow-menu/in-a-header.jsx +128 -0
- package/dist/cases/overflow-menu/on-a-row.d.ts +1 -0
- package/dist/cases/overflow-menu/on-a-row.jsx +183 -0
- package/dist/cases/overflow-menu.md +410 -0
- package/dist/cases/profile-form/form.d.ts +1 -0
- package/dist/cases/profile-form/form.jsx +153 -0
- package/dist/cases/profile-form.md +236 -0
- package/dist/cases/quick-switcher/modal.d.ts +1 -0
- package/dist/cases/quick-switcher/modal.jsx +114 -0
- package/dist/cases/quick-switcher.md +205 -0
- package/dist/cases/range-switch/segmented.d.ts +1 -0
- package/dist/cases/range-switch/segmented.jsx +30 -0
- package/dist/cases/range-switch.md +67 -0
- package/dist/cases/rename.md +0 -4
- package/dist/cases/reply-feedback/thumbs.d.ts +1 -0
- package/dist/cases/reply-feedback/thumbs.jsx +191 -0
- package/dist/cases/reply-feedback/with-reason.d.ts +1 -0
- package/dist/cases/reply-feedback/with-reason.jsx +221 -0
- package/dist/cases/reply-feedback.md +548 -0
- package/dist/cases/reply-sources/cards.d.ts +1 -0
- package/dist/cases/reply-sources/cards.jsx +83 -0
- package/dist/cases/reply-sources/tag-only.d.ts +1 -0
- package/dist/cases/reply-sources/tag-only.jsx +45 -0
- package/dist/cases/reply-sources.md +243 -0
- package/dist/cases/route-loading.md +0 -2
- package/dist/cases/scope-picker/menu.d.ts +1 -0
- package/dist/cases/scope-picker/menu.jsx +47 -0
- package/dist/cases/scope-picker.md +97 -0
- package/dist/cases/set-new-password.md +0 -4
- package/dist/cases/settings-page/side-nav.d.ts +1 -0
- package/dist/cases/settings-page/side-nav.jsx +171 -0
- package/dist/cases/settings-page/top-tabs.d.ts +1 -0
- package/dist/cases/settings-page/top-tabs.jsx +129 -0
- package/dist/cases/settings-page.md +378 -0
- package/dist/cases/settings-save.md +35 -0
- package/dist/cases/sign-up-page.md +1 -5
- package/dist/cases/slash-command-list/in-composer.d.ts +1 -0
- package/dist/cases/slash-command-list/in-composer.jsx +162 -0
- package/dist/cases/slash-command-list.md +243 -0
- package/dist/cases/success-feedback.md +1 -5
- package/dist/cases/tag-filter/tags.d.ts +1 -0
- package/dist/cases/tag-filter/tags.jsx +226 -0
- package/dist/cases/tag-filter.md +298 -0
- package/dist/cases/type-to-confirm.md +0 -4
- package/dist/cases/typing-and-status/line.d.ts +1 -0
- package/dist/cases/typing-and-status/line.jsx +50 -0
- package/dist/cases/typing-and-status.md +92 -0
- package/dist/cases/unsaved-changes-guard.md +0 -4
- package/dist/cases/upgrade-prompt.md +0 -4
- package/dist/cases.json +2331 -294
- package/dist/components/alert.d.ts +3 -1
- package/dist/components/alert.jsx +2 -2
- package/dist/components/button.d.ts +3 -2
- package/dist/components/button.jsx +14 -9
- package/dist/components/checkBox.d.ts +5 -1
- package/dist/components/checkBox.jsx +2 -2
- package/dist/components/composer.d.ts +74 -0
- package/dist/components/composer.jsx +122 -0
- package/dist/components/copyField.d.ts +20 -0
- package/dist/components/copyField.jsx +99 -0
- package/dist/components/fileChip.d.ts +33 -0
- package/dist/components/fileChip.jsx +61 -0
- package/dist/components/formField.d.ts +34 -0
- package/dist/components/formField.jsx +28 -0
- package/dist/components/heading.d.ts +3 -1
- package/dist/components/heading.jsx +2 -2
- package/dist/components/iconButton.d.ts +3 -3
- package/dist/components/iconButton.jsx +9 -7
- package/dist/components/layout.d.ts +7 -1
- package/dist/components/layout.jsx +5 -2
- package/dist/components/menu.d.ts +21 -0
- package/dist/components/menu.jsx +27 -3
- package/dist/components/menuItem.d.ts +12 -2
- package/dist/components/menuItem.jsx +6 -5
- package/dist/components/message.d.ts +28 -0
- package/dist/components/message.jsx +25 -0
- package/dist/components/navigation.d.ts +9 -1
- package/dist/components/navigation.jsx +15 -3
- package/dist/components/paragraph.d.ts +3 -1
- package/dist/components/paragraph.jsx +2 -2
- package/dist/components/popover.d.ts +7 -1
- package/dist/components/popover.jsx +35 -9
- package/dist/components/radioGroup.d.ts +12 -1
- package/dist/components/radioGroup.jsx +20 -9
- package/dist/components/segmentedControl.d.ts +22 -0
- package/dist/components/segmentedControl.jsx +54 -0
- package/dist/components/select.d.ts +5 -1
- package/dist/components/select.jsx +2 -2
- package/dist/components/settingsSection.d.ts +31 -0
- package/dist/components/settingsSection.jsx +58 -0
- package/dist/components/slidingIndicator.d.ts +50 -0
- package/dist/components/slidingIndicator.jsx +102 -0
- package/dist/components/sourceCard.d.ts +23 -0
- package/dist/components/sourceCard.jsx +56 -0
- package/dist/components/stepList.d.ts +17 -0
- package/dist/components/stepList.jsx +79 -0
- package/dist/components/switch.d.ts +25 -0
- package/dist/components/switch.jsx +55 -0
- package/dist/components/tab.jsx +5 -11
- package/dist/components/tabsContainer.jsx +5 -67
- package/dist/components/tag.d.ts +9 -1
- package/dist/components/tag.jsx +6 -4
- package/dist/components/textField.d.ts +12 -2
- package/dist/components/textField.jsx +11 -4
- package/dist/components/textarea.d.ts +5 -1
- package/dist/components/textarea.jsx +6 -21
- package/dist/components/useHotkey.d.ts +7 -0
- package/dist/components/useHotkey.js +24 -0
- package/dist/components/userImage.d.ts +9 -1
- package/dist/components/userImage.jsx +10 -3
- package/dist/index.d.ts +6 -0
- package/dist/index.js +6 -0
- package/dist/internal/autoGrow.d.ts +11 -0
- package/dist/internal/autoGrow.js +28 -0
- package/dist/internal/composer.d.ts +16 -0
- package/dist/internal/composer.js +18 -0
- package/dist/internal/copyField.d.ts +5 -0
- package/dist/internal/copyField.js +61 -0
- package/dist/internal/hotkey.d.ts +16 -0
- package/dist/internal/hotkey.js +20 -0
- package/dist/internal/menu.d.ts +6 -0
- package/dist/internal/menu.js +31 -0
- package/dist/internal/switch.d.ts +5 -0
- package/dist/internal/switch.js +9 -0
- package/dist/native-mapping.json +62 -1
- package/dist/stories/Button.stories.d.ts +1 -0
- package/dist/stories/Button.stories.jsx +17 -1
- package/dist/stories/Cases.generated.stories.d.ts +53 -0
- package/dist/stories/Cases.generated.stories.jsx +106 -0
- package/dist/stories/Composer.stories.d.ts +23 -0
- package/dist/stories/Composer.stories.jsx +121 -0
- package/dist/stories/CopyField.stories.d.ts +11 -0
- package/dist/stories/CopyField.stories.jsx +65 -0
- package/dist/stories/FileChip.stories.d.ts +7 -0
- package/dist/stories/FileChip.stories.jsx +35 -0
- package/dist/stories/FormField.stories.d.ts +6 -0
- package/dist/stories/FormField.stories.jsx +44 -0
- package/dist/stories/IconButton.stories.d.ts +1 -0
- package/dist/stories/IconButton.stories.jsx +18 -1
- package/dist/stories/Menu.stories.d.ts +4 -0
- package/dist/stories/Menu.stories.jsx +46 -1
- package/dist/stories/MenuItem.stories.d.ts +1 -0
- package/dist/stories/MenuItem.stories.jsx +8 -0
- package/dist/stories/Message.stories.d.ts +10 -0
- package/dist/stories/Message.stories.jsx +77 -0
- package/dist/stories/Navigation.stories.d.ts +1 -0
- package/dist/stories/Navigation.stories.jsx +17 -1
- package/dist/stories/PageComponents.stories.d.ts +1 -0
- package/dist/stories/PageComponents.stories.jsx +21 -0
- package/dist/stories/RadioGroup.stories.d.ts +2 -0
- package/dist/stories/RadioGroup.stories.jsx +40 -1
- package/dist/stories/SegmentedControl.stories.d.ts +8 -0
- package/dist/stories/SegmentedControl.stories.jsx +33 -0
- package/dist/stories/SettingsSection.stories.d.ts +11 -0
- package/dist/stories/SettingsSection.stories.jsx +64 -0
- package/dist/stories/SourceCard.stories.d.ts +8 -0
- package/dist/stories/SourceCard.stories.jsx +33 -0
- package/dist/stories/StepList.stories.d.ts +8 -0
- package/dist/stories/StepList.stories.jsx +35 -0
- package/dist/stories/Switch.stories.d.ts +14 -0
- package/dist/stories/Switch.stories.jsx +87 -0
- package/dist/stories/TextField.stories.d.ts +1 -0
- package/dist/stories/TextField.stories.jsx +13 -0
- package/dist/stories/UserImage.stories.d.ts +2 -0
- package/dist/stories/UserImage.stories.jsx +19 -0
- package/package.json +8 -3
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { Bot } from 'lucide-react';
|
|
4
|
+
import Message from '../../components/message';
|
|
5
|
+
import UserImage from '../../components/userImage';
|
|
6
|
+
import Tag from '../../components/tag';
|
|
7
|
+
import TimeStamp from '../../components/timeStamp';
|
|
8
|
+
import Heading from '../../components/heading';
|
|
9
|
+
import Paragraph from '../../components/paragraph';
|
|
10
|
+
import Button from '../../components/button';
|
|
11
|
+
import Surface from '../../components/surface';
|
|
12
|
+
import StepList from '../../components/stepList';
|
|
13
|
+
import Textarea from '../../components/textarea';
|
|
14
|
+
import { Center, Cluster, Stack } from '../../components/layout';
|
|
15
|
+
var agentName = 'Acme Agent';
|
|
16
|
+
var request = { from: 'Dana Lee', at: new Date('2025-01-15T11:40:00Z'), text: 'Can you update the pricing page for the new plans?' };
|
|
17
|
+
var proposedAt = new Date('2025-01-15T11:41:00Z');
|
|
18
|
+
var firstSteps = [
|
|
19
|
+
'Change the Pro price from $12 to $15',
|
|
20
|
+
'Add the Team plan at $25 per seat',
|
|
21
|
+
'Update the plan table on the pricing page',
|
|
22
|
+
'Open a pull request for review',
|
|
23
|
+
];
|
|
24
|
+
var reply = 'The pricing page is updated, and the pull request is open for review.';
|
|
25
|
+
// Finished steps keep a check, the current one runs, and steps the agent has not started are not shown.
|
|
26
|
+
function stepsUpTo(steps, current) {
|
|
27
|
+
return steps.slice(0, current + 1).map(function (label, i) { return ({ label: label, status: i < current ? 'done' : 'running' }); });
|
|
28
|
+
}
|
|
29
|
+
function secondsLine(seconds) {
|
|
30
|
+
return "Working for ".concat(seconds, " ").concat(seconds === 1 ? 'second' : 'seconds');
|
|
31
|
+
}
|
|
32
|
+
// The agent's marks, as the rule 'An agent says what it is' says.
|
|
33
|
+
function agentMeta(at) {
|
|
34
|
+
return (<>
|
|
35
|
+
<Tag variant="contained" size="small" label="Agent"/>
|
|
36
|
+
<TimeStamp createdAt={at} dateFormat="absolute" data="time"/>
|
|
37
|
+
<Paragraph size="caption" tone="secondary" measure="none">Model name</Paragraph>
|
|
38
|
+
</>);
|
|
39
|
+
}
|
|
40
|
+
export default function AgentPlanProposalSteps() {
|
|
41
|
+
var _a = useState(firstSteps), steps = _a[0], setSteps = _a[1];
|
|
42
|
+
var _b = useState('open'), status = _b[0], setStatus = _b[1];
|
|
43
|
+
var _c = useState(null), pending = _c[0], setPending = _c[1];
|
|
44
|
+
var _d = useState(''), draft = _d[0], setDraft = _d[1];
|
|
45
|
+
// The run after 'Approve', in its own progress row under the card.
|
|
46
|
+
var _e = useState(null), run = _e[0], setRun = _e[1];
|
|
47
|
+
var _f = useState(0), current = _f[0], setCurrent = _f[1];
|
|
48
|
+
var _g = useState(0), seconds = _g[0], setSeconds = _g[1];
|
|
49
|
+
var _h = useState(proposedAt), startedAt = _h[0], setStartedAt = _h[1];
|
|
50
|
+
var timer = useRef();
|
|
51
|
+
var tick = useRef();
|
|
52
|
+
var step = useRef();
|
|
53
|
+
var cancel = useRef();
|
|
54
|
+
var editButton = useRef(null);
|
|
55
|
+
var stopButton = useRef(null);
|
|
56
|
+
// Where focus goes after the next render, once the element it goes to is on screen.
|
|
57
|
+
var focusNext = useRef();
|
|
58
|
+
// On unmount it stops the requests, the run and its clock.
|
|
59
|
+
useEffect(function () { return function () {
|
|
60
|
+
clearTimeout(timer.current);
|
|
61
|
+
clearInterval(tick.current);
|
|
62
|
+
clearTimeout(step.current);
|
|
63
|
+
clearTimeout(cancel.current);
|
|
64
|
+
}; }, []);
|
|
65
|
+
useEffect(function () {
|
|
66
|
+
var move = focusNext.current;
|
|
67
|
+
focusNext.current = undefined;
|
|
68
|
+
move === null || move === void 0 ? void 0 : move();
|
|
69
|
+
});
|
|
70
|
+
// Stands in for the agent's run: one step every 1.5 seconds.
|
|
71
|
+
function advance(at) {
|
|
72
|
+
step.current = setTimeout(function () {
|
|
73
|
+
if (at === steps.length - 1) {
|
|
74
|
+
clearInterval(tick.current);
|
|
75
|
+
setRun('done');
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
setCurrent(at + 1);
|
|
79
|
+
advance(at + 1);
|
|
80
|
+
}, 1500);
|
|
81
|
+
}
|
|
82
|
+
// The card stays as the record, and the run shows in its own progress row below it.
|
|
83
|
+
// 'Approve' is gone and 'Stop' is the control that took its place, so focus goes to 'Stop'.
|
|
84
|
+
function startRun() {
|
|
85
|
+
setRun('running');
|
|
86
|
+
setCurrent(0);
|
|
87
|
+
setSeconds(0);
|
|
88
|
+
setStartedAt(new Date());
|
|
89
|
+
tick.current = setInterval(function () { return setSeconds(function (s) { return s + 1; }); }, 1000);
|
|
90
|
+
advance(0);
|
|
91
|
+
focusNext.current = function () { var _a; return (_a = stopButton.current) === null || _a === void 0 ? void 0 : _a.focus(); };
|
|
92
|
+
}
|
|
93
|
+
// Decided once: the buttons go away, so a second click cannot approve or cancel it again.
|
|
94
|
+
// After 'Cancel' nothing takes their place: a real app moves focus to the message box.
|
|
95
|
+
function decide(action) {
|
|
96
|
+
if (pending || status !== 'open')
|
|
97
|
+
return;
|
|
98
|
+
setPending(action);
|
|
99
|
+
// Stands in for the request to the server.
|
|
100
|
+
timer.current = setTimeout(function () {
|
|
101
|
+
setPending(null);
|
|
102
|
+
if (action === 'cancel') {
|
|
103
|
+
setStatus('cancelled');
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
setStatus('approved');
|
|
107
|
+
startRun();
|
|
108
|
+
}, 1200);
|
|
109
|
+
}
|
|
110
|
+
// Stop asks the server to end the run. The row says it stopped only once the run has ended.
|
|
111
|
+
function stop() {
|
|
112
|
+
if (run !== 'running')
|
|
113
|
+
return;
|
|
114
|
+
clearTimeout(step.current);
|
|
115
|
+
setRun('stopping');
|
|
116
|
+
// Stands in for the request to the server.
|
|
117
|
+
cancel.current = setTimeout(function () {
|
|
118
|
+
clearInterval(tick.current);
|
|
119
|
+
setRun('stopped');
|
|
120
|
+
}, 1200);
|
|
121
|
+
}
|
|
122
|
+
function startEditing() {
|
|
123
|
+
if (pending)
|
|
124
|
+
return;
|
|
125
|
+
setDraft(steps.join('\n'));
|
|
126
|
+
setStatus('editing');
|
|
127
|
+
}
|
|
128
|
+
// 'Discard' leaves the edit and keeps the plan as it was. 'Cancel' would cancel the whole proposal.
|
|
129
|
+
function discard() {
|
|
130
|
+
setStatus('open');
|
|
131
|
+
focusNext.current = function () { var _a; return (_a = editButton.current) === null || _a === void 0 ? void 0 : _a.focus(); };
|
|
132
|
+
}
|
|
133
|
+
var draftSteps = draft.split('\n').map(function (s) { return s.trim(); }).filter(function (s) { return s !== ''; });
|
|
134
|
+
// 'Save' sends the edited steps to the agent. The plan comes back with them, still waiting for a yes.
|
|
135
|
+
function save() {
|
|
136
|
+
if (pending || draftSteps.length === 0)
|
|
137
|
+
return;
|
|
138
|
+
setPending('save');
|
|
139
|
+
// Stands in for the request to the server.
|
|
140
|
+
timer.current = setTimeout(function () {
|
|
141
|
+
setPending(null);
|
|
142
|
+
setSteps(draftSteps);
|
|
143
|
+
setStatus('open');
|
|
144
|
+
focusNext.current = function () { var _a; return (_a = editButton.current) === null || _a === void 0 ? void 0 : _a.focus(); };
|
|
145
|
+
}, 1200);
|
|
146
|
+
}
|
|
147
|
+
// A stop says how far the run got, so it never says nothing changed when something did.
|
|
148
|
+
// A real app takes the count from the server's answer, not from the list on screen.
|
|
149
|
+
var stoppedNote = current === 0
|
|
150
|
+
? 'Stopped. Nothing was changed.'
|
|
151
|
+
: "Stopped after ".concat(current, " of ").concat(steps.length, " steps. The rest of the plan was not done.");
|
|
152
|
+
return (<Center width="page">
|
|
153
|
+
<Stack gap="large">
|
|
154
|
+
<Heading level={1} size="h5">Launch plan</Heading>
|
|
155
|
+
{/* A real app gives the list that holds the rows role="log". */}
|
|
156
|
+
<Stack gap="small">
|
|
157
|
+
<Message aria-label={request.from} avatar={<UserImage userHandle={request.from} decorative/>} name={request.from} meta={<TimeStamp createdAt={request.at} dateFormat="absolute" data="time"/>}>
|
|
158
|
+
<Paragraph measure="none">{request.text}</Paragraph>
|
|
159
|
+
</Message>
|
|
160
|
+
<Message aria-label={"".concat(agentName, ", agent")} avatar={<UserImage userHandle={agentName} icon={Bot} decorative/>} name={agentName} meta={agentMeta(proposedAt)}>
|
|
161
|
+
<Surface padding="small">
|
|
162
|
+
<Stack gap="medium">
|
|
163
|
+
{/* A real app announces the decided Tag in a polite live region. */}
|
|
164
|
+
<Cluster gap="small">
|
|
165
|
+
<Heading level={2} size="subtitle1">Proposed plan</Heading>
|
|
166
|
+
{status === 'approved' && <Tag variant="contained" size="small" color="success" label="Approved"/>}
|
|
167
|
+
{status === 'cancelled' && <Tag variant="contained" size="small" label="Cancelled"/>}
|
|
168
|
+
</Cluster>
|
|
169
|
+
{status === 'editing' ? (<Textarea id="agent-plan-proposal-steps" label="Steps, one per line" value={draft} onChange={function (e) { return setDraft(e.target.value); }} onSubmit={save} autoFocus maxRows={10} disabled={pending === 'save'}/>) : (
|
|
170
|
+
// Every step, in the order the agent will do them. Once decided, the card is the record:
|
|
171
|
+
// an approved plan keeps its steps as they were, and a cancelled one marks each step cancelled.
|
|
172
|
+
<StepList numbered aria-label="Proposed plan" steps={steps.map(function (label) { return ({ label: label, status: status === 'cancelled' ? 'cancelled' : 'waiting' }); })}/>)}
|
|
173
|
+
{/* The product sets the waiting time and counts it down. When it is up, the card is marked Cancelled. */}
|
|
174
|
+
{(status === 'open' || status === 'editing') && (<Paragraph size="caption" tone="secondary" measure="none">Waits 10 more minutes, then cancels.</Paragraph>)}
|
|
175
|
+
{status === 'open' && (<Cluster gap="small">
|
|
176
|
+
<Button size="small" type="tertiary" state={pending === 'approve' ? 'disabled' : 'enabled'} label="Cancel" loading={pending === 'cancel'} onClickButton={function () { return decide('cancel'); }}/>
|
|
177
|
+
<Button ref={editButton} size="small" type="secondary" state={pending ? 'disabled' : 'enabled'} label="Edit" onClickButton={startEditing}/>
|
|
178
|
+
{/* The product writes this label, never the agent. */}
|
|
179
|
+
<Button size="small" type="primary" state={pending === 'cancel' ? 'disabled' : 'enabled'} label="Approve" loading={pending === 'approve'} onClickButton={function () { return decide('approve'); }}/>
|
|
180
|
+
</Cluster>)}
|
|
181
|
+
{status === 'editing' && (<Cluster gap="small">
|
|
182
|
+
<Button size="small" type="tertiary" state={pending === 'save' ? 'disabled' : 'enabled'} label="Discard" onClickButton={discard}/>
|
|
183
|
+
<Button size="small" type="primary" state={draftSteps.length === 0 ? 'disabled' : 'enabled'} label="Save" loading={pending === 'save'} onClickButton={save}/>
|
|
184
|
+
</Cluster>)}
|
|
185
|
+
</Stack>
|
|
186
|
+
</Surface>
|
|
187
|
+
</Message>
|
|
188
|
+
{status === 'cancelled' && (
|
|
189
|
+
// One line in the thread on what was not done, under the card.
|
|
190
|
+
<Message compact aria-label={"".concat(agentName, ", agent")}>
|
|
191
|
+
<Paragraph measure="none">Cancelled. Nothing was changed.</Paragraph>
|
|
192
|
+
</Message>)}
|
|
193
|
+
{run && (
|
|
194
|
+
// The run's own progress row, as the case 'Agent at work' shows.
|
|
195
|
+
<Message aria-label={"".concat(agentName, ", agent")} avatar={<UserImage userHandle={agentName} icon={Bot} decorative/>} name={agentName} meta={agentMeta(startedAt)} footer={run === 'running' || run === 'stopping' ? (
|
|
196
|
+
// The only Stop, on the row for the whole run. It shows loading while the run is stopping.
|
|
197
|
+
// When it goes, a real app moves focus to the message box.
|
|
198
|
+
<Cluster>
|
|
199
|
+
<Button ref={stopButton} size="small" type="secondary" state="enabled" label="Stop" loading={run === 'stopping'} onClickButton={stop}/>
|
|
200
|
+
</Cluster>) : undefined}>
|
|
201
|
+
{run === 'done' ? (<Paragraph measure="none">{reply}</Paragraph>) : run === 'stopped' ? (<Paragraph measure="none">{stoppedNote}</Paragraph>) : (
|
|
202
|
+
// A real app wraps this part in a polite live region, since StepList has none.
|
|
203
|
+
<Stack gap="medium">
|
|
204
|
+
<Paragraph size="caption" tone="secondary" measure="none">{secondsLine(seconds)}</Paragraph>
|
|
205
|
+
<StepList aria-label="Acme Agent's steps" steps={stepsUpTo(steps, current)}/>
|
|
206
|
+
</Stack>)}
|
|
207
|
+
</Message>)}
|
|
208
|
+
</Stack>
|
|
209
|
+
</Stack>
|
|
210
|
+
</Center>);
|
|
211
|
+
}
|