rift-ds 1.21.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 (111) hide show
  1. package/README.md +3 -3
  2. package/behaviors/chat-card.css +135 -0
  3. package/chat/AssistantTurn.js +12 -4
  4. package/chat/ChatLauncher.js +6 -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 +28 -3
  9. package/chat/ChatWidget.js +83 -41
  10. package/chat/DemoWelcome.js +2 -2
  11. package/chat/TurnContent.d.ts +3 -3
  12. package/chat/actions.d.ts +105 -0
  13. package/chat/actions.js +47 -0
  14. package/chat/agentState.d.ts +14 -0
  15. package/chat/agentState.js +29 -0
  16. package/chat/artifacts.d.ts +5 -0
  17. package/chat/artifacts.js +3 -1
  18. package/chat/demo-card-components.d.ts +3 -4
  19. package/chat/demo-script.js +15 -15
  20. package/chat/generatedStarters.d.ts +19 -0
  21. package/chat/generatedStarters.js +49 -0
  22. package/chat/index.d.ts +8 -3
  23. package/chat/index.js +27 -2
  24. package/chat/placement.d.ts +9 -0
  25. package/chat/placement.js +7 -0
  26. package/chat/queries.d.ts +6 -0
  27. package/chat/queries.js +25 -0
  28. package/chat/questions.d.ts +1 -1
  29. package/chat/questions.js +1 -1
  30. package/chat/registry.json.d.ts +4 -2
  31. package/chat/registry.json.js +1 -1
  32. package/chat/selection.css +8 -0
  33. package/chat/selection.d.ts +40 -0
  34. package/chat/selection.js +140 -0
  35. package/chat/selectionContext.d.ts +70 -0
  36. package/chat/selectionContext.js +60 -0
  37. package/chat/server.d.ts +54 -1
  38. package/chat/server.js +106 -5
  39. package/chat/suggestions.d.ts +12 -8
  40. package/chat/suggestions.js +1 -1
  41. package/chat/types.d.ts +14 -2
  42. package/chat/useChat.js +20 -7
  43. package/components/ActionCard/ActionCard.css +147 -0
  44. package/components/ActionCard/ActionCard.d.ts +54 -0
  45. package/components/ActionCard/ActionCard.js +75 -0
  46. package/components/ActionReadout/ActionReadout.css +47 -0
  47. package/components/ActionReadout/ActionReadout.d.ts +29 -0
  48. package/components/ActionReadout/ActionReadout.js +22 -0
  49. package/components/AgentPlan/AgentPlan.css +18 -8
  50. package/components/AgentPlan/AgentPlan.js +1 -0
  51. package/components/AppSidebar/AppSidebar.css +11 -5
  52. package/components/AppSidebar/AppSidebar.d.ts +2 -0
  53. package/components/AppSidebar/AppSidebar.js +13 -1
  54. package/components/ArtifactCard/ArtifactCard.css +11 -10
  55. package/components/ArtifactCard/ArtifactCard.js +3 -1
  56. package/components/ChatThread/ChatThread.css +6 -3
  57. package/components/Chip/Chip.css +9 -1
  58. package/components/CodeBlock/CodeBlock.css +2 -0
  59. package/components/CodeDiff/CodeDiff.css +18 -8
  60. package/components/CodeDiff/CodeDiff.js +1 -0
  61. package/components/Composer/Composer.css +73 -31
  62. package/components/Composer/Composer.d.ts +12 -4
  63. package/components/Composer/Composer.js +22 -3
  64. package/components/DataTable/FilterEditor.js +4 -2
  65. package/components/DataTable/filterModel.d.ts +8 -0
  66. package/components/DataTable/filterModel.js +4 -0
  67. package/components/DataTable/views.js +2 -2
  68. package/components/DocumentChip/DocumentChip.css +27 -3
  69. package/components/EntitySwitcher/EntitySwitcher.css +333 -0
  70. package/components/EntitySwitcher/EntitySwitcher.d.ts +74 -0
  71. package/components/EntitySwitcher/EntitySwitcher.js +291 -0
  72. package/components/InterruptCard/InterruptCard.css +96 -34
  73. package/components/InterruptCard/InterruptCard.d.ts +20 -3
  74. package/components/InterruptCard/InterruptCard.js +23 -8
  75. package/components/MessageCard/MessageCard.css +27 -18
  76. package/components/MessageCard/MessageCard.js +1 -0
  77. package/components/PromptSuggestions/PromptSuggestions.css +3 -0
  78. package/components/Prose/Prose.css +2 -0
  79. package/components/QuestionCard/QuestionCard.css +9 -5
  80. package/components/QuestionCard/QuestionCard.js +1 -0
  81. package/components/SourceTrail/SourceTrail.css +33 -11
  82. package/components/SourceTrail/SourceTrail.js +3 -2
  83. package/components/TableToolbar/TableToolbar.css +4 -1
  84. package/components/TableToolbar/TableToolbar.js +1 -3
  85. package/components/ThemeToggle/colorMode.d.ts +10 -0
  86. package/components/ThemeToggle/colorMode.js +19 -5
  87. package/components/ToolCall/ToolCall.css +89 -22
  88. package/components/ToolCall/ToolCall.js +2 -1
  89. package/components/UsageCard/UsageCard.css +29 -2
  90. package/components/UsageCard/UsageCard.js +1 -0
  91. package/components/registry.json +24 -0
  92. package/components/registry.json.d.ts +24 -0
  93. package/components/registry.json.js +1 -1
  94. package/fonts/presets/bricolage-grotesque-300-800-latin-ext.woff2 +0 -0
  95. package/fonts/presets/bricolage-grotesque-300-800-latin.woff2 +0 -0
  96. package/fonts/presets/figtree-300-800-latin-ext.woff2 +0 -0
  97. package/fonts/presets/figtree-300-800-latin.woff2 +0 -0
  98. package/index.d.ts +3 -0
  99. package/index.js +6 -0
  100. package/package.json +5 -1
  101. package/tokens/motion.d.ts +2 -0
  102. package/tokens/motion.js +2 -0
  103. package/tokens/presets/plum.css +419 -0
  104. package/tokens/presets/presets.css +1 -0
  105. package/tokens/registry.json +2 -0
  106. package/tokens/registry.json.d.ts +2 -0
  107. package/tokens/registry.json.js +1 -1
  108. package/tokens/tokens-dark.css +4 -0
  109. package/tokens/tokens-light.css +4 -0
  110. package/tokens/tokens-typography.css +8 -2
  111. 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
+ }
@@ -12,6 +12,7 @@ import { useChatWidget } from "./context.js";
12
12
  import { DOCK_QUERY } from "./queries.js";
13
13
  import { FollowupSuggestions } from "./FollowupSuggestions.js";
14
14
  import { ResponseActions } from "./ResponseActions.js";
15
+ import { turnCards } from "./artifacts.js";
15
16
  import { TurnCard } from "./TurnContent.js";
16
17
  import { TurnQuestion } from "./TurnQuestion.js";
17
18
  const CodeBlockLabelsContext = createContext(void 0);
@@ -60,7 +61,13 @@ function AssistantTurn({
60
61
  const durationSeconds = live ? live.durationSeconds : turn?.durationSeconds;
61
62
  const text = live ? live.text : turn?.text ?? "";
62
63
  const content = live ? live.content : turn?.content;
63
- const card = live ? live.card : turn?.card;
64
+ const source = live ?? turn;
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;
64
71
  const { turns, live: liveTurn, freshFollowupsId } = useChatWidget();
65
72
  const followupsPending = !!turn && turn.text !== "" && !!turn.exchangeId && !turn.followups && !turn.question && !liveTurn && turns[turns.length - 1]?.id === turn.id;
66
73
  return /* @__PURE__ */ jsx(
@@ -80,10 +87,10 @@ function AssistantTurn({
80
87
  }
81
88
  ) : followupsPending && turn ? /* @__PURE__ */ jsx(FollowupSuggestions, { turnId: turn.id, suggestions: [], pending: true }) : void 0,
82
89
  children: /* @__PURE__ */ jsxs("div", { className: "ds-chat-widget__response", children: [
83
- (thinking || tracePoints.length > 0) && /* @__PURE__ */ jsx(
90
+ showReasoning && /* @__PURE__ */ jsx(
84
91
  Reasoning,
85
92
  {
86
- streaming: thinking,
93
+ streaming: thinking && !led,
87
94
  summaryOnly: tracePoints.length === 0,
88
95
  duration: durationSeconds,
89
96
  label: labels?.reasoning && !thinking ? labels.reasoning(durationSeconds) : void 0,
@@ -91,8 +98,9 @@ function AssistantTurn({
91
98
  children: tracePoints.length > 0 && /* @__PURE__ */ jsx("ul", { children: tracePoints.map((point, index) => /* @__PURE__ */ jsx("li", { children: point }, `${index}-${point.slice(0, 24)}`)) })
92
99
  }
93
100
  ),
101
+ leadCards.map((card, index) => /* @__PURE__ */ jsx(TurnCard, { card }, `lead-${index}`)),
94
102
  content,
95
- card && /* @__PURE__ */ jsx(TurnCard, { card }),
103
+ cards.map((card, index) => /* @__PURE__ */ jsx(TurnCard, { card }, index)),
96
104
  text !== "" && /* @__PURE__ */ jsx(CodeBlockLabelsContext.Provider, { value: labels?.codeBlock, children: /* @__PURE__ */ jsx(Prose, { children: /* @__PURE__ */ jsx(ReactMarkdown, { remarkPlugins: [remarkGfm], components: markdownComponents, children: text }) }) }),
97
105
  turn?.question && /* @__PURE__ */ jsx(TurnQuestion, { turn, labels: labels?.questionCard })
98
106
  ] })
@@ -4,9 +4,10 @@ import { useSyncExternalStore, useLayoutEffect, useRef, useEffect, useState } fr
4
4
  import { useScrollLock } from "../behaviors/useScrollLock.js";
5
5
  import { AiButton } from "../components/AiButton/AiButton.js";
6
6
  import { ChatWidget } from "./ChatWidget.js";
7
+ import { useChatAgentState } from "./agentState.js";
7
8
  import { useChatWidget } from "./context.js";
8
9
  import { isFloatDragStart, FLOAT_EDGE_GAP, FLOAT_MAX_SCALE, dockWidthFromDrag, clampFloatPosition } from "./placement.js";
9
- import { DOCK_QUERY, TAKEOVER_QUERY } from "./queries.js";
10
+ import { useDockViewport, TAKEOVER_QUERY } from "./queries.js";
10
11
  import "./ChatWidget.css";
11
12
  const CHAT_PANEL_ID = "ds-chat-panel";
12
13
  const FLOAT_GRIPS = [
@@ -30,8 +31,6 @@ const subscribeQuery = (query) => (onChange) => {
30
31
  media.addEventListener("change", onChange);
31
32
  return () => media.removeEventListener("change", onChange);
32
33
  };
33
- const subscribeDock = subscribeQuery(DOCK_QUERY);
34
- const readDocked = () => window.matchMedia(DOCK_QUERY).matches;
35
34
  const subscribeTakeover = subscribeQuery(TAKEOVER_QUERY);
36
35
  const readTakeover = () => window.matchMedia(TAKEOVER_QUERY).matches;
37
36
  function ChatLauncher({
@@ -48,13 +47,14 @@ function ChatLauncher({
48
47
  surface = "raised"
49
48
  }) {
50
49
  const { open, setOpen, panelPhase, view, side, floating, returnFocusRef, send } = useChatWidget();
50
+ const agentState = useChatAgentState();
51
51
  const launchSuggestion = (id) => {
52
52
  const chip = summary?.chips?.find((c) => c.id === id);
53
53
  if (!chip) return;
54
54
  setOpen(true);
55
55
  send(chip.prompt);
56
56
  };
57
- const docked = useSyncExternalStore(subscribeDock, readDocked, () => false);
57
+ const docked = useDockViewport();
58
58
  const takeover = useSyncExternalStore(subscribeTakeover, readTakeover, () => false);
59
59
  const isFull = view === "full" || takeover;
60
60
  const isFloating = floating && !isFull;
@@ -251,6 +251,7 @@ function ChatLauncher({
251
251
  ...aiButtonLabels,
252
252
  label,
253
253
  icon,
254
+ state: agentState,
254
255
  "aria-expanded": false,
255
256
  "aria-controls": panelId,
256
257
  summary: summary ? {
@@ -354,7 +355,7 @@ function ChatLauncher({
354
355
  ]
355
356
  }
356
357
  ),
357
- showPanel && isDocked && /* @__PURE__ */ jsx(
358
+ showPanel && !isFull && !isFloating && /* @__PURE__ */ jsx(
358
359
  "div",
359
360
  {
360
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,9 +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
- /** The composer's context note, written from `contextLabel`. Defaults to `Looking at “<title>”`. */
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. */
141
+ contextPlacement?: 'above' | 'inside';
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`. */
118
143
  contextNote?: (title: string) => string;
119
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`. */
120
145
  attachHint?: (maxSize: string, maxFiles: number, maxBytes: number) => string;
@@ -226,4 +251,4 @@ export interface ChatWidgetProps {
226
251
  * a stage card, a whole page). It reads all of its state from ChatProvider,
227
252
  * so the conversation is the same object wherever it shows.
228
253
  */
229
- 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, 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,9 +15,10 @@ 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
- import { cardArtifact } from "./artifacts.js";
21
+ import { turnCards, cardArtifact } from "./artifacts.js";
20
22
  import { ChatAgentPane } from "./ChatAgentPane.js";
21
23
  import { ChatArtifactPane } from "./ChatArtifactPane.js";
22
24
  import { ChatTabs } from "./ChatTabs.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,8 +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,
80
+ contextPlacement = "inside",
75
81
  attachHint: attachHintText = defaultAttachHint,
76
82
  greetings,
77
83
  placementLabels,
@@ -175,6 +181,7 @@ function ChatWidget({
175
181
  const lockedValues = modelPolicy?.locked ?? [];
176
182
  const pick = chosenModel && !lockedValues.includes(chosenModel) ? chosenModel : null;
177
183
  const pickerValue = pick ?? modelPolicy?.default ?? defaultModel ?? models?.[0]?.value;
184
+ const composerHasActions = fileAttachments || Boolean(composerActions) || (models?.length ?? 0) > 0;
178
185
  const pickerModels = (models ?? []).map((option) => ({
179
186
  value: option.value,
180
187
  label: option.label,
@@ -195,29 +202,55 @@ function ChatWidget({
195
202
  }, [open]);
196
203
  const queue = useAttachments({ maxCount: maxAttachments, maxSize: maxAttachmentBytes });
197
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
+ };
198
221
  const handleSubmit = (value) => {
199
222
  if (fileAttachments && queue.items.length > 0) {
200
223
  const ready = queue.items.filter((item) => item.status === "ready");
201
- if (send(value, { attachments: ready })) {
224
+ if (send(value, { attachments: ready, content: sentContext() })) {
202
225
  queue.take();
203
226
  setDraft("");
204
227
  }
205
- } else if (send(value)) setDraft("");
228
+ } else if (send(value, { content: sentContext() })) setDraft("");
206
229
  focusComposer();
207
230
  };
208
231
  const isFull = view === "full";
209
232
  const isEmpty = turns.length === 0 && !live;
210
233
  const [stagedKey, setStagedKey] = useState(null);
211
- const startersThinking = open && isEmpty && starterRevealKey !== startersKey;
234
+ const heldKey = useRef(null);
235
+ const startersThinking = open && isEmpty && (startersPending || starterRevealKey !== startersKey);
212
236
  const startersEntrance = startersThinking || stagedKey === startersKey;
213
237
  useEffect(() => {
214
238
  if (!(open && isEmpty && starterRevealKey !== startersKey)) return;
215
- const timer = setTimeout(() => {
239
+ if (startersPending) {
240
+ heldKey.current = startersKey;
241
+ return;
242
+ }
243
+ const reveal = () => {
216
244
  setStagedKey(startersKey);
217
245
  setStarterRevealKey(startersKey);
218
- }, MOTION_SUGGESTIONS_THINK_MS);
246
+ };
247
+ if (heldKey.current === startersKey) {
248
+ reveal();
249
+ return;
250
+ }
251
+ const timer = setTimeout(reveal, MOTION_SUGGESTIONS_THINK_MS);
219
252
  return () => clearTimeout(timer);
220
- }, [open, isEmpty, starterRevealKey, setStarterRevealKey, startersKey]);
253
+ }, [open, isEmpty, starterRevealKey, setStarterRevealKey, startersKey, startersPending]);
221
254
  const renderThreads = threads === true ? (ctx) => /* @__PURE__ */ jsx(ChatThreads, { ...threadsProps, logoText: threadsProps?.logoText ?? title, ...ctx }) : threads || void 0;
222
255
  const renderAside = aside ?? (agent ? (ctx) => /* @__PURE__ */ jsx(
223
256
  ChatAgentPane,
@@ -309,8 +342,11 @@ function ChatWidget({
309
342
  };
310
343
  const latestArtifact = useMemo(() => {
311
344
  for (let index = turns.length - 1; index >= 0; index -= 1) {
312
- const found = cardArtifact(turns[index].card);
313
- if (found) return found;
345
+ const cards = turnCards(turns[index]);
346
+ for (let card = cards.length - 1; card >= 0; card -= 1) {
347
+ const found = cardArtifact(cards[card]);
348
+ if (found) return found;
349
+ }
314
350
  }
315
351
  return null;
316
352
  }, [turns]);
@@ -321,7 +357,7 @@ function ChatWidget({
321
357
  }, [asideWide]);
322
358
  useEffect(() => {
323
359
  if (!artifacts) return;
324
- const carrying = turns.filter((turn) => cardArtifact(turn.card));
360
+ const carrying = turns.filter((turn) => turnCards(turn).some((card) => cardArtifact(card)));
325
361
  if (seenArtifactTurns.current === null) {
326
362
  seenArtifactTurns.current = new Set(carrying.map((turn) => turn.id));
327
363
  return;
@@ -329,7 +365,7 @@ function ChatWidget({
329
365
  for (const turn of carrying) {
330
366
  if (seenArtifactTurns.current.has(turn.id)) continue;
331
367
  seenArtifactTurns.current.add(turn.id);
332
- const arrived = cardArtifact(turn.card);
368
+ const arrived = turnCards(turn).map((card) => cardArtifact(card)).filter(Boolean).pop();
333
369
  if (arrived && asideWideRef.current) openArtifact(arrived);
334
370
  }
335
371
  }, [artifacts, turns, openArtifact]);
@@ -374,7 +410,7 @@ function ChatWidget({
374
410
  suggestions: starters,
375
411
  onValueChange: (id) => {
376
412
  const starter = starters.find((s) => s.id === id);
377
- if (starter && send(starter.label)) focusComposer();
413
+ if (starter && send(starter.label, { content: sentContext() })) focusComposer();
378
414
  }
379
415
  }
380
416
  ) });
@@ -556,31 +592,34 @@ function ChatWidget({
556
592
  ),
557
593
  tabsNode && /* @__PURE__ */ jsx("div", { className: "ds-chat-widget__tabs-row", children: tabsNode }),
558
594
  /* @__PURE__ */ jsxs("div", { className: "ds-chat-widget__body", children: [
559
- /* @__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: [
560
- ...turns.map(
561
- (turn) => turn.bare ? (
562
- /* Conversation furniture (a day marker): the injected
563
- content stands alone in the thread, no message chrome. */
564
- /* @__PURE__ */ jsx("div", { children: turn.content }, turn.id)
565
- ) : turn.role === "user" ? (
566
- /* Files ride above the bubble on the sender's side; a turn
567
- of files alone draws no bubble. */
568
- /* @__PURE__ */ jsx(
569
- ChatMessage,
570
- {
571
- role: "user",
572
- attachments: turn.attachments ? /* @__PURE__ */ jsx(AttachmentGroup, { ...attachmentGroupLabels, align: "end", items: turn.attachments }) : /* @__PURE__ */ jsxs(Fragment, { children: [
573
- turn.content,
574
- turn.card && /* @__PURE__ */ jsx(TurnCard, { card: turn.card })
575
- ] }),
576
- 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
577
- },
578
- turn.id
579
- )
580
- ) : /* @__PURE__ */ jsx(AssistantTurn, { turn, labels: turnLabels }, turn.id)
581
- ),
582
- ...live ? [/* @__PURE__ */ jsx(AssistantTurn, { live, labels: turnLabels }, live.id)] : []
583
- ] }) }) }) }),
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
+ ] }) }) }),
584
623
  isEmpty && /* @__PURE__ */ jsx("div", { className: "ds-chat-widget__welcome", children: /* @__PURE__ */ jsxs("div", { className: "ds-chat-widget__greeting", children: [
585
624
  /* @__PURE__ */ jsx("p", { className: "ds-chat-widget__hello", children: greeting }),
586
625
  /* @__PURE__ */ jsx("p", { className: "ds-chat-widget__ask", children: tagline })
@@ -597,15 +636,18 @@ function ChatWidget({
597
636
  placeholder: questionsOpen ? questionsPlaceholder : placeholder,
598
637
  disabled: questionsOpen,
599
638
  sendLabel,
639
+ inline: composerHasActions ? false : "chat",
600
640
  aiGlow: true,
601
641
  value: draft,
602
642
  onValueChange: setDraft,
603
643
  onSubmit: handleSubmit,
604
644
  streaming,
605
645
  onStop: stop,
606
- context: contextLabel ? contextNote(contextLabel) : void 0,
607
- contextIcon: "description",
608
- contextPlacement: "above",
646
+ context: context ? context.note ?? defaultContextNote(context.label) : void 0,
647
+ contextIcon,
648
+ contextPlacement,
649
+ onContextClear: context?.onClear,
650
+ contextClearLabel,
609
651
  mentions,
610
652
  ...fileAttachments ? {
611
653
  files: queue.items,