@marimo-team/islands 0.26.1-dev7 → 0.26.1-dev70

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 (320) hide show
  1. package/dist/{ConnectedDataExplorerComponent-DtwVgVpX.js → ConnectedDataExplorerComponent-yQVBQBUW.js} +16 -16
  2. package/dist/{ErrorBoundary-Dxaw2lRl.js → ErrorBoundary-RBxrwyro.js} +19 -19
  3. package/dist/{abnfDiagram-VCTEODGH-BbZOIueZ.js → abnfDiagram-VCTEODGH-Ck_lXwQR.js} +2 -2
  4. package/dist/{any-language-editor-yG-YmLaK.js → any-language-editor-Cx4idbgX.js} +5 -5
  5. package/dist/{architectureDiagram-5GKGNRK7-qjLjxapm.js → architectureDiagram-5GKGNRK7-XeVhic7Z.js} +1 -1
  6. package/dist/{assertNever-DywGMo-S.js → assertNever-473SFxLt.js} +14 -14
  7. package/dist/{button-qQhINE7z.js → button-Z2R2272J.js} +34 -31
  8. package/dist/{capabilities-DKqMqBzm.js → capabilities-ba3Dyv8n.js} +1 -1
  9. package/dist/{chat-ui-D5YPIONI.js → chat-ui-D1mRz9h6.js} +113 -113
  10. package/dist/{check-jchHMCfs.js → check-DmTIavbZ.js} +1 -1
  11. package/dist/{chunk-IMKFNOWR-BzDY1_I7.js → chunk-IMKFNOWR-DdQni67K.js} +1 -1
  12. package/dist/{chunk-SHT3W25Y-DbHsMKdo.js → chunk-SHT3W25Y-BdK-vMct.js} +1 -1
  13. package/dist/{chunk-SVP7TREG-CtwnwAE6.js → chunk-SVP7TREG-cpFZk4Ca.js} +1 -1
  14. package/dist/{chunk-TICWLB2K-C5Z5QMbO.js → chunk-TICWLB2K-DDgQFRgT.js} +1 -1
  15. package/dist/{classDiagram-ZZMXUADV-B8E5Hn78.js → classDiagram-ZZMXUADV-DeojX9X4.js} +2 -2
  16. package/dist/{classDiagram-v2-VYDZK3BY-DeGsK9bT.js → classDiagram-v2-VYDZK3BY-DPfTAiQ6.js} +2 -2
  17. package/dist/{code-visibility-BbRR76tW.js → code-visibility-Bj4tN90X.js} +28 -28
  18. package/dist/{common-ChXjW7mo.js → common-CnnpukFz.js} +5102 -5055
  19. package/dist/{config-qTaTHnpE.js → config-D-lhQq-h.js} +31 -32
  20. package/dist/{copy-icon-BI7vZHEW.js → copy-icon-DuxRkh7T.js} +3 -3
  21. package/dist/{createReducer-DdSLRfBT.js → createReducer-D3pBhIVD.js} +2 -2
  22. package/dist/{cynefinDiagram-5FMLGOSQ-NDedRwsw.js → cynefinDiagram-5FMLGOSQ-DyY9TvuI.js} +1 -1
  23. package/dist/{dagre-GXQ25YYZ-De0sSZO7.js → dagre-GXQ25YYZ-BPCOgtKg.js} +1 -1
  24. package/dist/{data-grid-overlay-editor-DPmANZ7y.js → data-grid-overlay-editor-C7_UKpUZ.js} +1 -1
  25. package/dist/{diagram-S7CK7UJ4-wBtVl61y.js → diagram-S7CK7UJ4-KaF-C6kd.js} +1 -1
  26. package/dist/{diagram-UQ7AKVKN-CKWE3c1T.js → diagram-UQ7AKVKN-DkeqoSvK.js} +1 -1
  27. package/dist/{diagram-VX7I27RA-D2Ac5198.js → diagram-VX7I27RA-DExolTAf.js} +1 -1
  28. package/dist/{diagram-Z3DM3KII-CYaFOQcI.js → diagram-Z3DM3KII-BioFuBF3.js} +1 -1
  29. package/dist/{dialog-Ic6dh09m.js → dialog-CvyFEwby.js} +32 -32
  30. package/dist/{dist-BvZpdAuG.js → dist-6B1_Ttbh.js} +1 -1
  31. package/dist/{dist-D1D56-GS.js → dist-B28poF32.js} +2 -2
  32. package/dist/{dist-BozTF_gH.js → dist-BBZ7lnMw.js} +2 -2
  33. package/dist/{dist-BfrgytDR.js → dist-BD8ZKF5t.js} +3 -3
  34. package/dist/{dist-DNkrY12t.js → dist-BG-7Qpaj.js} +3 -3
  35. package/dist/{dist-D92tYjLc.js → dist-BIaGGUbU.js} +13 -11
  36. package/dist/{dist-BagHbFqG.js → dist-BR5PU2Ph.js} +3 -3
  37. package/dist/{dist-DpYpG8Yc.js → dist-BidYR5m4.js} +3 -3
  38. package/dist/{dist-D95Cd4xm.js → dist-BkGYCvFX.js} +3 -3
  39. package/dist/{dist-DneeBk3K.js → dist-BmEyXT7K.js} +2 -2
  40. package/dist/{dist-BdUitvVW.js → dist-Bt0Wt6m9.js} +2 -2
  41. package/dist/{dist-CEomphG1.js → dist-CG2Sl0D4.js} +2 -2
  42. package/dist/{dist-BMz__bo5.js → dist-CQfpgadU.js} +3 -3
  43. package/dist/{dist-BreKIQqQ.js → dist-CVOPvfzN.js} +3 -3
  44. package/dist/{dist-BEcpQbZa.js → dist-Cm0iCeQQ.js} +3 -3
  45. package/dist/{dist-CDVvitRS.js → dist-Cnc14jEq.js} +2 -2
  46. package/dist/{dist-ChcBm3jk.js → dist-D3KPC38e.js} +4 -4
  47. package/dist/{dist-B1qu3Bez.js → dist-D7BXk27E.js} +3 -3
  48. package/dist/{dist-BsE4gQHj.js → dist-D9Qhvxvg.js} +1 -1
  49. package/dist/{dist-OmeAz0fR.js → dist-DJKajXDB.js} +3 -3
  50. package/dist/{dist-ObeTgSmf.js → dist-DYbNRTYG.js} +4 -4
  51. package/dist/{dist-Cshl6jBw.js → dist-DhtDWnzK.js} +2 -2
  52. package/dist/{dist-BunZKA_9.js → dist-_x2Jks2R.js} +2 -2
  53. package/dist/{dist-MggMo7OR.js → dist-m0MWV-aw.js} +1 -1
  54. package/dist/{dist-TGSwzj8a.js → dist-pPbYNVjd.js} +4 -4
  55. package/dist/{dropdown-menu-Dhv4fcNl.js → dropdown-menu-BiXHfje7.js} +2568 -2568
  56. package/dist/{ebnfDiagram-PWID7BFC-Ds7f42dj.js → ebnfDiagram-PWID7BFC-BSb9k1ed.js} +2 -2
  57. package/dist/{erDiagram-RLTQ6QDP-b58Sz2Mc.js → erDiagram-RLTQ6QDP-PWA30a_r.js} +1 -1
  58. package/dist/{error-banner-CJVLr5_a.js → error-banner-B9HQMSaH.js} +35 -35
  59. package/dist/{error-entries-BKlEsuk4.js → error-entries-P6Qpq6wP.js} +1032 -867
  60. package/dist/{esm-B9n0caHs.js → esm-DY8dGAjJ.js} +23 -23
  61. package/dist/{esm-Bwp_FHP0.js → esm-Dw2ZydG_.js} +3 -3
  62. package/dist/{feedback-button-DP7fO1Hw.js → feedback-button-BsihKrjV.js} +123 -123
  63. package/dist/{flowDiagram-HODETNUW-BH9U7VZK.js → flowDiagram-HODETNUW-BPtD__Zz.js} +2 -2
  64. package/dist/{formats-BLNFWWhV.js → formats-BF95BoCT.js} +3 -3
  65. package/dist/{glide-data-editor-CVIrr2k2.js → glide-data-editor-bC_hEUqu.js} +43 -43
  66. package/dist/{glide-utils-Ze_7l_91.js → glide-utils-iHKKQPJ8.js} +3 -3
  67. package/dist/{globals-Cd1AqHZZ.js → globals-Db9HvOSQ.js} +3 -3
  68. package/dist/{html-to-image-CNM0ZSFD.js → html-to-image-DhrFZL7t.js} +24150 -24028
  69. package/dist/{infoDiagram-27XIBGKW-xbjwrcNi.js → infoDiagram-27XIBGKW-SJuilBEE.js} +1 -1
  70. package/dist/{ishikawaDiagram-5VMMS53U-DKtukhGS.js → ishikawaDiagram-5VMMS53U-DjzyxMr8.js} +1 -1
  71. package/dist/{kanban-definition-UXKFOSKX-BEhlkZBb.js → kanban-definition-UXKFOSKX-D2_qopGt.js} +1 -1
  72. package/dist/{loader-Bin_dutt.js → loader-qPmiRXZd.js} +1 -1
  73. package/dist/main.js +8860 -8741
  74. package/dist/{mermaid-D1CZDNoB.js → mermaid-DcowNmCx.js} +35 -35
  75. package/dist/{mindmap-definition-YA3MSWOX-DQcnJPcV.js → mindmap-definition-YA3MSWOX-pEra10M0.js} +1 -1
  76. package/dist/{number-overlay-editor-CehVCpEF.js → number-overlay-editor-M1rRkX42.js} +1 -1
  77. package/dist/{pegDiagram-XKGWAZYB-BFQuPYfI.js → pegDiagram-XKGWAZYB-CHOPKVOf.js} +2 -2
  78. package/dist/{pencil-DVYzq-iR.js → pencil-FAv6JUvp.js} +1 -1
  79. package/dist/{pieDiagram-E7YTZNPT-l7aqNrem.js → pieDiagram-E7YTZNPT-yGDhsyEN.js} +1 -1
  80. package/dist/{process-output-DthYR2Te.js → process-output-CBPqVQBu.js} +4 -4
  81. package/dist/{railroadDiagram-O6MQD6OU-6R3C1lwQ.js → railroadDiagram-O6MQD6OU-CeKEPdyc.js} +2 -2
  82. package/dist/{requirementDiagram-BXWQKSXE-DdWYu8fn.js → requirementDiagram-BXWQKSXE-DSAbAzKe.js} +1 -1
  83. package/dist/{reveal-component-AjFFBCGn.js → reveal-component-9yg2qvxu.js} +1018 -1018
  84. package/dist/{select-CDUxhHZg.js → select-BszV-bbI.js} +135 -135
  85. package/dist/{sequenceDiagram-WJ2MYXX4-Dzp0dgRc.js → sequenceDiagram-WJ2MYXX4-DVhWj_9H.js} +1 -1
  86. package/dist/{spec-ZAt4P01J.js → spec-CRfw-lOm.js} +4 -4
  87. package/dist/{stateDiagram-D77RDMKH-BGnTUhFJ.js → stateDiagram-D77RDMKH-CDQ2MltG.js} +2 -2
  88. package/dist/{stateDiagram-v2-MP3YSRHH-DsJbmDf1.js → stateDiagram-v2-MP3YSRHH-BQmvwBaz.js} +2 -2
  89. package/dist/{static-state-C4bAlKTU.js → static-state-BtDNJuc2.js} +7 -7
  90. package/dist/style.css +1 -1
  91. package/dist/{swimlanes-42K2YHIH-Bd4Bzh9r.js → swimlanes-42K2YHIH-DLOUTCEL.js} +1 -1
  92. package/dist/{swimlanesDiagram-VR7AAH4N-BlY12Jf6.js → swimlanesDiagram-VR7AAH4N-BVKrkNJ6.js} +2 -2
  93. package/dist/{swiper-component-DTdNB9wg.js → swiper-component-B2O8hF7b.js} +2 -2
  94. package/dist/{timeline-definition-24CTP7MA-m0LanyCH.js → timeline-definition-24CTP7MA-Cb2JoCSd.js} +1 -1
  95. package/dist/{toast-U3NpO2x3.js → toast-QsOAIPfq.js} +166 -166
  96. package/dist/{tooltip-UzJukb3F.js → tooltip-BQZ-Bm6h.js} +65 -65
  97. package/dist/{use-restore-focus-DaTVz6S6.js → use-restore-focus-DT1TZACX.js} +1885 -1877
  98. package/dist/{useDateFormatter-LQNtoXyh.js → useDateFormatter-D3gyMY-g.js} +2 -2
  99. package/dist/{useDeepCompareMemoize-CmNbQ9TT.js → useDeepCompareMemoize-CO6rO5Mq.js} +1 -1
  100. package/dist/{useIframeCapabilities-HTZiVlGV.js → useIframeCapabilities-_0KX0nu_.js} +1 -1
  101. package/dist/{useLifecycle-DTMczKkf.js → useLifecycle-C9UTzCY8.js} +2 -2
  102. package/dist/{vega-component-ZTdbCcwI.js → vega-component-i5lZ23n7.js} +19 -19
  103. package/dist/{vennDiagram-4TSXK5OY-BJ7vqDmn.js → vennDiagram-4TSXK5OY-Cm3EcCcP.js} +1 -1
  104. package/dist/{wardleyDiagram-VM6X3IG4-D5kWacsn.js → wardleyDiagram-VM6X3IG4-DjlUs2CC.js} +1 -1
  105. package/dist/{xychartDiagram-S5SC5T6Z-gr15Ws_z.js → xychartDiagram-S5SC5T6Z-DxNDul9l.js} +1 -1
  106. package/package.json +3 -3
  107. package/src/__mocks__/animation-frames.ts +31 -0
  108. package/src/__mocks__/executions.ts +51 -23
  109. package/src/__mocks__/intersection-observer.ts +45 -0
  110. package/src/__mocks__/notebook.ts +1 -1
  111. package/src/__tests__/branded.ts +4 -0
  112. package/src/__tests__/notebook-analysis.ts +48 -0
  113. package/src/__tests__/render-tracker.ts +15 -0
  114. package/src/__tests__/setup.ts +3 -0
  115. package/src/components/app-config/__tests__/add-model-discovery.test.tsx +30 -0
  116. package/src/components/app-config/ai-config.tsx +5 -3
  117. package/src/components/app-config/user-config-form.tsx +1 -1
  118. package/src/components/data-table/__tests__/export-actions.test.tsx +79 -0
  119. package/src/components/data-table/export-actions.tsx +64 -19
  120. package/src/components/data-table/schemas.ts +1 -0
  121. package/src/components/databases/engine-variable.tsx +2 -2
  122. package/src/components/dependency-graph/panels.tsx +2 -2
  123. package/src/components/editor/__tests__/cell-renders.test.tsx +116 -0
  124. package/src/components/editor/actions/__tests__/name-cell-input.test.tsx +1 -1
  125. package/src/components/editor/actions/useCellActionButton.tsx +2 -8
  126. package/src/components/editor/ai/__tests__/completion-utils.test.ts +28 -61
  127. package/src/components/editor/cell/CreateCellButton.tsx +69 -40
  128. package/src/components/editor/cell/__tests__/CreateCellButton.test.tsx +49 -0
  129. package/src/components/editor/cell/__tests__/cell-context-menu.test.tsx +126 -0
  130. package/src/components/editor/cell/__tests__/useRunCells.test.tsx +5 -5
  131. package/src/components/editor/cell/cell-context-menu.tsx +202 -111
  132. package/src/components/editor/cell/code/__tests__/code-placeholder.test.tsx +40 -0
  133. package/src/components/editor/cell/code/cell-editor.tsx +49 -108
  134. package/src/components/editor/cell/code/code-placeholder.css +61 -11
  135. package/src/components/editor/cell/code/code-placeholder.tsx +52 -27
  136. package/src/components/editor/cell/collapse.tsx +6 -3
  137. package/src/components/editor/cell/useSplitCell.tsx +2 -2
  138. package/src/components/editor/chrome/panels/__tests__/secrets-panel.test.tsx +57 -0
  139. package/src/components/editor/chrome/panels/secrets-panel.tsx +36 -9
  140. package/src/components/editor/chrome/panels/secrets-utils.ts +20 -0
  141. package/src/components/editor/chrome/wrapper/__tests__/document-sync-status.test.tsx +5 -2
  142. package/src/components/editor/chrome/wrapper/__tests__/pending-ai-cells.test.tsx +6 -10
  143. package/src/components/editor/errors/auto-fix.tsx +8 -7
  144. package/src/components/editor/header/status.tsx +5 -2
  145. package/src/components/editor/navigation/__tests__/navigation.test.ts +3 -16
  146. package/src/components/editor/navigation/focus-utils.ts +20 -8
  147. package/src/components/editor/navigation/multi-cell-action-toolbar.tsx +3 -11
  148. package/src/components/editor/navigation/navigation.ts +2 -2
  149. package/src/components/editor/notebook-cell.tsx +15 -24
  150. package/src/components/editor/output/MarimoTracebackOutput.tsx +2 -2
  151. package/src/components/editor/output/console/ConsoleOutput.tsx +77 -50
  152. package/src/components/editor/output/console/__tests__/ConsoleOutput.test.tsx +28 -0
  153. package/src/components/editor/renderers/cells-renderer.tsx +3 -2
  154. package/src/components/editor/renderers/vertical-layout/__tests__/useFocusFirstEditor.test.ts +6 -9
  155. package/src/components/editor/renderers/vertical-layout/useFocusFirstEditor.ts +2 -5
  156. package/src/components/find-replace/find-replace.tsx +3 -7
  157. package/src/components/icons/__tests__/large-spinner.test.tsx +5 -4
  158. package/src/components/scratchpad/scratchpad.tsx +2 -2
  159. package/src/components/tracing/tracing-keyboard.test.tsx +4 -3
  160. package/src/components/ui/__tests__/button-shortcut.test.tsx +22 -0
  161. package/src/components/ui/__tests__/fullscreen.test.tsx +83 -1
  162. package/src/components/ui/button.tsx +5 -1
  163. package/src/components/ui/fullscreen.tsx +43 -89
  164. package/src/components/variables/__tests__/variables-table.test.tsx +1 -2
  165. package/src/core/MarimoApp.tsx +1 -1
  166. package/src/core/__tests__/MarimoApp.test.tsx +147 -0
  167. package/src/core/ai/__tests__/staged-cells.test.ts +6 -39
  168. package/src/core/ai/context/providers/__tests__/error.test.ts +6 -3
  169. package/src/core/ai/staged-cells.ts +8 -35
  170. package/src/core/ai/tools/__tests__/edit-notebook-tool.test.ts +15 -13
  171. package/src/core/ai/tools/edit-notebook-tool.ts +13 -8
  172. package/src/core/cells/__tests__/actions.test.ts +2 -2
  173. package/src/core/cells/__tests__/add-missing-import.test.ts +14 -9
  174. package/src/core/cells/__tests__/arrange.test.ts +1 -1
  175. package/src/core/cells/__tests__/cell-editor-view.test.ts +44 -0
  176. package/src/core/cells/__tests__/cells.test.ts +0 -1
  177. package/src/core/cells/__tests__/focus.test.ts +1 -7
  178. package/src/core/cells/__tests__/harness.ts +9 -8
  179. package/src/core/cells/__tests__/layout.test.ts +1 -1
  180. package/src/core/cells/__tests__/pending-delete-service.test.tsx +121 -11
  181. package/src/core/cells/__tests__/runs.test.ts +14 -14
  182. package/src/core/cells/__tests__/utils.test.ts +3 -2
  183. package/src/core/cells/actions.ts +6 -6
  184. package/src/core/cells/add-missing-import.ts +2 -3
  185. package/src/core/cells/cells.ts +40 -27
  186. package/src/core/cells/document.ts +1 -2
  187. package/src/core/cells/execution-console.ts +10 -5
  188. package/src/core/cells/focus.ts +1 -1
  189. package/src/core/cells/ids.ts +2 -4
  190. package/src/core/cells/pending-delete-service.ts +97 -85
  191. package/src/core/cells/runs.ts +7 -5
  192. package/src/core/cells/scrollCellIntoView.ts +4 -14
  193. package/src/core/cells/session.ts +8 -5
  194. package/src/core/cells/utils.ts +0 -13
  195. package/src/core/codemirror/__tests__/cell-documents.test.ts +79 -0
  196. package/src/core/codemirror/__tests__/debounced-editor-update.test.ts +72 -0
  197. package/src/core/codemirror/__tests__/editor-mount-scheduler.test.ts +75 -105
  198. package/src/core/codemirror/__tests__/format.test.ts +85 -63
  199. package/src/core/codemirror/__tests__/setup.test.ts +61 -1
  200. package/src/core/codemirror/__tests__/use-lazy-editor-mount.test.tsx +198 -0
  201. package/src/core/codemirror/cell-documents.ts +132 -0
  202. package/src/core/codemirror/cells/debugger-decorations.ts +22 -18
  203. package/src/core/codemirror/cells/line-timing-decorations.ts +13 -11
  204. package/src/core/codemirror/cells/traceback-decorations.ts +10 -11
  205. package/src/core/codemirror/code-lens/__tests__/entities.test.ts +7 -11
  206. package/src/core/codemirror/code-lens/__tests__/extension.test.ts +38 -12
  207. package/src/core/codemirror/code-lens/__tests__/perf.test.ts +7 -9
  208. package/src/core/codemirror/code-lens/extension.ts +21 -13
  209. package/src/core/codemirror/copilot/__tests__/getCodes.test.ts +9 -14
  210. package/src/core/codemirror/copilot/getCodes.ts +3 -14
  211. package/src/core/codemirror/debounced-editor-update.ts +41 -0
  212. package/src/core/codemirror/editor-mount-scheduler.ts +41 -48
  213. package/src/core/codemirror/extensions.ts +2 -2
  214. package/src/core/codemirror/find-replace/__tests__/navigate.test.ts +42 -16
  215. package/src/core/codemirror/find-replace/__tests__/search-highlight.test.ts +30 -0
  216. package/src/core/codemirror/find-replace/__tests__/unmounted-cells.test.ts +145 -0
  217. package/src/core/codemirror/find-replace/navigate.ts +88 -129
  218. package/src/core/codemirror/find-replace/search-highlight.ts +3 -1
  219. package/src/core/codemirror/find-replace/state.ts +7 -2
  220. package/src/core/codemirror/format.ts +25 -31
  221. package/src/core/codemirror/go-to-definition/__tests__/underline.test.ts +58 -0
  222. package/src/core/codemirror/go-to-definition/__tests__/utils.test.ts +24 -44
  223. package/src/core/codemirror/go-to-definition/extension.ts +9 -7
  224. package/src/core/codemirror/go-to-definition/underline.ts +39 -48
  225. package/src/core/codemirror/language/__tests__/sql.test.ts +36 -0
  226. package/src/core/codemirror/language/cell-code.ts +7 -0
  227. package/src/core/codemirror/language/embedded/__tests__/embedded-python.test.ts +2 -18
  228. package/src/core/codemirror/language/languages/sql/sql.ts +3 -0
  229. package/src/core/codemirror/lsp/__tests__/notebook-lsp.test.ts +25 -0
  230. package/src/core/codemirror/lsp/notebook-lsp.ts +6 -16
  231. package/src/core/codemirror/placeholder/extensions.ts +26 -24
  232. package/src/core/codemirror/reactive-references/__tests__/extension.test.ts +54 -0
  233. package/src/core/codemirror/reactive-references/extension.ts +30 -21
  234. package/src/core/codemirror/use-lazy-editor-mount.ts +70 -0
  235. package/src/core/codemirror/utils.ts +2 -6
  236. package/src/core/datasets/__tests__/data-source.test.ts +15 -17
  237. package/src/core/datasets/data-source-connections.ts +8 -11
  238. package/src/core/datasets/state.ts +7 -12
  239. package/src/core/executions/__tests__/atoms.test.ts +211 -5
  240. package/src/core/executions/__tests__/freshness.test.ts +65 -56
  241. package/src/core/executions/__tests__/interrupt.test.ts +5 -3
  242. package/src/core/executions/__tests__/output-lifecycle.test.ts +95 -7
  243. package/src/core/executions/__tests__/output.test.ts +5 -3
  244. package/src/core/executions/__tests__/run.test.ts +4 -4
  245. package/src/core/executions/__tests__/select.test.ts +108 -69
  246. package/src/core/executions/atoms.ts +248 -83
  247. package/src/core/executions/freshness.ts +7 -7
  248. package/src/core/executions/hooks.ts +15 -59
  249. package/src/core/executions/index.ts +2 -0
  250. package/src/core/executions/output.ts +49 -35
  251. package/src/core/executions/select.ts +90 -37
  252. package/src/core/export/__tests__/hooks.test.ts +1 -1
  253. package/src/core/islands/__tests__/bridge.test.ts +1 -1
  254. package/src/core/islands/bootstrap.ts +7 -7
  255. package/src/core/islands/bridge.ts +1 -1
  256. package/src/core/meta/__tests__/code-visibility.test.tsx +3 -2
  257. package/src/core/notebook/document/__tests__/codemirror.test.ts +8 -6
  258. package/src/core/notebook/document/__tests__/draft.test.ts +56 -58
  259. package/src/core/notebook/document/__tests__/fixtures.ts +8 -7
  260. package/src/core/notebook/document/__tests__/hooks.test.tsx +39 -35
  261. package/src/core/notebook/document/__tests__/lifecycle-scenarios.test.ts +8 -5
  262. package/src/core/notebook/document/__tests__/model.test.ts +8 -5
  263. package/src/core/notebook/document/__tests__/protocol-fixtures.ts +2 -2
  264. package/src/core/notebook/document/__tests__/recovery-scenarios.test.ts +37 -32
  265. package/src/core/notebook/document/__tests__/scenarios.test.ts +49 -45
  266. package/src/core/notebook/document/__tests__/state.test.ts +59 -56
  267. package/src/core/notebook/document/__tests__/submission.test.ts +15 -12
  268. package/src/core/notebook/document/__tests__/test-host.ts +3 -2
  269. package/src/core/notebook/document/__tests__/user.ts +7 -3
  270. package/src/core/notebook/document/draft.ts +29 -11
  271. package/src/core/notebook/document/state.ts +7 -6
  272. package/src/core/notebook/replica/__tests__/document.test.ts +9 -5
  273. package/src/core/notebook/replica/__tests__/executions.test.ts +90 -25
  274. package/src/core/notebook/replica/__tests__/fixtures.ts +6 -2
  275. package/src/core/notebook/replica/__tests__/frame.test.ts +206 -0
  276. package/src/core/notebook/replica/__tests__/once-per-frame.test.ts +95 -0
  277. package/src/core/notebook/replica/__tests__/replica.test.ts +53 -9
  278. package/src/core/notebook/replica/__tests__/results.test.ts +27 -29
  279. package/src/core/notebook/replica/execution-state.ts +2 -2
  280. package/src/core/notebook/replica/frame.ts +54 -0
  281. package/src/core/notebook/replica/index.ts +1 -0
  282. package/src/core/notebook/replica/once-per-frame.ts +60 -0
  283. package/src/core/notebook/replica/replica.ts +27 -6
  284. package/src/core/notebook/replica/resources/analysis.ts +1 -1
  285. package/src/core/notebook/replica/resources/document.ts +9 -8
  286. package/src/core/notebook/replica/resources/executions.ts +197 -78
  287. package/src/core/notebook/replica/resources/results.ts +8 -14
  288. package/src/core/saving/__tests__/document.test.tsx +1 -1
  289. package/src/core/saving/__tests__/state.test.ts +2 -2
  290. package/src/core/session/__tests__/useNotebookReplica.hook.test.tsx +55 -9
  291. package/src/core/session/__tests__/useNotebookSession.hook.test.tsx +230 -12
  292. package/src/core/session/active-notebook.ts +4 -1
  293. package/src/core/session/useNotebookReplica.ts +15 -2
  294. package/src/core/session/useNotebookSession.tsx +38 -46
  295. package/src/core/state/__tests__/atom-with-selected-inputs.test.ts +48 -0
  296. package/src/core/state/__tests__/create-keyed-selector-hook.test.tsx +137 -0
  297. package/src/core/state/atom-with-selected-inputs.ts +24 -0
  298. package/src/core/state/create-keyed-atom-hook.ts +18 -0
  299. package/src/core/state/create-keyed-selector-hook.ts +22 -0
  300. package/src/core/storage/__tests__/state.test.ts +6 -9
  301. package/src/core/storage/state.ts +5 -8
  302. package/src/core/transports/__tests__/static.test.ts +3 -2
  303. package/src/core/transports/static.ts +2 -2
  304. package/src/core/variables/state.ts +73 -68
  305. package/src/core/variables/types.ts +2 -2
  306. package/src/core/vscode/__tests__/is-in-vscode.test.ts +36 -0
  307. package/src/core/vscode/is-in-vscode.ts +2 -2
  308. package/src/core/wasm/__tests__/bridge.test.ts +73 -1
  309. package/src/core/wasm/bridge.ts +5 -4
  310. package/src/plugins/impl/TextInputPlugin.tsx +2 -1
  311. package/src/plugins/impl/__test__/text-labels.test.tsx +46 -1
  312. package/src/utils/__tests__/lazy.test.tsx +33 -0
  313. package/src/utils/__tests__/shared-intersection-observer.test.ts +49 -0
  314. package/src/utils/__tests__/shared-resource.test.ts +107 -0
  315. package/src/utils/arrays.ts +4 -1
  316. package/src/utils/lazy.tsx +74 -0
  317. package/src/utils/shared-intersection-observer.ts +53 -0
  318. package/src/utils/shared-resource.ts +59 -0
  319. package/src/core/variables/__tests__/state.test.ts +0 -148
  320. package/src/utils/lazy.ts +0 -35
@@ -10,6 +10,11 @@ import {
10
10
  } from "../state";
11
11
  import { selectCell, selectOrder } from "../select";
12
12
  import { cell, document, withCells } from "./fixtures";
13
+ import { cellId } from "@/__tests__/branded";
14
+
15
+ const C1 = cellId("c1");
16
+ const C2 = cellId("c2");
17
+ const C3 = cellId("c3");
13
18
 
14
19
  const lifetimes: AbortController[] = [];
15
20
  afterEach(() =>
@@ -31,7 +36,7 @@ function setup(initial: Document | null = document()) {
31
36
  store,
32
37
  source,
33
38
  ...model,
34
- cellAtom: (id: string) => selectCell(model.documentAtom, id),
39
+ cellAtom: (id: string) => selectCell(model.documentAtom, cellId(id)),
35
40
  orderAtom: selectOrder(model.documentAtom),
36
41
  abort: () => controller.abort(),
37
42
  edit: (callback: DocumentEdit) => store.set(model.editAtom, callback),
@@ -51,7 +56,7 @@ describe("document model", () => {
51
56
  it("keeps metadata drafts while source is unavailable and follows its return", () => {
52
57
  const initial = document();
53
58
  const { store, source, cellAtom, changesAtom, edit } = setup(initial);
54
- edit((tx) => tx.setName("c1", "local name"));
59
+ edit((tx) => tx.setName(C1, "local name"));
55
60
  const hidden = withCells(initial, {
56
61
  c1: cell("c1", "", { code: null }),
57
62
  });
@@ -86,10 +91,10 @@ describe("document model", () => {
86
91
 
87
92
  it("rebases a local order onto the latest host order and its precondition", () => {
88
93
  const { store, source, orderAtom, changesAtom, edit } = setup();
89
- edit((tx) => tx.setOrder(["c2", "c1"]));
94
+ edit((tx) => tx.setOrder([C2, C1]));
90
95
  store.set(
91
96
  source,
92
- withCells(document(), { c3: cell("c3", "new") }, ["c1", "c3", "c2"]),
97
+ withCells(document(), { c3: cell("c3", "new") }, [C1, C3, C2]),
93
98
  );
94
99
  expect(store.get(orderAtom)).toEqual(["c2", "c1", "c3"]);
95
100
  expect(store.get(changesAtom)).toEqual([
@@ -105,9 +110,7 @@ describe("document model", () => {
105
110
  "appends a creation when its %s anchor was removed remotely",
106
111
  (direction) => {
107
112
  const { store, source, orderAtom, changesAtom, edit } = setup();
108
- edit((tx) =>
109
- tx.createCell({ id: "c3", code: "" }, { [direction]: "c1" }),
110
- );
113
+ edit((tx) => tx.createCell({ id: C3, code: "" }, { [direction]: C1 }));
111
114
  store.set(source, withCells(document(), { c1: null }));
112
115
  expect(store.get(orderAtom)).toEqual(["c2", "c3"]);
113
116
  expect(store.get(changesAtom)).toEqual([
@@ -126,8 +129,8 @@ describe("document model", () => {
126
129
 
127
130
  it("brings back a cell deleted earlier in the draft with new content", () => {
128
131
  const { store, cellAtom, orderAtom, changesAtom, edit } = setup();
129
- edit((tx) => tx.deleteCell("c1"));
130
- edit((tx) => tx.createCell({ id: "c1", code: "back" }, { after: "c2" }));
132
+ edit((tx) => tx.deleteCell(C1));
133
+ edit((tx) => tx.createCell({ id: C1, code: "back" }, { after: C2 }));
131
134
  expect(store.get(cellAtom("c1"))?.code).toBe("back");
132
135
  expect(store.get(orderAtom)).toEqual(["c2", "c1"]);
133
136
  expect(store.get(changesAtom)).toEqual([
@@ -148,16 +151,16 @@ describe("document model", () => {
148
151
  it("publishes the visible order when an anchor is deleted later in the draft", () => {
149
152
  const { store, orderAtom, changesAtom, edit } = setup();
150
153
  edit((tx) => {
151
- tx.setCode("c1", "edited before creation");
152
- tx.createCell({ id: "c3", code: "" }, { after: "c1" });
153
- tx.deleteCell("c1");
154
+ tx.setCode(C1, "edited before creation");
155
+ tx.createCell({ id: C3, code: "" }, { after: C1 });
156
+ tx.deleteCell(C1);
154
157
  });
155
158
  expect(store.get(orderAtom)).toEqual(["c3", "c2"]);
156
159
  expect(store.get(changesAtom)).toEqual([
157
160
  { kind: "delete_cell", id: "c1", base_etag: "c1-etag" },
158
161
  {
159
162
  kind: "create_cell",
160
- cell: { id: "c3", code: "", name: "_", config: cell("c3", "").config },
163
+ cell: { id: C3, code: "", name: "_", config: cell("c3", "").config },
161
164
  },
162
165
  { kind: "set_order", base_etag: "order-1", order: ["c3", "c2"] },
163
166
  ]);
@@ -166,7 +169,7 @@ describe("document model", () => {
166
169
  it("does not release a draft because the host caught up", () => {
167
170
  const initial = document();
168
171
  const { store, source, cellAtom, edit } = setup(initial);
169
- edit((tx) => tx.setCode("c1", "local"));
172
+ edit((tx) => tx.setCode(C1, "local"));
170
173
  for (const code of ["local", "later remote edit"]) {
171
174
  store.set(source, withCells(initial, { c1: cell("c1", code) }));
172
175
  expect(store.get(cellAtom("c1"))?.code).toBe("local");
@@ -175,10 +178,10 @@ describe("document model", () => {
175
178
 
176
179
  it("keeps drafts separate when notebooks reuse cell ids", () => {
177
180
  const { store, source, cellAtom, edit } = setup();
178
- edit((tx) => tx.setCode("c1", "first notebook"));
181
+ edit((tx) => tx.setCode(C1, "first notebook"));
179
182
  store.set(source, document("n2"));
180
183
  expect(store.get(cellAtom("c1"))?.code).toBe("x = 1");
181
- edit((tx) => tx.setCode("c1", "second notebook"));
184
+ edit((tx) => tx.setCode(C1, "second notebook"));
182
185
  store.set(source, document("n1"));
183
186
  expect(store.get(cellAtom("c1"))?.code).toBe("first notebook");
184
187
  store.set(source, document("n2"));
@@ -188,15 +191,15 @@ describe("document model", () => {
188
191
  it("does not repeat a satisfied deletion without mounted readers", () => {
189
192
  const { store, source, cellAtom, changesAtom, edit } = setup();
190
193
  edit((tx) => {
191
- tx.deleteCell("c1");
192
- tx.setCode("c2", "keep this draft");
194
+ tx.deleteCell(C1);
195
+ tx.setCode(C2, "keep this draft");
193
196
  });
194
197
  const removed = withCells(document(), { c1: null });
195
198
  store.set(source, removed);
196
199
  // No reads between snapshots: reconciliation must observe the removal.
197
200
  store.set(
198
201
  source,
199
- withCells(removed, { c1: cell("c1", "restored") }, ["c1", "c2"]),
202
+ withCells(removed, { c1: cell("c1", "restored") }, [C1, C2]),
200
203
  );
201
204
  expect(store.get(cellAtom("c1"))?.code).toBe("restored");
202
205
  expect(store.get(cellAtom("c2"))?.code).toBe("keep this draft");
@@ -217,8 +220,8 @@ describe("document model", () => {
217
220
  it("retains edits when the host removes a cell and blocks partial submissions", () => {
218
221
  const { store, source, cellAtom, changesAtom, edit } = setup();
219
222
  edit((tx) => {
220
- tx.setCode("c1", "recover this code");
221
- tx.setCode("c2", "another edit");
223
+ tx.setCode(C1, "recover this code");
224
+ tx.setCode(C2, "another edit");
222
225
  });
223
226
  const removed = withCells(document(), { c1: null });
224
227
  store.set(source, removed);
@@ -241,12 +244,12 @@ describe("document model", () => {
241
244
  });
242
245
  const unsubscribeOrder = store.sub(orderAtom, onOrder);
243
246
  edit((tx) => {
244
- tx.createCell({ id: "c3", code: "3" }, { after: "c2" });
245
- tx.setCode("c3", "updated");
246
- tx.setName("c3", "example");
247
- tx.updateConfig("c3", { hide_code: true });
248
- tx.deleteCell("c1");
249
- tx.setOrder(["c3", "c2"]);
247
+ tx.createCell({ id: C3, code: "3" }, { after: C2 });
248
+ tx.setCode(C3, "updated");
249
+ tx.setName(C3, "example");
250
+ tx.updateConfig(C3, { hide_code: true });
251
+ tx.deleteCell(C1);
252
+ tx.setOrder([C3, C2]);
250
253
  expect(store.get(orderAtom)).toEqual(["c1", "c2"]);
251
254
  expect(store.get(cellAtom("c3"))).toBeUndefined();
252
255
  });
@@ -262,13 +265,13 @@ describe("document model", () => {
262
265
  const unsubscribeCell = store.sub(cellAtom("c1"), onCell);
263
266
  const unsubscribeOrder = store.sub(orderAtom, onOrder);
264
267
  edit((tx) => {
265
- tx.setCode("c1", "x = 1");
266
- tx.updateConfig("c1", { column: null });
268
+ tx.setCode(C1, "x = 1");
269
+ tx.updateConfig(C1, { column: null });
267
270
  });
268
271
  expect(onCell).not.toHaveBeenCalled();
269
- edit((tx) => tx.setCode("c1", "local"));
270
- edit((tx) => tx.setCode("c1", "local"));
271
- edit((tx) => tx.setOrder(["c1", "c2"]));
272
+ edit((tx) => tx.setCode(C1, "local"));
273
+ edit((tx) => tx.setCode(C1, "local"));
274
+ edit((tx) => tx.setOrder([C1, C2]));
272
275
  expect(onCell).toHaveBeenCalledOnce();
273
276
  expect(onOrder).not.toHaveBeenCalled();
274
277
  unsubscribeCell();
@@ -279,8 +282,8 @@ describe("document model", () => {
279
282
  const initial = document();
280
283
  const { store, source, cellAtom, orderAtom, edit } = setup(initial);
281
284
  edit((tx) => {
282
- tx.setCode("c1", "local");
283
- tx.createCell({ id: "c3", code: "new" });
285
+ tx.setCode(C1, "local");
286
+ tx.createCell({ id: C3, code: "new" });
284
287
  });
285
288
  const c1 = cellAtom("c1");
286
289
  const first = store.get(c1);
@@ -294,7 +297,7 @@ describe("document model", () => {
294
297
  store.sub(orderAtom, onOrder),
295
298
  ];
296
299
 
297
- edit((tx) => tx.setCode("c2", "other local"));
300
+ edit((tx) => tx.setCode(C2, "other local"));
298
301
  const remote = withCells(initial, {
299
302
  c1: cell("c1", "remote", { version: 2, etag: "new-etag" }),
300
303
  });
@@ -325,7 +328,7 @@ describe("document model", () => {
325
328
  config: cell("c1", "").config,
326
329
  });
327
330
  expect(onFirst).toHaveBeenCalledOnce();
328
- edit((tx) => tx.setOrder(["c3", "c2", "c1"]));
331
+ edit((tx) => tx.setOrder([C3, C2, C1]));
329
332
  expect(onOrder).toHaveBeenCalledOnce();
330
333
  expect(onFirst).toHaveBeenCalledOnce();
331
334
  unsubscribe.forEach((fn) => fn());
@@ -335,14 +338,14 @@ describe("document model", () => {
335
338
  [
336
339
  "a missing placement anchor",
337
340
  (tx: DocumentEditor) =>
338
- tx.createCell({ id: "c3", code: "" }, { after: "missing" }),
341
+ tx.createCell({ id: C3, code: "" }, { after: cellId("missing") }),
339
342
  "Cell missing does not exist",
340
343
  ],
341
344
  [
342
345
  "a deleted placement anchor",
343
346
  (tx: DocumentEditor) => {
344
- tx.deleteCell("c2");
345
- tx.createCell({ id: "c3", code: "" }, { before: "c2" });
347
+ tx.deleteCell(C2);
348
+ tx.createCell({ id: C3, code: "" }, { before: C2 });
346
349
  },
347
350
  "Cell c2 does not exist",
348
351
  ],
@@ -355,40 +358,40 @@ describe("document model", () => {
355
358
  ],
356
359
  [
357
360
  "a missing cell",
358
- (tx: DocumentEditor) => tx.setCode("missing", "code"),
361
+ (tx: DocumentEditor) => tx.setCode(cellId("missing"), "code"),
359
362
  "Cell missing does not exist",
360
363
  ],
361
364
  [
362
365
  "a deleted cell",
363
366
  (tx: DocumentEditor) => {
364
- tx.deleteCell("c2");
365
- tx.setName("c2", "missing");
367
+ tx.deleteCell(C2);
368
+ tx.setName(C2, "missing");
366
369
  },
367
370
  "Cell c2 does not exist",
368
371
  ],
369
372
  [
370
373
  "a duplicate cell",
371
- (tx: DocumentEditor) => tx.createCell({ id: "c1", code: "duplicate" }),
374
+ (tx: DocumentEditor) => tx.createCell({ id: C1, code: "duplicate" }),
372
375
  "Cell c1 already exists",
373
376
  ],
374
377
  [
375
378
  "an incomplete order",
376
- (tx: DocumentEditor) => tx.setOrder(["c1"]),
379
+ (tx: DocumentEditor) => tx.setOrder([C1]),
377
380
  "Cell order must contain every cell exactly once",
378
381
  ],
379
382
  [
380
383
  "a duplicate in the order",
381
- (tx: DocumentEditor) => tx.setOrder(["c1", "c1"]),
384
+ (tx: DocumentEditor) => tx.setOrder([C1, C1]),
382
385
  "Cell order must contain every cell exactly once",
383
386
  ],
384
387
  [
385
388
  "an unknown cell in the order",
386
- (tx: DocumentEditor) => tx.setOrder(["c1", "missing"]),
389
+ (tx: DocumentEditor) => tx.setOrder([C1, cellId("missing")]),
387
390
  "Cell order must contain every cell exactly once",
388
391
  ],
389
392
  [
390
393
  "an invalid config",
391
- (tx: DocumentEditor) => tx.updateConfig("c2", { column: 0.5 }),
394
+ (tx: DocumentEditor) => tx.updateConfig(C2, { column: 0.5 }),
392
395
  "Invalid input",
393
396
  ],
394
397
  ])("rolls back the whole transaction for %s", (_, fail, message) => {
@@ -397,13 +400,13 @@ describe("document model", () => {
397
400
  const unsubscribe = store.sub(cellAtom("c1"), onChange);
398
401
  expect(() =>
399
402
  edit((tx) => {
400
- tx.setCode("c1", "not committed");
403
+ tx.setCode(C1, "not committed");
401
404
  fail(tx);
402
405
  }),
403
406
  ).toThrow(message);
404
407
  expect(store.get(changesAtom)).toEqual([]);
405
408
  expect(onChange).not.toHaveBeenCalled();
406
- edit((tx) => tx.setCode("c1", "next transaction"));
409
+ edit((tx) => tx.setCode(C1, "next transaction"));
407
410
  expect(store.get(cellAtom("c1"))?.code).toBe("next transaction");
408
411
  unsubscribe();
409
412
  });
@@ -413,9 +416,9 @@ describe("document model", () => {
413
416
  let saved: DocumentEditor | undefined;
414
417
  edit((tx) => {
415
418
  saved = tx;
416
- tx.setCode("c1", "committed");
419
+ tx.setCode(C1, "committed");
417
420
  });
418
- expect(() => saved?.setCode("c1", "too late")).toThrow("has ended");
421
+ expect(() => saved?.setCode(C1, "too late")).toThrow("has ended");
419
422
  expect(store.get(cellAtom("c1"))?.code).toBe("committed");
420
423
  });
421
424
 
@@ -423,9 +426,9 @@ describe("document model", () => {
423
426
  const { store, changesAtom, edit } = setup();
424
427
  expect(() =>
425
428
  edit(async (tx) => {
426
- tx.setCode("c1", "before await");
429
+ tx.setCode(C1, "before await");
427
430
  await Promise.resolve();
428
- tx.setCode("c1", "after await");
431
+ tx.setCode(C1, "after await");
429
432
  }),
430
433
  ).toThrow("must be synchronous");
431
434
  await Promise.resolve();
@@ -436,8 +439,8 @@ describe("document model", () => {
436
439
  const { store, changesAtom, edit } = setup();
437
440
  expect(() =>
438
441
  edit((tx) => {
439
- tx.setCode("c1", "outer");
440
- edit((inner) => inner.setCode("c2", "inner"));
442
+ tx.setCode(C1, "outer");
443
+ edit((inner) => inner.setCode(C2, "inner"));
441
444
  }),
442
445
  ).toThrow("cannot be nested");
443
446
  expect(store.get(changesAtom)).toEqual([]);
@@ -447,7 +450,7 @@ describe("document model", () => {
447
450
  const { store, source, changesAtom, edit } = setup();
448
451
  expect(() =>
449
452
  edit((tx) => {
450
- tx.setCode("c1", "old notebook");
453
+ tx.setCode(C1, "old notebook");
451
454
  store.set(source, document("n2"));
452
455
  }),
453
456
  ).toThrow("changed during the transaction");
@@ -6,6 +6,9 @@ import type { Document } from "../../replica/resources/document";
6
6
  import { selectCell } from "../select";
7
7
  import { createDocumentState, type DocumentSubmission } from "../state";
8
8
  import { cell, document, withCells } from "./fixtures";
9
+ import { cellId } from "@/__tests__/branded";
10
+
11
+ const C1 = cellId("c1");
9
12
 
10
13
  const lifetimes: AbortController[] = [];
11
14
  afterEach(() =>
@@ -27,7 +30,7 @@ function setup() {
27
30
  store,
28
31
  source,
29
32
  ...model,
30
- cellAtom: (id: string) => selectCell(model.documentAtom, id),
33
+ cellAtom: (id: string) => selectCell(model.documentAtom, cellId(id)),
31
34
  submit() {
32
35
  const submission = store.set(model.submitAtom);
33
36
  if (submission === null) {
@@ -59,8 +62,8 @@ describe("document submissions", () => {
59
62
  });
60
63
  store.set(source, hidden);
61
64
  store.set(editAtom, (tx) => {
62
- tx.setCode("c2", "other edit");
63
- tx.setName("c1", "renamed");
65
+ tx.setCode(cellId("c2"), "other edit");
66
+ tx.setName(C1, "renamed");
64
67
  });
65
68
  expect(store.get(changesAtom)).toBeNull();
66
69
  expect(store.set(submitAtom)).toBeNull();
@@ -70,7 +73,7 @@ describe("document submissions", () => {
70
73
  if (recovery === "host source") {
71
74
  store.set(source, withCells(hidden, { c1: cell("c1", code) }));
72
75
  } else {
73
- store.set(editAtom, (tx) => tx.setCode("c1", code));
76
+ store.set(editAtom, (tx) => tx.setCode(C1, code));
74
77
  }
75
78
  const sent = submit();
76
79
  expect(sent.changes).toEqual([
@@ -110,13 +113,13 @@ describe("document submissions", () => {
110
113
  (first) => {
111
114
  const { store, source, editAtom, cellAtom, submit, settle } = setup();
112
115
  store.set(editAtom, (tx) => {
113
- tx.setCode("c1", "sent");
114
- tx.createCell({ id: "c3", code: "new" });
116
+ tx.setCode(C1, "sent");
117
+ tx.createCell({ id: cellId("c3"), code: "new" });
115
118
  });
116
119
  const sent = submit();
117
120
  store.set(editAtom, (tx) => {
118
- tx.setCode("c1", "still typing");
119
- tx.deleteCell("c3");
121
+ tx.setCode(C1, "still typing");
122
+ tx.deleteCell(cellId("c3"));
120
123
  });
121
124
  const onCode = vi.fn();
122
125
  const onCreation = vi.fn();
@@ -145,7 +148,7 @@ describe("document submissions", () => {
145
148
  it("waits for the response's later revision and follows subsequent host edits", () => {
146
149
  const { store, source, editAtom, cellAtom, submitAtom, submit, settle } =
147
150
  setup();
148
- store.set(editAtom, (tx) => tx.setCode("c1", "sent"));
151
+ store.set(editAtom, (tx) => tx.setCode(C1, "sent"));
149
152
  const sent = submit();
150
153
  const edited = withCells(document(), { c1: cell("c1", "sent") });
151
154
  const response = withCells(edited, { c2: cell("c2", "mirrored update") });
@@ -164,10 +167,10 @@ describe("document submissions", () => {
164
167
 
165
168
  it("invalidates submissions when switching notebooks, retaining each draft", () => {
166
169
  const { store, source, editAtom, cellAtom, submit, settle } = setup();
167
- store.set(editAtom, (tx) => tx.setCode("c1", "first"));
170
+ store.set(editAtom, (tx) => tx.setCode(C1, "first"));
168
171
  const sent = submit();
169
172
  store.set(source, document("n2"));
170
- store.set(editAtom, (tx) => tx.setCode("c1", "second"));
173
+ store.set(editAtom, (tx) => tx.setCode(C1, "second"));
171
174
  store.set(source, withCells(document(), { c2: cell("c2", "remote") }));
172
175
  settle(sent, withCells(document(), { c1: cell("c1", "first") }));
173
176
  expect(store.get(cellAtom("c1"))?.code).toBe("first");
@@ -178,7 +181,7 @@ describe("document submissions", () => {
178
181
  it("retries a rejected edit with fresh preconditions and ignores its late reply", () => {
179
182
  const { store, source, editAtom, settleAtom, submitAtom, submit, settle } =
180
183
  setup();
181
- store.set(editAtom, (tx) => tx.setCode("c1", "local"));
184
+ store.set(editAtom, (tx) => tx.setCode(C1, "local"));
182
185
  const sent = submit();
183
186
  store.set(settleAtom, sent, null);
184
187
  const remote = withCells(document(), {
@@ -24,7 +24,7 @@ function record(
24
24
  input: Protocol.CellInput,
25
25
  notebookId: Protocol.NotebookId,
26
26
  version: number,
27
- ): Protocol.Cell {
27
+ ): Protocol.CellOutput {
28
28
  const cell = Protocol.CellInput.parse(input);
29
29
  const config = Protocol.CellConfigInput.parse(cell.config ?? {});
30
30
  const code = cell.code.replace(/\r\n?/g, "\n");
@@ -86,7 +86,8 @@ export function createTestHost(initial: Document) {
86
86
  document: current.revision,
87
87
  });
88
88
 
89
- for (const [index, change] of changes.entries()) {
89
+ for (const [index, input] of changes.entries()) {
90
+ const change = Protocol.Change.parse(input);
90
91
  switch (change.kind) {
91
92
  case "create_cell":
92
93
  case "replace_cell": {
@@ -1,5 +1,6 @@
1
1
  /* Copyright 2026 Marimo. All rights reserved. */
2
2
 
3
+ import { cellId } from "@/__tests__/branded";
3
4
  import type * as Protocol from "@marimo-team/client/protocol";
4
5
  import type { createStore } from "jotai/vanilla";
5
6
  import type { Placement } from "../draft";
@@ -21,10 +22,11 @@ export function createUser(
21
22
  store.set(model.editAtom, (tx) => tx.setCode(id, code));
22
23
  },
23
24
  changeCells(
24
- changes: Record<Protocol.CellId, Partial<Omit<Protocol.CellInput, "id">>>,
25
+ changes: Record<string, Partial<Omit<Protocol.CellInput, "id">>>,
25
26
  ) {
26
27
  store.set(model.editAtom, (tx) => {
27
- for (const [id, patch] of Object.entries(changes)) {
28
+ for (const [key, patch] of Object.entries(changes)) {
29
+ const id = cellId(key);
28
30
  if (patch.code !== undefined) {
29
31
  tx.setCode(id, patch.code);
30
32
  }
@@ -38,7 +40,9 @@ export function createUser(
38
40
  });
39
41
  },
40
42
  createCell(cell: Protocol.CellInput, placement?: Placement) {
41
- store.set(model.editAtom, (tx) => tx.createCell(cell, placement));
43
+ store.set(model.editAtom, (tx) =>
44
+ tx.createCell({ ...cell, id: cellId(cell.id) }, placement),
45
+ );
42
46
  },
43
47
  deleteCell(id: Protocol.CellId) {
44
48
  store.set(model.editAtom, (tx) => tx.deleteCell(id));
@@ -5,11 +5,13 @@ import * as Protocol from "@marimo-team/client/protocol";
5
5
 
6
6
  /** The fields a client edits. Null code means the host withheld source. */
7
7
  export type EditableCell = Readonly<
8
- Pick<Protocol.Cell, "id" | "code" | "name">
8
+ Pick<Protocol.CellOutput, "id" | "code" | "name">
9
9
  > & {
10
10
  readonly config: Readonly<Protocol.CellConfig>;
11
11
  };
12
12
 
13
+ export type NewCell = Protocol.CellInput & { id: Protocol.CellId };
14
+
13
15
  type CellWithSource = EditableCell & { readonly code: string };
14
16
 
15
17
  /** A confirmed document with a draft applied. */
@@ -221,6 +223,7 @@ export function editCell(
221
223
  id: Protocol.CellId,
222
224
  edit: CellEdit,
223
225
  ): Draft {
226
+ checkColumn(edit.config?.column);
224
227
  const current = draft.cells.get(id);
225
228
  if (current?.kind === "delete") {
226
229
  return draft;
@@ -250,10 +253,10 @@ export function editCell(
250
253
  */
251
254
  export function createCell(
252
255
  draft: Draft,
253
- input: Protocol.CellInput,
256
+ input: NewCell,
254
257
  placement: Placement = {},
255
258
  ): Draft {
256
- const cell = parseCell(input);
259
+ const cell = withDefaults(input);
257
260
  const next = withCell(draft, cell.id, { kind: "create", cell, placement });
258
261
  return draft.order === null
259
262
  ? next
@@ -270,11 +273,11 @@ export function createCell(
270
273
  export function restoreCell(
271
274
  confirmed: Document,
272
275
  draft: Draft,
273
- input: Protocol.CellInput,
276
+ input: NewCell,
274
277
  placement: Placement = {},
275
278
  sent: Draft = EMPTY_DRAFT,
276
279
  ): Draft {
277
- const { id, code, name, config } = parseCell(input);
280
+ const { id, code, name, config } = withDefaults(input);
278
281
  const withdrawn = withCell(draft, id, undefined);
279
282
  const next =
280
283
  sent.cells.get(id)?.kind === "delete"
@@ -285,14 +288,29 @@ export function restoreCell(
285
288
  return sameOrder(order, placed) ? next : setOrder(next, placed);
286
289
  }
287
290
 
291
+ function checkColumn(column: number | null | undefined): void {
292
+ if (column != null && !Number.isSafeInteger(column)) {
293
+ throw new Error("Invalid input: cell column must be an integer");
294
+ }
295
+ }
296
+
288
297
  /** A cell input with the protocol's defaults filled in. */
289
- function parseCell(input: Protocol.CellInput): CellWithSource {
290
- const parsed = Protocol.CellInput.parse(input);
298
+ function withDefaults(input: NewCell): CellWithSource {
299
+ checkColumn(input.config?.column);
291
300
  return {
292
- id: parsed.id,
293
- code: parsed.code,
294
- name: parsed.name,
295
- config: parsed.config ?? Protocol.CellConfigInput.parse({}),
301
+ id: input.id,
302
+ code: input.code,
303
+ name: input.name ?? Protocol.cellInputNameDefault,
304
+ config: {
305
+ column: input.config?.column ?? Protocol.cellConfigInputColumnDefault,
306
+ disabled:
307
+ input.config?.disabled ?? Protocol.cellConfigInputDisabledDefault,
308
+ hide_code:
309
+ input.config?.hide_code ?? Protocol.cellConfigInputHideCodeDefault,
310
+ expand_output:
311
+ input.config?.expand_output ??
312
+ Protocol.cellConfigInputExpandOutputDefault,
313
+ },
296
314
  };
297
315
  }
298
316
 
@@ -7,7 +7,7 @@ import {
7
7
  type WritableAtom,
8
8
  } from "jotai/vanilla";
9
9
  import type { Document } from "../replica";
10
- import * as Protocol from "@marimo-team/client/protocol";
10
+ import type * as Protocol from "@marimo-team/client/protocol";
11
11
  import {
12
12
  acknowledge,
13
13
  type CellEdit,
@@ -19,6 +19,7 @@ import {
19
19
  editCell,
20
20
  EMPTY_DRAFT,
21
21
  isEmptyDraft,
22
+ type NewCell,
22
23
  type Placement,
23
24
  prune,
24
25
  setOrder,
@@ -32,7 +33,7 @@ export interface DocumentEditor {
32
33
  setName(id: Protocol.CellId, name: string): void;
33
34
  updateConfig(id: Protocol.CellId, patch: Partial<Protocol.CellConfig>): void;
34
35
  /** Create a cell, or bring back one this draft deletes with this content. */
35
- createCell(cell: Protocol.CellInput, placement?: Placement): void;
36
+ createCell(cell: NewCell, placement?: Placement): void;
36
37
  deleteCell(id: Protocol.CellId): void;
37
38
  /** A permutation of the cells present at this point in the transaction. */
38
39
  setOrder(order: readonly Protocol.CellId[]): void;
@@ -351,11 +352,11 @@ function editDocument(
351
352
  const editor: DocumentEditor = {
352
353
  setCode: (id, code) => updateCell(id, { code }),
353
354
  setName: (id, name) => updateCell(id, { name }),
354
- updateConfig: (id, patch) =>
355
- updateCell(id, { config: Protocol.CellConfig.partial().parse(patch) }),
355
+ updateConfig: (id, config) => updateCell(id, { config }),
356
356
  createCell: (cell, placement = {}) => {
357
357
  assertActive();
358
- if (hasCell(cell.id)) {
358
+ const { id } = cell;
359
+ if (hasCell(id)) {
359
360
  throw new Error(`Cell ${cell.id} already exists`);
360
361
  }
361
362
  if (placement.after !== undefined && placement.before !== undefined) {
@@ -365,7 +366,7 @@ function editDocument(
365
366
  if (anchor !== undefined) {
366
367
  requireCell(anchor);
367
368
  }
368
- next = confirmed.cells.has(cell.id)
369
+ next = confirmed.cells.has(id)
369
370
  ? restoreCell(confirmed, next, cell, { ...placement }, sent)
370
371
  : createCell(next, cell, { ...placement });
371
372
  },
@@ -5,6 +5,10 @@ import type * as Protocol from "@marimo-team/client/protocol";
5
5
  import { document } from "../resources/document";
6
6
  import { createNotebookReducer } from "@marimo-team/client";
7
7
  import { fixtureEvents } from "./fixtures";
8
+ import { cellId } from "@/__tests__/branded";
9
+
10
+ const C3 = cellId("c3");
11
+ const FIXTURE_CELL = cellId("k7f2");
8
12
 
9
13
  const reducer = createNotebookReducer({ document });
10
14
  const snapshot = fixtureEvents("notebook-events.sse");
@@ -43,11 +47,11 @@ describe("document resource", () => {
43
47
  );
44
48
  const saved = current(reducer.reduce(changed, save));
45
49
  expect(saved?.revision).toEqual(save.data.document);
46
- expect(saved?.cells.get("c3")?.code).toBe("x = 22");
47
- expect(saved?.cells.has("k7f2")).toBe(false);
50
+ expect(saved?.cells.get(C3)?.code).toBe("x = 22");
51
+ expect(saved?.cells.has(FIXTURE_CELL)).toBe(false);
48
52
  expect(saved?.revision.saved_etag).toBe(saved?.revision.etag);
49
- expect(first?.cells.get("c3")?.code).toBe("x = 21");
50
- expect(first?.cells.has("k7f2")).toBe(true);
53
+ expect(first?.cells.get(C3)?.code).toBe("x = 21");
54
+ expect(first?.cells.has(FIXTURE_CELL)).toBe(true);
51
55
  });
52
56
 
53
57
  it("applies order-only changes and distinguishes an empty notebook from no document", () => {
@@ -117,7 +121,7 @@ describe("document resource", () => {
117
121
  expect(() =>
118
122
  reducer.reduce(state, {
119
123
  event: "document",
120
- data: { document: { ...revision, order: ["missing"] } },
124
+ data: { document: { ...revision, order: [cellId("missing")] } },
121
125
  id: "200",
122
126
  }),
123
127
  ).toThrow("Document records do not match");