@marimo-team/islands 0.25.3-dev481 → 0.25.3-dev485

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 (38) hide show
  1. package/dist/{ErrorBoundary-VEwPi06B.js → ErrorBoundary-CodLzVG5.js} +1 -1
  2. package/dist/assets/__vite-browser-external-DZv_7F5P.js +1 -0
  3. package/dist/assets/{worker-DFvnFhLF.js → worker-cHYZNFD4.js} +2 -2
  4. package/dist/{chat-ui-LeUI9zli.js → chat-ui-Covffkhg.js} +7 -7
  5. package/dist/{code-visibility-D3Fzysn4.js → code-visibility-BauZWifR.js} +11 -11
  6. package/dist/{common-rNx_NjSU.js → common-DeBx86ld.js} +14 -14
  7. package/dist/{data-grid-overlay-editor-JtuxaR3K.js → data-grid-overlay-editor-BzEmIb3z.js} +1 -1
  8. package/dist/{error-entries--YT1ZOUW.js → error-entries-C4OopOce.js} +81 -62
  9. package/dist/{feedback-button-DLq5Sxk0.js → feedback-button-BTYGJiow.js} +135 -135
  10. package/dist/{glide-data-editor-DTvqUeZ9.js → glide-data-editor-Bcy2IE3H.js} +3 -3
  11. package/dist/{globals-DVNWDe7Y.js → globals-9AyCoAnh.js} +1 -1
  12. package/dist/{html-to-image-BMt1erSy.js → html-to-image-95V1hWZu.js} +32 -32
  13. package/dist/main.js +6048 -6020
  14. package/dist/{number-overlay-editor-CZ_t156n.js → number-overlay-editor-aEdDUAzH.js} +1 -1
  15. package/dist/{process-output-CNBGRz3r.js → process-output-DPHxrq7D.js} +2 -2
  16. package/dist/{reveal-component-glqW2Ys5.js → reveal-component-_1Vpg1lV.js} +2 -2
  17. package/package.json +1 -1
  18. package/src/__mocks__/executions.ts +2 -0
  19. package/src/__tests__/CellStatus.test.tsx +3 -3
  20. package/src/components/editor/cell/CellStatus.tsx +23 -38
  21. package/src/components/editor/notebook-cell.tsx +1 -1
  22. package/src/components/slides/slide-cell-view.tsx +1 -1
  23. package/src/core/executions/__tests__/atoms.test.ts +1 -41
  24. package/src/core/executions/__tests__/output-lifecycle.test.ts +1 -5
  25. package/src/core/executions/__tests__/select.test.ts +34 -2
  26. package/src/core/executions/atoms.ts +16 -31
  27. package/src/core/executions/hooks.ts +2 -3
  28. package/src/core/executions/index.ts +0 -1
  29. package/src/core/executions/select.ts +55 -2
  30. package/src/core/islands/bootstrap.ts +0 -8
  31. package/src/core/notebook/replica/replica.ts +50 -3
  32. package/src/core/notebook/replica/resources/analysis.ts +9 -0
  33. package/src/core/session/__tests__/backend.test.ts +3 -12
  34. package/src/core/session/__tests__/useNotebookSession.hook.test.tsx +84 -0
  35. package/src/core/session/backend.ts +4 -4
  36. package/src/core/session/useNotebookSession.tsx +0 -8
  37. package/src/stories/cell-status.stories.tsx +6 -6
  38. package/dist/assets/__vite-browser-external-DoIBUY2I.js +0 -1
@@ -10,6 +10,7 @@ import {
10
10
  StreamStopped,
11
11
  } from "@marimo-team/client";
12
12
  import type {
13
+ Analysis,
13
14
  Attachment,
14
15
  Execution as HostExecution,
15
16
  Output as HostOutput,
@@ -24,6 +25,7 @@ import {
24
25
  ConnectionState,
25
26
  type ConnectionStatus,
26
27
  } from "./connection";
28
+ import { analysis } from "./resources/analysis";
27
29
  import { attachments } from "./resources/attachments";
28
30
  import { type Document, document } from "./resources/document";
29
31
  import {
@@ -52,6 +54,7 @@ export const EDITOR_EVENT_KINDS = [
52
54
  "input",
53
55
  "output",
54
56
  "variable",
57
+ "analysis",
55
58
  "marimo",
56
59
  ] as const;
57
60
 
@@ -60,6 +63,30 @@ type EditorEvent = NotebookStreamEvent<(typeof EDITOR_EVENT_KINDS)[number]>;
60
63
  /** A native marimo notification, passed through without interpretation. */
61
64
  const MarimoMessage = z.object({ marimo: z.unknown() });
62
65
 
66
+ interface AnalysisView {
67
+ readonly freshness: "current" | "stale";
68
+ readonly analysis: Analysis;
69
+ readonly document: Document;
70
+ }
71
+
72
+ function analysisView(
73
+ previous: AnalysisView | null,
74
+ document: Document | null,
75
+ analysis: Analysis | null,
76
+ ): AnalysisView | null {
77
+ if (document === null) {
78
+ return null;
79
+ }
80
+ if (analysis?.document_etag === document.revision.etag) {
81
+ return previous?.analysis === analysis && previous.freshness === "current"
82
+ ? previous
83
+ : { freshness: "current", document, analysis };
84
+ }
85
+ return previous?.freshness === "current"
86
+ ? { ...previous, freshness: "stale" }
87
+ : previous;
88
+ }
89
+
63
90
  /** A notebook as its backend's stream reports it, kept current while connected. */
64
91
  export interface NotebookReplica {
65
92
  /** Connection status, independent of application session readiness. */
@@ -77,6 +104,8 @@ export interface NotebookReplica {
77
104
  * submit against this one.
78
105
  */
79
106
  readonly documentAtom: Atom<Document | null>;
107
+ /** Last analysis paired with its document. Only current analysis can gate actions. */
108
+ readonly analysisAtom: Atom<AnalysisView | null>;
80
109
  /**
81
110
  * The document on show: `documentAtom`, or through a reset, the one it
82
111
  * replaced until the snapshot that follows is complete.
@@ -176,6 +205,7 @@ export function createNotebookReplica(
176
205
  // One atom holds the whole stream, which resource atoms derive from.
177
206
  const reducer = createNotebookReducer({
178
207
  document,
208
+ analysis,
179
209
  attachments,
180
210
  runtime,
181
211
  executions,
@@ -189,9 +219,14 @@ export function createNotebookReplica(
189
219
  * whose session changed. Showing the new snapshot as it arrives would
190
220
  * empty every view for as long as that takes.
191
221
  */
192
- const followedAtom = atom<{ stream: Stream; retained: Stream | null }>({
222
+ const followedAtom = atom<{
223
+ stream: Stream;
224
+ retained: Stream | null;
225
+ analyzed: AnalysisView | null;
226
+ }>({
193
227
  stream: reducer.initial,
194
228
  retained: null,
229
+ analyzed: null,
195
230
  });
196
231
  const streamAtom = atom((get) => get(followedAtom).stream);
197
232
  const shownAtom = atom((get) => {
@@ -209,6 +244,7 @@ export function createNotebookReplica(
209
244
  const documentAtom = atom(
210
245
  (get) => get(streamAtom).resources.document.current,
211
246
  );
247
+ const analysisAtom = atom((get) => get(followedAtom).analyzed);
212
248
  const shownDocumentAtom = atom(
213
249
  (get) => get(shownAtom).resources.document.current,
214
250
  );
@@ -247,10 +283,16 @@ export function createNotebookReplica(
247
283
  },
248
284
  };
249
285
  }
250
- return { stream: next, retained: null };
286
+ const { analysis, document } = next.resources;
287
+ return {
288
+ stream: next,
289
+ retained: null,
290
+ analyzed: analysisView(followed.analyzed, document.current, analysis),
291
+ };
251
292
  }
252
293
  return {
253
294
  stream: next,
295
+ analyzed: null,
254
296
  retained: stream.phase === "snapshot" ? retained : stream,
255
297
  };
256
298
  });
@@ -265,7 +307,11 @@ export function createNotebookReplica(
265
307
 
266
308
  /** Drop what the stream reported and show `status`. */
267
309
  function clear(status: ConnectionStatus) {
268
- store.set(followedAtom, { stream: reducer.initial, retained: null });
310
+ store.set(followedAtom, {
311
+ stream: reducer.initial,
312
+ retained: null,
313
+ analyzed: null,
314
+ });
269
315
  setStatus(status);
270
316
  }
271
317
 
@@ -274,6 +320,7 @@ export function createNotebookReplica(
274
320
  generationAtom,
275
321
  notebookAtom,
276
322
  documentAtom,
323
+ analysisAtom,
277
324
  shownDocumentAtom,
278
325
  backendAtom,
279
326
  attachmentsAtom,
@@ -0,0 +1,9 @@
1
+ /* Copyright 2026 Marimo. All rights reserved. */
2
+
3
+ import type { NotebookResource } from "@marimo-team/client";
4
+ import type { Analysis } from "@marimo-team/client/protocol";
5
+
6
+ export const analysis: NotebookResource<Analysis | null, "analysis"> = {
7
+ initial: null,
8
+ on: { analysis: (_state, { data }) => data.analysis },
9
+ };
@@ -80,20 +80,11 @@ describe("createEditorBackend", () => {
80
80
  ).toBe(true),
81
81
  );
82
82
  const networkUrl = opened[0] ?? fetch.mock.calls[0]?.[0];
83
- const kinds =
83
+ const params =
84
84
  networkUrl === undefined
85
85
  ? undefined
86
- : new URL(String(networkUrl)).searchParams.get("kinds")?.split(",");
87
- const executionKinds = [
88
- "execution",
89
- "console",
90
- "output",
91
- "input",
92
- "marimo",
93
- ];
94
- expect(executionKinds.filter((kind) => kinds?.includes(kind))).toEqual(
95
- expected === "socket" || expected === "fetch" ? executionKinds : [],
96
- );
86
+ : new URL(String(networkUrl)).searchParams;
87
+ expect(params?.has("kinds")).toBeFalsy();
97
88
  events.close();
98
89
  });
99
90
 
@@ -54,6 +54,12 @@ import { ConnectionNotice } from "@/components/editor/alerts/connection-notice";
54
54
  import { kernelStartupErrorAtom } from "@/core/errors/state";
55
55
  import type { NotificationPayload } from "@/core/kernel/messages";
56
56
  import { useRuntimeManager } from "@/core/runtime/config";
57
+ import { cellExecutionInputsAtom, cellExecutionView } from "@/core/executions";
58
+ import {
59
+ cell,
60
+ CONFIG,
61
+ document as documentOf,
62
+ } from "@/core/notebook/document/__tests__/fixtures";
57
63
  import { initialRunCompletedAtom } from "../../kernel/state";
58
64
  import { connectionAtom, startupProgressAtom } from "../../network/connection";
59
65
  import { generateSessionId } from "../../kernel/session";
@@ -353,6 +359,84 @@ describe("useNotebookSession messages", () => {
353
359
  act(() => connection(fake).receive(payload));
354
360
  }
355
361
 
362
+ it("keeps the last blocked indicator across edits until the host replaces the graph", () => {
363
+ const revision = documentOf().revision;
364
+ const graph = { a: [], b: ["a"], c: ["b"], d: [] };
365
+ function publish(version: number) {
366
+ const codes = {
367
+ a: "x = 1",
368
+ b: version < 3 ? "y = x" : "y = 0",
369
+ c: "print(y)",
370
+ d: version === 1 ? "0" : "1",
371
+ };
372
+ for (const [id, code] of Object.entries(codes)) {
373
+ const record = cell(id, code, {
374
+ version,
375
+ etag: id + version,
376
+ config: { ...CONFIG, disabled: id === "a" },
377
+ });
378
+ receive({ event: "cell", data: { cell: record } });
379
+ }
380
+ const document = {
381
+ ...revision,
382
+ version,
383
+ etag: String(version),
384
+ order: Object.keys(graph),
385
+ };
386
+ receive({ event: "document", data: { document } });
387
+ }
388
+ function analyze(
389
+ version: number,
390
+ parents: Record<string, string[]> | null,
391
+ ) {
392
+ const analysis = {
393
+ notebook_id: revision.notebook_id,
394
+ document_etag: String(version),
395
+ cells: Object.fromEntries(
396
+ Object.keys(graph).map((id) => [
397
+ id,
398
+ {
399
+ defs: [],
400
+ refs: [],
401
+ errors: [],
402
+ ...(parents && { parents: parents[id] }),
403
+ },
404
+ ]),
405
+ ),
406
+ };
407
+ receive({ event: "analysis", data: { analysis } });
408
+ }
409
+
410
+ receive({
411
+ event: "notebook",
412
+ data: { notebook: MockExecutions.notebook() },
413
+ });
414
+ publish(1);
415
+ receive({ event: "ready", id: "1", data: {} });
416
+ const blocked = () => store.get(cellExecutionInputsAtom).blocked;
417
+ expect(blocked().size).toBe(0);
418
+ analyze(1, null);
419
+ expect(blocked().size).toBe(0);
420
+ analyze(1, graph);
421
+ expect(blocked()).toEqual(new Set(["b", "c"]));
422
+
423
+ const badge = () =>
424
+ cellExecutionView(store.get(cellExecutionInputsAtom), "b").shownBlock;
425
+ expect(badge()).toBe("current");
426
+ publish(2);
427
+ expect(blocked().size).toBe(0);
428
+ expect(badge()).toBe("stale");
429
+ analyze(2, graph);
430
+ expect(badge()).toBe("current");
431
+
432
+ publish(3);
433
+ analyze(2, graph);
434
+ expect(badge()).toBe("stale");
435
+ analyze(3, { ...graph, b: [] });
436
+ expect(badge()).toBeNull();
437
+ expect(blocked().size).toBe(0);
438
+ });
439
+
356
440
  it("records completion of the initial run", () => {
357
441
  const notification = {
358
442
  op: "completed-run",
@@ -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 { EDITOR_EVENT_KINDS, type NotebookBackend } from "../notebook/replica";
7
+ import 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,9 +59,9 @@ function afterStartup({
59
59
  });
60
60
  }
61
61
  }
62
- const target = new URL(url());
63
- target.searchParams.set("kinds", EDITOR_EVENT_KINDS.join(","));
64
- return target;
62
+ // The replica filters locally. A host may reject a filter naming an
63
+ // experimental kind it does not implement.
64
+ return new URL(url());
65
65
  };
66
66
  }
67
67
 
@@ -58,7 +58,6 @@ import {
58
58
  } from "../kernel/session";
59
59
  import { cellError } from "../executions/output";
60
60
  import { getCellLogsForMessage } from "../cells/logs";
61
- import { setCellBlocked } from "../executions";
62
61
  import { initialRunCompletedAtom } from "../kernel/state";
63
62
  import { useLayoutActions } from "../layout/state";
64
63
  import { kioskModeAtom } from "../mode";
@@ -225,13 +224,6 @@ export function useNotebookSession(opts: { sessionId: SessionId }) {
225
224
  });
226
225
  return;
227
226
  case "cell-op":
228
- if (msg.data.status != null) {
229
- setCellBlocked(
230
- store,
231
- msg.data.cell_id,
232
- msg.data.status === "disabled-transitively",
233
- );
234
- }
235
227
  if (msg.data.serialization !== undefined) {
236
228
  setCellReusability({
237
229
  cell_id: msg.data.cell_id,
@@ -87,7 +87,7 @@ export const DisabledTransitively = Template.bind({});
87
87
  DisabledTransitively.args = {
88
88
  editing: true,
89
89
  status: "idle",
90
- blocked: true,
90
+ blocked: "current",
91
91
  freshness: { sourceChanged: false, inputsChanged: false },
92
92
  interrupted: false,
93
93
  disabled: false,
@@ -98,7 +98,7 @@ export const DisabledTransitivelyAndEdited = Template.bind({});
98
98
  DisabledTransitivelyAndEdited.args = {
99
99
  editing: true,
100
100
  status: "idle",
101
- blocked: true,
101
+ blocked: "current",
102
102
  freshness: { sourceChanged: true, inputsChanged: false },
103
103
  interrupted: false,
104
104
  disabled: false,
@@ -109,7 +109,7 @@ export const Stale = Template.bind({});
109
109
  Stale.args = {
110
110
  editing: true,
111
111
  status: "idle",
112
- blocked: true,
112
+ blocked: "current",
113
113
  freshness: { sourceChanged: false, inputsChanged: true },
114
114
  interrupted: false,
115
115
  disabled: false,
@@ -120,7 +120,7 @@ export const StaleAndDisabled = Template.bind({});
120
120
  StaleAndDisabled.args = {
121
121
  editing: true,
122
122
  status: "idle",
123
- blocked: true,
123
+ blocked: "current",
124
124
  freshness: { sourceChanged: false, inputsChanged: true },
125
125
  interrupted: false,
126
126
  disabled: true,
@@ -131,7 +131,7 @@ export const EditedStaleAndDisabled = Template.bind({});
131
131
  EditedStaleAndDisabled.args = {
132
132
  editing: true,
133
133
  status: "idle",
134
- blocked: true,
134
+ blocked: "current",
135
135
  freshness: { sourceChanged: false, inputsChanged: true },
136
136
  interrupted: false,
137
137
  disabled: true,
@@ -142,7 +142,7 @@ export const EditedAndStale = Template.bind({});
142
142
  EditedAndStale.args = {
143
143
  editing: true,
144
144
  status: "idle",
145
- blocked: true,
145
+ blocked: "current",
146
146
  freshness: { sourceChanged: true, inputsChanged: false },
147
147
  interrupted: false,
148
148
  disabled: false,
@@ -1 +0,0 @@
1
- import{t as e}from"./worker-DFvnFhLF.js";var t=/* @__PURE__ */ e(((e,t)=>{t.exports={}}));export default t();