@marimo-team/islands 0.26.1-dev42 → 0.26.1-dev46

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 (108) hide show
  1. package/dist/{ConnectedDataExplorerComponent-BVMWCBON.js → ConnectedDataExplorerComponent-yQVBQBUW.js} +16 -16
  2. package/dist/{ErrorBoundary-BzyGrUMt.js → ErrorBoundary-i7VCVA53.js} +18 -18
  3. package/dist/{abnfDiagram-VCTEODGH-BRj77JhY.js → abnfDiagram-VCTEODGH-Ck_lXwQR.js} +2 -2
  4. package/dist/{any-language-editor-BQ9dhxg5.js → any-language-editor-Cx4idbgX.js} +2 -2
  5. package/dist/{architectureDiagram-5GKGNRK7-CDnAsvE1.js → architectureDiagram-5GKGNRK7-XeVhic7Z.js} +1 -1
  6. package/dist/{assertNever-DeSqnr83.js → assertNever-473SFxLt.js} +2 -2
  7. package/dist/{chat-ui-CXyZb62N.js → chat-ui-6qTQeEIx.js} +870 -870
  8. package/dist/{check-COXd6cXw.js → check-DmTIavbZ.js} +1 -1
  9. package/dist/{chunk-IMKFNOWR-BFtu1O6j.js → chunk-IMKFNOWR-DdQni67K.js} +1 -1
  10. package/dist/{chunk-SHT3W25Y-B9zWo9Da.js → chunk-SHT3W25Y-BdK-vMct.js} +1 -1
  11. package/dist/{chunk-SVP7TREG-kKS-I24p.js → chunk-SVP7TREG-cpFZk4Ca.js} +1 -1
  12. package/dist/{chunk-TICWLB2K-EY3w5-eg.js → chunk-TICWLB2K-DDgQFRgT.js} +1 -1
  13. package/dist/{classDiagram-ZZMXUADV-BR66X7fj.js → classDiagram-ZZMXUADV-DeojX9X4.js} +2 -2
  14. package/dist/{classDiagram-v2-VYDZK3BY-DPcxw_9g.js → classDiagram-v2-VYDZK3BY-DPfTAiQ6.js} +2 -2
  15. package/dist/{code-visibility-DcxCjPS7.js → code-visibility-DNUnnMY_.js} +27 -27
  16. package/dist/{common-CA3E-SaD.js → common-CXvbAyqO.js} +4892 -4900
  17. package/dist/{config-DE3A8m65.js → config-D-lhQq-h.js} +3 -3
  18. package/dist/{copy-icon-gSCLWI50.js → copy-icon-DuxRkh7T.js} +2 -2
  19. package/dist/{createReducer-BFfuVhJG.js → createReducer-D3pBhIVD.js} +5 -5
  20. package/dist/{cynefinDiagram-5FMLGOSQ-B9kG0Adl.js → cynefinDiagram-5FMLGOSQ-DyY9TvuI.js} +1 -1
  21. package/dist/{dagre-GXQ25YYZ-ClnyHQzL.js → dagre-GXQ25YYZ-BPCOgtKg.js} +1 -1
  22. package/dist/{data-grid-overlay-editor-DjSnRyGz.js → data-grid-overlay-editor-_B2yWrZg.js} +1 -1
  23. package/dist/{diagram-S7CK7UJ4-afCjSSlp.js → diagram-S7CK7UJ4-KaF-C6kd.js} +1 -1
  24. package/dist/{diagram-UQ7AKVKN-BCHefG5P.js → diagram-UQ7AKVKN-DkeqoSvK.js} +1 -1
  25. package/dist/{diagram-VX7I27RA-9jXA0khj.js → diagram-VX7I27RA-DExolTAf.js} +1 -1
  26. package/dist/{diagram-Z3DM3KII-C8tsbK7Q.js → diagram-Z3DM3KII-BioFuBF3.js} +1 -1
  27. package/dist/{dialog-Dn_UHaEl.js → dialog-CvyFEwby.js} +28 -28
  28. package/dist/{dropdown-menu-D0nePAlm.js → dropdown-menu-BiXHfje7.js} +651 -651
  29. package/dist/{ebnfDiagram-PWID7BFC-It0ZS33j.js → ebnfDiagram-PWID7BFC-BSb9k1ed.js} +2 -2
  30. package/dist/{erDiagram-RLTQ6QDP-Z0Qfo02H.js → erDiagram-RLTQ6QDP-PWA30a_r.js} +1 -1
  31. package/dist/{error-banner-DChjSagB.js → error-banner-B9HQMSaH.js} +70 -70
  32. package/dist/{error-entries-DYoi03MZ.js → error-entries-8CPw0aYH.js} +812 -698
  33. package/dist/{feedback-button-DeA5LGUm.js → feedback-button-BOJ6pfBP.js} +52 -52
  34. package/dist/{flowDiagram-HODETNUW-8DeXLUFK.js → flowDiagram-HODETNUW-BPtD__Zz.js} +2 -2
  35. package/dist/{formats-6QF5hRsy.js → formats-BF95BoCT.js} +1 -1
  36. package/dist/{glide-data-editor-DD03A2zN.js → glide-data-editor-oQ3lCfvU.js} +11 -11
  37. package/dist/{glide-utils-B7gy9Her.js → glide-utils-iHKKQPJ8.js} +2 -2
  38. package/dist/{globals-CXh7buzB.js → globals-a3k2q2j7.js} +3 -3
  39. package/dist/{html-to-image-CUFNjxtw.js → html-to-image-BIom70fW.js} +404 -404
  40. package/dist/{infoDiagram-27XIBGKW-B5wmzeRz.js → infoDiagram-27XIBGKW-SJuilBEE.js} +1 -1
  41. package/dist/{ishikawaDiagram-5VMMS53U-BcbPwik7.js → ishikawaDiagram-5VMMS53U-DjzyxMr8.js} +1 -1
  42. package/dist/{kanban-definition-UXKFOSKX-AfQmkIoH.js → kanban-definition-UXKFOSKX-D2_qopGt.js} +1 -1
  43. package/dist/main.js +5811 -5766
  44. package/dist/{mermaid-az53hfgW.js → mermaid-DcowNmCx.js} +34 -34
  45. package/dist/{mindmap-definition-YA3MSWOX-B7eBrMap.js → mindmap-definition-YA3MSWOX-pEra10M0.js} +1 -1
  46. package/dist/{number-overlay-editor-DJFSx1CC.js → number-overlay-editor-CUwIpUt4.js} +1 -1
  47. package/dist/{pegDiagram-XKGWAZYB-BwjpXSLR.js → pegDiagram-XKGWAZYB-CHOPKVOf.js} +2 -2
  48. package/dist/{pencil-pQhLU2Up.js → pencil-FAv6JUvp.js} +1 -1
  49. package/dist/{pieDiagram-E7YTZNPT-D5AyRqAQ.js → pieDiagram-E7YTZNPT-yGDhsyEN.js} +1 -1
  50. package/dist/{process-output-DMMs8Ywh.js → process-output-ns7N5ovS.js} +4 -4
  51. package/dist/{railroadDiagram-O6MQD6OU-Hhrla0Qq.js → railroadDiagram-O6MQD6OU-CeKEPdyc.js} +2 -2
  52. package/dist/{requirementDiagram-BXWQKSXE-MgDRuFUM.js → requirementDiagram-BXWQKSXE-DSAbAzKe.js} +1 -1
  53. package/dist/{reveal-component-DwB1-KYy.js → reveal-component-BAhQeB3o.js} +7 -7
  54. package/dist/{select-C4rPKgSx.js → select-BszV-bbI.js} +307 -307
  55. package/dist/{sequenceDiagram-WJ2MYXX4-xZYdOGbe.js → sequenceDiagram-WJ2MYXX4-DVhWj_9H.js} +1 -1
  56. package/dist/{spec-BsiCag5K.js → spec-CRfw-lOm.js} +4 -4
  57. package/dist/{stateDiagram-D77RDMKH-DdhE3Yx9.js → stateDiagram-D77RDMKH-CDQ2MltG.js} +2 -2
  58. package/dist/{stateDiagram-v2-MP3YSRHH-DENKYVKr.js → stateDiagram-v2-MP3YSRHH-BQmvwBaz.js} +2 -2
  59. package/dist/{static-state-CNnjDcOR.js → static-state-BtDNJuc2.js} +5 -5
  60. package/dist/{swimlanes-42K2YHIH-Bw7xuGAn.js → swimlanes-42K2YHIH-DLOUTCEL.js} +1 -1
  61. package/dist/{swimlanesDiagram-VR7AAH4N-L91TUeh5.js → swimlanesDiagram-VR7AAH4N-BVKrkNJ6.js} +2 -2
  62. package/dist/{timeline-definition-24CTP7MA-BeGrmws1.js → timeline-definition-24CTP7MA-Cb2JoCSd.js} +1 -1
  63. package/dist/{toast-qyBwbZJ0.js → toast-QsOAIPfq.js} +192 -192
  64. package/dist/{tooltip-COQxCMLx.js → tooltip-BQZ-Bm6h.js} +76 -76
  65. package/dist/{use-restore-focus-D5-Hgr1l.js → use-restore-focus-DT1TZACX.js} +1167 -1167
  66. package/dist/{useDateFormatter-L8edl513.js → useDateFormatter-D3gyMY-g.js} +2 -2
  67. package/dist/{useDeepCompareMemoize-B6yhm6sM.js → useDeepCompareMemoize-CO6rO5Mq.js} +1 -1
  68. package/dist/{useLifecycle-Dnxradbp.js → useLifecycle-C9UTzCY8.js} +1 -1
  69. package/dist/{vega-component-CWKS3tOU.js → vega-component-i5lZ23n7.js} +17 -17
  70. package/dist/{vennDiagram-4TSXK5OY-fknCUyJ2.js → vennDiagram-4TSXK5OY-Cm3EcCcP.js} +1 -1
  71. package/dist/{wardleyDiagram-VM6X3IG4-DvoVMCdj.js → wardleyDiagram-VM6X3IG4-DjlUs2CC.js} +1 -1
  72. package/dist/{xychartDiagram-S5SC5T6Z-0TYtO6UV.js → xychartDiagram-S5SC5T6Z-DxNDul9l.js} +1 -1
  73. package/package.json +1 -1
  74. package/src/__mocks__/animation-frames.ts +31 -0
  75. package/src/__mocks__/executions.ts +6 -1
  76. package/src/components/editor/cell/collapse.tsx +6 -3
  77. package/src/components/editor/header/status.tsx +5 -2
  78. package/src/components/scratchpad/scratchpad.tsx +2 -2
  79. package/src/core/cells/cells.ts +24 -16
  80. package/src/core/cells/execution-console.ts +7 -2
  81. package/src/core/executions/__tests__/atoms.test.ts +204 -1
  82. package/src/core/executions/__tests__/output-lifecycle.test.ts +20 -3
  83. package/src/core/executions/__tests__/select.test.ts +32 -1
  84. package/src/core/executions/atoms.ts +245 -81
  85. package/src/core/executions/hooks.ts +15 -59
  86. package/src/core/executions/index.ts +2 -0
  87. package/src/core/executions/output.ts +34 -14
  88. package/src/core/executions/select.ts +70 -25
  89. package/src/core/islands/bootstrap.ts +7 -2
  90. package/src/core/notebook/replica/__tests__/executions.test.ts +8 -12
  91. package/src/core/notebook/replica/__tests__/frame.test.ts +206 -0
  92. package/src/core/notebook/replica/__tests__/once-per-frame.test.ts +95 -0
  93. package/src/core/notebook/replica/__tests__/results.test.ts +3 -9
  94. package/src/core/notebook/replica/frame.ts +54 -0
  95. package/src/core/notebook/replica/index.ts +1 -0
  96. package/src/core/notebook/replica/once-per-frame.ts +60 -0
  97. package/src/core/notebook/replica/resources/executions.ts +0 -2
  98. package/src/core/session/__tests__/useNotebookReplica.hook.test.tsx +53 -7
  99. package/src/core/session/__tests__/useNotebookSession.hook.test.tsx +29 -7
  100. package/src/core/session/active-notebook.ts +4 -1
  101. package/src/core/session/useNotebookReplica.ts +14 -1
  102. package/src/core/state/__tests__/atom-with-selected-inputs.test.ts +48 -0
  103. package/src/core/state/__tests__/create-keyed-selector-hook.test.tsx +16 -7
  104. package/src/core/state/atom-with-selected-inputs.ts +24 -0
  105. package/src/core/state/create-keyed-atom-hook.ts +18 -0
  106. package/src/core/state/create-keyed-selector-hook.ts +5 -9
  107. package/src/core/wasm/__tests__/bridge.test.ts +73 -1
  108. package/src/utils/arrays.ts +4 -1
@@ -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-COQxCMLx.js";
4
- import { C as r } from "./select-C4rPKgSx.js";
3
+ import { h as n } from "./tooltip-BQZ-Bm6h.js";
4
+ import { C as r } from "./select-BszV-bbI.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 { Lt as n } from "./use-restore-focus-D5-Hgr1l.js";
3
+ import { Rt as n } from "./use-restore-focus-DT1TZACX.js";
4
4
  //#region src/utils/semaphore.ts
5
5
  var r = class {
6
6
  maxPermits;
@@ -2,7 +2,7 @@ import { a as e } from "./rolldown-runtime-BPCzCO3I.js";
2
2
  import { h as t, i as n } from "./button-Z2R2272J.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-COQxCMLx.js";
5
+ import { h as a } from "./tooltip-BQZ-Bm6h.js";
6
6
  import { t as o } from "./jsx-runtime-D8btoEHk.js";
7
7
  var s = a("calendar", [
8
8
  ["path", {
@@ -2,18 +2,18 @@ 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-Z2R2272J.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-COQxCMLx.js";
6
- import { l as c, t as l } from "./config-DE3A8m65.js";
5
+ import { t as s } from "./tooltip-BQZ-Bm6h.js";
6
+ import { l as c, t as l } from "./config-D-lhQq-h.js";
7
7
  import { t as u } from "./jsx-runtime-D8btoEHk.js";
8
- import { d } from "./use-restore-focus-D5-Hgr1l.js";
9
- import { n as f } from "./error-banner-DChjSagB.js";
8
+ import { d } from "./use-restore-focus-DT1TZACX.js";
9
+ import { n as f } from "./error-banner-B9HQMSaH.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-6QF5hRsy.js";
14
- import { a as h, t as g } from "./arrays-DoQ-AILx.js";
13
+ import { a as m, t as h } from "./arrays-DoQ-AILx.js";
14
+ import { a as ne, i as re, n as ie, t as g } from "./formats-BF95BoCT.js";
15
15
  import { t as ae } from "./useAsyncData-P5-Oovhq.js";
16
- import { n as _, t as oe } from "./useDeepCompareMemoize-B6yhm6sM.js";
16
+ import { n as _, t as oe } from "./useDeepCompareMemoize-CO6rO5Mq.js";
17
17
  import { W as se, n as ce } from "./vega-loader.browser-Co9gYE8Z.js";
18
18
  import { t as le } from "./react-vega-CGgQEf0O.js";
19
19
  import { a as ue, n as de } from "./loader-qPmiRXZd.js";
@@ -199,9 +199,9 @@ function w(e) {
199
199
  function T(e) {
200
200
  if ("params" in e && e.params && e.params.length > 0) {
201
201
  let t = e.params.filter((e) => e != null && "select" in e && e.select !== void 0).map((e) => e.name);
202
- return h(t);
202
+ return m(t);
203
203
  }
204
- return "layer" in e ? h(e.layer.flatMap(T)) : "vconcat" in e ? h(e.vconcat.flatMap(T)) : "hconcat" in e ? h(e.hconcat.flatMap(T)) : [];
204
+ return "layer" in e ? m(e.layer.flatMap(T)) : "vconcat" in e ? m(e.vconcat.flatMap(T)) : "hconcat" in e ? m(e.hconcat.flatMap(T)) : [];
205
205
  }
206
206
  function E(e) {
207
207
  if (!e || !("mark" in e)) return;
@@ -372,7 +372,7 @@ function ge(e, t) {
372
372
  let t = e.params && e.params.length > 0, i = r !== !1 && !t, a = [];
373
373
  if (i) {
374
374
  let t = e.layer.flatMap((e) => "mark" in e ? O(e) : []);
375
- a = [...new Set(t)], Array.isArray(r) && (a = g.intersection(a, r));
375
+ a = [...new Set(t)], Array.isArray(r) && (a = h.intersection(a, r));
376
376
  }
377
377
  let o = e.layer.map((e, t) => {
378
378
  if (!("mark" in e)) return e;
@@ -398,7 +398,7 @@ function ge(e, t) {
398
398
  function L(e, t) {
399
399
  if (t === !1) return e;
400
400
  let n = O(e);
401
- Array.isArray(t) && (n = g.intersection(n, t));
401
+ Array.isArray(t) && (n = h.intersection(n, t));
402
402
  let r = n.map((e) => C.legend(e)), i = [...e.params || [], ...r];
403
403
  return {
404
404
  ...e,
@@ -504,7 +504,7 @@ async function U(e) {
504
504
  //#endregion
505
505
  //#region src/plugins/impl/vega/vega-component.tsx
506
506
  var W = u();
507
- ce("arrow", m);
507
+ ce("arrow", g);
508
508
  var G = (e) => {
509
509
  let t = (0, me.c)(12), { value: n, setValue: r, chartSelection: i, fieldSelection: a, spec: o, embedOptions: s } = e, c, l;
510
510
  t[0] === o ? (c = t[1], l = t[2]) : (c = async () => U(o), l = [o], t[0] = o, t[1] = c, t[2] = l);
@@ -524,10 +524,10 @@ var G = (e) => {
524
524
  embedOptions: s
525
525
  }), t[5] = i, t[6] = s, t[7] = a, t[8] = u, t[9] = r, t[10] = n, t[11] = p) : p = t[11], p;
526
526
  }, K = (e) => {
527
- let a = (0, me.c)(50), { value: o, setValue: l, chartSelection: u, fieldSelection: f, spec: ne, embedOptions: m } = e, { theme: h } = d(), g = (0, pe.useRef)(null), ae = (0, pe.useRef)(void 0), [_, ce] = (0, pe.useState)(), de;
527
+ let a = (0, me.c)(50), { value: o, setValue: l, chartSelection: u, fieldSelection: f, spec: m, embedOptions: h } = e, { theme: ne } = d(), g = (0, pe.useRef)(null), ae = (0, pe.useRef)(void 0), [_, ce] = (0, pe.useState)(), de;
528
528
  bb0: {
529
- if (m && "actions" in m) {
530
- de = m.actions;
529
+ if (h && "actions" in h) {
530
+ de = h.actions;
531
531
  break bb0;
532
532
  }
533
533
  let e;
@@ -536,7 +536,7 @@ var G = (e) => {
536
536
  compiled: !1
537
537
  }, a[0] = e) : e = a[0], de = e;
538
538
  }
539
- let v = de, y = oe(ne), b;
539
+ let v = de, y = oe(m), b;
540
540
  a[1] !== u || a[2] !== f || a[3] !== y ? (b = ge(he(y), {
541
541
  chartSelection: u,
542
542
  fieldSelection: f
@@ -589,7 +589,7 @@ var G = (e) => {
589
589
  children: /* @__PURE__ */ (0, W.jsx)(c, { className: "absolute bottom-1 right-0 m-2 h-4 w-4 cursor-help text-muted-foreground hover:text-foreground" })
590
590
  });
591
591
  }, a[20] = w, a[21] = L);
592
- let R = L, z = h === "dark" ? "dark" : void 0, B;
592
+ let R = L, z = ne === "dark" ? "dark" : void 0, B;
593
593
  a[22] !== v || a[23] !== z ? (B = {
594
594
  theme: z,
595
595
  actions: v,
@@ -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-az53hfgW.js";
6
+ import { p as v } from "./mermaid-DcowNmCx.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-az53hfgW.js";
5
+ import { p as m } from "./mermaid-DcowNmCx.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-az53hfgW.js";
12
+ import { p as x } from "./mermaid-DcowNmCx.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.26.1-dev42",
3
+ "version": "0.26.1-dev46",
4
4
  "main": "dist/main.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
@@ -0,0 +1,31 @@
1
+ /* Copyright 2026 Marimo. All rights reserved. */
2
+
3
+ import { onTestFinished, vi } from "vitest";
4
+
5
+ /** Drive animation frames without changing timers used by transports. */
6
+ export function mockAnimationFrames() {
7
+ let id = 0;
8
+ const callbacks = new Map<number, FrameRequestCallback>();
9
+ const request = vi
10
+ .spyOn(globalThis, "requestAnimationFrame")
11
+ .mockImplementation((callback) => {
12
+ callbacks.set(++id, callback);
13
+ return id;
14
+ });
15
+ const cancel = vi
16
+ .spyOn(globalThis, "cancelAnimationFrame")
17
+ .mockImplementation((id) => {
18
+ callbacks.delete(id);
19
+ });
20
+ const visibility = vi.spyOn(document, "hidden", "get").mockReturnValue(false);
21
+ onTestFinished(() => {
22
+ request.mockRestore();
23
+ cancel.mockRestore();
24
+ visibility.mockRestore();
25
+ });
26
+ return () => {
27
+ const pending = [...callbacks.values()];
28
+ callbacks.clear();
29
+ pending.forEach((callback) => callback(performance.now()));
30
+ };
31
+ }
@@ -19,7 +19,10 @@ import {
19
19
  type Result,
20
20
  } from "@/core/notebook/replica";
21
21
  import { shown } from "@/core/notebook/replica";
22
- import { activeNotebookReplicaAtom } from "@/core/session/active-notebook";
22
+ import {
23
+ activeNotebookReplicaAtom,
24
+ activeNotebookFrameAtom,
25
+ } from "@/core/session/active-notebook";
23
26
 
24
27
  type Store = ReturnType<typeof createStore>;
25
28
 
@@ -319,6 +322,8 @@ export const MockExecutions = {
319
322
  resultsAtom: atom(results(entries)),
320
323
  } satisfies NotebookReplica;
321
324
  store.set(activeNotebookReplicaAtom, replica);
325
+ // Selector tests share current inputs; frame scheduling is tested separately.
326
+ store.set(activeNotebookFrameAtom, replica);
322
327
  return replica;
323
328
  },
324
329
  };
@@ -17,7 +17,10 @@ import { Tooltip } from "@/components/ui/tooltip";
17
17
  import { columnOf, useLayout } from "@/core/cells/layout";
18
18
  import type { CellId } from "@/core/cells/ids";
19
19
  import { getDescendantsStatus } from "@/core/cells/utils";
20
- import { cellExecutionInputsAtom, cellFreshnessAtom } from "@/core/executions";
20
+ import {
21
+ frameCellExecutionInputsAtom,
22
+ frameCellFreshnessAtom,
23
+ } from "@/core/executions";
21
24
  import { cn } from "@/utils/cn";
22
25
 
23
26
  interface Props {
@@ -65,8 +68,8 @@ export const CollapsedCellBanner: React.FC<{
65
68
  cellId: CellId;
66
69
  count: number;
67
70
  }> = memo(({ onClick, count, cellId }) => {
68
- const executions = useAtomValue(cellExecutionInputsAtom);
69
- const freshness = useAtomValue(cellFreshnessAtom);
71
+ const executions = useAtomValue(frameCellExecutionInputsAtom);
72
+ const freshness = useAtomValue(frameCellFreshnessAtom);
70
73
  const layout = useLayout();
71
74
  const states = getDescendantsStatus(
72
75
  executions,
@@ -5,7 +5,10 @@ import { HourglassIcon, UnlinkIcon } from "lucide-react";
5
5
  import React from "react";
6
6
  import { Tooltip } from "@/components/ui/tooltip";
7
7
  import { notebookScrollToRunning } from "@/core/cells/actions";
8
- import { cellExecutionInputsAtom, onlyScratchRunning } from "@/core/executions";
8
+ import {
9
+ frameCellExecutionInputsAtom,
10
+ onlyScratchRunning,
11
+ } from "@/core/executions";
9
12
  import { viewStateAtom } from "@/core/mode";
10
13
  import {
11
14
  type ConnectionStatus,
@@ -78,7 +81,7 @@ const DisconnectedIcon: React.FC<{ onReconnect?: () => void }> = ({
78
81
 
79
82
  const RunningIcon = () => {
80
83
  const scratchpadOnly = onlyScratchRunning(
81
- useAtomValue(cellExecutionInputsAtom).executions,
84
+ useAtomValue(frameCellExecutionInputsAtom).executions,
82
85
  );
83
86
  const tooltip = scratchpadOnly
84
87
  ? "Scratchpad is running"
@@ -24,7 +24,7 @@ import { getEditorCodeAsPython } from "@/core/codemirror/language/utils";
24
24
  import { useResolvedMarimoConfig } from "@/core/config/config";
25
25
  import { CSSClasses } from "@/core/constants";
26
26
  import {
27
- cellExecutionInputsAtom,
27
+ frameCellExecutionInputsAtom,
28
28
  scratchStatus,
29
29
  useScratchOutput,
30
30
  } from "@/core/executions";
@@ -73,7 +73,7 @@ export const ScratchPad: React.FC = () => {
73
73
  const cellRuntime = useCellRuntime(cellId);
74
74
  const output = useScratchOutput();
75
75
  const status = scratchStatus(
76
- useAtomValue(cellExecutionInputsAtom).executions,
76
+ useAtomValue(frameCellExecutionInputsAtom).executions,
77
77
  );
78
78
  const consoleOutputs = cellRuntime?.consoleOutputs;
79
79
  const answerPrompt = useAnswerPrompt(cellId);
@@ -8,10 +8,10 @@ import { createRef, type ReducerWithoutAction } from "react";
8
8
  import type { CellHandle } from "@/components/editor/notebook-cell";
9
9
  import type { EditableDocument, Placement } from "@/core/notebook/document";
10
10
  import {
11
- cellExecutionInputsAtom,
11
+ frameCellExecutionInputsAtom,
12
12
  cellExecutionView,
13
13
  executionSource,
14
- cellFreshnessAtom,
14
+ frameCellFreshnessAtom,
15
15
  cellOutlineAtom,
16
16
  cellOutputAtom,
17
17
  releaseCellOutputAtoms,
@@ -26,7 +26,7 @@ import { foldAllBulk, unfoldAllBulk } from "../codemirror/editing/commands";
26
26
  import { editorMountScheduler } from "../codemirror/editor-mount-scheduler";
27
27
  import type { SerializedEditorState } from "../codemirror/types";
28
28
  import { mergeOutlines } from "../dom/outline";
29
- import { confirmedDocumentAtom } from "../session/active-notebook";
29
+ import { activeNotebookFrameAtom } from "../session/active-notebook";
30
30
  import { isErrorMime } from "../mime";
31
31
  import { createDeepEqualAtom, store } from "../state/jotai";
32
32
  import { isWasm } from "../wasm/utils";
@@ -34,6 +34,7 @@ import {
34
34
  type CommandOutputMessage,
35
35
  updateCommandConsole,
36
36
  } from "./command-console";
37
+ import { createKeyedAtomHook } from "@/core/state/create-keyed-atom-hook";
37
38
  import { consoleExecution, consoleView } from "./execution-console";
38
39
  import { applyDocument } from "./document";
39
40
  import { isCodeHidden, shownHiddenCodeAtom } from "./editor";
@@ -435,8 +436,8 @@ export const undoLabelAtom = atom((get) => getUndoLabel(get(notebookAtom)));
435
436
  export const runReasonAtom = atom((get) =>
436
437
  notebookRunReason(
437
438
  get(notebookAtom),
438
- get(cellExecutionInputsAtom),
439
- get(cellFreshnessAtom),
439
+ get(frameCellExecutionInputsAtom),
440
+ get(frameCellFreshnessAtom),
440
441
  ),
441
442
  );
442
443
 
@@ -573,13 +574,20 @@ export const cellDataAtom = atomFamily((cellId: CellId) =>
573
574
  );
574
575
  const EMPTY_RUNTIME = createCellRuntimeState();
575
576
  export const cellRuntimeAtom = atomFamily((cellId: CellId) => {
577
+ const executionAtom = atom((get) =>
578
+ consoleExecution(get, cellId, get(activeNotebookFrameAtom)),
579
+ );
580
+ const localAtom = atom(
581
+ (get) => get(notebookAtom).cellRuntime[cellId] ?? EMPTY_RUNTIME,
582
+ );
576
583
  const inputs = atom((get) => {
577
- const execution = consoleExecution(get, cellId);
578
- const cells = get(confirmedDocumentAtom)?.cells;
584
+ const execution = get(executionAtom);
585
+ const frame = get(activeNotebookFrameAtom);
586
+ const cells = frame && get(frame.shownDocumentAtom)?.cells;
579
587
  return {
580
- local: get(notebookAtom).cellRuntime[cellId] ?? EMPTY_RUNTIME,
588
+ local: get(localAtom),
581
589
  execution,
582
- code: execution && executionSource(execution.record, cells),
590
+ code: execution && executionSource(execution.record, cells ?? undefined),
583
591
  };
584
592
  });
585
593
  const view = selectAtom(inputs, consoleView);
@@ -606,14 +614,11 @@ export function releaseCellAtoms(cellId: CellId) {
606
614
  }
607
615
 
608
616
  /** Subscribes to reactive updates of the cell's data. */
609
- export const useCellData = (cellId: CellId) =>
610
- useAtomValue(cellDataAtom(cellId));
617
+ export const useCellData = createKeyedAtomHook(cellDataAtom);
611
618
  /** Subscribes to reactive updates of the cell's runtime info. */
612
- export const useCellRuntime = (cellId: CellId) =>
613
- useAtomValue(cellRuntimeAtom(cellId));
619
+ export const useCellRuntime = createKeyedAtomHook(cellRuntimeAtom);
614
620
  /** Subscribes to reactive updates of the cell's handle (e.g. refs or UI bindings). */
615
- export const useCellHandle = (cellId: CellId) =>
616
- useAtomValue(cellHandleAtom(cellId));
621
+ export const useCellHandle = createKeyedAtomHook(cellHandleAtom);
617
622
 
618
623
  /**
619
624
  * Get mounted editor views only. Read cellData for cells without an editor.
@@ -665,7 +670,10 @@ export function createTracebackInfoAtom(
665
670
  return undefined;
666
671
  }
667
672
 
668
- const { status } = cellExecutionView(get(cellExecutionInputsAtom), cellId);
673
+ const { status } = cellExecutionView(
674
+ get(frameCellExecutionInputsAtom),
675
+ cellId,
676
+ );
669
677
  if (status === "queued" || status === "running") {
670
678
  return undefined;
671
679
  }
@@ -114,8 +114,13 @@ export function consoleObservers(
114
114
  };
115
115
  }
116
116
 
117
- export function consoleExecution(get: Getter, cellId: CellId) {
118
- const replica = get(activeNotebookReplicaAtom);
117
+ export function consoleExecution(
118
+ get: Getter,
119
+ cellId: CellId,
120
+ replica: Pick<NotebookReplica, "executionsAtom"> | null = get(
121
+ activeNotebookReplicaAtom,
122
+ ),
123
+ ) {
119
124
  if (!replica) {
120
125
  return;
121
126
  }
@@ -1,7 +1,11 @@
1
1
  /* Copyright 2026 Marimo. All rights reserved. */
2
2
 
3
+ import { createNotebookReducer } from "@marimo-team/client";
4
+ import { fixtureEvents } from "@/core/notebook/replica/__tests__/fixtures";
5
+ import { executions } from "@/core/notebook/replica/resources/executions";
6
+ import { document as documentResource } from "@/core/notebook/replica/resources/document";
3
7
  import { createStore } from "jotai";
4
- import { describe, expect, it } from "vitest";
8
+ import { describe, expect, it, vi, onTestFinished } from "vitest";
5
9
  import { MockExecutions } from "@/__mocks__/executions";
6
10
  import { cellId, runId } from "@/__tests__/branded";
7
11
  import type * as Protocol from "@marimo-team/client/protocol";
@@ -13,6 +17,14 @@ import type { Executions } from "@/core/notebook/replica";
13
17
  import {
14
18
  acceptRun,
15
19
  cellExecutionInputsAtom,
20
+ cellExecutionAtom,
21
+ cellOutputAtom,
22
+ cellOutputsAtom,
23
+ scratchOutputAtom,
24
+ cellOutputInputsAtom,
25
+ cellOutlineAtom,
26
+ cellFreshnessForAtom,
27
+ releaseCellOutputAtoms,
16
28
  notebookQueuedOrRunningCountAtom,
17
29
  requestRun,
18
30
  type RunRequest,
@@ -20,6 +32,10 @@ import {
20
32
  } from "../atoms";
21
33
  import { cellExecutionView } from "../select";
22
34
 
35
+ import * as selection from "../select";
36
+ import * as output from "../output";
37
+ import * as freshness from "../freshness";
38
+
23
39
  const C1 = cellId("c1");
24
40
  const C2 = cellId("c2");
25
41
 
@@ -219,3 +235,190 @@ describe("acceptRun", () => {
219
235
  expect(statusOf(store)).toBe("queued");
220
236
  });
221
237
  });
238
+
239
+ it.each([25, 500])(
240
+ "does not rebuild views for console-only updates with %s cells",
241
+ (size) => {
242
+ const store = createStore();
243
+ const ids = Array.from({ length: size }, (_, i) => cellId(`cell-${i}`));
244
+ const replica = MockExecutions.seed(
245
+ store,
246
+ ids.map((id) => MockExecutions.completed(id)),
247
+ null,
248
+ documentOf(),
249
+ );
250
+ const executionView = vi.spyOn(selection, "executionView");
251
+ const resultOutput = vi.spyOn(output, "resultOutput");
252
+ const freshnessOf = vi.spyOn(freshness, "freshnessOf");
253
+ const scratchView = vi.spyOn(output, "scratchOutputView");
254
+ onTestFinished(() => {
255
+ vi.restoreAllMocks();
256
+ });
257
+ for (const id of ids) {
258
+ for (const view of [
259
+ cellExecutionAtom(id),
260
+ cellOutputAtom(id),
261
+ cellFreshnessForAtom(id),
262
+ ]) {
263
+ onTestFinished(store.sub(view, () => undefined));
264
+ }
265
+ onTestFinished(() => releaseCellOutputAtoms(id));
266
+ }
267
+ onTestFinished(store.sub(cellOutputsAtom, () => undefined));
268
+ onTestFinished(store.sub(scratchOutputAtom, () => undefined));
269
+ scratchView.mockClear();
270
+ executionView.mockClear();
271
+ resultOutput.mockClear();
272
+ freshnessOf.mockClear();
273
+ const before = store.get(replica.executionsAtom);
274
+ const first = [...before.executions.values()][0];
275
+ store.set(replica.executionsAtom, {
276
+ ...before,
277
+ executions: new Map(before.executions).set(first.record.id, {
278
+ ...first,
279
+ items: new Map(first.items),
280
+ }),
281
+ });
282
+ expect(executionView).not.toHaveBeenCalled();
283
+ expect(resultOutput).not.toHaveBeenCalled();
284
+ expect(freshnessOf).not.toHaveBeenCalled();
285
+ expect(scratchView).not.toHaveBeenCalled();
286
+ const current = store.get(replica.executionsAtom);
287
+ store.set(replica.executionsAtom, {
288
+ ...current,
289
+ executions: new Map(current.executions).set(first.record.id, {
290
+ ...first,
291
+ record: {
292
+ ...first.record,
293
+ state: { status: "running", started_at: "2026-10-01T09:20:13Z" },
294
+ },
295
+ }),
296
+ });
297
+ expect(executionView).toHaveBeenCalledTimes(1);
298
+ expect(scratchView).not.toHaveBeenCalled();
299
+ },
300
+ );
301
+
302
+ it("releases every per-cell atom and reconstructs it from current state", () => {
303
+ const { store } = shown();
304
+ const families = [
305
+ cellExecutionAtom,
306
+ cellOutputAtom,
307
+ cellFreshnessForAtom,
308
+ cellOutlineAtom,
309
+ ];
310
+ const before = families.map((family) => family(C1));
311
+ const values = before.map((view) => store.get<unknown>(view));
312
+ releaseCellOutputAtoms(C1);
313
+ const after = families.map((family) => family(C1));
314
+ after.forEach((view, index) => {
315
+ expect(view).not.toBe(before[index]);
316
+ expect(store.get<unknown>(view)).toEqual(values[index]);
317
+ });
318
+ releaseCellOutputAtoms(C1);
319
+ });
320
+
321
+ it("keeps mounted slices equivalent to the pure views throughout a stream", () => {
322
+ const { store, replica } = shown();
323
+ const ids = [C1, C2, cellId("c3")];
324
+ for (const id of ids) {
325
+ for (const view of [
326
+ cellExecutionAtom(id),
327
+ cellOutputAtom(id),
328
+ cellFreshnessForAtom(id),
329
+ ]) {
330
+ onTestFinished(store.sub(view, () => undefined));
331
+ }
332
+ onTestFinished(() => releaseCellOutputAtoms(id));
333
+ }
334
+ const reducer = createNotebookReducer({
335
+ executions,
336
+ document: documentResource,
337
+ });
338
+ let state = reducer.initial;
339
+ for (const event of [
340
+ ...fixtureEvents("notebook-events.sse"),
341
+ ...fixtureEvents("run-cells.sse"),
342
+ ]) {
343
+ state = reducer.reduce(state, event);
344
+ const { executions, document } = state.resources;
345
+ store.set(replica.documentAtom, document.current);
346
+ store.set(replica.executionsAtom, executions);
347
+ store.set(replica.resultsAtom, executions.results);
348
+ const expectedFreshness = freshness.freshnessOf({
349
+ cells: document.current?.cells ?? new Map(),
350
+ executions,
351
+ results: executions.results,
352
+ });
353
+ for (const id of ids) {
354
+ expect(store.get(cellExecutionAtom(id))).toEqual(
355
+ selection.cellExecutionView(store.get(cellExecutionInputsAtom), id),
356
+ );
357
+ expect(store.get(cellOutputAtom(id))).toEqual(
358
+ output.cellOutputView(store.get(cellOutputInputsAtom), id),
359
+ );
360
+ const expected =
361
+ document.current === null
362
+ ? { sourceChanged: false, inputsChanged: false }
363
+ : expectedFreshness(id);
364
+ expect(store.get(cellFreshnessForAtom(id))).toEqual(expected);
365
+ }
366
+ }
367
+ });
368
+
369
+ it("shares scratch derivation across subscribers and observes results and failures", () => {
370
+ const { store, replica } = shown();
371
+ const derive = vi.spyOn(output, "scratchOutputView");
372
+ onTestFinished(() => {
373
+ derive.mockRestore();
374
+ });
375
+ const first = vi.fn();
376
+ const second = vi.fn();
377
+ onTestFinished(store.sub(scratchOutputAtom, first));
378
+ onTestFinished(store.sub(scratchOutputAtom, second));
379
+ derive.mockClear();
380
+ const scratch = MockExecutions.inputs([
381
+ MockExecutions.shown(null, { mimetype: "text/plain", data: "hello" }),
382
+ ]).executions.scratch;
383
+ store.set(replica.executionsAtom, (state) => ({ ...state, scratch }));
384
+ expect(store.get(scratchOutputAtom)?.data).toBe("hello");
385
+ expect(derive).toHaveBeenCalledTimes(1);
386
+ expect(first).toHaveBeenCalledTimes(1);
387
+ expect(second).toHaveBeenCalledTimes(1);
388
+ store.set(replica.executionsAtom, (state) => ({
389
+ ...state,
390
+ scratchFailure: {
391
+ runId: runId("failed-run"),
392
+ message: "Disconnected",
393
+ completedAt: MockExecutions.T1,
394
+ },
395
+ }));
396
+ expect(store.get(scratchOutputAtom)?.data).toEqual([
397
+ { type: "unknown", msg: "Disconnected", error_type: null },
398
+ ]);
399
+ expect(derive).toHaveBeenCalledTimes(2);
400
+ });
401
+
402
+ it("does not notify an unrelated cell during run transitions", () => {
403
+ const { store, replica } = shown();
404
+ const unrelated = vi.fn();
405
+ const affected = vi.fn();
406
+ onTestFinished(store.sub(cellExecutionAtom(C1), unrelated));
407
+ onTestFinished(store.sub(cellExecutionAtom(C2), affected));
408
+ onTestFinished(() => {
409
+ releaseCellOutputAtoms(C1);
410
+ releaseCellOutputAtoms(C2);
411
+ });
412
+ const before = store.get(cellExecutionAtom(C1));
413
+ for (const status of ["queued", "running", "completed"] as const) {
414
+ store.set(replica.executionsAtom, (state) =>
415
+ withRuns(state, [run([C2], status)]),
416
+ );
417
+ expect(store.get(cellExecutionAtom(C2)).status).toBe(
418
+ status === "completed" ? "idle" : "queued",
419
+ );
420
+ expect(store.get(cellExecutionAtom(C1))).toBe(before);
421
+ expect(unrelated).not.toHaveBeenCalled();
422
+ }
423
+ expect(affected).toHaveBeenCalledTimes(2);
424
+ });