@marimo-team/islands 0.26.1-dev19 → 0.26.1-dev21

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 (83) hide show
  1. package/dist/{ErrorBoundary-CYipPzuL.js → ErrorBoundary-C5X_T831.js} +1 -1
  2. package/dist/{chat-ui-b1ERxzeA.js → chat-ui-qZdDDrzU.js} +3 -3
  3. package/dist/{code-visibility-D2uVdtAQ.js → code-visibility-7FxdzbDq.js} +2 -2
  4. package/dist/{common-d-UA4Z2n.js → common-D-iTRwaQ.js} +3 -3
  5. package/dist/{data-grid-overlay-editor-BfZIG_OX.js → data-grid-overlay-editor-DoWUW2oW.js} +1 -1
  6. package/dist/{error-entries-Bl8fzLQc.js → error-entries-DhI0hGvj.js} +448 -450
  7. package/dist/{feedback-button-Ct0bgfAh.js → feedback-button-OUiV15AL.js} +3 -3
  8. package/dist/{glide-data-editor-D9EGRA-V.js → glide-data-editor-CFouYM6e.js} +3 -3
  9. package/dist/{globals-UnK9bjY3.js → globals-B_U6Frqj.js} +1 -1
  10. package/dist/{html-to-image-D6A1lg0A.js → html-to-image-B803aaWE.js} +1 -1
  11. package/dist/main.js +3213 -3203
  12. package/dist/{number-overlay-editor-DMasuqqm.js → number-overlay-editor-CiQQjf9m.js} +1 -1
  13. package/dist/{process-output-w5omHedc.js → process-output-CnCLfvnL.js} +2 -2
  14. package/dist/{reveal-component-v6w_cxzA.js → reveal-component-B73BObRc.js} +2 -2
  15. package/package.json +1 -1
  16. package/src/__mocks__/executions.ts +20 -19
  17. package/src/__mocks__/notebook.ts +1 -1
  18. package/src/__tests__/branded.ts +4 -0
  19. package/src/components/editor/actions/__tests__/name-cell-input.test.tsx +1 -1
  20. package/src/components/editor/cell/__tests__/useRunCells.test.tsx +5 -5
  21. package/src/components/editor/chrome/wrapper/__tests__/document-sync-status.test.tsx +5 -2
  22. package/src/components/tracing/tracing-keyboard.test.tsx +4 -3
  23. package/src/core/ai/context/providers/__tests__/error.test.ts +6 -3
  24. package/src/core/cells/__tests__/actions.test.ts +2 -2
  25. package/src/core/cells/__tests__/arrange.test.ts +1 -1
  26. package/src/core/cells/__tests__/harness.ts +9 -7
  27. package/src/core/cells/__tests__/layout.test.ts +1 -1
  28. package/src/core/cells/__tests__/runs.test.ts +14 -14
  29. package/src/core/cells/__tests__/utils.test.ts +3 -2
  30. package/src/core/cells/actions.ts +6 -6
  31. package/src/core/cells/cells.ts +1 -1
  32. package/src/core/cells/document.ts +1 -2
  33. package/src/core/cells/execution-console.ts +3 -3
  34. package/src/core/cells/ids.ts +2 -4
  35. package/src/core/cells/runs.ts +7 -5
  36. package/src/core/cells/session.ts +8 -5
  37. package/src/core/executions/__tests__/atoms.test.ts +7 -4
  38. package/src/core/executions/__tests__/freshness.test.ts +57 -53
  39. package/src/core/executions/__tests__/interrupt.test.ts +4 -3
  40. package/src/core/executions/__tests__/output-lifecycle.test.ts +3 -3
  41. package/src/core/executions/__tests__/output.test.ts +5 -3
  42. package/src/core/executions/__tests__/run.test.ts +4 -4
  43. package/src/core/executions/__tests__/select.test.ts +75 -67
  44. package/src/core/executions/atoms.ts +2 -2
  45. package/src/core/executions/freshness.ts +5 -5
  46. package/src/core/executions/output.ts +15 -21
  47. package/src/core/executions/select.ts +17 -9
  48. package/src/core/export/__tests__/hooks.test.ts +1 -1
  49. package/src/core/meta/__tests__/code-visibility.test.tsx +3 -2
  50. package/src/core/notebook/document/__tests__/codemirror.test.ts +8 -6
  51. package/src/core/notebook/document/__tests__/draft.test.ts +56 -58
  52. package/src/core/notebook/document/__tests__/fixtures.ts +8 -7
  53. package/src/core/notebook/document/__tests__/hooks.test.tsx +39 -35
  54. package/src/core/notebook/document/__tests__/lifecycle-scenarios.test.ts +8 -5
  55. package/src/core/notebook/document/__tests__/model.test.ts +8 -5
  56. package/src/core/notebook/document/__tests__/protocol-fixtures.ts +2 -2
  57. package/src/core/notebook/document/__tests__/recovery-scenarios.test.ts +37 -32
  58. package/src/core/notebook/document/__tests__/scenarios.test.ts +49 -45
  59. package/src/core/notebook/document/__tests__/state.test.ts +59 -56
  60. package/src/core/notebook/document/__tests__/submission.test.ts +15 -12
  61. package/src/core/notebook/document/__tests__/test-host.ts +3 -2
  62. package/src/core/notebook/document/__tests__/user.ts +7 -3
  63. package/src/core/notebook/document/draft.ts +29 -11
  64. package/src/core/notebook/document/state.ts +7 -6
  65. package/src/core/notebook/replica/__tests__/document.test.ts +9 -5
  66. package/src/core/notebook/replica/__tests__/executions.test.ts +16 -11
  67. package/src/core/notebook/replica/__tests__/fixtures.ts +6 -2
  68. package/src/core/notebook/replica/__tests__/replica.test.ts +7 -2
  69. package/src/core/notebook/replica/__tests__/results.test.ts +23 -19
  70. package/src/core/notebook/replica/execution-state.ts +2 -2
  71. package/src/core/notebook/replica/replica.ts +2 -2
  72. package/src/core/notebook/replica/resources/analysis.ts +1 -1
  73. package/src/core/notebook/replica/resources/document.ts +9 -8
  74. package/src/core/notebook/replica/resources/executions.ts +2 -2
  75. package/src/core/notebook/replica/resources/results.ts +2 -2
  76. package/src/core/saving/__tests__/document.test.tsx +1 -1
  77. package/src/core/saving/__tests__/state.test.ts +2 -2
  78. package/src/core/session/__tests__/useNotebookSession.hook.test.tsx +9 -4
  79. package/src/core/session/useNotebookReplica.ts +1 -1
  80. package/src/core/session/useNotebookSession.tsx +1 -1
  81. package/src/core/transports/__tests__/static.test.ts +3 -2
  82. package/src/core/transports/static.ts +2 -2
  83. package/src/core/wasm/bridge.ts +5 -4
@@ -5,6 +5,9 @@ import * as Protocol from "@marimo-team/client/protocol";
5
5
  import { executions, itemsInOrder } from "../resources/executions";
6
6
  import { createNotebookReducer } from "@marimo-team/client";
7
7
  import { fixtureEvents } from "./fixtures";
8
+ import { cellId, runId } from "@/__tests__/branded";
9
+
10
+ const C3 = cellId("c3");
8
11
 
9
12
  const reducer = createNotebookReducer({ executions });
10
13
  const snapshot = fixtureEvents("notebook-events.sse");
@@ -46,28 +49,30 @@ describe("executions resource", () => {
46
49
  expect(itemsInOrder(scratch!).map((item) => item.kind)).toEqual([
47
50
  "console",
48
51
  ]);
49
- expect(opening.runs.get("run-scratch")?.state.status).toBe("running");
52
+ expect(opening.runs.get(runId("run-scratch"))?.state.status).toBe(
53
+ "running",
54
+ );
50
55
  expect(opening.latest.size).toBe(0);
51
56
 
52
57
  const done = resource(replay(snapshot));
53
58
  expect(done.executions.get("e7")?.record.state.status).toBe("completed");
54
- expect(done.runs.get("run-scratch")?.state).toMatchObject({
59
+ expect(done.runs.get(runId("run-scratch"))?.state).toMatchObject({
55
60
  outcome: { kind: "succeeded" },
56
61
  });
57
62
  const released = reducer.reduce(
58
63
  replay(snapshot),
59
64
  removed("run", "run-scratch", "98"),
60
65
  );
61
- expect(resource(released).runs.has("run-scratch")).toBe(false);
66
+ expect(resource(released).runs.has(runId("run-scratch"))).toBe(false);
62
67
  });
63
68
 
64
69
  it("indexes a cell's execution while it is on the stream", () => {
65
70
  const start = replay(snapshot);
66
71
  const running = resource(replay(runCells.slice(0, 5), start));
67
- expect(running.latest.get("c3")).toBe("e12");
72
+ expect(running.latest.get(C3)).toBe("e12");
68
73
  expect(running.executions.get("e12")?.record.state.status).toBe("running");
69
- expect(running.latest.get("k7f2")).toBe("e13");
70
- expect(running.runs.get("run-cells")?.state.status).toBe("running");
74
+ expect(running.latest.get(cellId("k7f2"))).toBe("e13");
75
+ expect(running.runs.get(runId("run-cells"))?.state.status).toBe("running");
71
76
 
72
77
  const done = replay(runCells, start);
73
78
  const e12 = resource(done).executions.get("e12");
@@ -79,13 +84,13 @@ describe("executions resource", () => {
79
84
  x: { execution_id: "e12", update: 0 },
80
85
  },
81
86
  );
82
- expect(resource(done).runs.get("run-cells")?.state).toMatchObject({
87
+ expect(resource(done).runs.get(runId("run-cells"))?.state).toMatchObject({
83
88
  outcome: { kind: "succeeded" },
84
89
  });
85
90
 
86
91
  const retired = replay(retire("e12", "e12-x"), done);
87
92
  expect(resource(retired).executions.has("e12")).toBe(false);
88
- expect(resource(retired).latest.has("c3")).toBe(false);
93
+ expect(resource(retired).latest.has(C3)).toBe(false);
89
94
  const queued = reducer.reduce(
90
95
  retired,
91
96
  event({
@@ -104,7 +109,7 @@ describe("executions resource", () => {
104
109
  },
105
110
  }),
106
111
  );
107
- expect(resource(queued).latest.get("c3")).toBe("e14");
112
+ expect(resource(queued).latest.get(C3)).toBe("e14");
108
113
  expect([...resource(queued).executions.keys()]).toEqual([
109
114
  "e7",
110
115
  "e13",
@@ -149,7 +154,7 @@ describe("executions resource", () => {
149
154
  const e12 = resource(cleared).executions.get("e12")!;
150
155
  expect(ids(e12)).toEqual([]);
151
156
  expect(e12.variables.size).toBe(0);
152
- expect(resource(cleared).latest.get("c3")).toBe("e12");
157
+ expect(resource(cleared).latest.get(C3)).toBe("e12");
153
158
  });
154
159
 
155
160
  it("orders items by seq, replaces them by id, and drops orphans", () => {
@@ -172,7 +177,7 @@ describe("executions resource", () => {
172
177
  expect(prompted.latest.size).toBe(0);
173
178
  const gone = resource(replay(inputs, start));
174
179
  expect(gone.executions.has("e-input")).toBe(false);
175
- expect(gone.runs.get("run-input")?.state).toMatchObject({
180
+ expect(gone.runs.get(runId("run-input"))?.state).toMatchObject({
176
181
  outcome: { kind: "cancelled" },
177
182
  });
178
183
 
@@ -96,8 +96,12 @@ export function fixtureMessages(name: string) {
96
96
  }
97
97
 
98
98
  /** Read the protocol's portable examples as decoded protocol events. */
99
- export function fixtureEvents(name: string): Protocol.NotebookStreamEventOutput[] {
99
+ export function fixtureEvents(
100
+ name: string,
101
+ ): Protocol.NotebookStreamEventOutput[] {
100
102
  return fixtureMessages(name).map(({ id, ...message }) =>
101
- Protocol.NotebookStreamEvent.parse(id === undefined ? message : { ...message, id }),
103
+ Protocol.NotebookStreamEvent.parse(
104
+ id === undefined ? message : { ...message, id },
105
+ ),
102
106
  );
103
107
  }
@@ -1,6 +1,7 @@
1
1
  /* Copyright 2026 Marimo. All rights reserved. */
2
2
  // @vitest-environment jsdom
3
3
 
4
+ import { runId } from "@/__tests__/branded";
4
5
  import { type NotebookTransport, StreamStopped } from "@marimo-team/client";
5
6
  import { createStore } from "jotai";
6
7
  import { afterEach, describe, expect, it, onTestFinished, vi } from "vitest";
@@ -318,7 +319,9 @@ describe("NotebookReplica lifetime", () => {
318
319
  "k7f2",
319
320
  ]);
320
321
  expect(store.get(client.runtimeAtom)?.id).toBe("r1");
321
- expect(store.get(client.executionsAtom).runs.has("run-scratch")).toBe(true);
322
+ expect(
323
+ store.get(client.executionsAtom).runs.has(runId("run-scratch")),
324
+ ).toBe(true);
322
325
  expect(store.get(client.resultsAtom).size).toBe(3);
323
326
  attempt.drop();
324
327
  await backoff();
@@ -328,7 +331,9 @@ describe("NotebookReplica lifetime", () => {
328
331
  "k7f2",
329
332
  ]);
330
333
  expect(store.get(client.runtimeAtom)).toBeNull();
331
- expect(store.get(client.executionsAtom).runs.has("run-scratch")).toBe(true);
334
+ expect(
335
+ store.get(client.executionsAtom).runs.has(runId("run-scratch")),
336
+ ).toBe(true);
332
337
  expect(store.get(client.resultsAtom).size).toBe(3);
333
338
  current.abort();
334
339
  expect(store.get(client.documentAtom)).toBeNull();
@@ -5,6 +5,10 @@ import * as Protocol from "@marimo-team/client/protocol";
5
5
  import { executions } from "../resources/executions";
6
6
  import { createNotebookReducer } from "@marimo-team/client";
7
7
  import { fixtureEvents } from "./fixtures";
8
+ import { cellId } from "@/__tests__/branded";
9
+
10
+ const C3 = cellId("c3");
11
+ const FIXTURE_CELL = cellId("k7f2");
8
12
 
9
13
  const reducer = createNotebookReducer({ executions });
10
14
  const snapshot = fixtureEvents("notebook-events.sse");
@@ -67,28 +71,28 @@ describe("retained results", () => {
67
71
  ...snapshot.slice(ready),
68
72
  ]),
69
73
  );
70
- expect(opened.get("c3")?.record.id).toBe("e-restored");
71
- expect(opened.get("c3")?.record.run_id).toBeNull();
74
+ expect(opened.get(C3)?.record.id).toBe("e-restored");
75
+ expect(opened.get(C3)?.record.run_id).toBeNull();
72
76
  });
73
77
 
74
78
  it("records a cell's result when its execution completes", () => {
75
79
  const start = replay(snapshot);
76
80
  const running = resource(replay(runCells.slice(0, 5), start));
77
- expect(running.get("c3")).toBeNull();
78
- expect(running.get("k7f2")).toBeNull();
81
+ expect(running.get(C3)).toBeNull();
82
+ expect(running.get(FIXTURE_CELL)).toBeNull();
79
83
 
80
84
  const done = resource(replay(runCells, start));
81
- expect(done.get("c3")?.record.id).toBe("e12");
82
- expect(done.get("c3")?.record.state.status).toBe("completed");
83
- expect(done.get("k7f2")?.record.state).toHaveProperty("depends_on", {
85
+ expect(done.get(C3)?.record.id).toBe("e12");
86
+ expect(done.get(C3)?.record.state.status).toBe("completed");
87
+ expect(done.get(FIXTURE_CELL)?.record.state).toHaveProperty("depends_on", {
84
88
  x: { execution_id: "e12", update: 0 },
85
89
  });
86
- expect(done.get("c1")).toBeNull();
90
+ expect(done.get(cellId("c1"))).toBeNull();
87
91
  });
88
92
 
89
93
  it("keeps a result when the attempt that replaced it was superseded", () => {
90
94
  const done = replay(runCells, replay(snapshot));
91
- const result = resource(done).get("c3")!;
95
+ const result = resource(done).get(C3)!;
92
96
  const superseded = reducer.reduce(
93
97
  replay(retire("e12", "e12-x"), done),
94
98
  event({
@@ -115,14 +119,14 @@ describe("retained results", () => {
115
119
  },
116
120
  }),
117
121
  );
118
- expect(resource(superseded).get("c3")).toBe(result);
122
+ expect(resource(superseded).get(C3)).toBe(result);
119
123
  });
120
124
 
121
125
  it("keeps a result while the host replaces it", () => {
122
126
  const done = replay(runCells, replay(snapshot));
123
- const result = resource(done).get("c3")!;
127
+ const result = resource(done).get(C3)!;
124
128
  const retired = replay(retire("e12", "e12-x"), done);
125
- expect(resource(retired).get("c3")).toBe(result);
129
+ expect(resource(retired).get(C3)).toBe(result);
126
130
 
127
131
  const again = {
128
132
  ...result.record,
@@ -134,7 +138,7 @@ describe("retained results", () => {
134
138
  retired,
135
139
  event({ event: "execution", id: "113", data: { execution: again } }),
136
140
  );
137
- expect(resource(queued).get("c3")).toBe(result);
141
+ expect(resource(queued).get(C3)).toBe(result);
138
142
 
139
143
  const completed = reducer.reduce(
140
144
  queued,
@@ -155,12 +159,12 @@ describe("retained results", () => {
155
159
  },
156
160
  }),
157
161
  );
158
- expect(resource(completed).get("c3")?.record.id).toBe("e14");
162
+ expect(resource(completed).get(C3)?.record.id).toBe("e14");
159
163
  });
160
164
 
161
165
  it("replaces a result with an execution interrupted before it started", () => {
162
166
  const done = replay(runCells, replay(snapshot));
163
- const result = resource(done).get("c3")!;
167
+ const result = resource(done).get(C3)!;
164
168
  const interrupted = {
165
169
  ...result.record,
166
170
  id: "e14",
@@ -194,7 +198,7 @@ describe("retained results", () => {
194
198
  ],
195
199
  done,
196
200
  );
197
- expect(resource(cancelled).get("c3")?.record.state).toHaveProperty(
201
+ expect(resource(cancelled).get(C3)?.record.state).toHaveProperty(
198
202
  "outcome",
199
203
  {
200
204
  kind: "cancelled",
@@ -205,11 +209,11 @@ describe("retained results", () => {
205
209
  it("drops a cell deleted while its execution runs", () => {
206
210
  const start = replay(runCells.slice(0, 5), replay(snapshot));
207
211
  const deleted = reducer.reduce(start, removed("cell", "c3", "105"));
208
- expect(resource(deleted).has("c3")).toBe(false);
212
+ expect(resource(deleted).has(C3)).toBe(false);
209
213
 
210
214
  const finished = replay(runCells.slice(5), deleted);
211
- expect(resource(finished).has("c3")).toBe(false);
212
- expect(resource(finished).get("k7f2")?.record.id).toBe("e13");
215
+ expect(resource(finished).has(C3)).toBe(false);
216
+ expect(resource(finished).get(FIXTURE_CELL)?.record.id).toBe("e13");
213
217
  });
214
218
 
215
219
  it("ignores cells it has not seen and clears on reset", () => {
@@ -7,14 +7,14 @@ import type * as Protocol from "@marimo-team/client/protocol";
7
7
  /** What an execution shows in place of a cell's output. */
8
8
  export type Shown =
9
9
  | { readonly kind: "output"; readonly media: Protocol.Media | null }
10
- | Exclude<Protocol.ExecutionOutcome, { kind: "succeeded" }>;
10
+ | Exclude<Protocol.ExecutionOutcomeOutput, { kind: "succeeded" }>;
11
11
 
12
12
  /**
13
13
  * How an execution ended when it did not succeed, else its output. Null
14
14
  * until a queued or running execution sets its output.
15
15
  */
16
16
  export function shown(result: {
17
- readonly record: Protocol.Execution;
17
+ readonly record: Protocol.ExecutionOutput;
18
18
  readonly output: Protocol.Output | null;
19
19
  }): Shown | null {
20
20
  const { state } = result.record;
@@ -10,9 +10,9 @@ import {
10
10
  StreamStopped,
11
11
  } from "@marimo-team/client";
12
12
  import type {
13
- Analysis,
13
+ AnalysisOutput as Analysis,
14
14
  Attachment,
15
- Execution as HostExecution,
15
+ ExecutionOutput as HostExecution,
16
16
  Output as HostOutput,
17
17
  NotebookOutput,
18
18
  Runtime,
@@ -1,7 +1,7 @@
1
1
  /* Copyright 2026 Marimo. All rights reserved. */
2
2
 
3
3
  import type { NotebookResource } from "@marimo-team/client";
4
- import type { Analysis } from "@marimo-team/client/protocol";
4
+ import type { AnalysisOutput as Analysis } from "@marimo-team/client/protocol";
5
5
 
6
6
  export const analysis: NotebookResource<Analysis | null, "analysis"> = {
7
7
  initial: null,
@@ -10,15 +10,15 @@ import type { NotebookResource } from "@marimo-team/client";
10
10
  * version. Each cell in its order has a record in `cells`.
11
11
  */
12
12
  export interface Document {
13
- readonly revision: Protocol.Document;
14
- readonly cells: ReadonlyMap<Protocol.CellId, Protocol.Cell>;
13
+ readonly revision: Protocol.DocumentOutput;
14
+ readonly cells: ReadonlyMap<Protocol.CellId, Protocol.CellOutput>;
15
15
  }
16
16
 
17
17
  /** The records of a revision still being received. */
18
18
  interface PendingDocument {
19
19
  /** Null until the `document` event that closes the group arrives. */
20
- readonly revision: Protocol.Document | null;
21
- readonly cells: ReadonlyMap<Protocol.CellId, Protocol.Cell>;
20
+ readonly revision: Protocol.DocumentOutput | null;
21
+ readonly cells: ReadonlyMap<Protocol.CellId, Protocol.CellOutput>;
22
22
  }
23
23
 
24
24
  /**
@@ -43,8 +43,8 @@ function pendingOf(state: DocumentState): PendingDocument {
43
43
 
44
44
  /** Confirm a revision whose records are complete. */
45
45
  function publish(
46
- revision: Protocol.Document,
47
- cells: ReadonlyMap<Protocol.CellId, Protocol.Cell>,
46
+ revision: Protocol.DocumentOutput,
47
+ cells: ReadonlyMap<Protocol.CellId, Protocol.CellOutput>,
48
48
  ): DocumentState {
49
49
  const order = new Set(revision.order);
50
50
  if (
@@ -73,11 +73,12 @@ export const document: NotebookResource<DocumentState, "cell" | "document"> = {
73
73
  },
74
74
  "cell.removed": (state, { data }) => {
75
75
  const pending = pendingOf(state);
76
- if (!pending.cells.has(data.id)) {
76
+ const { id } = data;
77
+ if (!pending.cells.has(id)) {
77
78
  return state;
78
79
  }
79
80
  const cells = new Map(pending.cells);
80
- cells.delete(data.id);
81
+ cells.delete(id);
81
82
  return { ...state, pending: { ...pending, cells } };
82
83
  },
83
84
  document: (state, { data }, { phase }) => {
@@ -36,7 +36,7 @@ export interface Execution extends Result {
36
36
  * stays for display while a new execution runs.
37
37
  */
38
38
  export interface Executions {
39
- readonly runs: ReadonlyMap<Protocol.RunId, Protocol.Run>;
39
+ readonly runs: ReadonlyMap<Protocol.RunId, Protocol.RunOutput>;
40
40
  /** Every execution on the stream, scratch included. */
41
41
  readonly executions: ReadonlyMap<Protocol.ExecutionId, Execution>;
42
42
  /** The execution on the stream for each cell that has one. */
@@ -56,7 +56,7 @@ export interface RunFailure {
56
56
  readonly completedAt: string;
57
57
  }
58
58
 
59
- function hostFailure(run: Protocol.Run): RunFailure | undefined {
59
+ function hostFailure(run: Protocol.RunOutput): RunFailure | undefined {
60
60
  const { state } = run;
61
61
  return state.status === "completed" &&
62
62
  state.outcome.kind === "failed" &&
@@ -5,7 +5,7 @@ import { completedAt, shown, startedAt } from "../execution-state";
5
5
 
6
6
  /** An execution record and its output, with the local revision of what it shows. */
7
7
  export interface Result {
8
- readonly record: Protocol.Execution;
8
+ readonly record: Protocol.ExecutionOutput;
9
9
  /** The execution's output item, null until it sets one. */
10
10
  readonly output: Protocol.Output | null;
11
11
  /** Unchanged by lifecycle-only events. */
@@ -55,7 +55,7 @@ export function retainScratchResult(
55
55
  if (record.cell_id !== null || shown(result) === null) {
56
56
  return previous;
57
57
  }
58
- const time = (execution: Protocol.Execution) =>
58
+ const time = (execution: Protocol.ExecutionOutput) =>
59
59
  Date.parse(
60
60
  completedAt(execution) ?? startedAt(execution) ?? "1970-01-01T00:00:00Z",
61
61
  );
@@ -17,7 +17,7 @@ import { activeNotebookReplicaAtom } from "@/core/session/active-notebook";
17
17
  import { Deferred } from "@/utils/Deferred";
18
18
  import { useNotebookDocumentSave } from "../document";
19
19
 
20
- const confirmed: Protocol.Document = {
20
+ const confirmed: Protocol.DocumentOutput = {
21
21
  notebook_id: "n1",
22
22
  order: [],
23
23
  app_config: {},
@@ -17,8 +17,8 @@ import { initialLayoutState, layoutStateAtom } from "../../layout/state";
17
17
  import { documentVersionAtom, needsSaveAtom, savedLayoutAtom } from "../state";
18
18
 
19
19
  function revision(
20
- overrides: Partial<Protocol.Document> = {},
21
- ): Protocol.Document {
20
+ overrides: Partial<Protocol.DocumentOutput> = {},
21
+ ): Protocol.DocumentOutput {
22
22
  return {
23
23
  notebook_id: "nb",
24
24
  order: [],
@@ -77,6 +77,8 @@ import { VirtualFileTracker } from "@/core/static/virtual-file-tracker";
77
77
  import { useNotebookSession } from "../useNotebookSession";
78
78
  import { type NotebookTransport, StreamStopped } from "@marimo-team/client";
79
79
 
80
+ const C1 = cellId("c1");
81
+
80
82
  const SESSION_ID = generateSessionId();
81
83
 
82
84
  /** One connection the fake transport opened. */
@@ -270,8 +272,8 @@ describe("useNotebookSession document model", () => {
270
272
  fixtureMessages("notebook-events.sse").forEach(connection(fake).receive);
271
273
  });
272
274
  const model = result.current.documentModel;
273
- const code = () => store.get(model.documentAtom)?.cells.get("c1")?.code;
274
- act(() => store.set(model.editAtom, (tx) => tx.setCode("c1", "local")));
275
+ const code = () => store.get(model.documentAtom)?.cells.get(C1)?.code;
276
+ act(() => store.set(model.editAtom, (tx) => tx.setCode(C1, "local")));
275
277
  expect(code()).toBe("local");
276
278
 
277
279
  await act(async () => connection(fake).drop());
@@ -335,7 +337,9 @@ describe("useNotebookSession document model", () => {
335
337
  });
336
338
 
337
339
  const model = result.current.documentModel;
338
- act(() => store.set(model.editAtom, (tx) => tx.setCode("c3", "x = 42")));
340
+ act(() =>
341
+ store.set(model.editAtom, (tx) => tx.setCode(cellId("c3"), "x = 42")),
342
+ );
339
343
  notebook = store.get(notebookAtom);
340
344
  expect(notebook.cellData[cellId("c3")].code).toBe("x = 42");
341
345
 
@@ -421,7 +425,8 @@ describe("useNotebookSession messages", () => {
421
425
  expect(blocked()).toEqual(new Set(["b", "c"]));
422
426
 
423
427
  const badge = () =>
424
- cellExecutionView(store.get(cellExecutionInputsAtom), "b").shownBlock;
428
+ cellExecutionView(store.get(cellExecutionInputsAtom), cellId("b"))
429
+ .shownBlock;
425
430
  expect(badge()).toBe("current");
426
431
  publish(2);
427
432
  expect(blocked().size).toBe(0);
@@ -2,7 +2,7 @@
2
2
 
3
3
  /** The editor session's replica, following its backend while mounted. */
4
4
 
5
- import type { Execution } from "@marimo-team/client/protocol";
5
+ import type { ExecutionOutput as Execution } from "@marimo-team/client/protocol";
6
6
  import { consoleObservers } from "../cells/execution-console";
7
7
  import { useReducerActions } from "../cells/cells";
8
8
  import { useStore } from "jotai";
@@ -412,7 +412,7 @@ export function useNotebookSession(opts: { sessionId: SessionId }) {
412
412
  },
413
413
  checkHealth: () => runtimeManager.reconcileFromHealth(),
414
414
  onExecution: (record) => {
415
- const cellId = (record.cell_id ?? SCRATCH_CELL_ID) as CellId;
415
+ const cellId = record.cell_id ?? SCRATCH_CELL_ID;
416
416
  const time = completedAt(record) ?? startedAt(record);
417
417
  const timestamp =
418
418
  time === null ? Date.now() / 1000 : Date.parse(time) / 1000;
@@ -3,6 +3,7 @@
3
3
  import { createNotebookReducer, NotebookEvents } from "@marimo-team/client";
4
4
  import type * as Protocol from "@marimo-team/client/protocol";
5
5
  import { afterEach, assert, describe, expect, it, vi } from "vitest";
6
+ import { runId } from "@/__tests__/branded";
6
7
  import type { NotebookBackend } from "../../notebook/replica";
7
8
  import { document as documentResource } from "../../notebook/replica/resources/document";
8
9
  import { executions } from "../../notebook/replica/resources/executions";
@@ -108,9 +109,9 @@ describe("static notebook backend", () => {
108
109
  it("delivers embedded results as completed executions after the document", async () => {
109
110
  const source = snapshot();
110
111
  const cell = source.cells[0];
111
- const execution: Protocol.Execution = {
112
+ const execution: Protocol.ExecutionOutput = {
112
113
  id: "embedded:result",
113
- run_id: "embedded:run",
114
+ run_id: runId("embedded:run"),
114
115
  runtime_id: "embedded",
115
116
  caused_by_id: null,
116
117
  cell_id: cell.id,
@@ -10,14 +10,14 @@ import type { NotebookBackend } from "../notebook/replica";
10
10
  export interface StaticNotebookSnapshot {
11
11
  readonly notebook: Omit<Protocol.Notebook, "operations">;
12
12
  readonly document: Protocol.Document;
13
- readonly cells: readonly Protocol.Cell[];
13
+ readonly cells: readonly Protocol.CellOutput[];
14
14
  /** What the cells last produced, as completed executions and their outputs. */
15
15
  readonly results: readonly StaticResult[];
16
16
  }
17
17
 
18
18
  /** A completed execution and the output it showed, if it set one. */
19
19
  export interface StaticResult {
20
- readonly execution: Protocol.Execution;
20
+ readonly execution: Protocol.ExecutionOutput;
21
21
  readonly output: Protocol.Output | null;
22
22
  }
23
23
 
@@ -1,6 +1,7 @@
1
1
  /* Copyright 2026 Marimo. All rights reserved. */
2
2
  /* oxlint-disable typescript/no-explicit-any */
3
3
 
4
+ import type { RunOutput } from "@marimo-team/client/protocol";
4
5
  import { createRPCRequestHandler } from "rpc-anywhere";
5
6
  import { toast } from "@/components/ui/use-toast";
6
7
  import { userConfigAtom } from "@/core/config/config";
@@ -349,10 +350,10 @@ export class PyodideBridge implements RunRequests, EditRequests {
349
350
  if (replica === null) {
350
351
  return false;
351
352
  }
352
- return (
353
- store.get(replica.executionsAtom).runs.get(runId)?.state.status ===
354
- "running"
355
- );
353
+ const runs: ReadonlyMap<string, RunOutput> = store.get(
354
+ replica.executionsAtom,
355
+ ).runs;
356
+ return runs.get(runId)?.state.status === "running";
356
357
  }
357
358
 
358
359
  public sendRename: EditRequests["sendRename"] = async ({ filename }) => {