@vokality/design-system 4.0.2 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/README.md +3 -3
  3. package/dist/chat.d.ts +65 -2
  4. package/dist/components/ChatInbox/ChatInbox.d.ts +3 -1
  5. package/dist/components/ChatInbox/ChatInbox.js +3 -2
  6. package/dist/components/ChatPanel/ChatPanel.d.ts +1 -1
  7. package/dist/components/ChatPanel/ChatPanel.js +2 -2
  8. package/dist/components/ChatPanel/activity.d.ts +6 -0
  9. package/dist/components/ChatPanel/activity.js +102 -0
  10. package/dist/components/ChatPanel/transcript.d.ts +3 -3
  11. package/dist/components/ChatPanel/transcript.js +5 -4
  12. package/dist/components/Menu/Menu.d.ts +2 -2
  13. package/dist/components/Menu/Menu.js +2 -2
  14. package/dist/components/Popover/Popover.d.ts +2 -2
  15. package/dist/components/Select/Select.d.ts +2 -0
  16. package/dist/components/Select/Select.js +2 -2
  17. package/dist/components.css +65 -6
  18. package/dist/icons/refresh.svg +1 -0
  19. package/dist/icons/settings.svg +1 -0
  20. package/dist/internal/useThrottled.d.ts +2 -0
  21. package/dist/internal/useThrottled.js +17 -0
  22. package/dist/lib/icons.d.ts +15 -0
  23. package/dist/lib/icons.js +9 -0
  24. package/dist/localization.d.ts +13 -0
  25. package/dist/localization.js +13 -1
  26. package/dist/vokality.css +65 -6
  27. package/dist/vokality.iife.js +485 -98
  28. package/docs/components/ChatInbox/README.md +24 -7
  29. package/docs/components/ChatWidget/README.md +48 -7
  30. package/docs/components/Icon/README.md +1 -1
  31. package/docs/components/Menu/README.md +1 -1
  32. package/docs/components/Popover/README.md +3 -2
  33. package/docs/components/Select/README.md +2 -1
  34. package/package.json +1 -1
  35. package/skills/vokality-design-system/SKILL.md +2 -2
  36. package/skills/vokality-design-system/references/examples.tsx +8 -8
package/CHANGELOG.md CHANGED
@@ -2,6 +2,37 @@
2
2
 
3
3
  All notable changes to `@vokality/design-system`. The package follows [semantic versioning](https://semver.org); see CONTRIBUTING.md for what counts as breaking.
4
4
 
5
+ ## 5.1.0 — 2026-10-19
6
+
7
+ Compact toolbar and status-line controls.
8
+
9
+ ### Added
10
+ - `settings` (Lucide settings) and `refresh` (Lucide rotate-cw) icons, 18px by default, in `iconData`, `Icon`, `IconButton` and `icons/*.svg`.
11
+ - `variant="text"` on `Menu` and `Popover` triggers: sentence case with the chevron after the label; at `size="xs"` it is 12px, the size of `Text size="small"` under compact density. With `size="xs"` it sits at `--control-height-xs`, like `Button variant="text" size="xs"`.
12
+ - `Select` `size="xs"`: a 24px toolbar trigger with 12px text and tighter padding on fine pointers; coarse pointers keep 44px, and form fields keep the control height.
13
+ - Stories: `IconButton` `Settings`, `Popover` `StatusLine`, `Select` `Sizes`, and the text variant in the `Menu` and `Popover` `Sizes` stories.
14
+
15
+ ### Fixed
16
+ - An icon-only `Menu` trigger with `variant="primary"` rendered a class with no styles; it is a ghost icon button, as for every variant other than `outline`.
17
+
18
+ ## 5.0.0 — 2026-10-19
19
+
20
+ Agent activity in chat transcripts.
21
+
22
+ ### Added
23
+ - Agent runs in the chat transcript. A `ChatActivity` has a `title`, `state` (`working`, `waiting`, `finished`, `failed`, `stopped`), `elapsed`, a one-line `outcome`, ordered `entries` and an `omitted` step count. Entries are narration (`ChatActivityNarration`) or typed steps (`ChatActivityStep`: `read`, `search`, `edit`, `run`, `web`, `plan`, `delegate` or `tool`, each with its own icon, and `started`, `succeeded`, `failed` or `left_running`). A working run shows a live status line over its latest six entries, with earlier entries behind a disclosure; an ended run collapses to one line that opens to every entry. Failed runs and steps say so in words as well as colour. Screen readers hear a run through its own polite status, at most once every five seconds, never once per step.
24
+ - A `waiting` activity state for a run that asks a person a question. It shows its latest entries without the working mark, says “Waiting” in the accent colour, and its steps are not announced.
25
+ - `ChatInbox` `headerActions`: controls at the trailing end of whichever header is showing, on one row at 380px.
26
+ - `ChatAuthor.source: { label, mark? }` names the channel a message came through, beside the author.
27
+ - `ChatMessage.actions: ChatAction[]`: extra-small buttons under a message (`outline` by default, or `primary`, `ghost`, `danger`).
28
+ - Read-only conversations: `composer` is optional on `ChatPanelProps`, `ChatInbox` and `ChatWidget`. Without it, `readOnlyNotice` (or localized default copy) takes the composer's place and says why.
29
+ - Localized chat copy for activity states, step states, earlier entries, omitted steps, announcements and the read-only notice in English and Dutch (`LocaleProvider.messages.chat`).
30
+ - Stories: a working run, a finished run, a failed run, omitted steps, runs between messages from two channels, message actions and a read-only inbox.
31
+
32
+ ### Changed (breaking)
33
+ - `ChatPanelProps.messages` is replaced by `items: readonly ChatItem[]`, on `ChatInbox` and `ChatWidget` too. A `ChatItem` is `{ type: "message", ...ChatMessage }` or `{ type: "activity", ...ChatActivity }`; add `type: "message"` to existing messages and rename the prop.
34
+ - `ChatInbox` fills its container (`height: 100%`) instead of sizing itself to the viewport (up to 42rem), so it can fill a docked pane. Give the inbox's container a height. A 380px docked pane gets the narrow list-or-conversation layout. New `DockedPane`, `HeaderActions` and `ActivityWaiting` stories.
35
+
5
36
  ## 4.0.2 — 2026-10-19
6
37
 
7
38
  ### Fixed
package/README.md CHANGED
@@ -89,7 +89,7 @@ Pages not rendered by React can inline `themeScript()` instead. See `docs/compon
89
89
 
90
90
  Pass `density="compact"` to `ThemeProvider` for dense operational interfaces. It uses 20px page titles, 16px section titles, 14px body text and 24px statistics, never enlarges smaller text, and tightens table cells, list and navigation rows, menus and cards. Page-header actions align with the title; headers leave section spacing to `Stack` instead of adding another margin. With only a fine pointer, buttons and fields share a 32px height and inputs use 14px text; when a coarse pointer is available they keep 44px targets and 16px input text, which stops iOS zooming on focus. Density redefines the control tokens (`--control-height`, `--control-font-size`, `--control-padding-block`) and the button heights, so components that size from them follow it while component-specific sizes still apply. The provider sets it on `html`, so portalled dialogs and menus inherit it. Without it the defaults apply. Prose follows the compact scale (14px text, headings from 20px), and alert and toast titles use 14px.
91
91
 
92
- For toolbars, record rows and status lines, `size="xs"` on `Button`, `IconButton`, `Menu`, `Popover` and `SegmentedControl` gives 24px actions with 11px labels. Fields keep the control height, so forms stay readable. Extra-small sizes apply with fine pointers only; a coarse pointer keeps the 44px target. The `--control-height-xs` token holds the height.
92
+ For toolbars, record rows and status lines, `size="xs"` on `Button`, `IconButton`, `Menu`, `Popover` and `SegmentedControl` gives 24px actions with 11px labels, and on `Select` a 24px toolbar picker with 12px text. A status-line `Menu` or `Popover` takes `variant="text"` to read in sentence case, at 12px with `size="xs"`, like compact `Text size="small"`. Form fields keep the control height, so forms stay readable. Extra-small sizes apply with fine pointers only; a coarse pointer keeps the 44px target. The `--control-height-xs` token holds the height.
93
93
 
94
94
  Compose pages with `Stack`, `Inline` and `Grid`; these forward standard attributes and events typed for the element they render, including `Inline as="form" onSubmit={...}`. Use `Fieldset` for related controls, `Button variant="text"` for record names, and `Text numeric overflowWrap="anywhere"` for long identifiers.
95
95
 
@@ -124,11 +124,11 @@ The app supplies `uploadAttachment(file, { signal })`, which returns a promise o
124
124
 
125
125
  ## Chat surfaces
126
126
 
127
- `ChatWidget` supplies a floating launcher and a Radix popup. `ChatInbox` supplies an embedded conversation list and message panel, with a list/detail view on phones. Both reuse the Markdown rich editor for formatting, emoji and optional attachment uploads. Apps supply render-ready messages, selected conversations and send/retry callbacks; transport, streaming updates, persistence and authentication remain app responsibilities.
127
+ `ChatWidget` supplies a floating launcher and a Radix popup. `ChatInbox` supplies an embedded conversation list and message panel, with a list/detail view on phones. Both reuse the Markdown rich editor for formatting, emoji and optional attachment uploads. Apps supply a transcript of render-ready messages and agent runs (`items`), selected conversations and send/retry callbacks; transport, streaming updates, persistence and authentication remain app responsibilities. A message can name the channel it came through and carry extra-small actions; an agent run shows its narration and steps, collapsed to one line once it ends. Omit the composer for a read-only conversation.
128
128
 
129
129
  The composer starts with a message field, emoji and optional attachment action. One formatting toggle reveals basic text tools. Motion adds short chat entrance/exit, launcher feedback and new-message transitions; existing history stays still, and reduced-motion preferences disable these animations. See the [Motion and Radix integration guide](https://motion.dev/docs/radix) for the upstream composition pattern.
130
130
 
131
- Import the components from `@vokality/design-system/chat-widget` and `@vokality/design-system/chat-inbox`. Shared message, conversation and composer types are defined in `@vokality/design-system/chat-models`. See the component documentation for controlled draft and message contracts.
131
+ Import the components from `@vokality/design-system/chat-widget` and `@vokality/design-system/chat-inbox`. Shared transcript, activity, conversation and composer types are defined in `@vokality/design-system/chat-models`. See the component documentation for controlled draft and message contracts.
132
132
 
133
133
  ## Starting a new project
134
134
 
package/dist/chat.d.ts CHANGED
@@ -1,9 +1,16 @@
1
1
  import type { ReactNode } from "react";
2
+ import type { ButtonProps } from "./components/Button/Button.js";
2
3
  import type { RichTextEditorProps } from "./components/RichTextEditor/RichTextEditor.js";
4
+ /** The channel a message arrived through, drawn beside the author's name. Pass a decorative mark. */
5
+ export interface ChatSource {
6
+ label: string;
7
+ mark?: ReactNode;
8
+ }
3
9
  /** Render-ready identity; pass an Avatar or another accessible visual in the slot. */
4
10
  export interface ChatAuthor {
5
11
  name: string;
6
12
  avatar?: ReactNode;
13
+ source?: ChatSource;
7
14
  }
8
15
  /** Applications own delivery, persistence and retry requests. Omit for a sent message. */
9
16
  export type ChatMessageDelivery = {
@@ -12,6 +19,15 @@ export type ChatMessageDelivery = {
12
19
  state: "failed";
13
20
  error?: ReactNode;
14
21
  };
22
+ /** An extra-small button under a message. The application handles what selecting it does. */
23
+ export interface ChatAction {
24
+ id: string;
25
+ label: string;
26
+ onSelect: () => void;
27
+ disabled?: boolean;
28
+ /** Default outline. */
29
+ variant?: Extract<ButtonProps["variant"], "primary" | "outline" | "ghost" | "danger">;
30
+ }
15
31
  export interface ChatMessage {
16
32
  id: string;
17
33
  author: ChatAuthor;
@@ -20,7 +36,50 @@ export interface ChatMessage {
20
36
  timestamp?: ReactNode;
21
37
  direction: "incoming" | "outgoing";
22
38
  delivery?: ChatMessageDelivery;
39
+ actions?: readonly ChatAction[];
40
+ }
41
+ /** What an agent run is doing: working, or waiting for a person to answer; then how it ended. */
42
+ export type ChatActivityState = "working" | "waiting" | "finished" | "failed" | "stopped";
43
+ /** Each kind of step draws its own icon. */
44
+ export type ChatActivityStepKind = "read" | "search" | "edit" | "run" | "web" | "plan" | "delegate" | "tool";
45
+ /** A step that was still running when its run ended was left running. */
46
+ export type ChatActivityStepState = "started" | "succeeded" | "failed" | "left_running";
47
+ /** What the agent said while it worked. */
48
+ export interface ChatActivityNarration {
49
+ type: "narration";
50
+ id: string;
51
+ content: ReactNode;
52
+ }
53
+ /** One thing the agent did, with display-ready text: "Read src/app.ts", "Searched for useLocale" and "12 matches". */
54
+ export interface ChatActivityStep {
55
+ type: "step";
56
+ id: string;
57
+ kind: ChatActivityStepKind;
58
+ label: string;
59
+ outcome?: string;
60
+ state: ChatActivityStepState;
61
+ }
62
+ export type ChatActivityEntry = ChatActivityNarration | ChatActivityStep;
63
+ /** One agent run in the conversation: its narration and steps in order. */
64
+ export interface ChatActivity {
65
+ id: string;
66
+ /** Names the run: "Working on the fix". */
67
+ title: string;
68
+ state: ChatActivityState;
69
+ /** Application-formatted running time. */
70
+ elapsed?: ReactNode;
71
+ /** One line on how the run ended: "Edited 4 files, checks passed". */
72
+ outcome?: ReactNode;
73
+ entries: readonly ChatActivityEntry[];
74
+ /** Steps the application did not keep, shown as a count after the entries. */
75
+ omitted?: number;
23
76
  }
77
+ /** One entry in a transcript, in conversation order. */
78
+ export type ChatItem = ({
79
+ type: "message";
80
+ } & ChatMessage) | ({
81
+ type: "activity";
82
+ } & ChatActivity);
24
83
  /** The application handles async sending and supplies pending/error message data. */
25
84
  export interface ChatComposerOptions extends Pick<RichTextEditorProps, "value" | "defaultValue" | "onChange" | "disabled" | "placeholder" | "name" | "onUploadAttachment" | "accept" | "maxFileSize" | "emojiOptions" | "onUploadError"> {
26
85
  /** Returns after accepting the message. Only uncontrolled drafts clear automatically. */
@@ -41,8 +100,12 @@ export interface ChatThread {
41
100
  }
42
101
  /** Shared conversation presentation used by the widget and inbox. */
43
102
  export interface ChatPanelProps {
44
- messages: readonly ChatMessage[];
45
- composer: ChatComposerOptions;
103
+ /** Messages and agent activity in conversation order, each with a stable id. */
104
+ items: readonly ChatItem[];
105
+ /** Omit for a read-only conversation; `readOnlyNotice` then takes the composer's place. */
106
+ composer?: ChatComposerOptions;
107
+ /** Says why the conversation can't be answered. Shown only without a composer; defaults to localized copy. */
108
+ readOnlyNotice?: ReactNode;
46
109
  emptyState?: ReactNode;
47
110
  /** App-provided response/loading feedback, displayed in a polite status region. */
48
111
  pending?: ReactNode;
@@ -6,6 +6,8 @@ export interface ChatInboxProps extends ChatPanelProps {
6
6
  selectedThreadId: string | null;
7
7
  onSelectThread: (threadId: string | null) => void;
8
8
  emptySelection?: ReactNode;
9
+ /** Controls at the trailing end of the header that is showing: the conversation's while a thread is open, otherwise the thread list's. Pass xs IconButtons or Buttons. */
10
+ headerActions?: ReactNode;
9
11
  }
10
12
  /** Controlled thread selection; CSS handles the narrow-screen list/detail presentation. */
11
- export declare function ChatInbox({ title, threads, selectedThreadId, onSelectThread, emptySelection, className, ...panel }: ChatInboxProps): import("react/jsx-runtime").JSX.Element;
13
+ export declare function ChatInbox({ title, threads, selectedThreadId, onSelectThread, emptySelection, headerActions, className, ...panel }: ChatInboxProps): import("react/jsx-runtime").JSX.Element;
@@ -16,7 +16,7 @@ function ThreadList({ threads, selectedId, activeRef, onSelect }) {
16
16
  return _jsx("ul", { className: "vk-chat-threads", children: threads.map((thread) => _jsx("li", { children: _jsxs("button", { ref: thread.id === selectedId ? activeRef : undefined, type: "button", className: "vk-chat-thread", "aria-current": thread.id === selectedId ? "true" : undefined, disabled: thread.disabled, onClick: () => { onSelect(thread.id); }, children: [_jsx("span", { className: "vk-chat-thread-avatar", children: thread.avatar || _jsx(Avatar, { name: thread.title, decorative: true }) }), _jsxs("span", { className: "vk-chat-thread-text", children: [_jsx("span", { className: "vk-chat-thread-title", children: thread.title }), thread.preview ? _jsx("span", { className: "vk-chat-thread-preview", children: thread.preview }) : null, _jsxs("span", { className: "vk-chat-thread-meta", children: [thread.timestamp, thread.unreadCount && thread.unreadCount > 0 ? _jsx("span", { className: "vk-chat-thread-count", "aria-label": messages.chat.unread(thread.unreadCount), children: formatNumber(thread.unreadCount, { locale }) }) : null] })] })] }) }, thread.id)) });
17
17
  }
18
18
  /** Controlled thread selection; CSS handles the narrow-screen list/detail presentation. */
19
- export function ChatInbox({ title, threads, selectedThreadId, onSelectThread, emptySelection, className, ...panel }) {
19
+ export function ChatInbox({ title, threads, selectedThreadId, onSelectThread, emptySelection, headerActions, className, ...panel }) {
20
20
  const { messages } = useLocale();
21
21
  const listTitleId = useUid("vk-chat-threads");
22
22
  const selected = threads.find((thread) => thread.id === selectedThreadId);
@@ -45,5 +45,6 @@ export function ChatInbox({ title, threads, selectedThreadId, onSelectThread, em
45
45
  onSelectThread(null);
46
46
  };
47
47
  const empty = emptySelection === undefined ? messages.chat.chooseThread : emptySelection;
48
- return (_jsxs("div", { className: cx("vk-chat-inbox", selected && "vk-chat-inbox-selected", className), children: [_jsxs("section", { className: "vk-chat-inbox-list", "aria-labelledby": listTitleId, children: [_jsx("header", { className: "vk-chat-header", children: _jsx("h2", { id: listTitleId, className: "vk-chat-title", children: title || messages.chat.conversations }) }), _jsx(ThreadList, { threads: threads, selectedId: selectedThreadId, activeRef: activeRef, onSelect: select })] }), _jsx("section", { className: "vk-chat-inbox-detail", "aria-label": selected?.title || messages.chat.messages, children: selected ? _jsxs(_Fragment, { children: [_jsxs("header", { className: "vk-chat-header", children: [_jsx(IconButton, { icon: "chevron-left", label: messages.chat.back, className: "vk-chat-back", onClick: back }), _jsx("h2", { ref: headingRef, tabIndex: -1, className: "vk-chat-title", children: selected.title })] }), _jsx(ChatPanel, { ...panel }, selected.id)] }) : _jsx("div", { className: "vk-chat-empty vk-chat-no-selection", children: empty }) })] }));
48
+ const actions = headerActions ? _jsx("div", { className: "vk-chat-header-actions", children: headerActions }) : null;
49
+ return (_jsxs("div", { className: cx("vk-chat-inbox", selected && "vk-chat-inbox-selected", className), children: [_jsxs("section", { className: "vk-chat-inbox-list", "aria-labelledby": listTitleId, children: [_jsxs("header", { className: "vk-chat-header", children: [_jsx("h2", { id: listTitleId, className: "vk-chat-title", children: title || messages.chat.conversations }), selected ? null : actions] }), _jsx(ThreadList, { threads: threads, selectedId: selectedThreadId, activeRef: activeRef, onSelect: select })] }), _jsx("section", { className: "vk-chat-inbox-detail", "aria-label": selected?.title || messages.chat.messages, children: selected ? _jsxs(_Fragment, { children: [_jsxs("header", { className: "vk-chat-header", children: [_jsx(IconButton, { icon: "chevron-left", label: messages.chat.back, className: "vk-chat-back", onClick: back }), _jsx("h2", { ref: headingRef, tabIndex: -1, className: "vk-chat-title", children: selected.title }), actions] }), _jsx(ChatPanel, { ...panel }, selected.id)] }) : _jsx("div", { className: "vk-chat-empty vk-chat-no-selection", children: empty }) })] }));
49
50
  }
@@ -1,3 +1,3 @@
1
1
  import type { ChatPanelProps } from "../../chat.js";
2
- /** Shared transcript, feedback and Markdown composer; no transport or persistence. */
2
+ /** Shared transcript, feedback and Markdown composer (or a read-only notice); no transport or persistence. */
3
3
  export declare function ChatPanel(props: ChatPanelProps): import("react/jsx-runtime").JSX.Element;
@@ -6,8 +6,8 @@ import { Button } from "../Button/Button.js";
6
6
  import { Icon } from "../Icon/Icon.js";
7
7
  import { ChatComposer } from "./composer.js";
8
8
  import { ChatTranscript } from "./transcript.js";
9
- /** Shared transcript, feedback and Markdown composer; no transport or persistence. */
9
+ /** Shared transcript, feedback and Markdown composer (or a read-only notice); no transport or persistence. */
10
10
  export function ChatPanel(props) {
11
11
  const { messages } = useLocale();
12
- return (_jsxs("div", { className: cx("vk-chat-panel", props.className), children: [_jsx(ChatTranscript, { messages: props.messages, emptyState: props.emptyState, pending: props.pending, error: props.error, label: props["aria-label"], onRetryMessage: props.onRetryMessage }), props.error ? _jsxs("div", { className: "vk-chat-feedback", role: "alert", children: [_jsx(Icon, { name: "circle-alert", size: 16 }), _jsx("div", { children: props.error }), props.onRetry ? _jsx(Button, { type: "button", size: "sm", variant: "ghost", onClick: props.onRetry, children: messages.chat.tryAgain }) : null] }) : null, _jsx(ChatComposer, { options: props.composer })] }));
12
+ return (_jsxs("div", { className: cx("vk-chat-panel", props.className), children: [_jsx(ChatTranscript, { items: props.items, emptyState: props.emptyState, pending: props.pending, error: props.error, label: props["aria-label"], onRetryMessage: props.onRetryMessage }), props.error ? _jsxs("div", { className: "vk-chat-feedback", role: "alert", children: [_jsx(Icon, { name: "circle-alert", size: 16 }), _jsx("div", { children: props.error }), props.onRetry ? _jsx(Button, { type: "button", size: "sm", variant: "ghost", onClick: props.onRetry, children: messages.chat.tryAgain }) : null] }) : null, props.composer ? _jsx(ChatComposer, { options: props.composer }) : _jsxs("div", { className: "vk-chat-read-only", children: [_jsx(Icon, { name: "info", size: 16 }), _jsx("div", { children: props.readOnlyNotice === undefined ? messages.chat.readOnly : props.readOnlyNotice })] })] }));
13
13
  }
@@ -0,0 +1,6 @@
1
+ import type { ChatActivity } from "../../chat.js";
2
+ /** An agent run in the transcript. The log ignores its entries; a throttled status speaks for it. */
3
+ export declare function ActivityItem({ activity, reducedMotion }: {
4
+ activity: ChatActivity;
5
+ reducedMotion: boolean;
6
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,102 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { useState } from "react";
4
+ import { Collapsible } from "radix-ui";
5
+ import * as m from "motion/react-m";
6
+ import { useLocale } from "../../localization.js";
7
+ import { useThrottled } from "../../internal/useThrottled.js";
8
+ import { Button } from "../Button/Button.js";
9
+ import { Icon } from "../Icon/Icon.js";
10
+ /** A working run shows this many of its latest entries; the rest wait behind a disclosure. */
11
+ const LATEST_ENTRIES = 6;
12
+ /** Screen readers hear about a run at most this often, never once per step. */
13
+ const ANNOUNCE_INTERVAL = 5000;
14
+ const STEP_ICON = { read: "file", search: "search", edit: "pencil", run: "chevron-right", web: "arrow-up-right", plan: "menu", delegate: "users", tool: "ellipsis" };
15
+ const STATE_ICON = { waiting: "message-circle", finished: "circle-check", failed: "circle-alert", stopped: "minus" };
16
+ function activityWord(state, chat) {
17
+ switch (state) {
18
+ case "working": return chat.activityWorking;
19
+ case "waiting": return chat.activityWaiting;
20
+ case "finished": return chat.activityFinished;
21
+ case "failed": return chat.activityFailed;
22
+ case "stopped": return chat.activityStopped;
23
+ }
24
+ }
25
+ function stepWord(state, chat) {
26
+ switch (state) {
27
+ case "started": return chat.stepStarted;
28
+ case "failed": return chat.stepFailed;
29
+ case "left_running": return chat.stepKeptRunning;
30
+ case "succeeded": return undefined;
31
+ }
32
+ }
33
+ function WorkingMark() {
34
+ return _jsx("span", { className: "vk-spinner vk-chat-activity-spinner", "aria-hidden": "true" });
35
+ }
36
+ /** A started step shows the working mark only while its run is live; otherwise it says it is in progress. */
37
+ function StepState({ state, live }) {
38
+ const { messages } = useLocale();
39
+ const word = stepWord(state, messages.chat);
40
+ if (!word)
41
+ return null;
42
+ if (state === "started" && live)
43
+ return _jsxs("span", { className: "vk-chat-step-state", children: [_jsx(WorkingMark, {}), _jsx("span", { className: "vk-sr-only", children: word })] });
44
+ return _jsxs("span", { className: "vk-chat-step-state", children: [state === "failed" ? _jsx(Icon, { name: "circle-alert", size: 14 }) : null, word] });
45
+ }
46
+ function Step({ step, live }) {
47
+ return (_jsxs("li", { className: "vk-chat-step", "data-state": step.state, children: [_jsx(Icon, { name: STEP_ICON[step.kind], size: 14, className: "vk-chat-step-icon" }), _jsxs("span", { className: "vk-chat-step-text", children: [_jsx("span", { className: "vk-chat-step-label", children: step.label }), step.outcome ? _jsx("span", { className: "vk-chat-step-outcome", children: step.outcome }) : null] }), _jsx(StepState, { state: step.state, live: live })] }));
48
+ }
49
+ function Entries({ entries, live }) {
50
+ if (!entries.length)
51
+ return null;
52
+ return _jsx("ol", { className: "vk-chat-activity-entries", children: entries.map((entry) => entry.type === "step" ? _jsx(Step, { step: entry, live: live }, entry.id) : _jsx("li", { className: "vk-prose vk-chat-narration", children: entry.content }, entry.id)) });
53
+ }
54
+ function Omitted({ count }) {
55
+ const { messages } = useLocale();
56
+ if (!count || count <= 0)
57
+ return null;
58
+ return _jsx("p", { className: "vk-chat-activity-omitted", children: messages.chat.omittedSteps(count) });
59
+ }
60
+ /** Title, state word, outcome and elapsed time: the run's status line, and its summary once it ends. */
61
+ function Summary({ activity }) {
62
+ const { messages } = useLocale();
63
+ return _jsxs(_Fragment, { children: [activity.state === "working" ? _jsx(WorkingMark, {}) : _jsx(Icon, { name: STATE_ICON[activity.state], size: 16, className: "vk-chat-activity-icon" }), _jsxs("span", { className: "vk-chat-activity-text", children: [_jsx("span", { className: "vk-chat-activity-title", children: activity.title }), _jsx("span", { className: "vk-chat-activity-state", children: activityWord(activity.state, messages.chat) }), activity.outcome ? _jsx("span", { className: "vk-chat-activity-outcome", children: activity.outcome }) : null, activity.elapsed ? _jsx("span", { className: "vk-chat-activity-elapsed", children: activity.elapsed }) : null] })] });
64
+ }
65
+ /** A working or waiting run: the latest entries under its status line; earlier ones open above them. */
66
+ function OpenActivity({ activity }) {
67
+ const live = activity.state === "working";
68
+ const { messages } = useLocale();
69
+ const earlier = activity.entries.slice(0, Math.max(0, activity.entries.length - LATEST_ENTRIES));
70
+ const latest = activity.entries.slice(earlier.length);
71
+ return _jsxs(_Fragment, { children: [_jsx("div", { className: "vk-chat-activity-line", children: _jsx(Summary, { activity: activity }) }), _jsxs("div", { className: "vk-chat-activity-body", children: [earlier.length ? _jsxs(Collapsible.Root, { className: "vk-chat-activity-earlier", children: [_jsx(Collapsible.Trigger, { asChild: true, children: _jsxs(Button, { type: "button", size: "xs", variant: "ghost", className: "vk-chat-activity-more", children: [_jsx(Icon, { name: "chevron-down", size: 14, className: "vk-chat-activity-chevron" }), messages.chat.earlierEntries(earlier.length)] }) }), _jsx(Collapsible.Content, { children: _jsx(Entries, { entries: earlier, live: live }) })] }) : null, _jsx(Entries, { entries: latest, live: live }), _jsx(Omitted, { count: activity.omitted })] })] });
72
+ }
73
+ /** One line that opens to the whole run. */
74
+ function EndedActivity({ activity }) {
75
+ if (!activity.entries.length && !activity.omitted)
76
+ return _jsx("div", { className: "vk-chat-activity-line", children: _jsx(Summary, { activity: activity }) });
77
+ return (_jsxs(Collapsible.Root, { children: [_jsxs(Collapsible.Trigger, { className: "vk-chat-activity-line vk-chat-activity-toggle", children: [_jsx(Summary, { activity: activity }), _jsx(Icon, { name: "chevron-down", size: 16, className: "vk-chat-activity-chevron" })] }), _jsxs(Collapsible.Content, { className: "vk-chat-activity-body", children: [_jsx(Entries, { entries: activity.entries, live: false }), _jsx(Omitted, { count: activity.omitted })] })] }));
78
+ }
79
+ function latestStep(entries) {
80
+ for (let index = entries.length - 1; index >= 0; index--) {
81
+ const entry = entries[index];
82
+ if (entry?.type === "step")
83
+ return entry;
84
+ }
85
+ return undefined;
86
+ }
87
+ /** The latest step while working, otherwise the run's state; nothing for what was already there on mount. */
88
+ function useAnnouncement(activity) {
89
+ const { messages } = useLocale();
90
+ const step = latestStep(activity.entries);
91
+ const text = activity.state !== "working"
92
+ ? messages.chat.activityStatus(activity.title, activityWord(activity.state, messages.chat))
93
+ : step ? messages.chat.activityStep(activity.title, step.label, step.state === "failed" ? messages.chat.stepFailed : undefined) : "";
94
+ const [initial] = useState(text);
95
+ const shown = useThrottled(text, ANNOUNCE_INTERVAL);
96
+ return shown === initial ? "" : shown;
97
+ }
98
+ /** An agent run in the transcript. The log ignores its entries; a throttled status speaks for it. */
99
+ export function ActivityItem({ activity, reducedMotion }) {
100
+ const announcement = useAnnouncement(activity);
101
+ return (_jsxs(m.li, { className: "vk-chat-activity", "data-state": activity.state, initial: { opacity: 0, y: reducedMotion ? 0 : 4 }, animate: { opacity: 1, y: 0 }, transition: { duration: reducedMotion ? 0 : 0.16, ease: "easeOut" }, children: [_jsx("div", { "aria-live": "off", children: activity.state === "working" || activity.state === "waiting" ? _jsx(OpenActivity, { activity: activity }) : _jsx(EndedActivity, { activity: activity }) }), _jsx("div", { role: "status", className: "vk-sr-only", children: announcement })] }));
102
+ }
@@ -1,13 +1,13 @@
1
1
  import { type ReactNode } from "react";
2
- import type { ChatMessage } from "../../chat.js";
2
+ import type { ChatItem } from "../../chat.js";
3
3
  interface TranscriptProps {
4
- messages: readonly ChatMessage[];
4
+ items: readonly ChatItem[];
5
5
  emptyState?: ReactNode;
6
6
  pending?: ReactNode;
7
7
  error?: ReactNode;
8
8
  label?: string;
9
9
  onRetryMessage?: (id: string) => void;
10
10
  }
11
- /** A native scrollable log. Follow new messages only while the reader is near its end. */
11
+ /** A native scrollable log of messages and agent runs. Follow new items only while the reader is near its end. */
12
12
  export declare function ChatTranscript(props: TranscriptProps): import("react/jsx-runtime").JSX.Element;
13
13
  export {};
@@ -9,6 +9,7 @@ import { Avatar } from "../Avatar/Avatar.js";
9
9
  import { Button } from "../Button/Button.js";
10
10
  import { Icon } from "../Icon/Icon.js";
11
11
  import { cx } from "../../lib/cx.js";
12
+ import { ActivityItem } from "./activity.js";
12
13
  function MessageDelivery({ message, onRetry }) {
13
14
  const { messages } = useLocale();
14
15
  if (!message.delivery)
@@ -18,9 +19,9 @@ function MessageDelivery({ message, onRetry }) {
18
19
  return (_jsxs("div", { className: "vk-chat-delivery vk-chat-delivery-failed", children: [_jsx(Icon, { name: "circle-alert", size: 14 }), _jsx("span", { children: message.delivery.error || messages.chat.failed }), onRetry ? _jsx(Button, { type: "button", size: "sm", variant: "ghost", "aria-label": messages.chat.retryMessage(message.author.name), onClick: () => { onRetry(message.id); }, children: messages.chat.retry }) : null] }));
19
20
  }
20
21
  function MessageItem({ message, onRetry, reducedMotion }) {
21
- return (_jsxs(m.li, { className: cx("vk-chat-message", "vk-chat-message-" + message.direction), initial: { opacity: 0, y: reducedMotion ? 0 : 4 }, animate: { opacity: 1, y: 0 }, transition: { duration: reducedMotion ? 0 : 0.16, ease: "easeOut" }, children: [_jsx("span", { className: "vk-chat-message-avatar", children: message.author.avatar || _jsx(Avatar, { name: message.author.name, size: 28, decorative: true }) }), _jsxs("div", { className: "vk-chat-message-body", children: [_jsxs("div", { className: "vk-chat-message-meta", children: [_jsx("span", { className: "vk-chat-message-author", children: message.author.name }), message.timestamp ? _jsx("span", { className: "vk-chat-message-time", children: message.timestamp }) : null] }), _jsx("div", { className: "vk-prose vk-chat-message-content", children: message.content }), _jsx(MessageDelivery, { message: message, onRetry: onRetry })] })] }));
22
+ return (_jsxs(m.li, { className: cx("vk-chat-message", "vk-chat-message-" + message.direction), initial: { opacity: 0, y: reducedMotion ? 0 : 4 }, animate: { opacity: 1, y: 0 }, transition: { duration: reducedMotion ? 0 : 0.16, ease: "easeOut" }, children: [_jsx("span", { className: "vk-chat-message-avatar", children: message.author.avatar || _jsx(Avatar, { name: message.author.name, size: 28, decorative: true }) }), _jsxs("div", { className: "vk-chat-message-body", children: [_jsxs("div", { className: "vk-chat-message-meta", children: [_jsx("span", { className: "vk-chat-message-author", children: message.author.name }), message.author.source ? _jsxs("span", { className: "vk-chat-message-source", children: [message.author.source.mark, message.author.source.label] }) : null, message.timestamp ? _jsx("span", { className: "vk-chat-message-time", children: message.timestamp }) : null] }), _jsx("div", { className: "vk-prose vk-chat-message-content", children: message.content }), _jsx(MessageDelivery, { message: message, onRetry: onRetry })] }), message.actions?.length ? _jsx("div", { className: "vk-chat-message-actions", children: message.actions.map((action) => _jsx(Button, { type: "button", size: "xs", variant: action.variant || "outline", disabled: action.disabled, onClick: action.onSelect, children: action.label }, action.id)) }) : null] }));
22
23
  }
23
- /** A native scrollable log. Follow new messages only while the reader is near its end. */
24
+ /** A native scrollable log of messages and agent runs. Follow new items only while the reader is near its end. */
24
25
  export function ChatTranscript(props) {
25
26
  const { messages } = useLocale();
26
27
  const reducedMotion = useReducedMotion() === true;
@@ -30,10 +31,10 @@ export function ChatTranscript(props) {
30
31
  const node = scrollRef.current;
31
32
  if (node && follow.current)
32
33
  node.scrollTop = node.scrollHeight;
33
- }, [props.messages, props.pending]);
34
+ }, [props.items, props.pending]);
34
35
  const empty = props.emptyState === undefined ? messages.chat.empty : props.emptyState;
35
36
  return (_jsxs("div", { ref: scrollRef, role: "log", "aria-label": props.label || messages.chat.messages, "aria-live": "polite", "aria-relevant": "additions text", "aria-atomic": "false", tabIndex: 0, className: "vk-chat-transcript", onScroll: (event) => {
36
37
  const node = event.currentTarget;
37
38
  follow.current = node.scrollHeight - node.scrollTop - node.clientHeight <= 32;
38
- }, children: [_jsx(LazyMotion, { features: domAnimation, children: _jsx("ol", { className: "vk-chat-messages", children: _jsx(AnimatePresence, { initial: false, children: props.messages.map((message) => _jsx(MessageItem, { message: message, onRetry: props.onRetryMessage, reducedMotion: reducedMotion }, message.id)) }) }) }), !props.messages.length && !props.pending && !props.error ? _jsx("div", { className: "vk-chat-empty", children: empty }) : null, props.pending ? _jsx("div", { className: "vk-chat-pending", role: "status", children: props.pending }) : null] }));
39
+ }, children: [_jsx(LazyMotion, { features: domAnimation, children: _jsx("ol", { className: "vk-chat-messages", children: _jsx(AnimatePresence, { initial: false, children: props.items.map((item) => item.type === "activity" ? _jsx(ActivityItem, { activity: item, reducedMotion: reducedMotion }, item.id) : _jsx(MessageItem, { message: item, onRetry: props.onRetryMessage, reducedMotion: reducedMotion }, item.id)) }) }) }), !props.items.length && !props.pending && !props.error ? _jsx("div", { className: "vk-chat-empty", children: empty }) : null, props.pending ? _jsx("div", { className: "vk-chat-pending", role: "status", children: props.pending }) : null] }));
39
40
  }
@@ -3,8 +3,8 @@ export interface MenuProps {
3
3
  items: MenuEntry[];
4
4
  label?: string;
5
5
  icon?: IconName;
6
- triggerLabel?: string;
7
- variant?: 'outline' | 'ghost' | 'primary';
6
+ triggerLabel?: string; /** text reads as a sentence-case label, 12px at xs; it applies to labelled triggers. */
7
+ variant?: 'outline' | 'ghost' | 'primary' | 'text';
8
8
  size?: 'sm' | 'xs';
9
9
  align?: 'start' | 'end';
10
10
  disabled?: boolean;
@@ -6,10 +6,10 @@ import { Icon } from "../Icon/Icon.js";
6
6
  import { cx } from "../../lib/cx.js";
7
7
  import { MenuEntries } from "./entries.js";
8
8
  /** Menu button (WAI-ARIA), built on Radix DropdownMenu. */
9
- /** An icon button when the trigger has only an icon, else a labelled button; both follow size. */
9
+ /** An icon button (ghost or outline) when the trigger has only an icon, else a labelled button; both follow size. */
10
10
  function triggerClass(iconOnly, variant, size) {
11
11
  return iconOnly
12
- ? cx("vk-icon-btn", "vk-icon-btn-" + (variant || "ghost"), size === "xs" && "vk-icon-btn-xs")
12
+ ? cx("vk-icon-btn", variant === "outline" ? "vk-icon-btn-outline" : "vk-icon-btn-ghost", size === "xs" && "vk-icon-btn-xs")
13
13
  : cx("vk-btn", "vk-btn-" + (variant || "outline"), size === "sm" && "vk-btn-sm", size === "xs" && "vk-btn-xs");
14
14
  }
15
15
  export function Menu({ items, label, icon, triggerLabel, variant, size, align, disabled, className }) {
@@ -4,8 +4,8 @@ import type { IconName } from "../../types.js";
4
4
  export interface PopoverProps extends Pick<Primitive.PopoverProps, 'open' | 'defaultOpen' | 'onOpenChange' | 'modal'> {
5
5
  label: string;
6
6
  title?: string;
7
- icon?: IconName;
8
- variant?: 'outline' | 'ghost' | 'primary';
7
+ icon?: IconName; /** text reads as a sentence-case status ("2 issues"), 12px at xs; outline is the default. */
8
+ variant?: 'outline' | 'ghost' | 'primary' | 'text';
9
9
  size?: 'sm' | 'xs';
10
10
  align?: 'start' | 'end';
11
11
  width?: string;
@@ -13,6 +13,8 @@ export interface SelectProps extends Omit<RootProps, "children" | "value" | "def
13
13
  defaultValue?: string;
14
14
  /** Receives Radix's changed value and its matching option. */
15
15
  onChange?: (value: string, option: SelectOption) => void;
16
+ /** xs for toolbars and status lines (24px with small type on fine pointers, 44px on touch); forms keep the control height. */
17
+ size?: 'xs';
16
18
  id?: string;
17
19
  className?: string;
18
20
  "aria-label"?: string;
@@ -8,7 +8,7 @@ import { normalizeOptions } from "../../internal/options.js";
8
8
  import { useUid } from "../../internal/useUid.js";
9
9
  import { cx } from "../../lib/cx.js";
10
10
  /** Styled Radix Select. Radix owns state, form participation, focus, keys and dismissal. */
11
- export const Select = forwardRef(function Select({ options: optionValues, placeholder, value, defaultValue, onChange, id, className, "aria-label": ariaLabel, "aria-labelledby": labelledBy, "aria-describedby": describedBy, "aria-invalid": invalid, ...rootProps }, ref) {
11
+ export const Select = forwardRef(function Select({ options: optionValues, placeholder, value, defaultValue, onChange, size, id, className, "aria-label": ariaLabel, "aria-labelledby": labelledBy, "aria-describedby": describedBy, "aria-invalid": invalid, ...rootProps }, ref) {
12
12
  const { messages } = useLocale();
13
13
  const options = normalizeOptions(optionValues);
14
14
  const baseId = useUid("vk-select");
@@ -17,5 +17,5 @@ export const Select = forwardRef(function Select({ options: optionValues, placeh
17
17
  if (option)
18
18
  onChange?.(option.value, option);
19
19
  };
20
- return (_jsx("div", { className: cx("vk-select", className), children: _jsxs(Primitive.Root, { ...rootProps, value: value === null ? "" : value, defaultValue: defaultValue, onValueChange: onValueChange, children: [_jsxs(Primitive.Trigger, { ref: ref, id: id, className: "vk-input vk-select-trigger", "aria-label": ariaLabel, "aria-labelledby": labelledBy, "aria-describedby": describedBy, "aria-invalid": invalid, children: [_jsx("span", { className: "vk-select-value", children: _jsx(Primitive.Value, { placeholder: placeholder ?? messages.selectOne }) }), _jsx(Primitive.Icon, { asChild: true, children: _jsx(Icon, { name: "chevron-down", className: "vk-select-icon" }) })] }), _jsx(Primitive.Portal, { children: _jsx(Primitive.Content, { position: "popper", side: "bottom", align: "start", sideOffset: 4, collisionPadding: 8, className: "vk-select-menu vk-select-content", "aria-label": ariaLabel, "aria-labelledby": labelledBy, children: _jsx(Primitive.Viewport, { className: "vk-select-viewport", children: options.map((option, index) => (_jsxs(Primitive.Item, { value: option.value, textValue: option.label, disabled: option.disabled, "data-index": index, "aria-describedby": option.description ? baseId + "-" + String(index) + "-desc" : undefined, className: "vk-select-option", children: [_jsxs("span", { className: "vk-select-option-text", children: [_jsx(Primitive.ItemText, { children: option.label }), option.description ? _jsx("span", { id: baseId + "-" + String(index) + "-desc", className: "vk-select-option-description", children: option.description }) : null] }), _jsx(Primitive.ItemIndicator, { asChild: true, children: _jsx(Icon, { name: "check", size: 16, className: "vk-select-check" }) })] }, option.value))) }) }) })] }) }));
20
+ return (_jsx("div", { className: cx("vk-select", size === "xs" && "vk-select-xs", className), children: _jsxs(Primitive.Root, { ...rootProps, value: value === null ? "" : value, defaultValue: defaultValue, onValueChange: onValueChange, children: [_jsxs(Primitive.Trigger, { ref: ref, id: id, className: "vk-input vk-select-trigger", "aria-label": ariaLabel, "aria-labelledby": labelledBy, "aria-describedby": describedBy, "aria-invalid": invalid, children: [_jsx("span", { className: "vk-select-value", children: _jsx(Primitive.Value, { placeholder: placeholder ?? messages.selectOne }) }), _jsx(Primitive.Icon, { asChild: true, children: _jsx(Icon, { name: "chevron-down", className: "vk-select-icon" }) })] }), _jsx(Primitive.Portal, { children: _jsx(Primitive.Content, { position: "popper", side: "bottom", align: "start", sideOffset: 4, collisionPadding: 8, className: "vk-select-menu vk-select-content", "aria-label": ariaLabel, "aria-labelledby": labelledBy, children: _jsx(Primitive.Viewport, { className: "vk-select-viewport", children: options.map((option, index) => (_jsxs(Primitive.Item, { value: option.value, textValue: option.label, disabled: option.disabled, "data-index": index, "aria-describedby": option.description ? baseId + "-" + String(index) + "-desc" : undefined, className: "vk-select-option", children: [_jsxs("span", { className: "vk-select-option-text", children: [_jsx(Primitive.ItemText, { children: option.label }), option.description ? _jsx("span", { id: baseId + "-" + String(index) + "-desc", className: "vk-select-option-description", children: option.description }) : null] }), _jsx(Primitive.ItemIndicator, { asChild: true, children: _jsx(Icon, { name: "check", size: 16, className: "vk-select-check" }) })] }, option.value))) }) }) })] }) }));
21
21
  });