@marimo-team/frontend 0.16.0 → 0.16.2

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 (284) hide show
  1. package/dist/assets/ConnectedDataExplorerComponent-B5cPvWoQ.js +19 -0
  2. package/dist/assets/{ImageComparisonComponent-fTHv1Ih0.js → ImageComparisonComponent-CqR26LSv.js} +1 -1
  3. package/dist/assets/{VegaLite-Bdi-TyfY.js → VegaLite-DvQDATwI.js} +1 -1
  4. package/dist/assets/_baseEach--KDTwKbG.js +1 -0
  5. package/dist/assets/_baseMap-Cu3o-eyO.js +1 -0
  6. package/dist/assets/{_baseUniq-CCgDNtZb.js → _baseUniq-y7ZXnMo1.js} +1 -1
  7. package/dist/assets/{_createAggregator-DcD0kTA5.js → _createAggregator-ZcHkHPNJ.js} +1 -1
  8. package/dist/assets/{agent-panel-Crv430aI.js → agent-panel-B91RoLct.js} +76 -57
  9. package/dist/assets/{any-language-editor-CQh552Wu.js → any-language-editor-CxfHcm5h.js} +1 -1
  10. package/dist/assets/{architectureDiagram-W76B3OCA-BAJeBxzt.js → architectureDiagram-W76B3OCA-BQsvK8uR.js} +1 -1
  11. package/dist/assets/{between-horizontal-start-Boxgxbt_.js → between-horizontal-start-BmYToIaM.js} +1 -1
  12. package/dist/assets/{blockDiagram-QIGZ2CNN-CL-1svEK.js → blockDiagram-QIGZ2CNN-r3HgCj4w.js} +1 -1
  13. package/dist/assets/{c4Diagram-FPNF74CW-BbEqbCTl.js → c4Diagram-FPNF74CW-BJbPNt41.js} +1 -1
  14. package/dist/assets/channel-DFaEx1fu.js +1 -0
  15. package/dist/assets/chat-panel-IoPMv8e2.js +3 -0
  16. package/dist/assets/{chunk-4BX2VUAB-C--8TXeE.js → chunk-4BX2VUAB-Dv4MZ9Hj.js} +1 -1
  17. package/dist/assets/{chunk-55IACEB6-Bj00HDqq.js → chunk-55IACEB6-CM4AHquB.js} +1 -1
  18. package/dist/assets/{chunk-FMBD7UC4-C-lhB6hN.js → chunk-FMBD7UC4-C_Zz0ENB.js} +1 -1
  19. package/dist/assets/{chunk-K7UQS3LO-B-pGTXPt.js → chunk-K7UQS3LO-DYSmiXYq.js} +1 -1
  20. package/dist/assets/{chunk-QN33PNHL-DqUzGhvm.js → chunk-QN33PNHL-QM4OPuQP.js} +1 -1
  21. package/dist/assets/{chunk-QZHKN3VN-TntJHfSk.js → chunk-QZHKN3VN-CfAsGyeB.js} +1 -1
  22. package/dist/assets/{chunk-TVAH2DTR-HUJb1psV.js → chunk-TVAH2DTR-6j_Cpjsi.js} +1 -1
  23. package/dist/assets/{chunk-TZMSLE5B-BK3C__t3.js → chunk-TZMSLE5B-BHslFJQE.js} +1 -1
  24. package/dist/assets/{circle-play-DBLOv1Yu.js → circle-play-CK3UZRYQ.js} +1 -1
  25. package/dist/assets/classDiagram-KNZD7YFC-BsZtvV5O.js +1 -0
  26. package/dist/assets/classDiagram-v2-RKCZMP56-BsZtvV5O.js +1 -0
  27. package/dist/assets/{clear-button-BeoFbEKH.js → clear-button-C4fDVSv8.js} +1 -1
  28. package/dist/assets/clone-YBEvPE-s.js +1 -0
  29. package/dist/assets/command-palette-D7hOfvf6.js +1 -0
  30. package/dist/assets/{common-C7oJcmCT.js → common-D-lbuUwz.js} +1 -1
  31. package/dist/assets/{compile-7L0MwhyI.js → compile-DVQe1Mzk.js} +1 -1
  32. package/dist/assets/{cose-bilkent-S5V4N54A-BMkGLcVC.js → cose-bilkent-S5V4N54A-D-IS7WC8.js} +1 -1
  33. package/dist/assets/{dagre-5GWH7T2D-BJtRienS.js → dagre-5GWH7T2D-lYu-tEWT.js} +1 -1
  34. package/dist/assets/{data-grid-overlay-editor-DBkmGtNs.js → data-grid-overlay-editor-C5peOCit.js} +1 -1
  35. package/dist/assets/datasources-panel-D3NA20uZ.js +1 -0
  36. package/dist/assets/{dependency-graph-panel-DEdOxp2X.js → dependency-graph-panel-BGVYOfkV.js} +1 -1
  37. package/dist/assets/{diagram-N5W7TBWH-CmECY3nb.js → diagram-N5W7TBWH-BnvIuYUp.js} +1 -1
  38. package/dist/assets/{diagram-QEK2KX5R-DMOVSNKD.js → diagram-QEK2KX5R-DemedRK3.js} +1 -1
  39. package/dist/assets/{diagram-S2PKOQOG-BiJ96PNQ.js → diagram-S2PKOQOG-iiY7AuyH.js} +1 -1
  40. package/dist/assets/{documentation-panel-xULhaEv3.js → documentation-panel-C3dSwOSQ.js} +1 -1
  41. package/dist/assets/edit-page-C5TsEeSo.js +129 -0
  42. package/dist/assets/{ellipsis-vertical-BBqXIlc2.js → ellipsis-vertical-CazJl8M7.js} +1 -1
  43. package/dist/assets/{empty-state-B3dA3G5P.js → empty-state-DW308mFO.js} +1 -1
  44. package/dist/assets/{erDiagram-AWTI2OKA-MP1DiFRo.js → erDiagram-AWTI2OKA-6wQ8Ugg0.js} +1 -1
  45. package/dist/assets/{error-panel-Cc1sv-Ag.js → error-panel-D1VnJ1yP.js} +1 -1
  46. package/dist/assets/file-explorer-panel-0oVd4t-D.js +1 -0
  47. package/dist/assets/{flowDiagram-PVAE7QVJ-BX7caPp7.js → flowDiagram-PVAE7QVJ-C55IUWjm.js} +1 -1
  48. package/dist/assets/{ganttDiagram-OWAHRB6G-B462g4Yf.js → ganttDiagram-OWAHRB6G-DmqCM6ME.js} +4 -4
  49. package/dist/assets/{gitGraphDiagram-NY62KEGX-CGgvZ9-9.js → gitGraphDiagram-NY62KEGX-DBvhAeM_.js} +1 -1
  50. package/dist/assets/{glide-data-editor-C0gUFZON.js → glide-data-editor-CHNuHidQ.js} +4 -4
  51. package/dist/assets/{graph-CHRVBzY5.js → graph-CG6BgUWQ.js} +1 -1
  52. package/dist/assets/home-page-dgivXuSR.js +9 -0
  53. package/dist/assets/{index-Clbi_Yaq.js → index-BTGpssVX.js} +1 -1
  54. package/dist/assets/{index-CQDrxQ0j.js → index-BYVZlBF8.js} +1 -1
  55. package/dist/assets/{index-lYa_leQE.js → index-BelfnXwL.js} +1 -1
  56. package/dist/assets/{index-DRMm6SNo.js → index-BneyUujp.js} +1 -1
  57. package/dist/assets/{index-BY93Ejhl.js → index-C02SqeRj.js} +1 -1
  58. package/dist/assets/{index-C-8WADat.js → index-C7dtgr9A.js} +1 -1
  59. package/dist/assets/{index-D9UKkrr2.js → index-CAQvMTzM.js} +1 -1
  60. package/dist/assets/index-CGDMlQfO.css +1 -0
  61. package/dist/assets/index-CelXfcd8.js +580 -0
  62. package/dist/assets/{index-vmICa5KN.js → index-Csd6QrCV.js} +1 -1
  63. package/dist/assets/{index-DoRmcrKM.js → index-CtPksxf0.js} +1 -1
  64. package/dist/assets/{index-C1v_Z9et.js → index-Cxyk7pt-.js} +1 -1
  65. package/dist/assets/{index-CpTPJo4k.js → index-DAZ-9ri2.js} +1 -1
  66. package/dist/assets/{index-DEQvTChO.js → index-DONRrmA2.js} +1 -1
  67. package/dist/assets/{index-C4Tn5NvJ.js → index-Db36XTG_.js} +1 -1
  68. package/dist/assets/{index-z9bohSQJ.js → index-DdIhdEVw.js} +1 -1
  69. package/dist/assets/{index-C-GhZ7ti.js → index-M_pBKDSe.js} +1 -1
  70. package/dist/assets/{index-C77h_TXN.js → index-_luCZMLM.js} +1 -1
  71. package/dist/assets/{index-D1vmG6DS.js → index-mkubqy9-.js} +1 -1
  72. package/dist/assets/{index-BVgAenPd.js → index-sbO9UaUU.js} +1 -1
  73. package/dist/assets/{index-CWMgowgL.js → index-z4krxQ4j.js} +1 -1
  74. package/dist/assets/infoDiagram-STP46IZ2-wTALjfPc.js +2 -0
  75. package/dist/assets/{isEmpty-DU_ogP_D.js → isEmpty-CqX_YTIf.js} +1 -1
  76. package/dist/assets/{journeyDiagram-BIP6EPQ6-C6EgLP_Q.js → journeyDiagram-BIP6EPQ6-Y5w_Tqe_.js} +1 -1
  77. package/dist/assets/{kanban-definition-6OIFK2YF-BXzYO1yj.js → kanban-definition-6OIFK2YF-DbXs5Rxi.js} +1 -1
  78. package/dist/assets/{layout-jihVw5-i.js → layout-BCNPDACj.js} +1 -1
  79. package/dist/assets/{linear-C4blANlC.js → linear-uO6UVhXt.js} +1 -1
  80. package/dist/assets/links-Drv7cJgN.js +7 -0
  81. package/dist/assets/{logs-panel-D401qzZh.js → logs-panel-BEQ1eRUp.js} +1 -1
  82. package/dist/assets/{markdown-renderer-Cd9eYyaL.js → markdown-renderer-Dmzbb00W.js} +20 -20
  83. package/dist/assets/{mermaid-BEVuRz_O.js → mermaid-qRc4MXIj.js} +1 -1
  84. package/dist/assets/{mermaid.core-CaSnaLH0.js → mermaid.core-CvvJtCRj.js} +4 -4
  85. package/dist/assets/min-DYUOb1RR.js +1 -0
  86. package/dist/assets/{mindmap-definition-Q6HEUPPD-BXUM5MT2.js → mindmap-definition-Q6HEUPPD-G5NognM-.js} +1 -1
  87. package/dist/assets/{number-overlay-editor-4uWXGlPG.js → number-overlay-editor-DPr5sHFu.js} +1 -1
  88. package/dist/assets/outline-panel-gxQXvVi4.js +1 -0
  89. package/dist/assets/{packages-panel-CJL0MVlj.js → packages-panel-B1T0VPlg.js} +1 -1
  90. package/dist/assets/{pieDiagram-ADFJNKIX-Dxt5PVNo.js → pieDiagram-ADFJNKIX-DK9SHkfc.js} +1 -1
  91. package/dist/assets/{quadrantDiagram-LMRXKWRM-D4pUaA31.js → quadrantDiagram-LMRXKWRM-D1DdWF8C.js} +1 -1
  92. package/dist/assets/{react-plotly-cJZ0VWBq.js → react-plotly-CTwajqCb.js} +1 -1
  93. package/dist/assets/{requirementDiagram-4UW4RH46-DVRTjgas.js → requirementDiagram-4UW4RH46-DnjDAypr.js} +1 -1
  94. package/dist/assets/{run-page-BUEnMC9w.js → run-page-CQY9im22.js} +1 -1
  95. package/dist/assets/{sankeyDiagram-GR3RE2ED-CVFnD9C-.js → sankeyDiagram-GR3RE2ED-B67Va-ER.js} +1 -1
  96. package/dist/assets/{scratchpad-panel-BIgRENkI.js → scratchpad-panel-DlDfcDtW.js} +1 -1
  97. package/dist/assets/{secrets-panel-xY5-V_BD.js → secrets-panel-BDGyuGZA.js} +1 -1
  98. package/dist/assets/{sequenceDiagram-C3RYC4MD-_lY4ZN_S.js → sequenceDiagram-C3RYC4MD-DiWgZPtN.js} +1 -1
  99. package/dist/assets/{slides-component-DMjQomc3.css → slides-component-C-LoGC1U.css} +1 -1
  100. package/dist/assets/{slides-component-Xjymwj7X.js → slides-component-DhpPRtQp.js} +1 -1
  101. package/dist/assets/snippets-panel-CLkBXhJ2.js +1 -0
  102. package/dist/assets/sortBy-D4OG7w4O.js +1 -0
  103. package/dist/assets/{state-C4NiC9tO.js → state-Dz_3JyED.js} +1 -1
  104. package/dist/assets/{stateDiagram-KXAO66HF-Da0JQWCn.js → stateDiagram-KXAO66HF-ByF2AULw.js} +1 -1
  105. package/dist/assets/stateDiagram-v2-UMBNRL4Z-CtBJqosP.js +1 -0
  106. package/dist/assets/storage-Dr0CC44z.js +26 -0
  107. package/dist/assets/{terminal-BPwTkXae.js → terminal-BtdissBf.js} +1 -1
  108. package/dist/assets/{time-Dv5_Ouz_.js → time-DKdOTnQg.js} +1 -1
  109. package/dist/assets/{timeline-definition-XQNQX7LJ-Dxh5Zu2e.js → timeline-definition-XQNQX7LJ-DzER9bf6.js} +1 -1
  110. package/dist/assets/tracing-Dpx5M-u3.js +2 -0
  111. package/dist/assets/{tracing-panel-DAzrzNmm.js → tracing-panel-hCjBkSER.js} +2 -2
  112. package/dist/assets/{trash-Dc6DSjz_.js → trash-C6Ko-g5q.js} +1 -1
  113. package/dist/assets/{tree-jheoerAX.js → tree-BHN2gcCF.js} +6 -6
  114. package/dist/assets/{treemap-75Q7IDZK-IgpxeGaf.js → treemap-75Q7IDZK-DR79Mhzt.js} +27 -27
  115. package/dist/assets/variable-panel-PFBCFz36.js +1 -0
  116. package/dist/assets/{vega-component-BpfpiPKI.js → vega-component-Db6-uY4C.js} +1 -1
  117. package/dist/assets/worker-fHbtoWvT.js +1 -0
  118. package/dist/assets/{xychartDiagram-6GGTOJPD-CmNigJ31.js → xychartDiagram-6GGTOJPD-DWzBP3tZ.js} +1 -1
  119. package/dist/index.html +2 -2
  120. package/package.json +5 -4
  121. package/src/__mocks__/requests.ts +1 -0
  122. package/src/components/app-config/user-config-form.tsx +46 -1
  123. package/src/components/chat/acp/__tests__/__snapshots__/prompt.test.ts.snap +62 -43
  124. package/src/components/chat/acp/__tests__/atoms.test.ts +1 -1
  125. package/src/components/chat/acp/__tests__/state.test.ts +36 -36
  126. package/src/components/chat/acp/agent-panel.tsx +24 -27
  127. package/src/components/chat/acp/blocks.tsx +6 -6
  128. package/src/components/chat/acp/prompt.ts +62 -43
  129. package/src/components/chat/chat-panel.tsx +5 -1
  130. package/src/components/chat/markdown-renderer.tsx +6 -10
  131. package/src/components/chat/tool-call-accordion.tsx +52 -20
  132. package/src/components/data-table/SearchBar.tsx +8 -7
  133. package/src/components/data-table/__tests__/column_formatting.test.ts +50 -35
  134. package/src/components/data-table/__tests__/columns.test.tsx +38 -0
  135. package/src/components/data-table/__tests__/data-table.test.tsx +39 -1
  136. package/src/components/data-table/cell-hover-template/feature.ts +14 -0
  137. package/src/components/data-table/cell-hover-template/types.ts +11 -0
  138. package/src/components/data-table/charts/components/form-fields.tsx +41 -37
  139. package/src/components/data-table/charts/forms/common-chart.tsx +2 -2
  140. package/src/components/data-table/column-explorer-panel/column-explorer.tsx +5 -2
  141. package/src/components/data-table/column-formatting/feature.ts +62 -29
  142. package/src/components/data-table/column-formatting/types.ts +1 -0
  143. package/src/components/data-table/column-header.tsx +3 -1
  144. package/src/components/data-table/column-summary/chart-spec-model.tsx +24 -7
  145. package/src/components/data-table/column-summary/column-summary.tsx +18 -9
  146. package/src/components/data-table/columns.tsx +63 -20
  147. package/src/components/data-table/data-table.tsx +10 -2
  148. package/src/components/data-table/date-popover.tsx +85 -75
  149. package/src/components/data-table/filter-pills.tsx +14 -9
  150. package/src/components/data-table/header-items.tsx +5 -1
  151. package/src/components/data-table/pagination.tsx +20 -13
  152. package/src/components/data-table/renderers.tsx +36 -0
  153. package/src/components/data-table/row-viewer-panel/row-viewer.tsx +10 -8
  154. package/src/components/data-table/schemas.ts +16 -0
  155. package/src/components/datasources/column-preview.tsx +6 -2
  156. package/src/components/datasources/datasources.tsx +8 -12
  157. package/src/components/editor/Cell.tsx +2 -0
  158. package/src/components/editor/ai/transport/chat-transport.tsx +4 -1
  159. package/src/components/editor/cell/CellStatus.tsx +23 -20
  160. package/src/components/editor/cell/CreateCellButton.tsx +3 -4
  161. package/src/components/editor/cell/code/language-toggle.tsx +3 -4
  162. package/src/components/editor/chrome/wrapper/footer-items/machine-stats.tsx +39 -28
  163. package/src/components/editor/controls/notebook-menu-dropdown.tsx +4 -2
  164. package/src/components/editor/errors/sql-validation-errors.tsx +34 -0
  165. package/src/components/editor/file-tree/requesting-tree.tsx +14 -8
  166. package/src/components/editor/output/ConsoleOutput.tsx +13 -1
  167. package/src/components/editor/output/MarimoErrorOutput.tsx +60 -1
  168. package/src/components/editor/renderers/CellArray.tsx +3 -4
  169. package/src/components/editor/renderers/slides-layout/slides-layout.tsx +3 -3
  170. package/src/components/editor/renderers/slides-layout/types.ts +1 -0
  171. package/src/components/pages/home-page.tsx +4 -1
  172. package/src/components/slides/slides-component.tsx +1 -1
  173. package/src/components/slides/slides.css +6 -0
  174. package/src/components/terminal/theme.tsx +1 -0
  175. package/src/components/tracing/tracing-spec.ts +5 -4
  176. package/src/components/ui/range-slider.tsx +4 -2
  177. package/src/components/ui/slider.tsx +3 -1
  178. package/src/components/variables/variables-table.tsx +3 -0
  179. package/src/core/MarimoApp.tsx +9 -6
  180. package/src/core/ai/context/__tests__/registry.test.ts +6 -4
  181. package/src/core/ai/context/providers/cell-output.ts +4 -20
  182. package/src/core/ai/context/providers/error.ts +3 -1
  183. package/src/core/ai/context/providers/file.ts +7 -2
  184. package/src/core/ai/context/providers/tables.ts +3 -2
  185. package/src/core/ai/context/providers/variable.ts +6 -4
  186. package/src/core/ai/staged-cells.ts +34 -1
  187. package/src/core/cells/__tests__/add-missing-import.test.ts +67 -22
  188. package/src/core/cells/add-missing-import.ts +24 -7
  189. package/src/core/cells/cells.ts +26 -27
  190. package/src/core/cells/logs.ts +1 -1
  191. package/src/core/codemirror/find-replace/search-highlight.ts +3 -1
  192. package/src/core/codemirror/language/LanguageAdapters.ts +9 -3
  193. package/src/core/codemirror/language/__tests__/extension.test.ts +24 -0
  194. package/src/core/codemirror/language/__tests__/sql-validation.test.ts +133 -0
  195. package/src/core/codemirror/language/languages/sql/sql-mode.ts +20 -0
  196. package/src/core/codemirror/language/languages/sql/sql.ts +90 -3
  197. package/src/core/codemirror/language/languages/sql/validation-errors.ts +79 -0
  198. package/src/core/codemirror/language/panel/panel.tsx +8 -2
  199. package/src/core/codemirror/language/panel/sql.tsx +81 -4
  200. package/src/core/codemirror/lsp/notebook-lsp.ts +8 -2
  201. package/src/core/codemirror/readonly/__tests__/extension.test.ts +1 -1
  202. package/src/core/codemirror/rtc/loro/awareness.ts +52 -17
  203. package/src/core/codemirror/rtc/loro/sync.ts +12 -4
  204. package/src/core/config/config-schema.ts +1 -0
  205. package/src/core/config/config.ts +4 -0
  206. package/src/core/config/feature-flag.tsx +3 -1
  207. package/src/core/datasets/request-registry.ts +17 -1
  208. package/src/core/hotkeys/hotkeys.ts +8 -4
  209. package/src/core/i18n/__tests__/locale-provider.test.tsx +176 -0
  210. package/src/core/i18n/locale-provider.tsx +35 -0
  211. package/src/core/i18n/with-locale.tsx +12 -0
  212. package/src/core/islands/bridge.ts +1 -0
  213. package/src/core/islands/components/web-components.tsx +13 -10
  214. package/src/core/islands/main.ts +1 -0
  215. package/src/core/kernel/RuntimeState.ts +4 -1
  216. package/src/core/kernel/messages.ts +3 -2
  217. package/src/core/network/DeferredRequestRegistry.ts +16 -4
  218. package/src/core/network/requests-network.ts +7 -0
  219. package/src/core/network/requests-static.ts +1 -0
  220. package/src/core/network/requests-toasting.ts +1 -0
  221. package/src/core/network/types.ts +2 -0
  222. package/src/core/runtime/runtime.ts +5 -4
  223. package/src/core/wasm/bridge.ts +10 -1
  224. package/src/core/wasm/store.ts +4 -1
  225. package/src/core/wasm/worker/message-buffer.ts +3 -2
  226. package/src/core/websocket/types.ts +22 -16
  227. package/src/core/websocket/useMarimoWebSocket.tsx +4 -0
  228. package/src/hooks/useFormatting.ts +97 -0
  229. package/src/hooks/useTimer.ts +8 -5
  230. package/src/plugins/core/registerReactComponent.tsx +39 -29
  231. package/src/plugins/impl/DataTablePlugin.tsx +15 -4
  232. package/src/plugins/impl/RangeSliderPlugin.tsx +5 -3
  233. package/src/plugins/impl/SliderPlugin.tsx +3 -1
  234. package/src/plugins/impl/anywidget/model.ts +16 -5
  235. package/src/plugins/impl/data-editor/types.ts +7 -5
  236. package/src/plugins/impl/data-explorer/components/column-summary.tsx +20 -13
  237. package/src/plugins/impl/data-frames/DataFramePlugin.tsx +17 -5
  238. package/src/plugins/impl/panel/utils.ts +6 -4
  239. package/src/plugins/layout/OutlinePlugin.tsx +69 -0
  240. package/src/plugins/layout/StatPlugin.tsx +4 -1
  241. package/src/plugins/plugins.ts +2 -0
  242. package/src/stories/dataframe.stories.tsx +2 -0
  243. package/src/utils/__tests__/dates.test.ts +45 -24
  244. package/src/utils/__tests__/dom.test.ts +167 -0
  245. package/src/utils/__tests__/numbers.test.ts +42 -30
  246. package/src/utils/__tests__/once.test.ts +187 -0
  247. package/src/utils/dates.ts +15 -10
  248. package/src/utils/dom.ts +55 -0
  249. package/src/utils/edit-distance.ts +8 -6
  250. package/src/utils/errors.ts +1 -1
  251. package/src/utils/id-tree.tsx +21 -10
  252. package/src/utils/localStorage.ts +13 -4
  253. package/src/utils/numbers.ts +11 -11
  254. package/src/utils/once.ts +32 -0
  255. package/src/utils/paths.ts +4 -1
  256. package/src/utils/pluralize.ts +12 -5
  257. package/src/utils/python-poet/poet.ts +30 -15
  258. package/src/utils/time.ts +5 -1
  259. package/dist/assets/ConnectedDataExplorerComponent-BErMbWvG.js +0 -19
  260. package/dist/assets/_baseEach-CNBxBxvS.js +0 -1
  261. package/dist/assets/_baseMap-D1WHjKrd.js +0 -1
  262. package/dist/assets/channel-_2eNSz0n.js +0 -1
  263. package/dist/assets/chat-panel-CXh5Wl6C.js +0 -3
  264. package/dist/assets/classDiagram-KNZD7YFC-BGmh9POF.js +0 -1
  265. package/dist/assets/classDiagram-v2-RKCZMP56-BGmh9POF.js +0 -1
  266. package/dist/assets/clone-BFDSPAj3.js +0 -1
  267. package/dist/assets/command-palette-CXZiSv0I.js +0 -1
  268. package/dist/assets/datasources-panel-B7FbYLiy.js +0 -1
  269. package/dist/assets/edit-page-BrYda9VE.js +0 -129
  270. package/dist/assets/file-explorer-panel-Bw59Kva1.js +0 -1
  271. package/dist/assets/home-page-Fb2osjys.js +0 -9
  272. package/dist/assets/index-Cx0bsY1w.css +0 -1
  273. package/dist/assets/index-DKEudB02.js +0 -578
  274. package/dist/assets/infoDiagram-STP46IZ2-CVyrdLc8.js +0 -2
  275. package/dist/assets/links-D59GIweI.js +0 -7
  276. package/dist/assets/min-DUMu_zeK.js +0 -1
  277. package/dist/assets/outline-panel-DIzkvm2I.js +0 -1
  278. package/dist/assets/snippets-panel-CTPYW41n.js +0 -1
  279. package/dist/assets/sortBy-BNZKwiq_.js +0 -1
  280. package/dist/assets/stateDiagram-v2-UMBNRL4Z-D5lYZOOt.js +0 -1
  281. package/dist/assets/storage-CMdLzB_c.js +0 -26
  282. package/dist/assets/tracing-BCIurUfa.js +0 -2
  283. package/dist/assets/variable-panel-DYAiLBmF.js +0 -1
  284. package/dist/assets/worker-X5rxzQGQ.js +0 -1
@@ -1,6 +1,10 @@
1
1
  /* Copyright 2024 Marimo. All rights reserved. */
2
2
 
3
- import { NotebookPenIcon, SquareArrowOutUpRightIcon } from "lucide-react";
3
+ import {
4
+ InfoIcon,
5
+ NotebookPenIcon,
6
+ SquareArrowOutUpRightIcon,
7
+ } from "lucide-react";
4
8
  import { Fragment, type JSX } from "react";
5
9
  import {
6
10
  Accordion,
@@ -72,6 +76,8 @@ export const MarimoErrorOutput = ({
72
76
  titleContents = "Ancestor stopped";
73
77
  alertVariant = "default";
74
78
  titleColor = "text-secondary-foreground";
79
+ } else if (errors.some((e) => e.type === "sql-error")) {
80
+ titleContents = "SQL Error in statement";
75
81
  } else {
76
82
  // Check for exception type
77
83
  const exceptionError = errors.find((e) => e.type === "exception");
@@ -126,6 +132,10 @@ export const MarimoErrorOutput = ({
126
132
  const unknownErrors = errors.filter(
127
133
  (e): e is Extract<MarimoError, { type: "unknown" }> => e.type === "unknown",
128
134
  );
135
+ const sqlErrors = errors.filter(
136
+ (e): e is Extract<MarimoError, { type: "sql-error" }> =>
137
+ e.type === "sql-error",
138
+ );
129
139
 
130
140
  const openScratchpad = () => {
131
141
  chromeActions.openApplication("scratchpad");
@@ -485,6 +495,55 @@ export const MarimoErrorOutput = ({
485
495
  );
486
496
  }
487
497
 
498
+ if (sqlErrors.length > 0) {
499
+ messages.push(
500
+ <div key="sql-errors">
501
+ {sqlErrors.map((error, idx) => {
502
+ const line =
503
+ error.sql_line != null ? (error?.sql_line | 0) + 1 : null;
504
+ const col = error.sql_col != null ? (error?.sql_col | 0) + 1 : null;
505
+ return (
506
+ <div key={`sql-error-${idx}`} className="space-y-2">
507
+ <p className="text-muted-foreground">{error.msg}</p>
508
+ {error.hint && (
509
+ <div className="flex items-start gap-2">
510
+ <InfoIcon className="h-4 w-4 text-muted-foreground mt-0.5 flex-shrink-0" />
511
+ <pre className="whitespace-pre-wrap text-sm text-muted-foreground">
512
+ {error.hint}
513
+ </pre>
514
+ </div>
515
+ )}
516
+ {error.sql_statement && (
517
+ <div className="bg-muted/50 p-2 rounded text-xs font-mono">
518
+ <pre className="whitespace-pre-wrap">
519
+ {error.sql_statement}
520
+ </pre>
521
+ </div>
522
+ )}
523
+ {line !== null && col !== null && (
524
+ <p className="text-xs text-muted-foreground">
525
+ Error at line {line}, column {col}
526
+ </p>
527
+ )}
528
+ </div>
529
+ );
530
+ })}
531
+ {cellId && <AutoFixButton errors={sqlErrors} cellId={cellId} />}
532
+ <Tip title="How to fix SQL errors">
533
+ <p className="pb-2">
534
+ SQL parsing errors often occur due to invalid syntax, missing
535
+ keywords, or unsupported SQL features.
536
+ </p>
537
+ <p className="py-2">
538
+ Check your SQL syntax and ensure you're using supported SQL
539
+ dialect features. The error location can help you identify the
540
+ problematic part of your query.
541
+ </p>
542
+ </Tip>
543
+ </div>,
544
+ );
545
+ }
546
+
488
547
  return messages;
489
548
  };
490
549
 
@@ -20,8 +20,7 @@ import { SortableCellsProvider } from "@/components/sort/SortableCellsProvider";
20
20
  import { Button } from "@/components/ui/button";
21
21
  import { Tooltip } from "@/components/ui/tooltip";
22
22
  import { maybeAddMarimoImport } from "@/core/cells/add-missing-import";
23
- import { MarkdownLanguageAdapter } from "@/core/codemirror/language/languages/markdown";
24
- import { SQLLanguageAdapter } from "@/core/codemirror/language/languages/sql/sql";
23
+ import { LanguageAdapters } from "@/core/codemirror/language/LanguageAdapters";
25
24
  import { aiEnabledAtom } from "@/core/config/config";
26
25
  import { isConnectedAtom } from "@/core/network/connection";
27
26
  import { useBoolean } from "@/hooks/useBoolean";
@@ -288,7 +287,7 @@ const AddCellButtons: React.FC<{
288
287
  createNewCell({
289
288
  cellId: { type: "__end__", columnId },
290
289
  before: false,
291
- code: new MarkdownLanguageAdapter().defaultCode,
290
+ code: LanguageAdapters.markdown.defaultCode,
292
291
  hideCode: true,
293
292
  });
294
293
  }}
@@ -307,7 +306,7 @@ const AddCellButtons: React.FC<{
307
306
  createNewCell({
308
307
  cellId: { type: "__end__", columnId },
309
308
  before: false,
310
- code: new SQLLanguageAdapter().defaultCode,
309
+ code: LanguageAdapters.sql.defaultCode,
311
310
  });
312
311
  }}
313
312
  >
@@ -24,7 +24,7 @@ export const SlidesLayoutRenderer: React.FC<Props> = ({
24
24
  const isReading = mode === "read";
25
25
 
26
26
  const slides = (
27
- <LazySlidesComponent forceKeyboardNavigation={true}>
27
+ <LazySlidesComponent forceKeyboardNavigation={true} className="flex-1">
28
28
  {cells.map((cell) => {
29
29
  const isOutputEmpty = cell.output == null || cell.output.data === "";
30
30
  if (isOutputEmpty) {
@@ -45,10 +45,10 @@ export const SlidesLayoutRenderer: React.FC<Props> = ({
45
45
  );
46
46
 
47
47
  if (isReading) {
48
- return <div className="p-4">{slides}</div>;
48
+ return <div className="p-4 flex flex-col flex-1 max-h-[95%]">{slides}</div>;
49
49
  }
50
50
 
51
- return <div className="pr-9">{slides}</div>;
51
+ return <div className="pr-18 pb-5 flex-1 flex flex-col">{slides}</div>;
52
52
  };
53
53
 
54
54
  interface SlideProps extends Pick<CellRuntimeState, "output" | "status"> {
@@ -5,6 +5,7 @@
5
5
  * The serialized form of a slides layout.
6
6
  * This must be backwards-compatible as it is stored on the user's disk.
7
7
  */
8
+ // eslint-disable-next-line @typescript-eslint/no-empty-object-type
8
9
  export type SerializedSlidesLayout = {};
9
10
 
10
11
  export interface SlidesLayout extends SerializedSlidesLayout {
@@ -21,6 +21,7 @@ import {
21
21
  Tree,
22
22
  type TreeApi,
23
23
  } from "react-arborist";
24
+ import { useLocale } from "react-aria";
24
25
  import { MarkdownIcon } from "@/components/editor/cell/code/icons";
25
26
  import { useImperativeModal } from "@/components/modal/ImperativeModal";
26
27
  import { AlertDialogDestructiveAction } from "@/components/ui/alert-dialog";
@@ -383,6 +384,8 @@ const NotebookList: React.FC<{
383
384
  };
384
385
 
385
386
  const MarimoFileComponent = ({ file }: { file: MarimoFile }) => {
387
+ const { locale } = useLocale();
388
+
386
389
  // If path is a sessionId, then it has not been saved yet
387
390
  // We want to keep the sessionId in this case
388
391
  const isNewNotebook = isSessionId(file.path);
@@ -427,7 +430,7 @@ const MarimoFileComponent = ({ file }: { file: MarimoFile }) => {
427
430
  </div>
428
431
  {!!file.lastModified && (
429
432
  <div className="text-xs text-muted-foreground opacity-80">
430
- {timeAgo(file.lastModified * 1000)}
433
+ {timeAgo(file.lastModified * 1000, locale)}
431
434
  </div>
432
435
  )}
433
436
  </div>
@@ -95,7 +95,7 @@ const SlidesComponent = ({
95
95
  }}
96
96
  className={cn(
97
97
  "h-full w-full flex box-border overflow-y-auto overflow-x-hidden",
98
- isFullscreen ? "p-20" : "p-6",
98
+ isFullscreen ? "p-20" : "p-6 pb-12",
99
99
  )}
100
100
  >
101
101
  <div className="mo-slide-content">{child}</div>
@@ -68,6 +68,7 @@ so we are resetting this back to initial. */
68
68
  width: 100%;
69
69
  display: flex;
70
70
  justify-content: center;
71
+ min-height: fit-content;
71
72
 
72
73
  /* width is normally set to 100%, but we want the content to be centered around
73
74
  the width needed. */
@@ -79,6 +80,11 @@ so we are resetting this back to initial. */
79
80
  width: unset;
80
81
  }
81
82
 
83
+ /* If the first output is the only child, make it flex 1 */
84
+ > *:only-child > .output:only-child {
85
+ flex: 1;
86
+ }
87
+
82
88
  /* Components that should be full width when in slides mode */
83
89
  div:has(> marimo-ui-element > marimo-vega) {
84
90
  display: block !important;
@@ -1,3 +1,4 @@
1
+ /* Copyright 2024 Marimo. All rights reserved. */
1
2
  import type { ResolvedTheme } from "@/theme/useTheme";
2
3
 
3
4
  // Terminal theme configuration
@@ -1,6 +1,7 @@
1
1
  /* Copyright 2024 Marimo. All rights reserved. */
2
2
 
3
3
  import type { TopLevelSpec } from "vega-lite";
4
+ import type { TimeUnit } from "vega-lite/build/src/timeunit";
4
5
  import type { CellId } from "@/core/cells/ids";
5
6
  import type { CellRun } from "@/core/cells/runs";
6
7
  import type { ResolvedTheme } from "@/theme/useTheme";
@@ -30,6 +31,8 @@ export function createGanttBaseSpec(
30
31
  chartPosition: ChartPosition,
31
32
  theme: ResolvedTheme,
32
33
  ): Readonly<TopLevelSpec> {
34
+ // @ts-expect-error - Supported by vega/vega-lite but invalid "TimeUnit" option from exported type
35
+ const timeUnit: TimeUnit = "hoursminutessecondsmilliseconds";
33
36
  return {
34
37
  $schema: "https://vega.github.io/schema/vega-lite/v5.json",
35
38
  background: theme === "dark" ? "black" : undefined,
@@ -76,15 +79,13 @@ export function createGanttBaseSpec(
76
79
  {
77
80
  field: startTimestampField,
78
81
  type: "temporal",
79
- // @ts-expect-error - Supported by vega/vega-lite but invalid "TimeUnit" option from exported type
80
- timeUnit: "hoursminutessecondsmilliseconds",
82
+ timeUnit: timeUnit,
81
83
  title: "Start",
82
84
  },
83
85
  {
84
86
  field: endTimestampField,
85
87
  type: "temporal",
86
- // @ts-expect-error - Supported by vega/vega-lite but invalid "TimeUnit" option from exported type
87
- timeUnit: "hoursminutessecondsmilliseconds",
88
+ timeUnit: timeUnit,
88
89
  title: "End",
89
90
  },
90
91
  ],
@@ -3,6 +3,7 @@
3
3
  import * as SliderPrimitive from "@radix-ui/react-slider";
4
4
  import { TooltipPortal } from "@radix-ui/react-tooltip";
5
5
  import * as React from "react";
6
+ import { useLocale } from "react-aria";
6
7
  import { cn } from "@/utils/cn";
7
8
  import { prettyScientificNumber } from "@/utils/numbers";
8
9
  import { useBoolean } from "../../hooks/useBoolean";
@@ -20,6 +21,7 @@ const RangeSlider = React.forwardRef<
20
21
  }
21
22
  >(({ className, valueMap, ...props }, ref) => {
22
23
  const [open, openActions] = useBoolean(false);
24
+ const { locale } = useLocale();
23
25
 
24
26
  return (
25
27
  <SliderPrimitive.Root
@@ -66,7 +68,7 @@ const RangeSlider = React.forwardRef<
66
68
  <TooltipPortal>
67
69
  {props.value != null && props.value.length === 2 && (
68
70
  <TooltipContent key={props.value[0]}>
69
- {prettyScientificNumber(valueMap(props.value[0]))}
71
+ {prettyScientificNumber(valueMap(props.value[0]), { locale })}
70
72
  </TooltipContent>
71
73
  )}
72
74
  </TooltipPortal>
@@ -87,7 +89,7 @@ const RangeSlider = React.forwardRef<
87
89
  <TooltipPortal>
88
90
  {props.value != null && props.value.length === 2 && (
89
91
  <TooltipContent key={props.value[1]}>
90
- {prettyScientificNumber(valueMap(props.value[1]))}
92
+ {prettyScientificNumber(valueMap(props.value[1]), { locale })}
91
93
  </TooltipContent>
92
94
  )}
93
95
  </TooltipPortal>
@@ -3,6 +3,7 @@
3
3
  import * as SliderPrimitive from "@radix-ui/react-slider";
4
4
  import { TooltipPortal } from "@radix-ui/react-tooltip";
5
5
  import * as React from "react";
6
+ import { useLocale } from "react-aria";
6
7
  import { cn } from "@/utils/cn";
7
8
  import { prettyScientificNumber } from "@/utils/numbers";
8
9
  import { useBoolean } from "../../hooks/useBoolean";
@@ -20,6 +21,7 @@ const Slider = React.forwardRef<
20
21
  }
21
22
  >(({ className, valueMap, ...props }, ref) => {
22
23
  const [open, openActions] = useBoolean(false);
24
+ const { locale } = useLocale();
23
25
 
24
26
  return (
25
27
  <SliderPrimitive.Root
@@ -66,7 +68,7 @@ const Slider = React.forwardRef<
66
68
  <TooltipPortal>
67
69
  {props.value != null && props.value.length === 1 && (
68
70
  <TooltipContent key={props.value[0]}>
69
- {prettyScientificNumber(valueMap(props.value[0]))}
71
+ {prettyScientificNumber(valueMap(props.value[0]), { locale })}
70
72
  </TooltipContent>
71
73
  )}
72
74
  </TooltipPortal>
@@ -14,6 +14,7 @@ import {
14
14
  import { sortBy } from "lodash-es";
15
15
  import { SquareEqualIcon, WorkflowIcon } from "lucide-react";
16
16
  import React, { memo, useMemo } from "react";
17
+ import { useLocale } from "react-aria";
17
18
  import { CellLink } from "@/components/editor/links/cell-link";
18
19
  import { getCellEditorView, useCellNames } from "@/core/cells/cells";
19
20
  import type { CellId } from "@/core/cells/ids";
@@ -233,6 +234,7 @@ export const VariableTable: React.FC<Props> = memo(
233
234
  const [sorting, setSorting] = React.useState<SortingState>([]);
234
235
  const [globalFilter, setGlobalFilter] = React.useState("");
235
236
  const cellNames = useCellNames();
237
+ const { locale } = useLocale();
236
238
 
237
239
  const resolvedVariables: ResolvedVariable[] = useMemo(() => {
238
240
  const getName = (id: CellId) => {
@@ -279,6 +281,7 @@ export const VariableTable: React.FC<Props> = memo(
279
281
  globalFilterFn: "auto",
280
282
  // sorting
281
283
  manualSorting: true,
284
+ locale: locale,
282
285
  onSortingChange: setSorting,
283
286
  getSortedRowModel: getSortedRowModel(),
284
287
  state: {
@@ -15,6 +15,7 @@ import { ErrorBoundary } from "../components/editor/boundary/ErrorBoundary";
15
15
  import { ModalProvider } from "../components/modal/ImperativeModal";
16
16
  import { Toaster } from "../components/ui/toaster";
17
17
  import { TooltipProvider } from "../components/ui/tooltip";
18
+ import { LocaleProvider } from "./i18n/locale-provider";
18
19
  import { slotsController } from "./slots/slots";
19
20
 
20
21
  // Force tailwind classnames
@@ -69,7 +70,7 @@ export const MarimoApp: React.FC = memo(() => {
69
70
  <CssVariables
70
71
  variables={{ "--marimo-code-editor-font-size": editorFontSize }}
71
72
  >
72
- {renderBody()}
73
+ <LocaleProvider>{renderBody()}</LocaleProvider>
73
74
  </CssVariables>
74
75
  </Providers>
75
76
  );
@@ -85,11 +86,13 @@ const Providers = memo(({ children }: PropsWithChildren) => {
85
86
  <Suspense>
86
87
  <TooltipProvider>
87
88
  <SlotzProvider controller={slotsController}>
88
- <ModalProvider>
89
- {children}
90
- <Toaster />
91
- <TailwindIndicator />
92
- </ModalProvider>
89
+ <LocaleProvider>
90
+ <ModalProvider>
91
+ {children}
92
+ <Toaster />
93
+ <TailwindIndicator />
94
+ </ModalProvider>
95
+ </LocaleProvider>
93
96
  </SlotzProvider>
94
97
  </TooltipProvider>
95
98
  </Suspense>
@@ -101,11 +101,13 @@ class AttachmentContextProvider extends AIContextProvider<MockContextItem> {
101
101
  readonly mentionPrefix = "@";
102
102
  readonly contextType = "attachment";
103
103
 
104
- constructor(
105
- private items: MockContextItem[] = [],
106
- private attachments: FileUIPart[] = [],
107
- ) {
104
+ private items: MockContextItem[];
105
+ private attachments: FileUIPart[];
106
+
107
+ constructor(items: MockContextItem[] = [], attachments: FileUIPart[] = []) {
108
108
  super();
109
+ this.items = items;
110
+ this.attachments = attachments;
109
111
  }
110
112
 
111
113
  getItems(): MockContextItem[] {
@@ -9,6 +9,7 @@ import { displayCellName } from "@/core/cells/names";
9
9
  import { isOutputEmpty } from "@/core/cells/outputs";
10
10
  import type { OutputMessage } from "@/core/kernel/messages";
11
11
  import type { JotaiStore } from "@/core/state/jotai";
12
+ import { parseHtmlContent } from "@/utils/dom";
12
13
  import { Logger } from "@/utils/Logger";
13
14
  import { type AIContextItem, AIContextProvider } from "../registry";
14
15
  import { contextToXml } from "../utils";
@@ -64,31 +65,14 @@ function isMediaMimetype(
64
65
  return false;
65
66
  }
66
67
 
67
- function parseHtmlContent(htmlString: string): string {
68
- try {
69
- // Create a temporary DOM element to parse HTML
70
- const tempDiv = document.createElement("div");
71
- tempDiv.innerHTML = htmlString;
72
-
73
- // Extract text content, removing HTML tags
74
- const textContent = tempDiv.textContent || tempDiv.innerText || "";
75
-
76
- // Clean up extra whitespace
77
- return textContent.replaceAll(/\s+/g, " ").trim();
78
- } catch (error) {
79
- Logger.error("Error parsing HTML content:", error);
80
- // If parsing fails, return the original string
81
- return htmlString;
82
- }
83
- }
84
-
85
68
  export class CellOutputContextProvider extends AIContextProvider<CellOutputContextItem> {
86
69
  readonly title = "Cell Outputs";
87
70
  readonly mentionPrefix = "@";
88
71
  readonly contextType = "cell-output";
89
-
90
- constructor(private store: JotaiStore) {
72
+ private store: JotaiStore;
73
+ constructor(store: JotaiStore) {
91
74
  super();
75
+ this.store = store;
92
76
  }
93
77
 
94
78
  getItems(): CellOutputContextItem[] {
@@ -64,9 +64,11 @@ export class ErrorContextProvider extends AIContextProvider<ErrorContextItem> {
64
64
  readonly title = "Errors";
65
65
  readonly mentionPrefix = "@";
66
66
  readonly contextType = "error";
67
+ private store: JotaiStore;
67
68
 
68
- constructor(private store: JotaiStore) {
69
+ constructor(store: JotaiStore) {
69
70
  super();
71
+ this.store = store;
70
72
  }
71
73
 
72
74
  getItems(): ErrorContextItem[] {
@@ -43,11 +43,16 @@ export class FileContextProvider extends AIContextProvider<FileContextItem> {
43
43
  readonly mentionPrefix = "#";
44
44
  readonly contextType = "file";
45
45
 
46
+ private apiRequests: EditRequests & RunRequests;
47
+ private config: FileSearchConfig;
48
+
46
49
  constructor(
47
- private apiRequests: EditRequests & RunRequests,
48
- private config: FileSearchConfig = DEFAULT_FILE_SEARCH_CONFIG,
50
+ apiRequests: EditRequests & RunRequests,
51
+ config: FileSearchConfig = DEFAULT_FILE_SEARCH_CONFIG,
49
52
  ) {
50
53
  super();
54
+ this.apiRequests = apiRequests;
55
+ this.config = config;
51
56
  }
52
57
 
53
58
  /**
@@ -17,9 +17,10 @@ export class TableContextProvider extends AIContextProvider<TableContextItem> {
17
17
  readonly title = "Tables";
18
18
  readonly mentionPrefix = "@";
19
19
  readonly contextType = "data";
20
-
21
- constructor(private tablesMap: DatasetTablesMap) {
20
+ private tablesMap: DatasetTablesMap;
21
+ constructor(tablesMap: DatasetTablesMap) {
22
22
  super();
23
+ this.tablesMap = tablesMap;
23
24
  }
24
25
 
25
26
  getItems(): TableContextItem[] {
@@ -20,11 +20,13 @@ export class VariableContextProvider extends AIContextProvider<VariableContextIt
20
20
  readonly mentionPrefix = "@";
21
21
  readonly contextType = "variable";
22
22
 
23
- constructor(
24
- private variables: Variables,
25
- private tablesMap: DatasetTablesMap,
26
- ) {
23
+ private variables: Variables;
24
+ private tablesMap: DatasetTablesMap;
25
+
26
+ constructor(variables: Variables, tablesMap: DatasetTablesMap) {
27
27
  super();
28
+ this.variables = variables;
29
+ this.tablesMap = tablesMap;
28
30
  }
29
31
 
30
32
  getItems(): VariableContextItem[] {
@@ -10,7 +10,12 @@ import { useDeleteCellCallback } from "@/components/editor/cell/useDeleteCell";
10
10
  import { CellId } from "@/core/cells/ids";
11
11
  import { createReducerAndAtoms } from "@/utils/createReducer";
12
12
  import { Logger } from "@/utils/Logger";
13
- import { cellHandleAtom, useCellActions } from "../cells/cells";
13
+ import { maybeAddMarimoImport } from "../cells/add-missing-import";
14
+ import {
15
+ type CreateNewCellAction,
16
+ cellHandleAtom,
17
+ useCellActions,
18
+ } from "../cells/cells";
14
19
  import type { LanguageAdapterType } from "../codemirror/language/types";
15
20
  import { updateEditorCodeFromPython } from "../codemirror/language/utils";
16
21
  import type { JotaiStore } from "../state/jotai";
@@ -113,6 +118,8 @@ export function useStagedCells(store: JotaiStore) {
113
118
  cellCreationStream.current = new CellCreationStream(
114
119
  createStagedCell,
115
120
  updateStagedCell,
121
+ addStagedCell,
122
+ createNewCell,
116
123
  );
117
124
  break;
118
125
  case "text-delta":
@@ -168,13 +175,20 @@ class CellCreationStream {
168
175
 
169
176
  private onCreateCell: (code: string) => CellId;
170
177
  private onUpdateCell: (opts: UpdateStagedCellAction) => void;
178
+ private addStagedCell: (payload: { cellId: CellId }) => void;
179
+ private createNewCell: (opts: CreateNewCellAction) => void;
180
+ private hasMarimoImport = false;
171
181
 
172
182
  constructor(
173
183
  onCreateCell: (code: string) => CellId,
174
184
  onUpdateCell: (opts: UpdateStagedCellAction) => void,
185
+ addStagedCell: (payload: { cellId: CellId }) => void,
186
+ createNewCell: (opts: CreateNewCellAction) => void,
175
187
  ) {
176
188
  this.onCreateCell = onCreateCell;
177
189
  this.onUpdateCell = onUpdateCell;
190
+ this.addStagedCell = addStagedCell;
191
+ this.createNewCell = createNewCell;
178
192
  }
179
193
 
180
194
  stream(chunk: TextDeltaChunk) {
@@ -187,6 +201,7 @@ class CellCreationStream {
187
201
  // For each parsed cell, we either update an existing staged cell or create a new one.
188
202
  for (const [idx, cell] of completionCells.entries()) {
189
203
  if (idx < this.createdCells.length) {
204
+ this.addMarimoImport(cell.language);
190
205
  const existingCell = this.createdCells[idx];
191
206
  this.createdCells[idx] = { ...existingCell, cell };
192
207
  this.onUpdateCell({
@@ -201,6 +216,24 @@ class CellCreationStream {
201
216
  }
202
217
  }
203
218
 
219
+ /** Add a marimo import if the cell is SQL or Markdown and we haven't added it yet. */
220
+ private addMarimoImport(language: LanguageAdapterType) {
221
+ if (this.hasMarimoImport || language === "python") {
222
+ return;
223
+ }
224
+
225
+ const cellId = maybeAddMarimoImport({
226
+ autoInstantiate: false,
227
+ createNewCell: this.createNewCell,
228
+ fromCellId: this.createdCells[0]?.cellId,
229
+ before: true,
230
+ });
231
+ if (cellId) {
232
+ this.addStagedCell({ cellId });
233
+ }
234
+ this.hasMarimoImport = true;
235
+ }
236
+
204
237
  stop() {
205
238
  // Clear all state
206
239
  this.buffer = "";