oneslash-design-system 2.28.1 → 2.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +51 -0
- package/dist/cases/agent-permissions/per-tool.d.ts +3 -0
- package/dist/cases/agent-permissions/per-tool.jsx +180 -0
- package/dist/cases/agent-permissions.md +319 -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.md +2 -0
- 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 +206 -0
- package/dist/cases/bulk-actions/paged-table.d.ts +1 -0
- package/dist/cases/bulk-actions/paged-table.jsx +243 -0
- package/dist/cases/bulk-actions.md +553 -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.md +2 -0
- 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 +1 -0
- package/dist/cases/product-demo/scripted.jsx +99 -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 +226 -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 +1492 -39
- package/dist/components/checkBox.d.ts +7 -2
- package/dist/components/checkBox.jsx +39 -14
- package/dist/components/diff.d.ts +32 -0
- package/dist/components/diff.jsx +42 -0
- package/dist/components/segmentedControl.d.ts +3 -1
- package/dist/components/segmentedControl.jsx +8 -6
- package/dist/components/slidingIndicator.d.ts +5 -2
- package/dist/components/slidingIndicator.jsx +9 -3
- package/dist/components/tableContainer.d.ts +1 -1
- package/dist/components/tableContainer.jsx +2 -2
- package/dist/components/timeStamp.d.ts +3 -1
- package/dist/components/timeStamp.jsx +4 -2
- package/dist/components/useReducedMotion.d.ts +6 -0
- package/dist/components/useReducedMotion.js +19 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -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 +3 -0
- package/dist/stories/Checkbox.stories.jsx +38 -0
- package/dist/stories/Diff.stories.d.ts +10 -0
- package/dist/stories/Diff.stories.jsx +45 -0
- package/dist/stories/SegmentedControl.stories.d.ts +1 -0
- package/dist/stories/SegmentedControl.stories.jsx +6 -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/dist/stories/Table.stories.d.ts +1 -0
- package/dist/stories/Table.stories.jsx +25 -0
- package/dist/stories/TimeStamp.stories.d.ts +1 -0
- package/dist/stories/TimeStamp.stories.jsx +13 -0
- package/package.json +5 -1
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { Bot, Rocket } 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 SourceCard from '../../components/sourceCard';
|
|
12
|
+
import { Center, Cluster, Stack } from '../../components/layout';
|
|
13
|
+
// A real app reads these from the session and the person's role. Dana Lee can approve deploys too.
|
|
14
|
+
var me = 'Dana Lee';
|
|
15
|
+
var canTakeOver = true;
|
|
16
|
+
var agentName = 'Acme Agent';
|
|
17
|
+
var approver = 'Ben Carter';
|
|
18
|
+
var request = { from: me, at: new Date('2026-11-16T14:30:00Z'), text: 'Can you ship the new pricing page today?' };
|
|
19
|
+
var handedOffAt = new Date('2026-11-16T14:40:00Z');
|
|
20
|
+
// The agent's marks, as the rule 'An agent says what it is' says.
|
|
21
|
+
function agentMeta(at) {
|
|
22
|
+
return (<>
|
|
23
|
+
<Tag variant="contained" size="small" label="Agent"/>
|
|
24
|
+
<TimeStamp createdAt={at} dateFormat="absolute" data="time"/>
|
|
25
|
+
<Paragraph size="caption" tone="secondary" measure="none">Model name</Paragraph>
|
|
26
|
+
</>);
|
|
27
|
+
}
|
|
28
|
+
export default function AgentHandoffToPerson() {
|
|
29
|
+
var _a = useState(false), takenOver = _a[0], setTakenOver = _a[1];
|
|
30
|
+
var _b = useState(false), pending = _b[0], setPending = _b[1];
|
|
31
|
+
var timer = useRef();
|
|
32
|
+
var deployCard = useRef(null);
|
|
33
|
+
// Where focus goes after the next render, once the element it goes to is on screen.
|
|
34
|
+
var focusNext = useRef();
|
|
35
|
+
// Stops the request if the example goes away before it ends.
|
|
36
|
+
useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
|
|
37
|
+
useEffect(function () {
|
|
38
|
+
var move = focusNext.current;
|
|
39
|
+
focusNext.current = undefined;
|
|
40
|
+
move === null || move === void 0 ? void 0 : move();
|
|
41
|
+
});
|
|
42
|
+
// The work moves to the reader. 'Take Over' goes away, so focus goes to the deploy they now approve.
|
|
43
|
+
function takeOver() {
|
|
44
|
+
if (pending || takenOver)
|
|
45
|
+
return;
|
|
46
|
+
setPending(true);
|
|
47
|
+
// Stands in for the request to the server.
|
|
48
|
+
timer.current = setTimeout(function () {
|
|
49
|
+
setPending(false);
|
|
50
|
+
setTakenOver(true);
|
|
51
|
+
focusNext.current = function () { var _a; return (_a = deployCard.current) === null || _a === void 0 ? void 0 : _a.focus(); };
|
|
52
|
+
}, 1200);
|
|
53
|
+
}
|
|
54
|
+
var waitingFor = takenOver ? me : approver;
|
|
55
|
+
return (<Center width="page">
|
|
56
|
+
<Stack gap="large">
|
|
57
|
+
<Heading level={1} size="h5">Launch plan</Heading>
|
|
58
|
+
{/* A real app gives the list that holds the rows role="log". */}
|
|
59
|
+
<Stack gap="small">
|
|
60
|
+
<Message aria-label={request.from} avatar={<UserImage userHandle={request.from} decorative/>} name={request.from} meta={<TimeStamp createdAt={request.at} dateFormat="absolute" data="time"/>}>
|
|
61
|
+
<Paragraph measure="none">{request.text}</Paragraph>
|
|
62
|
+
</Message>
|
|
63
|
+
<Message aria-label={"".concat(agentName, ", agent")} avatar={<UserImage userHandle={agentName} icon={Bot} decorative/>} name={agentName} meta={agentMeta(handedOffAt)} footer={canTakeOver && !takenOver ? (
|
|
64
|
+
// Only for a reader who can do the work themselves.
|
|
65
|
+
<Cluster>
|
|
66
|
+
<Button size="small" type="secondary" state="enabled" label="Take Over" loading={pending} onClickButton={takeOver}/>
|
|
67
|
+
</Cluster>) : undefined}>
|
|
68
|
+
<Stack gap="medium">
|
|
69
|
+
<Paragraph measure="none">I merged the pricing changes, and every check passed. Production deploys need a release manager, and I am not one.</Paragraph>
|
|
70
|
+
{/* A real app shows the name as a mention, which notifies Ben Carter. */}
|
|
71
|
+
<Paragraph measure="none">I need {approver} to approve the production deploy.</Paragraph>
|
|
72
|
+
<SourceCard ref={deployCard} icon={Rocket} title="Pricing page deploy" meta="Production · Ready to approve" href="/deploys/482"/>
|
|
73
|
+
{/* A real app announces the changed Tag in a polite live region. */}
|
|
74
|
+
<Cluster gap="small">
|
|
75
|
+
<Tag variant="contained" size="small" color="warning" label={"Waiting for ".concat(waitingFor)}/>
|
|
76
|
+
{takenOver && <Paragraph size="caption" tone="secondary" measure="none">{me} took over from {approver}.</Paragraph>}
|
|
77
|
+
</Cluster>
|
|
78
|
+
<Paragraph size="caption" tone="secondary" measure="none">If nobody approves by 5:00 PM, I cancel the deploy and say so here. Nothing goes live without an approval.</Paragraph>
|
|
79
|
+
</Stack>
|
|
80
|
+
</Message>
|
|
81
|
+
</Stack>
|
|
82
|
+
</Stack>
|
|
83
|
+
</Center>);
|
|
84
|
+
}
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
# Hand-off
|
|
2
|
+
|
|
3
|
+
The agent cannot finish the work itself and hands it to a named person, or to another agent with a different job.
|
|
4
|
+
|
|
5
|
+
For: an agent
|
|
6
|
+
|
|
7
|
+
## Do
|
|
8
|
+
|
|
9
|
+
- Hand off in a `Message` from the agent, in the thread where the work is, marked as the rule 'An agent says what it is' says.
|
|
10
|
+
- Say what the agent did, what it needs and from whom: 'I need Ben Carter to approve the production deploy.'
|
|
11
|
+
- Mention the person by name, so the product notifies them.
|
|
12
|
+
- Link the thing they must act on in a `SourceCard`, so they do not have to look for it.
|
|
13
|
+
- Show who the work waits for in a `Tag`: 'Waiting for Ben Carter'.
|
|
14
|
+
- Say what happens if nobody acts, as the rule 'An agent cancels and reports when nobody answers' says: 'If nobody approves by 5:00 PM, I cancel the deploy.'
|
|
15
|
+
- Offer 'Take Over' as a secondary Button to a reader who can do the work. Remove it once it is pressed, put the reader's name in the Tag, say who took over, and move focus to the `SourceCard`.
|
|
16
|
+
- Say the hand-off to another agent in one line with its reason: 'Handed off to Acme Reviewer. It checks every change before it merges.'
|
|
17
|
+
- Let the new agent's first message say what it will do. Mark it as the rule 'An agent says what it is' says.
|
|
18
|
+
|
|
19
|
+
## Don't
|
|
20
|
+
|
|
21
|
+
- Do not hand off silently. The thread says who has the work now.
|
|
22
|
+
- Do not show a bare caption that names the new owner and gives no reason.
|
|
23
|
+
- Do not hand off to a person without saying what they must do.
|
|
24
|
+
- Do not let the work wait with no end. Say when it is cancelled.
|
|
25
|
+
|
|
26
|
+
## Option: To a person
|
|
27
|
+
|
|
28
|
+
Use when: The agent cannot go on and a named person must.
|
|
29
|
+
|
|
30
|
+
Uses: `Button`, `Center`, `Cluster`, `Heading`, `Message`, `Paragraph`, `SourceCard`, `Stack`, `Tag`, `TimeStamp`, `UserImage`
|
|
31
|
+
|
|
32
|
+
```tsx
|
|
33
|
+
'use client';
|
|
34
|
+
import { useEffect, useRef, useState } from 'react';
|
|
35
|
+
import { Bot, Rocket } from 'lucide-react';
|
|
36
|
+
import Message from 'oneslash-design-system/components/message';
|
|
37
|
+
import UserImage from 'oneslash-design-system/components/userImage';
|
|
38
|
+
import Tag from 'oneslash-design-system/components/tag';
|
|
39
|
+
import TimeStamp from 'oneslash-design-system/components/timeStamp';
|
|
40
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
41
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
42
|
+
import Button from 'oneslash-design-system/components/button';
|
|
43
|
+
import SourceCard from 'oneslash-design-system/components/sourceCard';
|
|
44
|
+
import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
|
|
45
|
+
|
|
46
|
+
type Focusable = HTMLButtonElement | HTMLAnchorElement | null;
|
|
47
|
+
|
|
48
|
+
// A real app reads these from the session and the person's role. Dana Lee can approve deploys too.
|
|
49
|
+
const me = 'Dana Lee';
|
|
50
|
+
const canTakeOver = true;
|
|
51
|
+
|
|
52
|
+
const agentName = 'Acme Agent';
|
|
53
|
+
const approver = 'Ben Carter';
|
|
54
|
+
|
|
55
|
+
const request = { from: me, at: new Date('2026-11-16T14:30:00Z'), text: 'Can you ship the new pricing page today?' };
|
|
56
|
+
const handedOffAt = new Date('2026-11-16T14:40:00Z');
|
|
57
|
+
|
|
58
|
+
// The agent's marks, as the rule 'An agent says what it is' says.
|
|
59
|
+
function agentMeta(at: Date) {
|
|
60
|
+
return (
|
|
61
|
+
<>
|
|
62
|
+
<Tag variant="contained" size="small" label="Agent" />
|
|
63
|
+
<TimeStamp createdAt={at} dateFormat="absolute" data="time" />
|
|
64
|
+
<Paragraph size="caption" tone="secondary" measure="none">Model name</Paragraph>
|
|
65
|
+
</>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export default function AgentHandoffToPerson() {
|
|
70
|
+
const [takenOver, setTakenOver] = useState(false);
|
|
71
|
+
const [pending, setPending] = useState(false);
|
|
72
|
+
const timer = useRef<ReturnType<typeof setTimeout>>();
|
|
73
|
+
const deployCard = useRef<Focusable>(null);
|
|
74
|
+
// Where focus goes after the next render, once the element it goes to is on screen.
|
|
75
|
+
const focusNext = useRef<() => void>();
|
|
76
|
+
|
|
77
|
+
// Stops the request if the example goes away before it ends.
|
|
78
|
+
useEffect(() => () => clearTimeout(timer.current), []);
|
|
79
|
+
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
const move = focusNext.current;
|
|
82
|
+
focusNext.current = undefined;
|
|
83
|
+
move?.();
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
// The work moves to the reader. 'Take Over' goes away, so focus goes to the deploy they now approve.
|
|
87
|
+
function takeOver() {
|
|
88
|
+
if (pending || takenOver) return;
|
|
89
|
+
setPending(true);
|
|
90
|
+
// Stands in for the request to the server.
|
|
91
|
+
timer.current = setTimeout(() => {
|
|
92
|
+
setPending(false);
|
|
93
|
+
setTakenOver(true);
|
|
94
|
+
focusNext.current = () => deployCard.current?.focus();
|
|
95
|
+
}, 1200);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const waitingFor = takenOver ? me : approver;
|
|
99
|
+
|
|
100
|
+
return (
|
|
101
|
+
<Center width="page">
|
|
102
|
+
<Stack gap="large">
|
|
103
|
+
<Heading level={1} size="h5">Launch plan</Heading>
|
|
104
|
+
{/* A real app gives the list that holds the rows role="log". */}
|
|
105
|
+
<Stack gap="small">
|
|
106
|
+
<Message
|
|
107
|
+
aria-label={request.from}
|
|
108
|
+
avatar={<UserImage userHandle={request.from} decorative />}
|
|
109
|
+
name={request.from}
|
|
110
|
+
meta={<TimeStamp createdAt={request.at} dateFormat="absolute" data="time" />}
|
|
111
|
+
>
|
|
112
|
+
<Paragraph measure="none">{request.text}</Paragraph>
|
|
113
|
+
</Message>
|
|
114
|
+
<Message
|
|
115
|
+
aria-label={`${agentName}, agent`}
|
|
116
|
+
avatar={<UserImage userHandle={agentName} icon={Bot} decorative />}
|
|
117
|
+
name={agentName}
|
|
118
|
+
meta={agentMeta(handedOffAt)}
|
|
119
|
+
footer={
|
|
120
|
+
canTakeOver && !takenOver ? (
|
|
121
|
+
// Only for a reader who can do the work themselves.
|
|
122
|
+
<Cluster>
|
|
123
|
+
<Button size="small" type="secondary" state="enabled" label="Take Over" loading={pending} onClickButton={takeOver} />
|
|
124
|
+
</Cluster>
|
|
125
|
+
) : undefined
|
|
126
|
+
}
|
|
127
|
+
>
|
|
128
|
+
<Stack gap="medium">
|
|
129
|
+
<Paragraph measure="none">I merged the pricing changes, and every check passed. Production deploys need a release manager, and I am not one.</Paragraph>
|
|
130
|
+
{/* A real app shows the name as a mention, which notifies Ben Carter. */}
|
|
131
|
+
<Paragraph measure="none">I need {approver} to approve the production deploy.</Paragraph>
|
|
132
|
+
<SourceCard ref={deployCard} icon={Rocket} title="Pricing page deploy" meta="Production · Ready to approve" href="/deploys/482" />
|
|
133
|
+
{/* A real app announces the changed Tag in a polite live region. */}
|
|
134
|
+
<Cluster gap="small">
|
|
135
|
+
<Tag variant="contained" size="small" color="warning" label={`Waiting for ${waitingFor}`} />
|
|
136
|
+
{takenOver && <Paragraph size="caption" tone="secondary" measure="none">{me} took over from {approver}.</Paragraph>}
|
|
137
|
+
</Cluster>
|
|
138
|
+
<Paragraph size="caption" tone="secondary" measure="none">If nobody approves by 5:00 PM, I cancel the deploy and say so here. Nothing goes live without an approval.</Paragraph>
|
|
139
|
+
</Stack>
|
|
140
|
+
</Message>
|
|
141
|
+
</Stack>
|
|
142
|
+
</Stack>
|
|
143
|
+
</Center>
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Option: To another agent
|
|
149
|
+
|
|
150
|
+
Use when: Another agent with a different job takes over.
|
|
151
|
+
|
|
152
|
+
Uses: `Center`, `Heading`, `Message`, `Paragraph`, `SourceCard`, `Stack`, `Tag`, `TimeStamp`, `UserImage`
|
|
153
|
+
|
|
154
|
+
```tsx
|
|
155
|
+
'use client';
|
|
156
|
+
import { Bot, GitPullRequest } from 'lucide-react';
|
|
157
|
+
import Message from 'oneslash-design-system/components/message';
|
|
158
|
+
import UserImage from 'oneslash-design-system/components/userImage';
|
|
159
|
+
import Tag from 'oneslash-design-system/components/tag';
|
|
160
|
+
import TimeStamp from 'oneslash-design-system/components/timeStamp';
|
|
161
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
162
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
163
|
+
import SourceCard from 'oneslash-design-system/components/sourceCard';
|
|
164
|
+
import { Center, Stack } from 'oneslash-design-system/components/layout';
|
|
165
|
+
|
|
166
|
+
const agentName = 'Acme Agent';
|
|
167
|
+
const reviewerName = 'Acme Reviewer';
|
|
168
|
+
|
|
169
|
+
const request = { from: 'Dana Lee', at: new Date('2026-11-16T14:30:00Z'), text: 'Can you fix the broken Terms link in the footer?' };
|
|
170
|
+
const fixedAt = new Date('2026-11-16T14:36:00Z');
|
|
171
|
+
const reviewAt = new Date('2026-11-16T14:37:00Z');
|
|
172
|
+
|
|
173
|
+
// Each agent's marks, as the rule 'An agent says what it is' says.
|
|
174
|
+
function agentMeta(at: Date) {
|
|
175
|
+
return (
|
|
176
|
+
<>
|
|
177
|
+
<Tag variant="contained" size="small" label="Agent" />
|
|
178
|
+
<TimeStamp createdAt={at} dateFormat="absolute" data="time" />
|
|
179
|
+
<Paragraph size="caption" tone="secondary" measure="none">Model name</Paragraph>
|
|
180
|
+
</>
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export default function AgentHandoffToAgent() {
|
|
185
|
+
return (
|
|
186
|
+
<Center width="page">
|
|
187
|
+
<Stack gap="large">
|
|
188
|
+
<Heading level={1} size="h5">Launch plan</Heading>
|
|
189
|
+
{/* A real app gives the list that holds the rows role="log". */}
|
|
190
|
+
<Stack gap="small">
|
|
191
|
+
<Message
|
|
192
|
+
aria-label={request.from}
|
|
193
|
+
avatar={<UserImage userHandle={request.from} decorative />}
|
|
194
|
+
name={request.from}
|
|
195
|
+
meta={<TimeStamp createdAt={request.at} dateFormat="absolute" data="time" />}
|
|
196
|
+
>
|
|
197
|
+
<Paragraph measure="none">{request.text}</Paragraph>
|
|
198
|
+
</Message>
|
|
199
|
+
<Message
|
|
200
|
+
aria-label={`${agentName}, agent`}
|
|
201
|
+
avatar={<UserImage userHandle={agentName} icon={Bot} decorative />}
|
|
202
|
+
name={agentName}
|
|
203
|
+
meta={agentMeta(fixedAt)}
|
|
204
|
+
>
|
|
205
|
+
<Stack gap="medium">
|
|
206
|
+
<Paragraph measure="none">I fixed the Terms link in the footer and opened a pull request.</Paragraph>
|
|
207
|
+
<SourceCard icon={GitPullRequest} title="Fix the Terms link" meta="Pull request · Waiting for review" href="/pulls/1187" />
|
|
208
|
+
</Stack>
|
|
209
|
+
</Message>
|
|
210
|
+
{/* One line, with its reason, so the hand-off is never silent. */}
|
|
211
|
+
<Message compact aria-label={`${agentName}, agent`}>
|
|
212
|
+
<Paragraph size="body2" tone="secondary" measure="none">Handed off to {reviewerName}. It checks every change before it merges.</Paragraph>
|
|
213
|
+
</Message>
|
|
214
|
+
<Message
|
|
215
|
+
aria-label={`${reviewerName}, agent`}
|
|
216
|
+
avatar={<UserImage userHandle={reviewerName} icon={Bot} decorative />}
|
|
217
|
+
name={reviewerName}
|
|
218
|
+
meta={agentMeta(reviewAt)}
|
|
219
|
+
>
|
|
220
|
+
<Stack gap="medium">
|
|
221
|
+
{/* Its first message says what it is and what it will do. */}
|
|
222
|
+
<Paragraph measure="none">I am {reviewerName}, the agent that checks changes before they merge. I am reviewing the fix to the Terms link now, and I will post what I find here.</Paragraph>
|
|
223
|
+
<Paragraph size="caption" tone="secondary" measure="none">If the review needs a decision and nobody answers by 5:00 PM, I cancel the review and say so here. Nothing merges.</Paragraph>
|
|
224
|
+
</Stack>
|
|
225
|
+
</Message>
|
|
226
|
+
</Stack>
|
|
227
|
+
</Stack>
|
|
228
|
+
</Center>
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function AgentMemoryList(): import("react").JSX.Element;
|
|
@@ -0,0 +1,256 @@
|
|
|
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 Link from '../../components/link';
|
|
18
|
+
import Button from '../../components/button';
|
|
19
|
+
import IconButton from '../../components/iconButton';
|
|
20
|
+
import Tooltip from '../../components/tooltip';
|
|
21
|
+
import Popover from '../../components/popover';
|
|
22
|
+
import Menu from '../../components/menu';
|
|
23
|
+
import MenuItem from '../../components/menuItem';
|
|
24
|
+
import Line from '../../components/line';
|
|
25
|
+
import TextField from '../../components/textField';
|
|
26
|
+
import EmptyBox from '../../components/emptyBox';
|
|
27
|
+
import SettingsSection from '../../components/settingsSection';
|
|
28
|
+
import TableContainer from '../../components/tableContainer';
|
|
29
|
+
import TableRow from '../../components/tableRow';
|
|
30
|
+
import TableCell from '../../components/tableCell';
|
|
31
|
+
import { Center, Cluster, Stack } from '../../components/layout';
|
|
32
|
+
// A real app reads these from the server.
|
|
33
|
+
var firstMemories = [
|
|
34
|
+
{ id: 'lead', text: 'Dana Lee leads the pricing work for the launch.', from: 'From a chat on Nov 12, 2026', href: '/chat/launch/m-2210', seenBy: 'everyone' },
|
|
35
|
+
{ id: 'short', text: 'Dana prefers short answers with a link to the task.', from: 'From a chat on Nov 10, 2026', href: '/chat/dm/m-1984', seenBy: 'you' },
|
|
36
|
+
{ id: 'cents', text: 'Prices are written with cents, such as $8.00.', from: 'From a chat on Nov 3, 2026', href: '/chat/launch/m-1820', seenBy: 'everyone' },
|
|
37
|
+
{ id: 'hours', text: 'Dana works from 9:00 AM to 5:00 PM Central time.', from: 'From a chat on Oct 28, 2026', href: '/chat/dm/m-1702', seenBy: 'you' },
|
|
38
|
+
];
|
|
39
|
+
var seenByLine = { you: 'Only you can see this.', everyone: 'Everyone in Acme can see this.' };
|
|
40
|
+
export default function AgentMemoryList() {
|
|
41
|
+
var _a = useState(firstMemories), memories = _a[0], setMemories = _a[1];
|
|
42
|
+
var _b = useState(''), query = _b[0], setQuery = _b[1];
|
|
43
|
+
// The row whose menu is open, and the More button it opens from. Both stay set while the menu fades out.
|
|
44
|
+
var _c = useState(null), menuRow = _c[0], setMenuRow = _c[1];
|
|
45
|
+
var _d = useState(null), menuAnchor = _d[0], setMenuAnchor = _d[1];
|
|
46
|
+
var _e = useState(false), menuOpen = _e[0], setMenuOpen = _e[1];
|
|
47
|
+
// One row at a time asks to confirm 'Forget', or is being edited.
|
|
48
|
+
var _f = useState(null), confirmingId = _f[0], setConfirmingId = _f[1];
|
|
49
|
+
var _g = useState(null), editingId = _g[0], setEditingId = _g[1];
|
|
50
|
+
var _h = useState(''), draft = _h[0], setDraft = _h[1];
|
|
51
|
+
var _j = useState(null), pending = _j[0], setPending = _j[1];
|
|
52
|
+
var _k = useState(false), confirmingAll = _k[0], setConfirmingAll = _k[1];
|
|
53
|
+
var timer = useRef();
|
|
54
|
+
var toastIds = useRef([]);
|
|
55
|
+
var searchField = useRef(null);
|
|
56
|
+
var cancelForget = useRef(null);
|
|
57
|
+
var editField = useRef(null);
|
|
58
|
+
var forgetAllButton = useRef(null);
|
|
59
|
+
var cancelForgetAll = useRef(null);
|
|
60
|
+
// Each row's More button by memory id, so focus can move to one when the thing that had it is gone.
|
|
61
|
+
var moreButtons = 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 the request and closes every toast it opened.
|
|
65
|
+
useEffect(function () { return function () {
|
|
66
|
+
clearTimeout(timer.current);
|
|
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
|
+
var words = query.trim().toLowerCase();
|
|
76
|
+
var shown = words === '' ? memories : memories.filter(function (m) { return m.text.toLowerCase().includes(words); });
|
|
77
|
+
function openMenu(m, anchor) {
|
|
78
|
+
if (menuOpen && (menuRow === null || menuRow === void 0 ? void 0 : menuRow.id) === m.id) {
|
|
79
|
+
setMenuOpen(false);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
setMenuRow(m);
|
|
83
|
+
setMenuAnchor(anchor);
|
|
84
|
+
setMenuOpen(true);
|
|
85
|
+
}
|
|
86
|
+
// Every item closes the menu, and Escape and a click outside do too. The Popover gives focus back to More.
|
|
87
|
+
function choose(action) {
|
|
88
|
+
if (!menuRow)
|
|
89
|
+
return;
|
|
90
|
+
var m = menuRow;
|
|
91
|
+
setMenuOpen(false);
|
|
92
|
+
action(m);
|
|
93
|
+
}
|
|
94
|
+
// The row turns into a field, with focus in it.
|
|
95
|
+
function startEdit(m) {
|
|
96
|
+
setConfirmingId(null);
|
|
97
|
+
setDraft(m.text);
|
|
98
|
+
setEditingId(m.id);
|
|
99
|
+
focusNext.current = function () { var _a; return (_a = editField.current) === null || _a === void 0 ? void 0 : _a.focus(); };
|
|
100
|
+
}
|
|
101
|
+
// 'Cancel' and 'Save' go away with the field, so focus goes back to the row's More button.
|
|
102
|
+
function cancelEdit() {
|
|
103
|
+
if (pending || !editingId)
|
|
104
|
+
return;
|
|
105
|
+
var id = editingId;
|
|
106
|
+
setEditingId(null);
|
|
107
|
+
focusNext.current = function () { var _a; return (_a = moreButtons.current[id]) === null || _a === void 0 ? void 0 : _a.focus(); };
|
|
108
|
+
}
|
|
109
|
+
function saveEdit() {
|
|
110
|
+
if (pending || !editingId || draft.trim() === '')
|
|
111
|
+
return;
|
|
112
|
+
var id = editingId;
|
|
113
|
+
var text = draft.trim();
|
|
114
|
+
setPending('save');
|
|
115
|
+
// Stands in for the request to the server.
|
|
116
|
+
timer.current = setTimeout(function () {
|
|
117
|
+
setPending(null);
|
|
118
|
+
setMemories(function (list) { return list.map(function (m) { return (m.id === id ? __assign(__assign({}, m), { text: text }) : m); }); });
|
|
119
|
+
setEditingId(null);
|
|
120
|
+
// The row's More button, or the search field when the saved memory no longer matches the search.
|
|
121
|
+
focusNext.current = function () { var _a, _b; return (_b = ((_a = moreButtons.current[id]) !== null && _a !== void 0 ? _a : searchField.current)) === null || _b === void 0 ? void 0 : _b.focus(); };
|
|
122
|
+
}, 1200);
|
|
123
|
+
}
|
|
124
|
+
// The confirm opens in the row, with focus on 'Cancel'.
|
|
125
|
+
function askToForget(m) {
|
|
126
|
+
setEditingId(null);
|
|
127
|
+
setConfirmingId(m.id);
|
|
128
|
+
focusNext.current = function () { var _a; return (_a = cancelForget.current) === null || _a === void 0 ? void 0 : _a.focus(); };
|
|
129
|
+
}
|
|
130
|
+
// 'Cancel' goes away with the confirm, so focus goes back to the row's More button.
|
|
131
|
+
function keepMemory() {
|
|
132
|
+
if (pending || !confirmingId)
|
|
133
|
+
return;
|
|
134
|
+
var id = confirmingId;
|
|
135
|
+
setConfirmingId(null);
|
|
136
|
+
focusNext.current = function () { var _a; return (_a = moreButtons.current[id]) === null || _a === void 0 ? void 0 : _a.focus(); };
|
|
137
|
+
}
|
|
138
|
+
function confirmForget() {
|
|
139
|
+
var _a;
|
|
140
|
+
if (pending || !confirmingId)
|
|
141
|
+
return;
|
|
142
|
+
var id = confirmingId;
|
|
143
|
+
var at = shown.findIndex(function (m) { return m.id === id; });
|
|
144
|
+
var neighbor = (_a = shown[at + 1]) !== null && _a !== void 0 ? _a : shown[at - 1];
|
|
145
|
+
setPending('forget');
|
|
146
|
+
// Stands in for the request to the server.
|
|
147
|
+
timer.current = setTimeout(function () {
|
|
148
|
+
setPending(null);
|
|
149
|
+
setConfirmingId(null);
|
|
150
|
+
setMemories(function (list) { return list.filter(function (m) { return m.id !== id; }); });
|
|
151
|
+
toastIds.current.push(toast({ type: 'success', message: 'Memory forgotten.' }));
|
|
152
|
+
// The row is gone: focus goes to the next row's More button, or the one before it when it was the last.
|
|
153
|
+
// With no row left, it goes to the search field.
|
|
154
|
+
focusNext.current = function () { var _a; return (_a = (neighbor ? moreButtons.current[neighbor.id] : searchField.current)) === null || _a === void 0 ? void 0 : _a.focus(); };
|
|
155
|
+
}, 1200);
|
|
156
|
+
}
|
|
157
|
+
// The danger zone's confirm opens in place, with focus on 'Cancel'.
|
|
158
|
+
function askToForgetAll() {
|
|
159
|
+
setConfirmingAll(true);
|
|
160
|
+
focusNext.current = function () { var _a; return (_a = cancelForgetAll.current) === null || _a === void 0 ? void 0 : _a.focus(); };
|
|
161
|
+
}
|
|
162
|
+
function keepAll() {
|
|
163
|
+
if (pending)
|
|
164
|
+
return;
|
|
165
|
+
setConfirmingAll(false);
|
|
166
|
+
focusNext.current = function () { var _a; return (_a = forgetAllButton.current) === null || _a === void 0 ? void 0 : _a.focus(); };
|
|
167
|
+
}
|
|
168
|
+
// Every row and the danger zone go away, so focus goes to the search field.
|
|
169
|
+
function forgetAll() {
|
|
170
|
+
if (pending)
|
|
171
|
+
return;
|
|
172
|
+
setPending('forget-all');
|
|
173
|
+
// Stands in for the request to the server.
|
|
174
|
+
timer.current = setTimeout(function () {
|
|
175
|
+
setPending(null);
|
|
176
|
+
setConfirmingAll(false);
|
|
177
|
+
setConfirmingId(null);
|
|
178
|
+
setEditingId(null);
|
|
179
|
+
setMemories([]);
|
|
180
|
+
setQuery('');
|
|
181
|
+
toastIds.current.push(toast({ type: 'success', message: 'Acme Agent forgot every memory.' }));
|
|
182
|
+
focusNext.current = function () { var _a; return (_a = searchField.current) === null || _a === void 0 ? void 0 : _a.focus(); };
|
|
183
|
+
}, 1200);
|
|
184
|
+
}
|
|
185
|
+
function clearSearch() {
|
|
186
|
+
var _a;
|
|
187
|
+
setQuery('');
|
|
188
|
+
(_a = searchField.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
189
|
+
}
|
|
190
|
+
return (<Center width="page">
|
|
191
|
+
{/* A real app mounts one Toaster near its root. */}
|
|
192
|
+
<Toaster />
|
|
193
|
+
<Stack gap="xlarge">
|
|
194
|
+
<Stack gap="small">
|
|
195
|
+
<Heading level={1} size="h5">Memory</Heading>
|
|
196
|
+
<Paragraph tone="secondary" size="body2" measure="none">What Acme Agent has learned from your chats. It uses this to answer you.</Paragraph>
|
|
197
|
+
</Stack>
|
|
198
|
+
|
|
199
|
+
<SettingsSection title="What Acme Agent remembers" description="Each memory says where it came from and who else can see it.">
|
|
200
|
+
<TextField ref={searchField} id="agent-memory-list-search" type="search" label="Search memories" value={query} autoComplete="off" onChange={function (e) { return setQuery(e.target.value); }}/>
|
|
201
|
+
{shown.length > 0 ? (<TableContainer>
|
|
202
|
+
{shown.map(function (m) {
|
|
203
|
+
var confirming = m.id === confirmingId;
|
|
204
|
+
var editing = m.id === editingId;
|
|
205
|
+
return (<TableRow key={m.id}>
|
|
206
|
+
<TableCell>
|
|
207
|
+
{editing ? (<TextField ref={editField} id={"agent-memory-list-edit-".concat(m.id)} label="Memory" value={draft} disabled={pending === 'save'} error={draft.trim() === ''} errorText={draft.trim() === '' ? 'Write the memory, or use Forget to remove it.' : undefined} onChange={function (e) { return setDraft(e.target.value); }}/>) : (<Stack gap="small">
|
|
208
|
+
{m.text}
|
|
209
|
+
{confirming ? (<Paragraph size="body2" tone="secondary" measure="none">Forget this memory? Acme Agent stops using it.</Paragraph>) : (<Cluster gap="small">
|
|
210
|
+
<Link href={m.href} size="caption">{m.from}</Link>
|
|
211
|
+
<Paragraph size="caption" tone="secondary" measure="none">{seenByLine[m.seenBy]}</Paragraph>
|
|
212
|
+
</Cluster>)}
|
|
213
|
+
</Stack>)}
|
|
214
|
+
</TableCell>
|
|
215
|
+
{/* A fixed last column keeps every row's Buttons in one place, so they do not jump when they change. */}
|
|
216
|
+
<TableCell width="168px" align="right">
|
|
217
|
+
{confirming ? (<Cluster gap="small" justify="end">
|
|
218
|
+
<Button ref={cancelForget} size="small" type="tertiary" state={pending === 'forget' ? 'disabled' : 'enabled'} label="Cancel" aria-label={"Cancel forgetting ".concat(m.text)} onClickButton={keepMemory}/>
|
|
219
|
+
<Button size="small" type="primary" color="danger" state="enabled" label="Forget" aria-label={"Forget ".concat(m.text)} loading={pending === 'forget'} onClickButton={confirmForget}/>
|
|
220
|
+
</Cluster>) : editing ? (<Cluster gap="small" justify="end">
|
|
221
|
+
<Button size="small" type="tertiary" state={pending === 'save' ? 'disabled' : 'enabled'} label="Cancel" aria-label="Cancel editing the memory" onClickButton={cancelEdit}/>
|
|
222
|
+
<Button size="small" type="primary" state={draft.trim() === '' ? 'disabled' : 'enabled'} label="Save" aria-label="Save the memory" loading={pending === 'save'} onClickButton={saveEdit}/>
|
|
223
|
+
</Cluster>) : (<Cluster justify="end">
|
|
224
|
+
<Tooltip title="More">
|
|
225
|
+
<IconButton ref={function (el) { moreButtons.current[m.id] = el; }} color="iconOnly" state={menuOpen && (menuRow === null || menuRow === void 0 ? void 0 : menuRow.id) === m.id ? 'selected' : 'enabled'} size="small" iconName="Ellipsis" ariaLabel={"More actions for ".concat(m.text)} aria-haspopup="menu" aria-expanded={menuOpen && (menuRow === null || menuRow === void 0 ? void 0 : menuRow.id) === m.id} onClick={function (e) { return openMenu(m, e.currentTarget); }}/>
|
|
226
|
+
</Tooltip>
|
|
227
|
+
</Cluster>)}
|
|
228
|
+
</TableCell>
|
|
229
|
+
</TableRow>);
|
|
230
|
+
})}
|
|
231
|
+
</TableContainer>) : memories.length > 0 ? (<EmptyBox size="small" icon="Search" text={"No memories match \"".concat(query.trim(), "\"")} secondText="Try other words, or clear the search." action={<Button size="small" type="secondary" state="enabled" label="Clear Search" onClickButton={clearSearch}/>}/>) : (<EmptyBox size="small" icon="Brain" text="No memories" secondText="What Acme Agent learns in your chats appears here."/>)}
|
|
232
|
+
</SettingsSection>
|
|
233
|
+
|
|
234
|
+
{memories.length > 0 && (<SettingsSection tone="danger" title="Forget everything" description="This cannot be undone.">
|
|
235
|
+
<Paragraph size="body2" measure="none">Acme Agent forgets every memory listed here. Your chats and files stay.</Paragraph>
|
|
236
|
+
{confirmingAll ? (<>
|
|
237
|
+
<Paragraph size="body2" measure="none">Forget all {memories.length} memories?</Paragraph>
|
|
238
|
+
<Cluster gap="small">
|
|
239
|
+
<Button ref={cancelForgetAll} size="small" type="tertiary" state={pending === 'forget-all' ? 'disabled' : 'enabled'} label="Cancel" aria-label="Cancel forgetting everything" onClickButton={keepAll}/>
|
|
240
|
+
<Button size="small" type="primary" color="danger" state="enabled" label="Forget Everything" loading={pending === 'forget-all'} onClickButton={forgetAll}/>
|
|
241
|
+
</Cluster>
|
|
242
|
+
</>) : (<Cluster>
|
|
243
|
+
<Button ref={forgetAllButton} size="small" type="secondary" color="danger" state="enabled" label="Forget Everything" onClickButton={askToForgetAll}/>
|
|
244
|
+
</Cluster>)}
|
|
245
|
+
</SettingsSection>)}
|
|
246
|
+
</Stack>
|
|
247
|
+
<Popover open={menuOpen} anchorEl={menuAnchor} onClose={function () { return setMenuOpen(false); }} returnFocus>
|
|
248
|
+
<Menu navigable aria-label={menuRow ? "Actions for ".concat(menuRow.text) : 'Memory actions'} width={200}>
|
|
249
|
+
<MenuItem size="small" iconName="Pencil" label="Edit" onClick={function () { return choose(startEdit); }}/>
|
|
250
|
+
<Line />
|
|
251
|
+
{/* Forget is last, and danger. */}
|
|
252
|
+
<MenuItem size="small" color="danger" iconName="Trash2" label="Forget" onClick={function () { return choose(askToForget); }}/>
|
|
253
|
+
</Menu>
|
|
254
|
+
</Popover>
|
|
255
|
+
</Center>);
|
|
256
|
+
}
|