@marimo-team/islands 0.25.3-dev463 → 0.25.3-dev465

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 (47) hide show
  1. package/dist/{ErrorBoundary-LEY4eR-u.js → ErrorBoundary-Bitt9N44.js} +1 -1
  2. package/dist/{chat-ui-Ow2U38zW.js → chat-ui-BJSYaekC.js} +3 -3
  3. package/dist/{code-visibility-B6vd-MS9.js → code-visibility-CK8BfIsO.js} +3 -3
  4. package/dist/{common-CmFmwC3k.js → common-C-TqeXix.js} +4 -4
  5. package/dist/{data-grid-overlay-editor-DLAyzP8s.js → data-grid-overlay-editor-CilodNKx.js} +1 -1
  6. package/dist/{error-entries-DEV4YOvI.js → error-entries-CNH4hNt-.js} +272 -261
  7. package/dist/{feedback-button-ln7KZEYq.js → feedback-button-B_nA4iPT.js} +3 -3
  8. package/dist/{glide-data-editor-DwVqbx2W.js → glide-data-editor-BQ0Ykfzt.js} +3 -3
  9. package/dist/{globals-DqKjaSau.js → globals-BkrP88Os.js} +1 -1
  10. package/dist/{html-to-image-BdgBPfgg.js → html-to-image-BBX2UucV.js} +1 -1
  11. package/dist/main.js +4556 -4544
  12. package/dist/{number-overlay-editor-D9vaIlf5.js → number-overlay-editor-C9lu04cw.js} +1 -1
  13. package/dist/{process-output-C_EHwiTn.js → process-output-DatAq1xF.js} +2 -2
  14. package/dist/{reveal-component-BrnL8w_N.js → reveal-component-BvH2Wxyh.js} +2 -2
  15. package/package.json +1 -1
  16. package/src/__mocks__/executions.ts +6 -6
  17. package/src/components/dependency-graph/minimap-content.tsx +1 -1
  18. package/src/components/editor/cell/__tests__/useRunCells.test.tsx +1 -1
  19. package/src/components/editor/notebook-cell.tsx +6 -6
  20. package/src/components/editor/renderers/vertical-layout/vertical-layout.tsx +3 -3
  21. package/src/components/slides/slide-cell-view.tsx +2 -2
  22. package/src/core/ai/context/providers/__tests__/error.test.ts +0 -4
  23. package/src/core/cells/__tests__/cell.test.ts +8 -8
  24. package/src/core/cells/__tests__/runs.test.ts +1 -1
  25. package/src/core/cells/__tests__/session.test.ts +2 -2
  26. package/src/core/cells/__tests__/utils.test.ts +2 -2
  27. package/src/core/cells/cell.ts +2 -2
  28. package/src/core/cells/runs.ts +10 -2
  29. package/src/core/cells/session.ts +1 -1
  30. package/src/core/cells/utils.ts +2 -2
  31. package/src/core/executions/__tests__/atoms.test.ts +1 -1
  32. package/src/core/executions/__tests__/input.test.ts +1 -1
  33. package/src/core/executions/__tests__/interrupt.test.ts +3 -7
  34. package/src/core/executions/__tests__/output.test.ts +26 -5
  35. package/src/core/executions/__tests__/run.test.ts +35 -24
  36. package/src/core/executions/__tests__/select.test.ts +4 -4
  37. package/src/core/executions/atoms.ts +15 -6
  38. package/src/core/executions/output.ts +16 -4
  39. package/src/core/notebook/replica/__tests__/executions.test.ts +57 -3
  40. package/src/core/notebook/replica/__tests__/results.test.ts +2 -2
  41. package/src/core/notebook/replica/__tests__/runtime.test.ts +9 -10
  42. package/src/core/notebook/replica/resources/executions.ts +27 -0
  43. package/src/core/notebook/replica/resources/runtime.ts +1 -1
  44. package/src/core/runtime/__tests__/adapter.test.ts +1 -1
  45. package/src/core/runtime/adapter.ts +1 -1
  46. package/src/core/session/useNotebookSession.tsx +1 -1
  47. package/src/core/wasm/__tests__/bridge.test.ts +4 -6
@@ -255,7 +255,9 @@ export function clearCellOutputs(
255
255
  /** The runtime's status, null while the notebook has none or the stream is not ready. */
256
256
  export const runtimeStatusAtom = atom((get) => {
257
257
  const replica = get(activeNotebookReplicaAtom);
258
- return replica === null ? null : (get(replica.runtimeAtom)?.status ?? null);
258
+ return replica === null
259
+ ? null
260
+ : (get(replica.runtimeAtom)?.state.status ?? null);
259
261
  });
260
262
 
261
263
  export const notebookIsRunningAtom = atom((get) =>
@@ -272,7 +274,7 @@ type RuntimeReadiness = "running" | "waiting" | { refused: string };
272
274
  * Whether a run can go to the host now, should wait, or has nothing to wait for.
273
275
  *
274
276
  * A runtime that is starting, or a stream that has not reported yet, will
275
- * settle one way or the other. A failed or absent runtime, or a connection
277
+ * settle one way or the other. An ended or absent runtime, or a connection
276
278
  * that has closed, will not, so a run waiting on it is refused instead.
277
279
  */
278
280
  const runtimeReadinessAtom = atom((get): RuntimeReadiness => {
@@ -292,11 +294,18 @@ const runtimeReadinessAtom = atom((get): RuntimeReadiness => {
292
294
  if (runtime === null) {
293
295
  return { refused: "The notebook has no runtime" };
294
296
  }
295
- switch (runtime.status) {
296
- case "running":
297
+ switch (runtime.state.status) {
298
+ case "ready":
297
299
  return "running";
298
- case "failed":
299
- return { refused: runtime.message ?? "The runtime failed" };
300
+ case "ended": {
301
+ const { outcome } = runtime.state;
302
+ return {
303
+ refused:
304
+ outcome.kind === "failed"
305
+ ? (outcome.message ?? "The runtime failed")
306
+ : "The notebook has no runtime",
307
+ };
308
+ }
300
309
  default:
301
310
  return "waiting";
302
311
  }
@@ -130,8 +130,6 @@ export function cellError(error: Protocol.Error): CellError {
130
130
  };
131
131
  case "internal":
132
132
  return { type: "unknown", msg: error.message, error_type: error.name };
133
- case "interrupted":
134
- return { type: "interruption" };
135
133
  default:
136
134
  return {
137
135
  type: "diagnostic",
@@ -221,9 +219,9 @@ function resultDisplay(result: Result): CellOutput | null {
221
219
  switch (showing.kind) {
222
220
  case "output":
223
221
  return showing.media === null ? null : valueOutput(record, showing.media);
224
- case "error":
222
+ case "failed":
225
223
  return errorOutput(record, [cellError(showing.error)]);
226
- case "interrupted":
224
+ case "cancelled":
227
225
  return errorOutput(record, [{ type: "interruption" }]);
228
226
  case "skipped":
229
227
  return skippedOutput(record, showing);
@@ -321,5 +319,19 @@ export function cellOutputsView(
321
319
  * The latest scratch display, retained until a newer execution shows one.
322
320
  */
323
321
  export function scratchOutputView(executions: Executions): CellOutput | null {
322
+ const failure = executions.scratchFailure;
323
+ // A run that failed before the kernel saw its code has no execution to
324
+ // show, so its own reason stands in for the result.
325
+ if (
326
+ failure !== undefined &&
327
+ executions.scratch?.record.run_id !== failure.runId
328
+ ) {
329
+ return {
330
+ channel: "marimo-error",
331
+ mimetype: ERROR_MIMETYPE,
332
+ data: [{ type: "unknown", msg: failure.message, error_type: null }],
333
+ timestamp: seconds(failure.completedAt),
334
+ };
335
+ }
324
336
  return executions.scratch === null ? null : resultOutput(executions.scratch);
325
337
  }
@@ -52,7 +52,7 @@ describe("executions resource", () => {
52
52
  const done = resource(replay(snapshot));
53
53
  expect(done.executions.get("e7")?.record.state.status).toBe("completed");
54
54
  expect(done.runs.get("run-scratch")?.state).toMatchObject({
55
- outcome: "succeeded",
55
+ outcome: { kind: "succeeded" },
56
56
  });
57
57
  const released = reducer.reduce(
58
58
  replay(snapshot),
@@ -80,7 +80,7 @@ describe("executions resource", () => {
80
80
  },
81
81
  );
82
82
  expect(resource(done).runs.get("run-cells")?.state).toMatchObject({
83
- outcome: "succeeded",
83
+ outcome: { kind: "succeeded" },
84
84
  });
85
85
 
86
86
  const retired = replay(retire("e12", "e12-x"), done);
@@ -173,7 +173,7 @@ describe("executions resource", () => {
173
173
  const gone = resource(replay(inputs, start));
174
174
  expect(gone.executions.has("e-input")).toBe(false);
175
175
  expect(gone.runs.get("run-input")?.state).toMatchObject({
176
- outcome: "interrupted",
176
+ outcome: { kind: "cancelled" },
177
177
  });
178
178
 
179
179
  const orphan = reducer.reduce(
@@ -208,4 +208,58 @@ describe("executions resource", () => {
208
208
  const reset = reducer.reduce(done, { event: "reset", data: {} });
209
209
  expect(resource(reset)).toBe(executions.initial);
210
210
  });
211
+
212
+ it("remembers why the latest scratch run failed until a newer one arrives", () => {
213
+ const run = (
214
+ id: string,
215
+ origin: Protocol.RunOrigin,
216
+ state: Protocol.RunState,
217
+ cursor: string,
218
+ ) =>
219
+ event({
220
+ event: "run",
221
+ id: cursor,
222
+ data: {
223
+ run: { id, notebook_id: "n1", runtime_id: "r1", origin, state },
224
+ time,
225
+ },
226
+ });
227
+ const code: Protocol.RunOrigin = { kind: "code", code: "1" };
228
+ const failed: Protocol.RunState = {
229
+ status: "completed",
230
+ started_at: null,
231
+ completed_at: time,
232
+ outcome: { kind: "failed", message: "Kernel channel closed" },
233
+ };
234
+
235
+ const afterFailure = replay(
236
+ [run("run-9", code, failed, "200")],
237
+ replay(snapshot),
238
+ );
239
+ expect(resource(afterFailure).scratchFailure).toEqual({
240
+ runId: "run-9",
241
+ message: "Kernel channel closed",
242
+ completedAt: time,
243
+ });
244
+
245
+ // Cell runs say nothing about the scratchpad.
246
+ const afterCells = replay(
247
+ [
248
+ run(
249
+ "run-10",
250
+ { kind: "cells", cell_ids: ["c1"] },
251
+ { status: "queued" },
252
+ "201",
253
+ ),
254
+ ],
255
+ afterFailure,
256
+ );
257
+ expect(resource(afterCells).scratchFailure?.runId).toBe("run-9");
258
+
259
+ const afterNext = replay(
260
+ [run("run-11", code, { status: "queued" }, "202")],
261
+ afterCells,
262
+ );
263
+ expect(resource(afterNext).scratchFailure).toBeUndefined();
264
+ });
211
265
  });
@@ -168,7 +168,7 @@ describe("retained results", () => {
168
168
  status: "completed",
169
169
  started_at: null,
170
170
  completed_at: time,
171
- outcome: { kind: "interrupted" },
171
+ outcome: { kind: "cancelled" },
172
172
  depends_on: {},
173
173
  },
174
174
  };
@@ -196,7 +196,7 @@ describe("retained results", () => {
196
196
  expect(resource(cancelled).get("c3")?.record.state).toHaveProperty(
197
197
  "outcome",
198
198
  {
199
- kind: "interrupted",
199
+ kind: "cancelled",
200
200
  },
201
201
  );
202
202
  });
@@ -17,22 +17,22 @@ describe("runtime resource", () => {
17
17
  const state = confirmed();
18
18
  const running = current(state);
19
19
  expect(running?.id).toBe("r1");
20
- expect(running?.status).toBe("running");
20
+ expect(running?.state).toEqual({ status: "ready" });
21
21
 
22
- const terminating = reducer.reduce(state, {
22
+ const stopping = reducer.reduce(state, {
23
23
  event: "runtime",
24
24
  id: "98",
25
- data: { runtime: { ...running!, status: "terminating" } },
25
+ data: { runtime: { ...running!, state: { status: "stopping" } } },
26
26
  });
27
- expect(current(terminating)?.status).toBe("terminating");
28
- expect(current(state)?.status).toBe("running");
27
+ expect(current(stopping)?.state).toEqual({ status: "stopping" });
28
+ expect(current(state)?.state).toEqual({ status: "ready" });
29
29
 
30
- const other = reducer.reduce(terminating, {
30
+ const other = reducer.reduce(stopping, {
31
31
  event: "runtime.removed",
32
32
  id: "99",
33
33
  data: { id: "r0", time },
34
34
  });
35
- expect(current(other)).toBe(current(terminating));
35
+ expect(current(other)).toBe(current(stopping));
36
36
 
37
37
  const removed = reducer.reduce(other, {
38
38
  event: "runtime.removed",
@@ -58,10 +58,9 @@ describe("runtime resource", () => {
58
58
  const replacement = {
59
59
  ...current(state)!,
60
60
  id: "r2",
61
- status: "starting" as const,
62
- message: "Starting the kernel",
63
61
  marimo_version: null,
64
- started_at: "2026-10-01T09:31:00Z",
62
+ created_at: "2026-10-01T09:31:00Z",
63
+ state: { status: "starting" as const, message: "Starting the kernel" },
65
64
  };
66
65
  const starting = reducer.reduce(removed, {
67
66
  event: "runtime",
@@ -45,6 +45,28 @@ export interface Executions {
45
45
  readonly scratch: Result | null;
46
46
  /** The latest scratch execution to start, including one that printed nothing. */
47
47
  readonly scratchConsole?: Execution;
48
+ /** The latest scratch run, if the host could not finish it and says why. */
49
+ readonly scratchFailure?: RunFailure;
50
+ }
51
+
52
+ /** A run the host could not finish, with its reason. */
53
+ export interface RunFailure {
54
+ readonly runId: Protocol.RunId;
55
+ readonly message: string;
56
+ readonly completedAt: string;
57
+ }
58
+
59
+ function hostFailure(run: Protocol.Run): RunFailure | undefined {
60
+ const { state } = run;
61
+ return state.status === "completed" &&
62
+ state.outcome.kind === "failed" &&
63
+ state.outcome.message !== null
64
+ ? {
65
+ runId: run.id,
66
+ message: state.outcome.message,
67
+ completedAt: state.completed_at,
68
+ }
69
+ : undefined;
48
70
  }
49
71
 
50
72
  type Kind =
@@ -275,6 +297,11 @@ export const executions: NotebookResource<Executions, Kind> = {
275
297
  run: (state, { data }) => ({
276
298
  ...state,
277
299
  runs: new Map(state.runs).set(data.run.id, data.run),
300
+ // A newer scratch run replaces what the last one reported.
301
+ scratchFailure:
302
+ data.run.origin.kind === "code"
303
+ ? hostFailure(data.run)
304
+ : state.scratchFailure,
278
305
  }),
279
306
  "run.removed": (state, { data }) =>
280
307
  state.runs.has(data.id)
@@ -3,7 +3,7 @@
3
3
  import type { Runtime } from "@marimo-team/client/protocol";
4
4
  import type { NotebookResource } from "@marimo-team/client";
5
5
 
6
- /** The notebook's runtime record while it has one. */
6
+ /** The notebook's runtime record, kept after the runtime ends. */
7
7
  export const runtime: NotebookResource<Runtime | null, "runtime"> = {
8
8
  initial: null,
9
9
  on: {
@@ -128,7 +128,7 @@ describe("canRunCellsAtom", () => {
128
128
  store.set(connectionAtom, { state: ConnectionState.OPEN });
129
129
  expect(store.get(canRunCellsAtom)).toBe(false);
130
130
 
131
- MockExecutions.seed(store, [], MockExecutions.runtime("running"));
131
+ MockExecutions.seed(store, [], MockExecutions.runtime());
132
132
  expect(store.get(canRunCellsAtom)).toBe(true);
133
133
  });
134
134
 
@@ -169,7 +169,7 @@ export const canRunCellsAtom = atom<boolean>((get) => {
169
169
  return false;
170
170
  }
171
171
  if (adapter.kind === "remote") {
172
- return get(runtimeStatusAtom) === "running";
172
+ return get(runtimeStatusAtom) === "ready";
173
173
  }
174
174
  return true;
175
175
  });
@@ -443,7 +443,7 @@ export function useNotebookSession(opts: { sessionId: SessionId }) {
443
443
  time === null ? Date.now() / 1000 : Date.parse(time) / 1000;
444
444
  if (
445
445
  record.state.status === "completed" &&
446
- record.state.outcome?.kind === "error"
446
+ record.state.outcome.kind === "failed"
447
447
  ) {
448
448
  getCellLogsForMessage({
449
449
  cell_id: cellId,
@@ -341,10 +341,9 @@ it.each(["running", "completed", null])(
341
341
  body: {
342
342
  id: "r1",
343
343
  notebook_id: "n1",
344
- status: "running",
345
- message: null,
346
344
  marimo_version: null,
347
- started_at: "2026-10-01T09:20:11Z",
345
+ created_at: "2026-10-01T09:20:11Z",
346
+ state: { status: "ready" },
348
347
  },
349
348
  };
350
349
  mockNotebookCall.mockImplementation(async () => {
@@ -479,10 +478,9 @@ it("signals an interrupt once across pending, completed, and lost-reply retries"
479
478
  body: {
480
479
  id: "r1",
481
480
  notebook_id: "n1",
482
- status: "running",
483
- message: null,
484
481
  marimo_version: null,
485
- started_at: "2026-10-01T09:20:11Z",
482
+ created_at: "2026-10-01T09:20:11Z",
483
+ state: { status: "ready" },
486
484
  },
487
485
  };
488
486
  mockNotebookCall.mockImplementation(() => pending.promise);