@marimo-team/islands 0.25.2-dev99 → 0.25.3-dev10

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 (205) hide show
  1. package/dist/{ConnectedDataExplorerComponent-BZmqc_F0.js → ConnectedDataExplorerComponent-CNMliVzw.js} +15 -15
  2. package/dist/{ErrorBoundary-CXkr_IcB.js → ErrorBoundary-BsqSMK9Y.js} +12 -12
  3. package/dist/{ImageComparisonComponent-Cpfz30OZ.js → ImageComparisonComponent-uU8FSKZE.js} +3 -3
  4. package/dist/{Plot-CTyjbQDT.js → Plot-DdYOe1UK.js} +2 -2
  5. package/dist/{abnfDiagram-VCTEODGH-C_Lmaa2j.js → abnfDiagram-VCTEODGH-D-Ez91gV.js} +3 -3
  6. package/dist/{any-language-editor-BFzqhOBR.js → any-language-editor-DZ_YTVus.js} +7 -7
  7. package/dist/{architectureDiagram-5GKGNRK7-BKMataHB.js → architectureDiagram-5GKGNRK7-CTpcNtO8.js} +5 -5
  8. package/dist/assets/__vite-browser-external-BXYkiFsk.js +1 -0
  9. package/dist/assets/worker-HPY9fbhz.js +114 -0
  10. package/dist/{blockDiagram-I7D4REHJ-BeHOjyDk.js → blockDiagram-I7D4REHJ-Cg25UrxT.js} +9 -9
  11. package/dist/{button-BtsM2UqM.js → button-CvjkwdSk.js} +5 -5
  12. package/dist/{c4Diagram-7LVT6UL2-Bao10t_O.js → c4Diagram-7LVT6UL2-BxFgrnNV.js} +7 -7
  13. package/dist/{capabilities-A5jrzjCJ.js → capabilities-CQ5IjhzL.js} +1 -1
  14. package/dist/{channel-BxCkvUgE.js → channel-CPObtJXj.js} +1 -1
  15. package/dist/{chat-ui-CwOWzoSO.js → chat-ui-0lKdOoQ3.js} +1588 -1396
  16. package/dist/{check-CNP79M3A.js → check-EDwSwP89.js} +1 -1
  17. package/dist/{chunk-4HAMMTFA-CH7Gpamd.js → chunk-4HAMMTFA-D4eFPyFh.js} +5 -5
  18. package/dist/{chunk-75Z2AOVW-AI7CvgKn.js → chunk-75Z2AOVW-D7gxIs2Q.js} +1 -1
  19. package/dist/{chunk-DU6HZSFF-BSvuTkX4.js → chunk-DU6HZSFF-BwiyaNpg.js} +1 -1
  20. package/dist/{chunk-F27PBJKO-CLshwT9T.js → chunk-F27PBJKO-ufseIn5y.js} +1 -1
  21. package/dist/{chunk-GMAD6QVW-wnHcn-lH.js → chunk-GMAD6QVW-BhaJx0X3.js} +3 -3
  22. package/dist/{chunk-GVQU2GXP-7O2p8hut.js → chunk-GVQU2GXP-Cwbt-lF0.js} +2 -2
  23. package/dist/{chunk-IMKFNOWR-Bu0Vh_Yi.js → chunk-IMKFNOWR-DGxi-zeo.js} +5 -5
  24. package/dist/{chunk-L3NEJ4N5-B9_Alrxb.js → chunk-L3NEJ4N5-n-zgIVSy.js} +5 -5
  25. package/dist/{chunk-OSK3NFVY-PeQPH2fD.js → chunk-OSK3NFVY-DXa-Cxbn.js} +6 -6
  26. package/dist/{chunk-P2QGCYS3-D9twiFuU.js → chunk-P2QGCYS3-B_Zd3-X0.js} +1 -1
  27. package/dist/{chunk-POPQ4Y6H-BUiNs18s.js → chunk-POPQ4Y6H-hYOXbYH_.js} +1 -1
  28. package/dist/{chunk-PWAF6VOD-D8S9NPCy.js → chunk-PWAF6VOD-CQw5qATZ.js} +1 -1
  29. package/dist/{chunk-SHT3W25Y-B2dyNZ31.js → chunk-SHT3W25Y-CV9J3rAB.js} +7 -7
  30. package/dist/{chunk-SVP7TREG-D7UPvB10.js → chunk-SVP7TREG-BL-9Fqgg.js} +2 -2
  31. package/dist/{chunk-TICWLB2K-BNaGoadd.js → chunk-TICWLB2K-Cu_XMjDM.js} +5 -5
  32. package/dist/{chunk-YOKDWASO-DrWbKnxA.js → chunk-YOKDWASO-DPZk8vhS.js} +6 -6
  33. package/dist/classDiagram-ZZMXUADV-BXXV13Hq.js +30 -0
  34. package/dist/classDiagram-v2-VYDZK3BY-B7FXJ1Cp.js +30 -0
  35. package/dist/{code-visibility-pPjYsRTH.js → code-visibility-CXQvUXHT.js} +18 -18
  36. package/dist/{common-CkvBp0B4.js → common-CuD-CAC-.js} +6128 -7136
  37. package/dist/{compiler-runtime-Cj8ZWiNS.js → compiler-runtime-CldRdSsv.js} +2 -2
  38. package/dist/{copy-icon-BY7jgcaV.js → copy-icon-Ft7t9bqz.js} +6 -6
  39. package/dist/{cynefinDiagram-5FMLGOSQ-CCDn4Z9e.js → cynefinDiagram-5FMLGOSQ-CH96rwba.js} +3 -3
  40. package/dist/{dagre-GXQ25YYZ-BJiUO_SV.js → dagre-GXQ25YYZ-BD3PmpFY.js} +10 -10
  41. package/dist/{data-grid-overlay-editor-L6ELxFAh.js → data-grid-overlay-editor-DgeyYmC1.js} +7 -7
  42. package/dist/{data-grid-types-BucVmDDp.js → data-grid-types-BH_r7g7l.js} +1 -1
  43. package/dist/{diagram-S7CK7UJ4-BZfxFNRR.js → diagram-S7CK7UJ4-BsSJJldB.js} +4 -4
  44. package/dist/{diagram-UQ7AKVKN-1xcsiIMg.js → diagram-UQ7AKVKN-muQtNZc4.js} +3 -3
  45. package/dist/{diagram-VSXAHHWV-DPAWJ9Nw.js → diagram-VSXAHHWV-BJWcVVJY.js} +2 -2
  46. package/dist/{diagram-VX7I27RA-DmRsnHYY.js → diagram-VX7I27RA-CdhuZAqR.js} +5 -5
  47. package/dist/{diagram-Z3DM3KII--b49ryKx.js → diagram-Z3DM3KII-BD8mXjOj.js} +3 -3
  48. package/dist/{dialog-CmExhUDI.js → dialog-CEBFZNyc.js} +6 -6
  49. package/dist/{dist-CcyKTBTF.js → dist-DpBpA_n1.js} +2 -2
  50. package/dist/{dropdown-menu-Cz4TdOJh.js → dropdown-menu-CP_qCYHC.js} +139 -139
  51. package/dist/{ebnfDiagram-PWID7BFC-rSwVyh4y.js → ebnfDiagram-PWID7BFC-BIN1sweE.js} +3 -3
  52. package/dist/{erDiagram-RLTQ6QDP-Bfd3iAoC.js → erDiagram-RLTQ6QDP-Ctp5cfoN.js} +12 -12
  53. package/dist/{error-banner-D30nA9nE.js → error-banner-D-WCIiMt.js} +16 -11
  54. package/dist/{cells-DZi0ioak.js → error-entries-DSvFWT_M.js} +6171 -5075
  55. package/dist/{esm-DAVrGVKP.js → esm-AMFssoNp.js} +4 -4
  56. package/dist/{feedback-button-D-pV0Qji.js → feedback-button-DZMj9PF3.js} +119 -120
  57. package/dist/flowDiagram-HODETNUW-3EfLrlFb.js +16 -0
  58. package/dist/{formats-DhhbdyAH.js → formats-CeOmU1MU.js} +6 -6
  59. package/dist/{ganttDiagram-EL5Y4UJY-B4m_YsKa.js → ganttDiagram-EL5Y4UJY-BQT16JSc.js} +2 -2
  60. package/dist/{gitGraphDiagram-WWUBYQGX-QRBbvWXh.js → gitGraphDiagram-WWUBYQGX-D5nSIzdE.js} +2 -2
  61. package/dist/{glide-data-editor-D6CfYwdr.js → glide-data-editor-g_L8FLAC.js} +60 -60
  62. package/dist/{glide-utils-BVJ4fkxX.js → glide-utils-DJyqh0EM.js} +4 -4
  63. package/dist/{globals-BwK9YGrX.js → globals-CYGlmBXb.js} +3 -3
  64. package/dist/{highlighted-body-KPVGNVTW-Ad3MKZ18.js → highlighted-body-KPVGNVTW-zwjq21tf.js} +4 -4
  65. package/dist/{html-to-image-Cn1_16-x.js → html-to-image-B8s5SgGm.js} +37 -37
  66. package/dist/{infoDiagram-27XIBGKW-DVQFYvhg.js → infoDiagram-27XIBGKW-DipQoHxl.js} +2 -2
  67. package/dist/{ishikawaDiagram-5VMMS53U-viPND-nm.js → ishikawaDiagram-5VMMS53U-DgFMjSGz.js} +3 -3
  68. package/dist/{journeyDiagram-3NMN7TZE-BeeJdJo3.js → journeyDiagram-3NMN7TZE-BaLqn-dZ.js} +2 -2
  69. package/dist/{jsx-runtime-DgDPJV9S.js → jsx-runtime-3BD1kT0s.js} +1 -1
  70. package/dist/{kanban-definition-UXKFOSKX-Dcl_ECO9.js → kanban-definition-UXKFOSKX-w1ACVjgl.js} +9 -9
  71. package/dist/{katex-BNCmKUol.js → katex-BIdZGsyO.js} +141 -116
  72. package/dist/{label-DQO1jFjf.js → label-BDKF3Afc.js} +10 -10
  73. package/dist/{loader-Cm-ATtou.js → loader-BQOfjTIJ.js} +1 -1
  74. package/dist/main.js +623 -590
  75. package/dist/{mermaid-BfhcnSj-.js → mermaid-CHo49Yv-.js} +56 -56
  76. package/dist/mermaid-HWGCJPDP-ByCsZnYF.js +2 -0
  77. package/dist/{mhchem-BEc7A1or.js → mhchem-CdWPJK6g.js} +1 -1
  78. package/dist/{mindmap-definition-YA3MSWOX-BdxxhF-5.js → mindmap-definition-YA3MSWOX-CrT0KSfX.js} +11 -11
  79. package/dist/{number-overlay-editor-tMylyldi.js → number-overlay-editor-9VRv-pdj.js} +5 -5
  80. package/dist/{pegDiagram-XKGWAZYB-Du5p2s0w.js → pegDiagram-XKGWAZYB-BqvywNJA.js} +3 -3
  81. package/dist/{pieDiagram-E7YTZNPT-DJg-SOIq.js → pieDiagram-E7YTZNPT-BfxJ_XCc.js} +3 -3
  82. package/dist/{process-output-CUG57KRp.js → process-output-CKRXyszb.js} +5 -5
  83. package/dist/{quadrantDiagram-AXDQQJYC-keLfFx9f.js → quadrantDiagram-AXDQQJYC-Ccw0xMjN.js} +1 -1
  84. package/dist/{railroadDiagram-O6MQD6OU-C0ojm-6_.js → railroadDiagram-O6MQD6OU-8vFLVTPu.js} +3 -3
  85. package/dist/{react-dom-BUgJ-ab_.js → react-dom-DUmH0GXv.js} +29 -21
  86. package/dist/{react-ofJbxM4x.js → react-sHtZdjeP.js} +103 -94
  87. package/dist/{react-vega-ewj7q_U5.js → react-vega-BED0DjiB.js} +3 -3
  88. package/dist/{requirementDiagram-BXWQKSXE-CNwNBmI3.js → requirementDiagram-BXWQKSXE-a_MxGvxe.js} +11 -11
  89. package/dist/{reveal-component-LXUMcqWX.js → reveal-component-C87mv9Mn.js} +906 -878
  90. package/dist/{sankeyDiagram-P5KCCOFB-Bh4EsJox.js → sankeyDiagram-P5KCCOFB-ELvOcnZH.js} +1 -1
  91. package/dist/{select-Bs-nmvm6.js → select-BButFi-d.js} +11 -11
  92. package/dist/{sequenceDiagram-WJ2MYXX4-DQaW5qBG.js → sequenceDiagram-WJ2MYXX4-CXFMnxGh.js} +4 -4
  93. package/dist/{spec-DVsoMvYT.js → spec-BwarBpUJ.js} +4 -4
  94. package/dist/{stateDiagram-D77RDMKH-BDa515QC.js → stateDiagram-D77RDMKH-DQeA_CwI.js} +13 -13
  95. package/dist/stateDiagram-v2-MP3YSRHH-BxxQucm1.js +30 -0
  96. package/dist/style.css +1 -1
  97. package/dist/{swimlanes-42K2YHIH-M4IdGi8J.js → swimlanes-42K2YHIH-Do6L-cYg.js} +10 -10
  98. package/dist/swimlanesDiagram-VR7AAH4N-DUzPvSVU.js +30 -0
  99. package/dist/{swiper-component-CpN-hewZ.js → swiper-component-DKntyn8p.js} +5 -5
  100. package/dist/{timeline-definition-24CTP7MA-DH-kvakg.js → timeline-definition-24CTP7MA-D3c46WM5.js} +3 -3
  101. package/dist/{toDate-vEi5kTfY.js → toDate-vIXljnsr.js} +43 -42
  102. package/dist/{toast-DfEpJedt.js → toast-B9UMEi8u.js} +9 -9
  103. package/dist/{tooltip-CuNWg2ay.js → tooltip-BO1REbqs.js} +7 -7
  104. package/dist/{use-restore-focus-kmgwrL8q.js → use-restore-focus-BEM7sFWl.js} +2042 -1827
  105. package/dist/{use-vega-container-remeasure-4DwJbPWu.js → use-vega-container-remeasure-Bz4PZMtt.js} +2 -2
  106. package/dist/{useAsyncData-rkAlR_vh.js → useAsyncData-Deh5kszT.js} +3 -3
  107. package/dist/{useDateFormatter-C-tz65rD.js → useDateFormatter-D8XruNGG.js} +4 -4
  108. package/dist/{useDeepCompareMemoize-BlHFBj5_.js → useDeepCompareMemoize-DXwzRINI.js} +2 -2
  109. package/dist/{useIframeCapabilities-C1Bt04Iz.js → useIframeCapabilities-DBETvvPl.js} +2 -2
  110. package/dist/{useLifecycle-B68iY077.js → useLifecycle-j7D9uD1o.js} +6 -6
  111. package/dist/{useTheme-BwSgeAFb.js → useTheme-CRnjkku0.js} +7 -7
  112. package/dist/{vega-component-C-bPttRN.js → vega-component-DTG6zxaY.js} +14 -14
  113. package/dist/{vega-embed-container-sSR5hAsy.js → vega-embed-container-BNHE18G9.js} +5 -5
  114. package/dist/{vennDiagram-4TSXK5OY-d5g7XeiI.js → vennDiagram-4TSXK5OY-BSZD8JcZ.js} +3 -3
  115. package/dist/{wardleyDiagram-VM6X3IG4-BfX3bSzR.js → wardleyDiagram-VM6X3IG4-48cUWkfA.js} +3 -3
  116. package/dist/{xychartDiagram-S5SC5T6Z-C1QsLZg7.js → xychartDiagram-S5SC5T6Z-CswYgYeu.js} +5 -5
  117. package/package.json +25 -22
  118. package/src/__tests__/fixtures/{pair-preview.ts → pair-config.ts} +3 -2
  119. package/src/__tests__/host-imports.test.ts +100 -0
  120. package/src/__tests__/mount.test.ts +8 -8
  121. package/src/components/data-table/__tests__/column_formatting.test.ts +30 -0
  122. package/src/components/data-table/__tests__/columns.test.tsx +70 -0
  123. package/src/components/data-table/__tests__/context-menu.test.ts +176 -0
  124. package/src/components/data-table/__tests__/date-filter-inputs.test.tsx +24 -1
  125. package/src/components/data-table/__tests__/export-actions.test.tsx +329 -6
  126. package/src/components/data-table/column-formatting/feature.ts +20 -1
  127. package/src/components/data-table/columns.tsx +25 -18
  128. package/src/components/data-table/context-menu.tsx +125 -26
  129. package/src/components/data-table/date-filter-inputs.tsx +15 -42
  130. package/src/components/data-table/export-actions.tsx +192 -116
  131. package/src/components/data-table/schemas.ts +14 -36
  132. package/src/components/data-table/utils.ts +18 -0
  133. package/src/components/editor/Output.tsx +9 -2
  134. package/src/components/editor/actions/__tests__/pair-with-agent-commands.test.ts +80 -252
  135. package/src/components/editor/actions/__tests__/pair-with-agent-modal.test.tsx +186 -34
  136. package/src/components/editor/actions/pair-with-agent-commands.ts +42 -51
  137. package/src/components/editor/actions/pair-with-agent-modal.tsx +96 -36
  138. package/src/components/editor/chrome/panels/error-panel.tsx +1 -0
  139. package/src/components/editor/chrome/wrapper/__tests__/attachment-status.test.tsx +372 -0
  140. package/src/components/editor/chrome/wrapper/footer-item.tsx +32 -24
  141. package/src/components/editor/chrome/wrapper/footer-items/attachment-status.tsx +237 -0
  142. package/src/components/editor/chrome/wrapper/footer.tsx +2 -0
  143. package/src/components/editor/controls/__tests__/notebook-menu-dropdown.test.tsx +4 -3
  144. package/src/components/editor/errors/__tests__/send-error-report-button.test.tsx +548 -0
  145. package/src/components/editor/errors/send-error-report-button.tsx +69 -0
  146. package/src/components/editor/output/MarimoErrorOutput.tsx +21 -5
  147. package/src/components/editor/output/MarimoTracebackOutput.tsx +35 -20
  148. package/src/components/editor/output/__tests__/ansi-reduce.test.ts +18 -0
  149. package/src/components/editor/output/ansi-reduce.ts +6 -0
  150. package/src/components/editor/output/console/ConsoleOutput.tsx +5 -3
  151. package/src/components/editor/output/console/__tests__/ConsoleOutput.test.tsx +18 -0
  152. package/src/components/storage/__tests__/storage-file-viewer.test.tsx +2 -1
  153. package/src/core/attachments/__tests__/toast.test.tsx +58 -0
  154. package/src/core/attachments/state.ts +21 -0
  155. package/src/core/attachments/toast.ts +15 -0
  156. package/src/core/cells/__tests__/cells.test.ts +52 -0
  157. package/src/core/cells/__tests__/document-roundtrip.test.ts +16 -0
  158. package/src/core/cells/__tests__/error-report.test.ts +139 -0
  159. package/src/core/cells/__tests__/session.test.ts +50 -1
  160. package/src/core/cells/error-report.ts +63 -0
  161. package/src/core/cells/session.ts +28 -1
  162. package/src/core/codemirror/copilot/__tests__/completion-integration.test.ts +447 -0
  163. package/src/core/codemirror/copilot/__tests__/inline-completion.test.ts +395 -0
  164. package/src/core/codemirror/copilot/__tests__/language-server.test.ts +511 -2
  165. package/src/core/codemirror/copilot/__tests__/rpc-cancellation.test.ts +201 -0
  166. package/src/core/codemirror/copilot/extension.ts +22 -11
  167. package/src/core/codemirror/copilot/language-server.ts +109 -60
  168. package/src/core/codemirror/language/__tests__/sql.test.ts +4 -3
  169. package/src/core/codemirror/language/embedded/__tests__/embedded-python.test.ts +138 -26
  170. package/src/core/codemirror/language/embedded/embedded-python.ts +47 -13
  171. package/src/core/codemirror/language/embedded/latex.ts +20 -13
  172. package/src/core/config/pair.ts +5 -3
  173. package/src/core/datasets/__tests__/data-source-discovery.test.ts +18 -11
  174. package/src/core/host/AGENTS.md +6 -0
  175. package/src/core/host/__tests__/protocol.test.ts +214 -0
  176. package/src/core/host/protocol.ts +1943 -0
  177. package/src/core/islands/__tests__/bootstrap.test.ts +26 -0
  178. package/src/core/islands/bootstrap.ts +1 -0
  179. package/src/core/islands/bridge.ts +2 -2
  180. package/src/core/kernel/messages.ts +4 -7
  181. package/src/core/network/__tests__/api.test.ts +114 -1
  182. package/src/core/network/api.ts +3 -2
  183. package/src/core/wasm/bridge.ts +2 -2
  184. package/src/core/wasm/worker/types.ts +2 -2
  185. package/src/core/websocket/__tests__/useMarimoKernelConnection.hook.test.tsx +193 -0
  186. package/src/core/websocket/useMarimoKernelConnection.tsx +9 -0
  187. package/src/css/katex-css.test.ts +1 -1
  188. package/src/css/katex.min.css +6 -1
  189. package/src/hooks/__tests__/useEventListener.test.tsx +45 -1
  190. package/src/hooks/useEventListener.ts +6 -1
  191. package/src/mount.tsx +3 -3
  192. package/src/plugins/impl/NumberPlugin.tsx +20 -3
  193. package/src/plugins/impl/__tests__/DataTablePlugin.test.tsx +84 -0
  194. package/src/plugins/impl/__tests__/NumberPlugin.test.tsx +159 -1
  195. package/src/utils/__tests__/dates.test.ts +116 -0
  196. package/src/utils/dates.ts +94 -0
  197. package/dist/assets/__vite-browser-external-BqAtzd2P.js +0 -1
  198. package/dist/assets/worker-Bf8dt6S-.js +0 -109
  199. package/dist/classDiagram-ZZMXUADV-Bbo2n384.js +0 -30
  200. package/dist/classDiagram-v2-VYDZK3BY-xR8cGP0r.js +0 -30
  201. package/dist/error-entries-BovkFYNy.js +0 -56
  202. package/dist/flowDiagram-HODETNUW-D7IBKS12.js +0 -16
  203. package/dist/mermaid-HWGCJPDP-DYCzSILp.js +0 -2
  204. package/dist/stateDiagram-v2-MP3YSRHH-ChNddepZ.js +0 -30
  205. package/dist/swimlanesDiagram-VR7AAH4N-FUSwmzEp.js +0 -30
@@ -2,13 +2,17 @@
2
2
 
3
3
  import type { CompletionContext } from "@codemirror/autocomplete";
4
4
  import { python } from "@codemirror/lang-python";
5
+ import { StreamLanguage } from "@codemirror/language";
6
+ import { stexMath } from "@codemirror/legacy-modes/mode/stex";
5
7
  import { EditorState } from "@codemirror/state";
6
- import type { InlineContext } from "@lezer/markdown";
7
- import { beforeEach, describe, expect, it } from "vitest";
8
+ import { classHighlighter, highlightTree } from "@lezer/highlight";
9
+ import { parser as markdownParser } from "@lezer/markdown";
10
+ import { beforeEach, describe, expect, it, vi } from "vitest";
8
11
  import { cellId, variableName } from "@/__tests__/branded";
9
12
  import { store } from "@/core/state/jotai";
10
13
  import { variablesAtom } from "@/core/variables/state";
11
14
  import { parsePython, variableCompletionSource } from "../embedded-python";
15
+ import { parseLatex } from "../latex";
12
16
 
13
17
  const IS_ACTIVE = () => true;
14
18
 
@@ -23,25 +27,133 @@ describe("parsePython", () => {
23
27
  ]);
24
28
  });
25
29
 
26
- it("should not parse double curly braces", () => {
30
+ const cases = [
31
+ "{math.exp(3)}",
32
+ '${math.exp(3) + len("$}")} $',
33
+ "${math.exp(3)} + {math.sin(3)}$",
34
+ "${math.exp(3)}$",
35
+ "$$ {math.exp(3)} $$",
36
+ String.raw`\({math.exp(3)}\)`,
37
+ String.raw`\[{math.exp(3)}\]`,
38
+ String.raw`\\({math.exp(3)}\\)`,
39
+ String.raw`\\[{math.exp(3)}\\]`,
40
+ String.raw`$\frac{{{math.exp(3)}}}{{2}}$`,
41
+ String.raw`$\{math.exp(3)}$`,
42
+ '${ {"}": math.exp(3)} }$',
43
+ "${math.exp(3):{width}.{precision}f}$",
44
+ ];
45
+
46
+ function highlightedProperties(doc: string, prefix: string) {
47
+ const parser = markdownParser.configure([
48
+ parseLatex(StreamLanguage.define(stexMath).parser),
49
+ parsePython(python().language.parser, () => prefix.includes("f")),
50
+ ]);
51
+ const properties: string[] = [];
52
+ highlightTree(parser.parse(doc), classHighlighter, (from, to, classes) => {
53
+ if (classes.split(" ").includes("tok-propertyName")) {
54
+ properties.push(doc.slice(from, to));
55
+ }
56
+ });
57
+ return properties;
58
+ }
59
+
60
+ it.each(["f", "rf", "fr"])(
61
+ "highlights interpolation with %s strings",
62
+ (prefix) => {
63
+ for (const doc of cases) {
64
+ expect(highlightedProperties(doc, prefix)).toEqual(
65
+ doc.includes("math.sin") ? ["exp", "sin"] : ["exp"],
66
+ );
67
+ }
68
+ },
69
+ );
70
+
71
+ it.each(["", "r"])("does not interpolate %s strings", (prefix) => {
72
+ for (const doc of cases) {
73
+ expect(highlightedProperties(doc, prefix)).toEqual([]);
74
+ }
75
+ });
76
+
77
+ it("parses replacement boundaries once for a paragraph with many interpolations", () => {
27
78
  const pythonParser = python().language.parser;
28
- const config = parsePython(pythonParser, IS_ACTIVE);
79
+ const parse = vi.spyOn(pythonParser, "parse");
80
+ try {
81
+ const doc = "{math.exp(3)} ".repeat(1000);
82
+ const parser = markdownParser.configure([
83
+ parseLatex(StreamLanguage.define(stexMath).parser),
84
+ parsePython(pythonParser, IS_ACTIVE),
85
+ ]);
86
+ const properties: string[] = [];
87
+ highlightTree(
88
+ parser.parse(doc),
89
+ classHighlighter,
90
+ (from, to, classes) => {
91
+ if (classes.split(" ").includes("tok-propertyName")) {
92
+ properties.push(doc.slice(from, to));
93
+ }
94
+ },
95
+ );
96
+ expect(properties).toEqual(Array.from({ length: 1000 }, () => "exp"));
97
+ expect(parse).toHaveBeenCalledTimes(1);
98
+ } finally {
99
+ parse.mockRestore();
100
+ }
101
+ });
29
102
 
30
- // Create a mock context
31
- const mockContext = {
32
- slice: (from: number, to: number) => {
33
- if (from === 5 && to === 6) {
34
- return "{";
35
- }
36
- return "";
37
- },
38
- addDelimiter: () => -1,
39
- } as unknown as InlineContext;
103
+ it("preserves raw backslashes between replacements", () => {
104
+ expect(
105
+ highlightedProperties(String.raw`{math.exp(3)} \N{math.sin(3)}`, "rf"),
106
+ ).toEqual(["exp", "sin"]);
107
+ });
108
+
109
+ it("finds replacements after triple quotes in markdown text", () => {
110
+ expect(
111
+ highlightedProperties('{math.exp(3)} """ {math.sin(3)}', "f"),
112
+ ).toEqual(["exp", "sin"]);
113
+ });
40
114
 
41
- // Test with double curly braces
42
- const result = config.parseInline![0].parse(mockContext, 123, 6); // 123 is OPEN_BRACE
43
- expect(result).toBe(-1);
115
+ it("keeps replacement positions local to each paragraph", () => {
116
+ expect(
117
+ highlightedProperties("${math.exp(3)}$\n\n${math.sin(3)}$", "rf"),
118
+ ).toEqual(["exp", "sin"]);
44
119
  });
120
+
121
+ it("preserves LaTeX highlighting around Python replacements", () => {
122
+ const doc = String.raw`$\frac{{{math.exp(3)}}}{{2}} + \alpha$`;
123
+ const parser = markdownParser.configure([
124
+ parseLatex(StreamLanguage.define(stexMath).parser),
125
+ parsePython(python().language.parser, IS_ACTIVE),
126
+ ]);
127
+ const highlighted: string[] = [];
128
+ highlightTree(parser.parse(doc), classHighlighter, (from, to) => {
129
+ highlighted.push(doc.slice(from, to));
130
+ });
131
+ expect(highlighted).toEqual(
132
+ expect.arrayContaining(["\\frac", "exp", "\\alpha"]),
133
+ );
134
+ });
135
+
136
+ it.each(["${math.exp(3)$", "${math.exp(3)", "${{math.exp(3)}$"])(
137
+ "does not treat incomplete or escaped braces as replacements: %s",
138
+ (doc) => {
139
+ expect(highlightedProperties(doc, "f")).toEqual([]);
140
+ },
141
+ );
142
+
143
+ it.each(["f", "rf", "fr"])(
144
+ "keeps doubled braces literal in %s strings",
145
+ (prefix) => {
146
+ for (const doc of [
147
+ "{{math.exp(3)}}",
148
+ "${{math.exp(3)}}$",
149
+ "$ {{{{math.exp(3)}}}} $",
150
+ String.raw`$\{{math.exp(3)}}$`,
151
+ String.raw`$\frac{{1}}{{2}}$`,
152
+ ]) {
153
+ expect(highlightedProperties(doc, prefix)).toEqual([]);
154
+ }
155
+ },
156
+ );
45
157
  });
46
158
 
47
159
  describe("variableCompletionSource", () => {
@@ -72,10 +184,10 @@ describe("variableCompletionSource", () => {
72
184
  const context: Partial<CompletionContext> = {
73
185
  pos: 8,
74
186
  explicit: false,
75
- matchBefore: (expr: RegExp) => ({ from: 7, to: 8, text: "v" }),
187
+ matchBefore: (_expr: RegExp) => ({ from: 7, to: 8, text: "v" }),
76
188
  state,
77
189
  aborted: false,
78
- tokenBefore: (types: readonly string[]) => null,
190
+ tokenBefore: (_types: readonly string[]) => null,
79
191
  };
80
192
 
81
193
  const result = variableCompletionSource(context as CompletionContext);
@@ -92,10 +204,10 @@ describe("variableCompletionSource", () => {
92
204
  const context: Partial<CompletionContext> = {
93
205
  pos: 7,
94
206
  explicit: false,
95
- matchBefore: (expr: RegExp) => ({ from: 6, to: 7, text: "v" }),
207
+ matchBefore: (_expr: RegExp) => ({ from: 6, to: 7, text: "v" }),
96
208
  state,
97
209
  aborted: false,
98
- tokenBefore: (types: readonly string[]) => null,
210
+ tokenBefore: (_types: readonly string[]) => null,
99
211
  };
100
212
 
101
213
  const result = variableCompletionSource(context as CompletionContext);
@@ -110,10 +222,10 @@ describe("variableCompletionSource", () => {
110
222
  const context: Partial<CompletionContext> = {
111
223
  pos: 13,
112
224
  explicit: false,
113
- matchBefore: (expr: RegExp) => ({ from: 12, to: 13, text: "v" }),
225
+ matchBefore: (_expr: RegExp) => ({ from: 12, to: 13, text: "v" }),
114
226
  state,
115
227
  aborted: false,
116
- tokenBefore: (types: readonly string[]) => null,
228
+ tokenBefore: (_types: readonly string[]) => null,
117
229
  };
118
230
 
119
231
  const result = variableCompletionSource(context as CompletionContext);
@@ -131,7 +243,7 @@ describe("variableCompletionSource", () => {
131
243
  matchBefore: () => null,
132
244
  state,
133
245
  aborted: false,
134
- tokenBefore: (types: readonly string[]) => null,
246
+ tokenBefore: (_types: readonly string[]) => null,
135
247
  };
136
248
 
137
249
  const result = variableCompletionSource(context as CompletionContext);
@@ -146,10 +258,10 @@ describe("variableCompletionSource", () => {
146
258
  const context: Partial<CompletionContext> = {
147
259
  pos: 9,
148
260
  explicit: false,
149
- matchBefore: (expr: RegExp) => ({ from: 8, to: 9, text: "v" }),
261
+ matchBefore: (_expr: RegExp) => ({ from: 8, to: 9, text: "v" }),
150
262
  state,
151
263
  aborted: false,
152
- tokenBefore: (types: readonly string[]) => null,
264
+ tokenBefore: (_types: readonly string[]) => null,
153
265
  };
154
266
 
155
267
  const result = variableCompletionSource(context as CompletionContext);
@@ -16,11 +16,8 @@ import { getVariableCompletions } from "../../completion/variable-completions";
16
16
  const PYTHON = "Python";
17
17
 
18
18
  const OPEN_BRACE = 123; // {
19
- const CLOSE_BRACE = 125; // }
20
19
  const DELIMITER_LENGTH = 1;
21
20
 
22
- const MARK = { mark: `${PYTHON}Mark`, resolve: PYTHON };
23
-
24
21
  /**
25
22
  * Define a Python code block parser for Markdown.
26
23
  *
@@ -31,6 +28,11 @@ export function parsePython(
31
28
  pythonParser: Parser,
32
29
  isActivated: () => boolean,
33
30
  ): MarkdownConfig {
31
+ const replacements = new WeakMap<
32
+ InlineContext,
33
+ { ends: Map<number, number>; parsedTo: number }
34
+ >();
35
+
34
36
  const defineNodes = [
35
37
  { name: PYTHON, style: tags.emphasis },
36
38
  { name: `${PYTHON}Mark`, style: tags.processingInstruction },
@@ -41,26 +43,58 @@ export function parsePython(
41
43
  parseInline: [
42
44
  {
43
45
  name: PYTHON,
46
+ before: "Escape",
44
47
  parse(cx: InlineContext, next: number, pos: number): number {
45
48
  if (!isActivated()) {
46
49
  return -1;
47
50
  }
48
51
 
49
- if (next !== OPEN_BRACE && next !== CLOSE_BRACE) {
52
+ // A backslash does not escape a brace in Python f-strings.
53
+ if (next === 92 && cx.char(pos + 1) === OPEN_BRACE) {
54
+ return pos + 1;
55
+ }
56
+ if (next !== OPEN_BRACE) {
50
57
  return -1;
51
58
  }
59
+ if (cx.char(pos + 1) === OPEN_BRACE) {
60
+ return pos + 2;
61
+ }
52
62
 
53
- // Check for double curly braces
54
- if (next === OPEN_BRACE && cx.slice(pos - 1, pos) === "{") {
63
+ let cached = replacements.get(cx);
64
+ if (!cached || pos >= cached.parsedTo) {
65
+ // Cache all replacements so each brace does not reparse the paragraph.
66
+ // Keep Markdown backslashes from consuming braces as Python escapes.
67
+ const prefix = 'rf"""';
68
+ const tree = pythonParser.parse(
69
+ `${prefix}${cx.slice(pos, cx.end)}\n"""`,
70
+ );
71
+ const formatString = tree.topNode
72
+ .getChild("ExpressionStatement")
73
+ ?.getChild("FormatString");
74
+ const offset = pos - prefix.length;
75
+ const ends = new Map<number, number>();
76
+ for (const replacement of formatString?.getChildren(
77
+ "FormatReplacement",
78
+ ) ?? []) {
79
+ if (replacement.lastChild?.name === "}") {
80
+ ends.set(offset + replacement.from, offset + replacement.to);
81
+ }
82
+ }
83
+ cached = {
84
+ ends,
85
+ parsedTo: formatString ? offset + formatString.to : cx.end,
86
+ };
87
+ replacements.set(cx, cached);
88
+ }
89
+ const end = cached.ends.get(pos);
90
+ if (end === undefined) {
55
91
  return -1;
56
92
  }
57
-
58
- return cx.addDelimiter(
59
- MARK,
60
- pos,
61
- pos + DELIMITER_LENGTH,
62
- next === OPEN_BRACE,
63
- next === CLOSE_BRACE,
93
+ return cx.addElement(
94
+ cx.elt(PYTHON, pos, end, [
95
+ cx.elt(`${PYTHON}Mark`, pos, pos + 1),
96
+ cx.elt(`${PYTHON}Mark`, end - 1, end),
97
+ ]),
64
98
  );
65
99
  },
66
100
  },
@@ -29,7 +29,7 @@
29
29
  // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30
30
  // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
31
 
32
- import { type Parser, parseMixed } from "@lezer/common";
32
+ import { IterMode, type Parser, parseMixed } from "@lezer/common";
33
33
  import { tags } from "@lezer/highlight";
34
34
  import type {
35
35
  DelimiterType,
@@ -231,24 +231,31 @@ export function parseLatex(latexParser: Parser): MarkdownConfig {
231
231
  // Test if the node type is one of the math expression
232
232
  const delimiterLength = DELIMITER_LENGTH[node.type.name];
233
233
  if (delimiterLength) {
234
- const from = node.from + delimiterLength;
235
- const to = node.to - delimiterLength;
234
+ const from = node.node.firstChild?.to ?? node.from + delimiterLength;
235
+ const to = node.node.lastChild?.from ?? node.to - delimiterLength;
236
236
 
237
237
  // Ensure valid ranges
238
238
  if (from >= to || from < 0 || to < 0) {
239
239
  return null;
240
240
  }
241
241
 
242
- return {
243
- parser: latexParser,
244
- // Remove delimiter from LaTeX parser otherwise it won't be highlighted
245
- overlay: [
246
- {
247
- from,
248
- to,
249
- },
250
- ],
251
- };
242
+ // Leave Python replacements to their own parser and highlighter.
243
+ const overlay: { from: number; to: number }[] = [];
244
+ let start = from;
245
+ node.node.cursor(IterMode.IgnoreMounts).iterate((child) => {
246
+ if (child.name !== "Python") {
247
+ return;
248
+ }
249
+ if (start < child.from) {
250
+ overlay.push({ from: start, to: child.from });
251
+ }
252
+ start = child.to;
253
+ return false;
254
+ });
255
+ if (start < to) {
256
+ overlay.push({ from: start, to });
257
+ }
258
+ return overlay.length ? { parser: latexParser, overlay } : null;
252
259
  }
253
260
 
254
261
  return null;
@@ -3,16 +3,18 @@
3
3
  import { atom } from "jotai";
4
4
  import { z } from "zod";
5
5
 
6
- export const pairPreviewSchema = z.object({
6
+ export const pairConfigSchema = z.object({
7
7
  command: z.string(),
8
+ hostEnabled: z.boolean().default(false),
8
9
  templates: z.object({
9
10
  prompt: z.string(),
11
+ notebook: z.string(),
10
12
  session: z.string(),
11
13
  token_file: z.string(),
12
14
  token: z.string(),
13
15
  }),
14
16
  });
15
17
 
16
- export type PairPreviewConfig = z.infer<typeof pairPreviewSchema>;
18
+ export type PairConfig = z.infer<typeof pairConfigSchema>;
17
19
 
18
- export const pairPreviewAtom = atom<PairPreviewConfig | undefined>(undefined);
20
+ export const pairConfigAtom = atom<PairConfig | undefined>(undefined);
@@ -1,5 +1,7 @@
1
1
  /* Copyright 2026 Marimo. All rights reserved. */
2
2
  import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
3
+ import { requestId } from "@/__tests__/branded";
4
+ import type { DataSourceDiscoveryResult } from "@/core/kernel/messages";
3
5
  import { connectionAtom } from "@/core/network/connection";
4
6
  import { store } from "@/core/state/jotai";
5
7
  import { ConnectionState } from "@/core/websocket/types";
@@ -41,7 +43,7 @@ describe("fetchDataSourceDiscovery", () => {
41
43
  it("shares a single in-flight request across concurrent callers", async () => {
42
44
  const request = vi
43
45
  .spyOn(DiscoverDataSources, "request")
44
- .mockResolvedValue({ request_id: "request-id", sources: [] });
46
+ .mockResolvedValue({ request_id: requestId("request-id"), sources: [] });
45
47
 
46
48
  await Promise.all([
47
49
  fetchDataSourceDiscovery(),
@@ -55,7 +57,7 @@ describe("fetchDataSourceDiscovery", () => {
55
57
  it("re-runs discovery after the cache is invalidated", async () => {
56
58
  const request = vi
57
59
  .spyOn(DiscoverDataSources, "request")
58
- .mockResolvedValue({ request_id: "request-id", sources: [] });
60
+ .mockResolvedValue({ request_id: requestId("request-id"), sources: [] });
59
61
 
60
62
  await fetchDataSourceDiscovery();
61
63
  invalidateDataSourceDiscovery();
@@ -68,7 +70,10 @@ describe("fetchDataSourceDiscovery", () => {
68
70
  const request = vi
69
71
  .spyOn(DiscoverDataSources, "request")
70
72
  .mockRejectedValueOnce(new Error("boom"))
71
- .mockResolvedValueOnce({ request_id: "request-id", sources: [] });
73
+ .mockResolvedValueOnce({
74
+ request_id: requestId("request-id"),
75
+ sources: [],
76
+ });
72
77
 
73
78
  await expect(fetchDataSourceDiscovery()).rejects.toThrow("boom");
74
79
  await expect(fetchDataSourceDiscovery()).resolves.toEqual([]);
@@ -77,16 +82,18 @@ describe("fetchDataSourceDiscovery", () => {
77
82
 
78
83
  it("does not clear a newer cache entry when an invalidated request fails", async () => {
79
84
  let rejectFirstRequest: ((error: Error) => void) | undefined;
80
- const firstRequest = new Promise<{
81
- request_id: string;
82
- sources: DetectedDataSource[];
83
- }>((_resolve, reject) => {
84
- rejectFirstRequest = reject;
85
- });
85
+ const firstRequest = new Promise<DataSourceDiscoveryResult>(
86
+ (_resolve, reject) => {
87
+ rejectFirstRequest = reject;
88
+ },
89
+ );
86
90
  const request = vi
87
91
  .spyOn(DiscoverDataSources, "request")
88
92
  .mockReturnValueOnce(firstRequest)
89
- .mockResolvedValueOnce({ request_id: "request-id", sources: [] });
93
+ .mockResolvedValueOnce({
94
+ request_id: requestId("request-id"),
95
+ sources: [],
96
+ });
90
97
 
91
98
  const staleResult = fetchDataSourceDiscovery().catch((error) => error);
92
99
  await vi.waitFor(() => expect(request).toHaveBeenCalledTimes(1));
@@ -116,7 +123,7 @@ describe("fetchDataSourceDiscovery", () => {
116
123
  }),
117
124
  ];
118
125
  vi.spyOn(DiscoverDataSources, "request").mockResolvedValue({
119
- request_id: "request-id",
126
+ request_id: requestId("request-id"),
120
127
  sources,
121
128
  });
122
129
 
@@ -0,0 +1,6 @@
1
+ # Host core
2
+
3
+ Production code may import host modules, `jotai/vanilla`, `zod`, and
4
+ `@/utils/Logger`. Enforced by `marimo/host-imports`. Tests are exempt.
5
+
6
+ Define interfaces here and inject application behavior through adapters.