@mcp-b/react-components 0.58.1 → 0.59.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 (103) hide show
  1. package/dist/{EmployeeChrome-DsdIek0l.d.ts → EmployeeChrome-QSki0QT4.d.ts} +4 -4
  2. package/dist/{ResponsiveSidebarShell-DoZlSP30.d.ts → ResponsiveSidebarShell-DzBGlRJF.d.ts} +23 -8
  3. package/dist/{ThinkChatActivity-BkGjTY4r.d.ts → ThinkChatActivity-C4_hPEmb.d.ts} +20 -4
  4. package/dist/{ThinkChatActivitySummary-DZVy3uQV.d.ts → ThinkChatActivitySummary-ChJ8Iu2T.d.ts} +3 -3
  5. package/dist/{ThinkChatToolParts-BucHi63O.d.ts → ThinkChatToolParts-BrntWlpa.d.ts} +29 -3
  6. package/dist/{WorkspaceConceptPanel-97ZyVpZI.js → WorkspaceConceptPanel-D21iRsWm.js} +7 -4
  7. package/dist/{WorkspaceFileView-M2jC2P4p.js → WorkspaceFileView-CsWwQA1U.js} +80 -74
  8. package/dist/app-bar-outlet-CNfNzY4Y.js +6 -0
  9. package/dist/components/agents-sdk/AgentChat.js +1 -1
  10. package/dist/components/agents-sdk/BrowserLiveScreen.js +49 -11
  11. package/dist/components/agents-sdk/EmployeeApp.d.ts +2 -3
  12. package/dist/components/agents-sdk/EmployeeApp.js +5 -5
  13. package/dist/components/agents-sdk/EmployeeChat.js +1 -1
  14. package/dist/components/agents-sdk/EmployeeChrome.d.ts +1 -1
  15. package/dist/components/agents-sdk/EmployeeChrome.js +217 -205
  16. package/dist/components/agents-sdk/EmployeeSchedules.d.ts +1 -1
  17. package/dist/components/agents-sdk/EmployeeSchedules.js +8 -8
  18. package/dist/components/agents-sdk/EmployeeStartScreen.d.ts +1 -1
  19. package/dist/components/agents-sdk/EmployeeStartScreen.js +2 -2
  20. package/dist/components/agents-sdk/ManagerAccountActions.js +1 -1
  21. package/dist/components/agents-sdk/ManagerOffice.js +1 -1
  22. package/dist/components/agents-sdk/ManagerOfficeScreens.d.ts +1 -1
  23. package/dist/components/agents-sdk/ManagerOfficeScreens.js +6 -19
  24. package/dist/components/agents-sdk/McpPluginCatalog.js +1 -1
  25. package/dist/components/agents-sdk/ModelEndpointDialog.js +1 -1
  26. package/dist/components/agents-sdk/ModelSelector.js +1 -1
  27. package/dist/components/agents-sdk/SubagentRunPanel.d.ts +8 -9
  28. package/dist/components/agents-sdk/SubagentRunPanel.js +133 -122
  29. package/dist/components/agents-sdk/ThinkChat.d.ts +1 -1
  30. package/dist/components/agents-sdk/ThinkChat.js +26 -3
  31. package/dist/components/agents-sdk/ThinkChatActivity.d.ts +1 -1
  32. package/dist/components/agents-sdk/ThinkChatActivity.js +108 -108
  33. package/dist/components/agents-sdk/ThinkChatActivitySummary.d.ts +1 -1
  34. package/dist/components/agents-sdk/ThinkChatActivitySummary.js +183 -40
  35. package/dist/components/agents-sdk/ThinkChatToolPanels.d.ts +8 -4
  36. package/dist/components/agents-sdk/ThinkChatToolPanels.js +308 -62
  37. package/dist/components/agents-sdk/ThinkChatToolParts.d.ts +2 -2
  38. package/dist/components/agents-sdk/ThinkChatToolParts.js +71 -1
  39. package/dist/components/agents-sdk/ThinkExecutionWorkbench.d.ts +3 -4
  40. package/dist/components/agents-sdk/ThinkExecutionWorkbench.js +5 -5
  41. package/dist/components/agents-sdk/ThinkFullApp.d.ts +1 -1
  42. package/dist/components/agents-sdk/ThinkFullApp.js +6 -1
  43. package/dist/components/agents-sdk/ThinkRoutineActions.js +15 -23
  44. package/dist/components/agents-sdk/ThinkRoutineDetail.js +1 -1
  45. package/dist/components/agents-sdk/ThinkRoutineForm.js +5 -5
  46. package/dist/components/agents-sdk/ThinkThreadPicker.js +2 -2
  47. package/dist/components/agents-sdk/WorkspaceExecution.js +139 -132
  48. package/dist/components/agents-sdk/WorkspaceExecutionTable.js +2 -2
  49. package/dist/components/agents-sdk/WorkspaceExplorer.js +2 -2
  50. package/dist/components/agents-sdk/WorkspaceFileView.js +1 -1
  51. package/dist/components/agents-sdk/WorkspaceHeader.js +26 -28
  52. package/dist/components/agents-sdk/WorkspaceProject.js +1 -1
  53. package/dist/components/agents-sdk/WorkspaceUserScript.js +2 -2
  54. package/dist/components/ai-sdk/Activity.d.ts +1 -1
  55. package/dist/components/ai-sdk/Activity.js +84 -6
  56. package/dist/components/ai-sdk/AgentChatMessageEditor.js +1 -1
  57. package/dist/components/ai-sdk/Approval.js +2 -1
  58. package/dist/components/ai-sdk/ComposerLink.js +1 -1
  59. package/dist/components/ai-sdk/ConnectedAppCards.js +63 -45
  60. package/dist/components/ai-sdk/Conversation.js +1 -1
  61. package/dist/components/ai-sdk/ExpansionState.d.ts +16 -6
  62. package/dist/components/ai-sdk/ExpansionState.js +25 -7
  63. package/dist/components/ai-sdk/MediaPreviewCard.js +1 -1
  64. package/dist/components/ai-sdk/MessageScrollerVirtual.js +98 -11
  65. package/dist/components/ai-sdk/PromptInput.js +7 -3
  66. package/dist/components/ai-sdk/PromptInputComposerEditor.js +2 -2
  67. package/dist/components/ai-sdk/Queue.js +1 -1
  68. package/dist/components/ai-sdk/ToolInvocation.d.ts +8 -0
  69. package/dist/components/ai-sdk/ToolInvocation.js +45 -19
  70. package/dist/components/foundations/ToggleGroup.d.ts +1 -1
  71. package/dist/components/foundations/ToggleGroup.js +2 -2
  72. package/dist/components/general-purpose/PricingBillingToggle.js +1 -1
  73. package/dist/components/general-purpose/PricingUsageCalculator.js +1 -1
  74. package/dist/components/general-purpose/ResponsiveSidebarShell.d.ts +2 -2
  75. package/dist/components/general-purpose/ResponsiveSidebarShell.js +162 -87
  76. package/dist/components/general-purpose/Terminal.js +1 -1
  77. package/dist/components/general-purpose/ThemeModeControl.js +1 -1
  78. package/dist/components/general-purpose/WebPreview.js +1 -1
  79. package/dist/components/nanites/AgentToolDetail.d.ts +1 -3
  80. package/dist/components/nanites/AgentToolDetail.js +31 -40
  81. package/dist/merge-refs-DAh6reu8.js +26 -0
  82. package/dist/styles/activity.css +74 -0
  83. package/dist/styles/agent-chat.css +7 -0
  84. package/dist/styles/agent-tool-detail.css +2 -17
  85. package/dist/styles/app-top-bar.css +6 -7
  86. package/dist/styles/base.css +1 -1
  87. package/dist/styles/employee-chrome.css +0 -7
  88. package/dist/styles/message.css +1 -1
  89. package/dist/styles/responsive-sidebar-shell.css +10 -25
  90. package/dist/styles/scroll-area.css +16 -0
  91. package/dist/styles/scrollbars.css +55 -41
  92. package/dist/styles/search-field.css +0 -1
  93. package/dist/styles/subagent-run.css +36 -196
  94. package/dist/styles/think-chat-tool-panels.css +38 -5
  95. package/dist/styles/think-execution-workbench.css +4 -0
  96. package/dist/styles/think-full-app.css +1 -6
  97. package/dist/styles/workspace-concepts.css +6 -39
  98. package/dist/styles/workspace-explorer.css +4 -11
  99. package/package.json +2 -2
  100. package/dist/components/agents-sdk/SubagentRunDetails.d.ts +0 -40
  101. package/dist/components/agents-sdk/SubagentRunDetails.js +0 -98
  102. package/dist/merge-refs-DF_7w2x_.js +0 -18
  103. package/dist/{ManagerOffice-C8AQcaXs.js → ManagerOffice-DHcLRhFu.js} +2 -2
@@ -1,10 +1,65 @@
1
1
  import { t as cx } from "../../class-names-BiMDVpUo.js";
2
2
  import { Collapsible } from "../foundations/Collapsible.js";
3
+ import { ScrollArea } from "../foundations/ScrollArea.js";
3
4
  import { useExpansionState } from "./ExpansionState.js";
4
5
  import { p as ChevronRightIcon } from "../../icons-DvlrWt54.js";
5
6
  import * as React from "react";
6
7
  import { jsx, jsxs } from "react/jsx-runtime";
7
8
  //#region src/components/ai-sdk/Activity.tsx
9
+ function observeActivityContent(list) {
10
+ if (!list || typeof ResizeObserver === "undefined") return;
11
+ const panel = list.closest(".activity__content, .activity__shell-viewport");
12
+ if (!panel) return;
13
+ let previousHeight;
14
+ let pendingHeight;
15
+ let pendingFrame;
16
+ const updatePanelSize = () => {
17
+ pendingFrame = void 0;
18
+ const height = pendingHeight;
19
+ pendingHeight = void 0;
20
+ if (height === void 0) return;
21
+ if (panel.closest("[hidden]")) {
22
+ previousHeight = void 0;
23
+ delete list.dataset.contentReady;
24
+ panel.style.removeProperty("--activity-content-panel-height");
25
+ panel.style.removeProperty("--activity-content-transition-duration");
26
+ return;
27
+ }
28
+ list.dataset.contentReady ??= "";
29
+ const hasNestedSizeTransition = list.getAnimations({ subtree: true }).some((animation) => {
30
+ if (!("transitionProperty" in animation)) return false;
31
+ const property = animation.transitionProperty;
32
+ return property === "block-size" || property === "height";
33
+ });
34
+ const panelIsOpen = (panel.hasAttribute("data-open") || panel.classList.contains("activity__shell-viewport")) && !panel.hasAttribute("data-starting-style") && !panel.hasAttribute("data-ending-style");
35
+ const hasPanelSizeTransition = panel.getAnimations().some((animation) => {
36
+ if (!("transitionProperty" in animation)) return false;
37
+ const property = animation.transitionProperty;
38
+ return (property === "block-size" || property === "height") && (animation.playState === "running" || animation.playState === "paused");
39
+ });
40
+ const heightValue = hasNestedSizeTransition && panelIsOpen && !hasPanelSizeTransition ? "auto" : previousHeight === "auto" ? getComputedStyle(list).blockSize : `${height}px`;
41
+ if (heightValue === "auto") panel.style.setProperty("--activity-content-transition-duration", "0ms");
42
+ else panel.style.removeProperty("--activity-content-transition-duration");
43
+ if (heightValue !== previousHeight) {
44
+ previousHeight = heightValue;
45
+ panel.style.setProperty("--activity-content-panel-height", heightValue);
46
+ }
47
+ };
48
+ const schedulePanelSize = (entries) => {
49
+ const height = entries.find((candidate) => candidate.target === list)?.borderBoxSize[0]?.blockSize;
50
+ if (height === void 0) return;
51
+ pendingHeight = height;
52
+ if (pendingFrame === void 0) pendingFrame = requestAnimationFrame(updatePanelSize);
53
+ };
54
+ const observer = new ResizeObserver(schedulePanelSize);
55
+ observer.observe(list, { box: "border-box" });
56
+ return () => {
57
+ observer.disconnect();
58
+ if (pendingFrame !== void 0) cancelAnimationFrame(pendingFrame);
59
+ panel.style.removeProperty("--activity-content-panel-height");
60
+ panel.style.removeProperty("--activity-content-transition-duration");
61
+ };
62
+ }
8
63
  function usePersistedActivityOpenProps({ defaultOpen = false, open: controlledOpen, onOpenChange, stateKey }) {
9
64
  const [persistedOpen, setPersistedOpen] = useExpansionState(stateKey, defaultOpen);
10
65
  const handleOpenChange = React.useCallback((nextOpen, eventDetails) => {
@@ -119,6 +174,7 @@ function ActivityContent({ className, children, ref, ...props }) {
119
174
  ...props,
120
175
  unstyled: true,
121
176
  children: /* @__PURE__ */ jsx("div", {
177
+ ref: observeActivityContent,
122
178
  className: "activity__list",
123
179
  children
124
180
  })
@@ -178,13 +234,12 @@ function ActivityItemGroup({ className, action, detail, icon, children, defaultO
178
234
  }
179
235
  /** Scrollable plain-text detail inside an ActivityItemGroup. */
180
236
  function ActivityText({ className, children, ref, ...props }) {
181
- return /* @__PURE__ */ jsx("div", {
237
+ return /* @__PURE__ */ jsxs(ScrollArea.Root, { children: [/* @__PURE__ */ jsx(ScrollArea.Viewport, {
182
238
  ref,
183
- tabIndex: 0,
184
239
  className: cx("activity__group-text", className),
185
240
  ...props,
186
- children
187
- });
241
+ children: /* @__PURE__ */ jsx(ScrollArea.Content, { children })
242
+ }), /* @__PURE__ */ jsx(ScrollArea.Scrollbar, { children: /* @__PURE__ */ jsx(ScrollArea.Thumb, {}) })] });
188
243
  }
189
244
  /**
190
245
  * A single activity row — "Searched code", "Edited a file", etc. Free-form
@@ -223,18 +278,41 @@ function ActivityOutput({ className, children, ref, ...props }) {
223
278
  children
224
279
  });
225
280
  }
226
- /** Quiet detail panel for tool output inside an ActivityItemGroup. */
281
+ /** Quiet tool detail with a bounded, fading scroll body and a persistent label/status. */
227
282
  function ActivityPanel({ className, label, text, status, error, children, ref, ...props }) {
283
+ const labelId = React.useId();
284
+ const content = children ?? (text ? /* @__PURE__ */ jsx(ActivityOutput, { children: text }) : null);
228
285
  return /* @__PURE__ */ jsxs("div", {
229
286
  ref,
230
287
  className: cx("activity__shell", className),
231
288
  ...props,
232
289
  children: [
233
290
  /* @__PURE__ */ jsx("span", {
291
+ id: labelId,
234
292
  className: "activity__shell-label",
235
293
  children: label
236
294
  }),
237
- children ?? (text ? /* @__PURE__ */ jsx(ActivityOutput, { children: text }) : null),
295
+ content != null ? /* @__PURE__ */ jsxs(ScrollArea.Root, {
296
+ className: "activity__shell-body",
297
+ children: [
298
+ /* @__PURE__ */ jsx(ScrollArea.Viewport, {
299
+ className: "activity__shell-viewport",
300
+ role: "group",
301
+ "aria-labelledby": labelId,
302
+ children: /* @__PURE__ */ jsx(ScrollArea.Content, {
303
+ ref: observeActivityContent,
304
+ className: "activity__shell-content",
305
+ children: content
306
+ })
307
+ }),
308
+ /* @__PURE__ */ jsx(ScrollArea.Scrollbar, { children: /* @__PURE__ */ jsx(ScrollArea.Thumb, {}) }),
309
+ /* @__PURE__ */ jsx(ScrollArea.Scrollbar, {
310
+ orientation: "horizontal",
311
+ children: /* @__PURE__ */ jsx(ScrollArea.Thumb, {})
312
+ }),
313
+ /* @__PURE__ */ jsx(ScrollArea.Corner, {})
314
+ ]
315
+ }) : null,
238
316
  status ? /* @__PURE__ */ jsx("span", {
239
317
  className: "activity__shell-status",
240
318
  "data-error": error || void 0,
@@ -61,7 +61,7 @@ function AgentChatMessageEditor({ message, originalText, onCancel, onSubmit, onS
61
61
  if (error) setError(void 0);
62
62
  },
63
63
  onKeyDown: (event) => {
64
- if (event.key !== "Escape" || isSubmitting) return;
64
+ if (event.key !== "Escape" || isSubmitting || event.nativeEvent.isComposing || event.nativeEvent.keyCode === 229) return;
65
65
  event.preventDefault();
66
66
  onCancel();
67
67
  }
@@ -120,6 +120,7 @@ function ApprovalDecision({ className, onDecision, onSkip, subject = "this actio
120
120
  className: cx("approval__options", className),
121
121
  "aria-busy": busy || void 0,
122
122
  onKeyDown: (event) => {
123
+ if (event.nativeEvent.isComposing || event.nativeEvent.keyCode === 229) return;
123
124
  if (event.key === "ArrowDown" || event.key === "ArrowUp") {
124
125
  event.preventDefault();
125
126
  (selected === "approve" ? reasonRef : approveRef).current?.focus();
@@ -183,7 +184,7 @@ function ApprovalDecision({ className, onDecision, onSkip, subject = "this actio
183
184
  setReason(event.currentTarget.value);
184
185
  },
185
186
  onKeyDown: (event) => {
186
- if (event.key === "Enter" && !event.nativeEvent.isComposing) {
187
+ if (event.key === "Enter" && !event.nativeEvent.isComposing && event.nativeEvent.keyCode !== 229) {
187
188
  event.preventDefault();
188
189
  respond(false);
189
190
  }
@@ -2,7 +2,7 @@ import { brandHexFromIconSrc, parseComposerHref, sampleImageAccent } from "../..
2
2
  import { findCatalogMcpServerCard, getMcpServerIconSrc } from "../../utils/mcp-server-catalog.js";
3
3
  import { t as cx } from "../../class-names-BiMDVpUo.js";
4
4
  import { c as BoxIcon } from "../../icons-DvlrWt54.js";
5
- import { n as mergeRefs } from "../../merge-refs-DF_7w2x_.js";
5
+ import { n as mergeRefs } from "../../merge-refs-DAh6reu8.js";
6
6
  import * as React from "react";
7
7
  import { jsx, jsxs } from "react/jsx-runtime";
8
8
  //#region src/components/ai-sdk/ComposerLink.tsx
@@ -95,8 +95,6 @@ function ConnectedAppCardFrame({ children, className, headerActions, icon, kind,
95
95
  onReject,
96
96
  onSend
97
97
  });
98
- const saveBlocked = saveState !== void 0;
99
- const saveErrorMessage = saveState?.status === "error" ? saveState.message : "";
100
98
  return /* @__PURE__ */ jsxs(Card, {
101
99
  render: /* @__PURE__ */ jsx("article", {}),
102
100
  ...props,
@@ -140,61 +138,81 @@ function ConnectedAppCardFrame({ children, className, headerActions, icon, kind,
140
138
  placeholder: "Shorter, and skip the recap",
141
139
  onChange: (event) => decision.setReason(event.currentTarget.value),
142
140
  onKeyDown: (event) => {
143
- if (event.key === "Enter" && !event.nativeEvent.isComposing) {
141
+ if (event.key === "Enter" && !event.nativeEvent.isComposing && event.nativeEvent.keyCode !== 229) {
144
142
  event.preventDefault();
145
143
  decision.reject?.();
146
144
  }
147
145
  }
148
146
  })] }) : null,
149
- saveErrorMessage ? /* @__PURE__ */ jsxs("div", {
150
- className: "connected-app-card__save-error",
151
- children: [/* @__PURE__ */ jsx(Field.Errors, { errors: [saveErrorMessage] }), saveState?.status === "error" && saveState.onRetry ? /* @__PURE__ */ jsx(Button, {
152
- type: "button",
153
- size: "sm",
154
- variant: "ghost",
155
- color: "neutral",
156
- onClick: saveState.onRetry,
157
- children: "Retry save"
158
- }) : null]
159
- }) : null,
147
+ /* @__PURE__ */ jsx(ConnectedAppCardSaveError, { saveState }),
160
148
  decision.errorMessage ? /* @__PURE__ */ jsx(Field.Errors, { errors: [decision.errorMessage] }) : null,
161
149
  /* @__PURE__ */ jsx("span", {
162
150
  className: "sigvelo-visually-hidden",
163
151
  role: "status",
164
152
  "aria-atomic": "true",
165
- children: saveErrorMessage || decision.errorMessage || (saveState?.status === "saving" ? "Saving" : decision.busy ? "Submitting" : "")
153
+ children: connectedAppCardAnnouncement(saveState, decision)
166
154
  })
167
155
  ] }),
168
- hasDecision ? /* @__PURE__ */ jsxs(CardFooter, {
169
- render: /* @__PURE__ */ jsx("footer", {}),
170
- className: "connected-app-card__footer",
171
- children: [
172
- decision.send ? /* @__PURE__ */ jsx(Button, {
173
- type: "button",
174
- size: "sm",
175
- disabled: decision.busy || saveBlocked,
176
- onClick: () => void decision.send?.(),
177
- children: sendLabel
178
- }) : null,
179
- decision.discard ? /* @__PURE__ */ jsx(Button, {
180
- type: "button",
181
- size: "sm",
182
- variant: "outline",
183
- color: "neutral",
184
- disabled: decision.busy,
185
- onClick: () => void decision.discard?.(),
186
- children: "Discard"
187
- }) : null,
188
- decision.reject ? /* @__PURE__ */ jsx(Button, {
189
- type: "button",
190
- size: "sm",
191
- variant: "ghost",
192
- color: "neutral",
193
- disabled: decision.busy,
194
- onClick: () => void decision.reject?.(),
195
- children: "Send feedback"
196
- }) : null
197
- ]
156
+ hasDecision ? /* @__PURE__ */ jsx(ConnectedAppCardDecisions, {
157
+ decision,
158
+ sendLabel,
159
+ saveBlocked: saveState !== void 0
160
+ }) : null
161
+ ]
162
+ });
163
+ }
164
+ /** A failed save stays visible, with its retry, until the store holds the draft. */
165
+ function ConnectedAppCardSaveError({ saveState }) {
166
+ if (saveState?.status !== "error" || !saveState.message) return null;
167
+ return /* @__PURE__ */ jsxs("div", {
168
+ className: "connected-app-card__save-error",
169
+ children: [/* @__PURE__ */ jsx(Field.Errors, { errors: [saveState.message] }), saveState.onRetry ? /* @__PURE__ */ jsx(Button, {
170
+ type: "button",
171
+ size: "sm",
172
+ variant: "ghost",
173
+ color: "neutral",
174
+ onClick: saveState.onRetry,
175
+ children: "Retry save"
176
+ }) : null]
177
+ });
178
+ }
179
+ /** One polite announcement: errors first, then the action in flight. */
180
+ function connectedAppCardAnnouncement(saveState, decision) {
181
+ if (saveState?.status === "error" && saveState.message) return saveState.message;
182
+ if (decision.errorMessage) return decision.errorMessage;
183
+ if (saveState?.status === "saving") return "Saving";
184
+ return decision.busy ? "Submitting" : "";
185
+ }
186
+ /** The pending draft's release decisions; an unsaved draft cannot be sent. */
187
+ function ConnectedAppCardDecisions({ decision, sendLabel, saveBlocked }) {
188
+ return /* @__PURE__ */ jsxs(CardFooter, {
189
+ render: /* @__PURE__ */ jsx("footer", {}),
190
+ className: "connected-app-card__footer",
191
+ children: [
192
+ decision.send ? /* @__PURE__ */ jsx(Button, {
193
+ type: "button",
194
+ size: "sm",
195
+ disabled: decision.busy || saveBlocked,
196
+ onClick: () => void decision.send?.(),
197
+ children: sendLabel
198
+ }) : null,
199
+ decision.discard ? /* @__PURE__ */ jsx(Button, {
200
+ type: "button",
201
+ size: "sm",
202
+ variant: "outline",
203
+ color: "neutral",
204
+ disabled: decision.busy,
205
+ onClick: () => void decision.discard?.(),
206
+ children: "Discard"
207
+ }) : null,
208
+ decision.reject ? /* @__PURE__ */ jsx(Button, {
209
+ type: "button",
210
+ size: "sm",
211
+ variant: "ghost",
212
+ color: "neutral",
213
+ disabled: decision.busy,
214
+ onClick: () => void decision.reject?.(),
215
+ children: "Send feedback"
198
216
  }) : null
199
217
  ]
200
218
  });
@@ -1,7 +1,7 @@
1
1
  import { t as cx } from "../../class-names-BiMDVpUo.js";
2
2
  import { n as ArrowDownIcon, v as DownloadIcon } from "../../icons-DvlrWt54.js";
3
3
  import { IconButton } from "../foundations/IconButton.js";
4
- import { t as assignRef } from "../../merge-refs-DF_7w2x_.js";
4
+ import { t as assignRef } from "../../merge-refs-DAh6reu8.js";
5
5
  import { MessageScroller, MessageScrollerButton, MessageScrollerContent, MessageScrollerItem, MessageScrollerProvider, MessageScrollerViewport } from "./MessageScroller.js";
6
6
  import * as React from "react";
7
7
  import { jsx } from "react/jsx-runtime";
@@ -1,15 +1,17 @@
1
1
  import * as React from "react";
2
2
  //#region src/components/ai-sdk/ExpansionState.d.ts
3
3
  /**
4
- * Disclosure open states keyed by stable transcript ids, held outside the
5
- * rows so a virtualized transcript can unmount a row and restore its
6
- * disclosures when it scrolls back into view.
4
+ * Disclosure and numeric inspection state keyed by stable transcript ids,
5
+ * held outside the rows so a virtualized transcript can unmount a row and
6
+ * restore its state when it scrolls back into view.
7
7
  */
8
8
  export interface ExpansionStore {
9
9
  get(key: string): boolean | undefined;
10
10
  set(key: string, open: boolean): void;
11
+ getNumber(key: string): number | undefined;
12
+ setNumber(key: string, value: number): void;
11
13
  }
12
- /** Plain Map-backed store. Create one per conversation/thread. */
14
+ /** Typed Map-backed disclosure and numeric state. Create one per conversation/thread. */
13
15
  export declare function createExpansionStore(): ExpansionStore;
14
16
  export interface ExpansionStateProviderProps {
15
17
  /**
@@ -27,8 +29,8 @@ export interface ExpansionStateProviderProps {
27
29
  children: React.ReactNode;
28
30
  }
29
31
  /**
30
- * Provides the expansion store that `Activity`, `ActivityItemGroup`, and
31
- * `ToolInvocation` write through when given a `stateKey`. (`Reasoning` is the
32
+ * Provides the store that `Activity`, `ActivityItemGroup`, `ToolInvocation`,
33
+ * and `useExpansionNumber` write through with stable keys. (`Reasoning` is the
32
34
  * deliberate exception — it keeps its own auto-open/auto-close streaming
33
35
  * state and resets on remount.) `AgentChat` renders one around its transcript
34
36
  * automatically; wrap it yourself (with an app-held `store`) to persist
@@ -43,4 +45,12 @@ export declare function ExpansionStateProvider({ store, children }: ExpansionSta
43
45
  * store. Without a provider or a `stateKey` this is plain local state.
44
46
  */
45
47
  export declare function useExpansionState(stateKey: string | undefined, defaultOpen: boolean): [boolean, (open: boolean) => void];
48
+ /**
49
+ * Numeric inspection state initialized from the surrounding store (falling
50
+ * back to `defaultValue`) and written through on every change. Only the
51
+ * mounted row reads a given key, so there is no subscription — remounting
52
+ * re-reads the store. Without a provider or a `stateKey` this is plain local
53
+ * state.
54
+ */
55
+ export declare function useExpansionNumber(stateKey: string | undefined, defaultValue: number): [number, (value: number) => void];
46
56
  //#endregion
@@ -1,18 +1,21 @@
1
1
  import * as React from "react";
2
2
  import { jsx } from "react/jsx-runtime";
3
3
  //#region src/components/ai-sdk/ExpansionState.tsx
4
- /** Plain Map-backed store. Create one per conversation/thread. */
4
+ /** Typed Map-backed disclosure and numeric state. Create one per conversation/thread. */
5
5
  function createExpansionStore() {
6
- const state = /* @__PURE__ */ new Map();
6
+ const disclosures = /* @__PURE__ */ new Map();
7
+ const numbers = /* @__PURE__ */ new Map();
7
8
  return {
8
- get: (key) => state.get(key),
9
- set: (key, open) => void state.set(key, open)
9
+ get: (key) => disclosures.get(key),
10
+ set: (key, open) => void disclosures.set(key, open),
11
+ getNumber: (key) => numbers.get(key),
12
+ setNumber: (key, value) => void numbers.set(key, value)
10
13
  };
11
14
  }
12
15
  const ExpansionStateContext = React.createContext(null);
13
16
  /**
14
- * Provides the expansion store that `Activity`, `ActivityItemGroup`, and
15
- * `ToolInvocation` write through when given a `stateKey`. (`Reasoning` is the
17
+ * Provides the store that `Activity`, `ActivityItemGroup`, `ToolInvocation`,
18
+ * and `useExpansionNumber` write through with stable keys. (`Reasoning` is the
16
19
  * deliberate exception — it keeps its own auto-open/auto-close streaming
17
20
  * state and resets on remount.) `AgentChat` renders one around its transcript
18
21
  * automatically; wrap it yourself (with an app-held `store`) to persist
@@ -41,5 +44,20 @@ function useExpansionState(stateKey, defaultOpen) {
41
44
  setLocalOpen(next);
42
45
  }, [store, stateKey])];
43
46
  }
47
+ /**
48
+ * Numeric inspection state initialized from the surrounding store (falling
49
+ * back to `defaultValue`) and written through on every change. Only the
50
+ * mounted row reads a given key, so there is no subscription — remounting
51
+ * re-reads the store. Without a provider or a `stateKey` this is plain local
52
+ * state.
53
+ */
54
+ function useExpansionNumber(stateKey, defaultValue) {
55
+ const store = React.useContext(ExpansionStateContext);
56
+ const [value, setLocalValue] = React.useState(() => (stateKey !== void 0 ? store?.getNumber(stateKey) : void 0) ?? defaultValue);
57
+ return [value, React.useCallback((next) => {
58
+ if (store && stateKey !== void 0) store.setNumber(stateKey, next);
59
+ setLocalValue(next);
60
+ }, [store, stateKey])];
61
+ }
44
62
  //#endregion
45
- export { ExpansionStateProvider, createExpansionStore, useExpansionState };
63
+ export { ExpansionStateProvider, createExpansionStore, useExpansionNumber, useExpansionState };
@@ -1,6 +1,6 @@
1
1
  import { t as cx } from "../../class-names-BiMDVpUo.js";
2
2
  import { z as PlayIcon } from "../../icons-DvlrWt54.js";
3
- import { n as mergeRefs } from "../../merge-refs-DF_7w2x_.js";
3
+ import { n as mergeRefs } from "../../merge-refs-DAh6reu8.js";
4
4
  import { Card } from "../foundations/Card.js";
5
5
  import * as React from "react";
6
6
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -6,6 +6,7 @@ import * as React from "react";
6
6
  import { jsx, jsxs } from "react/jsx-runtime";
7
7
  import { useVirtualizer } from "@tanstack/react-virtual";
8
8
  //#region src/components/ai-sdk/MessageScrollerVirtual.tsx
9
+ const SCROLL_END_THRESHOLD = 80;
9
10
  /**
10
11
  * Windowed chat transcript for unbounded threads (hours-long agent runs):
11
12
  * only the visible slice of rows exists in the DOM, end-anchored so streaming
@@ -39,6 +40,11 @@ function VirtualMessageScroller({ items, getItemKey, renderItem, estimateSize =
39
40
  const restoring = React.useRef(true);
40
41
  const contentRef = React.useRef(null);
41
42
  const warnedBadKey = React.useRef(false);
43
+ const [followingLatest, setFollowingLatest] = React.useState(initialAnchor.current?.followLatest ?? true);
44
+ const followingLatestRef = React.useRef(followingLatest);
45
+ const inspectionPaused = React.useRef(false);
46
+ const resumingLatest = React.useRef(false);
47
+ const lastScrollTop = React.useRef(void 0);
42
48
  const [atEnd, setAtEnd] = React.useState(true);
43
49
  const [scrollEdges, setScrollEdges] = React.useState();
44
50
  const { "aria-live": contentAriaLive = "off", "aria-relevant": contentAriaRelevant = messageScrollerContract.content.ariaRelevant, className: contentClassName, role: contentRole = messageScrollerContract.content.role, style: contentStyle, ...resolvedContentProps } = contentProps ?? {};
@@ -55,15 +61,38 @@ function VirtualMessageScroller({ items, getItemKey, renderItem, estimateSize =
55
61
  seen.add(key);
56
62
  }
57
63
  }, [items, getItemKey]);
58
- const recordAnchor = (instance) => {
64
+ const updateFollowingLatest = React.useCallback((next) => {
65
+ const anchor = scrollAnchor?.current;
66
+ if (anchor && anchor.followLatest !== next) scrollAnchor.current = {
67
+ ...anchor,
68
+ followLatest: next
69
+ };
70
+ if (followingLatestRef.current === next) return;
71
+ followingLatestRef.current = next;
72
+ setFollowingLatest(next);
73
+ }, [scrollAnchor]);
74
+ const recordAnchor = (instance, nativeScroll = false) => {
59
75
  const viewport = viewportRef.current;
60
- if (restoring.current || !scrollAnchor || !viewport) return;
76
+ if (!viewport) return;
61
77
  const scrollTop = viewport.scrollTop;
78
+ const previousScrollTop = lastScrollTop.current;
79
+ lastScrollTop.current = scrollTop;
80
+ if (restoring.current) return;
81
+ const distanceFromEnd = viewport.scrollHeight - viewport.clientHeight - scrollTop;
82
+ if (resumingLatest.current && distanceFromEnd <= 1) resumingLatest.current = false;
83
+ if (nativeScroll && !inspectionPaused.current) {
84
+ if (distanceFromEnd <= 1) updateFollowingLatest(true);
85
+ else if (!resumingLatest.current && previousScrollTop !== void 0 && scrollTop < previousScrollTop) {
86
+ if (followingLatestRef.current) instance.scrollToOffset(scrollTop, { behavior: "auto" });
87
+ updateFollowingLatest(false);
88
+ }
89
+ }
90
+ if (!scrollAnchor) return;
62
91
  const first = instance.getVirtualItems().find((item) => item.end > scrollTop);
63
92
  if (first) scrollAnchor.current = {
64
93
  key: getItemKey(items[first.index]),
65
94
  offset: scrollTop - first.start,
66
- followLatest: viewport.scrollHeight - viewport.clientHeight - scrollTop <= instance.options.scrollEndThreshold
95
+ followLatest: followingLatestRef.current
67
96
  };
68
97
  };
69
98
  const virtualizer = useVirtualizer({
@@ -73,8 +102,8 @@ function VirtualMessageScroller({ items, getItemKey, renderItem, estimateSize =
73
102
  estimateSize: () => estimateSize,
74
103
  getItemKey: (index) => getItemKey(items[index]),
75
104
  anchorTo: "end",
76
- followOnAppend: true,
77
- scrollEndThreshold: 80,
105
+ followOnAppend: followingLatest,
106
+ scrollEndThreshold: followingLatest ? SCROLL_END_THRESHOLD : -1,
78
107
  overscan,
79
108
  gap: 16,
80
109
  initialOffset: () => {
@@ -90,13 +119,28 @@ function VirtualMessageScroller({ items, getItemKey, renderItem, estimateSize =
90
119
  setScrollEdges(start && end ? "start end" : start ? "start" : end ? "end" : void 0);
91
120
  }
92
121
  });
122
+ const totalSize = virtualizer.getTotalSize();
123
+ const viewportHeight = virtualizer.scrollRect?.height;
124
+ React.useLayoutEffect(() => {
125
+ const viewport = viewportRef.current;
126
+ if (restoring.current || !followingLatestRef.current || resumingLatest.current || !viewport) return;
127
+ if (viewport.scrollHeight - viewport.clientHeight - viewport.scrollTop > 1) virtualizer.scrollToEnd({ behavior: "auto" });
128
+ }, [
129
+ totalSize,
130
+ virtualizer,
131
+ viewportHeight
132
+ ]);
93
133
  React.useLayoutEffect(() => {
94
134
  if (!restoring.current) return;
95
135
  const anchor = initialAnchor.current;
136
+ if (anchor && !anchor.followLatest && items.length === 0) return;
96
137
  const index = anchor && !anchor.followLatest ? items.findIndex((item) => getItemKey(item) === anchor.key) : -1;
97
138
  if (index >= 0 && anchor) {
98
139
  const row = contentRef.current?.querySelector(`:scope > [data-index="${index}"]`);
99
- if (!row) return;
140
+ if (!row) {
141
+ virtualizer.scrollToIndex(index, { align: "start" });
142
+ return;
143
+ }
100
144
  virtualizer.measureElement(row);
101
145
  const height = Number.parseFloat(contentRef.current?.style.height ?? "0");
102
146
  if (Math.abs(height - virtualizer.getTotalSize()) > .5) return;
@@ -106,6 +150,19 @@ function VirtualMessageScroller({ items, getItemKey, renderItem, estimateSize =
106
150
  } else virtualizer.scrollToEnd();
107
151
  restoring.current = false;
108
152
  });
153
+ const pauseForInspection = (target) => {
154
+ if (!(target instanceof Element) || !target.closest("[aria-expanded]")) return;
155
+ const viewport = viewportRef.current;
156
+ if (resumingLatest.current && viewport) virtualizer.scrollToOffset(viewport.scrollTop, { behavior: "auto" });
157
+ inspectionPaused.current = true;
158
+ resumingLatest.current = false;
159
+ updateFollowingLatest(false);
160
+ recordAnchor(virtualizer);
161
+ };
162
+ const noteUserScroll = () => {
163
+ inspectionPaused.current = false;
164
+ resumingLatest.current = false;
165
+ };
109
166
  return /* @__PURE__ */ jsxs("div", {
110
167
  "data-slot": messageScrollerContract.root.slot,
111
168
  className: cx(messageScrollerContract.root.className, className),
@@ -113,7 +170,27 @@ function VirtualMessageScroller({ items, getItemKey, renderItem, estimateSize =
113
170
  "data-recipe": "fill-host",
114
171
  children: [/* @__PURE__ */ jsx("div", {
115
172
  ref: viewportRef,
116
- onScroll: () => recordAnchor(virtualizer),
173
+ onScroll: () => recordAnchor(virtualizer, true),
174
+ onClickCapture: (event) => pauseForInspection(event.target),
175
+ onWheelCapture: noteUserScroll,
176
+ onTouchMoveCapture: noteUserScroll,
177
+ onPointerDownCapture: (event) => {
178
+ if (event.target === event.currentTarget) noteUserScroll();
179
+ },
180
+ onKeyDownCapture: (event) => {
181
+ if (!(event.target instanceof HTMLElement)) return;
182
+ if (event.target.closest("input, textarea, select, [contenteditable]:not([contenteditable=\"false\"]), [role=\"textbox\"], [role=\"combobox\"], [role=\"slider\"], [role=\"spinbutton\"]")) return;
183
+ if (event.key === " " && event.target.closest("button, [role=\"button\"]")) return;
184
+ if ([
185
+ "ArrowDown",
186
+ "ArrowUp",
187
+ "End",
188
+ "Home",
189
+ "PageDown",
190
+ "PageUp",
191
+ " "
192
+ ].includes(event.key)) noteUserScroll();
193
+ },
117
194
  "aria-label": messageScrollerContract.viewport.ariaLabel,
118
195
  "data-slot": messageScrollerContract.viewport.slot,
119
196
  "data-recipe": "scroll-fade-y",
@@ -121,6 +198,7 @@ function VirtualMessageScroller({ items, getItemKey, renderItem, estimateSize =
121
198
  className: messageScrollerContract.viewport.className,
122
199
  role: messageScrollerContract.viewport.role,
123
200
  tabIndex: messageScrollerContract.viewport.tabIndex,
201
+ style: { overflowAnchor: "none" },
124
202
  children: items.length === 0 ? emptyState : /* @__PURE__ */ jsx("div", {
125
203
  ...resolvedContentProps,
126
204
  ref: contentRef,
@@ -130,7 +208,7 @@ function VirtualMessageScroller({ items, getItemKey, renderItem, estimateSize =
130
208
  role: contentRole,
131
209
  style: {
132
210
  ...contentStyle,
133
- height: virtualizer.getTotalSize()
211
+ height: totalSize
134
212
  },
135
213
  children: virtualizer.getVirtualItems().map((virtualItem) => /* @__PURE__ */ jsx("div", {
136
214
  ref: virtualizer.measureElement,
@@ -151,9 +229,18 @@ function VirtualMessageScroller({ items, getItemKey, renderItem, estimateSize =
151
229
  className: cx(messageScrollerContract.button.className, scrollButtonProps?.className),
152
230
  "data-slot": messageScrollerContract.button.slot,
153
231
  "data-direction": "end",
154
- "data-active": !atEnd,
155
- tabIndex: atEnd ? -1 : void 0,
156
- onClick: () => virtualizer.scrollToEnd({ behavior: "smooth" }),
232
+ "data-active": !atEnd || !followingLatest,
233
+ tabIndex: atEnd && followingLatest ? -1 : void 0,
234
+ onClick: () => {
235
+ restoring.current = false;
236
+ inspectionPaused.current = false;
237
+ const viewport = viewportRef.current;
238
+ const distanceFromEnd = viewport ? viewport.scrollHeight - viewport.clientHeight - viewport.scrollTop : 0;
239
+ const behavior = (viewport?.ownerDocument.defaultView?.matchMedia("(prefers-reduced-motion: reduce)").matches ?? false) || distanceFromEnd <= 1 ? "auto" : "smooth";
240
+ resumingLatest.current = behavior === "smooth";
241
+ updateFollowingLatest(true);
242
+ virtualizer.scrollToEnd({ behavior });
243
+ },
157
244
  children: /* @__PURE__ */ jsx(ArrowDownIcon, {})
158
245
  })]
159
246
  });
@@ -11,7 +11,7 @@ import { Tooltip } from "../foundations/Tooltip.js";
11
11
  import { IconButton } from "../foundations/IconButton.js";
12
12
  import { t as AttachmentPreview } from "../../attachment-preview-1CXJvrmb.js";
13
13
  import { a as formatErrorMessage, i as formatClock, n as clamp } from "../../format-CWaZEp5o.js";
14
- import { n as mergeRefs } from "../../merge-refs-DF_7w2x_.js";
14
+ import { n as mergeRefs } from "../../merge-refs-DAh6reu8.js";
15
15
  import { ComposerLink } from "./ComposerLink.js";
16
16
  import { PromptInputComposerEditor } from "./PromptInputComposerEditor.js";
17
17
  import * as React from "react";
@@ -386,7 +386,7 @@ function PromptInputTextarea({ className, placeholder = "How can I help?", rows
386
386
  onKeyDown: (event) => {
387
387
  onKeyDown?.(event);
388
388
  if (event.defaultPrevented) return;
389
- if (event.key === "Enter" && !event.shiftKey && !isComposingRef.current && !event.nativeEvent.isComposing) {
389
+ if (event.key === "Enter" && !event.shiftKey && !isComposingRef.current && !event.nativeEvent.isComposing && event.nativeEvent.keyCode !== 229) {
390
390
  event.preventDefault();
391
391
  event.currentTarget.form?.requestSubmit();
392
392
  }
@@ -1026,7 +1026,11 @@ function PromptInputCommandComposer({ commands, mentionCommands, onCommandSelect
1026
1026
  },
1027
1027
  onKeyDown: (event) => {
1028
1028
  onKeyDown?.(event);
1029
- if (event.defaultPrevented || event.key !== "Enter" || !open) return;
1029
+ if (event.defaultPrevented || event.key === "Home" || event.key === "End" || event.nativeEvent.isComposing || event.nativeEvent.keyCode === 229) {
1030
+ event.preventBaseUIHandler();
1031
+ return;
1032
+ }
1033
+ if (event.key !== "Enter" || event.shiftKey || !open) return;
1030
1034
  const highlightedCommand = highlightedCommandRef.current;
1031
1035
  if (highlightedCommand && !highlightedCommand.disabled && filtered.includes(highlightedCommand)) return;
1032
1036
  const command = filtered.find((candidate) => !candidate.disabled);