@adecore/agents-react 0.23.0 → 0.24.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 (341) hide show
  1. package/README.md +14 -11
  2. package/dist/agents/AccountDot.js +3 -1
  3. package/dist/agents/accounts.d.ts +3 -2
  4. package/dist/agents/accounts.js +5 -6
  5. package/dist/chat/actions.d.ts +2 -2
  6. package/dist/chat/actions.js +8 -5
  7. package/dist/chat/bookmarks.d.ts +5 -3
  8. package/dist/chat/bookmarks.js +13 -14
  9. package/dist/chat/chat-client.d.ts +1 -0
  10. package/dist/chat/chat-client.js +7 -0
  11. package/dist/chat/composer-send.d.ts +3 -0
  12. package/dist/chat/composer-send.js +22 -0
  13. package/dist/chat/forks.js +22 -5
  14. package/dist/chat/index.d.ts +31 -0
  15. package/dist/chat/index.js +28 -0
  16. package/dist/chat/logic/embedded-code.d.ts +8 -0
  17. package/dist/chat/logic/embedded-code.js +371 -0
  18. package/dist/chat/logic/fork.js +1 -0
  19. package/dist/chat/logic/goal.d.ts +6 -0
  20. package/dist/chat/logic/goal.js +26 -0
  21. package/dist/chat/logic/scrubber.d.ts +1 -1
  22. package/dist/chat/logic/scrubber.js +6 -5
  23. package/dist/chat/logic/thought.d.ts +3 -0
  24. package/dist/chat/logic/thought.js +35 -0
  25. package/dist/chat/logic/thread-cards.js +2 -0
  26. package/dist/chat/logic/timeline.d.ts +5 -0
  27. package/dist/chat/logic/timeline.js +22 -1
  28. package/dist/chat/logic/tool-catalog.d.ts +1 -0
  29. package/dist/chat/logic/tool-catalog.js +3 -1
  30. package/dist/chat/logic/tools.d.ts +14 -0
  31. package/dist/chat/logic/tools.js +57 -0
  32. package/dist/chat/preferences.d.ts +6 -0
  33. package/dist/chat/preferences.js +19 -3
  34. package/dist/chat/reading-width.d.ts +9 -0
  35. package/dist/chat/reading-width.js +27 -0
  36. package/dist/chat/send-key.d.ts +10 -0
  37. package/dist/chat/send-key.js +24 -0
  38. package/dist/chat/ui/BookmarkMarker.js +4 -2
  39. package/dist/chat/ui/BookmarkSubmenu.js +4 -3
  40. package/dist/chat/ui/ChatActivity.js +14 -10
  41. package/dist/chat/ui/ChatReferenceChip.js +3 -4
  42. package/dist/chat/ui/CodeBlock.d.ts +2 -1
  43. package/dist/chat/ui/CodeBlock.js +14 -96
  44. package/dist/chat/ui/Composer.d.ts +1 -1
  45. package/dist/chat/ui/Composer.js +117 -906
  46. package/dist/chat/ui/ComposerInput.js +5 -4
  47. package/dist/chat/ui/EditDiff.js +3 -2
  48. package/dist/chat/ui/GoalDock.d.ts +9 -0
  49. package/dist/chat/ui/GoalDock.js +63 -0
  50. package/dist/chat/ui/LimitState.js +5 -3
  51. package/dist/chat/ui/Markdown.d.ts +2 -1
  52. package/dist/chat/ui/Markdown.js +70 -31
  53. package/dist/chat/ui/MermaidBlock.d.ts +3 -0
  54. package/dist/chat/ui/MermaidBlock.js +73 -0
  55. package/dist/chat/ui/MessageActions.js +12 -7
  56. package/dist/chat/ui/Pickers.js +6 -5
  57. package/dist/chat/ui/PromptComposer.js +4 -3
  58. package/dist/chat/ui/RowTime.d.ts +3 -0
  59. package/dist/chat/ui/RowTime.js +12 -0
  60. package/dist/chat/ui/RunSettings.js +5 -4
  61. package/dist/chat/ui/ShellCommand.d.ts +3 -0
  62. package/dist/chat/ui/ShellCommand.js +110 -0
  63. package/dist/chat/ui/SubagentInfo.js +4 -3
  64. package/dist/chat/ui/SubagentStopButton.js +4 -3
  65. package/dist/chat/ui/SubagentTimeline.js +4 -1
  66. package/dist/chat/ui/Timeline.js +70 -40
  67. package/dist/chat/ui/TimelineMenu.d.ts +2 -1
  68. package/dist/chat/ui/TimelineMenu.js +18 -8
  69. package/dist/chat/ui/UnifiedDiff.js +3 -2
  70. package/dist/chat/ui/VisualFrame.js +6 -7
  71. package/dist/chat/ui/code-theme.d.ts +2 -1
  72. package/dist/chat/ui/code-theme.js +4 -4
  73. package/dist/chat/ui/composer/ComposerControls.d.ts +27 -0
  74. package/dist/chat/ui/composer/ComposerControls.js +34 -0
  75. package/dist/chat/ui/composer/ComposerMenu.d.ts +4 -0
  76. package/dist/chat/ui/composer/ComposerMenu.js +46 -0
  77. package/dist/chat/ui/composer/DraftParts.d.ts +18 -0
  78. package/dist/chat/ui/composer/DraftParts.js +25 -0
  79. package/dist/chat/ui/composer/QueuedMessages.d.ts +10 -0
  80. package/dist/chat/ui/composer/QueuedMessages.js +20 -0
  81. package/dist/chat/ui/composer/key-handler.d.ts +20 -0
  82. package/dist/chat/ui/composer/key-handler.js +150 -0
  83. package/dist/chat/ui/composer/keys.d.ts +7 -2
  84. package/dist/chat/ui/composer/keys.js +19 -9
  85. package/dist/chat/ui/composer/placeholder.d.ts +9 -0
  86. package/dist/chat/ui/composer/placeholder.js +38 -0
  87. package/dist/chat/ui/composer/use-chat-controls.d.ts +28 -0
  88. package/dist/chat/ui/composer/use-chat-controls.js +112 -0
  89. package/dist/chat/ui/composer/use-compaction-offer.d.ts +2 -0
  90. package/dist/chat/ui/composer/use-compaction-offer.js +23 -0
  91. package/dist/chat/ui/composer/use-composer-draft.d.ts +14 -0
  92. package/dist/chat/ui/composer/use-composer-draft.js +39 -0
  93. package/dist/chat/ui/composer/use-composer-menus.d.ts +52 -0
  94. package/dist/chat/ui/composer/use-composer-menus.js +232 -0
  95. package/dist/chat/ui/composer/use-composer-submit.d.ts +32 -0
  96. package/dist/chat/ui/composer/use-composer-submit.js +113 -0
  97. package/dist/chat/ui/composer/use-draft-files.d.ts +27 -0
  98. package/dist/chat/ui/composer/use-draft-files.js +111 -0
  99. package/dist/chat/ui/composer/use-notice.d.ts +6 -0
  100. package/dist/chat/ui/composer/use-notice.js +18 -0
  101. package/dist/chat/ui/composer/use-pending-requests.d.ts +2 -0
  102. package/dist/chat/ui/composer/use-pending-requests.js +22 -0
  103. package/dist/chat/ui/composer/use-prompt-history.d.ts +8 -0
  104. package/dist/chat/ui/composer/use-prompt-history.js +57 -0
  105. package/dist/chat/ui/composer/use-prompt-hold.d.ts +6 -0
  106. package/dist/chat/ui/composer/use-prompt-hold.js +48 -0
  107. package/dist/chat/ui/composer/use-take-back.d.ts +13 -0
  108. package/dist/chat/ui/composer/use-take-back.js +82 -0
  109. package/dist/chat/ui/diff/EditorEditDiff.js +4 -3
  110. package/dist/chat/ui/diff/LegacyDiffPool.js +3 -2
  111. package/dist/chat/ui/diff/LegacyEditDiff.js +3 -2
  112. package/dist/chat/ui/diff/LegacyUnifiedDiff.js +3 -2
  113. package/dist/chat/ui/diff/syntax-runtime.d.ts +2 -1
  114. package/dist/chat/ui/diff/syntax-runtime.js +9 -5
  115. package/dist/chat/ui/diff-syntax.d.ts +2 -2
  116. package/dist/chat/ui/diff-syntax.js +1 -2
  117. package/dist/chat/ui/diff-theme.js +10 -9
  118. package/dist/chat/ui/file-links.d.ts +1 -1
  119. package/dist/chat/ui/file-links.js +7 -5
  120. package/dist/chat/ui/highlighter.d.ts +27 -0
  121. package/dist/chat/ui/highlighter.js +151 -0
  122. package/dist/chat/ui/index.d.ts +67 -0
  123. package/dist/chat/ui/index.js +64 -0
  124. package/dist/chat/ui/intelligent-ui/UiReply.js +3 -2
  125. package/dist/chat/ui/intelligent-ui/renderers/content.js +3 -2
  126. package/dist/chat/ui/intelligent-ui/use-ui-links.js +2 -2
  127. package/dist/chat/ui/intelligent-ui/use-ui-queries.js +4 -3
  128. package/dist/chat/ui/markdown-blocks.d.ts +8 -0
  129. package/dist/chat/ui/markdown-blocks.js +260 -12
  130. package/dist/chat/ui/mermaid.d.ts +23 -0
  131. package/dist/chat/ui/mermaid.js +93 -0
  132. package/dist/chat/ui/rows/ForksRow.js +5 -3
  133. package/dist/chat/ui/rows/GeneratedImageRow.js +6 -4
  134. package/dist/chat/ui/rows/MessageRows.d.ts +4 -0
  135. package/dist/chat/ui/rows/MessageRows.js +36 -13
  136. package/dist/chat/ui/rows/Rows.js +3 -1
  137. package/dist/chat/ui/rows/SubagentRow.js +3 -2
  138. package/dist/chat/ui/rows/VisualRow.js +3 -2
  139. package/dist/chat/ui/rows/WorkRows.d.ts +6 -3
  140. package/dist/chat/ui/rows/WorkRows.js +57 -20
  141. package/dist/chat/ui/rows/WorkflowRow.js +3 -2
  142. package/dist/chat/ui/timestamp-format.d.ts +1 -0
  143. package/dist/chat/ui/timestamp-format.js +2 -0
  144. package/dist/chat/ui/use-diff-source-tokens.js +6 -3
  145. package/dist/chat/ui/visual-theme.js +3 -2
  146. package/dist/host.d.ts +9 -6
  147. package/dist/host.js +19 -8
  148. package/dist/index.d.ts +8 -0
  149. package/dist/index.js +9 -0
  150. package/dist/locales/en/agent-chat.d.ts +658 -0
  151. package/dist/locales/en/agent-chat.js +657 -0
  152. package/dist/locales/en/agent-prompts.d.ts +44 -0
  153. package/dist/locales/en/agent-prompts.js +43 -0
  154. package/dist/locales/en/agent-providers.d.ts +132 -0
  155. package/dist/locales/en/agent-providers.js +131 -0
  156. package/dist/locales/en/agent-usage.d.ts +132 -0
  157. package/dist/locales/en/agent-usage.js +131 -0
  158. package/dist/locales/nl/agent-chat.d.ts +658 -0
  159. package/dist/locales/nl/agent-chat.js +657 -0
  160. package/dist/locales/nl/agent-prompts.d.ts +44 -0
  161. package/dist/locales/nl/agent-prompts.js +43 -0
  162. package/dist/locales/nl/agent-providers.d.ts +132 -0
  163. package/dist/locales/nl/agent-providers.js +131 -0
  164. package/dist/locales/nl/agent-usage.d.ts +132 -0
  165. package/dist/locales/nl/agent-usage.js +131 -0
  166. package/dist/locales.js +9 -8
  167. package/dist/prompts/index.d.ts +11 -0
  168. package/dist/prompts/index.js +12 -0
  169. package/dist/prompts/logic/subjects.d.ts +2 -1
  170. package/dist/prompts/logic/subjects.js +6 -4
  171. package/dist/prompts/ui/ApprovalBody.js +6 -4
  172. package/dist/prompts/ui/PromptCard.js +5 -4
  173. package/dist/prompts/ui/PromptView.js +3 -2
  174. package/dist/prompts/ui/QuestionBody.js +3 -2
  175. package/dist/providers/AccountColors.js +2 -2
  176. package/dist/providers/AccountDetail.js +7 -6
  177. package/dist/providers/AccountVariables.js +3 -1
  178. package/dist/providers/AddAccountForm.js +3 -2
  179. package/dist/providers/ProvidersPane.js +4 -3
  180. package/dist/providers/account-actions.d.ts +4 -3
  181. package/dist/providers/account-actions.js +6 -7
  182. package/dist/providers/index.d.ts +16 -0
  183. package/dist/providers/index.js +17 -0
  184. package/dist/providers/provider-abilities.d.ts +2 -1
  185. package/dist/providers/provider-abilities.js +4 -0
  186. package/dist/state/chats.js +4 -2
  187. package/dist/state/index.d.ts +4 -0
  188. package/dist/state/index.js +5 -0
  189. package/dist/testing/index.d.ts +1 -0
  190. package/dist/testing/index.js +2 -0
  191. package/dist/{prompts/logic/prompts.fixtures.d.ts → testing/prompts.d.ts} +1 -1
  192. package/dist/theme.css +13 -3
  193. package/dist/usage/UsageBreakdown.js +3 -2
  194. package/dist/usage/UsageLimits.js +4 -3
  195. package/dist/usage/UsagePage.js +3 -2
  196. package/dist/usage/index.d.ts +15 -0
  197. package/dist/usage/index.js +15 -0
  198. package/package.json +53 -1031
  199. package/src/agents/AccountDot.tsx +3 -1
  200. package/src/agents/accounts.ts +6 -6
  201. package/src/chat/actions.ts +8 -5
  202. package/src/chat/bookmarks.ts +23 -14
  203. package/src/chat/chat-client.ts +8 -0
  204. package/src/chat/composer-send.ts +27 -0
  205. package/src/chat/forks.ts +27 -6
  206. package/src/chat/index.ts +98 -0
  207. package/src/chat/logic/embedded-code.ts +409 -0
  208. package/src/chat/logic/fork.ts +1 -0
  209. package/src/chat/logic/goal.ts +33 -0
  210. package/src/chat/logic/scrubber.ts +6 -5
  211. package/src/chat/logic/thought.ts +40 -0
  212. package/src/chat/logic/thread-cards.ts +2 -0
  213. package/src/chat/logic/timeline.ts +25 -1
  214. package/src/chat/logic/tool-catalog.ts +5 -1
  215. package/src/chat/logic/tools.ts +76 -0
  216. package/src/chat/preferences.ts +26 -3
  217. package/src/chat/reading-width.ts +39 -0
  218. package/src/chat/send-key.ts +38 -0
  219. package/src/chat/ui/BookmarkMarker.tsx +4 -2
  220. package/src/chat/ui/BookmarkSubmenu.tsx +4 -3
  221. package/src/chat/ui/ChatActivity.tsx +14 -10
  222. package/src/chat/ui/ChatReferenceChip.tsx +3 -4
  223. package/src/chat/ui/CodeBlock.tsx +33 -124
  224. package/src/chat/ui/Composer.tsx +162 -1324
  225. package/src/chat/ui/ComposerInput.tsx +5 -4
  226. package/src/chat/ui/EditDiff.tsx +3 -2
  227. package/src/chat/ui/GoalDock.tsx +104 -0
  228. package/src/chat/ui/LimitState.tsx +5 -3
  229. package/src/chat/ui/Markdown.tsx +113 -39
  230. package/src/chat/ui/MermaidBlock.tsx +119 -0
  231. package/src/chat/ui/MessageActions.tsx +13 -8
  232. package/src/chat/ui/Pickers.tsx +8 -7
  233. package/src/chat/ui/PromptComposer.tsx +4 -3
  234. package/src/chat/ui/RowTime.tsx +21 -0
  235. package/src/chat/ui/RunSettings.tsx +9 -4
  236. package/src/chat/ui/ShellCommand.tsx +134 -0
  237. package/src/chat/ui/SubagentInfo.tsx +4 -3
  238. package/src/chat/ui/SubagentStopButton.tsx +4 -3
  239. package/src/chat/ui/SubagentTimeline.tsx +5 -1
  240. package/src/chat/ui/Timeline.tsx +167 -105
  241. package/src/chat/ui/TimelineMenu.tsx +42 -7
  242. package/src/chat/ui/UnifiedDiff.tsx +3 -2
  243. package/src/chat/ui/VisualFrame.tsx +6 -7
  244. package/src/chat/ui/code-theme.ts +4 -4
  245. package/src/chat/ui/composer/ComposerControls.tsx +147 -0
  246. package/src/chat/ui/composer/ComposerMenu.tsx +138 -0
  247. package/src/chat/ui/composer/DraftParts.tsx +86 -0
  248. package/src/chat/ui/composer/QueuedMessages.tsx +64 -0
  249. package/src/chat/ui/composer/key-handler.ts +174 -0
  250. package/src/chat/ui/composer/keys.ts +32 -10
  251. package/src/chat/ui/composer/placeholder.ts +48 -0
  252. package/src/chat/ui/composer/use-chat-controls.ts +134 -0
  253. package/src/chat/ui/composer/use-compaction-offer.ts +25 -0
  254. package/src/chat/ui/composer/use-composer-draft.ts +71 -0
  255. package/src/chat/ui/composer/use-composer-menus.ts +289 -0
  256. package/src/chat/ui/composer/use-composer-submit.ts +163 -0
  257. package/src/chat/ui/composer/use-draft-files.ts +135 -0
  258. package/src/chat/ui/composer/use-notice.ts +28 -0
  259. package/src/chat/ui/composer/use-pending-requests.ts +23 -0
  260. package/src/chat/ui/composer/use-prompt-history.ts +76 -0
  261. package/src/chat/ui/composer/use-prompt-hold.ts +58 -0
  262. package/src/chat/ui/composer/use-take-back.ts +91 -0
  263. package/src/chat/ui/diff/DiffFallbackBoundary.tsx +2 -2
  264. package/src/chat/ui/diff/EditorEditDiff.tsx +4 -3
  265. package/src/chat/ui/diff/LegacyDiffPool.tsx +3 -2
  266. package/src/chat/ui/diff/LegacyEditDiff.tsx +3 -2
  267. package/src/chat/ui/diff/LegacyUnifiedDiff.tsx +3 -2
  268. package/src/chat/ui/diff/syntax-runtime.ts +10 -5
  269. package/src/chat/ui/diff-syntax.ts +2 -2
  270. package/src/chat/ui/diff-theme.ts +10 -9
  271. package/src/chat/ui/file-links.ts +7 -5
  272. package/src/chat/ui/highlighter.ts +185 -0
  273. package/src/chat/ui/index.ts +109 -0
  274. package/src/chat/ui/intelligent-ui/UiReply.tsx +5 -4
  275. package/src/chat/ui/intelligent-ui/renderers/content.tsx +3 -2
  276. package/src/chat/ui/intelligent-ui/use-ui-links.ts +2 -2
  277. package/src/chat/ui/intelligent-ui/use-ui-queries.ts +4 -3
  278. package/src/chat/ui/markdown-blocks.ts +300 -12
  279. package/src/chat/ui/mermaid.ts +118 -0
  280. package/src/chat/ui/rows/ForksRow.tsx +5 -3
  281. package/src/chat/ui/rows/GeneratedImageRow.tsx +6 -4
  282. package/src/chat/ui/rows/MessageRows.tsx +73 -18
  283. package/src/chat/ui/rows/Rows.tsx +14 -1
  284. package/src/chat/ui/rows/SubagentRow.tsx +3 -2
  285. package/src/chat/ui/rows/VisualRow.tsx +3 -2
  286. package/src/chat/ui/rows/WorkRows.tsx +148 -47
  287. package/src/chat/ui/rows/WorkflowRow.tsx +3 -2
  288. package/src/chat/ui/timestamp-format.ts +2 -0
  289. package/src/chat/ui/use-diff-source-tokens.ts +10 -4
  290. package/src/chat/ui/visual-theme.ts +3 -2
  291. package/src/host.ts +31 -15
  292. package/src/index.ts +49 -0
  293. package/src/locales/en/agent-chat.ts +657 -0
  294. package/src/locales/en/agent-prompts.ts +43 -0
  295. package/src/locales/en/agent-providers.ts +131 -0
  296. package/src/locales/en/agent-usage.ts +131 -0
  297. package/src/locales/nl/agent-chat.ts +657 -0
  298. package/src/locales/nl/agent-prompts.ts +43 -0
  299. package/src/locales/nl/agent-providers.ts +131 -0
  300. package/src/locales/nl/agent-usage.ts +132 -0
  301. package/src/locales.ts +9 -8
  302. package/src/prompts/index.ts +35 -0
  303. package/src/prompts/logic/subjects.ts +12 -4
  304. package/src/prompts/ui/ApprovalBody.tsx +6 -4
  305. package/src/prompts/ui/PromptCard.tsx +11 -4
  306. package/src/prompts/ui/PromptView.tsx +3 -2
  307. package/src/prompts/ui/QuestionBody.tsx +3 -2
  308. package/src/providers/AccountColors.tsx +2 -2
  309. package/src/providers/AccountDetail.tsx +13 -7
  310. package/src/providers/AccountVariables.tsx +3 -1
  311. package/src/providers/AddAccountForm.tsx +3 -2
  312. package/src/providers/ProvidersPane.tsx +4 -3
  313. package/src/providers/account-actions.ts +7 -7
  314. package/src/providers/index.ts +17 -0
  315. package/src/providers/provider-abilities.ts +6 -1
  316. package/src/state/chats.ts +4 -2
  317. package/src/state/index.ts +39 -0
  318. package/src/testing/index.ts +2 -0
  319. package/src/{prompts/logic/prompts.fixtures.ts → testing/prompts.ts} +1 -1
  320. package/src/theme.css +13 -3
  321. package/src/usage/UsageBreakdown.tsx +3 -2
  322. package/src/usage/UsageLimits.tsx +4 -3
  323. package/src/usage/UsagePage.tsx +3 -2
  324. package/src/usage/index.ts +16 -0
  325. package/dist/locales/en/agent-chat.json +0 -597
  326. package/dist/locales/en/agent-prompts.json +0 -43
  327. package/dist/locales/en/agent-providers.json +0 -131
  328. package/dist/locales/en/agent-usage.json +0 -131
  329. package/dist/locales/nl/agent-chat.json +0 -597
  330. package/dist/locales/nl/agent-prompts.json +0 -43
  331. package/dist/locales/nl/agent-providers.json +0 -131
  332. package/dist/locales/nl/agent-usage.json +0 -131
  333. package/src/locales/en/agent-chat.json +0 -597
  334. package/src/locales/en/agent-prompts.json +0 -43
  335. package/src/locales/en/agent-providers.json +0 -131
  336. package/src/locales/en/agent-usage.json +0 -131
  337. package/src/locales/nl/agent-chat.json +0 -597
  338. package/src/locales/nl/agent-prompts.json +0 -43
  339. package/src/locales/nl/agent-providers.json +0 -131
  340. package/src/locales/nl/agent-usage.json +0 -131
  341. /package/dist/{prompts/logic/prompts.fixtures.js → testing/prompts.js} +0 -0
@@ -7,7 +7,7 @@ import {
7
7
  type DiffSyntaxService,
8
8
  type DiffSyntaxTokens
9
9
  } from '@adecore/editor/shiki-worker';
10
- import { chatHost } from '../../../host';
10
+ import type { ChatHost } from '../../../host';
11
11
 
12
12
  interface Pending {
13
13
  promise: Promise<DiffSyntaxTokens | null>;
@@ -39,11 +39,16 @@ export interface DiffSyntaxRuntimeOptions {
39
39
  }
40
40
 
41
41
  let nextGeneration = 0;
42
- let shared: DiffSyntaxRuntime | undefined;
42
+ const shared = new WeakMap<ChatHost['code'], DiffSyntaxRuntime>();
43
43
 
44
- export function diffSyntaxRuntime(): DiffSyntaxRuntime {
45
- const code = chatHost().code;
46
- return (shared ??= createDiffSyntaxRuntime({ workerFactory: code.syntaxWorker, themes: code.custom, highlighter: code.highlighter }));
44
+ /* The runtime of a host's `code`, made on first use and shared by every diff under that host. */
45
+ export function diffSyntaxRuntime(code: ChatHost['code']): DiffSyntaxRuntime {
46
+ let runtime = shared.get(code);
47
+ if (runtime === undefined) {
48
+ runtime = createDiffSyntaxRuntime({ workerFactory: code.syntaxWorker, themes: code.custom, highlighter: code.highlighter });
49
+ shared.set(code, runtime);
50
+ }
51
+ return runtime;
47
52
  }
48
53
 
49
54
  export function createDiffSyntaxRuntime(options: DiffSyntaxRuntimeOptions): DiffSyntaxRuntime {
@@ -1,7 +1,7 @@
1
1
  import type { LineToken } from '@adecore/editor';
2
2
  import { lineTokensOf, type DiffSyntaxDocument } from '@adecore/editor/shiki-worker';
3
3
  import type { DiffDocument } from '@adecore/merge';
4
- import { diffSyntaxRuntime, type DiffSyntaxRuntime } from './diff/syntax-runtime';
4
+ import type { DiffSyntaxRuntime } from './diff/syntax-runtime';
5
5
 
6
6
  export { createDiffSyntaxRuntime, diffSyntaxRuntime } from './diff/syntax-runtime';
7
7
  export type { DiffSyntaxRuntime, DiffSyntaxRuntimeOptions, DiffSyntaxSession } from './diff/syntax-runtime';
@@ -18,7 +18,7 @@ export interface DiffSourceTokenSession {
18
18
  }
19
19
 
20
20
  /* Structurally accepts the editor's source mapping without depending on its React renderer. */
21
- export function diffSourceTokens(document: DiffDocument, mapping: DiffSyntaxMapping, runtime: DiffSyntaxRuntime = diffSyntaxRuntime()): DiffSourceTokenSession {
21
+ export function diffSourceTokens(document: DiffDocument, mapping: DiffSyntaxMapping, runtime: DiffSyntaxRuntime): DiffSourceTokenSession {
22
22
  const sides = { old: runtime.open(mapping.documents.old), new: runtime.open(mapping.documents.new) };
23
23
  const cache = { old: new Map<number, ReadonlyArray<readonly LineToken[] | null>>(), new: new Map<number, ReadonlyArray<readonly LineToken[] | null>>() };
24
24
  const pending = { old: new Set<number>(), new: new Set<number>() };
@@ -1,23 +1,24 @@
1
1
  import { useMemo } from 'react';
2
2
  import { registerCustomTheme, type ThemesType } from '@pierre/diffs';
3
- import { chatHost } from '../../host';
3
+ import { useChatHost, type ChatHost } from '../../host';
4
4
 
5
- let registered = false;
5
+ const registered = new WeakSet<ChatHost['code']['custom']>();
6
6
 
7
- /* The library resolves Shiki's bundled themes by id on its own; the app's own it only knows by registration, done once the host is set. */
8
- function registerThemes(): void {
9
- if (registered) {
7
+ /* The library resolves Shiki's bundled themes by id on its own; the app's own it only knows by registration, done once per host. */
8
+ function registerThemes(custom: ChatHost['code']['custom']): void {
9
+ if (registered.has(custom)) {
10
10
  return;
11
11
  }
12
- registered = true;
13
- for (const theme of chatHost().code.custom) {
12
+ registered.add(custom);
13
+ for (const theme of custom) {
14
14
  registerCustomTheme(theme.name, () => Promise.resolve(theme));
15
15
  }
16
16
  }
17
17
 
18
18
  /* The code themes a diff is drawn in, the same pair a chat's code blocks use. */
19
19
  export function useDiffTheme(): ThemesType {
20
- registerThemes();
21
- const { light, dark } = chatHost().code.useThemes();
20
+ const { code } = useChatHost();
21
+ registerThemes(code.custom);
22
+ const { light, dark } = code.useThemes();
22
23
  return useMemo(() => ({ light, dark }), [light, dark]);
23
24
  }
@@ -1,5 +1,5 @@
1
1
  import { createContext, useContext, useMemo } from 'react';
2
- import { chatHost, type FileRef } from '../../host';
2
+ import { useChatHost, type FileRef } from '../../host';
3
3
  import { ChatScopeContext } from '../../scope';
4
4
 
5
5
  /*
@@ -21,10 +21,12 @@ export function useFileLinkScopeId(): string | null {
21
21
  export function useFileLinkTarget(text: string): FileRef | null {
22
22
  const cwd = useFileLinkCwd();
23
23
  const scopeId = useFileLinkScopeId();
24
- return useMemo(() => chatHost().fileLinks?.target(text, cwd, scopeId) ?? null, [text, cwd, scopeId]);
24
+ const { fileLinks } = useChatHost();
25
+ return useMemo(() => fileLinks?.target(text, cwd, scopeId) ?? null, [fileLinks, text, cwd, scopeId]);
25
26
  }
26
27
 
27
- /* A reference followed, the way the app opens a file or a folder. */
28
- export function openFileLink(cwd: string | null, ref: FileRef, scopeId: string | null = null): void {
29
- chatHost().fileLinks?.open(cwd, ref, scopeId);
28
+ /* Follows a reference the way the app opens a file or a folder. */
29
+ export function useOpenFileLink(): (cwd: string | null, ref: FileRef, scopeId?: string | null) => void {
30
+ const { fileLinks } = useChatHost();
31
+ return (cwd, ref, scopeId = null) => fileLinks?.open(cwd, ref, scopeId);
30
32
  }
@@ -0,0 +1,185 @@
1
+ import type { CSSProperties } from 'react';
2
+ import type { BundledLanguage, BundledTheme, Highlighter, ThemeRegistration } from 'shiki';
3
+ import type { CodeToken, Tokenize } from './code-lines';
4
+ import { useChatHost, type ChatHost } from '../../host';
5
+ import { shikiThemeOf } from './code-theme';
6
+
7
+ export type { Highlighter };
8
+ export type GrammarState = ReturnType<Highlighter['getLastGrammarState']>;
9
+ // A plain language needs no grammar; shiki draws it in the theme's own foreground.
10
+ const PLAIN = 'text';
11
+
12
+ /* One highlighter with the grammars and themes asked of it, each loaded once. */
13
+ export interface CodeHighlighter {
14
+ loadLanguage(lang: string): Promise<void>;
15
+ /* Loads a theme: one of `custom` by its name, or a bundled one by its id. */
16
+ loadTheme(theme: string, custom: ChatHost['code']['custom']): Promise<void>;
17
+ /* The highlighter once every one of `langs` and `theme` is in, or null while one is still on its way. */
18
+ ready(langs: Iterable<string>, theme: string): Highlighter | null;
19
+ /* The language shiki draws `lang` in: its own grammar, or plain text. Only meaningful once a load settled. */
20
+ language(lang: string): string;
21
+ /* The tokenizer for a language in a theme, or null while shiki, the grammar or the theme is still on its way. */
22
+ tokenizer(lang: string, theme: string): { tokenize: Tokenize<GrammarState>; fg: string | undefined } | null;
23
+ }
24
+
25
+ /* Plain text when the highlighter has no grammar for `lang`, as a bundle without that language answers. */
26
+ async function grammarOf(loaded: Highlighter, lang: string): Promise<string> {
27
+ if (lang === PLAIN || loaded.getLoadedLanguages().includes(lang)) {
28
+ return lang;
29
+ }
30
+ try {
31
+ await loaded.loadLanguage(lang as BundledLanguage);
32
+ return lang;
33
+ } catch {
34
+ return PLAIN;
35
+ }
36
+ }
37
+
38
+ function createCodeHighlighter(source: () => Promise<Highlighter>): CodeHighlighter {
39
+ let highlighter: Highlighter | null = null;
40
+ let highlighterLoad: Promise<Highlighter> | null = null;
41
+ const languages = new Map<string, string>();
42
+ const languageLoads = new Map<string, Promise<void>>();
43
+ const themes = new Set<string>();
44
+ const themeLoads = new Map<string, Promise<void>>();
45
+ const tokenizers = new Map<string, { tokenize: Tokenize<GrammarState>; fg: string | undefined }>();
46
+
47
+ const load = (): Promise<Highlighter> => {
48
+ highlighterLoad ??= source().then((loaded) => {
49
+ highlighter = loaded;
50
+ return loaded;
51
+ });
52
+ return highlighterLoad;
53
+ };
54
+
55
+ const ready = (langs: Iterable<string>, theme: string): Highlighter | null => {
56
+ if (highlighter === null || !themes.has(theme)) {
57
+ return null;
58
+ }
59
+ for (const lang of langs) {
60
+ if (!languages.has(lang)) {
61
+ return null;
62
+ }
63
+ }
64
+ return highlighter;
65
+ };
66
+
67
+ const language = (lang: string): string => languages.get(lang) ?? PLAIN;
68
+
69
+ return {
70
+ loadLanguage(lang) {
71
+ let pending = languageLoads.get(lang);
72
+ if (!pending) {
73
+ pending = load().then(async (loaded) => {
74
+ languages.set(lang, await grammarOf(loaded, lang));
75
+ });
76
+ languageLoads.set(lang, pending);
77
+ }
78
+ return pending;
79
+ },
80
+ loadTheme(theme, custom) {
81
+ let pending = themeLoads.get(theme);
82
+ if (!pending) {
83
+ pending = load().then(async (loaded) => {
84
+ // Loading a theme the highlighter already has replaces it, under whatever else of the host draws with it.
85
+ if (!loaded.getLoadedThemes().includes(theme)) {
86
+ await loaded.loadTheme(shikiThemeOf(theme, custom) as BundledTheme | ThemeRegistration);
87
+ }
88
+ themes.add(theme);
89
+ });
90
+ themeLoads.set(theme, pending);
91
+ }
92
+ return pending;
93
+ },
94
+ ready,
95
+ language,
96
+ tokenizer(lang, theme) {
97
+ const loaded = ready([lang], theme);
98
+ if (loaded === null) {
99
+ return null;
100
+ }
101
+ const resolved = language(lang);
102
+ const key = `${resolved}:${theme}`;
103
+ let entry = tokenizers.get(key);
104
+ if (!entry) {
105
+ const options = { lang: resolved as BundledLanguage, theme };
106
+ entry = {
107
+ tokenize: (code, state) => {
108
+ const result = loaded.codeToTokens(code, state ? { ...options, grammarState: state } : options);
109
+ return { lines: result.tokens, state: result.grammarState };
110
+ },
111
+ fg: loaded.getTheme(theme).fg
112
+ };
113
+ tokenizers.set(key, entry);
114
+ }
115
+ return entry;
116
+ }
117
+ };
118
+ }
119
+
120
+ // Shiki loads on the first code it draws, not with the app; the web bundle covers the languages a coding agent writes.
121
+ function loadBundled(): Promise<Highlighter> {
122
+ return import('shiki/bundle/web').then(({ createHighlighter }) => createHighlighter({ themes: [], langs: [] }) as Promise<Highlighter>);
123
+ }
124
+
125
+ let bundled: CodeHighlighter | null = null;
126
+ const borrowed = new WeakMap<() => Promise<Highlighter>, CodeHighlighter>();
127
+
128
+ /* The highlighter a host lends, which stays the host's, or without one the web bundle's of this package. */
129
+ export function codeHighlighter(source?: () => Promise<Highlighter>): CodeHighlighter {
130
+ if (source === undefined) {
131
+ bundled ??= createCodeHighlighter(loadBundled);
132
+ return bundled;
133
+ }
134
+ let highlighter = borrowed.get(source);
135
+ if (highlighter === undefined) {
136
+ highlighter = createCodeHighlighter(source);
137
+ borrowed.set(source, highlighter);
138
+ }
139
+ return highlighter;
140
+ }
141
+
142
+ /* The code highlighter of the host this is rendered under. */
143
+ export function useCodeHighlighter(): CodeHighlighter {
144
+ return codeHighlighter(useChatHost().code.highlighter);
145
+ }
146
+
147
+ /* Loads the grammar of one language into the web bundle's highlighter, once. */
148
+ export function loadLanguage(lang: string): Promise<void> {
149
+ return codeHighlighter().loadLanguage(lang);
150
+ }
151
+
152
+ /* Loads a theme into the web bundle's highlighter, once: one of `custom` by its name, or a bundled one by its id. */
153
+ export function loadTheme(theme: string, custom: ChatHost['code']['custom']): Promise<void> {
154
+ return codeHighlighter().loadTheme(theme, custom);
155
+ }
156
+
157
+ /* The web bundle's highlighter once every one of `langs` and `theme` is in, or null while one is still on its way. */
158
+ export function readyHighlighter(langs: Iterable<string>, theme: string): Highlighter | null {
159
+ return codeHighlighter().ready(langs, theme);
160
+ }
161
+
162
+ /* The language the web bundle draws `lang` in: the bundled grammar, or plain text. Only meaningful once a load settled. */
163
+ export function loadedLanguage(lang: string): string {
164
+ return codeHighlighter().language(lang);
165
+ }
166
+
167
+ /* The web bundle's tokenizer for a language in a theme, or null while shiki, the grammar or the theme is still on its way. */
168
+ export function tokenizerFor(lang: string, theme: string): { tokenize: Tokenize<GrammarState>; fg: string | undefined } | null {
169
+ return codeHighlighter().tokenizer(lang, theme);
170
+ }
171
+
172
+ /* The inline style of one token; undefined when it only has the surrounding color. */
173
+ export function tokenStyle(token: CodeToken): CSSProperties | undefined {
174
+ const style = token.fontStyle ?? 0;
175
+ if (token.color === undefined && style <= 0) {
176
+ return undefined;
177
+ }
178
+ const decorations = [style & 4 ? 'underline' : '', style & 8 ? 'line-through' : ''].filter(Boolean).join(' ');
179
+ return {
180
+ color: token.color,
181
+ ...(style & 1 ? { fontStyle: 'italic' } : {}),
182
+ ...(style & 2 ? { fontWeight: 'bold' } : {}),
183
+ ...(decorations ? { textDecoration: decorations } : {})
184
+ };
185
+ }
@@ -0,0 +1,109 @@
1
+ // Public API: exports.test.ts snapshots this list, so a name added or dropped here is an API change.
2
+ export { AccountPill } from './AccountPill';
3
+ export { AnsiOutput } from './AnsiOutput';
4
+ export { BookmarkMarker } from './BookmarkMarker';
5
+ export { BookmarkSubmenu } from './BookmarkSubmenu';
6
+ export { ChatActivity, StatusIcon } from './ChatActivity';
7
+ export { ChatReferenceChip } from './ChatReferenceChip';
8
+ export { CodeBlock } from './CodeBlock';
9
+ export { Composer } from './Composer';
10
+ export { type ComposerInputHandle, ComposerInput, type InputSelection } from './ComposerInput';
11
+ export { default as DiffPool } from './DiffPool';
12
+ export { default as EditDiff } from './EditDiff';
13
+ export { FadingWords } from './FadingWords';
14
+ export { GoalDock, GoalPill } from './GoalDock';
15
+ export { ImageThumb, type ImageThumbProps } from './ImageView';
16
+ export { LimitDock, LimitPill } from './LimitState';
17
+ export { ReplyMarkdown, MessageMarkdown, Markdown } from './Markdown';
18
+ export { MermaidBlock } from './MermaidBlock';
19
+ export { MessageActions } from './MessageActions';
20
+ export { ModelPicker, StashPicker } from './Pickers';
21
+ export { type PromptHold, PromptComposer } from './PromptComposer';
22
+ export { QuoteButton } from './QuoteButton';
23
+ export { ResumeCompactionDock } from './ResumeCompactionDock';
24
+ export { RowTime } from './RowTime';
25
+ export { RunSettings } from './RunSettings';
26
+ export { Scrubber, type CardChat } from './Scrubber';
27
+ export { SubagentTitleCrumb, SubagentBreadcrumb, SubagentActions } from './SubagentControls';
28
+ export { SubagentInfo } from './SubagentInfo';
29
+ export { SubagentStopButton } from './SubagentStopButton';
30
+ export { SubagentTimeline } from './SubagentTimeline';
31
+ export { Timeline } from './Timeline';
32
+ export { TimelineMenuPopup, BookmarkMenuItems } from './TimelineMenu';
33
+ export { default as UnifiedDiff } from './UnifiedDiff';
34
+ export { UploadThumb } from './UploadThumb';
35
+ export { VisualDialogs } from './VisualDialogs';
36
+ export { type VisualFrameProps, VisualFrame } from './VisualFrame';
37
+ export { WelcomeGreeting } from './Welcome';
38
+ export { chipDecorations, type ChipChoices } from './composer/chips';
39
+ export { externalChange, markdownLanguage, composerEditorExtensions } from './composer/editor';
40
+ export { insertAtSelection } from './composer/insert';
41
+ export {
42
+ listItemAt,
43
+ enterAction,
44
+ inOpenFence,
45
+ recallDirection,
46
+ type EnterAction,
47
+ type EnterKeys,
48
+ type ListItem,
49
+ type EnterContext,
50
+ type RecallContext
51
+ } from './composer/keys';
52
+ export {
53
+ createDiffSyntaxRuntime,
54
+ diffSyntaxRuntime,
55
+ type DiffSyntaxRuntime,
56
+ type DiffSyntaxRuntimeOptions,
57
+ type DiffSyntaxSession,
58
+ type DiffSyntaxMapping,
59
+ type DiffSourceTokenSession,
60
+ diffSourceTokens
61
+ } from './diff-syntax';
62
+ export { useDiffTheme } from './diff-theme';
63
+ export type { UnifiedDiffProps } from './diff/diff-props';
64
+ export { FileLinkContext, useFileLinkCwd, useFileLinkScopeId, useOpenFileLink } from './file-links';
65
+ export { type ChatFindField, type FindReveal, useOpenForFind } from './find-reveal';
66
+ export type { DiffContents } from './full-diff';
67
+ export { type UiBlockFrameProps, UiBlockFrame, type UiBlockFix, type UiBlockFooterProps } from './intelligent-ui/UiBlockFrame';
68
+ export { UiFallbackPart, type UiFallbackProblem } from './intelligent-ui/UiFallbackPart';
69
+ export { UiReply } from './intelligent-ui/UiReply';
70
+ export { uiChartData, type UiChartSeries, type UiChartValues, type UiChartData } from './intelligent-ui/chart-data';
71
+ export { uiNodeLabel } from './intelligent-ui/node-text';
72
+ export { UI_RENDERERS } from './intelligent-ui/registry';
73
+ export type {
74
+ UiRenderContext,
75
+ UiRendererProps,
76
+ UiLinkTarget,
77
+ UiLink,
78
+ UiAnswer,
79
+ UiLiveStatus,
80
+ UiLiveValue,
81
+ UiRenderer,
82
+ UiRenderers
83
+ } from './intelligent-ui/render-context';
84
+ export { uiTableColumns, type UiColumnKind, type UiTableColumn } from './intelligent-ui/table-data';
85
+ export type { QuoteTaker } from './quote-selection';
86
+ export { ReplyContext } from './reply-context';
87
+ export { ForksRow } from './rows/ForksRow';
88
+ export { GeneratedImageRow } from './rows/GeneratedImageRow';
89
+ export {
90
+ UserRow,
91
+ ReportRow,
92
+ ReplyHeader,
93
+ AssistantRow,
94
+ ThinkingRow,
95
+ LiveThoughtRow,
96
+ NoteRow,
97
+ AgentTurnRow,
98
+ CompactionRow,
99
+ ApprovalHistoryRow,
100
+ QuestionHistoryRow
101
+ } from './rows/MessageRows';
102
+ export { type RowContainerProps, RowContainer } from './rows/RowContainer';
103
+ export { Row, type RowProps } from './rows/Rows';
104
+ export { SubagentRow, SubagentBranchRow } from './rows/SubagentRow';
105
+ export { TaskRow } from './rows/TaskRow';
106
+ export { VisualRow } from './rows/VisualRow';
107
+ export { ToggleLine, WorkRow, RunningFor, WorkLiveRow, WorkGroupRow, TurnFoldRow, ChangedFilesRow, WorkingRow } from './rows/WorkRows';
108
+ export { WorkflowRow } from './rows/WorkflowRow';
109
+ export { useDiffSourceTokens } from './use-diff-source-tokens';
@@ -26,7 +26,7 @@ import {
26
26
  } from '@adecore/intelligent-ui';
27
27
  import { ErrorBoundary, Tooltip } from '@adecore/ui';
28
28
  import type { ChatUiAnswer, ChatUiQueryState } from '@adecore/agent-contracts';
29
- import { chatHost } from '../../../host';
29
+ import { useChatHost } from '../../../host';
30
30
  import { UiReplyNavigationContext } from '../reply-context';
31
31
  import { ReplyMarkdown } from '../Markdown';
32
32
  import { rehypeFadeWords } from '../rehype-fade';
@@ -314,7 +314,7 @@ interface UiNodeBoundaryState {
314
314
  }
315
315
 
316
316
  class UiNodeBoundary extends Component<UiNodeBoundaryProps, UiNodeBoundaryState> {
317
- state = { failed: false, node: this.props.node };
317
+ override state = { failed: false, node: this.props.node };
318
318
 
319
319
  static getDerivedStateFromError(): { failed: boolean } {
320
320
  return { failed: true };
@@ -324,7 +324,7 @@ class UiNodeBoundary extends Component<UiNodeBoundaryProps, UiNodeBoundaryState>
324
324
  return props.node === state.node ? null : { failed: false, node: props.node };
325
325
  }
326
326
 
327
- render(): ReactNode {
327
+ override render(): ReactNode {
328
328
  return this.state.failed ? <UiFallbackPart fallback={this.props.node.fallback} problem={{ kind: 'failed' }} /> : this.props.children;
329
329
  }
330
330
  }
@@ -379,6 +379,7 @@ function UiBlockBody({
379
379
  answered?: ChatUiAnswer;
380
380
  frozen?: ChatUiQueryState['blocks'][string];
381
381
  }): ReactNode {
382
+ const host = useChatHost();
382
383
  const { t } = useTranslation('agent-chat');
383
384
  const key = JSON.stringify([context.scopeId, context.chatId, context.itemId, block.id]);
384
385
  const [state] = useState(() => localState(key, block, answered));
@@ -428,7 +429,7 @@ function UiBlockBody({
428
429
  [sources, element]
429
430
  );
430
431
  const liveValue = useUiLiveValues(block, evaluation.nodes, queries.currentReadings);
431
- const sendChoice = chatHost().intelligentUi?.sendChoice;
432
+ const sendChoice = host.intelligentUi?.sendChoice;
432
433
  const rendering: UiRenderContext = {
433
434
  ...context,
434
435
  ...links,
@@ -4,7 +4,7 @@ import { useTranslation } from 'react-i18next';
4
4
  import type { UiProps } from '@adecore/intelligent-ui';
5
5
  import { PreviewCard, Tooltip } from '@adecore/ui';
6
6
  import { formatNumber } from '@adecore/ui/format';
7
- import { chatHost } from '../../../../host';
7
+ import { useChatHost } from '../../../../host';
8
8
  import { CodeBlock } from '../../CodeBlock';
9
9
  import { CodeStreamingContext } from '../../code-streaming';
10
10
  import { ImageThumb } from '../../ImageView';
@@ -26,7 +26,8 @@ export function CodeBlockRenderer({ node }: UiRendererProps<UiProps<'CodeBlock'>
26
26
 
27
27
  /* Its own component, so the host's hook is only called for an image that names an attachment. */
28
28
  function AttachedImage({ scopeId, chatId, attachmentId, alt }: { scopeId: string; chatId: string; attachmentId: string; alt: string }) {
29
- const source = chatHost().attachments.useUrl(scopeId, chatId, attachmentId);
29
+ const host = useChatHost();
30
+ const source = host.attachments.useUrl(scopeId, chatId, attachmentId);
30
31
  return <ImageThumb source={source} alt={alt} className="max-h-70 max-w-full object-contain" />;
31
32
  }
32
33
 
@@ -2,7 +2,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
2
2
  import type { ChatUiLinkReading, ChatUiQueryState } from '@adecore/agent-contracts';
3
3
  import { uiLinkTargets, type UiLinkTarget } from '@adecore/intelligent-ui/links';
4
4
  import { uiInputValues, UI_HOST_LIMITS, type UiBlock, UiState } from '@adecore/intelligent-ui';
5
- import { chatHost } from '../../../host';
5
+ import { useChatHost } from '../../../host';
6
6
  import type { UiRenderContext } from './render-context';
7
7
 
8
8
  interface LinkState {
@@ -23,7 +23,7 @@ export function useUiLinks(
23
23
  const [checked, setChecked] = useState<Record<string, LinkState>>({});
24
24
  // What each node was last checked as, so a change of input checks only the targets it moved.
25
25
  const asked = useRef(new Map<string, string>());
26
- const host = chatHost().intelligentUi;
26
+ const host = useChatHost().intelligentUi;
27
27
  const values = uiInputValues(block, state);
28
28
  const scope = state.scope();
29
29
  const queryValues = Object.fromEntries(
@@ -1,7 +1,7 @@
1
1
  import { useEffect, useMemo, useRef, useState } from 'react';
2
2
  import type { ChatUiQueryReading, ChatUiQueryState } from '@adecore/agent-contracts';
3
3
  import { uiInputValues, UI_CATALOG_VERSION, UI_HOST_LIMITS, UiState, type UiBlock, type UiViewNode, type UiNode } from '@adecore/intelligent-ui';
4
- import { chatHost } from '../../../host';
4
+ import { useChatHost } from '../../../host';
5
5
  import type { UiLiveValue, UiLiveStatus, UiRenderContext } from './render-context';
6
6
 
7
7
  interface LocalReading {
@@ -43,6 +43,7 @@ export function useUiQueries(
43
43
  element: HTMLDivElement | null,
44
44
  frozen?: ChatUiQueryState['blocks'][string]
45
45
  ) {
46
+ const host = useChatHost();
46
47
  const [readings, setReadings] = useState<Record<string, LocalReading>>({});
47
48
  const [busyInput, setBusyInput] = useState<string | null>(null);
48
49
  const lastRead = useRef({ inputKey: '', at: 0 });
@@ -70,8 +71,8 @@ export function useUiQueries(
70
71
  };
71
72
  const reads = readsFor(JSON.parse(inputs));
72
73
  const ready = reads !== null;
73
- const query = chatHost().intelligentUi?.query;
74
- const subscribe = chatHost().intelligentUi?.subscribe;
74
+ const query = host.intelligentUi?.query;
75
+ const subscribe = host.intelligentUi?.subscribe;
75
76
  useEffect(() => {
76
77
  const scope = state.scope();
77
78
  for (const name of Object.keys(block.queries)) {