@mcp-b/react-components 0.14.1 → 0.16.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 (241) hide show
  1. package/dist/AgentActivity-BNUNrP9O.d.ts +36 -0
  2. package/dist/{AgentChat-Cgb1xuT7.d.ts → AgentChat-CrlpbvQJ.d.ts} +62 -8
  3. package/dist/{CodeBlock-DUh9WOGo.d.ts → CodeBlock-BRajW4QU.d.ts} +1 -1
  4. package/dist/{CodeBlock-BUFXG8HW.js → CodeBlock-BmB4Xaqq.js} +15 -4
  5. package/dist/{FileTree-mpEIcfzA.js → FileTree-CkVbIMWV.js} +82 -89
  6. package/dist/Message-BkMdE3bS.js +375 -0
  7. package/dist/{ModelSelector-DVgVBdvw.js → ModelSelector-SlJNgwKY.js} +17 -8
  8. package/dist/{PromptInput-ClNqBiIw.d.ts → PromptInput-BWTuXMOD.d.ts} +123 -5
  9. package/dist/ResponsiveSidebarShell-Dd9DCcBT.d.ts +67 -0
  10. package/dist/{Select-Dl_vF_Bt.d.ts → Select-BeEsefzh.d.ts} +12 -2
  11. package/dist/{ThinkChat-7DQ2CogF.js → ThinkChat-CzC-zNGA.js} +27 -37
  12. package/dist/{ThinkChatActivity-m9orbdeI.d.ts → ThinkChatActivity-BFQnb2ct.d.ts} +3 -10
  13. package/dist/ThinkChatActivitySummary-BPmu9a-c.d.ts +39 -0
  14. package/dist/{ThinkChatToolParts-Cv4o7j6F.d.ts → ThinkChatToolParts-CSzVwMXf.d.ts} +62 -3
  15. package/dist/ThinkExecutionRun-ChhWhOoU.d.ts +30 -0
  16. package/dist/Toggle-CAAlNl-M.d.ts +69 -0
  17. package/dist/ToggleGroup-8hPv-b69.d.ts +73 -0
  18. package/dist/Workspace-D39LxGvP.d.ts +62 -0
  19. package/dist/WorkspaceFile-DOZkPwzu.d.ts +106 -0
  20. package/dist/WorkspaceFileView-rSN_yT0L.js +744 -0
  21. package/dist/WorkspaceLink-DIPbXrUM.js +337 -0
  22. package/dist/WorkspaceLink-DK1DWMHe.d.ts +89 -0
  23. package/dist/components/Activity.d.ts +27 -1
  24. package/dist/components/Activity.js +33 -15
  25. package/dist/components/AgentActivity.d.ts +2 -0
  26. package/dist/components/AgentActivity.js +45 -0
  27. package/dist/components/AgentActivityPreview.d.ts +46 -0
  28. package/dist/components/AgentActivityPreview.js +94 -0
  29. package/dist/components/AgentAttention.d.ts +73 -0
  30. package/dist/components/AgentAttention.js +85 -0
  31. package/dist/components/AgentChat.d.ts +2 -2
  32. package/dist/components/AgentChat.js +231 -205
  33. package/dist/components/AgentChatMessageEditor.d.ts +29 -0
  34. package/dist/components/AgentChatMessageEditor.js +92 -0
  35. package/dist/components/AgentChatTurnError.d.ts +17 -0
  36. package/dist/components/AgentChatTurnError.js +40 -0
  37. package/dist/components/AgentConnection.d.ts +12 -17
  38. package/dist/components/AgentConnection.js +99 -91
  39. package/dist/components/AppFrame.d.ts +24 -0
  40. package/dist/components/AppFrame.js +25 -0
  41. package/dist/components/AppTopBar.d.ts +71 -0
  42. package/dist/components/AppTopBar.js +82 -0
  43. package/dist/components/Artifact.js +1 -1
  44. package/dist/components/BrowserLiveView.js +1 -1
  45. package/dist/components/BrowserReplay.js +1 -1
  46. package/dist/components/BrowserRunPanel.js +1 -1
  47. package/dist/components/Card.d.ts +3 -0
  48. package/dist/components/Card.js +2 -1
  49. package/dist/components/ChainOfThought.d.ts +1 -1
  50. package/dist/components/ChainOfThought.js +1 -1
  51. package/dist/components/ChatGptSignInScreen.js +2 -2
  52. package/dist/components/Checkbox.js +5 -13
  53. package/dist/components/CheckboxGroup.d.ts +58 -2
  54. package/dist/components/CheckboxGroup.js +59 -1
  55. package/dist/components/CodeBlock.d.ts +1 -1
  56. package/dist/components/CodeBlock.js +1 -1
  57. package/dist/components/CodexModelSelector.js +1 -1
  58. package/dist/components/Commit.js +2 -2
  59. package/dist/components/ContextMenu.js +1 -1
  60. package/dist/components/Conversation.js +1 -1
  61. package/dist/components/DescriptionList.d.ts +12 -0
  62. package/dist/components/DescriptionList.js +11 -0
  63. package/dist/components/DescriptionListParts.d.ts +37 -0
  64. package/dist/components/DescriptionListParts.js +35 -0
  65. package/dist/components/EnvironmentVariables.js +2 -2
  66. package/dist/components/Fieldset.d.ts +13 -1
  67. package/dist/components/Fieldset.js +11 -2
  68. package/dist/components/FileTree.js +1 -1
  69. package/dist/components/IconButton.d.ts +33 -0
  70. package/dist/components/IconButton.js +27 -0
  71. package/dist/components/McpConnectionRequest.d.ts +44 -0
  72. package/dist/components/McpConnectionRequest.js +122 -0
  73. package/dist/components/McpServerPicker.d.ts +48 -23
  74. package/dist/components/McpServerPicker.js +238 -189
  75. package/dist/components/Menubar.js +1 -1
  76. package/dist/components/Message.d.ts +1 -0
  77. package/dist/components/Message.js +1 -285
  78. package/dist/components/MessageScroller.js +1 -1
  79. package/dist/components/ModelSelector.d.ts +15 -3
  80. package/dist/components/ModelSelector.js +1 -1
  81. package/dist/components/NaniteScene.d.ts +10 -1
  82. package/dist/components/NaniteScene.js +36 -1
  83. package/dist/components/Pricing.d.ts +37 -0
  84. package/dist/components/Pricing.js +17 -0
  85. package/dist/components/PricingBillingToggle.d.ts +23 -0
  86. package/dist/components/PricingBillingToggle.js +86 -0
  87. package/dist/components/PricingConfirmationDialog.d.ts +25 -0
  88. package/dist/components/PricingConfirmationDialog.js +57 -0
  89. package/dist/components/PricingFAQ.d.ts +18 -0
  90. package/dist/components/PricingFAQ.js +27 -0
  91. package/dist/components/PricingPage.d.ts +2 -38
  92. package/dist/components/PricingPage.js +39 -359
  93. package/dist/components/PricingPlanCard.d.ts +22 -0
  94. package/dist/components/PricingPlanCard.js +109 -0
  95. package/dist/components/PricingUsageCalculator.d.ts +22 -0
  96. package/dist/components/PricingUsageCalculator.js +96 -0
  97. package/dist/components/PromptInput.d.ts +2 -2
  98. package/dist/components/PromptInput.js +210 -15
  99. package/dist/components/Queue.js +1 -1
  100. package/dist/components/Reasoning.d.ts +2 -1
  101. package/dist/components/Reasoning.js +14 -29
  102. package/dist/components/ResizableSidePanel.d.ts +57 -0
  103. package/dist/components/ResizableSidePanel.js +151 -0
  104. package/dist/components/ResponsiveSidebarShell.d.ts +2 -0
  105. package/dist/components/ResponsiveSidebarShell.js +129 -0
  106. package/dist/components/Select.d.ts +2 -2
  107. package/dist/components/Select.js +11 -2
  108. package/dist/components/Slider.d.ts +13 -1
  109. package/dist/components/Slider.js +11 -0
  110. package/dist/components/Sources.js +1 -1
  111. package/dist/components/Stepper.d.ts +4 -0
  112. package/dist/components/Stepper.js +5 -3
  113. package/dist/components/SubagentRun.d.ts +86 -0
  114. package/dist/components/SubagentRun.js +108 -0
  115. package/dist/components/SubagentRunDetails.d.ts +44 -0
  116. package/dist/components/SubagentRunDetails.js +48 -0
  117. package/dist/components/SubagentRunIndicator.d.ts +22 -0
  118. package/dist/components/SubagentRunIndicator.js +33 -0
  119. package/dist/components/SubagentRunList.d.ts +25 -0
  120. package/dist/components/SubagentRunList.js +26 -0
  121. package/dist/components/SubagentRunSelector.d.ts +47 -0
  122. package/dist/components/SubagentRunSelector.js +55 -0
  123. package/dist/components/Task.js +1 -1
  124. package/dist/components/Terminal.js +2 -2
  125. package/dist/components/TestResults.js +1 -1
  126. package/dist/components/Textarea.d.ts +21 -0
  127. package/dist/components/Textarea.js +19 -0
  128. package/dist/components/ThemeModeControl.d.ts +24 -0
  129. package/dist/components/ThemeModeControl.js +52 -0
  130. package/dist/components/ThemeProvider.d.ts +38 -0
  131. package/dist/components/ThemeProvider.js +80 -0
  132. package/dist/components/ThinkChat.d.ts +34 -7
  133. package/dist/components/ThinkChat.js +7 -4
  134. package/dist/components/ThinkChatActivity.d.ts +3 -2
  135. package/dist/components/ThinkChatActivity.js +18 -297
  136. package/dist/components/ThinkChatActivitySummary.d.ts +2 -0
  137. package/dist/components/ThinkChatActivitySummary.js +421 -0
  138. package/dist/components/ThinkChatToolPanels.d.ts +15 -5
  139. package/dist/components/ThinkChatToolPanels.js +116 -9
  140. package/dist/components/ThinkChatToolParts.d.ts +2 -2
  141. package/dist/components/ThinkChatToolParts.js +51 -9
  142. package/dist/components/ThinkExecutionDetail.d.ts +20 -0
  143. package/dist/components/ThinkExecutionDetail.js +80 -0
  144. package/dist/components/ThinkExecutionRun.d.ts +2 -0
  145. package/dist/components/ThinkExecutionRun.js +72 -0
  146. package/dist/components/ThinkExecutionStatus.d.ts +22 -0
  147. package/dist/components/ThinkExecutionStatus.js +36 -0
  148. package/dist/components/ThinkExecutionWorkbench.d.ts +7 -0
  149. package/dist/components/ThinkExecutionWorkbench.js +69 -225
  150. package/dist/components/ThinkFullApp.d.ts +58 -14
  151. package/dist/components/ThinkFullApp.js +129 -160
  152. package/dist/components/ThinkFullAppViewSwitch.d.ts +31 -0
  153. package/dist/components/ThinkFullAppViewSwitch.js +34 -0
  154. package/dist/components/ThinkRoutine.d.ts +36 -0
  155. package/dist/components/ThinkRoutine.js +15 -0
  156. package/dist/components/ThinkRoutineBrowser.d.ts +25 -0
  157. package/dist/components/ThinkRoutineBrowser.js +156 -0
  158. package/dist/components/ThinkRoutineDetail.d.ts +24 -0
  159. package/dist/components/ThinkRoutineDetail.js +102 -0
  160. package/dist/components/ThinkRoutineForm.d.ts +32 -0
  161. package/dist/components/ThinkRoutineForm.js +151 -0
  162. package/dist/components/ThinkRoutineLibrary.d.ts +74 -0
  163. package/dist/components/ThinkRoutineLibrary.js +178 -0
  164. package/dist/components/ThinkRoutineRuns.d.ts +24 -0
  165. package/dist/components/ThinkRoutineRuns.js +68 -0
  166. package/dist/components/ThinkThreadPicker.d.ts +18 -1
  167. package/dist/components/ThinkThreadPicker.js +51 -5
  168. package/dist/components/ThinkThreadShell.d.ts +12 -9
  169. package/dist/components/ThinkThreadShell.js +17 -137
  170. package/dist/components/Toggle.d.ts +1 -68
  171. package/dist/components/ToggleGroup.d.ts +1 -72
  172. package/dist/components/Tooltip.d.ts +3 -1
  173. package/dist/components/Tooltip.js +4 -2
  174. package/dist/components/WebPreview.js +1 -1
  175. package/dist/components/Workspace.d.ts +2 -0
  176. package/dist/components/Workspace.js +424 -0
  177. package/dist/components/WorkspaceBrowser.d.ts +32 -0
  178. package/dist/components/WorkspaceBrowser.js +103 -0
  179. package/dist/components/WorkspaceExplorer.d.ts +12 -79
  180. package/dist/components/WorkspaceExplorer.js +116 -330
  181. package/dist/components/WorkspaceFile.d.ts +2 -0
  182. package/dist/components/WorkspaceFile.js +195 -0
  183. package/dist/components/WorkspaceFileView.d.ts +26 -0
  184. package/dist/components/WorkspaceFileView.js +2 -0
  185. package/dist/components/WorkspaceHeader.d.ts +35 -0
  186. package/dist/components/WorkspaceHeader.js +51 -0
  187. package/dist/components/WorkspaceLink.d.ts +2 -0
  188. package/dist/components/WorkspaceLink.js +2 -0
  189. package/dist/components/icons.d.ts +2 -2
  190. package/dist/components/icons.js +2 -2
  191. package/dist/{copy-button-DUMLYdsk.js → copy-button-Dejn5heL.js} +1 -1
  192. package/dist/icons-CpfUer49.js +85 -0
  193. package/dist/{icons-CUCz_Sft.d.ts → icons-GQd1xF4e.d.ts} +51 -1
  194. package/dist/styles/activity-header.css +75 -0
  195. package/dist/styles/activity.css +49 -63
  196. package/dist/styles/agent-activity-preview-overlay.css +80 -0
  197. package/dist/styles/agent-activity-preview.css +235 -0
  198. package/dist/styles/agent-attention.css +122 -0
  199. package/dist/styles/agent-chat.css +141 -4
  200. package/dist/styles/app-frame.css +15 -0
  201. package/dist/styles/app-top-bar.css +100 -0
  202. package/dist/styles/avatar.css +0 -1
  203. package/dist/styles/browser-control-overlay.css +184 -0
  204. package/dist/styles/card.css +21 -0
  205. package/dist/styles/checkbox-group.css +69 -0
  206. package/dist/styles/description-list.css +50 -0
  207. package/dist/styles/fieldset.css +11 -0
  208. package/dist/styles/index.css +15 -2
  209. package/dist/styles/mcp-connection-request.css +60 -0
  210. package/dist/styles/mcp-server-picker.css +95 -68
  211. package/dist/styles/message.css +4 -43
  212. package/dist/styles/nanite-scene.css +16 -0
  213. package/dist/styles/pricing-page.css +21 -27
  214. package/dist/styles/prompt-input.css +225 -32
  215. package/dist/styles/reasoning.css +1 -55
  216. package/dist/styles/recipes.css +23 -15
  217. package/dist/styles/resizable-side-panel.css +66 -0
  218. package/dist/styles/responsive-sidebar-shell.css +169 -0
  219. package/dist/styles/select.css +10 -0
  220. package/dist/styles/stepper.css +13 -0
  221. package/dist/styles/streamdown.css +0 -4
  222. package/dist/styles/subagent-run.css +205 -0
  223. package/dist/styles/textarea.css +20 -0
  224. package/dist/styles/theme-mode-control.css +72 -0
  225. package/dist/styles/think-execution-status.css +49 -0
  226. package/dist/styles/think-execution-workbench.css +8 -72
  227. package/dist/styles/think-full-app.css +106 -131
  228. package/dist/styles/think-routine-library.css +491 -0
  229. package/dist/styles/think-thread-picker.css +47 -3
  230. package/dist/styles/toggle-group.css +7 -0
  231. package/dist/styles/workspace-explorer.css +511 -64
  232. package/dist/utils/codex-model-catalog.d.ts +4 -4
  233. package/dist/utils/mcp-server-catalog.d.ts +82 -78
  234. package/dist/utils/mcp-server-catalog.js +64 -41
  235. package/dist/utils/structured-code.d.ts +1 -1
  236. package/dist/utils/theme.d.ts +22 -0
  237. package/dist/utils/theme.js +55 -0
  238. package/package.json +34 -28
  239. package/dist/icons-Ba9THQKz.js +0 -64
  240. package/dist/styles/think-resize-handle.css +0 -33
  241. package/dist/styles/think-thread-shell.css +0 -219
@@ -1,22 +1,24 @@
1
1
  import { t as cx } from "../class-names-9UtZwb0J.js";
2
- import { A as RefreshIcon, D as PencilIcon, k as PlusIcon } from "../icons-Ba9THQKz.js";
2
+ import { F as PlusIcon, H as SteerIcon, I as QueueIcon, K as TrashIcon, L as RefreshIcon, N as PencilIcon } from "../icons-CpfUer49.js";
3
3
  import { Activity, ActivityContent, ActivityPanel, ActivityTrigger } from "./Activity.js";
4
4
  import { Context, ContextContent, ContextContentBody, ContextContentHeader, ContextTrigger, getContextUsage, getContextUsedTokens } from "./Context.js";
5
- import { Button } from "./Button.js";
6
5
  import { MessageScroller, MessageScrollerButton, MessageScrollerContent, MessageScrollerItem, MessageScrollerProvider, MessageScrollerViewport } from "./MessageScroller.js";
7
6
  import { ConversationEmptyState } from "./Conversation.js";
8
- import { Message, MessageAction, MessageActions, MessageAttachment, MessageContent, MessageResponse } from "./Message.js";
7
+ import { d as MessageContent, f as MessageResponse, i as MessageAttachment, n as MessageAction, r as MessageActions, t as Message } from "../Message-BkMdE3bS.js";
8
+ import { AgentChatMessageEditor } from "./AgentChatMessageEditor.js";
9
9
  import { Marker, MarkerContent } from "./Marker.js";
10
- import { PromptInput, PromptInputActionAddAttachments, PromptInputActionMenu, PromptInputActionMenuContent, PromptInputActionMenuTrigger, PromptInputApproval, PromptInputAttachments, PromptInputBody, PromptInputButton, PromptInputDictation, PromptInputFooter, PromptInputHeader, PromptInputPermissionSelector, PromptInputSubmit, PromptInputTextarea, PromptInputTools, getApprovalRequestId, getApprovalStateKey, getPendingToolApprovals, usePromptInputAttachments } from "./PromptInput.js";
10
+ import { Menu } from "./Menu.js";
11
+ import { PromptInput, PromptInputActionAddAttachments, PromptInputActionMenu, PromptInputActionMenuContent, PromptInputActionMenuTrigger, PromptInputApproval, PromptInputAttachments, PromptInputBody, PromptInputButton, PromptInputCommandComposer, PromptInputContextSelector, PromptInputDictation, PromptInputFooter, PromptInputHeader, PromptInputPermissionSelector, PromptInputReferences, PromptInputSubmit, PromptInputTextarea, PromptInputTools, getApprovalRequestId, getApprovalStateKey, getPendingToolApprovals, usePromptInputAttachments } from "./PromptInput.js";
11
12
  import { Reasoning, ReasoningContent, ReasoningTrigger } from "./Reasoning.js";
12
13
  import { Source, Sources, SourcesContent, SourcesTrigger } from "./Sources.js";
13
- import { t as CopyButton } from "../copy-button-DUMLYdsk.js";
14
+ import { getToolDisplayName, isToolPartFailed, isToolPartWorking } from "./ThinkChatToolParts.js";
15
+ import { t as CopyButton } from "../copy-button-Dejn5heL.js";
14
16
  import { t as summarizeToolInput } from "../summarize-tool-input-BUJsENSn.js";
15
17
  import * as React from "react";
16
18
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
17
19
  import { isCompactionMessage } from "agents/experimental/memory/utils";
18
20
  import { getToolInput, getToolOutput, getToolPartState } from "@cloudflare/think/react";
19
- import { getToolName, isFileUIPart, isReasoningUIPart, isTextUIPart, isToolUIPart } from "ai";
21
+ import { isFileUIPart, isReasoningUIPart, isTextUIPart, isToolUIPart } from "ai";
20
22
  //#region src/components/AgentChat.tsx
21
23
  const EMPTY_PENDING_APPROVALS = [];
22
24
  const EMPTY_SKIPPED_APPROVAL_IDS = [];
@@ -24,12 +26,9 @@ function createApprovalSessionState(thinkStub) {
24
26
  return {
25
27
  thinkStub,
26
28
  skippedApprovalIds: EMPTY_SKIPPED_APPROVAL_IDS,
27
- permissionMode: "ask"
29
+ permissionMode: "bypass"
28
30
  };
29
31
  }
30
- function isCurrentApprovalSession(state, thinkStub) {
31
- return state.thinkStub === thinkStub;
32
- }
33
32
  function AgentChatAttachButton() {
34
33
  const attachments = usePromptInputAttachments();
35
34
  return /* @__PURE__ */ jsx(PromptInputButton, {
@@ -46,9 +45,22 @@ function AgentChatAddMenu({ children }) {
46
45
  sideOffset: 12,
47
46
  collisionPadding: 8,
48
47
  className: "agent-chat__add-menu",
49
- children: [/* @__PURE__ */ jsx(PromptInputActionAddAttachments, {}), children]
48
+ children: [/* @__PURE__ */ jsxs(Menu.Group, { children: [/* @__PURE__ */ jsx(Menu.GroupLabel, {
49
+ className: "agent-chat__add-menu-group-label",
50
+ children: "Add"
51
+ }), /* @__PURE__ */ jsx(PromptInputActionAddAttachments, {})] }), children]
50
52
  })] });
51
53
  }
54
+ function AgentChatSubmitAction({ status, onStop, allowSubmitWhileBusy, disabled, hasDraft }) {
55
+ const attachments = usePromptInputAttachments();
56
+ return /* @__PURE__ */ jsx(PromptInputSubmit, {
57
+ status,
58
+ onStop,
59
+ allowSubmitWhileBusy,
60
+ hasContent: hasDraft || attachments.files.length > 0,
61
+ disabled
62
+ });
63
+ }
52
64
  /**
53
65
  * Per-message row-size compaction marker from `AIChatAgent` persistence.
54
66
  *
@@ -75,14 +87,6 @@ function getPartKey(part, partIndex) {
75
87
  if ("id" in part && typeof part.id === "string") return `${part.type}-${part.id}`;
76
88
  return `${part.type}-${partIndex}`;
77
89
  }
78
- function isToolPartWorking(part) {
79
- const state = getToolPartState(part);
80
- return state === "loading" || state === "streaming" || state === "waiting-approval";
81
- }
82
- function isToolPartFailed(part) {
83
- const state = getToolPartState(part);
84
- return state === "error" || state === "denied";
85
- }
86
90
  /**
87
91
  * AI SDK exports concrete source part types but no public source-part guard.
88
92
  * Keep these local guards as exact discriminant checks, matching
@@ -97,21 +101,14 @@ function isSourceDocumentPart(part) {
97
101
  return part?.type === "source-document";
98
102
  }
99
103
  /**
100
- * AI SDK emits `step-start` as a native `StepStartUIPart`, but currently exports
101
- * only the type, not an `isStepStartUIPart` helper. Keep this as the exact
102
- * upstream discriminant so step separators do not become a local protocol.
103
- */
104
- function isStepStartPart(part) {
105
- return part.type === "step-start";
106
- }
107
- /**
108
104
  * Session compaction overlay marker from Agents Sessions.
109
105
  *
110
- * Agents exports `isCompactionMessage` from
111
- * `agents/experimental/memory/utils`; it checks the canonical `compaction_`
106
+ * Agents exports `isCompactionMessage` from `agents/sessions`; it checks the canonical `compaction_`
112
107
  * id prefix used when `Session.getHistory()` materializes a summary overlay.
113
108
  * `UIMessage` is structurally compatible with the fields the helper reads, so
114
- * keep this wrapper instead of duplicating the prefix test locally.
109
+ * keep this wrapper instead of duplicating the prefix test locally. The
110
+ * runtime import above stays on the deprecated compatibility path until this
111
+ * package raises its Agents dependency floor to the graduating release.
115
112
  */
116
113
  function isCompactionMessage$1(message) {
117
114
  return isCompactionMessage(message);
@@ -149,93 +146,6 @@ function getEditableUserText(message) {
149
146
  const part = message.parts[0];
150
147
  return isTextUIPart(part) && part.text.trim() ? part.text : void 0;
151
148
  }
152
- function AgentChatMessageEditor({ message, originalText, onCancel, onEditAndResend, onSuccess }) {
153
- const [draft, setDraft] = React.useState(originalText);
154
- const [isSubmitting, setIsSubmitting] = React.useState(false);
155
- const [error, setError] = React.useState();
156
- const textareaRef = React.useRef(null);
157
- const labelId = React.useId();
158
- const errorId = React.useId();
159
- const trimmedDraft = draft.trim();
160
- const canSubmit = !isSubmitting && Boolean(trimmedDraft) && trimmedDraft !== originalText.trim();
161
- React.useLayoutEffect(() => {
162
- textareaRef.current?.focus();
163
- const end = textareaRef.current?.value.length ?? 0;
164
- textareaRef.current?.setSelectionRange(end, end);
165
- }, []);
166
- const handleSubmit = async (event) => {
167
- event.preventDefault();
168
- if (!canSubmit) return;
169
- setError(void 0);
170
- setIsSubmitting(true);
171
- try {
172
- await onEditAndResend({
173
- message,
174
- text: trimmedDraft
175
- });
176
- onSuccess();
177
- } catch {
178
- setError("Message wasn’t resent. Try again.");
179
- setIsSubmitting(false);
180
- }
181
- };
182
- return /* @__PURE__ */ jsxs("form", {
183
- className: "message__edit-form",
184
- "aria-busy": isSubmitting,
185
- onSubmit: (event) => void handleSubmit(event),
186
- children: [
187
- /* @__PURE__ */ jsx("label", {
188
- id: labelId,
189
- className: "message__edit-label",
190
- htmlFor: `${labelId}-textarea`,
191
- children: "Edit message"
192
- }),
193
- /* @__PURE__ */ jsx("textarea", {
194
- ref: textareaRef,
195
- id: `${labelId}-textarea`,
196
- className: "message__edit-textarea",
197
- value: draft,
198
- "aria-describedby": error ? errorId : void 0,
199
- "aria-invalid": error ? true : void 0,
200
- disabled: isSubmitting,
201
- rows: 3,
202
- onChange: (event) => {
203
- setDraft(event.currentTarget.value);
204
- if (error) setError(void 0);
205
- },
206
- onKeyDown: (event) => {
207
- if (event.key !== "Escape" || isSubmitting) return;
208
- event.preventDefault();
209
- onCancel();
210
- }
211
- }),
212
- error ? /* @__PURE__ */ jsx("p", {
213
- id: errorId,
214
- className: "message__edit-error",
215
- role: "alert",
216
- children: error
217
- }) : null,
218
- /* @__PURE__ */ jsxs("div", {
219
- className: "message__edit-actions",
220
- children: [/* @__PURE__ */ jsx(Button, {
221
- type: "button",
222
- variant: "outline",
223
- color: "neutral",
224
- size: "lg",
225
- disabled: isSubmitting,
226
- onClick: onCancel,
227
- children: "Cancel"
228
- }), /* @__PURE__ */ jsx(Button, {
229
- type: "submit",
230
- color: "primary",
231
- size: "lg",
232
- disabled: !canSubmit,
233
- children: isSubmitting ? "Resending…" : "Send"
234
- })]
235
- })
236
- ]
237
- });
238
- }
239
149
  function formatSourceTitle(part) {
240
150
  if (part.title) return part.title;
241
151
  if (part.type === "source-document") return part.filename ?? part.mediaType;
@@ -264,7 +174,7 @@ function getSourceRun(parts, start) {
264
174
  return sources;
265
175
  }
266
176
  function describeToolPart(part) {
267
- const name = getToolName(part);
177
+ const name = getToolDisplayName(part);
268
178
  const verb = isToolPartFailed(part) ? `${name} failed` : isToolPartWorking(part) ? `Running ${name}` : `Ran ${name}`;
269
179
  const detail = summarizeToolInput(getToolInput(part));
270
180
  return detail ? `${verb} · ${detail}` : verb;
@@ -281,7 +191,7 @@ function renderToolActivity(part) {
281
191
  return /* @__PURE__ */ jsxs(Activity, {
282
192
  isStreaming: isToolPartWorking(part),
283
193
  children: [/* @__PURE__ */ jsx(ActivityTrigger, { label: describeToolPart(part) }), /* @__PURE__ */ jsxs(ActivityContent, { children: [/* @__PURE__ */ jsx(ActivityPanel, {
284
- label: getToolName(part),
194
+ label: getToolDisplayName(part),
285
195
  text: formatToolValue(getToolInput(part))
286
196
  }), output ? /* @__PURE__ */ jsx(ActivityPanel, {
287
197
  label: "output",
@@ -291,18 +201,20 @@ function renderToolActivity(part) {
291
201
  }) : null] })]
292
202
  });
293
203
  }
294
- function renderDefaultPart(part) {
204
+ function renderDefaultPart(message, part, partIndex, isLastMessage, status) {
295
205
  if (isTextUIPart(part) && part.text) return /* @__PURE__ */ jsx(MessageResponse, { children: part.text });
296
206
  if (isFileUIPart(part)) return /* @__PURE__ */ jsx(MessageAttachment, { part });
297
- if (isReasoningUIPart(part) && part.text) return /* @__PURE__ */ jsxs(Reasoning, {
298
- isStreaming: part.state === "streaming",
299
- children: [/* @__PURE__ */ jsx(ReasoningTrigger, {}), /* @__PURE__ */ jsx(ReasoningContent, { children: part.text })]
300
- });
207
+ if (isReasoningUIPart(part)) {
208
+ if (partIndex !== message.parts.findIndex(isReasoningUIPart)) return null;
209
+ const reasoningText = message.parts.filter(isReasoningUIPart).map((reasoningPart) => reasoningPart.text).join("\n\n");
210
+ if (!reasoningText) return null;
211
+ const lastPart = message.parts.at(-1);
212
+ return /* @__PURE__ */ jsxs(Reasoning, {
213
+ isStreaming: isLastMessage && status === "streaming" && lastPart !== void 0 && isReasoningUIPart(lastPart) && lastPart.state === "streaming",
214
+ children: [/* @__PURE__ */ jsx(ReasoningTrigger, {}), /* @__PURE__ */ jsx(ReasoningContent, { children: reasoningText })]
215
+ });
216
+ }
301
217
  if (isToolUIPart(part)) return renderToolActivity(part);
302
- if (isStepStartPart(part)) return /* @__PURE__ */ jsx(Marker, {
303
- variant: "separator",
304
- children: /* @__PURE__ */ jsx(MarkerContent, { children: "Next step" })
305
- });
306
218
  return null;
307
219
  }
308
220
  /**
@@ -310,8 +222,16 @@ function renderDefaultPart(part) {
310
222
  * transport. Product code that talks to a Cloudflare Think agent should render
311
223
  * `ThinkChat`; use this directly only for plain AI SDK or read-only messages.
312
224
  */
313
- function AgentChat({ className, messages, status = "ready", onSubmit, onStop, placeholder = "Ask anything...", disabled, emptyState, composerHeader, composerTools, voiceInput, beforeVoiceStart, composerAddMenuItems, notice, onRegenerate, onEditAndResend, onApprovalResponse, thinkStub, onExecutionSettled, pendingApprovals: durableApprovals = EMPTY_PENDING_APPROVALS, contextWindow, renderPart, renderMessageAfter, ref }) {
225
+ function AgentChat({ className, messages, queuedMessages = [], onSteerQueuedMessage, onRemoveQueuedMessage, status = "ready", onSubmit, showComposer = onSubmit !== void 0, onStop, allowSubmitWhileBusy = false, placeholder = "Ask anything...", disabled, emptyState, composerHeader, composerTools, slashCommands, mentionCommands, contextSelector, composerEndTools, voiceInput, beforeVoiceStart, composerAddMenuItems, notice, onRegenerate, onEditAndResend, onApprovalResponse, thinkStub, permissionModeControl, onExecutionSettled, pendingApprovals: durableApprovals = EMPTY_PENDING_APPROVALS, contextWindow, renderPart, renderMessageAfter, ref }) {
314
226
  const [copyAnnouncement, setCopyAnnouncement] = React.useState("");
227
+ const [composerDraft, setComposerDraft] = React.useState("");
228
+ const [composerReferences, setComposerReferences] = React.useState([]);
229
+ const addComposerReference = React.useCallback((reference) => {
230
+ setComposerReferences((current) => current.some((item) => item.id === reference.id && item.trigger === reference.trigger) ? current : [...current, reference]);
231
+ }, []);
232
+ const removeComposerReference = React.useCallback((reference) => {
233
+ setComposerReferences((current) => current.filter((item) => item.id !== reference.id || item.trigger !== reference.trigger));
234
+ }, []);
315
235
  const copyAnnouncementTimer = React.useRef(null);
316
236
  const announceCopyStatus = React.useCallback((message) => {
317
237
  if (copyAnnouncementTimer.current !== null) window.clearTimeout(copyAnnouncementTimer.current);
@@ -325,23 +245,62 @@ function AgentChat({ className, messages, status = "ready", onSubmit, onStop, pl
325
245
  if (copyAnnouncementTimer.current !== null) window.clearTimeout(copyAnnouncementTimer.current);
326
246
  }, []);
327
247
  const handleSubmit = React.useCallback((message) => {
328
- onSubmit?.(message);
329
- }, [onSubmit]);
248
+ const submission = onSubmit?.({
249
+ ...message,
250
+ ...composerReferences.length ? { references: composerReferences } : {}
251
+ });
252
+ setComposerDraft("");
253
+ setComposerReferences([]);
254
+ return submission;
255
+ }, [composerReferences, onSubmit]);
256
+ const selectComposerCommand = React.useCallback((command, trigger) => {
257
+ const reference = {
258
+ id: command.id,
259
+ value: command.value,
260
+ label: command.label,
261
+ icon: command.icon,
262
+ trigger
263
+ };
264
+ const nextReferences = composerReferences.some((item) => item.id === reference.id && item.trigger === reference.trigger) ? composerReferences : [...composerReferences, reference];
265
+ addComposerReference(reference);
266
+ const catalog = trigger === "@" ? mentionCommands : slashCommands;
267
+ if (catalog?.onSelect) catalog.onSelect(command, {
268
+ value: composerDraft,
269
+ references: nextReferences,
270
+ setValue: setComposerDraft,
271
+ clear: () => setComposerDraft(""),
272
+ addReference: addComposerReference,
273
+ removeReference: removeComposerReference
274
+ });
275
+ else setComposerDraft("");
276
+ }, [
277
+ addComposerReference,
278
+ composerDraft,
279
+ composerReferences,
280
+ mentionCommands,
281
+ removeComposerReference,
282
+ slashCommands
283
+ ]);
330
284
  const [approvalSession, setApprovalSession] = React.useState(() => createApprovalSessionState(thinkStub));
331
- const approvalSessionIsCurrent = isCurrentApprovalSession(approvalSession, thinkStub);
285
+ const approvalSessionIsCurrent = approvalSession.thinkStub === thinkStub;
332
286
  const skippedApprovalIds = approvalSessionIsCurrent ? approvalSession.skippedApprovalIds : EMPTY_SKIPPED_APPROVAL_IDS;
333
- const permissionMode = approvalSessionIsCurrent ? approvalSession.permissionMode : "ask";
287
+ const localPermissionMode = approvalSessionIsCurrent ? approvalSession.permissionMode : "bypass";
288
+ const permissionMode = permissionModeControl?.value ?? localPermissionMode;
334
289
  const updateApprovalSession = React.useCallback((update) => {
335
- setApprovalSession((previous) => update(isCurrentApprovalSession(previous, thinkStub) ? previous : createApprovalSessionState(thinkStub)));
290
+ setApprovalSession((previous) => update(previous.thinkStub === thinkStub ? previous : createApprovalSessionState(thinkStub)));
336
291
  }, [thinkStub]);
337
292
  const setPermissionMode = React.useCallback((next) => {
293
+ if (permissionModeControl) {
294
+ permissionModeControl.onChange(next);
295
+ return;
296
+ }
338
297
  updateApprovalSession((current) => ({
339
298
  ...current,
340
299
  permissionMode: next
341
300
  }));
342
- }, [updateApprovalSession]);
301
+ }, [permissionModeControl, updateApprovalSession]);
343
302
  React.useLayoutEffect(() => {
344
- setApprovalSession((previous) => isCurrentApprovalSession(previous, thinkStub) ? previous : createApprovalSessionState(thinkStub));
303
+ setApprovalSession((previous) => previous.thinkStub === thinkStub ? previous : createApprovalSessionState(thinkStub));
345
304
  }, [thinkStub]);
346
305
  const pendingApprovalItems = [...getPendingToolApprovals(messages, { pausedExecutions: Boolean(thinkStub) }).filter(({ part }) => {
347
306
  if (part.state === "approval-requested" && !onApprovalResponse) return false;
@@ -354,14 +313,14 @@ function AgentChat({ className, messages, status = "ready", onSubmit, onStop, pl
354
313
  ids: /* @__PURE__ */ new Set()
355
314
  });
356
315
  React.useLayoutEffect(() => {
357
- if (isCurrentApprovalSession(autoApprovedIds.current, thinkStub)) return;
316
+ if (autoApprovedIds.current.thinkStub === thinkStub) return;
358
317
  autoApprovedIds.current = {
359
318
  thinkStub,
360
319
  ids: /* @__PURE__ */ new Set()
361
320
  };
362
321
  }, [thinkStub]);
363
322
  React.useEffect(() => {
364
- if (permissionMode !== "bypass") return;
323
+ if (permissionModeControl || permissionMode !== "bypass") return;
365
324
  for (const item of pendingApprovalItems) {
366
325
  const id = "part" in item ? getApprovalRequestId(item.part) : item.approval.executionId;
367
326
  const key = "part" in item ? getApprovalStateKey(item.part) : item.approval.executionId;
@@ -377,22 +336,25 @@ function AgentChat({ className, messages, status = "ready", onSubmit, onStop, pl
377
336
  }
378
337
  }, [
379
338
  permissionMode,
339
+ permissionModeControl,
380
340
  messages,
381
341
  durableApprovals,
382
342
  onApprovalResponse,
383
343
  thinkStub,
384
344
  onExecutionSettled
385
345
  ]);
386
- const pendingApproval = permissionMode === "bypass" ? void 0 : pendingApprovalItems[0];
346
+ const pendingApproval = !permissionModeControl && permissionMode === "bypass" ? void 0 : pendingApprovalItems[0];
387
347
  const contextUsage = contextWindow ? getContextUsage(messages) : void 0;
388
- const newestAssistantIndex = messages.findLastIndex((message) => message.role === "assistant" && !isCompactionMessage$1(message));
348
+ const queuedMessageIds = new Set(queuedMessages.map((message) => message.id));
349
+ const transcriptMessages = queuedMessageIds.size ? messages.filter((message) => !queuedMessageIds.has(message.id)) : messages;
350
+ const newestAssistantIndex = transcriptMessages.findLastIndex((message) => message.role === "assistant" && !isCompactionMessage$1(message));
389
351
  const lastAssistantIndex = onRegenerate && status !== "streaming" && status !== "submitted" ? newestAssistantIndex : -1;
390
- const lastUserIndex = onEditAndResend && !disabled && status !== "streaming" && status !== "submitted" ? messages.findLastIndex((message) => message.role === "user") : -1;
352
+ const lastUserIndex = onEditAndResend && !disabled && status !== "streaming" && status !== "submitted" ? transcriptMessages.findLastIndex((message) => message.role === "user") : -1;
391
353
  const [editingMessageId, setEditingMessageId] = React.useState();
392
354
  const restoreEditFocus = React.useRef(false);
393
355
  const editButtonRef = React.useRef(null);
394
356
  let assistantResponseCount = 0;
395
- const assistantResponseNumbers = messages.map((message) => {
357
+ const assistantResponseNumbers = transcriptMessages.map((message) => {
396
358
  if (message.role !== "assistant" || isCompactionMessage$1(message)) return 0;
397
359
  assistantResponseCount += 1;
398
360
  return assistantResponseCount;
@@ -414,6 +376,7 @@ function AgentChat({ className, messages, status = "ready", onSubmit, onStop, pl
414
376
  return /* @__PURE__ */ jsxs("div", {
415
377
  ref,
416
378
  className: cx("agent-chat", className),
379
+ "data-composer-hidden": showComposer ? void 0 : "",
417
380
  children: [
418
381
  /* @__PURE__ */ jsx("span", {
419
382
  className: "message__copy-status",
@@ -429,13 +392,13 @@ function AgentChat({ className, messages, status = "ready", onSubmit, onStop, pl
429
392
  children: [/* @__PURE__ */ jsx(MessageScrollerViewport, { children: /* @__PURE__ */ jsxs(MessageScrollerContent, {
430
393
  "aria-busy": status === "streaming" || status === "submitted",
431
394
  className: "agent-chat__transcript-content",
432
- children: [messages.length === 0 ? /* @__PURE__ */ jsx(MessageScrollerItem, {
395
+ children: [transcriptMessages.length === 0 ? /* @__PURE__ */ jsx(MessageScrollerItem, {
433
396
  className: "agent-chat__empty-row",
434
397
  children: emptyState ?? /* @__PURE__ */ jsx(ConversationEmptyState, {
435
398
  title: "Start a conversation",
436
399
  description: "Ask the agent to inspect, plan, or build."
437
400
  })
438
- }) : null, messages.map((message, messageIndex) => /* @__PURE__ */ jsx(MessageScrollerItem, {
401
+ }) : null, transcriptMessages.map((message, messageIndex) => /* @__PURE__ */ jsx(MessageScrollerItem, {
439
402
  messageId: message.id,
440
403
  scrollAnchor: message.role === "user",
441
404
  children: isCompactionMessage$1(message) ? /* @__PURE__ */ jsx(Marker, {
@@ -446,7 +409,7 @@ function AgentChat({ className, messages, status = "ready", onSubmit, onStop, pl
446
409
  children: editingMessageId === message.id && onEditAndResend ? /* @__PURE__ */ jsx(AgentChatMessageEditor, {
447
410
  message,
448
411
  originalText: getEditableUserText(message) ?? "",
449
- onEditAndResend,
412
+ onSubmit: onEditAndResend,
450
413
  onCancel: () => {
451
414
  restoreEditFocus.current = true;
452
415
  setEditingMessageId(void 0);
@@ -457,7 +420,7 @@ function AgentChat({ className, messages, status = "ready", onSubmit, onStop, pl
457
420
  }
458
421
  }, message.id) : /* @__PURE__ */ jsxs(Fragment, { children: [
459
422
  message.parts.map((part, partIndex) => {
460
- const defaultRender = () => renderDefaultPart(part);
423
+ const defaultRender = () => renderDefaultPart(message, part, partIndex, messageIndex === transcriptMessages.length - 1, status);
461
424
  const custom = renderPart?.({
462
425
  message,
463
426
  part,
@@ -512,67 +475,130 @@ function AgentChat({ className, messages, status = "ready", onSubmit, onStop, pl
512
475
  })]
513
476
  })
514
477
  }),
515
- /* @__PURE__ */ jsxs("div", {
478
+ showComposer ? /* @__PURE__ */ jsxs("div", {
516
479
  ref: composerRef,
517
480
  className: "agent-chat__composer",
518
- children: [/* @__PURE__ */ jsx("div", {
519
- className: "agent-chat__notice",
520
- role: "status",
521
- "aria-atomic": "true",
522
- children: notice
523
- }), /* @__PURE__ */ jsx(PromptInput, {
524
- multiple: true,
525
- onSubmit: handleSubmit,
526
- children: pendingApproval ? /* @__PURE__ */ jsx(PromptInputApproval, {
527
- part: "part" in pendingApproval ? pendingApproval.part : void 0,
528
- approval: "approval" in pendingApproval ? pendingApproval.approval : void 0,
529
- count: pendingApprovalItems.length,
530
- onRespond: onApprovalResponse,
531
- thinkStub,
532
- onExecutionSettled,
533
- onSkip: () => {
534
- const id = "part" in pendingApproval ? getApprovalStateKey(pendingApproval.part) : pendingApproval.approval.executionId;
535
- if (id) updateApprovalSession((current) => ({
536
- ...current,
537
- skippedApprovalIds: [...current.skippedApprovalIds, id]
538
- }));
539
- }
540
- }) : /* @__PURE__ */ jsxs(Fragment, { children: [
541
- composerHeader ? /* @__PURE__ */ jsx(PromptInputHeader, { children: composerHeader }) : null,
542
- /* @__PURE__ */ jsx(PromptInputAttachments, {}),
543
- /* @__PURE__ */ jsx(PromptInputBody, { children: /* @__PURE__ */ jsx(PromptInputTextarea, {
544
- "aria-label": "Message",
545
- placeholder,
546
- disabled
547
- }) }),
548
- /* @__PURE__ */ jsxs(PromptInputFooter, { children: [/* @__PURE__ */ jsxs(PromptInputTools, { children: [
549
- /* @__PURE__ */ jsx(AgentChatAddMenu, { children: composerAddMenuItems }),
550
- approvalsWired ? /* @__PURE__ */ jsx(PromptInputPermissionSelector, {
551
- value: permissionMode,
552
- onValueChange: setPermissionMode
553
- }) : null,
554
- composerTools,
555
- voiceInput ? /* @__PURE__ */ jsx(PromptInputDictation, {
556
- voice: voiceInput,
557
- beforeStart: beforeVoiceStart,
558
- disabled
559
- }) : null
560
- ] }), /* @__PURE__ */ jsxs("div", {
561
- className: "prompt-input__footer-end",
562
- children: [contextWindow ? /* @__PURE__ */ jsxs(Context, {
563
- usedTokens: getContextUsedTokens(contextUsage),
564
- maxTokens: contextWindow.maxTokens,
565
- usage: contextUsage,
566
- modelId: contextWindow.modelId,
567
- children: [/* @__PURE__ */ jsx(ContextTrigger, {}), /* @__PURE__ */ jsxs(ContextContent, { children: [/* @__PURE__ */ jsx(ContextContentHeader, {}), /* @__PURE__ */ jsx(ContextContentBody, {})] })]
568
- }) : null, /* @__PURE__ */ jsx(PromptInputSubmit, {
569
- status,
570
- onStop
571
- })]
572
- })] })
573
- ] })
574
- })]
575
- })
481
+ children: [
482
+ /* @__PURE__ */ jsx("div", {
483
+ className: "agent-chat__notice",
484
+ role: "status",
485
+ "aria-atomic": "true",
486
+ children: notice
487
+ }),
488
+ queuedMessages.length ? /* @__PURE__ */ jsx("section", {
489
+ className: "agent-chat__queued",
490
+ "aria-label": "Queued messages",
491
+ children: /* @__PURE__ */ jsx("ul", {
492
+ className: "agent-chat__queued-list",
493
+ children: queuedMessages.map((message) => {
494
+ const messageText = getMessageText(message) || "Queued message";
495
+ return /* @__PURE__ */ jsxs("li", {
496
+ className: "agent-chat__queued-message",
497
+ children: [
498
+ /* @__PURE__ */ jsx("span", {
499
+ className: "agent-chat__queued-indicator",
500
+ "aria-hidden": "true",
501
+ children: /* @__PURE__ */ jsx(QueueIcon, {})
502
+ }),
503
+ /* @__PURE__ */ jsx("span", {
504
+ className: "agent-chat__queued-text",
505
+ children: messageText
506
+ }),
507
+ onSteerQueuedMessage ? /* @__PURE__ */ jsxs("button", {
508
+ type: "button",
509
+ className: "agent-chat__queued-action",
510
+ "aria-label": `Steer queued message: ${messageText}`,
511
+ onClick: () => onSteerQueuedMessage(message),
512
+ children: [/* @__PURE__ */ jsx(SteerIcon, {}), "Steer"]
513
+ }) : null,
514
+ onRemoveQueuedMessage ? /* @__PURE__ */ jsx("button", {
515
+ type: "button",
516
+ className: "agent-chat__queued-action agent-chat__queued-remove",
517
+ "aria-label": `Remove queued message: ${messageText}`,
518
+ onClick: () => onRemoveQueuedMessage(message),
519
+ children: /* @__PURE__ */ jsx(TrashIcon, {})
520
+ }) : null
521
+ ]
522
+ }, message.id);
523
+ })
524
+ })
525
+ }) : null,
526
+ /* @__PURE__ */ jsx(PromptInput, {
527
+ multiple: true,
528
+ onSubmit: handleSubmit,
529
+ children: pendingApproval ? /* @__PURE__ */ jsx(PromptInputApproval, {
530
+ part: "part" in pendingApproval ? pendingApproval.part : void 0,
531
+ approval: "approval" in pendingApproval ? pendingApproval.approval : void 0,
532
+ count: pendingApprovalItems.length,
533
+ onRespond: onApprovalResponse,
534
+ thinkStub,
535
+ onExecutionSettled,
536
+ onSkip: () => {
537
+ const id = "part" in pendingApproval ? getApprovalStateKey(pendingApproval.part) : pendingApproval.approval.executionId;
538
+ if (id) updateApprovalSession((current) => ({
539
+ ...current,
540
+ skippedApprovalIds: [...current.skippedApprovalIds, id]
541
+ }));
542
+ }
543
+ }) : /* @__PURE__ */ jsxs(Fragment, { children: [
544
+ composerHeader ? /* @__PURE__ */ jsx(PromptInputHeader, { children: composerHeader }) : null,
545
+ /* @__PURE__ */ jsx(PromptInputAttachments, {}),
546
+ /* @__PURE__ */ jsxs(PromptInputBody, { children: [/* @__PURE__ */ jsx(PromptInputReferences, {
547
+ references: composerReferences,
548
+ onRemove: removeComposerReference
549
+ }), slashCommands || mentionCommands ? /* @__PURE__ */ jsx(PromptInputCommandComposer, {
550
+ "aria-label": "Message",
551
+ placeholder: composerReferences.length ? "" : placeholder,
552
+ disabled,
553
+ commands: slashCommands?.items ?? [],
554
+ mentionCommands: mentionCommands?.items,
555
+ value: composerDraft,
556
+ onValueChange: setComposerDraft,
557
+ onCommandSelect: selectComposerCommand
558
+ }) : /* @__PURE__ */ jsx(PromptInputTextarea, {
559
+ "aria-label": "Message",
560
+ placeholder,
561
+ disabled,
562
+ value: composerDraft,
563
+ onChange: (event) => setComposerDraft(event.currentTarget.value)
564
+ })] }),
565
+ /* @__PURE__ */ jsxs(PromptInputFooter, { children: [/* @__PURE__ */ jsxs(PromptInputTools, { children: [
566
+ /* @__PURE__ */ jsx(AgentChatAddMenu, { children: composerAddMenuItems }),
567
+ contextSelector ? /* @__PURE__ */ jsx(PromptInputContextSelector, { ...contextSelector }) : null,
568
+ approvalsWired ? /* @__PURE__ */ jsx(PromptInputPermissionSelector, {
569
+ value: permissionMode,
570
+ onValueChange: setPermissionMode
571
+ }) : null,
572
+ composerTools
573
+ ] }), /* @__PURE__ */ jsxs("div", {
574
+ className: "prompt-input__footer-end",
575
+ children: [
576
+ composerEndTools,
577
+ voiceInput ? /* @__PURE__ */ jsx(PromptInputDictation, {
578
+ voice: voiceInput,
579
+ beforeStart: beforeVoiceStart,
580
+ disabled
581
+ }) : null,
582
+ contextWindow ? /* @__PURE__ */ jsxs(Context, {
583
+ usedTokens: getContextUsedTokens(contextUsage),
584
+ maxTokens: contextWindow.maxTokens,
585
+ usage: contextUsage,
586
+ modelId: contextWindow.modelId,
587
+ children: [/* @__PURE__ */ jsx(ContextTrigger, {}), /* @__PURE__ */ jsxs(ContextContent, { children: [/* @__PURE__ */ jsx(ContextContentHeader, {}), /* @__PURE__ */ jsx(ContextContentBody, {})] })]
588
+ }) : null,
589
+ /* @__PURE__ */ jsx(AgentChatSubmitAction, {
590
+ status,
591
+ onStop,
592
+ allowSubmitWhileBusy: Boolean(allowSubmitWhileBusy),
593
+ disabled,
594
+ hasDraft: Boolean(composerDraft.trim() || composerReferences.length)
595
+ })
596
+ ]
597
+ })] })
598
+ ] })
599
+ })
600
+ ]
601
+ }) : null
576
602
  ]
577
603
  });
578
604
  }
@@ -0,0 +1,29 @@
1
+ import * as React from "react";
2
+ import { UIMessage } from "ai";
3
+
4
+ //#region src/components/AgentChatMessageEditor.d.ts
5
+ interface AgentChatMessageEditorProps<MessageT extends UIMessage = UIMessage> {
6
+ /** Whole upstream message being edited, including app metadata and typed data parts. */
7
+ message: MessageT;
8
+ originalText: string;
9
+ onCancel: () => void;
10
+ onSubmit: (input: {
11
+ message: MessageT;
12
+ text: string;
13
+ }) => void | Promise<void>;
14
+ onSuccess?: () => void;
15
+ }
16
+ /**
17
+ * Edit-and-resend form for a chat message. It composes the shared Base UI
18
+ * Form/Field wrappers and Textarea recipe so validation, labels, focus, and
19
+ * disabled states stay owned by the design-system primitives.
20
+ */
21
+ declare function AgentChatMessageEditor<MessageT extends UIMessage = UIMessage>({
22
+ message,
23
+ originalText,
24
+ onCancel,
25
+ onSubmit,
26
+ onSuccess
27
+ }: AgentChatMessageEditorProps<MessageT>): React.JSX.Element;
28
+ //#endregion
29
+ export { AgentChatMessageEditor, AgentChatMessageEditorProps };