@miragon/mcp-toolkit-ui 2.6.0 → 2.8.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 (511) hide show
  1. package/README.md +14 -5
  2. package/dist/app/adapt-data-widget.d.ts +1 -22
  3. package/dist/app/adapt-data-widget.d.ts.map +1 -1
  4. package/dist/app/adapt-data-widget.js +1 -35
  5. package/dist/app/adapt-data-widget.js.map +1 -1
  6. package/dist/app/builder/BuilderBanners.d.ts +7 -2
  7. package/dist/app/builder/BuilderBanners.d.ts.map +1 -1
  8. package/dist/app/builder/BuilderBanners.js +8 -3
  9. package/dist/app/builder/BuilderBanners.js.map +1 -1
  10. package/dist/app/builder/CanvasRow.d.ts +4 -2
  11. package/dist/app/builder/CanvasRow.d.ts.map +1 -1
  12. package/dist/app/builder/CanvasRow.js +29 -17
  13. package/dist/app/builder/CanvasRow.js.map +1 -1
  14. package/dist/app/builder/CatalogueSheet.d.ts.map +1 -1
  15. package/dist/app/builder/CatalogueSheet.js +14 -6
  16. package/dist/app/builder/CatalogueSheet.js.map +1 -1
  17. package/dist/app/builder/CellPropsSheet.d.ts +7 -3
  18. package/dist/app/builder/CellPropsSheet.d.ts.map +1 -1
  19. package/dist/app/builder/CellPropsSheet.js +10 -3
  20. package/dist/app/builder/CellPropsSheet.js.map +1 -1
  21. package/dist/app/builder/DiscardDialog.d.ts +18 -0
  22. package/dist/app/builder/DiscardDialog.d.ts.map +1 -0
  23. package/dist/app/builder/DiscardDialog.js +18 -0
  24. package/dist/app/builder/DiscardDialog.js.map +1 -0
  25. package/dist/app/builder/EmptyHint.d.ts +4 -0
  26. package/dist/app/builder/EmptyHint.d.ts.map +1 -1
  27. package/dist/app/builder/EmptyHint.js +6 -1
  28. package/dist/app/builder/EmptyHint.js.map +1 -1
  29. package/dist/app/builder/LayoutSurface.d.ts +33 -9
  30. package/dist/app/builder/LayoutSurface.d.ts.map +1 -1
  31. package/dist/app/builder/LayoutSurface.js +74 -23
  32. package/dist/app/builder/LayoutSurface.js.map +1 -1
  33. package/dist/app/builder/PipelineStrip.d.ts +5 -2
  34. package/dist/app/builder/PipelineStrip.d.ts.map +1 -1
  35. package/dist/app/builder/PipelineStrip.js +33 -15
  36. package/dist/app/builder/PipelineStrip.js.map +1 -1
  37. package/dist/app/builder/SaveDialog.d.ts +9 -1
  38. package/dist/app/builder/SaveDialog.d.ts.map +1 -1
  39. package/dist/app/builder/SaveDialog.js +9 -3
  40. package/dist/app/builder/SaveDialog.js.map +1 -1
  41. package/dist/app/builder/Toolbar.d.ts +14 -4
  42. package/dist/app/builder/Toolbar.d.ts.map +1 -1
  43. package/dist/app/builder/Toolbar.js +24 -7
  44. package/dist/app/builder/Toolbar.js.map +1 -1
  45. package/dist/app/builder/Workspace.d.ts +23 -3
  46. package/dist/app/builder/Workspace.d.ts.map +1 -1
  47. package/dist/app/builder/Workspace.js +58 -8
  48. package/dist/app/builder/Workspace.js.map +1 -1
  49. package/dist/app/builder/builder-model.d.ts +146 -3
  50. package/dist/app/builder/builder-model.d.ts.map +1 -1
  51. package/dist/app/builder/builder-model.js +196 -5
  52. package/dist/app/builder/builder-model.js.map +1 -1
  53. package/dist/app/builder/labels.d.ts +13 -62
  54. package/dist/app/builder/labels.d.ts.map +1 -1
  55. package/dist/app/builder/labels.js +9 -58
  56. package/dist/app/builder/labels.js.map +1 -1
  57. package/dist/app/builder/reveal.d.ts +10 -0
  58. package/dist/app/builder/reveal.d.ts.map +1 -0
  59. package/dist/app/builder/reveal.js +10 -0
  60. package/dist/app/builder/reveal.js.map +1 -0
  61. package/dist/app/builder/status-chip.d.ts.map +1 -1
  62. package/dist/app/builder/status-chip.js +3 -2
  63. package/dist/app/builder/status-chip.js.map +1 -1
  64. package/dist/app/builder/use-builder-catalogue.d.ts +5 -1
  65. package/dist/app/builder/use-builder-catalogue.d.ts.map +1 -1
  66. package/dist/app/builder/use-builder-catalogue.js +50 -17
  67. package/dist/app/builder/use-builder-catalogue.js.map +1 -1
  68. package/dist/app/builder/use-builder-session.d.ts +30 -0
  69. package/dist/app/builder/use-builder-session.d.ts.map +1 -0
  70. package/dist/app/builder/use-builder-session.js +58 -0
  71. package/dist/app/builder/use-builder-session.js.map +1 -0
  72. package/dist/app/builder/use-display-resolver.d.ts +17 -0
  73. package/dist/app/builder/use-display-resolver.d.ts.map +1 -0
  74. package/dist/app/builder/use-display-resolver.js +16 -0
  75. package/dist/app/builder/use-display-resolver.js.map +1 -0
  76. package/dist/app/builder/use-save-dashboard.d.ts +3 -1
  77. package/dist/app/builder/use-save-dashboard.d.ts.map +1 -1
  78. package/dist/app/builder/use-save-dashboard.js +3 -1
  79. package/dist/app/builder/use-save-dashboard.js.map +1 -1
  80. package/dist/app/index.d.ts +8 -3
  81. package/dist/app/index.d.ts.map +1 -1
  82. package/dist/app/index.js +8 -2
  83. package/dist/app/index.js.map +1 -1
  84. package/dist/app/layout-builder.d.ts +18 -25
  85. package/dist/app/layout-builder.d.ts.map +1 -1
  86. package/dist/app/layout-builder.js +84 -78
  87. package/dist/app/layout-builder.js.map +1 -1
  88. package/dist/app/mcp-app-view-chrome.d.ts +103 -20
  89. package/dist/app/mcp-app-view-chrome.d.ts.map +1 -1
  90. package/dist/app/mcp-app-view-chrome.js +125 -40
  91. package/dist/app/mcp-app-view-chrome.js.map +1 -1
  92. package/dist/app/mcp-app-view-states.d.ts +23 -0
  93. package/dist/app/mcp-app-view-states.d.ts.map +1 -0
  94. package/dist/app/mcp-app-view-states.js +55 -0
  95. package/dist/app/mcp-app-view-states.js.map +1 -0
  96. package/dist/app/mcp-app-view.d.ts +72 -5
  97. package/dist/app/mcp-app-view.d.ts.map +1 -1
  98. package/dist/app/mcp-app-view.js +241 -141
  99. package/dist/app/mcp-app-view.js.map +1 -1
  100. package/dist/app/mcp-toolkit-app.d.ts +8 -2
  101. package/dist/app/mcp-toolkit-app.d.ts.map +1 -1
  102. package/dist/app/mcp-toolkit-app.js +33 -4
  103. package/dist/app/mcp-toolkit-app.js.map +1 -1
  104. package/dist/app/mcp-use-host-bridge.d.ts +15 -6
  105. package/dist/app/mcp-use-host-bridge.d.ts.map +1 -1
  106. package/dist/app/mcp-use-host-bridge.js +51 -22
  107. package/dist/app/mcp-use-host-bridge.js.map +1 -1
  108. package/dist/app/model-context.d.ts +71 -0
  109. package/dist/app/model-context.d.ts.map +1 -0
  110. package/dist/app/model-context.js +101 -0
  111. package/dist/app/model-context.js.map +1 -0
  112. package/dist/app/use-build-mode-focus.d.ts +33 -0
  113. package/dist/app/use-build-mode-focus.d.ts.map +1 -0
  114. package/dist/app/use-build-mode-focus.js +59 -0
  115. package/dist/app/use-build-mode-focus.js.map +1 -0
  116. package/dist/app/use-view-actions.d.ts +31 -0
  117. package/dist/app/use-view-actions.d.ts.map +1 -0
  118. package/dist/app/use-view-actions.js +81 -0
  119. package/dist/app/use-view-actions.js.map +1 -0
  120. package/dist/app/use-view-lifecycle.d.ts +42 -0
  121. package/dist/app/use-view-lifecycle.d.ts.map +1 -0
  122. package/dist/app/use-view-lifecycle.js +81 -0
  123. package/dist/app/use-view-lifecycle.js.map +1 -0
  124. package/dist/app/view-lifecycle.d.ts +185 -0
  125. package/dist/app/view-lifecycle.d.ts.map +1 -0
  126. package/dist/app/view-lifecycle.js +207 -0
  127. package/dist/app/view-lifecycle.js.map +1 -0
  128. package/dist/app/widget-fixture.d.ts +10 -3
  129. package/dist/app/widget-fixture.d.ts.map +1 -1
  130. package/dist/app/widget-fixture.js +21 -8
  131. package/dist/app/widget-fixture.js.map +1 -1
  132. package/dist/app/widget-props-sheet.d.ts +6 -10
  133. package/dist/app/widget-props-sheet.d.ts.map +1 -1
  134. package/dist/app/widget-props-sheet.js +25 -20
  135. package/dist/app/widget-props-sheet.js.map +1 -1
  136. package/dist/app/widget-renderer.d.ts +41 -1
  137. package/dist/app/widget-renderer.d.ts.map +1 -1
  138. package/dist/app/widget-renderer.js +82 -31
  139. package/dist/app/widget-renderer.js.map +1 -1
  140. package/dist/components/DrillButton.d.ts +9 -6
  141. package/dist/components/DrillButton.d.ts.map +1 -1
  142. package/dist/components/DrillButton.js +9 -6
  143. package/dist/components/DrillButton.js.map +1 -1
  144. package/dist/components/EmptyState.d.ts +33 -0
  145. package/dist/components/EmptyState.d.ts.map +1 -0
  146. package/dist/components/EmptyState.js +19 -0
  147. package/dist/components/EmptyState.js.map +1 -0
  148. package/dist/components/ErrorState.d.ts +53 -0
  149. package/dist/components/ErrorState.d.ts.map +1 -0
  150. package/dist/components/ErrorState.js +77 -0
  151. package/dist/components/ErrorState.js.map +1 -0
  152. package/dist/components/FilterBar.d.ts +16 -5
  153. package/dist/components/FilterBar.d.ts.map +1 -1
  154. package/dist/components/FilterBar.js +13 -5
  155. package/dist/components/FilterBar.js.map +1 -1
  156. package/dist/components/GroupCard.d.ts.map +1 -1
  157. package/dist/components/GroupCard.js +2 -1
  158. package/dist/components/GroupCard.js.map +1 -1
  159. package/dist/components/KpiGrid.d.ts +70 -18
  160. package/dist/components/KpiGrid.d.ts.map +1 -1
  161. package/dist/components/KpiGrid.js +112 -23
  162. package/dist/components/KpiGrid.js.map +1 -1
  163. package/dist/components/ListFooter.d.ts +32 -4
  164. package/dist/components/ListFooter.d.ts.map +1 -1
  165. package/dist/components/ListFooter.js +35 -6
  166. package/dist/components/ListFooter.js.map +1 -1
  167. package/dist/components/PagedListFooter.d.ts +57 -0
  168. package/dist/components/PagedListFooter.d.ts.map +1 -0
  169. package/dist/components/PagedListFooter.js +27 -0
  170. package/dist/components/PagedListFooter.js.map +1 -0
  171. package/dist/components/Pills.d.ts +36 -12
  172. package/dist/components/Pills.d.ts.map +1 -1
  173. package/dist/components/Pills.js +29 -8
  174. package/dist/components/Pills.js.map +1 -1
  175. package/dist/components/SectionHeading.d.ts +3 -1
  176. package/dist/components/SectionHeading.d.ts.map +1 -1
  177. package/dist/components/SectionHeading.js +6 -2
  178. package/dist/components/SectionHeading.js.map +1 -1
  179. package/dist/components/Toast.d.ts +43 -0
  180. package/dist/components/Toast.d.ts.map +1 -0
  181. package/dist/components/Toast.js +106 -0
  182. package/dist/components/Toast.js.map +1 -0
  183. package/dist/components/WidgetHeader.d.ts +34 -10
  184. package/dist/components/WidgetHeader.d.ts.map +1 -1
  185. package/dist/components/WidgetHeader.js +11 -6
  186. package/dist/components/WidgetHeader.js.map +1 -1
  187. package/dist/hooks/index.d.ts +4 -4
  188. package/dist/hooks/index.d.ts.map +1 -1
  189. package/dist/hooks/index.js +1 -1
  190. package/dist/hooks/index.js.map +1 -1
  191. package/dist/hooks/tool-result-recovery-model.d.ts +155 -0
  192. package/dist/hooks/tool-result-recovery-model.d.ts.map +1 -0
  193. package/dist/hooks/tool-result-recovery-model.js +273 -0
  194. package/dist/hooks/tool-result-recovery-model.js.map +1 -0
  195. package/dist/hooks/use-tool-query.d.ts +56 -14
  196. package/dist/hooks/use-tool-query.d.ts.map +1 -1
  197. package/dist/hooks/use-tool-query.js +102 -25
  198. package/dist/hooks/use-tool-query.js.map +1 -1
  199. package/dist/hooks/use-tool-result-recovery.d.ts +61 -44
  200. package/dist/hooks/use-tool-result-recovery.d.ts.map +1 -1
  201. package/dist/hooks/use-tool-result-recovery.js +62 -110
  202. package/dist/hooks/use-tool-result-recovery.js.map +1 -1
  203. package/dist/hooks/use-view-data.d.ts +55 -7
  204. package/dist/hooks/use-view-data.d.ts.map +1 -1
  205. package/dist/hooks/use-view-data.js +81 -11
  206. package/dist/hooks/use-view-data.js.map +1 -1
  207. package/dist/hooks/use-view-tool-query.d.ts +12 -7
  208. package/dist/hooks/use-view-tool-query.d.ts.map +1 -1
  209. package/dist/hooks/use-view-tool-query.js +15 -14
  210. package/dist/hooks/use-view-tool-query.js.map +1 -1
  211. package/dist/index.d.ts +27 -13
  212. package/dist/index.d.ts.map +1 -1
  213. package/dist/index.js +29 -7
  214. package/dist/index.js.map +1 -1
  215. package/dist/lib/focus-return.d.ts +61 -0
  216. package/dist/lib/focus-return.d.ts.map +1 -0
  217. package/dist/lib/focus-return.js +46 -0
  218. package/dist/lib/focus-return.js.map +1 -0
  219. package/dist/lib/focus-ring.d.ts +18 -0
  220. package/dist/lib/focus-ring.d.ts.map +1 -0
  221. package/dist/lib/focus-ring.js +18 -0
  222. package/dist/lib/focus-ring.js.map +1 -0
  223. package/dist/lib/icon-stroke.d.ts +12 -0
  224. package/dist/lib/icon-stroke.d.ts.map +1 -0
  225. package/dist/lib/icon-stroke.js +12 -0
  226. package/dist/lib/icon-stroke.js.map +1 -0
  227. package/dist/lib/parse-tool-result.d.ts +23 -1
  228. package/dist/lib/parse-tool-result.d.ts.map +1 -1
  229. package/dist/lib/parse-tool-result.js +38 -2
  230. package/dist/lib/parse-tool-result.js.map +1 -1
  231. package/dist/lib/toast-model.d.ts +86 -0
  232. package/dist/lib/toast-model.d.ts.map +1 -0
  233. package/dist/lib/toast-model.js +102 -0
  234. package/dist/lib/toast-model.js.map +1 -0
  235. package/dist/lib/tone-utils.d.ts +95 -9
  236. package/dist/lib/tone-utils.d.ts.map +1 -1
  237. package/dist/lib/tone-utils.js +100 -9
  238. package/dist/lib/tone-utils.js.map +1 -1
  239. package/dist/lib/tool-query.d.ts +107 -0
  240. package/dist/lib/tool-query.d.ts.map +1 -0
  241. package/dist/lib/tool-query.js +182 -0
  242. package/dist/lib/tool-query.js.map +1 -0
  243. package/dist/lib/tool-result-observer.d.ts +108 -0
  244. package/dist/lib/tool-result-observer.d.ts.map +1 -0
  245. package/dist/lib/tool-result-observer.js +158 -0
  246. package/dist/lib/tool-result-observer.js.map +1 -0
  247. package/dist/lib/typography.d.ts +37 -0
  248. package/dist/lib/typography.d.ts.map +1 -0
  249. package/dist/lib/typography.js +41 -0
  250. package/dist/lib/typography.js.map +1 -0
  251. package/dist/lib/utils.d.ts.map +1 -1
  252. package/dist/lib/utils.js +11 -1
  253. package/dist/lib/utils.js.map +1 -1
  254. package/dist/locale/index.d.ts +3 -1
  255. package/dist/locale/index.d.ts.map +1 -1
  256. package/dist/locale/index.js +2 -1
  257. package/dist/locale/index.js.map +1 -1
  258. package/dist/locale/locale-provider.d.ts +42 -1
  259. package/dist/locale/locale-provider.d.ts.map +1 -1
  260. package/dist/locale/locale-provider.js +44 -3
  261. package/dist/locale/locale-provider.js.map +1 -1
  262. package/dist/locale/message-types.d.ts +336 -0
  263. package/dist/locale/message-types.d.ts.map +1 -0
  264. package/dist/locale/message-types.js +7 -0
  265. package/dist/locale/message-types.js.map +1 -0
  266. package/dist/locale/messages-de.d.ts +9 -0
  267. package/dist/locale/messages-de.d.ts.map +1 -0
  268. package/dist/locale/messages-de.js +185 -0
  269. package/dist/locale/messages-de.js.map +1 -0
  270. package/dist/locale/messages-en.d.ts +8 -0
  271. package/dist/locale/messages-en.d.ts.map +1 -0
  272. package/dist/locale/messages-en.js +184 -0
  273. package/dist/locale/messages-en.js.map +1 -0
  274. package/dist/locale/toolkit-messages.d.ts +57 -0
  275. package/dist/locale/toolkit-messages.d.ts.map +1 -0
  276. package/dist/locale/toolkit-messages.js +103 -0
  277. package/dist/locale/toolkit-messages.js.map +1 -0
  278. package/dist/primitives/alert.d.ts +1 -1
  279. package/dist/primitives/alert.d.ts.map +1 -1
  280. package/dist/primitives/alert.js +6 -2
  281. package/dist/primitives/alert.js.map +1 -1
  282. package/dist/primitives/badge.d.ts +1 -1
  283. package/dist/primitives/badge.d.ts.map +1 -1
  284. package/dist/primitives/badge.js +19 -6
  285. package/dist/primitives/badge.js.map +1 -1
  286. package/dist/primitives/button.d.ts +1 -1
  287. package/dist/primitives/button.d.ts.map +1 -1
  288. package/dist/primitives/button.js +12 -8
  289. package/dist/primitives/button.js.map +1 -1
  290. package/dist/primitives/card.js +4 -4
  291. package/dist/primitives/card.js.map +1 -1
  292. package/dist/primitives/dialog.d.ts +7 -3
  293. package/dist/primitives/dialog.d.ts.map +1 -1
  294. package/dist/primitives/dialog.js +22 -8
  295. package/dist/primitives/dialog.js.map +1 -1
  296. package/dist/primitives/input.d.ts.map +1 -1
  297. package/dist/primitives/input.js +4 -1
  298. package/dist/primitives/input.js.map +1 -1
  299. package/dist/primitives/scroll-area.js +1 -1
  300. package/dist/primitives/scroll-area.js.map +1 -1
  301. package/dist/primitives/select.d.ts.map +1 -1
  302. package/dist/primitives/select.js +6 -3
  303. package/dist/primitives/select.js.map +1 -1
  304. package/dist/primitives/sheet.d.ts +3 -1
  305. package/dist/primitives/sheet.d.ts.map +1 -1
  306. package/dist/primitives/sheet.js +17 -7
  307. package/dist/primitives/sheet.js.map +1 -1
  308. package/dist/primitives/skeleton.js +1 -1
  309. package/dist/primitives/skeleton.js.map +1 -1
  310. package/dist/primitives/switch.d.ts.map +1 -1
  311. package/dist/primitives/switch.js +2 -1
  312. package/dist/primitives/switch.js.map +1 -1
  313. package/dist/primitives/tabs.d.ts.map +1 -1
  314. package/dist/primitives/tabs.js +5 -3
  315. package/dist/primitives/tabs.js.map +1 -1
  316. package/dist/providers/query-provider.d.ts +32 -1
  317. package/dist/providers/query-provider.d.ts.map +1 -1
  318. package/dist/providers/query-provider.js +53 -4
  319. package/dist/providers/query-provider.js.map +1 -1
  320. package/dist/render-cases-primitives.js +1 -1
  321. package/dist/render-cases-primitives.js.map +1 -1
  322. package/dist/render-cases.d.ts.map +1 -1
  323. package/dist/render-cases.js +48 -6
  324. package/dist/render-cases.js.map +1 -1
  325. package/dist/render-effects.d.ts +42 -0
  326. package/dist/render-effects.d.ts.map +1 -0
  327. package/dist/render-effects.js +81 -0
  328. package/dist/render-effects.js.map +1 -0
  329. package/dist/render-scan.d.ts +25 -0
  330. package/dist/render-scan.d.ts.map +1 -0
  331. package/dist/render-scan.js +66 -0
  332. package/dist/render-scan.js.map +1 -0
  333. package/dist/theme/cd-tokens.d.ts +66 -0
  334. package/dist/theme/cd-tokens.d.ts.map +1 -0
  335. package/dist/theme/cd-tokens.js +64 -0
  336. package/dist/theme/cd-tokens.js.map +1 -0
  337. package/dist/theme/create-theme.d.ts +214 -39
  338. package/dist/theme/create-theme.d.ts.map +1 -1
  339. package/dist/theme/create-theme.js +204 -13
  340. package/dist/theme/create-theme.js.map +1 -1
  341. package/dist/theme/fonts.d.ts +38 -0
  342. package/dist/theme/fonts.d.ts.map +1 -0
  343. package/dist/theme/fonts.js +56 -0
  344. package/dist/theme/fonts.js.map +1 -0
  345. package/dist/theme/host-fonts.d.ts +39 -0
  346. package/dist/theme/host-fonts.d.ts.map +1 -0
  347. package/dist/theme/host-fonts.js +44 -0
  348. package/dist/theme/host-fonts.js.map +1 -0
  349. package/dist/theme/index.d.ts +8 -1
  350. package/dist/theme/index.d.ts.map +1 -1
  351. package/dist/theme/index.js +5 -1
  352. package/dist/theme/index.js.map +1 -1
  353. package/dist/theme/portal-container.d.ts +16 -0
  354. package/dist/theme/portal-container.d.ts.map +1 -0
  355. package/dist/theme/portal-container.js +19 -0
  356. package/dist/theme/portal-container.js.map +1 -0
  357. package/dist/theme/presets.d.ts +24 -9
  358. package/dist/theme/presets.d.ts.map +1 -1
  359. package/dist/theme/presets.js +44 -11
  360. package/dist/theme/presets.js.map +1 -1
  361. package/dist/theme/theme-provider.d.ts +27 -9
  362. package/dist/theme/theme-provider.d.ts.map +1 -1
  363. package/dist/theme/theme-provider.js +42 -20
  364. package/dist/theme/theme-provider.js.map +1 -1
  365. package/package.json +11 -5
  366. package/src/app/adapt-data-widget.tsx +2 -42
  367. package/src/app/builder/BuilderBanners.tsx +26 -13
  368. package/src/app/builder/CanvasRow.tsx +79 -32
  369. package/src/app/builder/CatalogueSheet.tsx +58 -35
  370. package/src/app/builder/CellPropsSheet.tsx +17 -2
  371. package/src/app/builder/DiscardDialog.tsx +59 -0
  372. package/src/app/builder/EmptyHint.tsx +16 -11
  373. package/src/app/builder/LayoutSurface.tsx +207 -67
  374. package/src/app/builder/PipelineStrip.tsx +265 -156
  375. package/src/app/builder/SaveDialog.tsx +25 -14
  376. package/src/app/builder/Toolbar.tsx +154 -57
  377. package/src/app/builder/Workspace.tsx +226 -56
  378. package/src/app/builder/builder-feedback.test.tsx +75 -0
  379. package/src/app/builder/builder-model.test.ts +5 -0
  380. package/src/app/builder/builder-model.ts +346 -6
  381. package/src/app/builder/builder-model.ux.test.ts +456 -0
  382. package/src/app/builder/builder-ux.test.tsx +844 -0
  383. package/src/app/builder/labels.ts +15 -121
  384. package/src/app/builder/reveal.ts +10 -0
  385. package/src/app/builder/status-chip.tsx +8 -4
  386. package/src/app/builder/use-builder-catalogue.ts +62 -19
  387. package/src/app/builder/use-builder-session.ts +68 -0
  388. package/src/app/builder/use-display-resolver.ts +24 -0
  389. package/src/app/builder/use-save-dashboard.ts +5 -0
  390. package/src/app/index.ts +20 -3
  391. package/src/app/layout-builder.tsx +193 -186
  392. package/src/app/mcp-app-view-chrome.test.tsx +487 -14
  393. package/src/app/mcp-app-view-chrome.tsx +328 -100
  394. package/src/app/mcp-app-view-states.tsx +140 -0
  395. package/src/app/mcp-app-view.effects.test.tsx +292 -0
  396. package/src/app/mcp-app-view.test.tsx +478 -0
  397. package/src/app/mcp-app-view.tsx +447 -190
  398. package/src/app/mcp-toolkit-app.test.tsx +40 -0
  399. package/src/app/mcp-toolkit-app.tsx +39 -8
  400. package/src/app/mcp-use-host-bridge.test.tsx +180 -0
  401. package/src/app/mcp-use-host-bridge.tsx +67 -24
  402. package/src/app/model-context.test.tsx +116 -0
  403. package/src/app/model-context.tsx +125 -0
  404. package/src/app/use-build-mode-focus.ts +62 -0
  405. package/src/app/use-view-actions.ts +89 -0
  406. package/src/app/use-view-lifecycle.ts +122 -0
  407. package/src/app/view-lifecycle.test.ts +443 -0
  408. package/src/app/view-lifecycle.ts +334 -0
  409. package/src/app/widget-fixture.effects.test.tsx +51 -0
  410. package/src/app/widget-fixture.render.test.tsx +81 -0
  411. package/src/app/widget-fixture.tsx +34 -11
  412. package/src/app/widget-props-sheet.tsx +67 -39
  413. package/src/app/widget-renderer.render.test.tsx +131 -0
  414. package/src/app/widget-renderer.tsx +136 -38
  415. package/src/components/DrillButton.tsx +24 -10
  416. package/src/components/EmptyState.tsx +83 -0
  417. package/src/components/ErrorState.tsx +204 -0
  418. package/src/components/FilterBar.test.tsx +82 -0
  419. package/src/components/FilterBar.tsx +56 -27
  420. package/src/components/GroupCard.tsx +3 -2
  421. package/src/components/KpiGrid.test.tsx +279 -0
  422. package/src/components/KpiGrid.tsx +329 -91
  423. package/src/components/ListFooter.test.tsx +116 -0
  424. package/src/components/ListFooter.tsx +110 -12
  425. package/src/components/PagedListFooter.test.tsx +140 -0
  426. package/src/components/PagedListFooter.tsx +107 -0
  427. package/src/components/Pills.test.tsx +77 -0
  428. package/src/components/Pills.tsx +78 -16
  429. package/src/components/SectionHeading.tsx +9 -3
  430. package/src/components/Toast.tsx +206 -0
  431. package/src/components/WidgetHeader.test.tsx +78 -0
  432. package/src/components/WidgetHeader.tsx +63 -16
  433. package/src/components/feedback-states.test.tsx +314 -0
  434. package/src/components/tone-figures.test.tsx +58 -0
  435. package/src/fonts.css +19 -0
  436. package/src/globals.css +9 -165
  437. package/src/hooks/index.ts +6 -3
  438. package/src/hooks/tool-result-recovery-model.test.ts +744 -0
  439. package/src/hooks/tool-result-recovery-model.ts +418 -0
  440. package/src/hooks/use-tool-query.effects.test.tsx +205 -0
  441. package/src/hooks/use-tool-query.ts +156 -33
  442. package/src/hooks/use-tool-result-recovery.effects.test.tsx +141 -0
  443. package/src/hooks/use-tool-result-recovery.test.ts +28 -5
  444. package/src/hooks/use-tool-result-recovery.ts +101 -131
  445. package/src/hooks/use-view-data.test.tsx +169 -0
  446. package/src/hooks/use-view-data.ts +131 -10
  447. package/src/hooks/use-view-tool-query.ts +25 -19
  448. package/src/i18n-coverage.test.tsx +425 -0
  449. package/src/index.ts +102 -13
  450. package/src/lib/focus-return.test.ts +288 -0
  451. package/src/lib/focus-return.ts +96 -0
  452. package/src/lib/focus-ring.ts +20 -0
  453. package/src/lib/icon-stroke.test.ts +59 -0
  454. package/src/lib/icon-stroke.ts +13 -0
  455. package/src/lib/parse-tool-result.test.ts +46 -1
  456. package/src/lib/parse-tool-result.ts +40 -2
  457. package/src/lib/toast-model.test.ts +233 -0
  458. package/src/lib/toast-model.ts +165 -0
  459. package/src/lib/tone-utils.test.ts +125 -16
  460. package/src/lib/tone-utils.ts +144 -15
  461. package/src/lib/tool-query.test.ts +569 -0
  462. package/src/lib/tool-query.ts +253 -0
  463. package/src/lib/tool-result-observer.test.ts +296 -0
  464. package/src/lib/tool-result-observer.ts +211 -0
  465. package/src/lib/typography.test.ts +45 -0
  466. package/src/lib/typography.ts +47 -0
  467. package/src/lib/utils.ts +12 -1
  468. package/src/locale/index.ts +14 -1
  469. package/src/locale/locale-provider.test.tsx +87 -0
  470. package/src/locale/locale-provider.tsx +90 -3
  471. package/src/locale/message-types.ts +337 -0
  472. package/src/locale/messages-de.ts +198 -0
  473. package/src/locale/messages-en.ts +196 -0
  474. package/src/locale/toolkit-messages.test.ts +349 -0
  475. package/src/locale/toolkit-messages.ts +143 -0
  476. package/src/no-hardcoded-copy.test.ts +432 -0
  477. package/src/primitives/alert.tsx +7 -2
  478. package/src/primitives/badge.tsx +19 -7
  479. package/src/primitives/button.tsx +13 -8
  480. package/src/primitives/card.tsx +4 -4
  481. package/src/primitives/dialog.tsx +42 -8
  482. package/src/primitives/input.tsx +5 -3
  483. package/src/primitives/scroll-area.tsx +1 -1
  484. package/src/primitives/select.tsx +7 -4
  485. package/src/primitives/sheet.tsx +33 -6
  486. package/src/primitives/skeleton.tsx +1 -1
  487. package/src/primitives/switch.tsx +4 -2
  488. package/src/primitives/tabs.tsx +9 -6
  489. package/src/providers/query-provider.test.tsx +154 -0
  490. package/src/providers/query-provider.tsx +66 -5
  491. package/src/render-cases-primitives.tsx +1 -1
  492. package/src/render-cases.tsx +82 -6
  493. package/src/render-effects.tsx +96 -0
  494. package/src/render-scan.ts +75 -0
  495. package/src/theme/cd-tokens.generated.css +48 -0
  496. package/src/theme/cd-tokens.test.ts +109 -0
  497. package/src/theme/cd-tokens.ts +67 -0
  498. package/src/theme/create-theme.test.ts +253 -5
  499. package/src/theme/create-theme.ts +341 -41
  500. package/src/theme/fonts.test.ts +85 -0
  501. package/src/theme/fonts.ts +72 -0
  502. package/src/theme/host-fonts.test.ts +135 -0
  503. package/src/theme/host-fonts.ts +52 -0
  504. package/src/theme/index.ts +15 -1
  505. package/src/theme/portal-container.ts +20 -0
  506. package/src/theme/presets.ts +44 -11
  507. package/src/theme/theme-css.test.ts +619 -0
  508. package/src/theme/theme-provider.test.tsx +82 -0
  509. package/src/theme/theme-provider.tsx +60 -24
  510. package/src/theme.css +344 -0
  511. package/ui-catalog.json +783 -49
@@ -1,159 +1,259 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useState, useCallback } from "react";
3
- import { ToolCancelledError, useDisplayMode, useHostContext, useToolContext } from "mcp-use/react";
4
- import { AppQueryProvider, queryClient } from "../providers/query-provider.js";
5
- import { useToolResultRecovery } from "../hooks/use-tool-result-recovery.js";
6
- import { parseToolResult } from "../lib/parse-tool-result.js";
2
+ import { useState, useCallback, useEffect, useMemo } from "react";
3
+ import { LucideProvider } from "lucide-react";
4
+ import { ToolCancelledError, useHostContext, useToolContext } from "mcp-use/react";
5
+ import { ToastProvider } from "../components/Toast.js";
6
+ import { ToolkitLocaleFallback, useToolkitLocale, useToolkitMessages, } from "../locale/locale-provider.js";
7
+ import { formatClockTime, resolveFormatLocale } from "../locale/toolkit-messages.js";
8
+ import { AppQueryProvider, useAppQueryClient } from "../providers/query-provider.js";
9
+ import { resolveToolSafety } from "../hooks/tool-result-recovery-model.js";
10
+ import { DEFAULT_ASSUME_STRIPPED_AFTER_MS, resolveRecoveryToolName, useToolResultRecovery, } from "../hooks/use-tool-result-recovery.js";
11
+ import { ICON_STROKE } from "../lib/icon-stroke.js";
7
12
  import { useHostBridge } from "./host-bridge.js";
8
- import { DEFAULT_LABELS, isCompleteViewData, StepErrors, ViewBody, ViewPlaceholder, ViewToolbar, } from "./mcp-app-view-chrome.js";
9
- export function McpAppView({ widgets, refreshToolName = "refresh-view", builderEnabled, labels, }) {
10
- const effectiveLabels = { ...DEFAULT_LABELS, ...labels };
11
- // Since mcp-use 2.x the shell reads the view channels through the dedicated
12
- // hooks (all require the surrounding `bootstrapView` mount that
13
- // `mountMcpToolkitApp` provides) and calls tools through the HostBridge that
14
- // `McpUseHostBridgeProvider` installs.
15
- const tool = useToolContext();
16
- const { displayMode, requestDisplayMode } = useDisplayMode();
17
- const { safeArea, hostContext } = useHostContext();
18
- const bridge = useHostBridge();
19
- const callTool = useCallback((name, args) => bridge.callTool(name, args), [bridge]);
20
- const isPending = tool.status === "pending";
21
- // Since mcp-use 2.7.1 a host cancellation of the rendering call latches as a
22
- // terminal `status: "error"` — show it instead of the skeleton, and never
23
- // let the recovery below re-run the call the user stopped.
24
- const isCancelled = tool.status === "error" && tool.error instanceof ToolCancelledError;
25
- const initialViewData = tool.status === "ready" ? tool.toolOutput : undefined;
26
- const toolInput = tool.toolInput;
27
- const [viewData, setViewData] = useState(null);
28
- const [isRefreshing, setIsRefreshing] = useState(false);
29
- // In-iframe build mode is purely a UI state — the LLM never sees the
30
- // catalogue, the user toggles into build by clicking the toolbar button.
31
- const [buildMode, setBuildMode] = useState(false);
32
- // Sync host-provided initialViewData → local viewData via render-phase
33
- // setState (rather than an effect) so the React Compiler doesn't flag a
34
- // cascading render. The guard against transient empty toolOutput stays:
35
- // widgetProps may briefly drop `context`/`layout` when displayMode toggles,
36
- // and we don't want that to clobber a valid viewData.
37
- //
13
+ import { useViewResultSink } from "./mcp-use-host-bridge.js";
14
+ import { HostModelContext } from "./model-context.js";
15
+ import { applyBuilderCommit, isCompleteViewData, StepErrors, ViewBody, ViewToolbar, } from "./mcp-app-view-chrome.js";
16
+ import { ViewPlaceholder } from "./mcp-app-view-states.js";
17
+ import { useBuildModeFocus } from "./use-build-mode-focus.js";
18
+ import { useFullscreenToggle, useViewRefresh } from "./use-view-actions.js";
19
+ import { useRetryFocus, useViewLifecycle } from "./use-view-lifecycle.js";
20
+ import { DEFAULT_SLOW_HINT_MS, describeViewForModel, reloadedAtOf, } from "./view-lifecycle.js";
21
+ /**
22
+ * The toolkit's MCP App view: lifecycle placeholder (waiting / error /
23
+ * cancelled), toolbar, failed-steps alert and the rendered layout (or the
24
+ * builder). Mounts a `ToastProvider` and binds the toolkit's own strings to
25
+ * the host's locale unless a `LocaleProvider` sets one, so the chrome follows
26
+ * the host language; `useLocale()` in consumer widgets is unaffected. Lucide
27
+ * icons draw at the CI stroke (2.5) throughout, the toast stack included.
28
+ * The widgets' data hooks fetch through an enclosing `AppQueryProvider`'s
29
+ * client, else the toolkit's shared `queryClient`.
30
+ */
31
+ export function McpAppView(props) {
32
+ const { locale } = useHostContext();
33
+ return (_jsx(ToolkitLocaleFallback, { locale: locale, children: _jsx(LucideProvider, { strokeWidth: ICON_STROKE, children: _jsx(ToastProvider, { children: _jsx(McpAppViewShell, { ...props }) }) }) }));
34
+ }
35
+ const NO_VIEW = { data: null, source: null, reloadedAt: null };
36
+ /**
37
+ * Host-delivered payload → the shown view, recovered payloads included, each
38
+ * tagged with its source. Render-phase setState (not an effect) so the React
39
+ * Compiler doesn't flag a cascading render.
40
+ */
41
+ function useHostViewData(initialViewData, isPending, recovered, recoveredAt) {
42
+ const [view, setView] = useState(NO_VIEW);
38
43
  // `prev` MUST start as `null`, not `initialViewData`: hosts that expose the
39
44
  // complete tool output before the app's first render (e.g. window.openai
40
45
  // globals injected ahead of script execution) would otherwise never trip the
41
- // identity check — initialViewData never changes again, the sync never runs,
42
- // and the app idles on the loading skeleton forever.
43
- const [prevInitialViewData, setPrevInitialViewData] = useState(null);
44
- if (initialViewData !== prevInitialViewData) {
45
- setPrevInitialViewData(initialViewData);
46
+ // identity check — the sync never runs and the app idles on the skeleton.
47
+ // The completeness guard stays: widgetProps may briefly drop
48
+ // `context`/`layout` when displayMode toggles.
49
+ const [prevInitial, setPrevInitial] = useState(null);
50
+ if (initialViewData !== prevInitial) {
51
+ setPrevInitial(initialViewData);
46
52
  if (!isPending && isCompleteViewData(initialViewData)) {
47
- setViewData(initialViewData);
53
+ setView({ data: initialViewData, source: "host", reloadedAt: null });
54
+ }
55
+ }
56
+ const [prevRecovered, setPrevRecovered] = useState(null);
57
+ if (recovered !== prevRecovered) {
58
+ setPrevRecovered(recovered);
59
+ // The host-delivered payload always wins; a recovery fills the gap, and a
60
+ // recovery for newer arguments replaces an older recovered payload (N21).
61
+ if (recovered) {
62
+ setView((prev) => prev.data === null || prev.source === "recovered"
63
+ ? { data: recovered, source: "recovered", reloadedAt: recoveredAt }
64
+ : prev);
48
65
  }
49
66
  }
50
- // Hosts that strip `structuredContent` from the tool-result notification
51
- // (claude.ai / Claude Desktop) never latch a result under mcp-use 2.x — the
52
- // `useToolContext` latch ignores content-only results, so `isPending` stays
53
- // true forever. The recovery therefore also arms itself on a grace timer
54
- // once the originating tool is known, re-executes it via `callTool`
55
- // (responses carry `structuredContent` intact), and fills the gap.
56
- // Conforming hosts deliver a valid payload up front, so it never fires
57
- // there.
67
+ return [view, setView];
68
+ }
69
+ /**
70
+ * Hands the payload the view shows (the host's, its own recovery's, the
71
+ * user's retry or refresh) to the host bridge, so `HostBridge.getWidgetData()`
72
+ * returns what the view shows (toolkit#176 K15), also after a latch the view
73
+ * could not render.
74
+ */
75
+ function useReportShownPayload(view) {
76
+ const report = useViewResultSink();
77
+ const payload = view.data;
78
+ useEffect(() => {
79
+ if (payload)
80
+ report?.(payload);
81
+ }, [payload, report]);
82
+ }
83
+ /** The rendering call as mcp-use 2.x latches it, plus the tool the host names. */
84
+ function useRenderCall() {
85
+ const tool = useToolContext();
86
+ const { hostContext } = useHostContext();
87
+ // Since mcp-use 2.7.1 a host cancellation latches as `status: "error"`.
88
+ const isCancelled = tool.status === "error" && tool.error instanceof ToolCancelledError;
89
+ const isCallError = tool.status === "error" && !isCancelled;
90
+ return {
91
+ tool,
92
+ hostContext,
93
+ isPending: tool.status === "pending",
94
+ isCancelled,
95
+ isCallError,
96
+ callError: isCallError ? tool.error : undefined,
97
+ initialViewData: tool.status === "ready" ? tool.toolOutput : undefined,
98
+ toolName: resolveRecoveryToolName(hostContext),
99
+ /** The host reports the tool as writing: the view never offers to re-run it after a block. */
100
+ toolWrites: resolveToolSafety(hostContext) === "writes",
101
+ };
102
+ }
103
+ /**
104
+ * The payload the view shows: the host's, else the stripped-result recovery's.
105
+ * Hosts that strip `structuredContent` (claude.ai) never latch a result under
106
+ * mcp-use 2.x; the recovery re-executes the call once when the stripped
107
+ * result arrives. It never fires on a cancelled or failed call, nor while a
108
+ * slow tool is still running (#176): those render their state.
109
+ */
110
+ function useShownView(call, callTool, policy = "auto", graceMs = DEFAULT_ASSUME_STRIPPED_AFTER_MS) {
58
111
  const recovery = useToolResultRecovery({
59
- resultReady: !isPending,
60
- cancelled: isCancelled,
61
- props: initialViewData,
112
+ resultReady: !call.isPending,
113
+ cancelled: call.isCancelled,
114
+ errored: call.isCallError,
115
+ props: call.initialViewData,
62
116
  isValid: isCompleteViewData,
63
- toolInput,
64
- hostContext,
117
+ toolInput: call.tool.toolInput,
118
+ hostContext: call.hostContext,
65
119
  callTool,
120
+ policy,
121
+ assumeStrippedAfterMs: graceMs,
66
122
  });
67
- const [prevRecovered, setPrevRecovered] = useState(null);
68
- if (recovery.data !== prevRecovered) {
69
- setPrevRecovered(recovery.data);
70
- // The host-delivered payload always wins; recovery only fills the gap.
71
- if (recovery.data && !viewData)
72
- setViewData(recovery.data);
73
- }
74
- const toggleFullscreen = useCallback(async () => {
75
- const newMode = displayMode === "fullscreen" ? "inline" : "fullscreen";
76
- try {
77
- // Advisory since 2.x: the promise only confirms the host processed the
78
- // request. `displayMode` from `useDisplayMode` updates reactively when
79
- // (and only when) the host actually applies the change.
80
- await requestDisplayMode({ mode: newMode });
81
- }
82
- catch (e) {
83
- console.error("Failed to toggle display mode:", e);
84
- }
85
- }, [displayMode, requestDisplayMode]);
86
- // Stable callTool callback (avoids a new object reference on every render)
87
- const callToolFn = useCallback(async (name, args) => {
88
- return callTool(name, args);
89
- }, [callTool]);
90
- const refreshView = useCallback(async () => {
91
- if (!viewData?._refreshParams)
92
- return;
93
- setIsRefreshing(true);
94
- try {
95
- const result = await callTool(refreshToolName, viewData._refreshParams);
96
- // Decode through the shared structured-first parser (one convention with
97
- // `useToolQuery`); a refresh returns the view envelope as `structuredContent`.
98
- const refreshed = parseToolResult(result);
99
- if (refreshed?.context && refreshed?.layout) {
100
- setViewData(refreshed);
101
- }
102
- void queryClient.invalidateQueries();
103
- }
104
- catch (e) {
105
- console.error("Failed to refresh view:", e);
106
- }
107
- finally {
108
- setIsRefreshing(false);
109
- }
110
- }, [callTool, refreshToolName, viewData]);
111
- // Called by LayoutBuilder when the user clicks Done. Commits the draft
112
- // layout (and any keys/steps edits) into the parent viewData so the
113
- // WidgetRenderer takes over showing the just-built layout.
123
+ const [view, setView] = useHostViewData(call.initialViewData, call.isPending, recovery.data, recovery.recoveredAt);
124
+ useReportShownPayload(view);
125
+ // A re-run's figures can differ from the answer in the chat (N23): stamp
126
+ // it, unless the original call failed and the chat never had figures.
127
+ const callFailed = call.isCallError || call.isCancelled;
128
+ const showRetried = useCallback((data) => setView({ data, source: "retry", reloadedAt: reloadedAtOf("retry", Date.now(), callFailed) }), [setView, callFailed]);
129
+ const showRefreshed = useCallback((data) => setView({
130
+ data,
131
+ source: "refresh",
132
+ reloadedAt: reloadedAtOf("refresh", Date.now(), callFailed),
133
+ }), [setView, callFailed]);
134
+ return {
135
+ view,
136
+ setView,
137
+ showRetried,
138
+ showRefreshed,
139
+ // Without a named tool nothing can re-run it: a plain failure. A policy
140
+ // block is its own state: the tool ran, and the view must not repeat it.
141
+ recoveryFailed: recovery.failed || recovery.blocked === "no-tool",
142
+ recoveryBlocked: recovery.blocked === "policy",
143
+ };
144
+ }
145
+ /**
146
+ * The view's own line of model context (toolkit#176 K20, N23): an error the
147
+ * user sees instead of the view, failed data steps, or data the view
148
+ * re-loaded itself (a recovery, a retry, a refresh). Renders nothing while
149
+ * there is nothing to report.
150
+ */
151
+ function ViewModelContext({ lifecycle, toolName, view, }) {
152
+ const content = describeViewForModel({
153
+ lifecycle,
154
+ toolName,
155
+ stepErrors: view.data?.context.errors,
156
+ stepsRetryable: Boolean(view.data?._refreshParams),
157
+ reloadedAt: view.reloadedAt,
158
+ reloadedBy: reloadedByOf(view.source),
159
+ });
160
+ return content ? _jsx(HostModelContext, { content: content }) : null;
161
+ }
162
+ function McpAppViewShell({ widgets, refreshToolName = "refresh-view", builderEnabled, labels, builderLabels, titleMode = "show", titleLevel = 2, renderTitle, slowHintAfterMs = DEFAULT_SLOW_HINT_MS, describeError, describeStep, recoverStrippedResult, strippedResultGraceMs, toolNameInQueryKey, }) {
163
+ const messages = useToolkitMessages();
164
+ const L = useMemo(() => ({ ...messages.view, ...labels }), [messages.view, labels]);
165
+ // The mcp-use 2.x view channels (all need the `bootstrapView` mount
166
+ // `mountMcpToolkitApp` provides); tools go through the HostBridge.
167
+ const call = useRenderCall();
168
+ const { safeArea, locale, timeZone } = useHostContext();
169
+ // A time in the language of the sentence around it, in the host's zone.
170
+ const formatLocale = resolveFormatLocale(useToolkitLocale(), locale);
171
+ // The client the view's widgets fetch through (an enclosing
172
+ // AppQueryProvider's, else the shared one): a refresh invalidates it.
173
+ const viewClient = useAppQueryClient();
174
+ const bridge = useHostBridge();
175
+ const callTool = useCallback((name, args) => bridge.callTool(name, args), [bridge]);
176
+ // The widget-facing shape (`args: object`, so generated input interfaces
177
+ // without an index signature pass straight through).
178
+ const callToolFn = useCallback((name, args) => bridge.callTool(name, args), [bridge]);
179
+ const shown = useShownView(call, callTool, recoverStrippedResult, strippedResultGraceMs);
180
+ const { view, setView } = shown;
181
+ const viewData = view.data;
182
+ const { lifecycle, retry: retryCall } = useViewLifecycle({
183
+ hasViewData: viewData !== null,
184
+ callStatus: call.tool.status,
185
+ cancelled: call.isCancelled,
186
+ callError: call.callError,
187
+ recoveryFailed: shown.recoveryFailed,
188
+ recoveryBlocked: shown.recoveryBlocked,
189
+ toolWrites: call.toolWrites,
190
+ toolName: call.toolName,
191
+ toolInput: call.tool.toolInput,
192
+ callTool,
193
+ isValid: isCompleteViewData,
194
+ onResult: shown.showRetried,
195
+ slowHintAfterMs,
196
+ });
197
+ const { frameRef, retry } = useRetryFocus(lifecycle.phase, retryCall);
198
+ const { isRefreshing, refreshView } = useViewRefresh({
199
+ viewData,
200
+ setViewData: shown.showRefreshed,
201
+ callTool,
202
+ refreshToolName,
203
+ labels: L,
204
+ client: viewClient,
205
+ });
206
+ const fullscreen = useFullscreenToggle(L);
207
+ // In-iframe build mode is purely a UI state — the LLM never sees the catalogue.
208
+ const [buildMode, setBuildMode] = useState(false);
209
+ useBuildModeFocus(buildMode, frameRef);
114
210
  const exitBuildMode = useCallback((commit) => {
115
- if (commit) {
116
- setViewData((prev) => prev
117
- ? {
118
- ...prev,
119
- layout: commit.layout,
120
- title: commit.title ?? prev.title,
121
- context: commit.context ?? prev.context,
122
- _refreshParams: {
123
- keys: commit.keys,
124
- steps: commit.steps,
125
- layout: commit.layout,
126
- title: commit.title ?? prev.title,
127
- },
128
- }
129
- : prev);
130
- }
211
+ if (commit)
212
+ setView((prev) => withBuilderCommit(prev, commit));
131
213
  setBuildMode(false);
132
- }, []);
133
- // `isPending` must not gate the render: on hosts that strip
134
- // `structuredContent` the 2.x latch stays "pending" forever, and recovered
135
- // viewData still has to replace the skeleton.
214
+ }, [setView]);
215
+ const viewContext = (_jsx(ViewModelContext, { lifecycle: lifecycle, toolName: call.toolName, view: view }));
216
+ // `isPending` must not gate the render: on stripping hosts the latch stays
217
+ // "pending" forever, and recovered viewData still has to replace it. The
218
+ // frame is the stable focus target of a retry (`useRetryFocus`).
136
219
  if (!viewData) {
137
- return _jsx(ViewPlaceholder, { cancelled: isCancelled, labels: effectiveLabels });
220
+ return (_jsxs("div", { ref: frameRef, tabIndex: -1, "data-slot": "mcp-app-view", className: "outline-hidden", children: [viewContext, _jsx(ViewPlaceholder, { lifecycle: lifecycle, labels: L, onRetry: retry, describeError: describeError })] }));
138
221
  }
139
- const isFullscreen = displayMode === "fullscreen";
140
- // Follow the server's own signal by default: render-view reports
141
- // `builderAvailable` (derived from `app.builder`), so the Build button only
142
- // shows when the catalogue/dashboard tools are actually registered. An
143
- // explicit `builderEnabled` prop forces the affordance on or off.
144
- const builderAvailable = builderEnabled ?? viewData.builderAvailable ?? false;
145
- return (_jsxs("main", { style: {
146
- // Fullscreen: the widget owns the viewport, so we take the full window
147
- // and handle our own scrolling. Inline: the host (Claude, ChatGPT) owns
148
- // sizing + scrolling and observes our intrinsic height via
149
- // `bootstrapView`'s auto-resize, so we let content dictate height and
150
- // avoid setting overflowY (which would clip our own content inside a
151
- // host that's already auto-sized to us).
152
- ...(isFullscreen ? { minHeight: "100vh", overflowY: "auto" } : null),
153
- paddingTop: safeArea.top,
154
- paddingRight: safeArea.right,
155
- paddingBottom: safeArea.bottom,
156
- paddingLeft: safeArea.left,
157
- }, children: [_jsx(ViewToolbar, { hidden: buildMode, viewData: viewData, builderAvailable: builderAvailable, isFullscreen: isFullscreen, isRefreshing: isRefreshing, labels: effectiveLabels, onRefresh: refreshView, onEnterBuildMode: () => setBuildMode(true), onToggleFullscreen: toggleFullscreen }), _jsx(StepErrors, { hidden: buildMode, errors: viewData.context.errors }), _jsx(AppQueryProvider, { callTool: callToolFn, children: _jsx(ViewBody, { buildMode: buildMode, viewData: viewData, widgets: widgets, callTool: callToolFn, onExit: exitBuildMode }) })] }));
222
+ return (_jsxs("div", { ref: frameRef, tabIndex: -1, "data-slot": "mcp-app-view", className: "outline-hidden", children: [viewContext, _jsxs("main", { style: {
223
+ // Fullscreen: the view owns the viewport and scrolls itself. Inline:
224
+ // the host sizes us from our intrinsic height (bootstrapView's
225
+ // auto-resize), so no overflow clipping there.
226
+ ...(fullscreen.isFullscreen ? { minHeight: "100vh", overflowY: "auto" } : null),
227
+ paddingTop: safeArea.top,
228
+ paddingRight: safeArea.right,
229
+ paddingBottom: safeArea.bottom,
230
+ paddingLeft: safeArea.left,
231
+ }, children: [_jsx(ViewToolbar, { hidden: buildMode, viewData: viewData, builderAvailable: builderEnabled ?? viewData.builderAvailable ?? false, isFullscreen: fullscreen.isFullscreen, canFullscreen: fullscreen.canFullscreen, isRefreshing: isRefreshing, labels: L, titleMode: titleMode, titleLevel: titleLevel, renderTitle: renderTitle, onRefresh: refreshView, onEnterBuildMode: () => setBuildMode(true), onToggleFullscreen: fullscreen.toggle, dataAsOf: formatDataAsOf(view.reloadedAt, formatLocale, timeZone) }), _jsx(StepErrors, { hidden: buildMode, errors: viewData.context.errors, steps: viewData._refreshParams?.steps, labels: L, describeStep: describeStep, onRetry: viewData._refreshParams ? () => void refreshView() : undefined }), _jsx(AppQueryProvider, { callTool: callToolFn, client: viewClient, toolNameInQueryKey: toolNameInQueryKey, children: _jsx(ViewBody, { buildMode: buildMode, viewData: viewData, widgets: widgets, callTool: callToolFn, builderLabels: builderLabels, onExit: exitBuildMode }) })] })] }));
232
+ }
233
+ /** How the model line names the view's own re-load of the shown payload. */
234
+ function reloadedByOf(source) {
235
+ if (source === "refresh" || source === "builder")
236
+ return source;
237
+ return "recovery";
238
+ }
239
+ /**
240
+ * The shown view with a builder commit applied (nothing to apply without
241
+ * data). A commit that carries the builder's live context shows figures the
242
+ * builder loaded itself (its catalogue call ran the steps again), so it is
243
+ * stamped like a refresh: the toolbar says when, and the model learns that
244
+ * they can differ from the result the chat answered from. A commit without a
245
+ * context keeps the shown figures, and with them their source and stamp.
246
+ */
247
+ function withBuilderCommit(view, commit) {
248
+ if (!view.data)
249
+ return view;
250
+ const data = applyBuilderCommit(view.data, commit);
251
+ if (!commit.context)
252
+ return { ...view, data };
253
+ return { data, source: "builder", reloadedAt: reloadedAtOf("builder", Date.now(), false) };
254
+ }
255
+ /** The toolbar's "as of" time of a re-loaded payload, `undefined` for any other. */
256
+ function formatDataAsOf(reloadedAt, locale, timeZone) {
257
+ return reloadedAt === null ? undefined : formatClockTime(reloadedAt, locale, timeZone);
158
258
  }
159
259
  //# sourceMappingURL=mcp-app-view.js.map
@@ -1 +1 @@
1
-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AAA;AACH,CAAC;AAED,4EAA4E;AAC5E,SAAS,YAAY,CAAC,MAAyB;IAC7C,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,MAAM,CAAA;IAC/D,OAAO,UAAU,CAAA;AACnB,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,iBAAiB,CAAC,IAAe,EAAE,MAAqB;IAC/D,IAAI,CAAC,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAA;IAC3B,MAAM,IAAI,GAAG,kBAAkB,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;IAClD,IAAI,CAAC,MAAM,CAAC,OAAO;QAAE,OAAO,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,CAAA;IAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,CAAC,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,KAAK,CAAC,EAAE,CAAA;AAC5F,CAAC;AAED,oFAAoF;AACpF,SAAS,cAAc,CACrB,UAAyB,EACzB,MAAc,EACd,QAA4B;IAE5B,OAAO,UAAU,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAA;AACxF,CAAC"}
@@ -2,7 +2,8 @@ import { type McpAppViewProps } from "./mcp-app-view.js";
2
2
  /**
3
3
  * Consumer-facing root for a toolkit-rendered MCP App. Composes the mcp-use
4
4
  * 2.x view plumbing around `McpAppView`: `ThemeProvider` applies the host's
5
- * theme/style variables to the document, and `McpUseHostBridgeProvider`
5
+ * theme/style variables to the document (with the host's font kept behind
6
+ * Geist, see `adoptHostFontVariables`), and `McpUseHostBridgeProvider`
6
7
  * installs the `HostBridge` (and view-scope flag) every toolkit widget below
7
8
  * resolves through `useHostBridge()`.
8
9
  *
@@ -18,7 +19,12 @@ export declare function McpToolkitApp(props: McpAppViewProps): import("react").J
18
19
  *
19
20
  * `bootstrapView` owns the mount: it connects the ext-apps postMessage bridge
20
21
  * to the host, installs an error boundary, and auto-reports size changes
21
- * (replacing 1.x's `createRoot` + `McpUseProvider` pair).
22
+ * (replacing 1.x's `createRoot` + `McpUseProvider` pair). The tool-result
23
+ * observer goes in first, so it sees the whole host lifecycle from the
24
+ * handshake on: the view then tells a stripped result from a slow tool and
25
+ * never re-runs a call the host is still answering (toolkit#176). A custom
26
+ * shell under its own `bootstrapView` calls `installToolResultObserver()`
27
+ * before it for the same effect.
22
28
  *
23
29
  * ```tsx
24
30
  * // main.tsx of the widget bundle
@@ -1 +1 @@
1
- {"version":3,"file":"mcp-toolkit-app.d.ts","sourceRoot":"","sources":["../../src/app/mcp-toolkit-app.tsx"],"names":[],"mappings":"AACA,OAAO,EAAc,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAGpE;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,eAAe,+BAQnD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI,CAE/D"}
1
+ {"version":3,"file":"mcp-toolkit-app.d.ts","sourceRoot":"","sources":["../../src/app/mcp-toolkit-app.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAc,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAsBpE;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,eAAe,+BAUnD;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI,CAG/D"}
@@ -1,11 +1,34 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { ThemeProvider, bootstrapView } from "mcp-use/react";
2
+ import { useLayoutEffect } from "react";
3
+ import { ThemeProvider, bootstrapView, useHostContext } from "mcp-use/react";
4
+ import { installToolResultObserver } from "../lib/tool-result-observer.js";
5
+ import { adoptHostFontVariables } from "../theme/host-fonts.js";
3
6
  import { McpAppView } from "./mcp-app-view.js";
4
7
  import { McpUseHostBridgeProvider } from "./mcp-use-host-bridge.js";
8
+ /**
9
+ * Keeps Geist first when the host sends its font. mcp-use's `ThemeProvider`
10
+ * writes the host's SEP-1865 style variables inline on `<html>`, including
11
+ * `--font-sans`/`--font-mono`, which share their names with the toolkit's font
12
+ * roles and would replace the Geist-first stacks whole. This component sits
13
+ * ABOVE that provider on purpose: a parent's layout effect runs after its
14
+ * children's, so the host variables are already applied when it moves the
15
+ * font pair into the fallback slot (`adoptHostFontVariables`). Both effects
16
+ * key on the same host-context snapshot, so they run in the same commit.
17
+ */
18
+ function HostFontRoles({ children }) {
19
+ const { hostContext } = useHostContext();
20
+ useLayoutEffect(() => {
21
+ if (typeof document === "undefined")
22
+ return;
23
+ adoptHostFontVariables(document.documentElement.style, hostContext?.styles?.variables);
24
+ }, [hostContext]);
25
+ return children;
26
+ }
5
27
  /**
6
28
  * Consumer-facing root for a toolkit-rendered MCP App. Composes the mcp-use
7
29
  * 2.x view plumbing around `McpAppView`: `ThemeProvider` applies the host's
8
- * theme/style variables to the document, and `McpUseHostBridgeProvider`
30
+ * theme/style variables to the document (with the host's font kept behind
31
+ * Geist, see `adoptHostFontVariables`), and `McpUseHostBridgeProvider`
9
32
  * installs the `HostBridge` (and view-scope flag) every toolkit widget below
10
33
  * resolves through `useHostBridge()`.
11
34
  *
@@ -15,7 +38,7 @@ import { McpUseHostBridgeProvider } from "./mcp-use-host-bridge.js";
15
38
  * composing a custom view under your own `bootstrapView` call.
16
39
  */
17
40
  export function McpToolkitApp(props) {
18
- return (_jsx(ThemeProvider, { children: _jsx(McpUseHostBridgeProvider, { children: _jsx(McpAppView, { ...props }) }) }));
41
+ return (_jsx(HostFontRoles, { children: _jsx(ThemeProvider, { children: _jsx(McpUseHostBridgeProvider, { children: _jsx(McpAppView, { ...props }) }) }) }));
19
42
  }
20
43
  /**
21
44
  * Mount the toolkit app as the document's MCP App view — the bundle entry
@@ -23,7 +46,12 @@ export function McpToolkitApp(props) {
23
46
  *
24
47
  * `bootstrapView` owns the mount: it connects the ext-apps postMessage bridge
25
48
  * to the host, installs an error boundary, and auto-reports size changes
26
- * (replacing 1.x's `createRoot` + `McpUseProvider` pair).
49
+ * (replacing 1.x's `createRoot` + `McpUseProvider` pair). The tool-result
50
+ * observer goes in first, so it sees the whole host lifecycle from the
51
+ * handshake on: the view then tells a stripped result from a slow tool and
52
+ * never re-runs a call the host is still answering (toolkit#176). A custom
53
+ * shell under its own `bootstrapView` calls `installToolResultObserver()`
54
+ * before it for the same effect.
27
55
  *
28
56
  * ```tsx
29
57
  * // main.tsx of the widget bundle
@@ -31,6 +59,7 @@ export function McpToolkitApp(props) {
31
59
  * ```
32
60
  */
33
61
  export function mountMcpToolkitApp(props) {
62
+ installToolResultObserver();
34
63
  bootstrapView({ default: () => _jsx(McpToolkitApp, { ...props }) });
35
64
  }
36
65
  //# sourceMappingURL=mcp-toolkit-app.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mcp-toolkit-app.js","sourceRoot":"","sources":["../../src/app/mcp-toolkit-app.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAC5D,OAAO,EAAE,UAAU,EAAwB,MAAM,mBAAmB,CAAA;AACpE,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAA;AAEnE;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,aAAa,CAAC,KAAsB;IAClD,OAAO,CACL,KAAC,aAAa,cACZ,KAAC,wBAAwB,cACvB,KAAC,UAAU,OAAK,KAAK,GAAI,GACA,GACb,CACjB,CAAA;AACH,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAsB;IACvD,aAAa,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,KAAC,aAAa,OAAK,KAA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,EAAE,CAAC,CAAA;AAChE,CAAC"}
@@ -1,6 +1,9 @@
1
1
  import { type ReactNode } from "react";
2
- /** Whether the subtree runs inside an mcp-use view (see {@link McpUseViewContext}). */
3
- export declare function useIsInsideMcpUseView(): boolean;
2
+ /**
3
+ * The sink for the payload a view shows, or `null` outside a
4
+ * {@link McpUseHostBridgeProvider}. `McpAppView` reports through it.
5
+ */
6
+ export declare function useViewResultSink(): ((payload: unknown) => void) | null;
4
7
  /**
5
8
  * Install the `mcp-use` {@link HostBridge} (plus the view-scope flag) for a
6
9
  * subtree inside an mcp-use 2.x view.
@@ -14,10 +17,16 @@ export declare function useIsInsideMcpUseView(): boolean;
14
17
  * - `sendFollowup` / `openExternal` — `useSendFollowUp` / `useOpenExternal`;
15
18
  * while the bridge is not connected (local `file://` preview), `openExternal`
16
19
  * throws into `toHostBridge`'s documented `window.open` fallback.
17
- * - `setModelContext` — writes `{ __model_context }` into the view state,
18
- * which hosts receive via `ui/update-model-context` (ext-apps) or
19
- * `widgetState` (ChatGPT). The key is a toolkit-owned convention since 2.x.
20
- * - `getWidgetData` — the rendering tool's `structuredContent` once ready.
20
+ * - `setModelContext` — one line of the view's model-context tree (an mcp-use
21
+ * `ModelContext` node beside the ones `HostModelContext` and
22
+ * `useHostModelContext` register), which hosts receive via
23
+ * `ui/update-model-context` (ext-apps) or `widgetState` (ChatGPT). The
24
+ * provider does not seed mcp-use's view state, so a widget's own
25
+ * `useViewState(default)` keeps its default (N29).
26
+ * - `getWidgetData` — the payload the view reports it shows
27
+ * ({@link useViewResultSink}): the host's, or the one it got by re-running
28
+ * the tool when the host stripped it or kept back an unusable one. Without
29
+ * a report, the rendering tool's `structuredContent` once ready.
21
30
  *
22
31
  * Must render inside a `bootstrapView`-mounted tree (the mcp-use hooks throw
23
32
  * otherwise) — `McpToolkitApp` does this for the standard bundle; use it