@marimo-team/islands 0.25.3-dev439 → 0.25.3-dev440

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 (26) hide show
  1. package/dist/{ErrorBoundary-B4npV6Uy.js → ErrorBoundary-BmvTbIKd.js} +1 -1
  2. package/dist/assets/__vite-browser-external-CpRgw4M_.js +1 -0
  3. package/dist/assets/worker-BUqfWMtI.js +171 -0
  4. package/dist/{code-visibility-Dx3sTl1s.js → code-visibility-DrVy3Nt1.js} +1 -1
  5. package/dist/{common-Cx3bd6pm.js → common-DolvV945.js} +1 -1
  6. package/dist/{data-grid-overlay-editor-CqMKHPcR.js → data-grid-overlay-editor-CtqDeMah.js} +1 -1
  7. package/dist/{feedback-button-CUPrIFyj.js → feedback-button-DDw8qIfP.js} +2 -2
  8. package/dist/{glide-data-editor-T1r8b4Cr.js → glide-data-editor-B6_KvoZ3.js} +3 -3
  9. package/dist/{globals-BweO1Da5.js → globals-CmfHIWMY.js} +1 -1
  10. package/dist/main.js +58 -43
  11. package/dist/{number-overlay-editor-eynzhDoK.js → number-overlay-editor-DvKc0Woa.js} +1 -1
  12. package/dist/{reveal-component-C-ZgAhoP.js → reveal-component-Cb25blSt.js} +2 -2
  13. package/package.json +1 -1
  14. package/src/core/islands/bootstrap.ts +5 -1
  15. package/src/core/islands/worker/worker.tsx +9 -3
  16. package/src/core/notebook/replica/index.ts +5 -1
  17. package/src/core/notebook/replica/replica.ts +16 -8
  18. package/src/core/session/__tests__/backend.test.ts +20 -1
  19. package/src/core/session/__tests__/useNotebookSession.hook.test.tsx +31 -0
  20. package/src/core/session/backend.ts +4 -2
  21. package/src/core/session/useNotebookReplica.ts +3 -0
  22. package/src/core/static/virtual-file-tracker.ts +20 -5
  23. package/src/core/wasm/worker/types.ts +1 -0
  24. package/src/core/wasm/worker/worker.ts +9 -3
  25. package/dist/assets/__vite-browser-external-C0lHKu4c.js +0 -1
  26. package/dist/assets/worker-ByubE6Ou.js +0 -171
package/dist/main.js CHANGED
@@ -6,7 +6,7 @@ import { i as x, n as S, r as C, t as w } from "./copy-icon-CDvvlY90.js";
6
6
  import { B as T, Bt as E, Ct as D, E as O, F as k, Ft as A, I as j, It as M, L as N, Lt as P, M as F, Mt as I, O as L, Ot as R, P as z, R as B, Rt as ee, St as te, Ut as ne, Vt as re, Wt as ie, X as ae, Z as oe, _ as se, _t as ce, a as le, at as ue, b as de, bt as fe, c as pe, ct as me, dt as he, i as ge, it as _e, j as ve, kt as ye, lt as be, mt as xe, n as Se, o as Ce, ot as we, q as Te, rt as Ee, ut as De, vt as Oe, yt as ke, z as Ae, zt as je } from "./html-to-image-B0UiwmMu.js";
7
7
  import { a as Me, f as Ne, h as Pe, i as Fe, m as Ie, n as Le, o as Re, r as ze, t as Be } from "./tooltip-CiJ919pg.js";
8
8
  import { D as Ve, E as He, S as Ue, T as We, _ as Ge, a as Ke, c as qe, d as Je, f as Ye, g as Xe, h as Ze, i as Qe, l as $e, m as et, n as tt, o as nt, p as rt, r as it, s as at, t as ot, u as st, v as ct, w as lt, x as ut, y as dt } from "./spec-6shN7lEe.js";
9
- import { $t as ft, A as pt, At as mt, B as ht, Bt as gt, C as _t, Cn as vt, Ct as yt, D as bt, Dn as xt, Dt as St, E as Ct, En as wt, Et as Tt, F as Et, Ft as Dt, G as Ot, Gt as kt, H as At, Ht as jt, I as Mt, It as Nt, J as Pt, Jt as Ft, K as It, Kt as Lt, L as Rt, Lt as zt, M as Bt, Mt as Vt, N as Ht, Nt as Ut, O as Wt, On as Gt, Ot as Kt, P as qt, Pt as Jt, Qt as Yt, R as Xt, Rt as Zt, S as Qt, Sn as $t, T as en, Tn as tn, Tt as nn, U as rn, Ut as an, V as on, Vt as sn, W as cn, Wt as ln, X as un, Xt as dn, Y as fn, Yt as pn, Z as mn, Zt as hn, _ as gn, _n, _t as vn, an as yn, at as bn, b as xn, bt as Sn, c as Cn, cn as wn, ct as Tn, d as En, dn as Dn, dt as On, en as kn, f as An, fn as jn, ft as Mn, g as Nn, gn as Pn, gt as Fn, h as In, hn as Ln, ht as Rn, in as zn, it as Bn, j as Vn, jt as Hn, k as Un, kn as Wn, kt as Gn, ln as Kn, lt as qn, m as Jn, mn as Yn, mt as Xn, nn as Zn, nt as Qn, on as $n, ot as er, p as tr, pn as nr, pt as rr, q as ir, qt as ar, r as or, rn as sr, rt as cr, sn as lr, st as ur, t as dr, tn as fr, tt as pr, u as mr, un as hr, ut as gr, v as _r, vn as vr, vt as yr, w as br, wn as xr, wt as Sr, x as Cr, xn as wr, y as Tr, yn as Er, yt as Dr, z as Or, zt as kr } from "./common-Cx3bd6pm.js";
9
+ import { $t as ft, A as pt, At as mt, B as ht, Bt as gt, C as _t, Cn as vt, Ct as yt, D as bt, Dn as xt, Dt as St, E as Ct, En as wt, Et as Tt, F as Et, Ft as Dt, G as Ot, Gt as kt, H as At, Ht as jt, I as Mt, It as Nt, J as Pt, Jt as Ft, K as It, Kt as Lt, L as Rt, Lt as zt, M as Bt, Mt as Vt, N as Ht, Nt as Ut, O as Wt, On as Gt, Ot as Kt, P as qt, Pt as Jt, Qt as Yt, R as Xt, Rt as Zt, S as Qt, Sn as $t, T as en, Tn as tn, Tt as nn, U as rn, Ut as an, V as on, Vt as sn, W as cn, Wt as ln, X as un, Xt as dn, Y as fn, Yt as pn, Z as mn, Zt as hn, _ as gn, _n, _t as vn, an as yn, at as bn, b as xn, bt as Sn, c as Cn, cn as wn, ct as Tn, d as En, dn as Dn, dt as On, en as kn, f as An, fn as jn, ft as Mn, g as Nn, gn as Pn, gt as Fn, h as In, hn as Ln, ht as Rn, in as zn, it as Bn, j as Vn, jt as Hn, k as Un, kn as Wn, kt as Gn, ln as Kn, lt as qn, m as Jn, mn as Yn, mt as Xn, nn as Zn, nt as Qn, on as $n, ot as er, p as tr, pn as nr, pt as rr, q as ir, qt as ar, r as or, rn as sr, rt as cr, sn as lr, st as ur, t as dr, tn as fr, tt as pr, u as mr, un as hr, ut as gr, v as _r, vn as vr, vt as yr, w as br, wn as xr, wt as Sr, x as Cr, xn as wr, y as Tr, yn as Er, yt as Dr, z as Or, zt as kr } from "./common-DolvV945.js";
10
10
  import { a as Ar, n as jr, s as Mr, t as Nr } from "./useLifecycle-mKiMNa4V.js";
11
11
  import { t as Pr } from "./check-CApwK1fD.js";
12
12
  import { A as Fr, C as Ir, D as Lr, M as Rr, O as zr, a as Br, c as Vr, d as Hr, i as Ur, k as Wr, l as Gr, n as Kr, o as qr, r as Jr, s as Yr, t as Xr, w as Zr, x as Qr } from "./select-PQHWLm64.js";
@@ -16,7 +16,7 @@ import { At as Bi, B as Vi, Dt as Hi, E as Ui, Ft as Wi, G as Gi, Ht as Ki, J as
16
16
  import { a as Oa, d as ka, i as Aa, n as ja, o as Ma, r as Na, s as Pa, t as Fa, u as Ia } from "./process-output-3Epq3rw6.js";
17
17
  import { t as La } from "./pencil-BC7pOv9g.js";
18
18
  import { a as Ra, c as za, d as Ba, f as Va, i as Ha, l as Ua, r as Wa } from "./glide-utils-D1McS0Pn.js";
19
- import { n as Ga, t as Ka } from "./globals-BweO1Da5.js";
19
+ import { n as Ga, t as Ka } from "./globals-CmfHIWMY.js";
20
20
  import { a as qa, i as Ja, n as Ya, r as Xa, s as Za, t as Qa } from "./assertNever-DOTNJ2Y4.js";
21
21
  import { t as $a } from "./react-dom-DdqGVp5N.js";
22
22
  import { t as eo } from "./jsx-runtime-D8btoEHk.js";
@@ -40,10 +40,10 @@ import { n as Zs, t as Qs } from "./esm-Bwp_FHP0.js";
40
40
  import { p as $s } from "./dist-DpYpG8Yc.js";
41
41
  import { t as ec } from "./useAsyncData-P5-Oovhq.js";
42
42
  import { n as tc, r as nc, t as rc } from "./useDeepCompareMemoize-CDhinwm7.js";
43
- import { t as ic } from "./ErrorBoundary-B4npV6Uy.js";
43
+ import { t as ic } from "./ErrorBoundary-BmvTbIKd.js";
44
44
  import { G as ac, W as oc } from "./vega-loader.browser-Co9gYE8Z.js";
45
45
  import { a as sc, n as cc } from "./loader-Bin_dutt.js";
46
- import { a as lc, c as uc, i as dc, l as fc, o as pc, s as mc, t as hc } from "./code-visibility-Dx3sTl1s.js";
46
+ import { a as lc, c as uc, i as dc, l as fc, o as pc, s as mc, t as hc } from "./code-visibility-DrVy3Nt1.js";
47
47
  import { t as gc } from "./esm-B9n0caHs.js";
48
48
  //#region ../node_modules/.pnpm/iconify-icon@2.3.0/node_modules/iconify-icon/dist/iconify-icon.mjs
49
49
  var _c = Object.freeze({
@@ -4626,7 +4626,6 @@ var Jg = {
4626
4626
  "runtime",
4627
4627
  "run",
4628
4628
  "execution",
4629
- "input",
4630
4629
  "variable",
4631
4630
  "marimo"
4632
4631
  ], Zg = W({ marimo: Ko() }), Qg = {
@@ -4697,67 +4696,74 @@ function n_(e) {
4697
4696
  connect: x,
4698
4697
  reconnect: async () => _?.reconnect()
4699
4698
  };
4700
- function x(t, { onNotification: i }) {
4699
+ function x(t, { onNotification: i, onExecution: o }) {
4701
4700
  _?.end();
4702
- let o = new AbortController(), { signal: s } = o, l = t.checkHealth ?? (async () => !0);
4701
+ let s = new AbortController(), { signal: l } = s, u = t.checkHealth ?? (async () => !0);
4703
4702
  e.set(g, t);
4704
- let { transport: u } = t, d, f = !1;
4705
- function p(t) {
4703
+ let { transport: d } = t, f, p = !1;
4704
+ function m(t) {
4706
4705
  t === void 0 && v(r.initial);
4707
- let i = new Dg(u, {
4706
+ let i = new Dg(d, {
4708
4707
  types: Xg,
4709
4708
  cursor: t,
4710
- signal: s,
4709
+ signal: l,
4711
4710
  onStatus: (t) => {
4712
4711
  t === "connecting" ? y({ state: oa.CONNECTING }) : t === "connected" && (e.set(n, (e) => e + 1), y({ state: oa.OPEN }));
4713
4712
  }
4714
4713
  });
4715
- i.subscribe((e) => h(i, e), (e) => {
4716
- if (!s.aborted && i === d) {
4714
+ i.subscribe((e) => x(i, e), (e) => {
4715
+ if (!l.aborted && i === f) {
4717
4716
  c.warn("Notebook stream stopped", e);
4718
4717
  let t = t_(e);
4719
- t === $g ? m(i) : y(t);
4718
+ t === $g ? h(i) : y(t);
4720
4719
  }
4721
- }), d = i;
4720
+ }), f = i;
4722
4721
  }
4723
- function m(e) {
4722
+ function h(e) {
4724
4723
  e.close(), b($g);
4725
4724
  }
4726
- function h(t, o) {
4727
- if (o.event === "marimo") {
4728
- let e = Zg.safeParse(o.data);
4729
- e.success ? i(e.data.marimo) : (c.error("Failed to decode notebook message", o), m(t));
4730
- } else try {
4731
- v(r.reduce(e.get(a), o)), o.event === "reset" && e.set(n, (e) => e + 1);
4732
- } catch (e) {
4733
- c.error("Failed to apply notebook event", e), m(t);
4734
- return;
4725
+ function x(t, s) {
4726
+ if (s.event === "marimo") {
4727
+ let e = Zg.safeParse(s.data);
4728
+ e.success ? i(e.data.marimo) : (c.error("Failed to decode notebook message", s), h(t));
4729
+ } else {
4730
+ try {
4731
+ v(r.reduce(e.get(a), s)), s.event === "reset" && e.set(n, (e) => e + 1);
4732
+ } catch (e) {
4733
+ c.error("Failed to apply notebook event", e), h(t);
4734
+ return;
4735
+ }
4736
+ if (s.event === "execution" && o) try {
4737
+ o(s.data.execution);
4738
+ } catch (e) {
4739
+ c.error("Failed to handle execution update", e);
4740
+ }
4735
4741
  }
4736
4742
  }
4737
- let x = {
4743
+ let S = {
4738
4744
  end: () => {
4739
- s.aborted || (o.abort(), _ === x && (_ = void 0, e.set(g, null)), b({ state: oa.NOT_STARTED }));
4745
+ l.aborted || (s.abort(), _ === S && (_ = void 0, e.set(g, null)), b({ state: oa.NOT_STARTED }));
4740
4746
  },
4741
4747
  reconnect: async () => {
4742
- if (!(s.aborted || f || d?.status !== "closed")) {
4743
- f = !0, y({ state: oa.CONNECTING });
4748
+ if (!(l.aborted || p || f?.status !== "closed")) {
4749
+ p = !0, y({ state: oa.CONNECTING });
4744
4750
  try {
4745
- let t = await l();
4746
- if (s.aborted) return;
4751
+ let t = await u();
4752
+ if (l.aborted) return;
4747
4753
  if (!t) {
4748
4754
  y(Qg);
4749
4755
  return;
4750
4756
  }
4751
- p(e.get(a).phase === "snapshot" ? void 0 : d.cursor ?? void 0);
4757
+ m(e.get(a).phase === "snapshot" ? void 0 : f.cursor ?? void 0);
4752
4758
  } catch (e) {
4753
- s.aborted || (c.error("Notebook health check failed", e), y(Qg));
4759
+ l.aborted || (c.error("Notebook health check failed", e), y(Qg));
4754
4760
  } finally {
4755
- f = !1;
4761
+ p = !1;
4756
4762
  }
4757
4763
  }
4758
4764
  }
4759
4765
  };
4760
- return _ = x, y({ state: oa.CONNECTING }), p(), x.end;
4766
+ return _ = S, y({ state: oa.CONNECTING }), m(), S.end;
4761
4767
  }
4762
4768
  }
4763
4769
  //#endregion
@@ -12959,7 +12965,7 @@ function mO(e, t) {
12959
12965
  }
12960
12966
  //#endregion
12961
12967
  //#region src/plugins/impl/DataEditorPlugin.tsx
12962
- var hO = J.lazy(() => import("./glide-data-editor-T1r8b4Cr.js").then((e) => e.t)), gO = XE("marimo-data-editor", { cssStyles: [yD, bD] }).withData(W({
12968
+ var hO = J.lazy(() => import("./glide-data-editor-B6_KvoZ3.js").then((e) => e.t)), gO = XE("marimo-data-editor", { cssStyles: [yD, bD] }).withData(W({
12963
12969
  initialValue: W({ edits: V(W({
12964
12970
  rowIdx: G(),
12965
12971
  columnId: K(),
@@ -32682,7 +32688,7 @@ function _U(e) {
32682
32688
  }
32683
32689
  //#endregion
32684
32690
  //#region src/components/editor/renderers/slides-layout/slides-layout.tsx
32685
- var vU = J.lazy(() => import("./reveal-component-C-ZgAhoP.js")), yU = (e) => {
32691
+ var vU = J.lazy(() => import("./reveal-component-Cb25blSt.js")), yU = (e) => {
32686
32692
  let t = (0, X.c)(33), { layout: n, setLayout: r, cells: i, mode: a } = e, o = To(zs), s = a === "read" || o, c = To(ua) > 1, [l, u] = (0, J.useState)(null), d;
32687
32693
  t[0] !== i || t[1] !== n ? (d = hz(i, n), t[0] = i, t[1] = n, t[2] = d) : d = t[2];
32688
32694
  let { slideCells: f, skippedIds: p, noOutputIds: m, slideTypes: h, startCellIndex: g } = d, _;
@@ -33285,12 +33291,18 @@ var YU = /\/@file\/([^\s"&'/]+)\.([\dA-Za-z]+)/g, XU = class e {
33285
33291
  virtualFiles = /* @__PURE__ */ new Map();
33286
33292
  constructor() {}
33287
33293
  track(e) {
33288
- let t = e.output, n = e.cell_id;
33289
- if (t) switch (t.mimetype) {
33294
+ e.output && this.trackValue(e.cell_id, e.output);
33295
+ }
33296
+ trackExecution(e) {
33297
+ let t = e.outcome?.kind === "value" ? e.outcome.display : null;
33298
+ t && this.trackValue(e.cell_id ?? "__scratch__", t);
33299
+ }
33300
+ trackValue(e, t) {
33301
+ switch (t.mimetype) {
33290
33302
  case "application/json":
33291
33303
  case "text/html": {
33292
- let e = this.virtualFiles.get(n), r = ZU(t.data);
33293
- e?.forEach((e) => r.add(e)), this.virtualFiles.set(n, r);
33304
+ let n = this.virtualFiles.get(e), r = ZU(t.data);
33305
+ n?.forEach((e) => r.add(e)), this.virtualFiles.set(e, r);
33294
33306
  return;
33295
33307
  }
33296
33308
  default: return;
@@ -34311,7 +34323,10 @@ async function lG(e) {
34311
34323
  uG(e, o, t, n);
34312
34324
  });
34313
34325
  let s = n_(t);
34314
- s.connect(r.notebookBackend, { onNotification: a.NOOP }), t.set(so, s);
34326
+ s.connect(r.notebookBackend, {
34327
+ onNotification: a.NOOP,
34328
+ onExecution: (e) => XU.INSTANCE.trackExecution(e)
34329
+ }), t.set(so, s);
34315
34330
  let l = qx({
34316
34331
  store: t,
34317
34332
  documentAtom: s.documentAtom,
@@ -34630,7 +34645,7 @@ function CG(e, t) {
34630
34645
  }
34631
34646
  //#endregion
34632
34647
  //#region src/core/islands/worker/worker.tsx?worker&url
34633
- var wG = "/assets/worker-ByubE6Ou.js", TG = class {
34648
+ var wG = "/assets/worker-BUqfWMtI.js", TG = class {
34634
34649
  url;
34635
34650
  name;
34636
34651
  constructor(e = {}) {
@@ -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 { a as n } from "./glide-data-editor-T1r8b4Cr.js";
3
+ import { a as n } from "./glide-data-editor-B6_KvoZ3.js";
4
4
  //#region ../node_modules/.pnpm/@glideapps+glide-data-grid@6.0.4-alpha24_lodash@4.17.21_marked@15.0.12_react-dom@19.3.1_57c124ac5a994dbbf13fd11838cf9ba9/node_modules/@glideapps/glide-data-grid/dist/esm/internal/data-grid-overlay-editor/private/number-overlay-editor-style.js
5
5
  var r = /* @__PURE__ */ e(t()), i = /*#__PURE__*/ n("div")({
6
6
  name: "NumberOverlayEditorStyle",
@@ -3,7 +3,7 @@ import { g as t, h as n, i as r, m as i, t as a } from "./button-qQhINE7z.js";
3
3
  import { t as o } from "./react-Bgs_wQh3.js";
4
4
  import { t as s } from "./compiler-runtime-C5KHtL5D.js";
5
5
  import { h as c, t as l } from "./tooltip-CiJ919pg.js";
6
- import { $ as u, Cn as d, Q as f, bn as p, cn as m, et as h, i as g, l as _, n as v, r as y, t as b, u as x, yn as S } from "./common-Cx3bd6pm.js";
6
+ import { $ as u, Cn as d, Q as f, bn as p, cn as m, et as h, i as g, l as _, n as v, r as y, t as b, u as x, yn as S } from "./common-DolvV945.js";
7
7
  import { M as C } from "./select-PQHWLm64.js";
8
8
  import { X as ee } from "./dropdown-menu-B12Nf3Zf.js";
9
9
  import { Nt as w } from "./error-entries-CNB7O2yS.js";
@@ -11,7 +11,7 @@ import { t as T } from "./jsx-runtime-D8btoEHk.js";
11
11
  import { Rt as E, Vt as D, f as O, i as k } from "./use-restore-focus-BLj45Ibw.js";
12
12
  import { t as A } from "./useEvent-BoN7U38T.js";
13
13
  import { o as te } from "./static-state-CWXd6dYX.js";
14
- import { n as ne, t as re } from "./code-visibility-Dx3sTl1s.js";
14
+ import { n as ne, t as re } from "./code-visibility-DrVy3Nt1.js";
15
15
  /* empty css */
16
16
  var j = c("sticky-note", [["path", {
17
17
  d: "M21 9a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 15 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2z",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marimo-team/islands",
3
- "version": "0.25.3-dev439",
3
+ "version": "0.25.3-dev440",
4
4
  "main": "dist/main.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
@@ -40,6 +40,7 @@ import {
40
40
  activeDocumentModelAtom,
41
41
  activeNotebookReplicaAtom,
42
42
  } from "../session/active-notebook";
43
+ import { VirtualFileTracker } from "../static/virtual-file-tracker";
43
44
  import { store as defaultStore } from "../state/jotai";
44
45
  import type { IslandsPyodideBridge } from "./bridge";
45
46
  import { MarimoIslandElement } from "./components/web-components";
@@ -135,7 +136,10 @@ export async function initializeIslands(
135
136
 
136
137
  // The notebook's cells follow the managed session's host document.
137
138
  const replica = createNotebookReplica(store);
138
- replica.connect(bridge.notebookBackend, { onNotification: Functions.NOOP });
139
+ replica.connect(bridge.notebookBackend, {
140
+ onNotification: Functions.NOOP,
141
+ onExecution: (record) => VirtualFileTracker.INSTANCE.trackExecution(record),
142
+ });
139
143
  store.set(activeNotebookReplicaAtom, replica);
140
144
  const documentModel = createDocumentModel({
141
145
  store,
@@ -1,6 +1,7 @@
1
1
  /* Copyright 2026 Marimo. All rights reserved. */
2
2
 
3
3
  import type { unstable_NotebookCall } from "@marimo-team/client";
4
+ import { EDITOR_EVENT_TYPES } from "@/core/notebook/replica";
4
5
  import type { PyodideInterface } from "pyodide";
5
6
  import {
6
7
  createRPC,
@@ -141,9 +142,14 @@ async function follow(
141
142
  ): Promise<void> {
142
143
  const notebook = bridge.notebook;
143
144
  try {
144
- await notebook.subscribe(`island-${sessionGeneration}`, null, (event) => {
145
- rpc.send.notebookEvent({ event, sessionGeneration });
146
- });
145
+ await notebook.subscribe(
146
+ `island-${sessionGeneration}`,
147
+ null,
148
+ (event) => {
149
+ rpc.send.notebookEvent({ event, sessionGeneration });
150
+ },
151
+ EDITOR_EVENT_TYPES.join(","),
152
+ );
147
153
  } finally {
148
154
  notebook.destroy();
149
155
  }
@@ -9,7 +9,11 @@ export {
9
9
  ConnectionState,
10
10
  type ConnectionStatus,
11
11
  } from "./connection";
12
- export { createNotebookReplica, type NotebookReplica } from "./replica";
12
+ export {
13
+ EDITOR_EVENT_TYPES,
14
+ createNotebookReplica,
15
+ type NotebookReplica,
16
+ } from "./replica";
13
17
  export type { Document } from "./resources/document";
14
18
  export {
15
19
  type Execution,
@@ -11,6 +11,7 @@ import {
11
11
  } from "@marimo-team/client";
12
12
  import type {
13
13
  Attachment,
14
+ Execution as HostExecution,
14
15
  NotebookOutput,
15
16
  Runtime,
16
17
  } from "@marimo-team/client/protocol";
@@ -35,10 +36,9 @@ import { runtime } from "./resources/runtime";
35
36
  /**
36
37
  * The kinds the editor reads, with marimo's own notifications.
37
38
  *
38
- * Console and display items stay out until the editor reads outputs from
39
- * the replica. The native notifications still carry them.
39
+ * Console, display and stdin still render from the native console (MO-8405).
40
40
  */
41
- const TYPES = [
41
+ export const EDITOR_EVENT_TYPES = [
42
42
  "notebook",
43
43
  "cell",
44
44
  "document",
@@ -46,12 +46,11 @@ const TYPES = [
46
46
  "runtime",
47
47
  "run",
48
48
  "execution",
49
- "input",
50
49
  "variable",
51
50
  "marimo",
52
51
  ] as const;
53
52
 
54
- type EditorEvent = NotebookEvent<(typeof TYPES)[number]>;
53
+ type EditorEvent = NotebookEvent<(typeof EDITOR_EVENT_TYPES)[number]>;
55
54
 
56
55
  /** A native marimo notification, passed through without interpretation. */
57
56
  const MarimoMessage = z.object({ marimo: z.unknown() });
@@ -116,6 +115,8 @@ export interface NotebookReplica {
116
115
  options: {
117
116
  /** Handle a native marimo notification. Its payload has not been validated. */
118
117
  onNotification: (notification: unknown) => void;
118
+ /** Observe execution records as they arrive, including retained values on reconnect. */
119
+ onExecution?: (record: HostExecution) => void;
119
120
  },
120
121
  ): () => void;
121
122
  /** Restore the current connection after its stream closed, if the host is healthy. */
@@ -275,7 +276,7 @@ export function createNotebookReplica(
275
276
 
276
277
  function connect(
277
278
  connected: NotebookBackend,
278
- { onNotification }: { onNotification: (notification: unknown) => void },
279
+ { onNotification, onExecution }: Parameters<NotebookReplica["connect"]>[1],
279
280
  ) {
280
281
  current?.end();
281
282
  const lifetime = new AbortController();
@@ -283,7 +284,7 @@ export function createNotebookReplica(
283
284
  const checkHealth = connected.checkHealth ?? (async () => true);
284
285
  store.set(backendAtom, connected);
285
286
  const { transport } = connected;
286
- let events: NotebookEvents<(typeof TYPES)[number]> | undefined;
287
+ let events: NotebookEvents<(typeof EDITOR_EVENT_TYPES)[number]> | undefined;
287
288
  let checkingHealth = false;
288
289
 
289
290
  /** Mirror one stream into the atoms until it closes. */
@@ -292,7 +293,7 @@ export function createNotebookReplica(
292
293
  setStream(reducer.initial);
293
294
  }
294
295
  const current = new NotebookEvents(transport, {
295
- types: TYPES,
296
+ types: EDITOR_EVENT_TYPES,
296
297
  cursor,
297
298
  signal,
298
299
  // TODO(MO-8051): Gate editing and running on the notebook's operations
@@ -352,6 +353,13 @@ export function createNotebookReplica(
352
353
  stopMalformed(source);
353
354
  return;
354
355
  }
356
+ if (event.event === "execution" && onExecution) {
357
+ try {
358
+ onExecution(event.data.execution);
359
+ } catch (error) {
360
+ Logger.error("Failed to handle execution update", error);
361
+ }
362
+ }
355
363
  }
356
364
 
357
365
  const reconnect = async () => {
@@ -63,7 +63,9 @@ describe("createEditorBackend", () => {
63
63
  wasm.enabled = expected === "wasm";
64
64
  const worker = vi.fn(() => new Promise<void>(() => undefined));
65
65
  wasm.create.mockResolvedValue(fakeBackend({ transport: worker }));
66
- const fetch = vi.fn(() => new Promise<Response>(() => undefined));
66
+ const fetch = vi.fn(
67
+ (_url: RequestInfo | URL) => new Promise<Response>(() => undefined),
68
+ );
67
69
  const opened = sockets();
68
70
  vi.stubGlobal("fetch", fetch);
69
71
  const events = new NotebookEvents(createEditorBackend(chosen).transport);
@@ -77,6 +79,23 @@ describe("createEditorBackend", () => {
77
79
  }[expected],
78
80
  ).toBe(true),
79
81
  );
82
+ const networkUrl = opened[0] ?? fetch.mock.calls[0]?.[0];
83
+ const kinds =
84
+ networkUrl === undefined
85
+ ? undefined
86
+ : new URL(String(networkUrl)).searchParams.get("types")?.split(",");
87
+ const executionKinds = [
88
+ "execution",
89
+ "console",
90
+ "display",
91
+ "input",
92
+ "marimo",
93
+ ];
94
+ expect(executionKinds.filter((kind) => kinds?.includes(kind))).toEqual(
95
+ expected === "socket" || expected === "fetch"
96
+ ? ["execution", "marimo"]
97
+ : [],
98
+ );
80
99
  events.close();
81
100
  });
82
101
 
@@ -59,6 +59,8 @@ import {
59
59
  fixtureEvents,
60
60
  fixtureMessages,
61
61
  } from "../../notebook/replica/__tests__/fixtures";
62
+ import { MockExecutions } from "@/__mocks__/executions";
63
+ import { VirtualFileTracker } from "@/core/static/virtual-file-tracker";
62
64
  import { useNotebookSession } from "../useNotebookSession";
63
65
  import { type NotebookTransport, StreamStopped } from "@marimo-team/client";
64
66
 
@@ -457,6 +459,35 @@ it("does not mark the session connected on kernel-ready alone", async () => {
457
459
  expect(store.get(connectionAtom).state).toBe(ConnectionState.CONNECTING);
458
460
  });
459
461
 
462
+ it("tracks exported files from host execution values", async () => {
463
+ const store = createStore();
464
+ const fake = withTransport();
465
+ vi.mocked(useRuntimeManager).mockReturnValue(makeRuntimeManager());
466
+ renderConnectionHook(store);
467
+ await started();
468
+ const conn = connection(fake);
469
+ await act(async () => conn.open());
470
+ act(() => conn.ready());
471
+ const id = cellId("c1");
472
+ const file = "/@file/stream-image.png";
473
+ const record = MockExecutions.completed(id, {
474
+ outcome: {
475
+ kind: "value",
476
+ display: { mimetype: "text/html", data: `<img src="${file}">` },
477
+ },
478
+ });
479
+ act(() =>
480
+ conn.receive({
481
+ event: "execution",
482
+ id: "updated",
483
+ data: { execution: record },
484
+ }),
485
+ );
486
+ expect(VirtualFileTracker.INSTANCE.filenames()).toContain(file);
487
+ act(() => conn.send({ op: "remove-ui-elements", cell_id: id }));
488
+ expect(VirtualFileTracker.INSTANCE.filenames()).not.toContain(file);
489
+ });
490
+
460
491
  it("replaces gutter breakpoints with the session's replayed state", async () => {
461
492
  const store = createStore();
462
493
  const staleCell = cellId("stale");
@@ -4,7 +4,7 @@
4
4
 
5
5
  import { NotebookClient, StreamStopped } from "@marimo-team/client";
6
6
  import type { NotebookId } from "@marimo-team/client/protocol";
7
- import type { NotebookBackend } from "../notebook/replica";
7
+ import { EDITOR_EVENT_TYPES, type NotebookBackend } from "../notebook/replica";
8
8
  import { PyodideBridge } from "../wasm/bridge";
9
9
  import { isWasm } from "../wasm/utils";
10
10
  import { sessionSse, websocket, withHeaders } from "../transports/server";
@@ -59,7 +59,9 @@ function afterStartup({
59
59
  });
60
60
  }
61
61
  }
62
- return url();
62
+ const target = new URL(url());
63
+ target.searchParams.set("types", EDITOR_EVENT_TYPES.join(","));
64
+ return target;
63
65
  };
64
66
  }
65
67
 
@@ -13,6 +13,7 @@ import {
13
13
  createNotebookReplica,
14
14
  type NotebookReplica,
15
15
  } from "../notebook/replica";
16
+ import { VirtualFileTracker } from "../static/virtual-file-tracker";
16
17
  import { activeNotebookReplicaAtom } from "./active-notebook";
17
18
  import { createEditorBackend, type EditorBackendOptions } from "./backend";
18
19
 
@@ -58,6 +59,8 @@ export function useNotebookReplica(options: Options): NotebookReplica {
58
59
  useEffect(() => {
59
60
  store.set(activeNotebookReplicaAtom, replica);
60
61
  const disconnect = replica.connect(backend, {
62
+ onExecution: (record) =>
63
+ VirtualFileTracker.INSTANCE.trackExecution(record),
61
64
  // The host validates the envelope, not the native notification contents.
62
65
  onNotification: (notification) =>
63
66
  onNotification({ data: notification as NotificationMessage }),
@@ -1,6 +1,7 @@
1
1
  /* Copyright 2026 Marimo. All rights reserved. */
2
2
 
3
- import type { CellId } from "../cells/ids";
3
+ import type { Execution } from "@marimo-team/client/protocol";
4
+ import { type CellId, SCRATCH_CELL_ID } from "../cells/ids";
4
5
  import type { CellMessage } from "../kernel/messages";
5
6
 
6
7
  // Virtual files are of the form /@file/<file-name>.<extension>
@@ -28,12 +29,26 @@ export class VirtualFileTracker {
28
29
  }
29
30
 
30
31
  public track(message: Pick<CellMessage, "cell_id" | "output">): void {
31
- const output = message.output;
32
- const cellId = message.cell_id;
33
- if (!output) {
34
- return;
32
+ if (message.output) {
33
+ this.trackValue(message.cell_id, message.output);
35
34
  }
35
+ }
36
+
37
+ public trackExecution(record: Execution): void {
38
+ const value =
39
+ record.outcome?.kind === "value" ? record.outcome.display : null;
40
+ if (value) {
41
+ this.trackValue(
42
+ (record.cell_id as CellId | null) ?? SCRATCH_CELL_ID,
43
+ value,
44
+ );
45
+ }
46
+ }
36
47
 
48
+ private trackValue(
49
+ cellId: CellId,
50
+ output: { mimetype: string; data: unknown },
51
+ ): void {
37
52
  switch (output.mimetype) {
38
53
  case "application/json":
39
54
  case "text/html": {
@@ -121,6 +121,7 @@ export type SerializedBridge = {
121
121
  id: string,
122
122
  cursor: string | null,
123
123
  emit: (event: string) => void,
124
+ types?: string,
124
125
  ): Promise<void>;
125
126
  unsubscribe(id: string): void;
126
127
  call(call: string): Promise<string>;
@@ -1,6 +1,7 @@
1
1
  /* Copyright 2026 Marimo. All rights reserved. */
2
2
 
3
3
  import type { unstable_NotebookCall } from "@marimo-team/client";
4
+ import { EDITOR_EVENT_TYPES } from "@/core/notebook/replica";
4
5
  import type { PyodideInterface } from "pyodide";
5
6
  import {
6
7
  createRPC,
@@ -115,9 +116,14 @@ const requestHandler = createRPCRequestHandler({
115
116
  const session = await sessionReady.promise;
116
117
  const notebook = session.bridge.notebook;
117
118
  try {
118
- await notebook.subscribe(request.id, request.cursor, (event) => {
119
- rpc.send.notebookEvent({ id: request.id, event });
120
- });
119
+ await notebook.subscribe(
120
+ request.id,
121
+ request.cursor,
122
+ (event) => {
123
+ rpc.send.notebookEvent({ id: request.id, event });
124
+ },
125
+ EDITOR_EVENT_TYPES.join(","),
126
+ );
121
127
  if (!canceled) {
122
128
  void session.start().catch((error: unknown) => {
123
129
  rpc.send.initializedError({ error: prettyError(error) });
@@ -1 +0,0 @@
1
- import{t as e}from"./worker-ByubE6Ou.js";var t=/* @__PURE__ */ e(((e,t)=>{t.exports={}}));export default t();