@marimo-team/islands 0.25.3-dev170 → 0.25.3-dev175

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 (196) hide show
  1. package/dist/{ConnectedDataExplorerComponent-BbSXV-Xa.js → ConnectedDataExplorerComponent-Le_OBfmt.js} +9 -9
  2. package/dist/{ErrorBoundary-NE86qEWZ.js → ErrorBoundary-DNvcAIsP.js} +8 -8
  3. package/dist/{abnfDiagram-VCTEODGH-D7n07nXf.js → abnfDiagram-VCTEODGH-Tf1ghyQQ.js} +2 -2
  4. package/dist/{any-language-editor-3E24SnCV.js → any-language-editor-BVFHDDQ3.js} +4 -4
  5. package/dist/{architectureDiagram-5GKGNRK7-D6CjRib5.js → architectureDiagram-5GKGNRK7-xlnbTG0T.js} +1 -1
  6. package/dist/{chat-ui-CC7GekpG.js → chat-ui-X-cWrL9u.js} +1218 -1218
  7. package/dist/{check-SpOMoCLP.js → check-C9Mp9eCK.js} +1 -1
  8. package/dist/{chunk-IMKFNOWR-6dtPz7uS.js → chunk-IMKFNOWR-Cmd4a5jy.js} +1 -1
  9. package/dist/{chunk-SHT3W25Y-BwnFNKDA.js → chunk-SHT3W25Y-mSNp-WpO.js} +1 -1
  10. package/dist/{chunk-SVP7TREG-D2eV4vBJ.js → chunk-SVP7TREG-CWC49D8X.js} +1 -1
  11. package/dist/{chunk-TICWLB2K-BDs4-_-r.js → chunk-TICWLB2K-De9FINtG.js} +1 -1
  12. package/dist/{classDiagram-ZZMXUADV-DCJnf_8v.js → classDiagram-ZZMXUADV-DweTkYdp.js} +2 -2
  13. package/dist/{classDiagram-v2-VYDZK3BY-BOmSzPBD.js → classDiagram-v2-VYDZK3BY-A6MR2TiE.js} +2 -2
  14. package/dist/{code-visibility-Bzvc6ajl.js → code-visibility-CH1lmM1h.js} +5 -5
  15. package/dist/{common-Ciw4zkh2.js → common-DIrS1UR9.js} +1081 -1085
  16. package/dist/{copy-icon-C1trdvVt.js → copy-icon-De584pZ4.js} +2 -2
  17. package/dist/{cynefinDiagram-5FMLGOSQ-Bln_Soky.js → cynefinDiagram-5FMLGOSQ-BSvo5le-.js} +1 -1
  18. package/dist/{dagre-GXQ25YYZ-D-nf7WzW.js → dagre-GXQ25YYZ-tXRQslO6.js} +1 -1
  19. package/dist/{data-grid-overlay-editor-AQREmxI7.js → data-grid-overlay-editor-DFLZvFK0.js} +1 -1
  20. package/dist/{diagram-S7CK7UJ4-PsgSMkY2.js → diagram-S7CK7UJ4-r3t5VtwI.js} +1 -1
  21. package/dist/{diagram-UQ7AKVKN-DfwfUuSw.js → diagram-UQ7AKVKN-qgbC8YnT.js} +1 -1
  22. package/dist/{diagram-VX7I27RA-C9_e-oMc.js → diagram-VX7I27RA-CiHxEwtp.js} +1 -1
  23. package/dist/{diagram-Z3DM3KII-CWLa5tuY.js → diagram-Z3DM3KII-D95u15Ev.js} +1 -1
  24. package/dist/{dialog-DgeqyrEZ.js → dialog-DVRfQuhD.js} +24 -24
  25. package/dist/{dist-F8Ep36rk.js → dist-B1M0bGO3.js} +1 -1
  26. package/dist/{dist-D6d86eNJ.js → dist-BA13RJj5.js} +1 -1
  27. package/dist/{dist-Bvs24R_E.js → dist-BJtmSgcE.js} +48 -48
  28. package/dist/{dist-CN_BeG2I.js → dist-Ba2VIn1K.js} +53 -53
  29. package/dist/{dist-PXYI_yuP.js → dist-Bj4bmwUm.js} +12 -12
  30. package/dist/{dist-DoE4XJBC.js → dist-BmS-ZGjl.js} +8626 -8626
  31. package/dist/{dist-BorMD-uX.js → dist-Bzogh7CW.js} +87 -87
  32. package/dist/{dist-CN8zI-XC.js → dist-CThPVKaP.js} +1385 -1382
  33. package/dist/{dist-DiDibOYr.js → dist-CTi5FTiV.js} +87 -87
  34. package/dist/{dist-diIx5qJW.js → dist-Ck_C32ye.js} +2 -2
  35. package/dist/{dist-BLfKmR-l.js → dist-D1fnFp1J.js} +1 -1
  36. package/dist/{dist-OR1OnN-y.js → dist-D3x9__Fu.js} +46 -46
  37. package/dist/{dist-BMQf5zIS.js → dist-D7mrh5sO.js} +36 -36
  38. package/dist/{dist-CSJ0MDRw.js → dist-D9Q3xjiP.js} +1 -1
  39. package/dist/{dist-BuaRHxOc.js → dist-DP60Ubh8.js} +2 -2
  40. package/dist/{dist-CSbh1PNP.js → dist-DTv9KkpW.js} +12 -12
  41. package/dist/{dist-D-wwqlzJ.js → dist-DVVwOfrD.js} +109 -109
  42. package/dist/{dist-C8fAKSH1.js → dist-DYXM73-k.js} +36 -36
  43. package/dist/{dist-DBtSl3sf.js → dist-DjeybPOb.js} +1 -1
  44. package/dist/{dist-CrSP_H1M.js → dist-DtGn9N4h.js} +197 -197
  45. package/dist/{dist-CLdpGQVr.js → dist-KN80qWCP.js} +2 -2
  46. package/dist/{dist-Cg7gzw-a.js → dist-O0qFpEJh.js} +56 -56
  47. package/dist/{dist-CkTTIdBe.js → dist-OUle2RT7.js} +207 -207
  48. package/dist/{dist-BK4Oj99o.js → dist-T5rh6JvL.js} +1 -1
  49. package/dist/{dropdown-menu-B6ftyzOg.js → dropdown-menu-DCMbbQ35.js} +691 -691
  50. package/dist/{ebnfDiagram-PWID7BFC-B1QRM58v.js → ebnfDiagram-PWID7BFC-P7e4bryK.js} +2 -2
  51. package/dist/{erDiagram-RLTQ6QDP-DJK_FqvW.js → erDiagram-RLTQ6QDP-CUHZcmRj.js} +1 -1
  52. package/dist/{error-banner-D40pmfQQ.js → error-banner-DxJ3s8YO.js} +57 -57
  53. package/dist/{error-entries-DgK3wUJR.js → error-entries-mpoD5t79.js} +4985 -5006
  54. package/dist/{esm-D2gTsXEV.js → esm-Bbw_Njjx.js} +575 -575
  55. package/dist/{esm-AMFssoNp.js → esm-mDQNEFe_.js} +354 -354
  56. package/dist/{feedback-button-8a6SETmT.js → feedback-button-DL0DJ-LB.js} +30 -30
  57. package/dist/{flowDiagram-HODETNUW-Uxc25XSJ.js → flowDiagram-HODETNUW-BGZ95AzI.js} +2 -2
  58. package/dist/{formats-DQCyPd5Z.js → formats-DI7HEVv7.js} +1 -1
  59. package/dist/{glide-data-editor-B70oke_v.js → glide-data-editor-n4wnx19S.js} +10 -10
  60. package/dist/{glide-utils-Dz_F4pAY.js → glide-utils-D98laidb.js} +2 -2
  61. package/dist/{globals-Cxd5hNlI.js → globals-NCsYyjpB.js} +3 -3
  62. package/dist/{html-to-image-D4yG5Ru0.js → html-to-image-BoZthB4P.js} +467 -458
  63. package/dist/{infoDiagram-27XIBGKW-DmjxqwL0.js → infoDiagram-27XIBGKW-BF0YX70D.js} +1 -1
  64. package/dist/{ishikawaDiagram-5VMMS53U-NgCLHqQi.js → ishikawaDiagram-5VMMS53U-_itsAAn-.js} +1 -1
  65. package/dist/{kanban-definition-UXKFOSKX-CZaG-iam.js → kanban-definition-UXKFOSKX-VNW2Beqh.js} +1 -1
  66. package/dist/{label-D9_-zSg-.js → label-Qvw1E97W.js} +1 -1
  67. package/dist/main.js +8257 -6606
  68. package/dist/{mermaid-CSvw7c71.js → mermaid-CZ6FrClS.js} +35 -35
  69. package/dist/{mindmap-definition-YA3MSWOX-DJYQBDH_.js → mindmap-definition-YA3MSWOX-DR4ripvd.js} +1 -1
  70. package/dist/{number-overlay-editor-ChK-SKUk.js → number-overlay-editor-rlvo4mo3.js} +1 -1
  71. package/dist/{pegDiagram-XKGWAZYB-CHKO_dAe.js → pegDiagram-XKGWAZYB-CFr3XlGl.js} +2 -2
  72. package/dist/{pieDiagram-E7YTZNPT-DVevbMAo.js → pieDiagram-E7YTZNPT-j91XYSLY.js} +1 -1
  73. package/dist/{process-output-DxvBAeL3.js → process-output-DLS4Mqg_.js} +4 -4
  74. package/dist/{railroadDiagram-O6MQD6OU-Detj1kcB.js → railroadDiagram-O6MQD6OU-Cd47ZV9E.js} +2 -2
  75. package/dist/{requirementDiagram-BXWQKSXE-BLFD0T_Z.js → requirementDiagram-BXWQKSXE-eJH6gLtX.js} +1 -1
  76. package/dist/{reveal-component-CXMXeDZD.js → reveal-component-BJfmRUzb.js} +9 -9
  77. package/dist/{select-CkF_GBxO.js → select-2KOiReNY.js} +324 -324
  78. package/dist/{sequenceDiagram-WJ2MYXX4-BZBgatQV.js → sequenceDiagram-WJ2MYXX4-DdfFEIrm.js} +1 -1
  79. package/dist/{spec-Mnkn3XEr.js → spec-h69nC3SI.js} +4 -4
  80. package/dist/{stateDiagram-D77RDMKH-4BZW9-6_.js → stateDiagram-D77RDMKH-DkjDvip8.js} +2 -2
  81. package/dist/{stateDiagram-v2-MP3YSRHH-C4sKC8Iq.js → stateDiagram-v2-MP3YSRHH-DBHACnOo.js} +2 -2
  82. package/dist/{swimlanes-42K2YHIH-SL5yeGe2.js → swimlanes-42K2YHIH-ogImlOmp.js} +1 -1
  83. package/dist/{swimlanesDiagram-VR7AAH4N-DqPmAYUv.js → swimlanesDiagram-VR7AAH4N-D6x-zsci.js} +2 -2
  84. package/dist/{timeline-definition-24CTP7MA-BfXUMWkq.js → timeline-definition-24CTP7MA-DQpLtsHD.js} +1 -1
  85. package/dist/{toDate-TMubKIVL.js → toDate-CDzoofJo.js} +2 -2
  86. package/dist/{toast-Btbve3Lm.js → toast-B5t9o6s_.js} +47 -47
  87. package/dist/{tooltip-CJ4Rqasp.js → tooltip-s4zZxwKe.js} +67 -67
  88. package/dist/{use-restore-focus-CmGwRNId.js → use-restore-focus-BgDTd2tc.js} +1 -1
  89. package/dist/{useAsyncData-DjMGFzFy.js → useAsyncData-Bn8SxUqM.js} +1 -1
  90. package/dist/{useDateFormatter-eCL_SdeG.js → useDateFormatter-D3Tkfzej.js} +2 -2
  91. package/dist/{useDeepCompareMemoize-BQR5TJot.js → useDeepCompareMemoize-CC2tnPCk.js} +1 -1
  92. package/dist/{useLifecycle-C_GvKWbQ.js → useLifecycle-BJlxHqWa.js} +2 -2
  93. package/dist/{useTheme-Bns2gJZ6.js → useTheme-DMfQYmlG.js} +85 -85
  94. package/dist/{vega-component-BsVptuhz.js → vega-component-CovWHi60.js} +7 -7
  95. package/dist/{vennDiagram-4TSXK5OY-CH65znGa.js → vennDiagram-4TSXK5OY-BD-SL_vq.js} +1 -1
  96. package/dist/{wardleyDiagram-VM6X3IG4-z9pWKb2_.js → wardleyDiagram-VM6X3IG4-BDgJV4ah.js} +1 -1
  97. package/dist/{xychartDiagram-S5SC5T6Z-MxyaWjjq.js → xychartDiagram-S5SC5T6Z-1hIHN6Rl.js} +1 -1
  98. package/package.json +1 -1
  99. package/src/__mocks__/document.tsx +54 -0
  100. package/src/__mocks__/notebook.ts +2 -1
  101. package/src/__mocks__/requests.ts +0 -2
  102. package/src/components/chat/chat-panel.tsx +3 -3
  103. package/src/components/datasources/__tests__/column-preview.test.tsx +6 -8
  104. package/src/components/datasources/column-preview.tsx +4 -8
  105. package/src/components/datasources/datasources.tsx +4 -3
  106. package/src/components/dependency-graph/minimap-content.tsx +2 -6
  107. package/src/components/dependency-graph/panels.tsx +2 -1
  108. package/src/components/editor/__tests__/Output.test.tsx +50 -32
  109. package/src/components/editor/__tests__/data-attributes.test.tsx +22 -11
  110. package/src/components/editor/__tests__/output-persistence.test.tsx +6 -1
  111. package/src/components/editor/actions/__tests__/name-cell-input.test.tsx +69 -0
  112. package/src/components/editor/actions/name-cell-input.tsx +4 -3
  113. package/src/components/editor/actions/useCellActionButton.tsx +20 -26
  114. package/src/components/editor/actions/useNotebookActions.tsx +13 -18
  115. package/src/components/editor/actions/useSetCodeVisibility.ts +10 -11
  116. package/src/components/editor/actions/useSetOutputsExpanded.ts +13 -18
  117. package/src/components/editor/cell/CreateCellButton.tsx +5 -9
  118. package/src/components/editor/cell/__tests__/StagedAICell.test.tsx +3 -1
  119. package/src/components/editor/cell/code/cell-editor.tsx +13 -20
  120. package/src/components/editor/cell/useAddCell.ts +4 -8
  121. package/src/components/editor/cell/useDeleteCell.tsx +10 -36
  122. package/src/components/editor/cell/useRunCells.ts +2 -5
  123. package/src/components/editor/cell/useSplitCell.tsx +2 -1
  124. package/src/components/editor/chrome/panels/logs-panel.tsx +2 -1
  125. package/src/components/editor/chrome/panels/snippets-panel.tsx +5 -11
  126. package/src/components/editor/chrome/wrapper/__tests__/pending-ai-cells.test.tsx +3 -1
  127. package/src/components/editor/columns/sortable-column.tsx +1 -1
  128. package/src/components/editor/connections/components.tsx +4 -9
  129. package/src/components/editor/controls/Controls.tsx +1 -1
  130. package/src/components/editor/controls/__tests__/notebook-menu-dropdown.test.tsx +9 -3
  131. package/src/components/editor/documentation.css +34 -11
  132. package/src/components/editor/errors/auto-fix.tsx +4 -8
  133. package/src/components/editor/file-tree/file-explorer.tsx +3 -7
  134. package/src/components/editor/links/__tests__/cell-link.test.tsx +3 -1
  135. package/src/components/editor/links/cell-link.tsx +2 -1
  136. package/src/components/editor/navigation/__tests__/clipboard.test.ts +60 -38
  137. package/src/components/editor/navigation/__tests__/navigation.test.ts +73 -64
  138. package/src/components/editor/navigation/clipboard.ts +12 -11
  139. package/src/components/editor/navigation/multi-cell-action-toolbar.tsx +11 -20
  140. package/src/components/editor/navigation/navigation.ts +20 -28
  141. package/src/components/editor/notebook-cell.tsx +7 -10
  142. package/src/components/editor/output/console/__tests__/ConsoleOutput.test.tsx +125 -69
  143. package/src/components/editor/renderers/cell-array.tsx +10 -17
  144. package/src/components/markdown/markdown-renderer.tsx +4 -8
  145. package/src/components/pages/edit-page.tsx +32 -17
  146. package/src/components/scratchpad/scratchpad.test.tsx +3 -1
  147. package/src/components/scratchpad/scratchpad.tsx +4 -7
  148. package/src/components/slides/__tests__/minimap-actions.test.tsx +9 -25
  149. package/src/components/slides/minimap.tsx +7 -3
  150. package/src/components/slides/slide-cell-view.tsx +3 -3
  151. package/src/components/sort/SortableCellsProvider.tsx +2 -1
  152. package/src/core/ai/__tests__/staged-cells.test.ts +18 -20
  153. package/src/core/ai/staged-cells.ts +8 -16
  154. package/src/core/ai/tools/__tests__/edit-notebook-tool.test.ts +2 -2
  155. package/src/core/ai/tools/__tests__/run-cells-tool.test.ts +2 -2
  156. package/src/core/ai/tools/base.ts +2 -2
  157. package/src/core/ai/tools/edit-notebook-tool.ts +13 -21
  158. package/src/core/cells/__tests__/actions.test.ts +474 -34
  159. package/src/core/cells/__tests__/add-missing-import.test.ts +7 -8
  160. package/src/core/cells/__tests__/cells.test.ts +251 -861
  161. package/src/core/cells/__tests__/document.test.ts +42 -38
  162. package/src/core/cells/__tests__/notebook-outline.test.ts +7 -1
  163. package/src/core/cells/__tests__/outputs.test.tsx +71 -53
  164. package/src/core/cells/actions.ts +391 -3
  165. package/src/core/cells/add-missing-import.ts +46 -42
  166. package/src/core/cells/cells.ts +73 -444
  167. package/src/core/cells/document.ts +38 -6
  168. package/src/core/cells/outputs.ts +12 -28
  169. package/src/core/codemirror/cells/extensions.ts +6 -6
  170. package/src/core/codemirror/cells/state.ts +1 -1
  171. package/src/core/codemirror/keymaps/vim.ts +2 -2
  172. package/src/core/edit-app.tsx +20 -25
  173. package/src/core/islands/__tests__/bootstrap.test.ts +56 -0
  174. package/src/core/islands/__tests__/bridge.test.ts +42 -0
  175. package/src/core/islands/bootstrap.ts +24 -1
  176. package/src/core/islands/bridge.ts +46 -5
  177. package/src/core/kernel/__tests__/handlers.test.ts +7 -153
  178. package/src/core/kernel/handlers.ts +18 -59
  179. package/src/core/network/__tests__/requests-lazy.test.ts +1 -3
  180. package/src/core/network/requests-lazy.ts +0 -2
  181. package/src/core/network/requests-network.ts +0 -16
  182. package/src/core/network/requests-static.ts +0 -2
  183. package/src/core/network/requests-toasting.tsx +0 -2
  184. package/src/core/network/types.ts +0 -7
  185. package/src/core/notebook/document/__tests__/codemirror.test.ts +5 -0
  186. package/src/core/notebook/document/__tests__/draft.test.ts +41 -0
  187. package/src/core/notebook/document/__tests__/state.test.ts +21 -0
  188. package/src/core/notebook/document/draft.ts +35 -5
  189. package/src/core/notebook/document/index.ts +1 -0
  190. package/src/core/notebook/document/state.ts +6 -2
  191. package/src/core/run-app.tsx +1 -7
  192. package/src/core/session/__tests__/useNotebookSession.hook.test.tsx +0 -6
  193. package/src/core/session/useNotebookSession.tsx +28 -35
  194. package/src/core/wasm/bridge.ts +0 -16
  195. package/src/css/globals.css +56 -22
  196. package/src/stories/runtime-story.tsx +22 -15
@@ -21,7 +21,7 @@ const { stagedGenerationAtom, createActions, reducer, initialState } =
21
21
  visibleForTesting;
22
22
 
23
23
  // Mock the dependencies
24
- const mockCreateNewCell = vi.fn();
24
+ const mockCreateCell = vi.fn();
25
25
  const mockUpdateCellCode = vi.fn();
26
26
  const mockDeleteCellCallback = vi.fn();
27
27
 
@@ -34,14 +34,16 @@ const mockCellHandle = {
34
34
  },
35
35
  };
36
36
 
37
+ vi.mock("../../cells/actions", () => ({
38
+ useCellActions: () => ({
39
+ createCell: mockCreateCell,
40
+ updateCellCode: mockUpdateCellCode,
41
+ }),
42
+ }));
37
43
  vi.mock("../../cells/cells", async () => {
38
44
  const { atom } = await import("jotai");
39
45
  return {
40
46
  notebookAtom: atom({ cellData: {}, cellIds: { inOrderIds: [] } }),
41
- useCellActions: () => ({
42
- createNewCell: mockCreateNewCell,
43
- updateCellCode: mockUpdateCellCode,
44
- }),
45
47
  cellHandleAtom: vi.fn(() => ({
46
48
  read: vi.fn(() => mockCellHandle),
47
49
  })),
@@ -261,11 +263,9 @@ describe("staged-cells", () => {
261
263
  const returnedCellId = result.current.createStagedCell(testCode);
262
264
 
263
265
  expect(returnedCellId).toBe(mockCellId);
264
- expect(mockCreateNewCell).toHaveBeenCalledWith({
265
- cellId: "__end__",
266
+ expect(mockCreateCell).toHaveBeenCalledWith({
266
267
  code: testCode,
267
- before: false,
268
- newCellId: mockCellId,
268
+ id: mockCellId,
269
269
  });
270
270
  });
271
271
 
@@ -330,7 +330,7 @@ describe("staged-cells", () => {
330
330
 
331
331
  // Verify it was created and added
332
332
  expect(createdCellId).toBe(mockCellId);
333
- expect(mockCreateNewCell).toHaveBeenCalled();
333
+ expect(mockCreateCell).toHaveBeenCalled();
334
334
 
335
335
  let state = store.get(stagedAICellsAtom);
336
336
  expect(state.has(mockCellId)).toBe(true);
@@ -401,7 +401,7 @@ describe("staged cell generation", () => {
401
401
  result.current.beginStagedCellGeneration();
402
402
 
403
403
  // No cell or cell update should have been called
404
- expect(mockCreateNewCell).not.toHaveBeenCalled();
404
+ expect(mockCreateCell).not.toHaveBeenCalled();
405
405
  expect(prepareCellCodeUpdate).not.toHaveBeenCalled();
406
406
  expect(store.get(stagedGenerationInProgressAtom)).toBe(true);
407
407
  });
@@ -610,11 +610,9 @@ describe("staged cell generation", () => {
610
610
  },
611
611
  });
612
612
 
613
- expect(mockCreateNewCell).toHaveBeenCalledWith({
614
- cellId: "__end__",
613
+ expect(mockCreateCell).toHaveBeenCalledWith({
615
614
  code: "print('```')",
616
- before: false,
617
- newCellId: "mock-cell-id",
615
+ id: "mock-cell-id",
618
616
  });
619
617
  });
620
618
 
@@ -636,16 +634,16 @@ describe("staged cell generation", () => {
636
634
  },
637
635
  });
638
636
 
639
- expect(mockCreateNewCell).toHaveBeenCalledWith(
637
+ expect(mockCreateCell).toHaveBeenCalledWith(
640
638
  expect.objectContaining({
641
639
  code: "value = 1",
642
- newCellId: "first-cell",
640
+ id: "first-cell",
643
641
  }),
644
642
  );
645
- expect(mockCreateNewCell).toHaveBeenCalledWith(
643
+ expect(mockCreateCell).toHaveBeenCalledWith(
646
644
  expect.objectContaining({
647
645
  code: "value",
648
- newCellId: "second-cell",
646
+ id: "second-cell",
649
647
  }),
650
648
  );
651
649
  });
@@ -683,7 +681,7 @@ describe("staged cell generation", () => {
683
681
  },
684
682
  });
685
683
 
686
- expect(mockCreateNewCell).toHaveBeenCalledTimes(2);
684
+ expect(mockCreateCell).toHaveBeenCalledTimes(2);
687
685
  expect(store.get(stagedAICellsAtom).has(cellId("first-cell"))).toBe(true);
688
686
  expect(store.get(stagedAICellsAtom).has(cellId("second-cell"))).toBe(true);
689
687
  expect(prepareCellCodeUpdate).toHaveBeenCalledTimes(2);
@@ -14,11 +14,8 @@ import {
14
14
  notebookCellsCompletionSchema,
15
15
  } from "./completion-output";
16
16
  import { maybeAddMarimoImport } from "../cells/add-missing-import";
17
- import {
18
- type CreateNewCellAction,
19
- getCellEditorView,
20
- useCellActions,
21
- } from "../cells/cells";
17
+ import { getCellEditorView } from "../cells/cells";
18
+ import { type CreateCell, useCellActions } from "../cells/actions";
22
19
  import { prepareCellCodeUpdate } from "../codemirror/language/cell-code";
23
20
  import type { JotaiStore } from "../state/jotai";
24
21
  import type { EditType } from "./tools/edit-notebook-tool";
@@ -98,18 +95,13 @@ interface UpdateStagedCellAction {
98
95
  /** Manage staged cells without assuming which AI workflow owns them. */
99
96
  export function useStagedCells(store: JotaiStore) {
100
97
  const { addStagedCell, removeStagedCell } = useStagedAICellsActions();
101
- const { createNewCell, updateCellCode } = useCellActions();
98
+ const { updateCellCode, createCell } = useCellActions();
102
99
  const deleteCellCallback = useDeleteCellCallback();
103
100
 
104
101
  const createStagedCell = (code: string): CellId => {
105
102
  const newCellId = CellId.create();
106
103
  addStagedCell({ cellId: newCellId, edit: { type: "add_cell" } });
107
- createNewCell({
108
- cellId: "__end__",
109
- code,
110
- before: false,
111
- newCellId: newCellId,
112
- });
104
+ createCell({ code, id: newCellId });
113
105
  return newCellId;
114
106
  };
115
107
 
@@ -152,7 +144,7 @@ export function useStagedCells(store: JotaiStore) {
152
144
  /** Owns the lifecycle of cells created by one structured completion flow. */
153
145
  export function useStagedCellGeneration(store: JotaiStore) {
154
146
  const stagedCellActions = useStagedCells(store);
155
- const { createNewCell } = useCellActions();
147
+ const { createCell } = useCellActions();
156
148
  const ownedGeneration = useRef<OwnedStagedGeneration | null>(null);
157
149
  // Ownership lives in a ref, so subscribe to its backing atoms to rerender
158
150
  // consumers when completion or per-cell acceptance changes.
@@ -180,7 +172,7 @@ export function useStagedCellGeneration(store: JotaiStore) {
180
172
  status: "in_progress",
181
173
  reconciler: new StagedCellReconciler({
182
174
  ...stagedCellActions,
183
- createNewCell,
175
+ createCell,
184
176
  }),
185
177
  };
186
178
  store.set(stagedGenerationAtom, {
@@ -302,7 +294,7 @@ interface StagedCellReconcilerActions {
302
294
  deleteStagedCell: (cellId: CellId) => void;
303
295
  removeStagedCell: (cellId: CellId) => void;
304
296
  addStagedCell: (payload: { cellId: CellId; edit: Edit }) => void;
305
- createNewCell: (opts: CreateNewCellAction) => void;
297
+ createCell: CreateCell;
306
298
  }
307
299
 
308
300
  class StagedCellReconciler {
@@ -391,7 +383,7 @@ class StagedCellReconciler {
391
383
 
392
384
  const cellId = maybeAddMarimoImport({
393
385
  autoInstantiate: false,
394
- createNewCell: this.actions.createNewCell,
386
+ createCell: this.actions.createCell,
395
387
  fromCellId: this.createdCells[0]?.cellId,
396
388
  before: true,
397
389
  });
@@ -64,7 +64,7 @@ describe("EditNotebookTool", () => {
64
64
  let cellId3: CellId;
65
65
  let toolContext: {
66
66
  addStagedCell: ReturnType<typeof vi.fn>;
67
- createNewCell: ReturnType<typeof vi.fn>;
67
+ createCell: ReturnType<typeof vi.fn>;
68
68
  prepareForRun: ReturnType<typeof vi.fn>;
69
69
  sendRun: ReturnType<typeof vi.fn>;
70
70
  store: ReturnType<typeof getDefaultStore>;
@@ -81,7 +81,7 @@ describe("EditNotebookTool", () => {
81
81
  const current = store.get(stagedAICellsAtom);
82
82
  store.set(stagedAICellsAtom, new Map(current).set(cellId, edit));
83
83
  }),
84
- createNewCell: vi.fn(),
84
+ createCell: vi.fn(),
85
85
  prepareForRun: vi.fn(),
86
86
  sendRun: vi.fn().mockResolvedValue(null),
87
87
  store,
@@ -29,7 +29,7 @@ describe("RunStaleCellsTool", () => {
29
29
  let cellId3: CellId;
30
30
  let toolContext: {
31
31
  addStagedCell: ReturnType<typeof vi.fn>;
32
- createNewCell: ReturnType<typeof vi.fn>;
32
+ createCell: ReturnType<typeof vi.fn>;
33
33
  prepareForRun: ReturnType<typeof vi.fn>;
34
34
  sendRun: ReturnType<typeof vi.fn>;
35
35
  store: ReturnType<typeof getDefaultStore>;
@@ -39,7 +39,7 @@ describe("RunStaleCellsTool", () => {
39
39
  store = getDefaultStore();
40
40
  toolContext = {
41
41
  addStagedCell: vi.fn(),
42
- createNewCell: vi.fn(),
42
+ createCell: vi.fn(),
43
43
  prepareForRun: vi.fn(),
44
44
  sendRun: vi.fn().mockResolvedValue(null),
45
45
  store,
@@ -1,7 +1,7 @@
1
1
  /* Copyright 2026 Marimo. All rights reserved. */
2
2
 
3
3
  import { z } from "zod";
4
- import type { CreateNewCellAction } from "@/core/cells/cells";
4
+ import type { CreateCell } from "@/core/cells/actions";
5
5
  import type { CellId } from "@/core/cells/ids";
6
6
  import type { ExecuteCellsRequest } from "@/core/network/types";
7
7
  import type { JotaiStore } from "@/core/state/jotai";
@@ -113,7 +113,7 @@ export interface ToolDescription {
113
113
  export interface ToolNotebookContext {
114
114
  store: JotaiStore;
115
115
  addStagedCell: (payload: { cellId: CellId; edit: Edit }) => void;
116
- createNewCell: (payload: CreateNewCellAction) => void;
116
+ createCell: CreateCell;
117
117
  prepareForRun: (payload: { cellId: CellId }) => void;
118
118
  sendRun: (request: ExecuteCellsRequest) => Promise<null>;
119
119
  }
@@ -3,11 +3,8 @@
3
3
  import type { EditorView } from "@codemirror/view";
4
4
  import { z } from "zod";
5
5
  import { scrollAndHighlightCell } from "@/components/editor/links/cell-link";
6
- import {
7
- type CellPosition as NotebookCellPosition,
8
- type NotebookState,
9
- notebookAtom,
10
- } from "@/core/cells/cells";
6
+ import { type NotebookState, notebookAtom } from "@/core/cells/cells";
7
+ import type { CreateCellOptions } from "@/core/cells/actions";
11
8
  import { CellId } from "@/core/cells/ids";
12
9
  import { prepareCellCodeUpdate } from "@/core/codemirror/language/cell-code";
13
10
  import type { CellColumnId } from "@/utils/id-tree";
@@ -86,7 +83,7 @@ export class EditNotebookTool implements AiTool<
86
83
  { edit }: EditNotebookInput,
87
84
  toolContext: ToolNotebookContext,
88
85
  ): Promise<ToolOutputBase> => {
89
- const { addStagedCell, createNewCell, store } = toolContext;
86
+ const { addStagedCell, createCell, store } = toolContext;
90
87
 
91
88
  switch (edit.type) {
92
89
  case "update_cell": {
@@ -155,8 +152,7 @@ export class EditNotebookTool implements AiTool<
155
152
  case "add_cell": {
156
153
  const { position, code } = edit;
157
154
 
158
- let notebookPosition: NotebookCellPosition = "__end__";
159
- let before = false;
155
+ let placement: CreateCellOptions = {};
160
156
  const newCellId = CellId.create();
161
157
  const notebook = store.get(notebookAtom);
162
158
 
@@ -186,11 +182,12 @@ export class EditNotebookTool implements AiTool<
186
182
  }
187
183
 
188
184
  this.validateCellIdExists(cellId, notebook);
189
- notebookPosition = cellId;
190
- before = position.before;
185
+ placement = position.before
186
+ ? { before: cellId }
187
+ : { after: cellId };
191
188
  break;
192
189
  }
193
- case "column_end": {
190
+ case "column_end":
194
191
  if (!position.columnIndex) {
195
192
  throw new ToolExecutionError(
196
193
  "Column index is required for add_cell with column_end position",
@@ -203,21 +200,16 @@ export class EditNotebookTool implements AiTool<
203
200
  );
204
201
  }
205
202
 
206
- const columnId = this.getColumnId(position.columnIndex, notebook);
207
- notebookPosition = { type: "__end__", columnId };
203
+ placement = {
204
+ endOf: this.getColumnId(position.columnIndex, notebook),
205
+ };
208
206
  break;
209
- }
207
+
210
208
  case "notebook_end":
211
- // Use default: notebookPosition = "__end__"
212
209
  break;
213
210
  }
214
211
 
215
- createNewCell({
216
- cellId: notebookPosition,
217
- before,
218
- code,
219
- newCellId,
220
- });
212
+ createCell({ ...placement, code, id: newCellId });
221
213
 
222
214
  addStagedCell({
223
215
  cellId: newCellId,