@marimo-team/islands 0.25.3-dev458 → 0.25.3-dev460

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 (55) hide show
  1. package/dist/{ErrorBoundary-CwkGSYmm.js → ErrorBoundary-D2YXxE_x.js} +1 -1
  2. package/dist/{chat-ui-6d75EmD5.js → chat-ui-wWHUzOrx.js} +3 -3
  3. package/dist/{code-visibility-Xv_t4WwT.js → code-visibility-BPWgfZVa.js} +2 -2
  4. package/dist/{common-BlMwQJMs.js → common-_2RH91nQ.js} +3 -3
  5. package/dist/{data-grid-overlay-editor-Bd8kunYq.js → data-grid-overlay-editor-yh1wqygW.js} +1 -1
  6. package/dist/{error-entries-Y2oBe6wK.js → error-entries-3nytC8-z.js} +527 -504
  7. package/dist/{feedback-button-nET4jF-9.js → feedback-button-Ctc_u2JY.js} +3 -3
  8. package/dist/{glide-data-editor-DzQRP0yA.js → glide-data-editor-DJikF-sp.js} +3 -3
  9. package/dist/{globals-IFL15lCt.js → globals-D8_0qvIC.js} +1 -1
  10. package/dist/{html-to-image-BMB3OKAk.js → html-to-image-C3Nb90uM.js} +1 -1
  11. package/dist/main.js +8493 -8478
  12. package/dist/{number-overlay-editor-BtYxGlC3.js → number-overlay-editor-BUXorcPD.js} +1 -1
  13. package/dist/{process-output-lVSjjNuD.js → process-output-BiLaCBoX.js} +2 -2
  14. package/dist/{reveal-component-BtbTYMke.js → reveal-component-B54ZJYk8.js} +2 -2
  15. package/package.json +1 -1
  16. package/src/__mocks__/executions.ts +54 -52
  17. package/src/components/editor/__tests__/output-persistence.test.tsx +1 -1
  18. package/src/components/editor/cell/__tests__/useRunCells.test.tsx +5 -8
  19. package/src/components/editor/errors/__tests__/send-error-report-button.test.tsx +7 -5
  20. package/src/components/editor/stdin-blocking-alert.tsx +1 -1
  21. package/src/core/cells/__tests__/clear-outputs.test.ts +8 -9
  22. package/src/core/cells/__tests__/runs.test.ts +18 -18
  23. package/src/core/cells/__tests__/session.test.ts +13 -11
  24. package/src/core/cells/execution-console.ts +6 -8
  25. package/src/core/cells/runs.ts +10 -10
  26. package/src/core/cells/session.ts +7 -5
  27. package/src/core/cells/utils.ts +1 -1
  28. package/src/core/errors/__tests__/error-entries.test.ts +1 -1
  29. package/src/core/executions/__tests__/atoms.test.ts +12 -5
  30. package/src/core/executions/__tests__/freshness.test.ts +53 -37
  31. package/src/core/executions/__tests__/hooks.test.tsx +8 -9
  32. package/src/core/executions/__tests__/interrupt.test.ts +12 -5
  33. package/src/core/executions/__tests__/output-lifecycle.test.ts +39 -38
  34. package/src/core/executions/__tests__/output.test.ts +62 -72
  35. package/src/core/executions/__tests__/run.test.ts +1 -4
  36. package/src/core/executions/__tests__/select.test.ts +44 -30
  37. package/src/core/executions/atoms.ts +2 -1
  38. package/src/core/executions/freshness.ts +7 -5
  39. package/src/core/executions/output.ts +8 -6
  40. package/src/core/executions/select.ts +23 -18
  41. package/src/core/islands/__tests__/bridge.test.ts +2 -10
  42. package/src/core/notebook/replica/__tests__/executions.test.ts +20 -11
  43. package/src/core/notebook/replica/__tests__/results.test.ts +42 -33
  44. package/src/core/notebook/replica/execution-state.ts +35 -0
  45. package/src/core/notebook/replica/index.ts +6 -0
  46. package/src/core/notebook/replica/replica.ts +1 -1
  47. package/src/core/notebook/replica/resources/executions.ts +9 -8
  48. package/src/core/notebook/replica/resources/results.ts +6 -5
  49. package/src/core/session/__tests__/useNotebookSession.hook.test.tsx +20 -22
  50. package/src/core/session/useNotebookSession.tsx +11 -4
  51. package/src/core/static/virtual-file-tracker.ts +3 -2
  52. package/src/core/transports/__tests__/static.test.ts +13 -8
  53. package/src/core/wasm/__tests__/bridge.test.ts +7 -16
  54. package/src/core/wasm/bridge.ts +6 -5
  55. package/src/stories/cell.stories.tsx +24 -19
@@ -8,6 +8,7 @@ import {
8
8
  retainResult,
9
9
  retainScratchResult,
10
10
  } from "./results";
11
+ import { shownOutcome, startedAt } from "../execution-state";
11
12
 
12
13
  /** A console line, display, or input an execution produced, tagged by kind. */
13
14
  type ProducedItem =
@@ -75,7 +76,8 @@ function retainScratchConsole(
75
76
  execution: Execution,
76
77
  ): Execution | undefined {
77
78
  const current = state.scratchConsole;
78
- const { id, cell_id, started_at } = execution.record;
79
+ const { id, cell_id } = execution.record;
80
+ const started_at = startedAt(execution.record);
79
81
  if (cell_id !== null || started_at === null) {
80
82
  return current;
81
83
  }
@@ -83,10 +85,11 @@ function retainScratchConsole(
83
85
  return execution;
84
86
  }
85
87
  // A late write from an older execution cannot select its console again.
86
- if (state.executions.get(id)?.record.started_at != null) {
88
+ const previous = state.executions.get(id);
89
+ if (previous && startedAt(previous.record) !== null) {
87
90
  return current;
88
91
  }
89
- return Date.parse(started_at) >= Date.parse(current.record.started_at ?? "")
92
+ return Date.parse(started_at) >= Date.parse(startedAt(current.record) ?? "")
90
93
  ? execution
91
94
  : current;
92
95
  }
@@ -181,10 +184,8 @@ function unbind(state: Executions, itemId: Protocol.ItemId): Executions {
181
184
  }
182
185
 
183
186
  function sameOutcome(a: Protocol.Execution, b: Protocol.Execution): boolean {
184
- return (
185
- a.outcome === b.outcome ||
186
- JSON.stringify(a.outcome) === JSON.stringify(b.outcome)
187
- );
187
+ const [x, y] = [shownOutcome(a), shownOutcome(b)];
188
+ return x === y || JSON.stringify(x) === JSON.stringify(y);
188
189
  }
189
190
 
190
191
  /** Carry displayed results and their revisions through a replacement snapshot. */
@@ -230,7 +231,7 @@ export function resumeResults(
230
231
  results,
231
232
  scratchConsole:
232
233
  next.scratchConsole ??
233
- (previous.scratchConsole?.record.status === "completed" &&
234
+ (previous.scratchConsole?.record.state.status === "completed" &&
234
235
  previous.scratchConsole.record.runtime_id === runtimeId
235
236
  ? previous.scratchConsole
236
237
  : undefined),
@@ -1,6 +1,7 @@
1
1
  /* Copyright 2026 Marimo. All rights reserved. */
2
2
 
3
3
  import type * as Protocol from "@marimo-team/client/protocol";
4
+ import { completedAt, shownOutcome, startedAt } from "../execution-state";
4
5
 
5
6
  /** An execution record paired with the local revision of its outcome. */
6
7
  export interface Result {
@@ -33,10 +34,10 @@ export function retainResult(state: Results, result: Result): Results {
33
34
  const cellId = record.cell_id;
34
35
  if (
35
36
  cellId === null ||
36
- record.status !== "completed" ||
37
+ record.state.status !== "completed" ||
37
38
  !state.has(cellId) ||
38
- (record.outcome?.kind === "skipped" &&
39
- record.outcome.reason === "superseded")
39
+ (record.state.outcome.kind === "skipped" &&
40
+ record.state.outcome.reason === "superseded")
40
41
  ) {
41
42
  return state;
42
43
  }
@@ -49,12 +50,12 @@ export function retainScratchResult(
49
50
  result: Result,
50
51
  ): Result | null {
51
52
  const { record, outputVersion } = result;
52
- if (record.cell_id !== null || record.outcome === null) {
53
+ if (record.cell_id !== null || shownOutcome(record) === null) {
53
54
  return previous;
54
55
  }
55
56
  const time = (execution: Protocol.Execution) =>
56
57
  Date.parse(
57
- execution.completed_at ?? execution.started_at ?? "1970-01-01T00:00:00Z",
58
+ completedAt(execution) ?? startedAt(execution) ?? "1970-01-01T00:00:00Z",
58
59
  );
59
60
  if (previous !== null && time(previous.record) > time(record)) {
60
61
  return previous;
@@ -487,11 +487,14 @@ it.each(["", "latest"])(
487
487
  });
488
488
  expect(rows()).toEqual(["2\n"]);
489
489
  const scratch = {
490
- ...MockExecutions.completed(cellId("c1")),
491
- cell_id: null,
490
+ ...MockExecutions.execution(null, {
491
+ status: "completed",
492
+ depends_on: {},
493
+ outcome: { kind: "value", display: null },
494
+ started_at: "2026-10-01T09:21:01Z",
495
+ completed_at: "2026-10-01T09:21:02Z",
496
+ }),
492
497
  id: "second-scratch",
493
- started_at: "2026-10-01T09:21:01Z",
494
- completed_at: "2026-10-01T09:21:02Z",
495
498
  };
496
499
  act(() => {
497
500
  conn.receive({
@@ -499,9 +502,11 @@ it.each(["", "latest"])(
499
502
  data: {
500
503
  execution: {
501
504
  ...scratch,
502
- status: "running",
503
- outcome: null,
504
- completed_at: null,
505
+ state: {
506
+ status: "running",
507
+ started_at: "2026-10-01T09:21:01Z",
508
+ value: null,
509
+ },
505
510
  },
506
511
  },
507
512
  });
@@ -608,12 +613,7 @@ it.each(["browser", "kernel"])(
608
613
  await started();
609
614
  const conn = connection(fake);
610
615
  const cell = cellId("c1");
611
- const execution = {
612
- ...MockExecutions.completed(cell),
613
- status: "running",
614
- completed_at: null,
615
- outcome: null,
616
- };
616
+ const execution = MockExecutions.running(cell);
617
617
  const first = {
618
618
  id: "first",
619
619
  seq: 0,
@@ -746,7 +746,7 @@ it.each(["live", "replay"])(
746
746
  await started();
747
747
  const conn = connection(fake);
748
748
  const id = cellId("c1");
749
- const execution = MockExecutions.completed(id, { id: "mixed-writes" });
749
+ const execution = { ...MockExecutions.completed(id), id: "mixed-writes" };
750
750
  const line = (seq: number, text: string) => ({
751
751
  event: "console",
752
752
  data: {
@@ -811,7 +811,7 @@ it("replays execution, debugger, and callback output independently", async () =>
811
811
  await started();
812
812
  const conn = connection(fake);
813
813
  const id = cellId("c1");
814
- const execution = MockExecutions.failed(id, {}, { id: "failed-cell" });
814
+ const execution = { ...MockExecutions.failed(id), id: "failed-cell" };
815
815
  const line = {
816
816
  id: "line",
817
817
  execution_id: execution.id,
@@ -827,7 +827,7 @@ it("replays execution, debugger, and callback output independently", async () =>
827
827
  password: true,
828
828
  status: "answered",
829
829
  };
830
- const afterExecution = Date.parse(execution.completed_at!) / 1000;
830
+ const afterExecution = Date.parse(MockExecutions.T1) / 1000;
831
831
  const session = {
832
832
  op: "pdb-output",
833
833
  cell_id: id,
@@ -936,7 +936,7 @@ it.each([
936
936
  await started();
937
937
  const conn = connection(fake);
938
938
  const cell = cellId("c1");
939
- const execution = MockExecutions.completed(cell, { id: "previous-run" });
939
+ const execution = { ...MockExecutions.completed(cell), id: "previous-run" };
940
940
  const runtime = () => store.get(cellRuntimeAtom(cell));
941
941
  await act(async () => conn.open());
942
942
  act(() => {
@@ -1058,11 +1058,9 @@ it("collects exported files from execution values and public callback media", as
1058
1058
  const callbackFile = "/@file/callback-image.png";
1059
1059
  const previousFile = "/@file/previous-callback.png";
1060
1060
  const debuggerFile = "/@file/debugger-image.png";
1061
- const record = MockExecutions.completed(id, {
1062
- outcome: {
1063
- kind: "value",
1064
- display: { mimetype: "text/html", data: `<img src="${file}">` },
1065
- },
1061
+ const record = MockExecutions.shown(id, {
1062
+ mimetype: "text/html",
1063
+ data: `<img src="${file}">`,
1066
1064
  });
1067
1065
  act(() => {
1068
1066
  conn.receive({
@@ -76,7 +76,11 @@ import {
76
76
  import { useStorageActions } from "../storage/state";
77
77
  import { useVariablesActions } from "../variables/state";
78
78
  import type { VariableName } from "../variables/types";
79
- import { activeDocumentModelAtom, confirmedDocumentAtom } from "./active-notebook";
79
+ import {
80
+ activeDocumentModelAtom,
81
+ confirmedDocumentAtom,
82
+ } from "./active-notebook";
83
+ import { completedAt, startedAt } from "@/core/notebook/replica";
80
84
  import { executionSource } from "@/core/executions";
81
85
  import { embeddedSnapshotAtom } from "./embedded";
82
86
  import { WebSocketClosedReason, ConnectionState } from "./types";
@@ -434,17 +438,20 @@ export function useNotebookSession(opts: { sessionId: SessionId }) {
434
438
  checkHealth: () => runtimeManager.reconcileFromHealth(),
435
439
  onExecution: (record) => {
436
440
  const cellId = (record.cell_id ?? SCRATCH_CELL_ID) as CellId;
437
- const time = record.completed_at ?? record.started_at;
441
+ const time = completedAt(record) ?? startedAt(record);
438
442
  const timestamp =
439
443
  time === null ? Date.now() / 1000 : Date.parse(time) / 1000;
440
- if (record.status === "completed" && record.outcome?.kind === "error") {
444
+ if (
445
+ record.state.status === "completed" &&
446
+ record.state.outcome?.kind === "error"
447
+ ) {
441
448
  getCellLogsForMessage({
442
449
  cell_id: cellId,
443
450
  timestamp,
444
451
  output: {
445
452
  channel: "marimo-error",
446
453
  mimetype: "application/vnd.marimo+error",
447
- data: [cellError(record.outcome.error)],
454
+ data: [cellError(record.state.outcome.error)],
448
455
  timestamp,
449
456
  },
450
457
  });
@@ -6,6 +6,7 @@ import type {
6
6
  OutputMessage,
7
7
  NotificationMessageData,
8
8
  } from "../kernel/messages";
9
+ import { shownOutcome } from "@/core/notebook/replica";
9
10
 
10
11
  // Virtual files are of the form /@file/<file-name>.<extension>
11
12
  const VIRTUAL_FILE_REGEX = /\/@file\/([^\s"&'/]+)\.([\dA-Za-z]+)/g;
@@ -37,8 +38,8 @@ export class VirtualFileTracker {
37
38
  }
38
39
 
39
40
  public trackExecution(record: Execution): void {
40
- const value =
41
- record.outcome?.kind === "value" ? record.outcome.display : null;
41
+ const outcome = shownOutcome(record);
42
+ const value = outcome?.kind === "value" ? outcome.display : null;
42
43
  if (value) {
43
44
  this.trackValue(
44
45
  (record.cell_id as CellId | null) ?? SCRATCH_CELL_ID,
@@ -3,7 +3,6 @@
3
3
  import { createNotebookReducer, NotebookEvents } from "@marimo-team/client";
4
4
  import * as Protocol from "@marimo-team/client/protocol";
5
5
  import { afterEach, assert, describe, expect, it, vi } from "vitest";
6
- import { MockExecutions } from "@/__mocks__/executions";
7
6
  import type { NotebookBackend } from "../../notebook/replica";
8
7
  import { document as documentResource } from "../../notebook/replica/resources/document";
9
8
  import { executions } from "../../notebook/replica/resources/executions";
@@ -107,18 +106,24 @@ describe("static notebook backend", () => {
107
106
  it("delivers embedded results as completed executions after the document", async () => {
108
107
  const source = snapshot();
109
108
  const cell = source.cells[0];
110
- const result = MockExecutions.completed(cell.id, {
109
+ const result: Protocol.Execution = {
111
110
  id: "embedded:result",
112
111
  run_id: "embedded:run",
113
112
  runtime_id: "embedded",
113
+ caused_by: null,
114
+ cell_id: cell.id,
114
115
  code_fingerprint: cell.code_fingerprint,
115
- outcome: {
116
- kind: "value",
117
- display: { mimetype: "text/html", data: "<b>1</b>" },
116
+ state: {
117
+ status: "completed",
118
+ started_at: null,
119
+ completed_at: null,
120
+ outcome: {
121
+ kind: "value",
122
+ display: { mimetype: "text/html", data: "<b>1</b>" },
123
+ },
124
+ depends_on: {},
118
125
  },
119
- started_at: null,
120
- completed_at: null,
121
- });
126
+ };
122
127
  const { events } = await read(
123
128
  createStaticNotebookBackend({ ...source, results: [result] }),
124
129
  );
@@ -275,15 +275,12 @@ it("raises the interrupt buffer for a cancelled running run before the worker ta
275
275
  notebook_id: "n1",
276
276
  runtime_id: "r1",
277
277
  origin: { kind: "code", code: "pass" },
278
- status: "running",
279
- outcome: null,
280
- started_at: "2026-10-01T09:20:11Z",
281
- completed_at: null,
278
+ state: { status: "running", started_at: "2026-10-01T09:20:11Z" },
282
279
  };
283
280
  const replicaWith = (status: string) =>
284
281
  ({
285
282
  executionsAtom: atom({
286
- runs: new Map([["run-1", { ...run, status }]]),
283
+ runs: new Map([["run-1", { ...run, state: { status } }]]),
287
284
  executions: new Map(),
288
285
  latest: new Map(),
289
286
  }),
@@ -327,15 +324,12 @@ it.each(["running", "completed", null])(
327
324
  notebook_id: "n1",
328
325
  runtime_id: "r1",
329
326
  origin: { kind: "code", code: "pass" },
330
- status: "running",
331
- outcome: null,
332
- started_at: "2026-10-01T09:20:11Z",
333
- completed_at: null,
327
+ state: { status: "running", started_at: "2026-10-01T09:20:11Z" },
334
328
  };
335
329
  const replicaWith = (status: string) =>
336
330
  ({
337
331
  executionsAtom: atom({
338
- runs: new Map([["run-1", { ...run, status }]]),
332
+ runs: new Map([["run-1", { ...run, state: { status } }]]),
339
333
  executions: new Map(),
340
334
  latest: new Map(),
341
335
  }),
@@ -382,7 +376,7 @@ it.each(["running", "completed", null])(
382
376
  id: "sub",
383
377
  event: JSON.stringify({
384
378
  event: "run",
385
- data: { run: { ...run, status } },
379
+ data: { run: { ...run, state: { status } } },
386
380
  }),
387
381
  });
388
382
  deliver("running");
@@ -407,10 +401,7 @@ it("raises the interrupt buffer once a run cancelled while queued starts", async
407
401
  notebook_id: "n1",
408
402
  runtime_id: "r1",
409
403
  origin: { kind: "code", code: "pass" },
410
- status: "queued",
411
- outcome: null,
412
- started_at: null,
413
- completed_at: null,
404
+ state: { status: "queued" },
414
405
  };
415
406
  store.set(activeNotebookReplicaAtom, {
416
407
  executionsAtom: atom({
@@ -427,7 +418,7 @@ it("raises the interrupt buffer once a run cancelled while queued starts", async
427
418
  id: "sub",
428
419
  event: JSON.stringify({
429
420
  event: "run",
430
- data: { run: { ...run, status } },
421
+ data: { run: { ...run, state: { status } } },
431
422
  }),
432
423
  });
433
424
  try {
@@ -312,16 +312,16 @@ export class PyodideBridge implements RunRequests, EditRequests {
312
312
  }
313
313
  const frame = event as {
314
314
  event?: string;
315
- data?: { run?: { id: string; status: string } };
315
+ data?: { run?: { id: string; state: { status: string } } };
316
316
  };
317
317
  const run = frame.event === "run" ? frame.data?.run : undefined;
318
318
  if (run === undefined || !this.pendingInterrupts.has(run.id)) {
319
319
  return;
320
320
  }
321
- if (run.status === "running") {
321
+ if (run.state.status === "running") {
322
322
  this.pendingInterrupts.delete(run.id);
323
323
  this.raiseInterrupt();
324
- } else if (run.status === "completed") {
324
+ } else if (run.state.status === "completed") {
325
325
  this.pendingInterrupts.delete(run.id);
326
326
  }
327
327
  }
@@ -337,7 +337,7 @@ export class PyodideBridge implements RunRequests, EditRequests {
337
337
  return;
338
338
  }
339
339
  for (const run of store.get(replica.executionsAtom).runs.values()) {
340
- if (run.status === "queued") {
340
+ if (run.state.status === "queued") {
341
341
  this.pendingInterrupts.add(run.id);
342
342
  }
343
343
  }
@@ -350,7 +350,8 @@ export class PyodideBridge implements RunRequests, EditRequests {
350
350
  return false;
351
351
  }
352
352
  return (
353
- store.get(replica.executionsAtom).runs.get(runId)?.status === "running"
353
+ store.get(replica.executionsAtom).runs.get(runId)?.state.status ===
354
+ "running"
354
355
  );
355
356
  }
356
357
 
@@ -44,26 +44,31 @@ function seedResult(
44
44
  output: CellOutput | null,
45
45
  freshness: CellOverrides["freshness"],
46
46
  ) {
47
- const ran = MockExecutions.completed(cid, {
47
+ const ran = {
48
+ ...MockExecutions.execution(cid, {
49
+ status: "completed",
50
+ started_at: MockExecutions.T0,
51
+ completed_at: MockExecutions.T1,
52
+ outcome: {
53
+ kind: "value",
54
+ display:
55
+ output === null
56
+ ? null
57
+ : {
58
+ mimetype: output.mimetype,
59
+ data:
60
+ typeof output.data === "string"
61
+ ? output.data
62
+ : JSON.stringify(output.data),
63
+ },
64
+ },
65
+ depends_on:
66
+ freshness === undefined || freshness === "edited"
67
+ ? {}
68
+ : { x: { execution: "gone", update: 0 } },
69
+ }),
48
70
  code_fingerprint: "ran",
49
- depends_on:
50
- freshness === undefined || freshness === "edited"
51
- ? {}
52
- : { x: { execution: "gone", update: 0 } },
53
- outcome: {
54
- kind: "value",
55
- display:
56
- output === null
57
- ? null
58
- : {
59
- mimetype: output.mimetype,
60
- data:
61
- typeof output.data === "string"
62
- ? output.data
63
- : JSON.stringify(output.data),
64
- },
65
- },
66
- });
71
+ };
67
72
  const document =
68
73
  freshness === undefined
69
74
  ? null