rift-ds 1.22.0 → 1.23.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 (104) hide show
  1. package/README.md +3 -3
  2. package/behaviors/chat-card.css +135 -0
  3. package/chat/AssistantTurn.js +9 -3
  4. package/chat/ChatLauncher.js +3 -5
  5. package/chat/ChatProvider.d.ts +10 -1
  6. package/chat/ChatProvider.js +3 -2
  7. package/chat/ChatWidget.css +12 -0
  8. package/chat/ChatWidget.d.ts +27 -4
  9. package/chat/ChatWidget.js +73 -37
  10. package/chat/DemoWelcome.js +2 -2
  11. package/chat/actions.d.ts +105 -0
  12. package/chat/actions.js +47 -0
  13. package/chat/demo-card-components.d.ts +3 -4
  14. package/chat/demo-script.js +15 -15
  15. package/chat/generatedStarters.d.ts +19 -0
  16. package/chat/generatedStarters.js +49 -0
  17. package/chat/index.d.ts +7 -3
  18. package/chat/index.js +25 -2
  19. package/chat/placement.d.ts +9 -0
  20. package/chat/placement.js +7 -0
  21. package/chat/queries.d.ts +6 -0
  22. package/chat/queries.js +25 -0
  23. package/chat/questions.d.ts +1 -1
  24. package/chat/questions.js +1 -1
  25. package/chat/registry.json.d.ts +4 -2
  26. package/chat/registry.json.js +1 -1
  27. package/chat/selection.css +8 -0
  28. package/chat/selection.d.ts +40 -0
  29. package/chat/selection.js +140 -0
  30. package/chat/selectionContext.d.ts +70 -0
  31. package/chat/selectionContext.js +60 -0
  32. package/chat/server.d.ts +54 -1
  33. package/chat/server.js +101 -5
  34. package/chat/suggestions.d.ts +12 -8
  35. package/chat/suggestions.js +1 -1
  36. package/chat/types.d.ts +2 -0
  37. package/chat/useChat.js +5 -3
  38. package/components/ActionCard/ActionCard.css +147 -0
  39. package/components/ActionCard/ActionCard.d.ts +54 -0
  40. package/components/ActionCard/ActionCard.js +75 -0
  41. package/components/ActionReadout/ActionReadout.css +47 -0
  42. package/components/ActionReadout/ActionReadout.d.ts +29 -0
  43. package/components/ActionReadout/ActionReadout.js +22 -0
  44. package/components/AgentPlan/AgentPlan.css +18 -8
  45. package/components/AgentPlan/AgentPlan.js +1 -0
  46. package/components/AppSidebar/AppSidebar.css +11 -5
  47. package/components/AppSidebar/AppSidebar.d.ts +2 -0
  48. package/components/AppSidebar/AppSidebar.js +13 -1
  49. package/components/ArtifactCard/ArtifactCard.css +11 -10
  50. package/components/ArtifactCard/ArtifactCard.js +3 -1
  51. package/components/ChatThread/ChatThread.css +6 -3
  52. package/components/Chip/Chip.css +9 -1
  53. package/components/CodeBlock/CodeBlock.css +2 -0
  54. package/components/CodeDiff/CodeDiff.css +18 -8
  55. package/components/CodeDiff/CodeDiff.js +1 -0
  56. package/components/Composer/Composer.css +52 -13
  57. package/components/Composer/Composer.d.ts +9 -1
  58. package/components/Composer/Composer.js +19 -1
  59. package/components/DataTable/FilterEditor.js +4 -2
  60. package/components/DataTable/filterModel.d.ts +8 -0
  61. package/components/DataTable/filterModel.js +4 -0
  62. package/components/DataTable/views.js +2 -2
  63. package/components/DocumentChip/DocumentChip.css +27 -3
  64. package/components/EntitySwitcher/EntitySwitcher.css +333 -0
  65. package/components/EntitySwitcher/EntitySwitcher.d.ts +74 -0
  66. package/components/EntitySwitcher/EntitySwitcher.js +291 -0
  67. package/components/InterruptCard/InterruptCard.css +96 -34
  68. package/components/InterruptCard/InterruptCard.d.ts +20 -3
  69. package/components/InterruptCard/InterruptCard.js +23 -8
  70. package/components/MessageCard/MessageCard.css +27 -18
  71. package/components/MessageCard/MessageCard.js +1 -0
  72. package/components/PromptSuggestions/PromptSuggestions.css +3 -0
  73. package/components/Prose/Prose.css +2 -0
  74. package/components/QuestionCard/QuestionCard.css +9 -5
  75. package/components/QuestionCard/QuestionCard.js +1 -0
  76. package/components/SourceTrail/SourceTrail.css +33 -11
  77. package/components/SourceTrail/SourceTrail.js +3 -2
  78. package/components/TableToolbar/TableToolbar.css +4 -1
  79. package/components/TableToolbar/TableToolbar.js +1 -1
  80. package/components/ToolCall/ToolCall.css +89 -22
  81. package/components/ToolCall/ToolCall.js +2 -1
  82. package/components/UsageCard/UsageCard.css +29 -2
  83. package/components/UsageCard/UsageCard.js +1 -0
  84. package/components/registry.json +24 -0
  85. package/components/registry.json.d.ts +24 -0
  86. package/components/registry.json.js +1 -1
  87. package/fonts/presets/bricolage-grotesque-300-800-latin-ext.woff2 +0 -0
  88. package/fonts/presets/bricolage-grotesque-300-800-latin.woff2 +0 -0
  89. package/fonts/presets/figtree-300-800-latin-ext.woff2 +0 -0
  90. package/fonts/presets/figtree-300-800-latin.woff2 +0 -0
  91. package/index.d.ts +3 -0
  92. package/index.js +6 -0
  93. package/package.json +5 -1
  94. package/tokens/motion.d.ts +2 -0
  95. package/tokens/motion.js +2 -0
  96. package/tokens/presets/plum.css +419 -0
  97. package/tokens/presets/presets.css +1 -0
  98. package/tokens/registry.json +2 -0
  99. package/tokens/registry.json.d.ts +2 -0
  100. package/tokens/registry.json.js +1 -1
  101. package/tokens/tokens-dark.css +4 -0
  102. package/tokens/tokens-light.css +4 -0
  103. package/tokens/tokens-typography.css +8 -2
  104. package/tokens/values.json.js +1 -1
package/README.md CHANGED
@@ -13,7 +13,7 @@ An open source React design system built for AI products and coding agents: comp
13
13
 
14
14
  ## Why Rift DS
15
15
 
16
- - **<!-- component-count -->162<!-- /component-count --> components.** Buttons, forms and tables through to charts, navigation and overlays, each typed and documented with live examples. Every one forwards a ref and your own attributes to its element, state you can own works controlled or uncontrolled (a modal opens when your app says so, by design), and every word a component writes has a prop you can localise. The build checks the first two on every component, and the words wherever they sit in markup. React and React DOM are the only required peer dependencies.
16
+ - **<!-- component-count -->165<!-- /component-count --> components.** Buttons, forms and tables through to charts, navigation and overlays, each typed and documented with live examples. Every one forwards a ref and your own attributes to its element, state you can own works controlled or uncontrolled (a modal opens when your app says so, by design), and every word a component writes has a prop you can localise. The build checks the first two on every component, and the words wherever they sit in markup. React and React DOM are the only required peer dependencies.
17
17
  - **AI patterns, the whole chat and templates, ready to use.** Composer, streaming chat thread, tool calls, reasoning and thread panel are in the box, the complete AI chat ships assembled as one widget that one command scaffolds, and the docs site has complete template screens built from them.
18
18
  - **Fully themeable.** The shipped themes are complete looks to start from, each in light and dark. One `data-brand` attribute applies a theme, and a few CSS overrides make your own.
19
19
  - **Ready for coding agents.** One command installs the agent skills, and a public MCP endpoint serves every component's props, so your agent builds with the library as it actually is. No key, no account.
@@ -107,13 +107,13 @@ import 'rift-ds/tokens/presets/presets.css';
107
107
 
108
108
  ## Components
109
109
 
110
- <!-- component-count -->162<!-- /component-count --> components, including a chat set for AI products (Chat thread, Composer, Tool call, Reasoning, Thread panel) and Shader field, a WebGL2 ambient background whose light sources read your colour tokens at runtime, so it re-themes with everything else. Details and live examples are on the [docs site](https://rift-ds.com/components).
110
+ <!-- component-count -->165<!-- /component-count --> components, including a chat set for AI products (Chat thread, Composer, Tool call, Reasoning, Thread panel) and Shader field, a WebGL2 ambient background whose light sources read your colour tokens at runtime, so it re-themes with everything else. Details and live examples are on the [docs site](https://rift-ds.com/components).
111
111
 
112
112
  <details>
113
113
  <summary>The full list</summary>
114
114
 
115
115
  <!-- component-list:start -->
116
- Accordion · Agent plan · Agent rail · Agent status · AI button · Alert · Alert dialog · Anchor nav · Animated number · App layout · App sidebar · Area chart · Artifact card · Artifact panel · Attachment drop zone · Attachment group · Attachment tile · Attachment viewer · Avatar · Avatar group · Badge · Banner · Bar chart · Bento tile · Bento tile art · Bottom nav · Breadcrumb · Button · Button group · Card · Card stack · Carousel · Chat header · Chat marker · Chat message · Chat thread · Checkbox · Chip · Circular button · Code block · Code diff · Colour picker · Combo chart · Combobox · Command palette · Command palette trigger · Composer · Contact card · Context menu · Contribution graph · Data table · Date input · Date picker · Dialog · Divider · Document chip · Drawer · Dropdown · Dropdown menu · Empty state · Entity card · Event calendar · Field · Figure · File input · Filter bar · Funnel chart · Gantt chart · Gauge · Globe · Hover card · Image compare · Input · Inspector colour picker · Inspector dropdown · Inspector input · Inspector section · Inspector segments · Inspector slider · Inspector toggle switch · Instructions · Interrupt card · Kbd · Legend tile · Lightbox · Line chart · Link list · Map callout · Map legend · Mega menu · Mention · Message actions · Message card · Meter · Model picker · Nav · Nav list · Notification centre · Number input · Pagination · Panel · Pie chart · Pin input · Pixel avatar · Popover · Progress bar · Progressive blur · Prompt suggestions · Prose · Question card · Quote · Radar chart · Radial chart · Radio button · Rating · Reasoning · Rich dropdown · Scatter chart · Section title · Segmented control · Selection card · Shader field · Sidebar panel · Site header · Skeleton · Slider · Source chip · Source trail · Sparkline · Spinner · Split button · Split pane · Stacked bar chart · Stat · Status dot · Stepper · Streaming text · Swatch · Table · Table toolbar · Tabs · Tag input · Textarea · Theme picker · Theme toggle · Thread panel · Thread tabs · Time picker · Timeline · Toast · Toggle group · Toggle switch · Tool call · Toolbar · Tooltip · Top app bar · Tree view · Treemap · Usage card · Waveform · Widget · World map
116
+ Accordion · Action card · Action readout · Agent plan · Agent rail · Agent status · AI button · Alert · Alert dialog · Anchor nav · Animated number · App layout · App sidebar · Area chart · Artifact card · Artifact panel · Attachment drop zone · Attachment group · Attachment tile · Attachment viewer · Avatar · Avatar group · Badge · Banner · Bar chart · Bento tile · Bento tile art · Bottom nav · Breadcrumb · Button · Button group · Card · Card stack · Carousel · Chat header · Chat marker · Chat message · Chat thread · Checkbox · Chip · Circular button · Code block · Code diff · Colour picker · Combo chart · Combobox · Command palette · Command palette trigger · Composer · Contact card · Context menu · Contribution graph · Data table · Date input · Date picker · Dialog · Divider · Document chip · Drawer · Dropdown · Dropdown menu · Empty state · Entity card · Entity switcher · Event calendar · Field · Figure · File input · Filter bar · Funnel chart · Gantt chart · Gauge · Globe · Hover card · Image compare · Input · Inspector colour picker · Inspector dropdown · Inspector input · Inspector section · Inspector segments · Inspector slider · Inspector toggle switch · Instructions · Interrupt card · Kbd · Legend tile · Lightbox · Line chart · Link list · Map callout · Map legend · Mega menu · Mention · Message actions · Message card · Meter · Model picker · Nav · Nav list · Notification centre · Number input · Pagination · Panel · Pie chart · Pin input · Pixel avatar · Popover · Progress bar · Progressive blur · Prompt suggestions · Prose · Question card · Quote · Radar chart · Radial chart · Radio button · Rating · Reasoning · Rich dropdown · Scatter chart · Section title · Segmented control · Selection card · Shader field · Sidebar panel · Site header · Skeleton · Slider · Source chip · Source trail · Sparkline · Spinner · Split button · Split pane · Stacked bar chart · Stat · Status dot · Stepper · Streaming text · Swatch · Table · Table toolbar · Tabs · Tag input · Textarea · Theme picker · Theme toggle · Thread panel · Thread tabs · Time picker · Timeline · Toast · Toggle group · Toggle switch · Tool call · Toolbar · Tooltip · Top app bar · Tree view · Treemap · Usage card · Waveform · Widget · World map
117
117
  <!-- component-list:end -->
118
118
 
119
119
  </details>
@@ -0,0 +1,135 @@
1
+ /* ============================================
2
+ THE CHAT CARD RECIPE
3
+ The one home of the values every card a chat
4
+ reply can carry is drawn to, so the family is
5
+ one set: change a line here and every card
6
+ follows. Each card imports this file and reads
7
+ these properties instead of restating a token.
8
+
9
+ Declared on the cards themselves, not on :root,
10
+ so a theme scoped to part of a page (the
11
+ playground's stage) reaches them: a custom
12
+ property resolves where it is declared.
13
+
14
+ The selector list is the family. A new chat
15
+ card joins it here and reads the properties;
16
+ scripts/validate-chat-cards.mjs fails the build
17
+ for an ai component that draws a card shell of
18
+ its own outside it. design.md's "The chat cards
19
+ are one family" owns the rules these encode.
20
+
21
+ Below the properties, the two marks more than
22
+ one card shows, drawn once here and composed
23
+ by each card that shows one: the fact list and
24
+ the decision's read-out.
25
+ ============================================ */
26
+
27
+ :where(
28
+ .ds-interrupt-card,
29
+ .ds-question-card,
30
+ .ds-question-summary,
31
+ .ds-action-card,
32
+ .ds-action-readout,
33
+ .ds-tool-call,
34
+ .ds-agent-plan,
35
+ .ds-source-trail,
36
+ .ds-message-card,
37
+ .ds-artifact-card,
38
+ .ds-usage-card,
39
+ .ds-codediff
40
+ ) {
41
+ /* The shell: the crisp fill behind a hairline, at the bubbles' corner. */
42
+ --ds-chat-card-bg: var(--color-chat-card-bg);
43
+ --ds-chat-card-border: var(--border-025) solid var(--color-bg-container-border);
44
+ --ds-chat-card-radius: var(--radius-600);
45
+ /* A card whose content runs to its edges takes the code family's corner. */
46
+ --ds-chat-card-radius-edge: var(--radius-300);
47
+
48
+ /* Insets: every row's first thing stands this far in; stacked cards and
49
+ opened panels hold their text this far off the top and bottom edges. */
50
+ --ds-chat-card-inset: var(--padding-500);
51
+ --ds-chat-card-edge: var(--padding-300);
52
+
53
+ /* Rhythm, three steps: a title's subline (a description, detail, meta or
54
+ subtitle line) sits straight under it, its leading the only space; a
55
+ body under that (a description under a meta line, a list of facts)
56
+ stands a text gap off; blocks (text to buttons) a block gap apart. */
57
+ --ds-chat-card-gap-subline: 0;
58
+ --ds-chat-card-gap-text: var(--gap-200);
59
+ --ds-chat-card-gap-block: var(--gap-400);
60
+
61
+ /* One-row cards: a compact control and this much above and below, so a
62
+ label row and a row holding a button are one height. */
63
+ --ds-chat-card-row-pad: var(--padding-100);
64
+ --ds-chat-card-row-height: calc(var(--control-height-compact) + 2 * var(--ds-chat-card-row-pad));
65
+
66
+ /* Every icon in a card, spinners in the same box. */
67
+ --ds-chat-card-icon: var(--icon-size-500);
68
+ }
69
+
70
+ /* The fact list: a label beside its value, a line each, as ActionReadout
71
+ and ActionCard list what a change will do or did. A card sets only where
72
+ the list sits. */
73
+ .ds-chat-card-facts {
74
+ display: grid;
75
+ grid-template-columns: max-content minmax(0, 1fr);
76
+ column-gap: var(--gap-400);
77
+ row-gap: var(--gap-100);
78
+ margin: 0;
79
+ font-family: var(--font-paragraph-sm-family);
80
+ font-size: var(--font-paragraph-sm-size);
81
+ font-weight: var(--font-paragraph-sm-weight);
82
+ line-height: var(--font-paragraph-sm-line-height);
83
+ letter-spacing: var(--font-paragraph-sm-letter-spacing);
84
+ }
85
+
86
+ .ds-chat-card-facts dt {
87
+ color: var(--color-text-secondary);
88
+ }
89
+
90
+ .ds-chat-card-facts dd {
91
+ margin: 0;
92
+ color: var(--color-text-primary);
93
+ overflow-wrap: anywhere;
94
+ }
95
+
96
+ /* The read-out: a decision as a record where its buttons stood. A compact
97
+ Button's height, pill, padding, gap, type and icon size, so it sits where
98
+ the buttons were without a jump, filled in the status the decision records
99
+ instead of the action colour, so it reads as done rather than pressable. */
100
+ .ds-chat-card-readout {
101
+ --ds-chat-card-readout-bg: var(--color-status-neutral-bg);
102
+ --ds-chat-card-readout-text: var(--color-status-neutral-text);
103
+
104
+ box-sizing: border-box;
105
+ display: inline-flex;
106
+ align-items: center;
107
+ gap: var(--gap-200);
108
+ height: var(--control-height-compact);
109
+ padding: 0 var(--padding-300);
110
+ border-radius: var(--radius-pill);
111
+ background-color: var(--ds-chat-card-readout-bg);
112
+ color: var(--ds-chat-card-readout-text);
113
+ font-family: var(--font-paragraph-sm-emphasis-family);
114
+ font-size: var(--font-paragraph-sm-emphasis-size);
115
+ font-weight: var(--font-paragraph-sm-emphasis-weight);
116
+ line-height: var(--font-paragraph-sm-emphasis-line-height);
117
+ letter-spacing: var(--font-paragraph-sm-emphasis-letter-spacing);
118
+ white-space: nowrap;
119
+ }
120
+
121
+ .ds-chat-card-readout--positive {
122
+ --ds-chat-card-readout-bg: var(--color-status-positive-bg);
123
+ --ds-chat-card-readout-text: var(--color-status-positive-text);
124
+ }
125
+
126
+ .ds-chat-card-readout--error {
127
+ --ds-chat-card-readout-bg: var(--color-status-error-bg);
128
+ --ds-chat-card-readout-text: var(--color-status-error-text);
129
+ }
130
+
131
+ .ds-chat-card-readout__icon {
132
+ --icon-size: var(--icon-size-500);
133
+
134
+ color: inherit;
135
+ }
@@ -62,7 +62,12 @@ function AssistantTurn({
62
62
  const text = live ? live.text : turn?.text ?? "";
63
63
  const content = live ? live.content : turn?.content;
64
64
  const source = live ?? turn;
65
- const cards = source ? turnCards(source) : [];
65
+ const allCards = source ? turnCards(source) : [];
66
+ const leadCards = allCards.filter((card) => card.lead);
67
+ const cards = allCards.filter((card) => !card.lead);
68
+ const led = leadCards.length > 0;
69
+ const answered = !!content || cards.length > 0;
70
+ const showReasoning = tracePoints.length > 0 || thinking && !answered || led;
66
71
  const { turns, live: liveTurn, freshFollowupsId } = useChatWidget();
67
72
  const followupsPending = !!turn && turn.text !== "" && !!turn.exchangeId && !turn.followups && !turn.question && !liveTurn && turns[turns.length - 1]?.id === turn.id;
68
73
  return /* @__PURE__ */ jsx(
@@ -82,10 +87,10 @@ function AssistantTurn({
82
87
  }
83
88
  ) : followupsPending && turn ? /* @__PURE__ */ jsx(FollowupSuggestions, { turnId: turn.id, suggestions: [], pending: true }) : void 0,
84
89
  children: /* @__PURE__ */ jsxs("div", { className: "ds-chat-widget__response", children: [
85
- (thinking || tracePoints.length > 0) && /* @__PURE__ */ jsx(
90
+ showReasoning && /* @__PURE__ */ jsx(
86
91
  Reasoning,
87
92
  {
88
- streaming: thinking,
93
+ streaming: thinking && !led,
89
94
  summaryOnly: tracePoints.length === 0,
90
95
  duration: durationSeconds,
91
96
  label: labels?.reasoning && !thinking ? labels.reasoning(durationSeconds) : void 0,
@@ -93,6 +98,7 @@ function AssistantTurn({
93
98
  children: tracePoints.length > 0 && /* @__PURE__ */ jsx("ul", { children: tracePoints.map((point, index) => /* @__PURE__ */ jsx("li", { children: point }, `${index}-${point.slice(0, 24)}`)) })
94
99
  }
95
100
  ),
101
+ leadCards.map((card, index) => /* @__PURE__ */ jsx(TurnCard, { card }, `lead-${index}`)),
96
102
  content,
97
103
  cards.map((card, index) => /* @__PURE__ */ jsx(TurnCard, { card }, index)),
98
104
  text !== "" && /* @__PURE__ */ jsx(CodeBlockLabelsContext.Provider, { value: labels?.codeBlock, children: /* @__PURE__ */ jsx(Prose, { children: /* @__PURE__ */ jsx(ReactMarkdown, { remarkPlugins: [remarkGfm], components: markdownComponents, children: text }) }) }),
@@ -7,7 +7,7 @@ import { ChatWidget } from "./ChatWidget.js";
7
7
  import { useChatAgentState } from "./agentState.js";
8
8
  import { useChatWidget } from "./context.js";
9
9
  import { isFloatDragStart, FLOAT_EDGE_GAP, FLOAT_MAX_SCALE, dockWidthFromDrag, clampFloatPosition } from "./placement.js";
10
- import { DOCK_QUERY, TAKEOVER_QUERY } from "./queries.js";
10
+ import { useDockViewport, TAKEOVER_QUERY } from "./queries.js";
11
11
  import "./ChatWidget.css";
12
12
  const CHAT_PANEL_ID = "ds-chat-panel";
13
13
  const FLOAT_GRIPS = [
@@ -31,8 +31,6 @@ const subscribeQuery = (query) => (onChange) => {
31
31
  media.addEventListener("change", onChange);
32
32
  return () => media.removeEventListener("change", onChange);
33
33
  };
34
- const subscribeDock = subscribeQuery(DOCK_QUERY);
35
- const readDocked = () => window.matchMedia(DOCK_QUERY).matches;
36
34
  const subscribeTakeover = subscribeQuery(TAKEOVER_QUERY);
37
35
  const readTakeover = () => window.matchMedia(TAKEOVER_QUERY).matches;
38
36
  function ChatLauncher({
@@ -56,7 +54,7 @@ function ChatLauncher({
56
54
  setOpen(true);
57
55
  send(chip.prompt);
58
56
  };
59
- const docked = useSyncExternalStore(subscribeDock, readDocked, () => false);
57
+ const docked = useDockViewport();
60
58
  const takeover = useSyncExternalStore(subscribeTakeover, readTakeover, () => false);
61
59
  const isFull = view === "full" || takeover;
62
60
  const isFloating = floating && !isFull;
@@ -357,7 +355,7 @@ function ChatLauncher({
357
355
  ]
358
356
  }
359
357
  ),
360
- showPanel && isDocked && /* @__PURE__ */ jsx(
358
+ showPanel && !isFull && !isFloating && /* @__PURE__ */ jsx(
361
359
  "div",
362
360
  {
363
361
  className: [
@@ -14,6 +14,15 @@ export interface ChatProviderProps {
14
14
  transport?: ChatTransport;
15
15
  /** The endpoint the default transport posts to. */
16
16
  endpoint?: string;
17
+ /**
18
+ * What the default transport sends as the request's context, read at each
19
+ * send: the page by default (`window.location.pathname`). A host whose chat
20
+ * follows more than the page (a highlight, a selection) returns its own
21
+ * string, which its handler's `sanitiseContext` checks. Pass a stable
22
+ * function (one that reads the latest state itself), since a new one makes
23
+ * a new transport. Ignored with a `transport`, which carries its own.
24
+ */
25
+ getContext?: () => string | null;
17
26
  /** The seat the panel opens in. */
18
27
  defaultPlacement?: ChatPlacement;
19
28
  /**
@@ -57,4 +66,4 @@ export interface ChatProviderProps {
57
66
  * clicking between pages for free. A hard reload starts clean by design:
58
67
  * no storage, no persistence.
59
68
  */
60
- export declare function ChatProvider({ transport, endpoint, defaultPlacement, followups, fallbackFollowups, feedback, renderers, artifactRenderers, renderLink, isInternalHref, threads: threadsOptions, placeholders, children, }: ChatProviderProps): import("react").JSX.Element;
69
+ export declare function ChatProvider({ transport, endpoint, getContext, defaultPlacement, followups, fallbackFollowups, feedback, renderers, artifactRenderers, renderLink, isInternalHref, threads: threadsOptions, placeholders, children, }: ChatProviderProps): import("react").JSX.Element;
@@ -21,6 +21,7 @@ const defaultRenderLink = (props) => /* @__PURE__ */ jsx(DefaultChatLink, { ...p
21
21
  function ChatProvider({
22
22
  transport,
23
23
  endpoint = "/api/chat",
24
+ getContext,
24
25
  defaultPlacement = "right",
25
26
  followups = "/api/chat/followups",
26
27
  fallbackFollowups = DEFAULT_FALLBACK_FOLLOWUPS,
@@ -35,8 +36,8 @@ function ChatProvider({
35
36
  }) {
36
37
  const [chosenModel, setChosenModel] = useState(null);
37
38
  const fallbackTransport = useMemo(
38
- () => createFetchTransport(endpoint, { getModel: () => chosenModel }),
39
- [endpoint, chosenModel]
39
+ () => createFetchTransport(endpoint, { getModel: () => chosenModel, getContext }),
40
+ [endpoint, chosenModel, getContext]
40
41
  );
41
42
  const placeholderCopy = useMemo(
42
43
  () => ({ ...DEFAULT_PLACEHOLDER_COPY, ...placeholders }),
@@ -1248,3 +1248,15 @@ html[data-chat-resizing] .ds-chat-launcher__panel--floating .ds-chat-header {
1248
1248
  border-radius: var(--radius-pill);
1249
1249
  box-shadow: var(--shadow-floating);
1250
1250
  }
1251
+
1252
+ /* A sent message's context: the note's subject as a compact DocumentChip on the
1253
+ sender's side, over the bubble, where files ride. */
1254
+ .ds-chat-widget__sent-context {
1255
+ display: flex;
1256
+ justify-content: flex-end;
1257
+ min-width: 0;
1258
+ }
1259
+
1260
+ .ds-chat-widget__sent-context .ds-document-chip {
1261
+ max-width: 100%;
1262
+ }
@@ -15,6 +15,23 @@ import { ChatThreadsProps } from './ChatThreads';
15
15
  import { GreetingCopy } from './greeting';
16
16
  import { ChatPlacement } from './placement';
17
17
  import { ChatModelOption, Starter } from './types';
18
+ /**
19
+ * What the chat is looking at, as the composer's context note shows it. One
20
+ * object, so a host whose context follows the reader changes the label, the
21
+ * line, the icon, the way back and what each sent message carries together.
22
+ */
23
+ export interface ChatContext {
24
+ /** What it is called: a page title, "ORD-1000116", "3 orders", a passage. The note says it, and a sent message's chip names it. */
25
+ label: string;
26
+ /** The note's whole line, for a host that words it itself. Defaults to `Looking at “<label>”`. */
27
+ note?: string;
28
+ /** The note's icon: a Material Symbol name, or your own element. Defaults to `description`. */
29
+ icon?: string | ReactNode;
30
+ /** Called by the note's clear button, which appears only when this is set: for a context that follows a selection and can go back to the page as a whole. Its name is `contextClearLabel`. */
31
+ onClear?: () => void;
32
+ /** Repeat the context above each message sent while it is set, so the thread keeps what each question was about. `true` draws `label` as a compact DocumentChip wearing `icon`; a function draws what it returns, called at the send, for a chip that does more, such as bringing its context back. A message sent with files keeps its files there instead. */
33
+ sent?: boolean | (() => ReactNode);
34
+ }
18
35
  /** A rail slot: the widget's own panel, or a render prop for a custom one. */
19
36
  export type RailSlot = boolean | ((ctx: {
20
37
  overlay: boolean;
@@ -73,6 +90,8 @@ export interface ChatWidgetProps {
73
90
  starters?: Starter[];
74
91
  /** Keys the starters' staged reveal: a new key replays the generation beat, the same key shows the set standing. A host whose starters follow the page passes the pathname. */
75
92
  startersKey?: string;
93
+ /** Holds the starters' shimmer while the host is still writing them, for starters a model generates: the set reveals the moment this turns false, without the staged beat. Off by default. */
94
+ startersPending?: boolean;
76
95
  /** Replaces the composer's leading actions (the model picker). */
77
96
  composerActions?: ReactNode;
78
97
  /** The models the picker offers. The pick rides on each send as a wire value; the server resolves it. Omit for no picker. */
@@ -112,11 +131,15 @@ export interface ChatWidgetProps {
112
131
  agent?: ChatAgentOptions;
113
132
  /** Seat the artifact panel: a reply that carries an artifact draws a tile in the thread, and the tile (or the header's artifact button) opens the artifact beside the conversation on a wide host and as a bottom sheet on a narrow one. The trailing seat holds one panel at a time, so an open artifact stands in for the agent pane. Off, none of it exists: no header button, no tile, no panel. */
114
133
  artifacts?: boolean;
115
- /** The composer's context note, naming what the chat is looking at. Omit for none. The note's wording comes from `contextNote`. */
134
+ /** What the chat is looking at, named on the composer's context note: a page, a selection, a passage. Omit for none. A host whose context follows the reader (rows they ticked, text they highlighted) updates it as they go, and can offer a way back and repeat it on each message sent. */
135
+ context?: ChatContext | null;
136
+ /** The accessible name of the context note's clear button, shown when `context.onClear` is set. Defaults to "Clear context". */
137
+ contextClearLabel?: string;
138
+ /** The composer's context note, naming what the chat is looking at. @deprecated Use `context` with its `label`. */
116
139
  contextLabel?: string | null;
117
- /** Where the context note sits: `above` the composer, or `inside` it, at the top of the shell, which brings the two-row composer. */
140
+ /** Where the context note sits: `inside` the composer, at the top of the shell, or `above` it as a bar of its own. Defaults to `inside`, the Composer's own default. A note alone never brings the composer's footer: with nothing else to seat there, it sits over the one-row composer. */
118
141
  contextPlacement?: 'above' | 'inside';
119
- /** The composer's context note, written from `contextLabel`. Defaults to `Looking at “<title>”`. */
142
+ /** The composer's context note, written from `contextLabel`, for a host still on the label prop; `context` takes its `note` as a line. @deprecated Use `context` with its `note`. */
120
143
  contextNote?: (title: string) => string;
121
144
  /** The second line of the drop overlay with attachments on, written from the limits: the largest file as text ("50 MB"), the most files per message, and the largest file in bytes for a host that formats sizes itself. Defaults to `Up to <maxSize> each · <maxFiles> files max`. */
122
145
  attachHint?: (maxSize: string, maxFiles: number, maxBytes: number) => string;
@@ -228,4 +251,4 @@ export interface ChatWidgetProps {
228
251
  * a stage card, a whole page). It reads all of its state from ChatProvider,
229
252
  * so the conversation is the same object wherever it shows.
230
253
  */
231
- export declare function ChatWidget({ fullscreenEnabled, closeEnabled, placementEnabled, compact, phone, title, flow, placeholder, questionsPlaceholder, showStarters, logo, tagline, starters: startersInput, startersKey, composerActions, models, defaultModel, lockedModelDescription, fileAttachments, maxAttachments, maxAttachmentBytes, mentions, threads, threadsProps, tabs, aside, agent, artifacts, contextLabel, contextNote, contextPlacement, attachHint: attachHintText, greetings, placementLabels, agentStatus, artifactPanelTitle, artifactEmptyTitle, artifactEmptyDescription, widgets, widgetsLayout, widgetsWidth, disclaimer, startersLabel, newChatLabel, showAgentLabel, hideAgentLabel, closeAgentLabel, showArtifactLabel, hideArtifactLabel, closeArtifactLabel, placementLabel, enterFullscreenLabel, exitFullscreenLabel, closeLabel, openThreadsLabel, closeThreadsLabel, modelPickerLabel, sendLabel, copyResponseLabel, copiedResponseLabel, copiedAnnouncementLabel, goodResponseLabel, badResponseLabel, followupsLabel, pastedTextLabel, reasoningLabel, tabsProps, composerLabels, attachmentDropZoneLabels, attachmentGroupLabels, chatThreadLabels, modelPickerLabels, artifactPanelLabels, agentRailLabels, questionCardLabels, questionSummaryLabels, codeBlockLabels, promptSuggestionsLabels, }: ChatWidgetProps): import("react").JSX.Element;
254
+ export declare function ChatWidget({ fullscreenEnabled, closeEnabled, placementEnabled, compact, phone, title, flow, placeholder, questionsPlaceholder, showStarters, logo, tagline, starters: startersInput, startersKey, startersPending, composerActions, models, defaultModel, lockedModelDescription, fileAttachments, maxAttachments, maxAttachmentBytes, mentions, threads, threadsProps, tabs, aside, agent, artifacts, context: contextProp, contextClearLabel, contextLabel, contextNote, contextPlacement, attachHint: attachHintText, greetings, placementLabels, agentStatus, artifactPanelTitle, artifactEmptyTitle, artifactEmptyDescription, widgets, widgetsLayout, widgetsWidth, disclaimer, startersLabel, newChatLabel, showAgentLabel, hideAgentLabel, closeAgentLabel, showArtifactLabel, hideArtifactLabel, closeArtifactLabel, placementLabel, enterFullscreenLabel, exitFullscreenLabel, closeLabel, openThreadsLabel, closeThreadsLabel, modelPickerLabel, sendLabel, copyResponseLabel, copiedResponseLabel, copiedAnnouncementLabel, goodResponseLabel, badResponseLabel, followupsLabel, pastedTextLabel, reasoningLabel, tabsProps, composerLabels, attachmentDropZoneLabels, attachmentGroupLabels, chatThreadLabels, modelPickerLabels, artifactPanelLabels, agentRailLabels, questionCardLabels, questionSummaryLabels, codeBlockLabels, promptSuggestionsLabels, }: ChatWidgetProps): import("react").JSX.Element;
@@ -5,6 +5,7 @@ import { AttachmentDropZone } from "../components/Attachment/AttachmentDropZone.
5
5
  import { AttachmentGroup } from "../components/Attachment/AttachmentGroup.js";
6
6
  import { useAttachments } from "../components/Attachment/useAttachments.js";
7
7
  import { ChatHeader } from "../components/ChatHeader/ChatHeader.js";
8
+ import { DocumentChip } from "../components/DocumentChip/DocumentChip.js";
8
9
  import { ChatMessage } from "../components/ChatMessage/ChatMessage.js";
9
10
  import { ChatThread } from "../components/ChatThread/ChatThread.js";
10
11
  import { CircularButton } from "../components/CircularButton/CircularButton.js";
@@ -14,7 +15,8 @@ import { DropdownMenu } from "../components/DropdownMenu/DropdownMenu.js";
14
15
  import { MentionText } from "../components/Mention/Mention.js";
15
16
  import { ModelPicker } from "../components/ModelPicker/ModelPicker.js";
16
17
  import { PromptSuggestions } from "../components/PromptSuggestions/PromptSuggestions.js";
17
- import { MOTION_SUGGESTIONS_THINK_MS, MOTION_SCROLL_SETTLE_MS } from "../tokens/motion.js";
18
+ import { MOTION_ANNOUNCE_DEBOUNCE_MS, MOTION_SUGGESTIONS_THINK_MS, MOTION_SCROLL_SETTLE_MS } from "../tokens/motion.js";
19
+ import "../behaviors/visually-hidden.css";
18
20
  import { AssistantTurn } from "./AssistantTurn.js";
19
21
  import { turnCards, cardArtifact } from "./artifacts.js";
20
22
  import { ChatAgentPane } from "./ChatAgentPane.js";
@@ -56,6 +58,7 @@ function ChatWidget({
56
58
  tagline = "How can I help you today?",
57
59
  starters: startersInput,
58
60
  startersKey = "",
61
+ startersPending = false,
59
62
  composerActions,
60
63
  models,
61
64
  defaultModel,
@@ -70,9 +73,11 @@ function ChatWidget({
70
73
  aside,
71
74
  agent,
72
75
  artifacts = false,
76
+ context: contextProp,
77
+ contextClearLabel = "Clear context",
73
78
  contextLabel,
74
79
  contextNote = defaultContextNote,
75
- contextPlacement = "above",
80
+ contextPlacement = "inside",
76
81
  attachHint: attachHintText = defaultAttachHint,
77
82
  greetings,
78
83
  placementLabels,
@@ -176,7 +181,7 @@ function ChatWidget({
176
181
  const lockedValues = modelPolicy?.locked ?? [];
177
182
  const pick = chosenModel && !lockedValues.includes(chosenModel) ? chosenModel : null;
178
183
  const pickerValue = pick ?? modelPolicy?.default ?? defaultModel ?? models?.[0]?.value;
179
- const composerHasActions = fileAttachments || Boolean(composerActions) || (models?.length ?? 0) > 0 || Boolean(contextLabel) && contextPlacement === "inside";
184
+ const composerHasActions = fileAttachments || Boolean(composerActions) || (models?.length ?? 0) > 0;
180
185
  const pickerModels = (models ?? []).map((option) => ({
181
186
  value: option.value,
182
187
  label: option.label,
@@ -197,29 +202,55 @@ function ChatWidget({
197
202
  }, [open]);
198
203
  const queue = useAttachments({ maxCount: maxAttachments, maxSize: maxAttachmentBytes });
199
204
  const attachHint = attachHintText(formatBytes(maxAttachmentBytes), maxAttachments, maxAttachmentBytes);
205
+ const context = contextProp ?? (contextLabel ? { label: contextLabel, note: contextNote(contextLabel) } : null);
206
+ const contextIcon = context?.icon ?? "description";
207
+ const contextNoteText = context ? context.note ?? defaultContextNote(context.label) : "";
208
+ const [announcedContext, setAnnouncedContext] = useState("");
209
+ const openingContext = useRef(contextNoteText);
210
+ useEffect(() => {
211
+ if (contextNoteText === openingContext.current) return;
212
+ openingContext.current = "";
213
+ const timer = setTimeout(() => setAnnouncedContext(contextNoteText), MOTION_ANNOUNCE_DEBOUNCE_MS);
214
+ return () => clearTimeout(timer);
215
+ }, [contextNoteText]);
216
+ const sentContext = () => {
217
+ if (!context?.sent) return void 0;
218
+ if (typeof context.sent === "function") return context.sent();
219
+ return /* @__PURE__ */ jsx("div", { className: "ds-chat-widget__sent-context", children: /* @__PURE__ */ jsx(DocumentChip, { size: "compact", name: context.label, icon: contextIcon }) });
220
+ };
200
221
  const handleSubmit = (value) => {
201
222
  if (fileAttachments && queue.items.length > 0) {
202
223
  const ready = queue.items.filter((item) => item.status === "ready");
203
- if (send(value, { attachments: ready })) {
224
+ if (send(value, { attachments: ready, content: sentContext() })) {
204
225
  queue.take();
205
226
  setDraft("");
206
227
  }
207
- } else if (send(value)) setDraft("");
228
+ } else if (send(value, { content: sentContext() })) setDraft("");
208
229
  focusComposer();
209
230
  };
210
231
  const isFull = view === "full";
211
232
  const isEmpty = turns.length === 0 && !live;
212
233
  const [stagedKey, setStagedKey] = useState(null);
213
- const startersThinking = open && isEmpty && starterRevealKey !== startersKey;
234
+ const heldKey = useRef(null);
235
+ const startersThinking = open && isEmpty && (startersPending || starterRevealKey !== startersKey);
214
236
  const startersEntrance = startersThinking || stagedKey === startersKey;
215
237
  useEffect(() => {
216
238
  if (!(open && isEmpty && starterRevealKey !== startersKey)) return;
217
- const timer = setTimeout(() => {
239
+ if (startersPending) {
240
+ heldKey.current = startersKey;
241
+ return;
242
+ }
243
+ const reveal = () => {
218
244
  setStagedKey(startersKey);
219
245
  setStarterRevealKey(startersKey);
220
- }, MOTION_SUGGESTIONS_THINK_MS);
246
+ };
247
+ if (heldKey.current === startersKey) {
248
+ reveal();
249
+ return;
250
+ }
251
+ const timer = setTimeout(reveal, MOTION_SUGGESTIONS_THINK_MS);
221
252
  return () => clearTimeout(timer);
222
- }, [open, isEmpty, starterRevealKey, setStarterRevealKey, startersKey]);
253
+ }, [open, isEmpty, starterRevealKey, setStarterRevealKey, startersKey, startersPending]);
223
254
  const renderThreads = threads === true ? (ctx) => /* @__PURE__ */ jsx(ChatThreads, { ...threadsProps, logoText: threadsProps?.logoText ?? title, ...ctx }) : threads || void 0;
224
255
  const renderAside = aside ?? (agent ? (ctx) => /* @__PURE__ */ jsx(
225
256
  ChatAgentPane,
@@ -379,7 +410,7 @@ function ChatWidget({
379
410
  suggestions: starters,
380
411
  onValueChange: (id) => {
381
412
  const starter = starters.find((s) => s.id === id);
382
- if (starter && send(starter.label)) focusComposer();
413
+ if (starter && send(starter.label, { content: sentContext() })) focusComposer();
383
414
  }
384
415
  }
385
416
  ) });
@@ -561,31 +592,34 @@ function ChatWidget({
561
592
  ),
562
593
  tabsNode && /* @__PURE__ */ jsx("div", { className: "ds-chat-widget__tabs-row", children: tabsNode }),
563
594
  /* @__PURE__ */ jsxs("div", { className: "ds-chat-widget__body", children: [
564
- /* @__PURE__ */ jsx(ArtifactSeatContext.Provider, { value: artifacts, children: /* @__PURE__ */ jsx(ResponseActionsLabelsContext.Provider, { value: responseActionsLabels, children: /* @__PURE__ */ jsx(FollowupSuggestionsLabelContext.Provider, { value: followupsLabel, children: /* @__PURE__ */ jsx(ChatThread, { ...chatThreadLabels, className: "ds-chat-widget__thread", flow, children: [
565
- ...turns.map(
566
- (turn) => turn.bare ? (
567
- /* Conversation furniture (a day marker): the injected
568
- content stands alone in the thread, no message chrome. */
569
- /* @__PURE__ */ jsx("div", { children: turn.content }, turn.id)
570
- ) : turn.role === "user" ? (
571
- /* Files ride above the bubble on the sender's side; a turn
572
- of files alone draws no bubble. */
573
- /* @__PURE__ */ jsx(
574
- ChatMessage,
575
- {
576
- role: "user",
577
- attachments: turn.attachments ? /* @__PURE__ */ jsx(AttachmentGroup, { ...attachmentGroupLabels, align: "end", items: turn.attachments }) : /* @__PURE__ */ jsxs(Fragment, { children: [
578
- turn.content,
579
- turnCards(turn).map((card, index) => /* @__PURE__ */ jsx(TurnCard, { card }, index))
580
- ] }),
581
- children: turn.reply ? /* @__PURE__ */ jsx(ReplyBody, { reply: turn.reply, text: turn.text, missingLabel: questionSummaryLabels?.missingLabel }) : mentions && turn.text ? /* @__PURE__ */ jsx(MentionText, { text: turn.text, sources: mentions }) : turn.text
582
- },
583
- turn.id
584
- )
585
- ) : /* @__PURE__ */ jsx(AssistantTurn, { turn, labels: turnLabels }, turn.id)
586
- ),
587
- ...live ? [/* @__PURE__ */ jsx(AssistantTurn, { live, labels: turnLabels }, live.id)] : []
588
- ] }) }) }) }),
595
+ /* @__PURE__ */ jsx(ArtifactSeatContext.Provider, { value: artifacts, children: /* @__PURE__ */ jsx(ResponseActionsLabelsContext.Provider, { value: responseActionsLabels, children: /* @__PURE__ */ jsxs(FollowupSuggestionsLabelContext.Provider, { value: followupsLabel, children: [
596
+ /* @__PURE__ */ jsx("span", { className: "ds-visually-hidden", "aria-live": "polite", children: open ? announcedContext : "" }),
597
+ /* @__PURE__ */ jsx(ChatThread, { ...chatThreadLabels, className: "ds-chat-widget__thread", flow, children: [
598
+ ...turns.map(
599
+ (turn) => turn.bare ? (
600
+ /* Conversation furniture (a day marker): the injected
601
+ content stands alone in the thread, no message chrome. */
602
+ /* @__PURE__ */ jsx("div", { children: turn.content }, turn.id)
603
+ ) : turn.role === "user" ? (
604
+ /* Files ride above the bubble on the sender's side; a turn
605
+ of files alone draws no bubble. */
606
+ /* @__PURE__ */ jsx(
607
+ ChatMessage,
608
+ {
609
+ role: "user",
610
+ attachments: turn.attachments ? /* @__PURE__ */ jsx(AttachmentGroup, { ...attachmentGroupLabels, align: "end", items: turn.attachments }) : /* @__PURE__ */ jsxs(Fragment, { children: [
611
+ turn.content,
612
+ turnCards(turn).map((card, index) => /* @__PURE__ */ jsx(TurnCard, { card }, index))
613
+ ] }),
614
+ children: turn.reply ? /* @__PURE__ */ jsx(ReplyBody, { reply: turn.reply, text: turn.text, missingLabel: questionSummaryLabels?.missingLabel }) : mentions && turn.text ? /* @__PURE__ */ jsx(MentionText, { text: turn.text, sources: mentions }) : turn.text
615
+ },
616
+ turn.id
617
+ )
618
+ ) : /* @__PURE__ */ jsx(AssistantTurn, { turn, labels: turnLabels }, turn.id)
619
+ ),
620
+ ...live ? [/* @__PURE__ */ jsx(AssistantTurn, { live, labels: turnLabels }, live.id)] : []
621
+ ] })
622
+ ] }) }) }),
589
623
  isEmpty && /* @__PURE__ */ jsx("div", { className: "ds-chat-widget__welcome", children: /* @__PURE__ */ jsxs("div", { className: "ds-chat-widget__greeting", children: [
590
624
  /* @__PURE__ */ jsx("p", { className: "ds-chat-widget__hello", children: greeting }),
591
625
  /* @__PURE__ */ jsx("p", { className: "ds-chat-widget__ask", children: tagline })
@@ -609,9 +643,11 @@ function ChatWidget({
609
643
  onSubmit: handleSubmit,
610
644
  streaming,
611
645
  onStop: stop,
612
- context: contextLabel ? contextNote(contextLabel) : void 0,
613
- contextIcon: "description",
646
+ context: context ? context.note ?? defaultContextNote(context.label) : void 0,
647
+ contextIcon,
614
648
  contextPlacement,
649
+ onContextClear: context?.onClear,
650
+ contextClearLabel,
615
651
  mentions,
616
652
  ...fileAttachments ? {
617
653
  files: queue.items,
@@ -9,7 +9,7 @@ import { WidgetGrid, Widget, WidgetRow, WidgetGroup } from "../components/Widget
9
9
  const LINKS = [
10
10
  { id: "How do I get started?", icon: "rocket_launch", label: "Get started", description: "Set up a workspace" },
11
11
  { id: "What do the plans include?", icon: "sell", label: "Plans", description: "What each one includes" },
12
- { id: "Invite my team to a workspace", icon: "group_add", label: "Team", description: "Invite the others" },
12
+ { id: "Invite my team", icon: "group_add", label: "Team", description: "Invite the others" },
13
13
  { id: "How is the trial going?", icon: "monitoring", label: "Trial", description: "Signups so far" }
14
14
  ];
15
15
  const CARDS = [
@@ -70,7 +70,7 @@ function DemoBoard({ onAsk }) {
70
70
  title: "Invite the other three",
71
71
  description: "2 of 5 seats filled",
72
72
  meta: "Today",
73
- onClick: () => onAsk("Invite my team to a workspace")
73
+ onClick: () => onAsk("Invite my team")
74
74
  }
75
75
  ),
76
76
  /* @__PURE__ */ jsx(