oneslash-design-system 2.16.0 → 2.17.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 +26 -3
- 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 +2 -2
- 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 +168 -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 +432 -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 +656 -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 +338 -0
- package/dist/cases/agent-shows-sources.md +2 -2
- 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 +103 -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 +286 -0
- 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 +208 -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 +252 -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 +651 -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 +310 -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 +356 -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 +179 -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 +371 -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 +189 -0
- 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 +552 -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 +247 -0
- 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 +247 -0
- package/dist/cases/success-feedback.md +1 -1
- 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 +96 -0
- package/dist/cases.json +1276 -14
- package/dist/components/button.d.ts +3 -2
- package/dist/components/button.jsx +9 -7
- package/dist/components/composer.d.ts +74 -0
- package/dist/components/composer.jsx +122 -0
- package/dist/components/fileChip.d.ts +33 -0
- package/dist/components/fileChip.jsx +61 -0
- 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 +9 -1
- package/dist/components/menuItem.jsx +5 -4
- package/dist/components/message.d.ts +28 -0
- package/dist/components/message.jsx +25 -0
- 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 +8 -1
- package/dist/components/radioGroup.jsx +19 -8
- 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/tag.d.ts +9 -1
- package/dist/components/tag.jsx +6 -4
- package/dist/components/textarea.jsx +3 -18
- package/dist/components/userImage.d.ts +9 -1
- package/dist/components/userImage.jsx +10 -3
- 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/menu.d.ts +6 -0
- package/dist/internal/menu.js +31 -0
- package/dist/native-mapping.json +32 -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 +30 -0
- package/dist/stories/Cases.generated.stories.jsx +60 -0
- package/dist/stories/Composer.stories.d.ts +23 -0
- package/dist/stories/Composer.stories.jsx +121 -0
- package/dist/stories/FileChip.stories.d.ts +7 -0
- package/dist/stories/FileChip.stories.jsx +35 -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/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/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/UserImage.stories.d.ts +2 -0
- package/dist/stories/UserImage.stories.jsx +19 -0
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -70,7 +70,7 @@ import SectionIntro from 'oneslash-design-system/components/sectionIntro';
|
|
|
70
70
|
|
|
71
71
|
## Design cases
|
|
72
72
|
|
|
73
|
-
A case is one design situation with oneSlash's answer to it. A rule case has one answer, such as "an agent asks before a risky action". A design case has one to four options, each with a line on when to use it and a working example built only from this package. 2.
|
|
73
|
+
A case is one design situation with oneSlash's answer to it. A rule case has one answer, such as "an agent asks before a risky action". A design case has one to four options, each with a line on when to use it and a working example built only from this package. 2.17.0 has 56: ten rules and 46 design cases for auth pages, confirms and modals, states, chat and agent interfaces.
|
|
74
74
|
|
|
75
75
|
- `oneslash-design-system/cases.json` lists every case with its rule text, options, Do and Don't lines, and the source of each example.
|
|
76
76
|
- `oneslash-design-system/cases/<id>.md` is one case as text, and `oneslash-design-system/cases/<id>/<option>.jsx` is the example itself.
|
package/dist/DESIGN.md
CHANGED
|
@@ -295,9 +295,11 @@ For each web component, the table gives the native control to use. System contro
|
|
|
295
295
|
| button | `Button` with `.odsProminentButton()` for accent (`.odsProminentButton(.glass)` for the glass style), `.bordered` for primary | `Button`, `OutlinedButton` | Tertiary and text-only: `.borderless` / `TextButton`. On Apple, apply `.odsProminentButton()` to every prominent button. Under `odsTheme` the label of a `.borderedProminent` or `.glassProminent` button takes `text.primary`, not the system white, which is below 4.5:1 on the accent in default dark, forest light, forest dark, clay dark, indigo light, indigo dark, wine light, wine dark. In forest light it is the same color as the fill, so the label cannot be seen. The modifier keeps the system style and sets the label to `accent.contrast`. Compose needs nothing: `onPrimary` is `accent.contrast`. |
|
|
296
296
|
| brandIcon | the provider's own button where one exists (`SignInWithAppleButton`), else an asset in the app | an asset in the app | |
|
|
297
297
|
| checkBox | `Toggle` (switch on iOS, `.toggleStyle(.checkbox)` on macOS) | `Checkbox` | |
|
|
298
|
+
| composer | `TextField(_:text:axis: .vertical)` with `.lineLimit(1...6)` over a toolbar `HStack` of the tool `Button`s and a send `Button` | `OutlinedTextField` with `maxLines = 6` over a `Row` of the tool `IconButton`s and a send `IconButton` | On iPhone and Android, Return adds a line and the send button sends. While an agent works, send becomes Stop. |
|
|
298
299
|
| emptyBox | `ContentUnavailableView` | `OdsEmptyState` | The system has this control on Apple, so ODS adds no part there. Material has none, so ODS does. |
|
|
299
300
|
| factsRow | Not applicable: web page pattern | Not applicable: web page pattern | In an app screen: `LabeledContent` rows in a `Form` / `ListItem` rows. |
|
|
300
301
|
| figure | Not applicable: web page pattern | Not applicable: web page pattern | In an app screen: an `Image` with a caption `Text` in the caption text style. |
|
|
302
|
+
| fileChip | A capsule `Label` (`.labelStyle(.titleAndIcon)`) with the file icon, the name and size, and a `Button` with `xmark.circle.fill` to remove it | An `InputChip` with a `trailingIcon` that removes it | An uploading chip gets a `ProgressView`; a failed one an alert symbol, not color alone. Say the state in the VoiceOver / TalkBack label. |
|
|
301
303
|
| form | `Form` | A `Column` of fields; submit from the keyboard action | On Apple the system lays the fields out; do not add spacing. |
|
|
302
304
|
| heading | `Text` with the type role's text style and `.accessibilityAddTraits(.isHeader)` | `Text` with the type role's `MaterialTheme.typography` style and `Modifier.semantics { heading() }` | |
|
|
303
305
|
| icon | `Image(systemName:)` (SF Symbols) | Material Symbols | |
|
|
@@ -311,6 +313,7 @@ For each web component, the table gives the native control to use. System contro
|
|
|
311
313
|
| loadingScreen | `ProgressView` | `CircularProgressIndicator` | |
|
|
312
314
|
| menu | `Menu` or `.contextMenu` | `DropdownMenu` | |
|
|
313
315
|
| menuItem | `Button` inside a `Menu` | `DropdownMenuItem` | In a sidebar: a `List` row / `NavigationDrawerItem`. |
|
|
316
|
+
| message | An `HStack` with `ODSAvatar` and a `VStack` of the header and the body | A `Row` with `OdsAvatar` and a `Column` of the header and the body | SwiftUI and Compose have no message row. Mark an agent with `ODSTag` / `OdsTag` after its name. |
|
|
314
317
|
| modal | `.sheet` or `.alert` | `ModalBottomSheet` or `AlertDialog` | `ModalBottomSheet` needs `@OptIn(ExperimentalMaterial3Api::class)`. |
|
|
315
318
|
| navigation | `NavigationSplitView` with a sidebar `List` | `NavigationRail` or `ModalNavigationDrawer` with `NavigationDrawerItem` | |
|
|
316
319
|
| numberedRow | Not applicable: web page pattern | Not applicable: web page pattern | In an app screen: rows of a `List` / `ListItem`s. |
|
|
@@ -318,9 +321,11 @@ For each web component, the table gives the native control to use. System contro
|
|
|
318
321
|
| pageShell | Not applicable: web page pattern | Not applicable: web page pattern | In an app screen: `NavigationStack` / `Scaffold`. |
|
|
319
322
|
| paragraph | `Text` with `.font(.body)` | `Text` with `MaterialTheme.typography.bodyLarge` | |
|
|
320
323
|
| popover | `.popover` | `DropdownMenu` | Larger anchored content on Android: `ModalBottomSheet`. |
|
|
321
|
-
| radioGroup | `Picker` (`.inline` on iOS, `.radioGroup` on macOS) | `RadioButton`s in a `Column` with `Modifier.selectableGroup()` |
|
|
324
|
+
| radioGroup | `Picker` (`.inline` on iOS, `.radioGroup` on macOS) | `RadioButton`s in a `Column` with `Modifier.selectableGroup()` | `variant="card"`: each option is a bordered card with the radio in it, a `Picker` with custom rows on iOS / selectable `Card`s with a `RadioButton` in a `selectableGroup` on Android. |
|
|
322
325
|
| sectionIntro | Not applicable: web page pattern | Not applicable: web page pattern | In an app screen: a `Section` header in a `List` or `Form` / a heading `Text`. |
|
|
323
326
|
| select | `Picker` or `Menu` | `ExposedDropdownMenuBox` | |
|
|
327
|
+
| sourceCard | `Link` or `Button` with a `Label` (icon, title) and the meta as a secondary line | A `Card` with `onClick`, or a `ListItem` with a leading `Icon` | With no destination it is a plain `Label`, not a button. |
|
|
328
|
+
| stepList | A `List` of `Label`s with an SF Symbol per status (`circle`, `checkmark.circle.fill`, `xmark.circle.fill`, `minus.circle`); `ProgressView` for the running one | A `Column` of `ListItem`s with an `Icon` per status; `CircularProgressIndicator` for the running one | Give each row a status text for VoiceOver / TalkBack, not color alone. |
|
|
324
329
|
| surface | Not applicable: web page pattern | Not applicable: web page pattern | In an app screen: a `Form` section or `GroupBox` / `Card`. |
|
|
325
330
|
| tab | `TabView` or segmented `Picker` | `PrimaryTabRow` | One `Tab` inside `TabView` or one segment / one `Tab`. `TabRow` is deprecated in Material 3. |
|
|
326
331
|
| tableCell | A `TableColumn` content view | `Text` in a `Row` with `Modifier.weight` | Material 3 has no table. |
|
|
@@ -428,7 +433,7 @@ File: cases/agent-shows-progress.md
|
|
|
428
433
|
|
|
429
434
|
The agent answers from things it read: documents, files, chat, tasks, or a connected service such as a code host or a design tool.
|
|
430
435
|
|
|
431
|
-
Answer: Under the reply, the agent lists what it used. A small tag names the kinds of source, such as 'From Chat · Knowledge base', and one card per source shows its title, its kind and where it lives. Each card opens the source. A reply that used no sources shows no sources section.
|
|
436
|
+
Answer: Under the reply, the agent lists what it used. A small tag names the kinds of source, such as 'From Chat · Knowledge base', and one card per source shows its title, its kind and where it lives. Each card opens the source. A reply that used no sources shows no sources section. When the reply read only the messages already on screen above it, the Tag alone is enough.
|
|
432
437
|
|
|
433
438
|
File: cases/agent-shows-sources.md
|
|
434
439
|
|
|
@@ -466,7 +471,7 @@ File: cases/form-errors.md
|
|
|
466
471
|
|
|
467
472
|
Something the person did has worked.
|
|
468
473
|
|
|
469
|
-
Answer: The feedback depends on where the result shows. A Button that is `loading` keeps its label, and the spinner shows that it is working. Only success changes a label, and there are three success labels: 'Saved', 'Copied' and 'Sent', each for 2 seconds. When a form saves in place, its Button is `loading`, then reads 'Saved' for 2 seconds, then its own label again. There is no toast. Sometimes the result is somewhere else or gone. Something was deleted, sent, moved or duplicated somewhere else, or a long job has finished. Then call `toast({ type: 'success', message: '…' })` with one short sentence in the past tense, in sentence case. It closes after 5 seconds. When something is copied to the clipboard, a Button reads 'Copied' for 2 seconds, and an IconButton swaps its icon to `Check` for 2 seconds. When a Button sends an email again, it reads 'Sent' for 2 seconds. The message names the thing and does not say 'successfully'.
|
|
474
|
+
Answer: The feedback depends on where the result shows. A Button that is `loading` keeps its label, and the spinner shows that it is working. Only success changes a label, and there are three success labels: 'Saved', 'Copied' and 'Sent', each for 2 seconds. When a form saves in place, its Button is `loading`, then reads 'Saved' for 2 seconds, then its own label again. There is no toast. Sometimes the result is somewhere else or gone. Something was deleted, sent, moved or duplicated somewhere else, or a long job has finished. Then call `toast({ type: 'success', message: '…' })` with one short sentence in the past tense, in sentence case. It closes after 5 seconds. When something is copied to the clipboard, a Button reads 'Copied' for 2 seconds, and an IconButton swaps its icon to `Check` for 2 seconds. When Copy is a menu item, the menu closes, so a toast says 'Message copied.' instead. When a Button sends an email again, it reads 'Sent' for 2 seconds. The message names the thing and does not say 'successfully'.
|
|
470
475
|
|
|
471
476
|
**Not built yet:** Scindo on the web has no toast. It shows success in five ways: a 'Saved' Button label, a green caption, an inline Alert, a thank-you that replaces a dialog and a 'Copied' label. The timed ones clear after 1.5, 2, 3 or 4 seconds. Commentify shows toasts through `Alert`, one at a time, and many of them say 'successfully'.
|
|
472
477
|
|
|
@@ -475,9 +480,16 @@ File: cases/success-feedback.md
|
|
|
475
480
|
| Case | When | File |
|
|
476
481
|
| --- | --- | --- |
|
|
477
482
|
| Invite link page | A person opens an invite link to join a workspace. | cases/accept-invite.md |
|
|
483
|
+
| Agent options | The agent sees two to four ways forward and needs the person to pick one. These are ways forward for the agent's own work. For a fact or a decision only the person has, see the case 'Agent question'. | cases/agent-options.md |
|
|
484
|
+
| Agent at work | The agent is working on a request in the thread, and its reply is not ready yet. | cases/agent-pending-reply.md |
|
|
485
|
+
| Plan proposal | The agent is about to change shared work and needs the person to approve it first. | cases/agent-plan-proposal.md |
|
|
486
|
+
| Agent question | The agent needs an answer from the person before it can go on. It needs a fact or a decision only the person has. For ways forward in its own work, see the case 'Agent options'. | cases/agent-question.md |
|
|
487
|
+
| Document card | The agent made a document for the person, such as a plan or a report. | cases/artifact-card.md |
|
|
478
488
|
| Login check loading | The app is checking whether the person is logged in, or running a step such as checking an invite, before it knows what to show. | cases/auth-gate-loading.md |
|
|
479
489
|
| Check your email | A person signed up, and the product sent a link to confirm their email. | cases/check-your-email.md |
|
|
490
|
+
| Composer at a limit | The agent cannot be called from the composer because the workspace reached a limit, such as its agent replies for the month. | cases/composer-limit.md |
|
|
480
491
|
| Delete confirm | A person asks to delete or remove something, and it cannot be undone. | cases/confirm-destructive-action.md |
|
|
492
|
+
| Conversation starters | A thread has no messages yet, and the person may not know what to write first. | cases/conversation-starters.md |
|
|
481
493
|
| Create modal | A person creates something new, such as a project or a task, and it needs a name before it exists. | cases/create-modal.md |
|
|
482
494
|
| Device login | A CLI, an editor or another app opened the browser so the person can log in, and the login must reach that app. | cases/device-login.md |
|
|
483
495
|
| Email confirmed | A person opened the link that confirms their email. | cases/email-confirmed.md |
|
|
@@ -493,12 +505,23 @@ File: cases/success-feedback.md
|
|
|
493
505
|
| Load failure | A list or a section could not load. | cases/load-failure.md |
|
|
494
506
|
| Log-out confirm | A person chooses Log Out. | cases/log-out-confirm.md |
|
|
495
507
|
| Login page | A person who already has an account opens the product and is not logged in. | cases/login-page.md |
|
|
508
|
+
| Mention list | A person types @ in the message box to name someone, or the agent. | cases/mention-list.md |
|
|
509
|
+
| Message actions | A person acts on one message: reacts to it, copies it, edits or deletes it. | cases/message-actions.md |
|
|
510
|
+
| Attachments | A person adds files to a message, and people open the files in a message that was sent. | cases/message-attachments.md |
|
|
511
|
+
| Message composer | A person writes a message at the bottom of a thread. | cases/message-composer.md |
|
|
512
|
+
| Message edit | A person changes the text of a message they sent. | cases/message-edit.md |
|
|
513
|
+
| Reactions | People answer a message with an emoji instead of a reply. | cases/message-reactions.md |
|
|
514
|
+
| Message row | A thread shows messages from people, and sometimes from an agent. | cases/message-row.md |
|
|
496
515
|
| Page not found | A person opens a link to a page that does not exist. | cases/not-found-page.md |
|
|
497
516
|
| OAuth consent | Another app, such as a CLI or an MCP client, asks to act for a person who is logged in, and the person must allow it. | cases/oauth-consent.md |
|
|
498
517
|
| Rename | A person renames something, such as a project or a channel. | cases/rename.md |
|
|
518
|
+
| Reply feedback | The agent has replied, and the person can say whether the reply helped. | cases/reply-feedback.md |
|
|
519
|
+
| Reply sources | The agent answered from things it read, and the person may want to check them. | cases/reply-sources.md |
|
|
499
520
|
| Page loading | A page or a pane is loading, and there is nothing to show yet. | cases/route-loading.md |
|
|
500
521
|
| Set new password | A person opened the link to reset their password and now chooses a new one. | cases/set-new-password.md |
|
|
501
522
|
| Sign-up page | A person who has no account yet opens the product and wants one. | cases/sign-up-page.md |
|
|
523
|
+
| Command list | A person types / at the start of the message box to run a command. | cases/slash-command-list.md |
|
|
502
524
|
| Type to confirm | A person asks to delete something large that cannot be brought back, such as a workspace or an account. | cases/type-to-confirm.md |
|
|
525
|
+
| Typing line | Other people in the thread are writing a message that has not arrived yet. | cases/typing-and-status.md |
|
|
503
526
|
| Unsaved changes | A person closes or leaves something they changed and did not save. | cases/unsaved-changes-guard.md |
|
|
504
527
|
| Upgrade prompt | A person reaches something their plan does not include, or a limit of their plan. | cases/upgrade-prompt.md |
|
|
@@ -42,7 +42,7 @@ export default function AcceptInviteSignedIn() {
|
|
|
42
42
|
<Stack gap="medium">
|
|
43
43
|
<Heading level={1} size="h5">You're invited to Acme Design</Heading>
|
|
44
44
|
<Cluster gap="small">
|
|
45
|
-
<UserImage userHandle="Dana Lee"/>
|
|
45
|
+
<UserImage userHandle="Dana Lee" decorative/>
|
|
46
46
|
<Paragraph size="body2" measure="none">Invited by Dana Lee</Paragraph>
|
|
47
47
|
</Cluster>
|
|
48
48
|
{/* An open link names no address, so the page shows only the workspace and the role. */}
|
|
@@ -18,7 +18,7 @@ export default function AcceptInviteSignedOut() {
|
|
|
18
18
|
<Heading level={1} size="h5">You're invited to Acme Design</Heading>
|
|
19
19
|
{/* 'Invited by' shows on every invite. */}
|
|
20
20
|
<Cluster gap="small">
|
|
21
|
-
<UserImage userHandle="Dana Lee"/>
|
|
21
|
+
<UserImage userHandle="Dana Lee" decorative/>
|
|
22
22
|
<Paragraph size="body2" measure="none">Invited by Dana Lee</Paragraph>
|
|
23
23
|
</Cluster>
|
|
24
24
|
{/* The address sentence shows only when the invite is tied to an address, and the address is masked: anyone who holds the link sees this page.
|
|
@@ -59,7 +59,7 @@ export default function AcceptInviteSignedOut() {
|
|
|
59
59
|
<Heading level={1} size="h5">You're invited to Acme Design</Heading>
|
|
60
60
|
{/* 'Invited by' shows on every invite. */}
|
|
61
61
|
<Cluster gap="small">
|
|
62
|
-
<UserImage userHandle="Dana Lee" />
|
|
62
|
+
<UserImage userHandle="Dana Lee" decorative />
|
|
63
63
|
<Paragraph size="body2" measure="none">Invited by Dana Lee</Paragraph>
|
|
64
64
|
</Cluster>
|
|
65
65
|
{/* The address sentence shows only when the invite is tied to an address, and the address is masked: anyone who holds the link sees this page.
|
|
@@ -138,7 +138,7 @@ export default function AcceptInviteSignedIn() {
|
|
|
138
138
|
<Stack gap="medium">
|
|
139
139
|
<Heading level={1} size="h5">You're invited to Acme Design</Heading>
|
|
140
140
|
<Cluster gap="small">
|
|
141
|
-
<UserImage userHandle="Dana Lee" />
|
|
141
|
+
<UserImage userHandle="Dana Lee" decorative />
|
|
142
142
|
<Paragraph size="body2" measure="none">Invited by Dana Lee</Paragraph>
|
|
143
143
|
</Cluster>
|
|
144
144
|
{/* An open link names no address, so the page shows only the workspace and the role. */}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function AgentOptionsCards(): import("react").JSX.Element;
|
|
@@ -0,0 +1,91 @@
|
|
|
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 RadioGroup from '../../components/radioGroup';
|
|
13
|
+
import { Center, Cluster, Stack } from '../../components/layout';
|
|
14
|
+
var agentName = 'Acme Agent';
|
|
15
|
+
var request = { from: 'Dana Lee', at: new Date('2025-01-15T11:40:00Z'), text: 'Can you add the Team plan to the pricing page?' };
|
|
16
|
+
var askedAt = new Date('2025-01-15T11:41:00Z');
|
|
17
|
+
var question = 'Which layout should the pricing page use?';
|
|
18
|
+
var options = [
|
|
19
|
+
{ value: 'columns', label: 'Three columns', secondLabel: 'One card per plan, side by side. Easy to compare.', badge: 'Recommended' },
|
|
20
|
+
{ value: 'table', label: 'Table', secondLabel: 'Plans as columns and features as rows.' },
|
|
21
|
+
{ value: 'switch', label: 'One plan at a time', secondLabel: 'A switch moves between the plans.' },
|
|
22
|
+
];
|
|
23
|
+
// The agent's marks, as the rule 'An agent says what it is' says.
|
|
24
|
+
function agentMeta(at) {
|
|
25
|
+
return (<>
|
|
26
|
+
<Tag variant="contained" size="small" label="Agent"/>
|
|
27
|
+
<TimeStamp createdAt={at} dateFormat="absolute" data="time"/>
|
|
28
|
+
<Paragraph size="caption" tone="secondary" measure="none">Model name</Paragraph>
|
|
29
|
+
</>);
|
|
30
|
+
}
|
|
31
|
+
export default function AgentOptionsCards() {
|
|
32
|
+
// The recommended option starts selected: the agent has a view, and the person can pick another.
|
|
33
|
+
var _a = useState('columns'), selected = _a[0], setSelected = _a[1];
|
|
34
|
+
var _b = useState('open'), status = _b[0], setStatus = _b[1];
|
|
35
|
+
var _c = useState(null), pending = _c[0], setPending = _c[1];
|
|
36
|
+
var timer = useRef();
|
|
37
|
+
// On unmount it stops the request.
|
|
38
|
+
useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
|
|
39
|
+
// Decided once: the buttons go away, so a second click cannot change it.
|
|
40
|
+
// Nothing takes their place, so a real app moves focus to the message box.
|
|
41
|
+
function decide(action) {
|
|
42
|
+
if (pending || status !== 'open' || (action === 'choose' && selected === ''))
|
|
43
|
+
return;
|
|
44
|
+
setPending(action);
|
|
45
|
+
// Stands in for the request to the server.
|
|
46
|
+
timer.current = setTimeout(function () {
|
|
47
|
+
setPending(null);
|
|
48
|
+
setStatus(action === 'choose' ? 'chosen' : 'cancelled');
|
|
49
|
+
}, 1200);
|
|
50
|
+
}
|
|
51
|
+
var chosen = options.find(function (o) { return o.value === selected; });
|
|
52
|
+
return (<Center width="page">
|
|
53
|
+
<Stack gap="large">
|
|
54
|
+
<Heading level={1} size="h5">Launch plan</Heading>
|
|
55
|
+
{/* A real app gives the list that holds the rows role="log". */}
|
|
56
|
+
<Stack gap="small">
|
|
57
|
+
<Message aria-label={request.from} avatar={<UserImage userHandle={request.from} decorative/>} name={request.from} meta={<TimeStamp createdAt={request.at} dateFormat="absolute" data="time"/>}>
|
|
58
|
+
<Paragraph measure="none">{request.text}</Paragraph>
|
|
59
|
+
</Message>
|
|
60
|
+
<Message aria-label={"".concat(agentName, ", agent")} avatar={<UserImage userHandle={agentName} icon={Bot} decorative/>} name={agentName} meta={agentMeta(askedAt)}>
|
|
61
|
+
<Surface padding="small">
|
|
62
|
+
<Stack gap="medium">
|
|
63
|
+
{/* A real app announces the decided Tag in a polite live region. */}
|
|
64
|
+
<Cluster gap="small">
|
|
65
|
+
<Heading level={2} size="subtitle1">{question}</Heading>
|
|
66
|
+
{status === 'chosen' && <Tag variant="contained" size="small" color="success" label="Chosen"/>}
|
|
67
|
+
{status === 'cancelled' && <Tag variant="contained" size="small" label="Cancelled"/>}
|
|
68
|
+
</Cluster>
|
|
69
|
+
{status === 'open' && (<>
|
|
70
|
+
<RadioGroup variant="card" aria-label={question} options={options} selectedValue={selected} onChange={setSelected} disabled={pending !== null}/>
|
|
71
|
+
{/* The product sets the waiting time and counts it down. When it is up, the card is marked Cancelled. */}
|
|
72
|
+
<Paragraph size="caption" tone="secondary" measure="none">Waits 10 more minutes, then cancels.</Paragraph>
|
|
73
|
+
<Cluster gap="small">
|
|
74
|
+
<Button size="small" type="tertiary" state={pending === 'choose' ? 'disabled' : 'enabled'} label="Cancel" loading={pending === 'cancel'} onClickButton={function () { return decide('cancel'); }}/>
|
|
75
|
+
<Button size="small" type="primary" state={selected === '' || pending === 'cancel' ? 'disabled' : 'enabled'} label="Choose" loading={pending === 'choose'} onClickButton={function () { return decide('choose'); }}/>
|
|
76
|
+
</Cluster>
|
|
77
|
+
</>)}
|
|
78
|
+
{/* Once decided, only the chosen option is left on the card. */}
|
|
79
|
+
{status === 'chosen' && chosen && <Paragraph measure="none">{chosen.label}</Paragraph>}
|
|
80
|
+
</Stack>
|
|
81
|
+
</Surface>
|
|
82
|
+
</Message>
|
|
83
|
+
{status === 'cancelled' && (
|
|
84
|
+
// One line in the thread on what was not done, under the card.
|
|
85
|
+
<Message compact aria-label={"".concat(agentName, ", agent")}>
|
|
86
|
+
<Paragraph measure="none">Cancelled. Nothing was changed.</Paragraph>
|
|
87
|
+
</Message>)}
|
|
88
|
+
</Stack>
|
|
89
|
+
</Stack>
|
|
90
|
+
</Center>);
|
|
91
|
+
}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
# Agent options
|
|
2
|
+
|
|
3
|
+
The agent sees two to four ways forward and needs the person to pick one. These are ways forward for the agent's own work. For a fact or a decision only the person has, see the case 'Agent question'.
|
|
4
|
+
|
|
5
|
+
**Not built yet:** Scindo's options card labels its button 'Confirm Selection', which reads 'Confirming...' while it loads, and marks a decided card 'Selected'. With no recommended option it preselects the first one. Scindo's Apple app shows no options card.
|
|
6
|
+
|
|
7
|
+
## Do
|
|
8
|
+
|
|
9
|
+
- Put the card in the agent's `Message`, in a `Surface` with the question as its heading.
|
|
10
|
+
- Show each way forward as an option of `<RadioGroup variant="card">`, with a `secondLabel` that says what it means.
|
|
11
|
+
- Give the agent's pick the `badge` 'Recommended', on one option only.
|
|
12
|
+
- Preselect the recommended option: the agent has a view, and the person can pick another. With no recommended option, preselect nothing.
|
|
13
|
+
- Disable 'Choose' until an option is picked when nothing is preselected.
|
|
14
|
+
- Give the RadioGroup an `aria-label` that starts with the question.
|
|
15
|
+
- Order the buttons 'Cancel', then 'Choose' as the primary Button, at the start of the row.
|
|
16
|
+
- Make the pressed Button `loading` and keep its label. Disable the options and the other Button while the request runs.
|
|
17
|
+
- Keep the card and its buttons when a request fails. Show an inline error `Alert` above the buttons, as the rule 'A form error shows next to the problem' says.
|
|
18
|
+
- Show the waiting time on the card while it waits: 'Waits 10 more minutes, then cancels.'
|
|
19
|
+
- Notify the person who asked when the agent needs their answer.
|
|
20
|
+
- Keep only the chosen option once it is decided, as text, with a 'Chosen' `Tag`. Remove the buttons.
|
|
21
|
+
- Mark the card with a 'Cancelled' `Tag` when it is cancelled, and add one compact agent row under it that says what was not done: 'Cancelled. Nothing was changed.'
|
|
22
|
+
- Mark the card Cancelled when the waiting time is up, with the same row on what was not done.
|
|
23
|
+
- Announce the decided `Tag` politely: the app wraps it in a polite live region.
|
|
24
|
+
- Move focus to the message box once the card is decided, since its buttons are gone.
|
|
25
|
+
|
|
26
|
+
## Don't
|
|
27
|
+
|
|
28
|
+
- Do not offer one option, or more than four.
|
|
29
|
+
- Do not give more than one option the 'Recommended' badge.
|
|
30
|
+
- Do not preselect an option the agent does not recommend.
|
|
31
|
+
- Do not recommend or preselect an option that does more than the others, such as one that deletes, publishes or widens access.
|
|
32
|
+
- Do not act on an option before the person presses Choose.
|
|
33
|
+
- Do not change a Button's label while it is loading, such as to 'Confirming...'.
|
|
34
|
+
|
|
35
|
+
## Example: Option cards
|
|
36
|
+
|
|
37
|
+
Uses: `Button`, `Center`, `Cluster`, `Heading`, `Message`, `Paragraph`, `RadioGroup`, `Stack`, `Surface`, `Tag`, `TimeStamp`, `UserImage`
|
|
38
|
+
|
|
39
|
+
```tsx
|
|
40
|
+
'use client';
|
|
41
|
+
import { useEffect, useRef, useState } from 'react';
|
|
42
|
+
import { Bot } from 'lucide-react';
|
|
43
|
+
import Message from 'oneslash-design-system/components/message';
|
|
44
|
+
import UserImage from 'oneslash-design-system/components/userImage';
|
|
45
|
+
import Tag from 'oneslash-design-system/components/tag';
|
|
46
|
+
import TimeStamp from 'oneslash-design-system/components/timeStamp';
|
|
47
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
48
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
49
|
+
import Button from 'oneslash-design-system/components/button';
|
|
50
|
+
import Surface from 'oneslash-design-system/components/surface';
|
|
51
|
+
import RadioGroup from 'oneslash-design-system/components/radioGroup';
|
|
52
|
+
import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
|
|
53
|
+
|
|
54
|
+
const agentName = 'Acme Agent';
|
|
55
|
+
|
|
56
|
+
const request = { from: 'Dana Lee', at: new Date('2025-01-15T11:40:00Z'), text: 'Can you add the Team plan to the pricing page?' };
|
|
57
|
+
const askedAt = new Date('2025-01-15T11:41:00Z');
|
|
58
|
+
|
|
59
|
+
const question = 'Which layout should the pricing page use?';
|
|
60
|
+
|
|
61
|
+
const options = [
|
|
62
|
+
{ value: 'columns', label: 'Three columns', secondLabel: 'One card per plan, side by side. Easy to compare.', badge: 'Recommended' },
|
|
63
|
+
{ value: 'table', label: 'Table', secondLabel: 'Plans as columns and features as rows.' },
|
|
64
|
+
{ value: 'switch', label: 'One plan at a time', secondLabel: 'A switch moves between the plans.' },
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
type Status = 'open' | 'chosen' | 'cancelled';
|
|
68
|
+
|
|
69
|
+
// The agent's marks, as the rule 'An agent says what it is' says.
|
|
70
|
+
function agentMeta(at: Date) {
|
|
71
|
+
return (
|
|
72
|
+
<>
|
|
73
|
+
<Tag variant="contained" size="small" label="Agent" />
|
|
74
|
+
<TimeStamp createdAt={at} dateFormat="absolute" data="time" />
|
|
75
|
+
<Paragraph size="caption" tone="secondary" measure="none">Model name</Paragraph>
|
|
76
|
+
</>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export default function AgentOptionsCards() {
|
|
81
|
+
// The recommended option starts selected: the agent has a view, and the person can pick another.
|
|
82
|
+
const [selected, setSelected] = useState('columns');
|
|
83
|
+
const [status, setStatus] = useState<Status>('open');
|
|
84
|
+
const [pending, setPending] = useState<'choose' | 'cancel' | null>(null);
|
|
85
|
+
const timer = useRef<ReturnType<typeof setTimeout>>();
|
|
86
|
+
|
|
87
|
+
// On unmount it stops the request.
|
|
88
|
+
useEffect(() => () => clearTimeout(timer.current), []);
|
|
89
|
+
|
|
90
|
+
// Decided once: the buttons go away, so a second click cannot change it.
|
|
91
|
+
// Nothing takes their place, so a real app moves focus to the message box.
|
|
92
|
+
function decide(action: 'choose' | 'cancel') {
|
|
93
|
+
if (pending || status !== 'open' || (action === 'choose' && selected === '')) return;
|
|
94
|
+
setPending(action);
|
|
95
|
+
// Stands in for the request to the server.
|
|
96
|
+
timer.current = setTimeout(() => {
|
|
97
|
+
setPending(null);
|
|
98
|
+
setStatus(action === 'choose' ? 'chosen' : 'cancelled');
|
|
99
|
+
}, 1200);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const chosen = options.find((o) => o.value === selected);
|
|
103
|
+
|
|
104
|
+
return (
|
|
105
|
+
<Center width="page">
|
|
106
|
+
<Stack gap="large">
|
|
107
|
+
<Heading level={1} size="h5">Launch plan</Heading>
|
|
108
|
+
{/* A real app gives the list that holds the rows role="log". */}
|
|
109
|
+
<Stack gap="small">
|
|
110
|
+
<Message
|
|
111
|
+
aria-label={request.from}
|
|
112
|
+
avatar={<UserImage userHandle={request.from} decorative />}
|
|
113
|
+
name={request.from}
|
|
114
|
+
meta={<TimeStamp createdAt={request.at} dateFormat="absolute" data="time" />}
|
|
115
|
+
>
|
|
116
|
+
<Paragraph measure="none">{request.text}</Paragraph>
|
|
117
|
+
</Message>
|
|
118
|
+
<Message
|
|
119
|
+
aria-label={`${agentName}, agent`}
|
|
120
|
+
avatar={<UserImage userHandle={agentName} icon={Bot} decorative />}
|
|
121
|
+
name={agentName}
|
|
122
|
+
meta={agentMeta(askedAt)}
|
|
123
|
+
>
|
|
124
|
+
<Surface padding="small">
|
|
125
|
+
<Stack gap="medium">
|
|
126
|
+
{/* A real app announces the decided Tag in a polite live region. */}
|
|
127
|
+
<Cluster gap="small">
|
|
128
|
+
<Heading level={2} size="subtitle1">{question}</Heading>
|
|
129
|
+
{status === 'chosen' && <Tag variant="contained" size="small" color="success" label="Chosen" />}
|
|
130
|
+
{status === 'cancelled' && <Tag variant="contained" size="small" label="Cancelled" />}
|
|
131
|
+
</Cluster>
|
|
132
|
+
{status === 'open' && (
|
|
133
|
+
<>
|
|
134
|
+
<RadioGroup
|
|
135
|
+
variant="card"
|
|
136
|
+
aria-label={question}
|
|
137
|
+
options={options}
|
|
138
|
+
selectedValue={selected}
|
|
139
|
+
onChange={setSelected}
|
|
140
|
+
disabled={pending !== null}
|
|
141
|
+
/>
|
|
142
|
+
{/* The product sets the waiting time and counts it down. When it is up, the card is marked Cancelled. */}
|
|
143
|
+
<Paragraph size="caption" tone="secondary" measure="none">Waits 10 more minutes, then cancels.</Paragraph>
|
|
144
|
+
<Cluster gap="small">
|
|
145
|
+
<Button size="small" type="tertiary" state={pending === 'choose' ? 'disabled' : 'enabled'} label="Cancel" loading={pending === 'cancel'} onClickButton={() => decide('cancel')} />
|
|
146
|
+
<Button size="small" type="primary" state={selected === '' || pending === 'cancel' ? 'disabled' : 'enabled'} label="Choose" loading={pending === 'choose'} onClickButton={() => decide('choose')} />
|
|
147
|
+
</Cluster>
|
|
148
|
+
</>
|
|
149
|
+
)}
|
|
150
|
+
{/* Once decided, only the chosen option is left on the card. */}
|
|
151
|
+
{status === 'chosen' && chosen && <Paragraph measure="none">{chosen.label}</Paragraph>}
|
|
152
|
+
</Stack>
|
|
153
|
+
</Surface>
|
|
154
|
+
</Message>
|
|
155
|
+
{status === 'cancelled' && (
|
|
156
|
+
// One line in the thread on what was not done, under the card.
|
|
157
|
+
<Message compact aria-label={`${agentName}, agent`}>
|
|
158
|
+
<Paragraph measure="none">Cancelled. Nothing was changed.</Paragraph>
|
|
159
|
+
</Message>
|
|
160
|
+
)}
|
|
161
|
+
</Stack>
|
|
162
|
+
</Stack>
|
|
163
|
+
</Center>
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Seen in: Scindo.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function AgentPendingReplySteps(): import("react").JSX.Element;
|
|
@@ -0,0 +1,149 @@
|
|
|
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 Alert from '../../components/alert';
|
|
12
|
+
import StepList from '../../components/stepList';
|
|
13
|
+
import { Center, Cluster, Stack } from '../../components/layout';
|
|
14
|
+
var agentName = 'Acme Agent';
|
|
15
|
+
var request = { from: 'Dana Lee', at: new Date('2025-01-15T11:40:00Z'), text: 'Can you check the pricing page against the new plans?' };
|
|
16
|
+
var runStartedAt = new Date('2025-01-15T11:41:00Z');
|
|
17
|
+
// Each step in plain words: what the agent is doing now, and what it did once the step is done.
|
|
18
|
+
var plan = [
|
|
19
|
+
{ doing: 'Reading the thread', done: 'Read the thread' },
|
|
20
|
+
{ doing: 'Finding the new plans', done: 'Found the new plans' },
|
|
21
|
+
{ doing: 'Reading the pricing page', done: 'Read the pricing page' },
|
|
22
|
+
{ doing: 'Comparing the prices', done: 'Compared the prices' },
|
|
23
|
+
];
|
|
24
|
+
var reply = "The pricing page still shows last year's prices. Pro is $12 there, and the new plans set it at $15.";
|
|
25
|
+
// Finished steps keep a check, the current one runs, and steps the agent has not started are not shown.
|
|
26
|
+
function stepsUpTo(current, failed) {
|
|
27
|
+
return plan.slice(0, current + 1).map(function (s, i) {
|
|
28
|
+
return i < current ? { label: s.done, status: 'done' } : { label: s.doing, status: failed ? 'failed' : 'running' };
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
function secondsLine(seconds) {
|
|
32
|
+
return "Working for ".concat(seconds, " ").concat(seconds === 1 ? 'second' : 'seconds');
|
|
33
|
+
}
|
|
34
|
+
// The agent's marks, as the rule 'An agent says what it is' says.
|
|
35
|
+
function agentMeta(at) {
|
|
36
|
+
return (<>
|
|
37
|
+
<Tag variant="contained" size="small" label="Agent"/>
|
|
38
|
+
<TimeStamp createdAt={at} dateFormat="absolute" data="time"/>
|
|
39
|
+
<Paragraph size="caption" tone="secondary" measure="none">Model name</Paragraph>
|
|
40
|
+
</>);
|
|
41
|
+
}
|
|
42
|
+
export default function AgentPendingReplySteps() {
|
|
43
|
+
// Opens on a still of a run in progress, 12 seconds in, so the picture in the docs does not move.
|
|
44
|
+
// 'Run Again' runs it live: the seconds tick and the steps go on.
|
|
45
|
+
var _a = useState('running'), phase = _a[0], setPhase = _a[1];
|
|
46
|
+
var _b = useState(2), current = _b[0], setCurrent = _b[1];
|
|
47
|
+
var _c = useState(12), seconds = _c[0], setSeconds = _c[1];
|
|
48
|
+
var _d = useState(runStartedAt), startedAt = _d[0], setStartedAt = _d[1];
|
|
49
|
+
var tick = useRef();
|
|
50
|
+
var step = useRef();
|
|
51
|
+
var cancel = useRef();
|
|
52
|
+
var runAgainButton = useRef(null);
|
|
53
|
+
// Where focus goes after the next render, once the element it goes to is on screen.
|
|
54
|
+
var focusNext = useRef();
|
|
55
|
+
// The first live run fails at the pricing page, so the example shows the failed row; 'Try Again' then works.
|
|
56
|
+
var triedAgain = useRef(false);
|
|
57
|
+
// On unmount it stops the run, its clock and the cancel request.
|
|
58
|
+
useEffect(function () { return function () {
|
|
59
|
+
clearInterval(tick.current);
|
|
60
|
+
clearTimeout(step.current);
|
|
61
|
+
clearTimeout(cancel.current);
|
|
62
|
+
}; }, []);
|
|
63
|
+
useEffect(function () {
|
|
64
|
+
var move = focusNext.current;
|
|
65
|
+
focusNext.current = undefined;
|
|
66
|
+
move === null || move === void 0 ? void 0 : move();
|
|
67
|
+
});
|
|
68
|
+
function stopTimers() {
|
|
69
|
+
clearInterval(tick.current);
|
|
70
|
+
clearTimeout(step.current);
|
|
71
|
+
}
|
|
72
|
+
// Stands in for the agent's run: one step every 1.5 seconds.
|
|
73
|
+
function advance(at) {
|
|
74
|
+
step.current = setTimeout(function () {
|
|
75
|
+
if (at === 2 && !triedAgain.current) {
|
|
76
|
+
stopTimers();
|
|
77
|
+
setPhase('failed');
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
if (at === plan.length - 1) {
|
|
81
|
+
stopTimers();
|
|
82
|
+
setPhase('done');
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
setCurrent(at + 1);
|
|
86
|
+
advance(at + 1);
|
|
87
|
+
}, 1500);
|
|
88
|
+
}
|
|
89
|
+
function runLive() {
|
|
90
|
+
stopTimers();
|
|
91
|
+
setPhase('running');
|
|
92
|
+
setCurrent(0);
|
|
93
|
+
setSeconds(0);
|
|
94
|
+
setStartedAt(new Date());
|
|
95
|
+
tick.current = setInterval(function () { return setSeconds(function (s) { return s + 1; }); }, 1000);
|
|
96
|
+
advance(0);
|
|
97
|
+
}
|
|
98
|
+
function tryAgain() {
|
|
99
|
+
triedAgain.current = true;
|
|
100
|
+
runLive();
|
|
101
|
+
}
|
|
102
|
+
// Stop asks the server to end the run. The row says it stopped only once the run has ended.
|
|
103
|
+
function stop() {
|
|
104
|
+
if (phase !== 'running')
|
|
105
|
+
return;
|
|
106
|
+
clearTimeout(step.current);
|
|
107
|
+
setPhase('stopping');
|
|
108
|
+
// Stands in for the request to the server.
|
|
109
|
+
cancel.current = setTimeout(function () {
|
|
110
|
+
clearInterval(tick.current);
|
|
111
|
+
setPhase('stopped');
|
|
112
|
+
// 'Stop' had focus and is gone. Here 'Run Again' takes its place; in a real app, the message box.
|
|
113
|
+
focusNext.current = function () { var _a; return (_a = runAgainButton.current) === null || _a === void 0 ? void 0 : _a.focus(); };
|
|
114
|
+
}, 1200);
|
|
115
|
+
}
|
|
116
|
+
var working = phase === 'running' || phase === 'stopping';
|
|
117
|
+
return (<Center width="page">
|
|
118
|
+
<Stack gap="large">
|
|
119
|
+
<Heading level={1} size="h5">Launch plan</Heading>
|
|
120
|
+
{/* A real app gives the list that holds the rows role="log". */}
|
|
121
|
+
<Stack gap="small">
|
|
122
|
+
<Message aria-label={request.from} avatar={<UserImage userHandle={request.from} decorative/>} name={request.from} meta={<TimeStamp createdAt={request.at} dateFormat="absolute" data="time"/>}>
|
|
123
|
+
<Paragraph measure="none">{request.text}</Paragraph>
|
|
124
|
+
</Message>
|
|
125
|
+
<Message aria-label={"".concat(agentName, ", agent")} avatar={<UserImage userHandle={agentName} icon={Bot} decorative/>} name={agentName} meta={agentMeta(startedAt)} footer={working ? (
|
|
126
|
+
// The only Stop, on the row for the whole run. It shows loading while the run is stopping.
|
|
127
|
+
<Cluster>
|
|
128
|
+
<Button size="small" type="secondary" state="enabled" label="Stop" loading={phase === 'stopping'} onClickButton={stop}/>
|
|
129
|
+
</Cluster>) : phase === 'failed' ? (<Cluster>
|
|
130
|
+
<Button size="small" type="secondary" state="enabled" label="Try Again" onClickButton={tryAgain}/>
|
|
131
|
+
</Cluster>) : phase === 'stopped' ? (<Cluster>
|
|
132
|
+
<Button ref={runAgainButton} size="small" type="secondary" state="enabled" label="Run Again" onClickButton={runLive}/>
|
|
133
|
+
</Cluster>) : undefined}>
|
|
134
|
+
{phase === 'done' ? (
|
|
135
|
+
// The run is over: the row is the reply, and Stop is gone. A real app moves focus to the message box.
|
|
136
|
+
<Paragraph measure="none">{reply}</Paragraph>) : phase === 'stopped' ? (<Paragraph measure="none">Stopped. Nothing was changed.</Paragraph>) : (
|
|
137
|
+
// A real app wraps this part in a polite live region, since StepList has none.
|
|
138
|
+
<Stack gap="medium">
|
|
139
|
+
{working && <Paragraph size="caption" tone="secondary" measure="none">{secondsLine(seconds)}</Paragraph>}
|
|
140
|
+
<StepList aria-label="Acme Agent's steps" steps={stepsUpTo(current, phase === 'failed')}/>
|
|
141
|
+
{phase === 'failed' && (
|
|
142
|
+
// It reports where the run stands, so it has no close button and stays.
|
|
143
|
+
<Alert type="error" variant="inline" autoDismiss={false} message="Acme Agent could not open the pricing page. Nothing was changed."/>)}
|
|
144
|
+
</Stack>)}
|
|
145
|
+
</Message>
|
|
146
|
+
</Stack>
|
|
147
|
+
</Stack>
|
|
148
|
+
</Center>);
|
|
149
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function AgentPendingReplyStreaming(): import("react").JSX.Element;
|