@adecore/agents-react 0.38.0 → 0.40.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 (351) hide show
  1. package/dist/agents/AgentModelLabel.d.ts +10 -0
  2. package/dist/agents/AgentModelLabel.js +98 -0
  3. package/dist/agents/model-name.js +2 -1
  4. package/dist/agents/provider-paths.d.ts +2 -1
  5. package/dist/agents/provider-paths.js +7 -3
  6. package/dist/chat/account-choice.js +57 -28
  7. package/dist/chat/bookmarks.js +2 -1
  8. package/dist/chat/drafts.d.ts +0 -1
  9. package/dist/chat/drafts.js +9 -28
  10. package/dist/chat/logic/picker-entries.js +2 -8
  11. package/dist/chat/logic/resume-compaction.js +2 -5
  12. package/dist/chat/logic/timeline-copy.js +2 -8
  13. package/dist/chat/logic/timeline.js +9 -10
  14. package/dist/chat/logic/workflow.js +2 -4
  15. package/dist/chat/subagent-conversation.js +2 -1
  16. package/dist/chat/ui/Composer.js +385 -360
  17. package/dist/chat/ui/GoalDock.js +2 -1
  18. package/dist/chat/ui/LimitState.js +4 -6
  19. package/dist/chat/ui/Pickers.d.ts +2 -1
  20. package/dist/chat/ui/Pickers.js +126 -123
  21. package/dist/chat/ui/PromptEditor.d.ts +19 -0
  22. package/dist/chat/ui/PromptEditor.js +115 -0
  23. package/dist/chat/ui/Timeline.d.ts +2 -1
  24. package/dist/chat/ui/Timeline.js +13 -1
  25. package/dist/chat/ui/composer/ComposerControls.d.ts +3 -0
  26. package/dist/chat/ui/composer/ComposerControls.js +235 -38
  27. package/dist/chat/ui/composer/key-handler.d.ts +1 -1
  28. package/dist/chat/ui/composer/key-handler.js +3 -11
  29. package/dist/chat/ui/composer/prompt-picks.d.ts +4 -0
  30. package/dist/chat/ui/composer/prompt-picks.js +14 -0
  31. package/dist/chat/ui/composer/use-composer-menus.d.ts +4 -49
  32. package/dist/chat/ui/composer/use-composer-menus.js +65 -519
  33. package/dist/chat/ui/composer/use-continuable-turn.js +0 -1
  34. package/dist/chat/ui/composer/use-notice.js +2 -1
  35. package/dist/chat/ui/composer/use-prompt-history.js +1 -1
  36. package/dist/chat/ui/composer/use-prompt-menus.d.ts +73 -0
  37. package/dist/chat/ui/composer/use-prompt-menus.js +499 -0
  38. package/dist/chat/ui/composer/use-take-back.js +2 -2
  39. package/dist/chat/ui/diff/ApprovalReview.js +1 -1
  40. package/dist/chat/ui/highlighter.d.ts +0 -6
  41. package/dist/chat/ui/highlighter.js +0 -12
  42. package/dist/chat/ui/icons.d.ts +0 -1
  43. package/dist/chat/ui/icons.js +0 -3
  44. package/dist/chat/ui/index.d.ts +3 -0
  45. package/dist/chat/ui/index.js +2 -0
  46. package/dist/chat/ui/rows/MessageRows.js +2 -5
  47. package/dist/chat/ui/rows/row-rhythm.js +2 -5
  48. package/dist/chat/ui/theme-watch.js +3 -7
  49. package/dist/host-hooks.d.ts +2 -1
  50. package/dist/host-hooks.js +6 -0
  51. package/dist/host.d.ts +17 -1
  52. package/dist/index.d.ts +1 -1
  53. package/dist/locales/en/agent-chat.d.ts +1 -0
  54. package/dist/locales/en/agent-chat.js +1 -0
  55. package/dist/locales/nl/agent-chat.d.ts +1 -0
  56. package/dist/locales/nl/agent-chat.js +1 -0
  57. package/dist/prompts/logic/usePromptSession.js +2 -1
  58. package/dist/providers/AddAccountForm.js +2 -1
  59. package/dist/providers/CliDetail.js +104 -130
  60. package/dist/providers/account-actions.js +6 -9
  61. package/dist/providers/index.d.ts +1 -0
  62. package/dist/providers/index.js +1 -0
  63. package/dist/state/chats.d.ts +1 -0
  64. package/dist/state/chats.js +6 -11
  65. package/dist/state/provider-accounts.d.ts +1 -1
  66. package/dist/state/provider-accounts.js +2 -8
  67. package/dist/theme.css +3 -0
  68. package/dist/transport.d.ts +2 -0
  69. package/dist/transport.js +14 -0
  70. package/dist/usage/ChartLogo.d.ts +5 -0
  71. package/dist/usage/ChartLogo.js +48 -0
  72. package/dist/usage/LimitsList.js +6 -16
  73. package/dist/usage/UsageBreakdown.js +17 -40
  74. package/dist/usage/UsageLimits.js +183 -211
  75. package/dist/usage/UsagePage.js +3 -17
  76. package/dist/usage/UsageSummary.js +4 -9
  77. package/dist/usage/limits.js +16 -31
  78. package/dist/usage/summary.d.ts +1 -1
  79. package/dist/usage/summary.js +3 -5
  80. package/package.json +26 -26
  81. package/src/agents/AccountDot.tsx +1 -0
  82. package/src/agents/AgentIcon.tsx +2 -0
  83. package/src/agents/AgentModelLabel.tsx +38 -0
  84. package/src/agents/ModelOptionControl.tsx +8 -0
  85. package/src/agents/account-limits.ts +3 -0
  86. package/src/agents/accounts.ts +12 -0
  87. package/src/agents/model-name.ts +13 -1
  88. package/src/agents/model-options.ts +2 -0
  89. package/src/agents/model-requirement.ts +4 -0
  90. package/src/agents/option-words.ts +2 -0
  91. package/src/agents/provider-paths.ts +8 -3
  92. package/src/agents/status-look.ts +1 -0
  93. package/src/chat/account-choice.ts +25 -19
  94. package/src/chat/actions.ts +5 -0
  95. package/src/chat/attachments.ts +8 -0
  96. package/src/chat/bookmarks.ts +13 -1
  97. package/src/chat/chat-client.ts +63 -0
  98. package/src/chat/chat-references.ts +3 -0
  99. package/src/chat/composer-effort.ts +5 -0
  100. package/src/chat/composer-send.ts +4 -0
  101. package/src/chat/drafts.ts +21 -17
  102. package/src/chat/forks.ts +4 -0
  103. package/src/chat/guards.ts +2 -0
  104. package/src/chat/index.ts +7 -0
  105. package/src/chat/logic/ansi.ts +47 -0
  106. package/src/chat/logic/bookmarks.ts +7 -0
  107. package/src/chat/logic/command-looks.ts +29 -0
  108. package/src/chat/logic/context-usage.ts +3 -0
  109. package/src/chat/logic/continue-after-stop.ts +5 -0
  110. package/src/chat/logic/effort.ts +4 -0
  111. package/src/chat/logic/embedded-code.ts +63 -0
  112. package/src/chat/logic/fork.ts +22 -0
  113. package/src/chat/logic/generated-image.ts +7 -0
  114. package/src/chat/logic/goal.ts +7 -0
  115. package/src/chat/logic/handback.ts +2 -0
  116. package/src/chat/logic/limit.ts +8 -0
  117. package/src/chat/logic/picker-entries.ts +16 -4
  118. package/src/chat/logic/resume-compaction.ts +22 -5
  119. package/src/chat/logic/scrubber.ts +38 -5
  120. package/src/chat/logic/thought.ts +5 -0
  121. package/src/chat/logic/thread-cards.ts +6 -0
  122. package/src/chat/logic/timeline-copy.ts +4 -9
  123. package/src/chat/logic/timeline-target.ts +15 -0
  124. package/src/chat/logic/timeline.ts +113 -10
  125. package/src/chat/logic/tools.ts +30 -0
  126. package/src/chat/logic/visual-height.ts +5 -0
  127. package/src/chat/logic/visual-viewport.ts +1 -0
  128. package/src/chat/logic/welcome.ts +3 -0
  129. package/src/chat/logic/workflow.ts +26 -7
  130. package/src/chat/mentions.ts +56 -0
  131. package/src/chat/pending-prompts.ts +16 -0
  132. package/src/chat/persisted-json.ts +15 -0
  133. package/src/chat/preferences.ts +16 -0
  134. package/src/chat/prompt-hold.ts +2 -0
  135. package/src/chat/quote.ts +7 -0
  136. package/src/chat/reading-width.ts +1 -0
  137. package/src/chat/recent-messages.ts +5 -0
  138. package/src/chat/resume-compaction-dismissals.ts +1 -0
  139. package/src/chat/stash.ts +12 -0
  140. package/src/chat/subagent-conversation.ts +24 -4
  141. package/src/chat/subagent-list.ts +14 -0
  142. package/src/chat/subagent-support.ts +1 -0
  143. package/src/chat/subagent-view.ts +9 -0
  144. package/src/chat/thumbnails.ts +14 -0
  145. package/src/chat/timeline-flash.ts +2 -0
  146. package/src/chat/timeline-scroll.ts +23 -0
  147. package/src/chat/ui/AccountPill.tsx +4 -0
  148. package/src/chat/ui/AnsiOutput.tsx +1 -0
  149. package/src/chat/ui/BookmarkMarker.tsx +5 -0
  150. package/src/chat/ui/BookmarkSubmenu.tsx +1 -0
  151. package/src/chat/ui/ChatActivity.tsx +13 -0
  152. package/src/chat/ui/CodeBlock.tsx +8 -0
  153. package/src/chat/ui/Composer.tsx +27 -3
  154. package/src/chat/ui/ComposerInput.tsx +22 -0
  155. package/src/chat/ui/DiffPool.tsx +3 -0
  156. package/src/chat/ui/EditDiff.tsx +5 -0
  157. package/src/chat/ui/GoalDock.tsx +13 -1
  158. package/src/chat/ui/ImageView.tsx +11 -0
  159. package/src/chat/ui/LimitState.tsx +23 -6
  160. package/src/chat/ui/Markdown.tsx +41 -0
  161. package/src/chat/ui/MermaidBlock.tsx +16 -0
  162. package/src/chat/ui/MessageActions.tsx +8 -0
  163. package/src/chat/ui/ModelMarks.tsx +1 -0
  164. package/src/chat/ui/Pickers.tsx +30 -1
  165. package/src/chat/ui/PromptComposer.tsx +2 -0
  166. package/src/chat/ui/PromptEditor.tsx +136 -0
  167. package/src/chat/ui/QuoteButton.tsx +12 -0
  168. package/src/chat/ui/ReferenceChip.tsx +3 -0
  169. package/src/chat/ui/ResumeCompactionDock.tsx +1 -0
  170. package/src/chat/ui/RowTime.tsx +1 -0
  171. package/src/chat/ui/RunSettings.tsx +38 -0
  172. package/src/chat/ui/Scrubber.tsx +14 -0
  173. package/src/chat/ui/SessionLine.tsx +1 -0
  174. package/src/chat/ui/ShellCommand.tsx +32 -0
  175. package/src/chat/ui/SubagentControls.tsx +7 -0
  176. package/src/chat/ui/SubagentInfo.tsx +1 -0
  177. package/src/chat/ui/SubagentStopButton.tsx +6 -0
  178. package/src/chat/ui/SubagentTimeline.tsx +10 -0
  179. package/src/chat/ui/Timeline.tsx +141 -1
  180. package/src/chat/ui/TimelineMenu.tsx +5 -0
  181. package/src/chat/ui/UnifiedDiff.tsx +6 -0
  182. package/src/chat/ui/UploadThumb.tsx +2 -0
  183. package/src/chat/ui/VisualDialogs.tsx +3 -0
  184. package/src/chat/ui/VisualFrame.tsx +15 -0
  185. package/src/chat/ui/Welcome.tsx +1 -0
  186. package/src/chat/ui/chip-clipboard.ts +20 -0
  187. package/src/chat/ui/code-lines.ts +14 -0
  188. package/src/chat/ui/code-theme.ts +1 -0
  189. package/src/chat/ui/composer/ComposerControls.tsx +70 -15
  190. package/src/chat/ui/composer/ComposerMenu.tsx +12 -0
  191. package/src/chat/ui/composer/DraftParts.tsx +2 -0
  192. package/src/chat/ui/composer/QueuedMessages.tsx +4 -0
  193. package/src/chat/ui/composer/chip-paste.ts +16 -0
  194. package/src/chat/ui/composer/chips.ts +6 -0
  195. package/src/chat/ui/composer/editor.ts +9 -0
  196. package/src/chat/ui/composer/insert.ts +2 -0
  197. package/src/chat/ui/composer/key-handler.ts +42 -9
  198. package/src/chat/ui/composer/keys.ts +23 -0
  199. package/src/chat/ui/composer/placeholder.ts +6 -0
  200. package/src/chat/ui/composer/prompt-picks.ts +18 -0
  201. package/src/chat/ui/composer/surface.ts +5 -0
  202. package/src/chat/ui/composer/use-chat-controls.ts +13 -0
  203. package/src/chat/ui/composer/use-compaction-offer.ts +3 -0
  204. package/src/chat/ui/composer/use-composer-menus.ts +20 -275
  205. package/src/chat/ui/composer/use-composer-submit.ts +27 -0
  206. package/src/chat/ui/composer/use-continuable-turn.ts +3 -5
  207. package/src/chat/ui/composer/use-draft-files.ts +24 -0
  208. package/src/chat/ui/composer/use-effort-stepper.ts +8 -0
  209. package/src/chat/ui/composer/use-notice.ts +4 -1
  210. package/src/chat/ui/composer/use-pending-requests.ts +3 -0
  211. package/src/chat/ui/composer/use-prompt-history.ts +20 -11
  212. package/src/chat/ui/composer/use-prompt-hold.ts +3 -0
  213. package/src/chat/ui/composer/use-prompt-menus.ts +361 -0
  214. package/src/chat/ui/composer/use-take-back.ts +20 -2
  215. package/src/chat/ui/diff/ApprovalReview.tsx +18 -15
  216. package/src/chat/ui/diff/DiffFallbackBoundary.tsx +1 -0
  217. package/src/chat/ui/diff/DiffOmitted.tsx +1 -0
  218. package/src/chat/ui/diff/DiffStack.tsx +2 -0
  219. package/src/chat/ui/diff/DiffUnavailable.tsx +1 -0
  220. package/src/chat/ui/diff/EditorEditDiff.tsx +13 -0
  221. package/src/chat/ui/diff/EditorPatchDiff.tsx +4 -0
  222. package/src/chat/ui/diff/LegacyDiffPool.tsx +2 -0
  223. package/src/chat/ui/diff/LegacyEditDiff.tsx +2 -0
  224. package/src/chat/ui/diff/LegacyUnifiedDiff.tsx +8 -0
  225. package/src/chat/ui/diff/RawDiff.tsx +1 -0
  226. package/src/chat/ui/diff/ReviewDiff.tsx +1 -0
  227. package/src/chat/ui/diff/diff-source-budget.ts +8 -0
  228. package/src/chat/ui/diff/editor-edit-model.ts +4 -0
  229. package/src/chat/ui/diff/review-plan.ts +9 -0
  230. package/src/chat/ui/diff/review-settle.ts +1 -0
  231. package/src/chat/ui/diff/syntax-runtime.ts +52 -0
  232. package/src/chat/ui/diff/use-review-stack.ts +9 -0
  233. package/src/chat/ui/diff-syntax.ts +12 -0
  234. package/src/chat/ui/diff-theme.ts +2 -0
  235. package/src/chat/ui/file-links.ts +2 -0
  236. package/src/chat/ui/find-reveal.ts +1 -0
  237. package/src/chat/ui/full-diff.ts +1 -0
  238. package/src/chat/ui/highlighter.ts +29 -15
  239. package/src/chat/ui/icons.tsx +2 -4
  240. package/src/chat/ui/index.ts +7 -0
  241. package/src/chat/ui/intelligent-ui/UiBlockFrame.tsx +25 -0
  242. package/src/chat/ui/intelligent-ui/UiFallbackPart.tsx +1 -0
  243. package/src/chat/ui/intelligent-ui/UiReply.tsx +63 -0
  244. package/src/chat/ui/intelligent-ui/block-local.ts +5 -0
  245. package/src/chat/ui/intelligent-ui/chart-data.ts +15 -0
  246. package/src/chat/ui/intelligent-ui/node-text.ts +17 -0
  247. package/src/chat/ui/intelligent-ui/renderers/binding.ts +1 -0
  248. package/src/chat/ui/intelligent-ui/renderers/chart.tsx +31 -0
  249. package/src/chat/ui/intelligent-ui/renderers/choices.tsx +4 -0
  250. package/src/chat/ui/intelligent-ui/renderers/content.tsx +18 -0
  251. package/src/chat/ui/intelligent-ui/renderers/data.tsx +11 -0
  252. package/src/chat/ui/intelligent-ui/renderers/inputs.tsx +13 -0
  253. package/src/chat/ui/intelligent-ui/renderers/links.tsx +9 -0
  254. package/src/chat/ui/intelligent-ui/renderers/map-slots.ts +15 -0
  255. package/src/chat/ui/intelligent-ui/renderers/map-style.ts +15 -0
  256. package/src/chat/ui/intelligent-ui/renderers/map-view.tsx +48 -0
  257. package/src/chat/ui/intelligent-ui/renderers/map.tsx +20 -0
  258. package/src/chat/ui/intelligent-ui/renderers/place-point.ts +3 -0
  259. package/src/chat/ui/intelligent-ui/renderers/structure.tsx +3 -0
  260. package/src/chat/ui/intelligent-ui/renderers/text.tsx +8 -0
  261. package/src/chat/ui/intelligent-ui/reply-parts.ts +5 -0
  262. package/src/chat/ui/intelligent-ui/table-data.ts +17 -0
  263. package/src/chat/ui/intelligent-ui/use-in-view.ts +4 -0
  264. package/src/chat/ui/intelligent-ui/use-later.ts +4 -0
  265. package/src/chat/ui/intelligent-ui/use-truncated.ts +5 -0
  266. package/src/chat/ui/intelligent-ui/use-ui-links.ts +29 -0
  267. package/src/chat/ui/intelligent-ui/use-ui-queries.ts +60 -0
  268. package/src/chat/ui/markdown-blocks.ts +64 -0
  269. package/src/chat/ui/mermaid.ts +4 -0
  270. package/src/chat/ui/quote-selection.ts +10 -0
  271. package/src/chat/ui/rehype-chips.ts +5 -0
  272. package/src/chat/ui/rehype-fade.ts +2 -0
  273. package/src/chat/ui/remark-html-as-text.ts +5 -0
  274. package/src/chat/ui/reveal.ts +18 -0
  275. package/src/chat/ui/rows/ForksRow.tsx +5 -0
  276. package/src/chat/ui/rows/GeneratedImageRow.tsx +10 -0
  277. package/src/chat/ui/rows/MessageRows.tsx +29 -5
  278. package/src/chat/ui/rows/RowContainer.tsx +1 -0
  279. package/src/chat/ui/rows/Rows.tsx +2 -0
  280. package/src/chat/ui/rows/SubagentRow.tsx +13 -0
  281. package/src/chat/ui/rows/TaskRow.tsx +7 -0
  282. package/src/chat/ui/rows/VisualRow.tsx +4 -0
  283. package/src/chat/ui/rows/WorkRows.tsx +46 -0
  284. package/src/chat/ui/rows/WorkflowRow.tsx +10 -0
  285. package/src/chat/ui/rows/row-rhythm.ts +7 -5
  286. package/src/chat/ui/theme-watch.ts +8 -7
  287. package/src/chat/ui/thread-references.ts +7 -0
  288. package/src/chat/ui/use-diff-source-tokens.ts +8 -0
  289. package/src/chat/ui/useToggleSet.ts +3 -0
  290. package/src/chat/ui/visual-theme.ts +30 -0
  291. package/src/chat/visual-bridge.ts +23 -0
  292. package/src/chat/visual-viewport.ts +12 -0
  293. package/src/host-hooks.ts +15 -5
  294. package/src/host.ts +29 -1
  295. package/src/index.ts +5 -0
  296. package/src/lazy.tsx +9 -0
  297. package/src/locales/en/agent-chat.ts +1 -0
  298. package/src/locales/nl/agent-chat.ts +1 -0
  299. package/src/mounted-registry.ts +4 -0
  300. package/src/port-transport.ts +32 -0
  301. package/src/prompts/index.ts +2 -0
  302. package/src/prompts/logic/focus.ts +5 -0
  303. package/src/prompts/logic/keys.ts +12 -0
  304. package/src/prompts/logic/prompts.ts +8 -0
  305. package/src/prompts/logic/subjects.ts +8 -0
  306. package/src/prompts/logic/useFocusAfterAnswer.ts +2 -0
  307. package/src/prompts/logic/usePromptSession.ts +13 -1
  308. package/src/prompts/ui/ApprovalBody.tsx +2 -0
  309. package/src/prompts/ui/PromptActions.tsx +2 -0
  310. package/src/prompts/ui/PromptCard.tsx +6 -0
  311. package/src/prompts/ui/PromptView.tsx +6 -0
  312. package/src/prompts/ui/QuestionBody.tsx +11 -0
  313. package/src/providers/AccountColors.tsx +1 -0
  314. package/src/providers/AccountDetail.tsx +7 -0
  315. package/src/providers/AccountVariables.tsx +2 -0
  316. package/src/providers/AddAccountForm.tsx +5 -1
  317. package/src/providers/CliDetail.tsx +6 -5
  318. package/src/providers/InstallPage.tsx +11 -0
  319. package/src/providers/ProviderList.tsx +3 -0
  320. package/src/providers/ProvidersPane.tsx +18 -0
  321. package/src/providers/account-actions.ts +10 -8
  322. package/src/providers/index.ts +1 -0
  323. package/src/providers/install-steps.ts +3 -0
  324. package/src/providers/pane-target.ts +5 -0
  325. package/src/providers/provider-abilities.ts +1 -0
  326. package/src/providers/provider-groups.ts +6 -0
  327. package/src/providers/variables.ts +12 -0
  328. package/src/scope.ts +2 -0
  329. package/src/state/chats.ts +61 -14
  330. package/src/state/index.ts +2 -0
  331. package/src/state/provider-accounts.ts +7 -9
  332. package/src/state/providers.ts +1 -0
  333. package/src/state/usage.ts +6 -0
  334. package/src/storage.ts +18 -0
  335. package/src/testing/prompts.ts +5 -0
  336. package/src/theme.css +3 -0
  337. package/src/transport.ts +18 -0
  338. package/src/usage/ChartLogo.tsx +12 -0
  339. package/src/usage/LimitsList.tsx +7 -8
  340. package/src/usage/UsageBreakdown.tsx +11 -4
  341. package/src/usage/UsageChart.tsx +5 -0
  342. package/src/usage/UsageLimits.tsx +10 -7
  343. package/src/usage/UsageLimitsCard.tsx +2 -0
  344. package/src/usage/UsagePage.tsx +16 -19
  345. package/src/usage/UsageSummary.tsx +4 -5
  346. package/src/usage/UsageTiles.tsx +2 -0
  347. package/src/usage/format.ts +7 -0
  348. package/src/usage/limit-groups.ts +14 -0
  349. package/src/usage/limits.ts +11 -13
  350. package/src/usage/money.ts +1 -0
  351. package/src/usage/summary.ts +15 -7
@@ -1,6 +1,7 @@
1
1
  import { type Ref } from 'react';
2
2
  import type { ChatInfo } from '@adecore/agent-contracts';
3
3
  import { type Shortcut } from '@adecore/ui';
4
+ import { type ComposerSendAction, type ComposerSendDraft } from '../../../host.js';
4
5
  import type { StashedPrompt } from '../../stash.js';
5
6
  import type { ChatControls } from './use-chat-controls.js';
6
7
  interface SendProps {
@@ -10,6 +11,8 @@ interface SendProps {
10
11
  kbd: Shortcut;
11
12
  onSend(alternate: boolean): void;
12
13
  onContinue: (() => void) | null;
14
+ actions: readonly ComposerSendAction[];
15
+ draft: ComposerSendDraft;
13
16
  }
14
17
  interface ComposerControlsProps {
15
18
  chatId: string;
@@ -1,19 +1,225 @@
1
1
  import { c as _c } from "react/compiler-runtime";
2
- import { useRef } from 'react';
2
+ import { useRef, useState } from 'react';
3
3
  import { useTranslation } from 'react-i18next';
4
- import { ArrowUp, Play, Plus, Square } from 'lucide-react';
5
- import { Button, ErrorBoundary, Icon, Tooltip } from '@adecore/ui';
4
+ import clsx from 'clsx';
5
+ import { ArrowUp, ChevronDown, Play, Plus, Square } from 'lucide-react';
6
+ import { Button, ErrorBoundary, Icon, Menu, Tooltip } from '@adecore/ui';
6
7
  import { useChatHost } from '../../../host.js';
7
8
  import { useChatScope } from '../../../scope.js';
8
9
  import { useProviders } from '../../../state/providers.js';
9
10
  import { useAccountChoice } from '../../account-choice.js';
10
11
  import { composerStopLabel } from '../../subagent-list.js';
12
+ import { HostMenuItems } from '../HostMenuItems.js';
11
13
  import { StashPicker } from '../Pickers.js';
12
14
  import { RunSettings } from '../RunSettings.js';
13
- /* The row under the box: attach, the chat's settings, the stash, the app's own control, and stop and send. */
15
+ /* The send button, split with a chevron that opens the host's send actions when it has any. */
14
16
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
17
+ function SendButton(t0) {
18
+ const $ = _c(38);
19
+ const {
20
+ send,
21
+ writable
22
+ } = t0;
23
+ const {
24
+ t
25
+ } = useTranslation("agent-chat");
26
+ const [box, setBox] = useState(null);
27
+ const split = send.actions.length > 0;
28
+ const t1 = send.label;
29
+ const t2 = send.kbd;
30
+ const t3 = split ? "focus-visible:-outline-offset-2" : "rounded-full";
31
+ let t4;
32
+ if ($[0] !== t3) {
33
+ t4 = clsx("flex h-9 w-9 shrink-0 items-center justify-center bg-accent text-accent-text hover:brightness-90 disabled:opacity-50 disabled:hover:brightness-100", t3);
34
+ $[0] = t3;
35
+ $[1] = t4;
36
+ } else {
37
+ t4 = $[1];
38
+ }
39
+ let t5;
40
+ if ($[2] !== send) {
41
+ t5 = event => send.onSend(event.altKey);
42
+ $[2] = send;
43
+ $[3] = t5;
44
+ } else {
45
+ t5 = $[3];
46
+ }
47
+ let t6;
48
+ if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
49
+ t6 = /*#__PURE__*/_jsx(Icon, {
50
+ icon: ArrowUp,
51
+ size: 16
52
+ });
53
+ $[4] = t6;
54
+ } else {
55
+ t6 = $[4];
56
+ }
57
+ let t7;
58
+ if ($[5] !== send.disabled || $[6] !== t4 || $[7] !== t5) {
59
+ t7 = /*#__PURE__*/_jsx("button", {
60
+ className: t4,
61
+ disabled: send.disabled,
62
+ onClick: t5,
63
+ children: t6
64
+ });
65
+ $[5] = send.disabled;
66
+ $[6] = t4;
67
+ $[7] = t5;
68
+ $[8] = t7;
69
+ } else {
70
+ t7 = $[8];
71
+ }
72
+ let t8;
73
+ if ($[9] !== send.kbd || $[10] !== send.label || $[11] !== t7) {
74
+ t8 = /*#__PURE__*/_jsx(Tooltip, {
75
+ label: t1,
76
+ kbd: t2,
77
+ name: true,
78
+ children: t7
79
+ });
80
+ $[9] = send.kbd;
81
+ $[10] = send.label;
82
+ $[11] = t7;
83
+ $[12] = t8;
84
+ } else {
85
+ t8 = $[12];
86
+ }
87
+ const button = t8;
88
+ if (!split) {
89
+ return button;
90
+ }
91
+ const {
92
+ draft
93
+ } = send;
94
+ let t9;
95
+ if ($[13] !== t) {
96
+ t9 = t("composer.sendActions");
97
+ $[13] = t;
98
+ $[14] = t9;
99
+ } else {
100
+ t9 = $[14];
101
+ }
102
+ let t10;
103
+ if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
104
+ t10 = /*#__PURE__*/_jsx("button", {
105
+ type: "button",
106
+ className: "relative flex h-9 w-6 shrink-0 items-center justify-center bg-accent text-accent-text before:absolute before:inset-y-0 before:left-0 before:my-auto before:h-4 before:w-px before:bg-current/30 before:content-[\"\"] hover:brightness-90 focus-visible:-outline-offset-2 disabled:opacity-50 disabled:hover:brightness-100"
107
+ });
108
+ $[15] = t10;
109
+ } else {
110
+ t10 = $[15];
111
+ }
112
+ const t11 = !writable;
113
+ let t12;
114
+ if ($[16] === Symbol.for("react.memo_cache_sentinel")) {
115
+ t12 = /*#__PURE__*/_jsx(Icon, {
116
+ icon: ChevronDown,
117
+ size: 14
118
+ });
119
+ $[16] = t12;
120
+ } else {
121
+ t12 = $[16];
122
+ }
123
+ let t13;
124
+ if ($[17] !== t11) {
125
+ t13 = /*#__PURE__*/_jsx(Menu.Trigger, {
126
+ render: t10,
127
+ disabled: t11,
128
+ children: t12
129
+ });
130
+ $[17] = t11;
131
+ $[18] = t13;
132
+ } else {
133
+ t13 = $[18];
134
+ }
135
+ let t14;
136
+ if ($[19] !== t13 || $[20] !== t9) {
137
+ t14 = /*#__PURE__*/_jsx(Tooltip, {
138
+ label: t9,
139
+ name: true,
140
+ children: t13
141
+ });
142
+ $[19] = t13;
143
+ $[20] = t9;
144
+ $[21] = t14;
145
+ } else {
146
+ t14 = $[21];
147
+ }
148
+ let t15;
149
+ if ($[22] !== draft || $[23] !== send.actions) {
150
+ let t16;
151
+ if ($[25] !== draft) {
152
+ t16 = action => ({
153
+ ...action,
154
+ run: () => action.run(draft)
155
+ });
156
+ $[25] = draft;
157
+ $[26] = t16;
158
+ } else {
159
+ t16 = $[26];
160
+ }
161
+ t15 = send.actions.map(t16);
162
+ $[22] = draft;
163
+ $[23] = send.actions;
164
+ $[24] = t15;
165
+ } else {
166
+ t15 = $[24];
167
+ }
168
+ let t16;
169
+ if ($[27] !== t15) {
170
+ t16 = /*#__PURE__*/_jsx(HostMenuItems, {
171
+ actions: t15
172
+ });
173
+ $[27] = t15;
174
+ $[28] = t16;
175
+ } else {
176
+ t16 = $[28];
177
+ }
178
+ let t17;
179
+ if ($[29] !== box || $[30] !== t16) {
180
+ t17 = /*#__PURE__*/_jsx(Menu.Popup, {
181
+ anchor: box,
182
+ side: "top",
183
+ sideOffset: 8,
184
+ align: "end",
185
+ className: "min-w-48",
186
+ children: t16
187
+ });
188
+ $[29] = box;
189
+ $[30] = t16;
190
+ $[31] = t17;
191
+ } else {
192
+ t17 = $[31];
193
+ }
194
+ let t18;
195
+ if ($[32] !== t14 || $[33] !== t17) {
196
+ t18 = /*#__PURE__*/_jsxs(Menu.Root, {
197
+ children: [t14, t17]
198
+ });
199
+ $[32] = t14;
200
+ $[33] = t17;
201
+ $[34] = t18;
202
+ } else {
203
+ t18 = $[34];
204
+ }
205
+ let t19;
206
+ if ($[35] !== button || $[36] !== t18) {
207
+ t19 = /*#__PURE__*/_jsxs("div", {
208
+ ref: setBox,
209
+ className: "flex h-9 shrink-0 overflow-clip rounded-full",
210
+ children: [button, t18]
211
+ });
212
+ $[35] = button;
213
+ $[36] = t18;
214
+ $[37] = t19;
215
+ } else {
216
+ t19 = $[37];
217
+ }
218
+ return t19;
219
+ }
220
+ /* The row under the box: attach, the chat's settings, the stash, the app's own control, and stop and send. */
15
221
  export function ComposerControls(t0) {
16
- const $ = _c(75);
222
+ const $ = _c(76);
17
223
  const {
18
224
  chatId,
19
225
  info,
@@ -282,55 +488,46 @@ export function ComposerControls(t0) {
282
488
  t16 = $[60];
283
489
  }
284
490
  let t17;
285
- if ($[61] !== send) {
286
- t17 = send.onContinue === null && send.visible && /*#__PURE__*/_jsx(Tooltip, {
287
- label: send.label,
288
- kbd: send.kbd,
289
- name: true,
290
- children: /*#__PURE__*/_jsx("button", {
291
- className: "flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-accent text-accent-text hover:brightness-90 disabled:opacity-50 disabled:hover:brightness-100",
292
- disabled: send.disabled,
293
- onClick: event_0 => send.onSend(event_0.altKey),
294
- children: /*#__PURE__*/_jsx(Icon, {
295
- icon: ArrowUp,
296
- size: 16
297
- })
298
- })
491
+ if ($[61] !== send || $[62] !== writable) {
492
+ t17 = send.onContinue === null && send.visible && /*#__PURE__*/_jsx(SendButton, {
493
+ send: send,
494
+ writable: writable
299
495
  });
300
496
  $[61] = send;
301
- $[62] = t17;
497
+ $[62] = writable;
498
+ $[63] = t17;
302
499
  } else {
303
- t17 = $[62];
500
+ t17 = $[63];
304
501
  }
305
502
  let t18;
306
- if ($[63] !== t14 || $[64] !== t15 || $[65] !== t16 || $[66] !== t17) {
503
+ if ($[64] !== t14 || $[65] !== t15 || $[66] !== t16 || $[67] !== t17) {
307
504
  t18 = /*#__PURE__*/_jsxs("div", {
308
505
  className: "flex h-9 shrink-0 items-center gap-0.5 rounded-full bg-surface-hover",
309
506
  children: [t14, t15, t16, t17]
310
507
  });
311
- $[63] = t14;
312
- $[64] = t15;
313
- $[65] = t16;
314
- $[66] = t17;
315
- $[67] = t18;
508
+ $[64] = t14;
509
+ $[65] = t15;
510
+ $[66] = t16;
511
+ $[67] = t17;
512
+ $[68] = t18;
316
513
  } else {
317
- t18 = $[67];
514
+ t18 = $[68];
318
515
  }
319
516
  let t19;
320
- if ($[68] !== t10 || $[69] !== t11 || $[70] !== t12 || $[71] !== t18 || $[72] !== t3 || $[73] !== t4) {
517
+ if ($[69] !== t10 || $[70] !== t11 || $[71] !== t12 || $[72] !== t18 || $[73] !== t3 || $[74] !== t4) {
321
518
  t19 = /*#__PURE__*/_jsxs("div", {
322
519
  className: "flex items-center gap-2 pt-3 pr-3.5 pb-3.5 pl-5 @max-md/composer:gap-1.5 @max-md/composer:p-3 @max-md/composer:pt-2.5",
323
520
  children: [t3, t4, t10, t11, t12, t13, t18]
324
521
  });
325
- $[68] = t10;
326
- $[69] = t11;
327
- $[70] = t12;
328
- $[71] = t18;
329
- $[72] = t3;
330
- $[73] = t4;
331
- $[74] = t19;
332
- } else {
333
- t19 = $[74];
522
+ $[69] = t10;
523
+ $[70] = t11;
524
+ $[71] = t12;
525
+ $[72] = t18;
526
+ $[73] = t3;
527
+ $[74] = t4;
528
+ $[75] = t19;
529
+ } else {
530
+ t19 = $[75];
334
531
  }
335
532
  return t19;
336
533
  }
@@ -13,8 +13,8 @@ interface KeyHandlerInput {
13
13
  history: PromptHistory;
14
14
  noteKey(e: KeyboardEvent): void;
15
15
  toggleStash(): void;
16
- setText(next: string): void;
17
16
  submit(how: ComposerSend): void;
18
17
  }
18
+ export declare function pickInMenu(e: KeyboardEvent, menus: ComposerMenus): boolean;
19
19
  export declare function composerKeyHandler(input: KeyHandlerInput): (e: KeyboardEvent, view: EditorView) => boolean;
20
20
  export {};
@@ -37,10 +37,7 @@ function indentInFence(e, view) {
37
37
  return true;
38
38
  }
39
39
  /* The keys an open picker takes: the arrows walk it, and Tab (or Enter, outside the commands) picks. */
40
- function pickInMenu(e, {
41
- menus,
42
- setText
43
- }) {
40
+ export function pickInMenu(e, menus) {
44
41
  const {
45
42
  activeIndex
46
43
  } = menus;
@@ -49,12 +46,7 @@ function pickInMenu(e, {
49
46
  return true;
50
47
  }
51
48
  if (e.key === 'Tab') {
52
- const chosen = menus.commands[activeIndex];
53
- if (chosen.skill) {
54
- menus.chooseSkill(chosen.name);
55
- } else {
56
- setText(`/${chosen.name} `);
57
- }
49
+ menus.completeCommand(menus.commands[activeIndex]);
58
50
  return true;
59
51
  }
60
52
  }
@@ -187,7 +179,7 @@ export function composerKeyHandler(input) {
187
179
  input.toggleStash();
188
180
  return true;
189
181
  }
190
- if (pickInMenu(e, input)) {
182
+ if (pickInMenu(e, input.menus)) {
191
183
  return true;
192
184
  }
193
185
  if (e.key === 'Tab' && !e.altKey && !e.metaKey && !e.ctrlKey && indentInFence(e, view)) {
@@ -0,0 +1,4 @@
1
+ import type { ChatSendExtras } from '../../chat-client.js';
2
+ import { type Referables } from '../../chat-references.js';
3
+ import type { PromptDraft } from './use-prompt-menus.js';
4
+ export declare function promptPicks(value: PromptDraft, referables: Referables): Pick<ChatSendExtras, 'mentions' | 'skills' | 'chats' | 'references'>;
@@ -0,0 +1,14 @@
1
+ import { referenceTokens } from '../../chat-references.js';
2
+ import { presentMentions, presentReferences, presentSkills } from '../../mentions.js';
3
+ /* What a prompt still holds of what was picked in it, as a send of the composer carries it. */
4
+ export function promptPicks(value, referables) {
5
+ const text = value.text.trim();
6
+ const tokens = referenceTokens([...value.chats, ...value.references], referables.items, value.referenceNames);
7
+ return {
8
+ mentions: presentMentions(text, value.mentions),
9
+ skills: presentSkills(text, value.skills),
10
+ chats: presentReferences(text, value.chats, tokens),
11
+ // A machine that resolves only chats would drop the rest.
12
+ references: referables.chatsOnly ? [] : presentReferences(text, value.references, tokens)
13
+ };
14
+ }
@@ -1,17 +1,10 @@
1
1
  import { type RefObject } from 'react';
2
- import type { EditorState } from '@codemirror/state';
3
2
  import type { ChatInfo, ProviderCapabilities } from '@adecore/agent-contracts';
4
- import { type Referable } from '../../chat-references.js';
5
- import { type MentionQuery, type TextRange } from '../../mentions.js';
6
3
  import type { ComposerInputHandle } from '../ComposerInput.js';
7
4
  import type { ComposerDraft } from './use-composer-draft.js';
5
+ import { type PromptMenus } from './use-prompt-menus.js';
6
+ export type { ComposerCommand } from './use-prompt-menus.js';
8
7
  export declare const LOCAL_COMMANDS: string[];
9
- export interface ComposerCommand {
10
- name: string;
11
- hint: string;
12
- local: boolean;
13
- skill: boolean;
14
- }
15
8
  interface MenusInput {
16
9
  chatId: string;
17
10
  info: ChatInfo;
@@ -20,43 +13,5 @@ interface MenusInput {
20
13
  draft: ComposerDraft;
21
14
  inputRef: RefObject<ComposerInputHandle | null>;
22
15
  }
23
- export declare function useComposerMenus({ chatId, info, capabilities, providerName, draft: { draft, setDraft, setText }, inputRef }: MenusInput): {
24
- listId: string;
25
- activeIndex: number;
26
- inputAria: Record<string, string>;
27
- hasSkills: boolean;
28
- skillNames: string[];
29
- commandQuery: string | null;
30
- commands: ComposerCommand[];
31
- commandMenuOpen: boolean;
32
- skillMatches: {
33
- name: string;
34
- description: string;
35
- source: "plugin" | "project" | "user";
36
- }[];
37
- skillMenuOpen: boolean;
38
- mention: MentionQuery | null;
39
- mentionMenuOpen: boolean;
40
- mentionCount: number;
41
- files: string[];
42
- referenceMenuOpen: boolean;
43
- referenceMatches: Referable[];
44
- referables: import("../../index.js").Referables;
45
- referenceChips: {
46
- id: string;
47
- name: string;
48
- kind: import("../../index.js").ReferableKind | null;
49
- }[];
50
- setMenuIndex: import("react").Dispatch<import("react").SetStateAction<number>>;
51
- trackTriggers: (value: string, selection: TextRange, state: EditorState) => void;
52
- close: () => void;
53
- chooseMention: (path: string) => void;
54
- chooseMentionAt: (index: number) => void;
55
- chooseReference: (item: Referable) => void;
56
- chooseReferenceAt: (index: number) => void;
57
- chooseSkill: (name: string) => void;
58
- pickCommand: (command: ComposerCommand, index: number) => void;
59
- moveInMenu: (key: string, count: number) => boolean;
60
- };
61
- export type ComposerMenus = ReturnType<typeof useComposerMenus>;
62
- export {};
16
+ export declare function useComposerMenus({ chatId, info, capabilities, providerName, draft, inputRef }: MenusInput): PromptMenus;
17
+ export type ComposerMenus = PromptMenus;