@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.
- package/dist/{ErrorBoundary-CYipPzuL.js → ErrorBoundary-C5X_T831.js} +1 -1
- package/dist/{chat-ui-b1ERxzeA.js → chat-ui-qZdDDrzU.js} +3 -3
- package/dist/{code-visibility-D2uVdtAQ.js → code-visibility-7FxdzbDq.js} +2 -2
- package/dist/{common-d-UA4Z2n.js → common-D-iTRwaQ.js} +3 -3
- package/dist/{data-grid-overlay-editor-BfZIG_OX.js → data-grid-overlay-editor-DoWUW2oW.js} +1 -1
- package/dist/{error-entries-Bl8fzLQc.js → error-entries-DhI0hGvj.js} +448 -450
- package/dist/{feedback-button-Ct0bgfAh.js → feedback-button-OUiV15AL.js} +3 -3
- package/dist/{glide-data-editor-D9EGRA-V.js → glide-data-editor-CFouYM6e.js} +3 -3
- package/dist/{globals-UnK9bjY3.js → globals-B_U6Frqj.js} +1 -1
- package/dist/{html-to-image-D6A1lg0A.js → html-to-image-B803aaWE.js} +1 -1
- package/dist/main.js +3213 -3203
- package/dist/{number-overlay-editor-DMasuqqm.js → number-overlay-editor-CiQQjf9m.js} +1 -1
- package/dist/{process-output-w5omHedc.js → process-output-CnCLfvnL.js} +2 -2
- package/dist/{reveal-component-v6w_cxzA.js → reveal-component-B73BObRc.js} +2 -2
- package/package.json +1 -1
- package/src/__mocks__/executions.ts +20 -19
- package/src/__mocks__/notebook.ts +1 -1
- package/src/__tests__/branded.ts +4 -0
- package/src/components/editor/actions/__tests__/name-cell-input.test.tsx +1 -1
- package/src/components/editor/cell/__tests__/useRunCells.test.tsx +5 -5
- package/src/components/editor/chrome/wrapper/__tests__/document-sync-status.test.tsx +5 -2
- package/src/components/tracing/tracing-keyboard.test.tsx +4 -3
- package/src/core/ai/context/providers/__tests__/error.test.ts +6 -3
- package/src/core/cells/__tests__/actions.test.ts +2 -2
- package/src/core/cells/__tests__/arrange.test.ts +1 -1
- package/src/core/cells/__tests__/harness.ts +9 -7
- package/src/core/cells/__tests__/layout.test.ts +1 -1
- package/src/core/cells/__tests__/runs.test.ts +14 -14
- package/src/core/cells/__tests__/utils.test.ts +3 -2
- package/src/core/cells/actions.ts +6 -6
- package/src/core/cells/cells.ts +1 -1
- package/src/core/cells/document.ts +1 -2
- package/src/core/cells/execution-console.ts +3 -3
- package/src/core/cells/ids.ts +2 -4
- package/src/core/cells/runs.ts +7 -5
- package/src/core/cells/session.ts +8 -5
- package/src/core/executions/__tests__/atoms.test.ts +7 -4
- package/src/core/executions/__tests__/freshness.test.ts +57 -53
- package/src/core/executions/__tests__/interrupt.test.ts +4 -3
- package/src/core/executions/__tests__/output-lifecycle.test.ts +3 -3
- package/src/core/executions/__tests__/output.test.ts +5 -3
- package/src/core/executions/__tests__/run.test.ts +4 -4
- package/src/core/executions/__tests__/select.test.ts +75 -67
- package/src/core/executions/atoms.ts +2 -2
- package/src/core/executions/freshness.ts +5 -5
- package/src/core/executions/output.ts +15 -21
- package/src/core/executions/select.ts +17 -9
- package/src/core/export/__tests__/hooks.test.ts +1 -1
- package/src/core/meta/__tests__/code-visibility.test.tsx +3 -2
- package/src/core/notebook/document/__tests__/codemirror.test.ts +8 -6
- package/src/core/notebook/document/__tests__/draft.test.ts +56 -58
- package/src/core/notebook/document/__tests__/fixtures.ts +8 -7
- package/src/core/notebook/document/__tests__/hooks.test.tsx +39 -35
- package/src/core/notebook/document/__tests__/lifecycle-scenarios.test.ts +8 -5
- package/src/core/notebook/document/__tests__/model.test.ts +8 -5
- package/src/core/notebook/document/__tests__/protocol-fixtures.ts +2 -2
- package/src/core/notebook/document/__tests__/recovery-scenarios.test.ts +37 -32
- package/src/core/notebook/document/__tests__/scenarios.test.ts +49 -45
- package/src/core/notebook/document/__tests__/state.test.ts +59 -56
- package/src/core/notebook/document/__tests__/submission.test.ts +15 -12
- package/src/core/notebook/document/__tests__/test-host.ts +3 -2
- package/src/core/notebook/document/__tests__/user.ts +7 -3
- package/src/core/notebook/document/draft.ts +29 -11
- package/src/core/notebook/document/state.ts +7 -6
- package/src/core/notebook/replica/__tests__/document.test.ts +9 -5
- package/src/core/notebook/replica/__tests__/executions.test.ts +16 -11
- package/src/core/notebook/replica/__tests__/fixtures.ts +6 -2
- package/src/core/notebook/replica/__tests__/replica.test.ts +7 -2
- package/src/core/notebook/replica/__tests__/results.test.ts +23 -19
- package/src/core/notebook/replica/execution-state.ts +2 -2
- package/src/core/notebook/replica/replica.ts +2 -2
- package/src/core/notebook/replica/resources/analysis.ts +1 -1
- package/src/core/notebook/replica/resources/document.ts +9 -8
- package/src/core/notebook/replica/resources/executions.ts +2 -2
- package/src/core/notebook/replica/resources/results.ts +2 -2
- package/src/core/saving/__tests__/document.test.tsx +1 -1
- package/src/core/saving/__tests__/state.test.ts +2 -2
- package/src/core/session/__tests__/useNotebookSession.hook.test.tsx +9 -4
- package/src/core/session/useNotebookReplica.ts +1 -1
- package/src/core/session/useNotebookSession.tsx +1 -1
- package/src/core/transports/__tests__/static.test.ts +3 -2
- package/src/core/transports/static.ts +2 -2
- package/src/core/wasm/bridge.ts +5 -4
|
@@ -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-
|
|
3
|
+
import { a as n } from "./glide-data-editor-CFouYM6e.js";
|
|
4
4
|
//#region ../node_modules/.pnpm/@glideapps+glide-data-grid@6.0.4-alpha24_lodash@4.18.1_marked@15.0.12_react-dom@19.3.1__a94b4518d090e84da26f3a68e82f2953/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",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { T as e } from "./html-to-image-
|
|
1
|
+
import { T as e } from "./html-to-image-B803aaWE.js";
|
|
2
2
|
import { h as t } from "./tooltip-D0h-ZJ6j.js";
|
|
3
|
-
import { Tt as n, wt as r } from "./error-entries-
|
|
3
|
+
import { Tt as n, wt as r } from "./error-entries-DhI0hGvj.js";
|
|
4
4
|
import { r as i } from "./assertNever-CqwxSD_2.js";
|
|
5
5
|
var a = t("file", [["path", {
|
|
6
6
|
d: "M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",
|
|
@@ -3,14 +3,14 @@ import { g as t, h as n, m as r, r as i, t as a } from "./button-Z2R2272J.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-D0h-ZJ6j.js";
|
|
6
|
-
import { Cn as u, En as d, Sn as f, dn as p, et as m, f as h, i as g, l as _, n as v, nt as y, r as b, t as x, tt as S, u as C } from "./common-
|
|
6
|
+
import { Cn as u, En as d, Sn as f, dn as p, et as m, f as h, i as g, l as _, n as v, nt as y, r as b, t as x, tt as S, u as C } from "./common-D-iTRwaQ.js";
|
|
7
7
|
import { M as w } from "./select-CvorIE3l.js";
|
|
8
8
|
import { X as T } from "./dropdown-menu-ChH3oiqI.js";
|
|
9
9
|
import { t as E } from "./jsx-runtime-D8btoEHk.js";
|
|
10
10
|
import { Ht as D, f as O, i as k, zt as A } from "./use-restore-focus-BFvwj2Hj.js";
|
|
11
11
|
import { t as j } from "./useEvent-BoN7U38T.js";
|
|
12
12
|
import { o as ee } from "./static-state-CqwW3B_X.js";
|
|
13
|
-
import { n as te, t as ne } from "./code-visibility-
|
|
13
|
+
import { n as te, t as ne } from "./code-visibility-7FxdzbDq.js";
|
|
14
14
|
/* empty css */
|
|
15
15
|
var M = c("sticky-note", [["path", {
|
|
16
16
|
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
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
/** Executions as the host would report them, for tests that read cell status. */
|
|
4
4
|
|
|
5
|
+
import { cellId, runId } from "@/__tests__/branded";
|
|
5
6
|
import type * as Protocol from "@marimo-team/client/protocol";
|
|
6
7
|
import { atom, type createStore } from "jotai";
|
|
7
8
|
import type { CellExecutionInputs } from "@/core/executions";
|
|
@@ -34,10 +35,10 @@ const T1 = "2026-10-01T09:20:12.500Z";
|
|
|
34
35
|
let sequence = 0;
|
|
35
36
|
|
|
36
37
|
const READY: Protocol.RuntimeState = { status: "ready" };
|
|
37
|
-
const SUCCEEDED: Protocol.
|
|
38
|
+
const SUCCEEDED: Protocol.ExecutionOutcomeOutput = { kind: "succeeded" };
|
|
38
39
|
|
|
39
40
|
/** An execution, or the output it set, as the stream delivers them. */
|
|
40
|
-
type ExecutionFixture = Protocol.
|
|
41
|
+
type ExecutionFixture = Protocol.ExecutionOutput & { items?: readonly Item[] };
|
|
41
42
|
type Entry = ExecutionFixture | Protocol.Output;
|
|
42
43
|
export type ExecutionEntries = ReadonlyArray<Entry | readonly Entry[]>;
|
|
43
44
|
|
|
@@ -55,16 +56,16 @@ function split(entries: ExecutionEntries) {
|
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
function execution(
|
|
58
|
-
|
|
59
|
-
state: Protocol.
|
|
60
|
-
): Protocol.
|
|
59
|
+
cid: string | null,
|
|
60
|
+
state: Protocol.ExecutionStateOutput,
|
|
61
|
+
): Protocol.ExecutionOutput {
|
|
61
62
|
sequence += 1;
|
|
62
63
|
return {
|
|
63
64
|
id: `e${sequence}`,
|
|
64
|
-
run_id: "run-1",
|
|
65
|
+
run_id: runId("run-1"),
|
|
65
66
|
runtime_id: "r1",
|
|
66
67
|
caused_by_id: null,
|
|
67
|
-
cell_id: cellId,
|
|
68
|
+
cell_id: cid === null ? null : cellId(cid),
|
|
68
69
|
code_fingerprint: "0f71456db2ea83f4",
|
|
69
70
|
created_at: T0,
|
|
70
71
|
state,
|
|
@@ -73,8 +74,8 @@ function execution(
|
|
|
73
74
|
|
|
74
75
|
function completed(
|
|
75
76
|
cellId: string | null,
|
|
76
|
-
outcome: Protocol.
|
|
77
|
-
): Protocol.
|
|
77
|
+
outcome: Protocol.ExecutionOutcomeOutput = SUCCEEDED,
|
|
78
|
+
): Protocol.ExecutionOutput {
|
|
78
79
|
return execution(cellId, {
|
|
79
80
|
status: "completed",
|
|
80
81
|
started_at: T0,
|
|
@@ -156,7 +157,7 @@ export const MockExecutions = {
|
|
|
156
157
|
completed,
|
|
157
158
|
|
|
158
159
|
/** A completed execution that took `elapsedMs`. */
|
|
159
|
-
took(cellId: string, elapsedMs: number): Protocol.
|
|
160
|
+
took(cellId: string, elapsedMs: number): Protocol.ExecutionOutput {
|
|
160
161
|
return execution(cellId, {
|
|
161
162
|
status: "completed",
|
|
162
163
|
started_at: T0,
|
|
@@ -170,8 +171,8 @@ export const MockExecutions = {
|
|
|
170
171
|
shown(
|
|
171
172
|
cellId: string | null,
|
|
172
173
|
display: Protocol.Media,
|
|
173
|
-
fields: Partial<Omit<Protocol.
|
|
174
|
-
): readonly [Protocol.
|
|
174
|
+
fields: Partial<Omit<Protocol.ExecutionOutput, "id" | "state">> = {},
|
|
175
|
+
): readonly [Protocol.ExecutionOutput, Protocol.Output] {
|
|
175
176
|
const execution = { ...completed(cellId), ...fields };
|
|
176
177
|
return [execution, output(execution, display)];
|
|
177
178
|
},
|
|
@@ -179,8 +180,8 @@ export const MockExecutions = {
|
|
|
179
180
|
/** A completed execution that ended in `error`, a ValueError by default. */
|
|
180
181
|
failed(
|
|
181
182
|
cellId: string,
|
|
182
|
-
error: Partial<Protocol.
|
|
183
|
-
): Protocol.
|
|
183
|
+
error: Partial<Protocol.ErrorOutput> = {},
|
|
184
|
+
): Protocol.ExecutionOutput {
|
|
184
185
|
return completed(cellId, {
|
|
185
186
|
kind: "failed",
|
|
186
187
|
error: {
|
|
@@ -197,15 +198,15 @@ export const MockExecutions = {
|
|
|
197
198
|
});
|
|
198
199
|
},
|
|
199
200
|
|
|
200
|
-
errored(cellId: string): Protocol.
|
|
201
|
+
errored(cellId: string): Protocol.ExecutionOutput {
|
|
201
202
|
return MockExecutions.failed(cellId);
|
|
202
203
|
},
|
|
203
204
|
|
|
204
|
-
interrupted(cellId: string | null): Protocol.
|
|
205
|
+
interrupted(cellId: string | null): Protocol.ExecutionOutput {
|
|
205
206
|
return completed(cellId, { kind: "cancelled" });
|
|
206
207
|
},
|
|
207
208
|
|
|
208
|
-
skipped(cellId: string): Protocol.
|
|
209
|
+
skipped(cellId: string): Protocol.ExecutionOutput {
|
|
209
210
|
return completed(cellId, {
|
|
210
211
|
kind: "skipped",
|
|
211
212
|
reason: "ancestor-stopped",
|
|
@@ -214,11 +215,11 @@ export const MockExecutions = {
|
|
|
214
215
|
});
|
|
215
216
|
},
|
|
216
217
|
|
|
217
|
-
running(cellId: string | null): Protocol.
|
|
218
|
+
running(cellId: string | null): Protocol.ExecutionOutput {
|
|
218
219
|
return execution(cellId, { status: "running", started_at: T0 });
|
|
219
220
|
},
|
|
220
221
|
|
|
221
|
-
queued(cellId: string | null): Protocol.
|
|
222
|
+
queued(cellId: string | null): Protocol.ExecutionOutput {
|
|
222
223
|
return execution(cellId, { status: "queued" });
|
|
223
224
|
},
|
|
224
225
|
|
package/src/__tests__/branded.ts
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* everywhere.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
+
import type { RunId } from "@marimo-team/client/protocol";
|
|
13
14
|
import type { components } from "@marimo-team/marimo-api";
|
|
14
15
|
import type { CellId, UIElementId } from "@/core/cells/ids";
|
|
15
16
|
import type { RequestId } from "@/core/network/DeferredRequestRegistry";
|
|
@@ -18,7 +19,10 @@ import type { VariableName } from "@/core/variables/types";
|
|
|
18
19
|
type WidgetModelId = components["schemas"]["WidgetModelId"];
|
|
19
20
|
type Base64String = components["schemas"]["Base64String"];
|
|
20
21
|
|
|
22
|
+
// SAFETY: The fixture author supplies a valid value for each brand, such as
|
|
23
|
+
// the nonempty ID of the run represented in the fixture.
|
|
21
24
|
export const cellId = (s: string) => s as CellId;
|
|
25
|
+
export const runId = (s: string) => s as RunId;
|
|
22
26
|
export const variableName = (s: string) => s as VariableName;
|
|
23
27
|
export const requestId = (s: string) => s as RequestId;
|
|
24
28
|
export const uiElementId = (s: string) => s as UIElementId;
|
|
@@ -63,7 +63,7 @@ describe("NameCellContentEditable", () => {
|
|
|
63
63
|
Object.defineProperty(field, "innerText", { value: " renamed " });
|
|
64
64
|
fireEvent.blur(field);
|
|
65
65
|
|
|
66
|
-
expect(store.get(model.documentAtom)?.cells.get("c1")?.name).toBe(
|
|
66
|
+
expect(store.get(model.documentAtom)?.cells.get(cellId("c1"))?.name).toBe(
|
|
67
67
|
"renamed",
|
|
68
68
|
);
|
|
69
69
|
});
|
|
@@ -7,7 +7,7 @@ import type { ReactNode } from "react";
|
|
|
7
7
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
8
8
|
import { MockExecutions } from "@/__mocks__/executions";
|
|
9
9
|
import { MockNotebook } from "@/__mocks__/notebook";
|
|
10
|
-
import { cellId } from "@/__tests__/branded";
|
|
10
|
+
import { cellId, runId } from "@/__tests__/branded";
|
|
11
11
|
import { notebookAtom } from "@/core/cells/cells";
|
|
12
12
|
import type { DocumentModel } from "@/core/notebook/document";
|
|
13
13
|
import {
|
|
@@ -35,12 +35,12 @@ const wrapper = ({ children }: { children: ReactNode }) => (
|
|
|
35
35
|
<Provider store={store}>{children}</Provider>
|
|
36
36
|
);
|
|
37
37
|
|
|
38
|
-
function accepted(cells:
|
|
38
|
+
function accepted(cells: string[]): Protocol.RunOutput {
|
|
39
39
|
return {
|
|
40
|
-
id: "run-1",
|
|
40
|
+
id: runId("run-1"),
|
|
41
41
|
notebook_id: "n1",
|
|
42
42
|
runtime_id: "r1",
|
|
43
|
-
origin: { kind: "cells", cell_ids: cells },
|
|
43
|
+
origin: { kind: "cells", cell_ids: cells.map(cellId) },
|
|
44
44
|
created_at: "2026-10-01T09:20:00Z",
|
|
45
45
|
state: { status: "queued" },
|
|
46
46
|
};
|
|
@@ -62,7 +62,7 @@ describe("useRunStaleCells", () => {
|
|
|
62
62
|
store.set(activeDocumentModelAtom, null);
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
-
function seed(records: Protocol.
|
|
65
|
+
function seed(records: Protocol.ExecutionOutput[]) {
|
|
66
66
|
const document = documentOf();
|
|
67
67
|
const replica = MockExecutions.seed(
|
|
68
68
|
store,
|
|
@@ -12,6 +12,9 @@ import {
|
|
|
12
12
|
} from "@/core/notebook/replica/__tests__/fixtures";
|
|
13
13
|
import { activeDocumentModelAtom } from "@/core/session/active-notebook";
|
|
14
14
|
import { DocumentSyncStatus } from "../footer-items/document-sync-status";
|
|
15
|
+
import { cellId } from "@/__tests__/branded";
|
|
16
|
+
|
|
17
|
+
const C1 = cellId("c1");
|
|
15
18
|
|
|
16
19
|
const lifetimes: AbortController[] = [];
|
|
17
20
|
|
|
@@ -28,7 +31,7 @@ const conflict = {
|
|
|
28
31
|
status: 412,
|
|
29
32
|
detail: "cell c1 has changed since it was read.",
|
|
30
33
|
index: 0,
|
|
31
|
-
cell: document().cells.get(
|
|
34
|
+
cell: document().cells.get(C1)!,
|
|
32
35
|
document: document().revision,
|
|
33
36
|
},
|
|
34
37
|
} satisfies Awaited<ReturnType<FakeEdit>>;
|
|
@@ -78,7 +81,7 @@ describe("DocumentSyncStatus", () => {
|
|
|
78
81
|
const { store, model } = setup(edit);
|
|
79
82
|
|
|
80
83
|
await act(async () => {
|
|
81
|
-
store.set(model.editAtom, (tx) => tx.setCode(
|
|
84
|
+
store.set(model.editAtom, (tx) => tx.setCode(C1, "x = 2"));
|
|
82
85
|
await model.flush().catch(() => undefined);
|
|
83
86
|
});
|
|
84
87
|
const item = screen.getByTestId("footer-document-sync");
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
2
|
|
|
3
|
+
import { runId } from "@/__tests__/branded";
|
|
3
4
|
import { act, fireEvent, render, screen } from "@testing-library/react";
|
|
4
5
|
import { createStore, Provider } from "jotai";
|
|
5
6
|
import { describe, expect, it, vi } from "vitest";
|
|
6
7
|
import { TooltipProvider } from "@/components/ui/tooltip";
|
|
7
|
-
import { type Run,
|
|
8
|
+
import { type Run, runsAtom } from "@/core/cells/runs";
|
|
8
9
|
import { Tracing } from "./tracing";
|
|
9
10
|
|
|
10
11
|
vi.mock("react-vega", () => ({ useVegaEmbed: () => undefined }));
|
|
@@ -14,7 +15,7 @@ vi.mock("@/components/editor/chrome/panels/panel-context", () => ({
|
|
|
14
15
|
}));
|
|
15
16
|
|
|
16
17
|
const run: Run = {
|
|
17
|
-
runId: "run-1"
|
|
18
|
+
runId: runId("run-1"),
|
|
18
19
|
runStartTime: 1_704_067_200,
|
|
19
20
|
cellRuns: new Map(),
|
|
20
21
|
};
|
|
@@ -67,7 +68,7 @@ describe("trace disclosure keyboard focus", () => {
|
|
|
67
68
|
act(() => header.focus());
|
|
68
69
|
const newer: Run = {
|
|
69
70
|
...run,
|
|
70
|
-
runId: "run-2"
|
|
71
|
+
runId: runId("run-2"),
|
|
71
72
|
runStartTime: run.runStartTime + 1,
|
|
72
73
|
};
|
|
73
74
|
act(() => {
|
|
@@ -8,11 +8,11 @@ import { MockNotebook } from "@/__mocks__/notebook";
|
|
|
8
8
|
import { type CellId, CellId as CellIdClass } from "@/core/cells/ids";
|
|
9
9
|
import { ErrorContextProvider } from "../error";
|
|
10
10
|
|
|
11
|
-
const SYNTAX: Partial<Protocol.
|
|
11
|
+
const SYNTAX: Partial<Protocol.ErrorOutput> = {
|
|
12
12
|
kind: "invalid-syntax",
|
|
13
13
|
message: "Invalid syntax",
|
|
14
14
|
};
|
|
15
|
-
const RUNTIME: Partial<Protocol.
|
|
15
|
+
const RUNTIME: Partial<Protocol.ErrorOutput> = {
|
|
16
16
|
kind: "exception",
|
|
17
17
|
name: "RuntimeError",
|
|
18
18
|
message: "Runtime error",
|
|
@@ -332,7 +332,10 @@ describe("ErrorContextProvider", () => {
|
|
|
332
332
|
|
|
333
333
|
describe("error description handling", () => {
|
|
334
334
|
it("describes each kind of host error", () => {
|
|
335
|
-
const errors: {
|
|
335
|
+
const errors: {
|
|
336
|
+
error: Partial<Protocol.ErrorOutput>;
|
|
337
|
+
expected: string;
|
|
338
|
+
}[] = [
|
|
336
339
|
{
|
|
337
340
|
error: { kind: "exception", message: "Runtime exception" },
|
|
338
341
|
expected: "Runtime exception",
|
|
@@ -53,7 +53,7 @@ afterEach(() => {
|
|
|
53
53
|
vi.clearAllMocks();
|
|
54
54
|
});
|
|
55
55
|
|
|
56
|
-
const setup = (cells?: Record<string, Protocol.
|
|
56
|
+
const setup = (cells?: Record<string, Protocol.CellOutput | null>) =>
|
|
57
57
|
setupNotebook(stops, cells);
|
|
58
58
|
|
|
59
59
|
describe("createCellAtom", () => {
|
|
@@ -456,7 +456,7 @@ describe("undoDeleteCellAtom", () => {
|
|
|
456
456
|
type: "delete",
|
|
457
457
|
cells: [
|
|
458
458
|
{
|
|
459
|
-
cell: { id: "c9", code: "q = 9" },
|
|
459
|
+
cell: { id: cellId("c9"), code: "q = 9", name: "_" },
|
|
460
460
|
placement: { after: cellId("gone") },
|
|
461
461
|
serializedEditorState: null,
|
|
462
462
|
},
|
|
@@ -44,7 +44,7 @@ afterEach(() => {
|
|
|
44
44
|
}
|
|
45
45
|
});
|
|
46
46
|
|
|
47
|
-
const setup = (cells?: Record<string, Protocol.
|
|
47
|
+
const setup = (cells?: Record<string, Protocol.CellOutput | null>) =>
|
|
48
48
|
setupNotebook(stops, cells);
|
|
49
49
|
|
|
50
50
|
/** Four cells, the last two in a second column. */
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
2
|
|
|
3
|
+
import { cellId } from "@/__tests__/branded";
|
|
3
4
|
import { defaultUserConfig } from "@/core/config/config-schema";
|
|
4
5
|
|
|
5
6
|
/** A store whose notebook follows a document model, as the session wires it. */
|
|
@@ -12,7 +13,6 @@ import type * as Protocol from "@marimo-team/client/protocol";
|
|
|
12
13
|
import { createStore } from "jotai";
|
|
13
14
|
import { mockDocumentModel } from "@/__mocks__/document";
|
|
14
15
|
import { MockExecutions } from "@/__mocks__/executions";
|
|
15
|
-
import type { CellId } from "@/core/cells/ids";
|
|
16
16
|
import { adaptiveLanguageConfiguration } from "@/core/codemirror/language/extension";
|
|
17
17
|
import { OverridingHotkeyProvider } from "@/core/hotkeys/hotkeys";
|
|
18
18
|
import {
|
|
@@ -26,7 +26,7 @@ import { layoutAtom } from "../layout";
|
|
|
26
26
|
|
|
27
27
|
export function setupNotebook(
|
|
28
28
|
stops: Array<() => void>,
|
|
29
|
-
cells?: Record<string, Protocol.
|
|
29
|
+
cells?: Record<string, Protocol.CellOutput | null>,
|
|
30
30
|
) {
|
|
31
31
|
const store = createStore();
|
|
32
32
|
store.set(notebookAtom, exportedForTesting.initialNotebookState());
|
|
@@ -39,7 +39,7 @@ export function setupNotebook(
|
|
|
39
39
|
/** What the host shows for each cell, by cell id. */
|
|
40
40
|
const results = new Map<
|
|
41
41
|
string,
|
|
42
|
-
readonly [Protocol.
|
|
42
|
+
readonly [Protocol.ExecutionOutput, Protocol.Output]
|
|
43
43
|
>();
|
|
44
44
|
followDocument({
|
|
45
45
|
store,
|
|
@@ -64,9 +64,11 @@ export function setupNotebook(
|
|
|
64
64
|
/** The columns' ids, as the page keys them. */
|
|
65
65
|
columnIds: () => store.get(layoutAtom).columns.map((column) => column.id),
|
|
66
66
|
notebook: () => store.get(notebookAtom),
|
|
67
|
-
cellIn: (id: string) =>
|
|
67
|
+
cellIn: (id: string) =>
|
|
68
|
+
store.get(model.documentAtom)?.cells.get(cellId(id)),
|
|
68
69
|
/** Give a cell an editor, as mounting it would, with a cell's language setup. */
|
|
69
|
-
mountEditor: (
|
|
70
|
+
mountEditor: (rawId: string) => {
|
|
71
|
+
const id = cellId(rawId);
|
|
70
72
|
const view = new EditorView({
|
|
71
73
|
state: EditorState.create({
|
|
72
74
|
doc: store.get(model.documentAtom)?.cells.get(id)?.code ?? "",
|
|
@@ -74,7 +76,7 @@ export function setupNotebook(
|
|
|
74
76
|
history(),
|
|
75
77
|
python(),
|
|
76
78
|
adaptiveLanguageConfiguration({
|
|
77
|
-
cellId: id
|
|
79
|
+
cellId: id,
|
|
78
80
|
completionConfig: {
|
|
79
81
|
...defaultUserConfig().completion,
|
|
80
82
|
activate_on_typing: true,
|
|
@@ -88,7 +90,7 @@ export function setupNotebook(
|
|
|
88
90
|
],
|
|
89
91
|
}),
|
|
90
92
|
});
|
|
91
|
-
store.get(notebookAtom).cellHandles[id
|
|
93
|
+
store.get(notebookAtom).cellHandles[id].current = {
|
|
92
94
|
editorView: view,
|
|
93
95
|
editorViewOrNull: view,
|
|
94
96
|
};
|
|
@@ -137,7 +137,7 @@ describe("layoutAtom", () => {
|
|
|
137
137
|
function reporter(store: ReturnType<typeof setupNotebook>["store"]) {
|
|
138
138
|
const results = new Map<
|
|
139
139
|
CellId,
|
|
140
|
-
readonly [Protocol.
|
|
140
|
+
readonly [Protocol.ExecutionOutput, Protocol.Output]
|
|
141
141
|
>();
|
|
142
142
|
return (id: CellId, html: string) => {
|
|
143
143
|
results.set(
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
2
|
|
|
3
3
|
import { describe, expect, it } from "vitest";
|
|
4
|
-
import { cellId } from "@/__tests__/branded";
|
|
5
|
-
import type { Execution } from "@marimo-team/client/protocol";
|
|
4
|
+
import { cellId, runId } from "@/__tests__/branded";
|
|
5
|
+
import type { ExecutionOutput as Execution } from "@marimo-team/client/protocol";
|
|
6
6
|
import {
|
|
7
7
|
exportedForTesting,
|
|
8
8
|
MAX_CODE_LENGTH,
|
|
9
9
|
MAX_RUNS,
|
|
10
|
-
type RunId,
|
|
11
10
|
type RunsState,
|
|
12
11
|
} from "../runs";
|
|
13
12
|
|
|
@@ -15,10 +14,10 @@ const { reducer, initialState, isPureMarkdown } = exportedForTesting;
|
|
|
15
14
|
|
|
16
15
|
const queued = {
|
|
17
16
|
id: "e1",
|
|
18
|
-
run_id: "r1",
|
|
17
|
+
run_id: runId("r1"),
|
|
19
18
|
runtime_id: "runtime",
|
|
20
19
|
caused_by_id: null,
|
|
21
|
-
cell_id: "cell",
|
|
20
|
+
cell_id: cellId("cell"),
|
|
22
21
|
code_fingerprint: "fp",
|
|
23
22
|
created_at: "2026-10-01T09:20:00Z",
|
|
24
23
|
state: { status: "queued" },
|
|
@@ -45,7 +44,6 @@ describe("execution traces", () => {
|
|
|
45
44
|
status: "completed",
|
|
46
45
|
outcome: { kind: "cancelled" },
|
|
47
46
|
} satisfies Execution["state"];
|
|
48
|
-
const runId = "r1" as RunId;
|
|
49
47
|
const running = observe(observe(initialState()), {
|
|
50
48
|
state: { started_at, status: "running" },
|
|
51
49
|
});
|
|
@@ -53,7 +51,9 @@ describe("execution traces", () => {
|
|
|
53
51
|
observe(running, { state: completed }),
|
|
54
52
|
observe(initialState(), { state: completed }),
|
|
55
53
|
]) {
|
|
56
|
-
expect(
|
|
54
|
+
expect(
|
|
55
|
+
state.runMap.get(queued.run_id)?.cellRuns.get(cellId("cell")),
|
|
56
|
+
).toEqual({
|
|
57
57
|
cellId: "cell",
|
|
58
58
|
executionId: "e1",
|
|
59
59
|
code: "print(1)",
|
|
@@ -66,7 +66,7 @@ describe("execution traces", () => {
|
|
|
66
66
|
observe(running, {
|
|
67
67
|
state: { ...completed, outcome: { kind: "succeeded" } },
|
|
68
68
|
})
|
|
69
|
-
.runMap.get(
|
|
69
|
+
.runMap.get(queued.run_id)
|
|
70
70
|
?.cellRuns.get(cellId("cell"))?.status,
|
|
71
71
|
).toBe("success");
|
|
72
72
|
});
|
|
@@ -89,7 +89,7 @@ describe("execution traces", () => {
|
|
|
89
89
|
},
|
|
90
90
|
});
|
|
91
91
|
expect(
|
|
92
|
-
state.runMap.get(
|
|
92
|
+
state.runMap.get(queued.run_id)?.cellRuns.get(cellId("cell"))?.status,
|
|
93
93
|
).toBe("skipped");
|
|
94
94
|
},
|
|
95
95
|
);
|
|
@@ -109,7 +109,7 @@ describe("execution traces", () => {
|
|
|
109
109
|
},
|
|
110
110
|
});
|
|
111
111
|
expect(
|
|
112
|
-
next.runMap.get(
|
|
112
|
+
next.runMap.get(queued.run_id)?.cellRuns.get(cellId("cell"))?.code,
|
|
113
113
|
).toBe(preview);
|
|
114
114
|
}
|
|
115
115
|
});
|
|
@@ -119,13 +119,13 @@ describe("execution traces", () => {
|
|
|
119
119
|
for (let i = 0; i <= MAX_RUNS; i++) {
|
|
120
120
|
state = observe(
|
|
121
121
|
state,
|
|
122
|
-
{ run_id: String(i) },
|
|
122
|
+
{ run_id: runId(String(i)) },
|
|
123
123
|
"x".repeat(MAX_CODE_LENGTH + 1),
|
|
124
124
|
);
|
|
125
125
|
}
|
|
126
126
|
expect(state.runMap.size).toBe(MAX_RUNS);
|
|
127
127
|
expect(state.runIds[0]).toBe(String(MAX_RUNS));
|
|
128
|
-
expect(state.runMap.has("0"
|
|
128
|
+
expect(state.runMap.has(runId("0"))).toBe(false);
|
|
129
129
|
expect(
|
|
130
130
|
state.runMap.get(state.runIds[0])?.cellRuns.get(cellId("cell"))?.code
|
|
131
131
|
.length,
|
|
@@ -147,8 +147,8 @@ describe("execution traces", () => {
|
|
|
147
147
|
expect(isPureMarkdown(markdown)).toBe(true);
|
|
148
148
|
expect(observe(initial, {}, markdown)).toBe(initial);
|
|
149
149
|
expect(
|
|
150
|
-
observe(observe(initial), { cell_id: "md" }, markdown).runMap.get(
|
|
151
|
-
|
|
150
|
+
observe(observe(initial), { cell_id: cellId("md") }, markdown).runMap.get(
|
|
151
|
+
queued.run_id,
|
|
152
152
|
)?.cellRuns.size,
|
|
153
153
|
).toBe(2);
|
|
154
154
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
2
|
/* oxlint-disable typescript/no-explicit-any */
|
|
3
|
+
import { cellId } from "@/__tests__/branded";
|
|
3
4
|
import { describe, expect, it } from "vitest";
|
|
4
5
|
import { MockExecutions } from "@/__mocks__/executions";
|
|
5
6
|
import { initialNotebookState, type NotebookState } from "@/core/cells/cells";
|
|
@@ -105,7 +106,7 @@ describe("staleCellIds", () => {
|
|
|
105
106
|
const state = notebook(cells);
|
|
106
107
|
const executions = MockExecutions.inputs(
|
|
107
108
|
[MockExecutions.completed("cell1"), MockExecutions.completed("cell2")],
|
|
108
|
-
{ blocked: new Set(["cell2"]) },
|
|
109
|
+
{ blocked: new Set([cellId("cell2")]) },
|
|
109
110
|
);
|
|
110
111
|
|
|
111
112
|
expect(staleCellIds(state, executions, freshness(cells))).toEqual([]);
|
|
@@ -131,7 +132,7 @@ describe("staleCellIds with a run in progress", () => {
|
|
|
131
132
|
const state = notebook(cells);
|
|
132
133
|
const ran = MockExecutions.completed("cell1");
|
|
133
134
|
const executions = MockExecutions.inputs([ran], {
|
|
134
|
-
requested: new Set(["cell1"]),
|
|
135
|
+
requested: new Set([cellId("cell1")]),
|
|
135
136
|
});
|
|
136
137
|
|
|
137
138
|
expect(staleCellIds(state, executions, freshness(cells))).toEqual([]);
|
|
@@ -506,7 +506,7 @@ export const deleteCellsAtom = atom(
|
|
|
506
506
|
Logger.warn("Skipping delete for missing cellId", { cellId: id });
|
|
507
507
|
}
|
|
508
508
|
}
|
|
509
|
-
const order = document.order
|
|
509
|
+
const order = document.order;
|
|
510
510
|
const deleting = order.flatMap((id) => {
|
|
511
511
|
const cell = document.cells.get(id);
|
|
512
512
|
return cell !== undefined && requested.has(id) ? [cell] : [];
|
|
@@ -517,11 +517,11 @@ export const deleteCellsAtom = atom(
|
|
|
517
517
|
if (deleting.length === 0) {
|
|
518
518
|
return false;
|
|
519
519
|
}
|
|
520
|
-
const gone = new Set(deleting.map((cell) => cell.id
|
|
520
|
+
const gone = new Set(deleting.map((cell) => cell.id));
|
|
521
521
|
const firstSurvivor = order.find((id) => !gone.has(id));
|
|
522
522
|
|
|
523
523
|
const cells: DeletedCell[] = deleting.map((cell) => {
|
|
524
|
-
const id = cell.id
|
|
524
|
+
const id = cell.id;
|
|
525
525
|
const index = order.indexOf(id);
|
|
526
526
|
const code = cell.code ?? notebook.cellData[id]?.code ?? "";
|
|
527
527
|
const editorView = notebook.cellHandles[id]?.current?.editorView;
|
|
@@ -541,7 +541,7 @@ export const deleteCellsAtom = atom(
|
|
|
541
541
|
});
|
|
542
542
|
|
|
543
543
|
// Focus the nearest visible survivor in the column, looking up before down.
|
|
544
|
-
const first = deleting[0].id
|
|
544
|
+
const first = deleting[0].id;
|
|
545
545
|
const column = columnOf(get(layoutAtom), first);
|
|
546
546
|
const ids = column.visible.includes(first) ? column.visible : column.ids;
|
|
547
547
|
const at = ids.indexOf(first);
|
|
@@ -634,7 +634,7 @@ export const undoDeleteCellAtom = atom(null, (get, set): void => {
|
|
|
634
634
|
const next = new Map(states);
|
|
635
635
|
for (const { cell, serializedEditorState } of last.cells) {
|
|
636
636
|
if (serializedEditorState !== null) {
|
|
637
|
-
next.set(cell.id
|
|
637
|
+
next.set(cell.id, serializedEditorState);
|
|
638
638
|
}
|
|
639
639
|
}
|
|
640
640
|
return next;
|
|
@@ -642,7 +642,7 @@ export const undoDeleteCellAtom = atom(null, (get, set): void => {
|
|
|
642
642
|
set(notebookAtom, (state) => ({
|
|
643
643
|
...state,
|
|
644
644
|
history: state.history.slice(0, -1),
|
|
645
|
-
scrollKey: last.cells[0].cell.id
|
|
645
|
+
scrollKey: last.cells[0].cell.id,
|
|
646
646
|
}));
|
|
647
647
|
});
|
|
648
648
|
|
package/src/core/cells/cells.ts
CHANGED
|
@@ -57,7 +57,7 @@ import {
|
|
|
57
57
|
|
|
58
58
|
/** A deleted cell as it was, with where it went in the document. */
|
|
59
59
|
export interface DeletedCell {
|
|
60
|
-
cell: Protocol.
|
|
60
|
+
cell: Protocol.CellInputOutput;
|
|
61
61
|
placement: Placement;
|
|
62
62
|
/** The editor's state at deletion, so undo brings its history back. */
|
|
63
63
|
serializedEditorState: SerializedEditorState | null;
|
|
@@ -64,10 +64,9 @@ export function applyDocument(
|
|
|
64
64
|
state: NotebookState,
|
|
65
65
|
document: EditableDocument,
|
|
66
66
|
): NotebookState {
|
|
67
|
-
// The protocol's ids are plain strings; the notebook brands them.
|
|
68
67
|
const cellIds = isEqual(document.order, state.cellIds)
|
|
69
68
|
? state.cellIds
|
|
70
|
-
:
|
|
69
|
+
: [...document.order];
|
|
71
70
|
let { cellData, cellRuntime, cellHandles } = state;
|
|
72
71
|
for (const id of cellIds) {
|
|
73
72
|
const cell = document.cells.get(id);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
2
|
|
|
3
|
-
import type { Execution } from "@marimo-team/client/protocol";
|
|
3
|
+
import type { ExecutionOutput as Execution } from "@marimo-team/client/protocol";
|
|
4
4
|
import type { Getter } from "jotai";
|
|
5
5
|
import type { ReducerCellActions } from "./cells";
|
|
6
6
|
import {
|
|
@@ -89,14 +89,14 @@ export function consoleObservers(
|
|
|
89
89
|
if (changed) {
|
|
90
90
|
if (record.state.status === "running") {
|
|
91
91
|
actions.startCellConsole({
|
|
92
|
-
cellId:
|
|
92
|
+
cellId: record.cell_id ?? SCRATCH_CELL_ID,
|
|
93
93
|
});
|
|
94
94
|
}
|
|
95
95
|
onExecution?.(record);
|
|
96
96
|
}
|
|
97
97
|
},
|
|
98
98
|
onItem(record, item, live) {
|
|
99
|
-
const cellId =
|
|
99
|
+
const cellId = record.cell_id ?? SCRATCH_CELL_ID;
|
|
100
100
|
const start = startedAt(record);
|
|
101
101
|
const output = consoleEntry(item, start ? Date.parse(start) / 1000 : 0);
|
|
102
102
|
if (output.channel === "media") {
|