@marimo-team/islands 0.25.3-dev388 → 0.25.3-dev394

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 (166) hide show
  1. package/dist/{ConnectedDataExplorerComponent-BpCrAeX0.js → ConnectedDataExplorerComponent-1DGGwl88.js} +9 -9
  2. package/dist/{ErrorBoundary-_mFP3LkM.js → ErrorBoundary-DDIASniH.js} +6 -6
  3. package/dist/{abnfDiagram-VCTEODGH-ZqNgGZlz.js → abnfDiagram-VCTEODGH-CeQEbVik.js} +2 -2
  4. package/dist/{any-language-editor-CFbAr7vc.js → any-language-editor-C_s_ZoaK.js} +2 -2
  5. package/dist/{architectureDiagram-5GKGNRK7-BEUaR96d.js → architectureDiagram-5GKGNRK7-C8xUpTAb.js} +1 -1
  6. package/dist/{assertNever-5uYEbJc8.js → assertNever-DXGfUmPW.js} +2 -2
  7. package/dist/assets/__vite-browser-external-C9HF3uHE.js +1 -0
  8. package/dist/assets/worker-B4Cpvr8b.js +171 -0
  9. package/dist/{chat-ui-BKSYhGMh.js → chat-ui-B6bY_0LF.js} +774 -774
  10. package/dist/{check-BbhVyViy.js → check-ywinAQy6.js} +1 -1
  11. package/dist/{chunk-IMKFNOWR-BdEPmWQI.js → chunk-IMKFNOWR-DY7AWyNi.js} +1 -1
  12. package/dist/{chunk-SHT3W25Y-IvvXM3xf.js → chunk-SHT3W25Y-D4epY9MY.js} +1 -1
  13. package/dist/{chunk-SVP7TREG-C_qpJUv1.js → chunk-SVP7TREG-CKsl2Q6r.js} +1 -1
  14. package/dist/{chunk-TICWLB2K-C4agYVWP.js → chunk-TICWLB2K-CMsD2y0F.js} +1 -1
  15. package/dist/{classDiagram-ZZMXUADV-CT2iq8uF.js → classDiagram-ZZMXUADV-C4FsLnvt.js} +2 -2
  16. package/dist/{classDiagram-v2-VYDZK3BY-Coe_dD0r.js → classDiagram-v2-VYDZK3BY-BJRuFZeI.js} +2 -2
  17. package/dist/{code-visibility-DkMNjdNe.js → code-visibility-CByYqwFv.js} +13 -13
  18. package/dist/{common-Ces9ooG_.js → common-KkgATX2Y.js} +4918 -4910
  19. package/dist/{config-DJ8M-gPL.js → config-DOwBtRkI.js} +3 -3
  20. package/dist/{copy-icon-xWvA8ybp.js → copy-icon-BKcX0ltw.js} +2 -2
  21. package/dist/{createReducer-fp0gX_9U.js → createReducer-Bjx6kuxh.js} +1 -1
  22. package/dist/{cynefinDiagram-5FMLGOSQ-D0LKziUu.js → cynefinDiagram-5FMLGOSQ-DyI_lSsn.js} +1 -1
  23. package/dist/{dagre-GXQ25YYZ-Cmgziaw8.js → dagre-GXQ25YYZ-Buoy6sX-.js} +1 -1
  24. package/dist/{data-grid-overlay-editor-uNMslVKY.js → data-grid-overlay-editor-BHrTJhN3.js} +1 -1
  25. package/dist/{diagram-S7CK7UJ4-D-lZsALU.js → diagram-S7CK7UJ4-CbSD1DUy.js} +1 -1
  26. package/dist/{diagram-UQ7AKVKN-TcbdsFoT.js → diagram-UQ7AKVKN-Dapj2rQm.js} +1 -1
  27. package/dist/{diagram-VX7I27RA-D5BqZi1q.js → diagram-VX7I27RA-CxA3txtC.js} +1 -1
  28. package/dist/{diagram-Z3DM3KII-MNc7jqvr.js → diagram-Z3DM3KII-BEZqz916.js} +1 -1
  29. package/dist/{dialog-Cm0VGdxc.js → dialog-mwa6XN15.js} +2 -2
  30. package/dist/{dropdown-menu-DfamXjVI.js → dropdown-menu-CmgUseHo.js} +5 -5
  31. package/dist/duckdb-keywords-CdzX4o33.js +3 -0
  32. package/dist/{ebnfDiagram-PWID7BFC-Cxt6ywyX.js → ebnfDiagram-PWID7BFC-Dmw-1JV3.js} +2 -2
  33. package/dist/{erDiagram-RLTQ6QDP-BLF-askI.js → erDiagram-RLTQ6QDP-DZpG4cbm.js} +1 -1
  34. package/dist/{error-banner-k06CAftu.js → error-banner-CHPLqogX.js} +1 -1
  35. package/dist/{error-entries-rtPWQkJk.js → error-entries-Bk96zt4w.js} +825 -690
  36. package/dist/{feedback-button-i960qUnq.js → feedback-button-2FaWjlaR.js} +12 -12
  37. package/dist/{flowDiagram-HODETNUW-CsLw2mWn.js → flowDiagram-HODETNUW-B02oHnBv.js} +2 -2
  38. package/dist/{formats-DQ-qq-dU.js → formats-BDqe9cfr.js} +1 -1
  39. package/dist/{glide-data-editor-_EEhlGzS.js → glide-data-editor-B9Yq6Wg1.js} +11 -11
  40. package/dist/{glide-utils-CHrghEu-.js → glide-utils-DYKWS2YV.js} +2 -2
  41. package/dist/{globals-DKkjIolp.js → globals-S4D5AVKN.js} +3 -3
  42. package/dist/{html-to-image-B5nTOeMI.js → html-to-image-BauFF9F_.js} +4842 -4821
  43. package/dist/{infoDiagram-27XIBGKW-CdSApBWg.js → infoDiagram-27XIBGKW-BPbQHO9m.js} +1 -1
  44. package/dist/{ishikawaDiagram-5VMMS53U-BnzQ8SI5.js → ishikawaDiagram-5VMMS53U-DmnKSNi7.js} +1 -1
  45. package/dist/{kanban-definition-UXKFOSKX-D2llTpeX.js → kanban-definition-UXKFOSKX-u5PZbsBe.js} +1 -1
  46. package/dist/main.js +6236 -6175
  47. package/dist/{mermaid-BcNMyKmf.js → mermaid-ffopDjig.js} +34 -34
  48. package/dist/{mindmap-definition-YA3MSWOX-uoEsfD5R.js → mindmap-definition-YA3MSWOX-CX187lhP.js} +1 -1
  49. package/dist/{number-overlay-editor-D5U7jbrh.js → number-overlay-editor-l7DB2HCO.js} +1 -1
  50. package/dist/{pegDiagram-XKGWAZYB-DTWrE0S4.js → pegDiagram-XKGWAZYB-Bj6HGPak.js} +2 -2
  51. package/dist/{pencil-weySvN0N.js → pencil-CijoRsa3.js} +1 -1
  52. package/dist/{pieDiagram-E7YTZNPT-COME2oGN.js → pieDiagram-E7YTZNPT-C_wIgDJM.js} +1 -1
  53. package/dist/{process-output-DNxpsd4n.js → process-output-Deae7dX1.js} +4 -4
  54. package/dist/{railroadDiagram-O6MQD6OU-CUeFcNTY.js → railroadDiagram-O6MQD6OU-CwoJvnvC.js} +2 -2
  55. package/dist/{requirementDiagram-BXWQKSXE-BUR4lDZG.js → requirementDiagram-BXWQKSXE-C8JuhLLL.js} +1 -1
  56. package/dist/{reveal-component-BM9TozVQ.js → reveal-component-VR4UzAUv.js} +37 -37
  57. package/dist/{select-Ca-POp4c.js → select-DW32QOzC.js} +4 -4
  58. package/dist/{sequenceDiagram-WJ2MYXX4-CSPmml3q.js → sequenceDiagram-WJ2MYXX4-RbrRdoiV.js} +1 -1
  59. package/dist/{spec-BgSMwzks.js → spec-Ww0JjShW.js} +4 -4
  60. package/dist/{stateDiagram-D77RDMKH-BDUC8Pi9.js → stateDiagram-D77RDMKH-DWdIvCnU.js} +2 -2
  61. package/dist/{stateDiagram-v2-MP3YSRHH-BH-qyk8a.js → stateDiagram-v2-MP3YSRHH-BG0j9crW.js} +2 -2
  62. package/dist/{static-state-Cqzv5X7B.js → static-state-CnQdTBTW.js} +1 -1
  63. package/dist/style.css +1 -1
  64. package/dist/{swimlanes-42K2YHIH-CLE9Kiir.js → swimlanes-42K2YHIH-B6zUw4gq.js} +1 -1
  65. package/dist/{swimlanesDiagram-VR7AAH4N-Cv8kWAeA.js → swimlanesDiagram-VR7AAH4N-DjVEnsIG.js} +2 -2
  66. package/dist/{timeline-definition-24CTP7MA-fbRGX21i.js → timeline-definition-24CTP7MA-DSAxwqnC.js} +1 -1
  67. package/dist/{toast-0xspcdmv.js → toast-Crofa36R.js} +3 -3
  68. package/dist/{tooltip-BwlFTaNy.js → tooltip-Bg-SDCwa.js} +1 -1
  69. package/dist/{use-restore-focus-fKgXR0nb.js → use-restore-focus-CE9Sflmg.js} +1298 -1283
  70. package/dist/{useDateFormatter-B7LvPmsw.js → useDateFormatter-D5fsC9ot.js} +2 -2
  71. package/dist/{useDeepCompareMemoize-OhBYt-q2.js → useDeepCompareMemoize-Bvrue1iy.js} +1 -1
  72. package/dist/{useLifecycle-D9xcFAIN.js → useLifecycle-Ctr5lECo.js} +1 -1
  73. package/dist/{vega-component-Chak9Aon.js → vega-component-DQZhTzVQ.js} +6 -6
  74. package/dist/{vennDiagram-4TSXK5OY-BzKtg8gL.js → vennDiagram-4TSXK5OY-FAGYRdBj.js} +1 -1
  75. package/dist/{wardleyDiagram-VM6X3IG4-R0SgDvz1.js → wardleyDiagram-VM6X3IG4-BlB973r1.js} +1 -1
  76. package/dist/{xychartDiagram-S5SC5T6Z-DRskTHEM.js → xychartDiagram-S5SC5T6Z-CywvmjIK.js} +1 -1
  77. package/package.json +2 -2
  78. package/src/__mocks__/executions.ts +48 -8
  79. package/src/__mocks__/notebook.ts +20 -42
  80. package/src/components/app-config/__tests__/add-model-discovery.test.tsx +255 -0
  81. package/src/components/app-config/__tests__/model-discovery.test.tsx +183 -0
  82. package/src/components/app-config/ai-config.tsx +20 -24
  83. package/src/components/app-config/model-discovery.tsx +118 -184
  84. package/src/components/app-config/model-provider-config.ts +25 -0
  85. package/src/components/editor/Output.tsx +5 -4
  86. package/src/components/editor/__tests__/data-attributes.test.tsx +1 -6
  87. package/src/components/editor/__tests__/dynamic-favicon.test.tsx +11 -16
  88. package/src/components/editor/__tests__/output-persistence.test.tsx +6 -24
  89. package/src/components/editor/actions/__tests__/useSetOutputsExpanded.test.ts +6 -8
  90. package/src/components/editor/actions/useSetOutputsExpanded.ts +12 -4
  91. package/src/components/editor/cell/cell-context-menu.tsx +3 -2
  92. package/src/components/editor/errors/__tests__/send-error-report-button.test.tsx +89 -72
  93. package/src/components/editor/notebook-cell.tsx +15 -10
  94. package/src/components/editor/output/console/process-output.ts +4 -2
  95. package/src/components/editor/renderers/cells-renderer.tsx +3 -1
  96. package/src/components/editor/renderers/grid-layout/__tests__/grid-layout.test.tsx +5 -11
  97. package/src/components/editor/renderers/grid-layout/grid-layout.tsx +9 -8
  98. package/src/components/editor/renderers/types.ts +2 -2
  99. package/src/components/editor/renderers/vertical-layout/utils.ts +4 -4
  100. package/src/components/editor/renderers/vertical-layout/vertical-layout.tsx +5 -8
  101. package/src/components/scratchpad/scratchpad.tsx +6 -2
  102. package/src/components/slides/__tests__/cell-output-block.test.tsx +7 -8
  103. package/src/components/slides/__tests__/minimap-actions.test.tsx +3 -3
  104. package/src/components/slides/__tests__/slide-cell-view.test.tsx +1 -0
  105. package/src/components/slides/slide-cell-view.tsx +1 -3
  106. package/src/components/slides/slide.tsx +3 -3
  107. package/src/core/ai/context/__tests__/registry.test.ts +7 -11
  108. package/src/core/ai/context/providers/__tests__/cell-output.test.ts +113 -35
  109. package/src/core/ai/context/providers/__tests__/error.test.ts +74 -191
  110. package/src/core/ai/context/providers/cell-output.ts +11 -6
  111. package/src/core/cells/__tests__/__snapshots__/cells.test.ts.snap +8 -103
  112. package/src/core/cells/__tests__/cells.test.ts +40 -292
  113. package/src/core/cells/__tests__/clear-outputs.test.ts +151 -0
  114. package/src/core/cells/__tests__/harness.ts +14 -12
  115. package/src/core/cells/__tests__/layout.test.ts +20 -26
  116. package/src/core/cells/__tests__/notebook-outline.test.ts +49 -43
  117. package/src/core/cells/__tests__/session.test.ts +26 -146
  118. package/src/core/cells/actions.ts +49 -9
  119. package/src/core/cells/cell.ts +0 -13
  120. package/src/core/cells/cells.ts +53 -62
  121. package/src/core/cells/focus.ts +6 -1
  122. package/src/core/cells/layout.ts +2 -3
  123. package/src/core/cells/outputs.ts +2 -2
  124. package/src/core/cells/session.ts +3 -38
  125. package/src/core/cells/types.ts +6 -8
  126. package/src/core/cells/utils.ts +4 -3
  127. package/src/core/codemirror/ai/__tests__/resources.test.ts +7 -11
  128. package/src/core/config/config-schema.ts +15 -0
  129. package/src/core/errors/__tests__/error-entries.test.ts +52 -18
  130. package/src/core/errors/error-entries.ts +21 -11
  131. package/src/core/executions/__tests__/freshness.test.ts +7 -4
  132. package/src/core/executions/__tests__/hooks.test.tsx +5 -1
  133. package/src/core/executions/__tests__/interrupt.test.ts +2 -0
  134. package/src/core/executions/__tests__/output-lifecycle.test.ts +201 -0
  135. package/src/core/executions/__tests__/output.test.ts +87 -3
  136. package/src/core/executions/__tests__/select.test.ts +17 -10
  137. package/src/core/executions/atoms.ts +73 -15
  138. package/src/core/executions/freshness.ts +1 -1
  139. package/src/core/executions/hooks.ts +18 -8
  140. package/src/core/executions/index.ts +6 -0
  141. package/src/core/executions/output.ts +122 -38
  142. package/src/core/executions/select.ts +2 -2
  143. package/src/core/export/__tests__/hooks.test.ts +20 -29
  144. package/src/core/export/hooks.ts +7 -9
  145. package/src/core/islands/__tests__/iframe-resizer.test.ts +91 -0
  146. package/src/core/islands/__tests__/main.test.ts +17 -0
  147. package/src/core/islands/components/__tests__/web-components.test.tsx +13 -15
  148. package/src/core/islands/components/output-wrapper.tsx +15 -20
  149. package/src/core/islands/iframe-resizer.ts +38 -0
  150. package/src/core/islands/main.ts +3 -0
  151. package/src/core/lifecycle/render-policy.ts +7 -4
  152. package/src/core/network/__tests__/ai.test.ts +41 -0
  153. package/src/core/network/ai.ts +12 -0
  154. package/src/core/notebook/document/__tests__/codemirror.test.ts +2 -0
  155. package/src/core/notebook/replica/__tests__/replica.test.ts +19 -0
  156. package/src/core/notebook/replica/__tests__/results.test.ts +45 -16
  157. package/src/core/notebook/replica/index.ts +1 -1
  158. package/src/core/notebook/replica/replica.ts +19 -4
  159. package/src/core/notebook/replica/resources/executions.ts +100 -9
  160. package/src/core/notebook/replica/resources/results.ts +46 -31
  161. package/src/core/transports/__tests__/static.test.ts +5 -3
  162. package/src/stories/cell.stories.tsx +40 -30
  163. package/src/stories/layout/vertical/one-column.stories.tsx +15 -7
  164. package/dist/assets/__vite-browser-external-C5NhJPNJ.js +0 -1
  165. package/dist/assets/worker-D-n8vtGi.js +0 -171
  166. package/dist/duckdb-keywords-BGArYVVK.js +0 -3
@@ -1,7 +1,7 @@
1
1
  import { a as e } from "./rolldown-runtime-BPCzCO3I.js";
2
2
  import { t } from "./react-Bgs_wQh3.js";
3
- import { h as n } from "./tooltip-BwlFTaNy.js";
4
- import { C as r } from "./select-Ca-POp4c.js";
3
+ import { h as n } from "./tooltip-Bg-SDCwa.js";
4
+ import { C as r } from "./select-DW32QOzC.js";
5
5
  var i = n("chart-pie", [["path", {
6
6
  d: "M21 12c.552 0 1.005-.449.95-.998a10 10 0 0 0-8.953-8.951c-.55-.055-.998.398-.998.95v8a1 1 0 0 0 1 1z",
7
7
  key: "pzmjnu"
@@ -1,6 +1,6 @@
1
1
  import { a as e } from "./rolldown-runtime-BPCzCO3I.js";
2
2
  import { t } from "./react-Bgs_wQh3.js";
3
- import { jt as n } from "./use-restore-focus-fKgXR0nb.js";
3
+ import { jt as n } from "./use-restore-focus-CE9Sflmg.js";
4
4
  //#region src/hooks/useDeepCompareMemoize.ts
5
5
  var r = /* @__PURE__ */ e(t(), 1);
6
6
  function i(e) {
@@ -2,7 +2,7 @@ import { a as e } from "./rolldown-runtime-BPCzCO3I.js";
2
2
  import { h as t, r as n } from "./button-qQhINE7z.js";
3
3
  import { t as r } from "./react-Bgs_wQh3.js";
4
4
  import { t as i } from "./compiler-runtime-C5KHtL5D.js";
5
- import { h as a } from "./tooltip-BwlFTaNy.js";
5
+ import { h as a } from "./tooltip-Bg-SDCwa.js";
6
6
  import { t as o } from "./jsx-runtime-D8btoEHk.js";
7
7
  var s = a("calendar", [
8
8
  ["path", {
@@ -2,22 +2,22 @@ import { a as e } from "./rolldown-runtime-BPCzCO3I.js";
2
2
  import { g as t, h as n, m as r, s as i } from "./button-qQhINE7z.js";
3
3
  import { t as a } from "./react-Bgs_wQh3.js";
4
4
  import { t as o } from "./compiler-runtime-C5KHtL5D.js";
5
- import { t as s } from "./tooltip-BwlFTaNy.js";
6
- import { l as c, t as l } from "./config-DJ8M-gPL.js";
5
+ import { t as s } from "./tooltip-Bg-SDCwa.js";
6
+ import { l as c, t as l } from "./config-DOwBtRkI.js";
7
7
  import { t as u } from "./jsx-runtime-D8btoEHk.js";
8
- import { d } from "./use-restore-focus-fKgXR0nb.js";
9
- import { n as f } from "./error-banner-k06CAftu.js";
8
+ import { d } from "./use-restore-focus-CE9Sflmg.js";
9
+ import { n as f } from "./error-banner-CHPLqogX.js";
10
10
  import { t as p } from "./debounce-DrhhziJv.js";
11
11
  import { t as ee } from "./objects-DCmMvZtn.js";
12
12
  import { t as te } from "./useEvent-BoN7U38T.js";
13
- import { a as ne, i as re, n as ie, t as m } from "./formats-DQ-qq-dU.js";
13
+ import { a as ne, i as re, n as ie, t as m } from "./formats-BDqe9cfr.js";
14
14
  import { a as h, t as g } from "./arrays-DoQ-AILx.js";
15
15
  import { t as ae } from "./useAsyncData-P5-Oovhq.js";
16
16
  import { t as _ } from "./semaphore-8KhQouXt.js";
17
17
  import { W as oe, n as se } from "./vega-loader.browser-Co9gYE8Z.js";
18
18
  import { t as ce } from "./react-vega-CGgQEf0O.js";
19
19
  import { a as le, n as v } from "./loader-Bin_dutt.js";
20
- import { t as ue } from "./useDeepCompareMemoize-OhBYt-q2.js";
20
+ import { t as ue } from "./useDeepCompareMemoize-Bvrue1iy.js";
21
21
  import { t as de } from "./use-vega-container-remeasure-BrUpWQfF.js";
22
22
  //#region src/plugins/impl/vega/fix-relative-url.ts
23
23
  var fe = /* @__PURE__ */ e(a(), 1), pe = o();
@@ -3,7 +3,7 @@ import { t } from "./src-D5uZaZib.js";
3
3
  import { n } from "./chunk-Y2CYZVJY-DKKS1VyV.js";
4
4
  import { $ as r, H as i, K as a, U as o, a as s, b as c, c as l, et as u, f as d, nt as f, tt as p, v as m, w as h, y as g } from "./chunk-DU6HZSFF-4SDIhUTY.js";
5
5
  import { t as _ } from "./rough.esm-CtV9AnV1.js";
6
- import { p as v } from "./mermaid-BcNMyKmf.js";
6
+ import { p as v } from "./mermaid-ffopDjig.js";
7
7
  //#region ../node_modules/.pnpm/khroma@2.1.0/node_modules/khroma/dist/methods/transparentize.js
8
8
  var y = (e, t) => p(e, "a", -t), b = 1e-10;
9
9
  function x(e, t) {
@@ -2,7 +2,7 @@ import { i as e } from "./chunk-75Z2AOVW-76L6My3P.js";
2
2
  import { n as t } from "./src-D5uZaZib.js";
3
3
  import { n } from "./chunk-Y2CYZVJY-DKKS1VyV.js";
4
4
  import { D as r, H as i, K as a, U as o, a as s, b as c, c as l, v as u, w as d, x as f, y as p } from "./chunk-DU6HZSFF-4SDIhUTY.js";
5
- import { p as m } from "./mermaid-BcNMyKmf.js";
5
+ import { p as m } from "./mermaid-ffopDjig.js";
6
6
  import { n as h } from "./mermaid-parser.core-DtOnl7m4.js";
7
7
  import { t as g } from "./chunk-JWPE2WC7-DJvv1t8U.js";
8
8
  //#region ../node_modules/.pnpm/mermaid@11.17.2/node_modules/mermaid/dist/chunks/mermaid.core/wardleyDiagram-VM6X3IG4.mjs
@@ -9,7 +9,7 @@ import { n as s } from "./chunk-Y2CYZVJY-DKKS1VyV.js";
9
9
  import { D as c, H as l, K as u, U as d, a as f, b as p, c as m, f as h, v as g, w as _, y as v, z as y } from "./chunk-DU6HZSFF-4SDIhUTY.js";
10
10
  import "./chunk-PWAF6VOD-CRu_RGP2.js";
11
11
  import { t as b } from "./chunk-GMAD6QVW-BJGF8QZL.js";
12
- import { p as x } from "./mermaid-BcNMyKmf.js";
12
+ import { p as x } from "./mermaid-ffopDjig.js";
13
13
  //#region ../node_modules/.pnpm/d3-scale@4.0.2/node_modules/d3-scale/src/band.js
14
14
  function S() {
15
15
  var e = t().unknown(void 0), r = e.domain, i = e.range, o = 0, s = 1, c, l, u = !1, d = 0, f = 0, p = .5;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marimo-team/islands",
3
- "version": "0.25.3-dev388",
3
+ "version": "0.25.3-dev394",
4
4
  "main": "dist/main.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
@@ -57,7 +57,7 @@
57
57
  "@marimo-team/codemirror-ai": "^0.3.10",
58
58
  "@marimo-team/codemirror-languageserver": "^2.0.1",
59
59
  "@marimo-team/codemirror-mcp": "^0.1.7",
60
- "@marimo-team/codemirror-sql": "^0.3.0",
60
+ "@marimo-team/codemirror-sql": "^0.3.1",
61
61
  "@marimo-team/llm-info": "workspace:*",
62
62
  "@marimo-team/marimo-api": "workspace:*",
63
63
  "@marimo-team/react-slotz": "^0.2.0",
@@ -14,6 +14,7 @@ import {
14
14
  type NotebookBackend,
15
15
  type NotebookReplica,
16
16
  type Results,
17
+ type Result,
17
18
  } from "@/core/notebook/replica";
18
19
  import { activeNotebookReplicaAtom } from "@/core/session/active-notebook";
19
20
 
@@ -52,7 +53,7 @@ function completed(
52
53
  };
53
54
  }
54
55
 
55
- function mirror(records: Protocol.Execution[]): Executions {
56
+ function mirror(records: readonly Protocol.Execution[]): Executions {
56
57
  const executions = new Map<Protocol.ExecutionId, Execution>();
57
58
  const latest = new Map<Protocol.CellId, Protocol.ExecutionId>();
58
59
  for (const record of records) {
@@ -66,18 +67,34 @@ function mirror(records: Protocol.Execution[]): Executions {
66
67
  }
67
68
  executions.set(record.id, {
68
69
  record,
70
+ outputVersion: 0,
69
71
  items: new Map(),
70
72
  variables: new Map(),
71
73
  });
72
74
  }
73
- return { runs: new Map(), executions, latest };
75
+ const scratch = records.findLast(
76
+ (record) => record.cell_id === null && record.outcome !== null,
77
+ );
78
+ return {
79
+ runs: new Map(),
80
+ executions,
81
+ latest,
82
+ results: results(records),
83
+ scratch:
84
+ scratch === undefined ? null : { record: scratch, outputVersion: 0 },
85
+ };
74
86
  }
75
87
 
76
- function results(records: Protocol.Execution[]): Results {
77
- const results = new Map<Protocol.CellId, Protocol.Execution>();
88
+ function results(records: readonly Protocol.Execution[]): Results {
89
+ const results = new Map<Protocol.CellId, Result | null>();
78
90
  for (const record of records) {
79
- if (record.cell_id !== null && record.status === "completed") {
80
- results.set(record.cell_id, record);
91
+ if (record.cell_id !== null) {
92
+ if (!results.has(record.cell_id)) {
93
+ results.set(record.cell_id, null);
94
+ }
95
+ if (record.status === "completed") {
96
+ results.set(record.cell_id, { record, outputVersion: 0 });
97
+ }
81
98
  }
82
99
  }
83
100
  return results;
@@ -95,7 +112,24 @@ export const MockExecutions = {
95
112
  });
96
113
  },
97
114
 
98
- errored(cellId: string): Protocol.Execution {
115
+ /** A completed execution that showed `display`. */
116
+ shown(
117
+ cellId: string,
118
+ display: Protocol.DisplayData,
119
+ overrides: Partial<Protocol.Execution> = {},
120
+ ): Protocol.Execution {
121
+ return completed(cellId, {
122
+ outcome: { kind: "value", display },
123
+ ...overrides,
124
+ });
125
+ },
126
+
127
+ /** A completed execution that ended in `error`, a ValueError by default. */
128
+ failed(
129
+ cellId: string,
130
+ error: Partial<Protocol.Error> = {},
131
+ overrides: Partial<Protocol.Execution> = {},
132
+ ): Protocol.Execution {
99
133
  return completed(cellId, {
100
134
  outcome: {
101
135
  kind: "error",
@@ -108,11 +142,17 @@ export const MockExecutions = {
108
142
  severity: "error",
109
143
  range: null,
110
144
  related: [],
145
+ ...error,
111
146
  },
112
147
  },
148
+ ...overrides,
113
149
  });
114
150
  },
115
151
 
152
+ errored(cellId: string): Protocol.Execution {
153
+ return MockExecutions.failed(cellId);
154
+ },
155
+
116
156
  interrupted(cellId: string): Protocol.Execution {
117
157
  return completed(cellId, { outcome: { kind: "interrupted" } });
118
158
  },
@@ -173,7 +213,7 @@ export const MockExecutions = {
173
213
  * with nothing keeping it from running.
174
214
  */
175
215
  inputs(
176
- records: Protocol.Execution[],
216
+ records: readonly Protocol.Execution[],
177
217
  extra: Partial<Pick<CellExecutionInputs, "requested" | "blocked">> = {},
178
218
  ): CellExecutionInputs {
179
219
  return {
@@ -1,9 +1,11 @@
1
1
  /* Copyright 2026 Marimo. All rights reserved. */
2
2
 
3
+ import type * as Protocol from "@marimo-team/client/protocol";
4
+ import type { createStore } from "jotai";
3
5
  import { createRef } from "react";
4
6
  import { vi } from "vitest";
5
7
  import type { CellActions } from "@/core/cells/actions";
6
- import type { NotebookState } from "@/core/cells/cells";
8
+ import { type NotebookState, notebookAtom } from "@/core/cells/cells";
7
9
  import { CellId } from "@/core/cells/ids";
8
10
  import {
9
11
  type CellData,
@@ -12,6 +14,7 @@ import {
12
14
  } from "@/core/cells/types";
13
15
  import type { MarimoError } from "@/core/kernel/messages";
14
16
  import { Objects } from "@/utils/objects";
17
+ import { MockExecutions } from "./executions";
15
18
 
16
19
  export const MockNotebook = {
17
20
  *cellIds() {
@@ -134,57 +137,32 @@ export const MockNotebook = {
134
137
  },
135
138
 
136
139
  /**
137
- * Create a notebook state with error outputs for testing ErrorContextProvider
140
+ * Set `store` to a notebook whose cells each ended in a host error.
141
+ *
142
+ * The host reports one error per execution, so each cell gets one.
138
143
  */
139
- notebookStateWithErrors: (
144
+ withErrors: (
145
+ store: ReturnType<typeof createStore>,
140
146
  errors: {
141
147
  cellId: CellId;
142
148
  cellName: string;
143
- errorData: MarimoError[];
149
+ code?: string;
150
+ error: Partial<Protocol.Error>;
144
151
  }[],
145
152
  ): NotebookState => {
146
153
  const cellData: Record<string, Partial<CellData>> = {};
147
-
148
- for (const error of errors) {
149
- cellData[error.cellId] = {
150
- name: error.cellName,
154
+ for (const { cellId, cellName, code } of errors) {
155
+ cellData[cellId] = {
156
+ name: cellName,
157
+ ...(code === undefined ? {} : { code }),
151
158
  };
152
159
  }
153
-
154
160
  const notebookState = MockNotebook.notebookState({ cellData });
155
-
156
- // Add error outputs to cell runtime
157
- for (const error of errors) {
158
- notebookState.cellRuntime[error.cellId] = {
159
- ...createCellRuntimeState(),
160
- output: {
161
- channel: "marimo-error" as const,
162
- data: error.errorData,
163
- mimetype: "application/vnd.marimo+error" as const,
164
- timestamp: Date.now(),
165
- },
166
- };
167
- }
168
-
161
+ store.set(notebookAtom, notebookState);
162
+ MockExecutions.seed(
163
+ store,
164
+ errors.map(({ cellId, error }) => MockExecutions.failed(cellId, error)),
165
+ );
169
166
  return notebookState;
170
167
  },
171
-
172
- /**
173
- * Create a single cell with errors for quick testing
174
- */
175
- cellWithErrors: (cellName: string, errorData: MarimoError[]) => {
176
- const cellId = CellId.create();
177
- return {
178
- cellId,
179
- cellName,
180
- errorData,
181
- notebookState: MockNotebook.notebookStateWithErrors([
182
- {
183
- cellId,
184
- cellName,
185
- errorData,
186
- },
187
- ]),
188
- };
189
- },
190
168
  };
@@ -0,0 +1,255 @@
1
+ /* Copyright 2026 Marimo. All rights reserved. */
2
+
3
+ import {
4
+ act,
5
+ fireEvent,
6
+ render,
7
+ screen,
8
+ waitFor,
9
+ } from "@testing-library/react";
10
+ import { createStore, Provider } from "jotai";
11
+ import { Controller, useForm } from "react-hook-form";
12
+ import { describe, expect, it, vi } from "vitest";
13
+ import { userConfigAtom } from "@/core/config/config";
14
+ import {
15
+ defaultUserConfig,
16
+ type UserConfig,
17
+ } from "@/core/config/config-schema";
18
+ import { listProviderModels } from "@/core/network/ai";
19
+ import type { EditRequests } from "@/core/network/types";
20
+ import { AddModelForm } from "../ai-config";
21
+ import { aiSettingsSubTabAtom, pendingConfigSavesAtom } from "../state";
22
+ import {
23
+ activeUserConfigCategoryAtom,
24
+ UserConfigForm,
25
+ } from "../user-config-form";
26
+
27
+ const saveUserConfig = vi.hoisted(() =>
28
+ vi.fn<EditRequests["saveUserConfig"]>(),
29
+ );
30
+
31
+ vi.mock("@/core/network/ai", () => ({ listProviderModels: vi.fn() }));
32
+ vi.mock("@/core/network/requests", async (importOriginal) => ({
33
+ ...(await importOriginal<typeof import("@/core/network/requests")>()),
34
+ useRequestClient: () => ({ saveUserConfig }),
35
+ }));
36
+ vi.mock("@uidotdev/usehooks", async (importOriginal) => ({
37
+ ...(await importOriginal<typeof import("@uidotdev/usehooks")>()),
38
+ useMediaQuery: () => true,
39
+ }));
40
+
41
+ Element.prototype.scrollIntoView = vi.fn();
42
+
43
+ const search = () =>
44
+ screen.getByRole("button", { name: "Search available models" });
45
+
46
+ async function openAddModel(providerName: string) {
47
+ fireEvent.click(screen.getByRole("button", { name: "Add model" }));
48
+ fireEvent.click(screen.getByRole("combobox"));
49
+ fireEvent.click(
50
+ await screen.findByRole("option", {
51
+ name: new RegExp(providerName, "i"),
52
+ }),
53
+ );
54
+ }
55
+
56
+ function ModelForm({
57
+ providerName,
58
+ savedConfig,
59
+ onSubmit,
60
+ }: {
61
+ providerName: string;
62
+ savedConfig: UserConfig;
63
+ onSubmit: (config: UserConfig) => void;
64
+ }) {
65
+ const form = useForm<UserConfig>({ defaultValues: savedConfig });
66
+ return (
67
+ <>
68
+ <Controller
69
+ control={form.control}
70
+ name={`ai.custom_providers.${providerName}.api_key`}
71
+ render={() => <span />}
72
+ />
73
+ <button
74
+ type="button"
75
+ onClick={() =>
76
+ form.setValue(
77
+ `ai.custom_providers.${providerName}.base_url`,
78
+ "https://changed.example.com/v1",
79
+ )
80
+ }
81
+ >
82
+ Change URL
83
+ </button>
84
+ <AddModelForm
85
+ form={form}
86
+ config={savedConfig}
87
+ customModels={[]}
88
+ customProviderNames={[providerName]}
89
+ onSubmit={onSubmit}
90
+ />
91
+ </>
92
+ );
93
+ }
94
+
95
+ describe("AddModelForm discovery", () => {
96
+ it.each(["gateway", "openrouter"])(
97
+ "waits for %s changes to be saved and only saves a selected model on Add",
98
+ async (providerName) => {
99
+ vi.mocked(listProviderModels)
100
+ .mockReset()
101
+ .mockResolvedValue({
102
+ models: [{ id: "model-a", name: "Model A" }],
103
+ });
104
+ const config = defaultUserConfig();
105
+ config.ai = {
106
+ ...config.ai,
107
+ custom_providers: {
108
+ [providerName]: { base_url: "https://original.example.com/v1" },
109
+ },
110
+ };
111
+ const store = createStore();
112
+ store.set(userConfigAtom, config);
113
+ const onSubmit = vi.fn();
114
+ const { rerender } = render(
115
+ <Provider store={store}>
116
+ <ModelForm
117
+ providerName={providerName}
118
+ savedConfig={config}
119
+ onSubmit={onSubmit}
120
+ />
121
+ </Provider>,
122
+ );
123
+ await openAddModel(providerName);
124
+ expect(search()).toBeEnabled();
125
+ fireEvent.click(search());
126
+ fireEvent.click(
127
+ await screen.findByRole("button", { name: "Model A — model-a" }),
128
+ );
129
+ expect(onSubmit).not.toHaveBeenCalled();
130
+
131
+ fireEvent.click(screen.getByRole("button", { name: "Change URL" }));
132
+ expect(search()).toBeDisabled();
133
+ const savedConfig = {
134
+ ...config,
135
+ ai: {
136
+ ...config.ai,
137
+ custom_providers: {
138
+ [providerName]: { base_url: "https://changed.example.com/v1" },
139
+ },
140
+ },
141
+ };
142
+ act(() => {
143
+ store.set(pendingConfigSavesAtom, 1);
144
+ store.set(userConfigAtom, savedConfig);
145
+ });
146
+ rerender(
147
+ <Provider store={store}>
148
+ <ModelForm
149
+ providerName={providerName}
150
+ savedConfig={savedConfig}
151
+ onSubmit={onSubmit}
152
+ />
153
+ </Provider>,
154
+ );
155
+ expect(search()).toBeDisabled();
156
+ act(() => store.set(pendingConfigSavesAtom, 0));
157
+ await waitFor(() => expect(search()).toBeEnabled());
158
+ fireEvent.focus(screen.getByLabelText("Model"));
159
+ expect(screen.queryByRole("dialog")).not.toBeInTheDocument();
160
+
161
+ vi.mocked(listProviderModels).mockResolvedValue({
162
+ models: [{ id: "model-b", name: "Model B" }],
163
+ });
164
+ fireEvent.change(screen.getByLabelText("Model"), {
165
+ target: { value: "" },
166
+ });
167
+ fireEvent.click(search());
168
+ fireEvent.click(
169
+ await screen.findByRole("button", { name: "Model B — model-b" }),
170
+ );
171
+ expect(listProviderModels).toHaveBeenCalledTimes(2);
172
+ expect(listProviderModels).toHaveBeenLastCalledWith(providerName);
173
+
174
+ fireEvent.click(screen.getByRole("button", { name: /^Add$/ }));
175
+ expect(onSubmit).toHaveBeenCalledWith(
176
+ expect.objectContaining({
177
+ ai: expect.objectContaining({
178
+ models: expect.objectContaining({
179
+ custom_models: [`${providerName}/model-b`],
180
+ }),
181
+ }),
182
+ }),
183
+ );
184
+ },
185
+ );
186
+
187
+ it("keeps model entry focused across settings saves and only adds models on Add", async () => {
188
+ const config = defaultUserConfig();
189
+ config.ai = {
190
+ ...config.ai,
191
+ custom_providers: {
192
+ gateway: { base_url: "https://gateway.example.com/v1" },
193
+ },
194
+ };
195
+ const store = createStore();
196
+ store.set(userConfigAtom, config);
197
+ store.set(activeUserConfigCategoryAtom, "ai");
198
+ store.set(aiSettingsSubTabAtom, "ai-models");
199
+ saveUserConfig.mockReset().mockResolvedValue(null);
200
+ vi.mocked(listProviderModels)
201
+ .mockReset()
202
+ .mockResolvedValue({
203
+ models: [{ id: "second-model", name: "Second model" }],
204
+ });
205
+ render(
206
+ <Provider store={store}>
207
+ <UserConfigForm />
208
+ </Provider>,
209
+ );
210
+
211
+ await openAddModel("gateway");
212
+ fireEvent.change(screen.getByLabelText("Model"), {
213
+ target: { value: "first-model" },
214
+ });
215
+ await act(async () => {
216
+ await new Promise((resolve) => setTimeout(resolve, 150));
217
+ });
218
+ fireEvent.click(screen.getByRole("button", { name: /^Add$/ }));
219
+ await waitFor(() => expect(saveUserConfig).toHaveBeenCalledOnce());
220
+ await waitFor(() => expect(store.get(pendingConfigSavesAtom)).toBe(0));
221
+
222
+ await openAddModel("gateway");
223
+ fireEvent.click(search());
224
+ await screen.findByRole("button", { name: "Second model — second-model" });
225
+ const pendingSave = Promise.withResolvers<null>();
226
+ saveUserConfig.mockReturnValueOnce(pendingSave.promise);
227
+ const input = screen.getByLabelText("Model");
228
+ act(() => input.focus());
229
+ fireEvent.change(input, { target: { value: "second" } });
230
+ await waitFor(() => expect(saveUserConfig).toHaveBeenCalledTimes(2));
231
+ expect(store.get(pendingConfigSavesAtom)).toBe(1);
232
+ expect(screen.getByLabelText("Model")).toBe(input);
233
+ expect(input).toHaveFocus();
234
+
235
+ await act(async () => pendingSave.resolve(null));
236
+ await screen.findByRole("button", { name: "Second model — second-model" });
237
+ expect(screen.getByLabelText("Model")).toBe(input);
238
+ expect(input).toHaveFocus();
239
+ expect(input).toHaveValue("second");
240
+ expect(store.get(userConfigAtom).ai?.models?.custom_models).toEqual([
241
+ "gateway/first-model",
242
+ ]);
243
+
244
+ fireEvent.click(
245
+ screen.getByRole("button", { name: "Second model — second-model" }),
246
+ );
247
+ fireEvent.click(screen.getByRole("button", { name: /^Add$/ }));
248
+ await waitFor(() =>
249
+ expect(store.get(userConfigAtom).ai?.models?.custom_models).toEqual([
250
+ "gateway/second-model",
251
+ "gateway/first-model",
252
+ ]),
253
+ );
254
+ });
255
+ });