@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
package/src/core/cells/ids.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
2
|
/* oxlint-disable typescript/no-redeclare */
|
|
3
3
|
|
|
4
|
+
import type * as Protocol from "@marimo-team/client/protocol";
|
|
4
5
|
import type { components } from "@marimo-team/marimo-api";
|
|
5
6
|
import { OBJECT_ID_ATTR } from "@/core/dom/ui-element-constants";
|
|
6
7
|
import { invariant } from "@/utils/invariant";
|
|
@@ -13,10 +14,7 @@ const seen = new Set<CellId>();
|
|
|
13
14
|
export const SCRATCH_CELL_ID = "__scratch__" as CellId;
|
|
14
15
|
export const SETUP_CELL_ID = "setup" as CellId;
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
* A typed CellId — derived from the generated OpenAPI schema.
|
|
18
|
-
*/
|
|
19
|
-
export type CellId = components["schemas"]["CellId"];
|
|
17
|
+
export type CellId = Protocol.CellId;
|
|
20
18
|
export const CellId = {
|
|
21
19
|
/**
|
|
22
20
|
* Create a new CellId, a random 4 letter string.
|
package/src/core/cells/runs.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
2
|
import { createReducerAndAtoms } from "@/utils/createReducer";
|
|
3
|
-
import type {
|
|
4
|
-
|
|
3
|
+
import type {
|
|
4
|
+
ExecutionOutput as Execution,
|
|
5
|
+
RunId,
|
|
6
|
+
} from "@marimo-team/client/protocol";
|
|
5
7
|
import { completedAt, startedAt } from "@/core/notebook/replica";
|
|
6
8
|
import type { CellId } from "./ids";
|
|
7
|
-
export type RunId
|
|
9
|
+
export type { RunId };
|
|
8
10
|
|
|
9
11
|
export interface CellRun {
|
|
10
12
|
cellId: CellId;
|
|
@@ -75,8 +77,8 @@ const {
|
|
|
75
77
|
if (record.run_id === null || record.cell_id === null) {
|
|
76
78
|
return state;
|
|
77
79
|
}
|
|
78
|
-
const runId = record.run_id
|
|
79
|
-
const cellId = record.cell_id
|
|
80
|
+
const runId = record.run_id;
|
|
81
|
+
const cellId = record.cell_id;
|
|
80
82
|
const previous = state.runMap.get(runId);
|
|
81
83
|
if (previous === undefined && code !== undefined && isPureMarkdown(code)) {
|
|
82
84
|
return state;
|
|
@@ -16,6 +16,9 @@ import { type CellRuntimeState, createCellRuntimeState } from "./types";
|
|
|
16
16
|
|
|
17
17
|
/** The identity of a snapshot the page carries. A host's own stream replaces it. */
|
|
18
18
|
export const EMBEDDED = "embedded";
|
|
19
|
+
// SAFETY: This snapshot assigns one synthetic run ID to all its restored
|
|
20
|
+
// executions. The fixed suffix satisfies RunId's nonempty-string requirement.
|
|
21
|
+
const EMBEDDED_RUN_ID = `${EMBEDDED}:run` as Protocol.RunId;
|
|
19
22
|
|
|
20
23
|
// Constants
|
|
21
24
|
const DEFAULT_TIMESTAMP = 0;
|
|
@@ -168,7 +171,7 @@ function createEmptySessionCell(): SessionCell {
|
|
|
168
171
|
}
|
|
169
172
|
|
|
170
173
|
/** The cell as a host would describe it. A snapshot never changes, so its etags only need to be distinct. */
|
|
171
|
-
function cellRecord(cellId: CellId, cell: NotebookCell): Protocol.
|
|
174
|
+
function cellRecord(cellId: CellId, cell: NotebookCell): Protocol.CellOutput {
|
|
172
175
|
return {
|
|
173
176
|
id: cellId,
|
|
174
177
|
notebook_id: EMBEDDED,
|
|
@@ -214,12 +217,12 @@ function normalizeTraceback(lines: readonly string[]): string | null {
|
|
|
214
217
|
* current, with no runtime behind it.
|
|
215
218
|
*/
|
|
216
219
|
function resultRecord(
|
|
217
|
-
cell: Protocol.
|
|
220
|
+
cell: Protocol.CellOutput,
|
|
218
221
|
sessionCell: SessionCell | null | undefined,
|
|
219
222
|
): StaticResult | null {
|
|
220
223
|
const primary = primaryOutputOf(sessionCell);
|
|
221
224
|
const id = `${EMBEDDED}:${cell.id}:result`;
|
|
222
|
-
let outcome: Protocol.
|
|
225
|
+
let outcome: Protocol.ExecutionOutcomeOutput;
|
|
223
226
|
let output: Protocol.Output | null = null;
|
|
224
227
|
if (primary === undefined) {
|
|
225
228
|
return null;
|
|
@@ -261,7 +264,7 @@ function resultRecord(
|
|
|
261
264
|
return {
|
|
262
265
|
execution: {
|
|
263
266
|
id,
|
|
264
|
-
run_id:
|
|
267
|
+
run_id: EMBEDDED_RUN_ID,
|
|
265
268
|
runtime_id: EMBEDDED,
|
|
266
269
|
caused_by_id: null,
|
|
267
270
|
cell_id: cell.id,
|
|
@@ -352,7 +355,7 @@ export function readExport({
|
|
|
352
355
|
return { snapshot: null, cellRuntime: {} };
|
|
353
356
|
}
|
|
354
357
|
|
|
355
|
-
const cells: Protocol.
|
|
358
|
+
const cells: Protocol.CellOutput[] = [];
|
|
356
359
|
const results: StaticResult[] = [];
|
|
357
360
|
const cellRuntime: Record<CellId, CellRuntimeState> = {};
|
|
358
361
|
for (const cellId of cellIds) {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { createStore } from "jotai";
|
|
4
4
|
import { describe, expect, it } from "vitest";
|
|
5
5
|
import { MockExecutions } from "@/__mocks__/executions";
|
|
6
|
-
import { cellId } from "@/__tests__/branded";
|
|
6
|
+
import { cellId, runId } from "@/__tests__/branded";
|
|
7
7
|
import type * as Protocol from "@marimo-team/client/protocol";
|
|
8
8
|
import {
|
|
9
9
|
document as documentOf,
|
|
@@ -29,9 +29,9 @@ function run(
|
|
|
29
29
|
cells: Protocol.CellId[],
|
|
30
30
|
status: Protocol.RunState["status"] = "queued",
|
|
31
31
|
id = "run-1",
|
|
32
|
-
): Protocol.
|
|
32
|
+
): Protocol.RunOutput {
|
|
33
33
|
return {
|
|
34
|
-
id,
|
|
34
|
+
id: runId(id),
|
|
35
35
|
notebook_id: "n1",
|
|
36
36
|
runtime_id: "r1",
|
|
37
37
|
origin: { kind: "cells", cell_ids: cells },
|
|
@@ -50,7 +50,10 @@ function run(
|
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
function withRuns(
|
|
53
|
+
function withRuns(
|
|
54
|
+
executions: Executions,
|
|
55
|
+
runs: Protocol.RunOutput[],
|
|
56
|
+
): Executions {
|
|
54
57
|
return { ...executions, runs: new Map(runs.map((r) => [r.id, r])) };
|
|
55
58
|
}
|
|
56
59
|
|
|
@@ -4,6 +4,10 @@ import type * as Protocol from "@marimo-team/client/protocol";
|
|
|
4
4
|
import { describe, expect, it } from "vitest";
|
|
5
5
|
import type { Execution, Executions, Result } from "@/core/notebook/replica";
|
|
6
6
|
import { type CellFreshnessInputs, freshnessOf } from "../freshness";
|
|
7
|
+
import { cellId, runId } from "@/__tests__/branded";
|
|
8
|
+
|
|
9
|
+
const C3 = cellId("c3");
|
|
10
|
+
const FIXTURE_CELL = cellId("k7f2");
|
|
7
11
|
|
|
8
12
|
const T0 = "2026-10-01T09:20:11Z";
|
|
9
13
|
const T1 = "2026-10-01T09:20:12.500Z";
|
|
@@ -15,10 +19,10 @@ const K7F2_FINGERPRINT = "db2b1c9e4a7f0d36";
|
|
|
15
19
|
function cell(
|
|
16
20
|
id: string,
|
|
17
21
|
fingerprint: string,
|
|
18
|
-
overrides: Partial<Protocol.
|
|
19
|
-
): Protocol.
|
|
22
|
+
overrides: Partial<Protocol.CellOutput> = {},
|
|
23
|
+
): Protocol.CellOutput {
|
|
20
24
|
return {
|
|
21
|
-
id,
|
|
25
|
+
id: cellId(id),
|
|
22
26
|
notebook_id: "n1",
|
|
23
27
|
code: null,
|
|
24
28
|
name: "_",
|
|
@@ -35,13 +39,13 @@ function cell(
|
|
|
35
39
|
};
|
|
36
40
|
}
|
|
37
41
|
|
|
38
|
-
const SUCCEEDED: Protocol.
|
|
42
|
+
const SUCCEEDED: Protocol.ExecutionOutcomeOutput = { kind: "succeeded" };
|
|
39
43
|
|
|
40
44
|
/** A completed state that read `depends_on`. */
|
|
41
45
|
function completed(
|
|
42
|
-
depends_on: Protocol.
|
|
43
|
-
outcome: Protocol.
|
|
44
|
-
): Protocol.
|
|
46
|
+
depends_on: Protocol.ExecutionCompletedOutput["depends_on"] = {},
|
|
47
|
+
outcome: Protocol.ExecutionOutcomeOutput = SUCCEEDED,
|
|
48
|
+
): Protocol.ExecutionCompletedOutput {
|
|
45
49
|
return {
|
|
46
50
|
status: "completed",
|
|
47
51
|
started_at: T0,
|
|
@@ -52,14 +56,14 @@ function completed(
|
|
|
52
56
|
}
|
|
53
57
|
|
|
54
58
|
function record(
|
|
55
|
-
fields: Partial<Protocol.
|
|
59
|
+
fields: Partial<Protocol.ExecutionOutput> & {
|
|
56
60
|
id: string;
|
|
57
|
-
cell_id:
|
|
61
|
+
cell_id: Protocol.CellId;
|
|
58
62
|
code_fingerprint: string;
|
|
59
63
|
},
|
|
60
|
-
): Protocol.
|
|
64
|
+
): Protocol.ExecutionOutput {
|
|
61
65
|
return {
|
|
62
|
-
run_id: "run-1",
|
|
66
|
+
run_id: runId("run-1"),
|
|
63
67
|
runtime_id: "r1",
|
|
64
68
|
caused_by_id: null,
|
|
65
69
|
created_at: null,
|
|
@@ -84,7 +88,7 @@ function variable(
|
|
|
84
88
|
}
|
|
85
89
|
|
|
86
90
|
function execution(
|
|
87
|
-
rec: Protocol.
|
|
91
|
+
rec: Protocol.ExecutionOutput,
|
|
88
92
|
variables: Protocol.Variable[] = [],
|
|
89
93
|
): Execution {
|
|
90
94
|
return {
|
|
@@ -101,10 +105,10 @@ function inputs({
|
|
|
101
105
|
executions,
|
|
102
106
|
results = executions.map((e) => e.record),
|
|
103
107
|
}: {
|
|
104
|
-
cells: Protocol.
|
|
108
|
+
cells: Protocol.CellOutput[];
|
|
105
109
|
executions: Execution[];
|
|
106
110
|
/** Defaults to the executions on the stream. */
|
|
107
|
-
results?: Protocol.
|
|
111
|
+
results?: Protocol.ExecutionOutput[];
|
|
108
112
|
}): CellFreshnessInputs {
|
|
109
113
|
const stream: Executions = {
|
|
110
114
|
results: new Map(),
|
|
@@ -140,12 +144,12 @@ const c3 = cell("c3", C3_FINGERPRINT);
|
|
|
140
144
|
const k7f2 = cell("k7f2", K7F2_FINGERPRINT);
|
|
141
145
|
const e12 = record({
|
|
142
146
|
id: "e12",
|
|
143
|
-
cell_id:
|
|
147
|
+
cell_id: C3,
|
|
144
148
|
code_fingerprint: C3_FINGERPRINT,
|
|
145
149
|
});
|
|
146
150
|
const e13 = record({
|
|
147
151
|
id: "e13",
|
|
148
|
-
cell_id:
|
|
152
|
+
cell_id: FIXTURE_CELL,
|
|
149
153
|
code_fingerprint: K7F2_FINGERPRINT,
|
|
150
154
|
state: completed({ x: { execution_id: "e12", update: 0 } }),
|
|
151
155
|
});
|
|
@@ -153,11 +157,11 @@ const e13 = record({
|
|
|
153
157
|
describe("cellFreshness", () => {
|
|
154
158
|
it("is current for a cell that never completed, having nothing to compare", () => {
|
|
155
159
|
const state = inputs({ cells: [c3], executions: [] });
|
|
156
|
-
expect(freshnessOf(state)(
|
|
160
|
+
expect(freshnessOf(state)(C3)).toEqual({
|
|
157
161
|
sourceChanged: false,
|
|
158
162
|
inputsChanged: false,
|
|
159
163
|
});
|
|
160
|
-
expect(freshnessOf(state)("missing")).toEqual({
|
|
164
|
+
expect(freshnessOf(state)(cellId("missing"))).toEqual({
|
|
161
165
|
sourceChanged: false,
|
|
162
166
|
inputsChanged: false,
|
|
163
167
|
});
|
|
@@ -169,11 +173,11 @@ describe("cellFreshness", () => {
|
|
|
169
173
|
executions: [execution(e12, [variable("x", "e12")]), execution(e13)],
|
|
170
174
|
});
|
|
171
175
|
const freshness = freshnessOf(state);
|
|
172
|
-
expect(freshness(
|
|
176
|
+
expect(freshness(C3)).toEqual({
|
|
173
177
|
sourceChanged: false,
|
|
174
178
|
inputsChanged: false,
|
|
175
179
|
});
|
|
176
|
-
expect(freshness(
|
|
180
|
+
expect(freshness(FIXTURE_CELL)).toEqual({
|
|
177
181
|
sourceChanged: false,
|
|
178
182
|
inputsChanged: false,
|
|
179
183
|
});
|
|
@@ -185,11 +189,11 @@ describe("cellFreshness", () => {
|
|
|
185
189
|
executions: [execution(e12, [variable("x", "e12", 1)]), execution(e13)],
|
|
186
190
|
});
|
|
187
191
|
const freshness = freshnessOf(state);
|
|
188
|
-
expect(freshness(
|
|
192
|
+
expect(freshness(C3)).toEqual({
|
|
189
193
|
sourceChanged: false,
|
|
190
194
|
inputsChanged: false,
|
|
191
195
|
});
|
|
192
|
-
expect(freshness(
|
|
196
|
+
expect(freshness(FIXTURE_CELL)).toEqual({
|
|
193
197
|
sourceChanged: false,
|
|
194
198
|
inputsChanged: true,
|
|
195
199
|
});
|
|
@@ -201,12 +205,12 @@ describe("cellFreshness", () => {
|
|
|
201
205
|
executions: [execution(e12, [variable("x", "e12")]), execution(e13)],
|
|
202
206
|
});
|
|
203
207
|
const freshness = freshnessOf(state);
|
|
204
|
-
expect(freshness(
|
|
208
|
+
expect(freshness(C3)).toEqual({
|
|
205
209
|
sourceChanged: true,
|
|
206
210
|
inputsChanged: false,
|
|
207
211
|
});
|
|
208
212
|
// The dependent's own source and the values it read are as they were.
|
|
209
|
-
expect(freshness(
|
|
213
|
+
expect(freshness(FIXTURE_CELL)).toEqual({
|
|
210
214
|
sourceChanged: false,
|
|
211
215
|
inputsChanged: false,
|
|
212
216
|
});
|
|
@@ -216,12 +220,12 @@ describe("cellFreshness", () => {
|
|
|
216
220
|
const m = cell("m", "aaaa111122223333");
|
|
217
221
|
const e14 = record({
|
|
218
222
|
id: "e14",
|
|
219
|
-
cell_id:
|
|
223
|
+
cell_id: C3,
|
|
220
224
|
code_fingerprint: C3_FINGERPRINT,
|
|
221
225
|
});
|
|
222
226
|
const e15 = record({
|
|
223
227
|
id: "e15",
|
|
224
|
-
cell_id: "m",
|
|
228
|
+
cell_id: cellId("m"),
|
|
225
229
|
code_fingerprint: "aaaa111122223333",
|
|
226
230
|
state: completed({ y: { execution_id: "e13", update: 0 } }),
|
|
227
231
|
});
|
|
@@ -234,11 +238,11 @@ describe("cellFreshness", () => {
|
|
|
234
238
|
],
|
|
235
239
|
});
|
|
236
240
|
const freshness = freshnessOf(state);
|
|
237
|
-
expect(freshness(
|
|
241
|
+
expect(freshness(FIXTURE_CELL)).toEqual({
|
|
238
242
|
sourceChanged: false,
|
|
239
243
|
inputsChanged: true,
|
|
240
244
|
});
|
|
241
|
-
expect(freshness("m")).toEqual({
|
|
245
|
+
expect(freshness(cellId("m"))).toEqual({
|
|
242
246
|
sourceChanged: false,
|
|
243
247
|
inputsChanged: true,
|
|
244
248
|
});
|
|
@@ -247,14 +251,14 @@ describe("cellFreshness", () => {
|
|
|
247
251
|
it("is outdated as replaced once the binding execution runs again", () => {
|
|
248
252
|
const e14 = record({
|
|
249
253
|
id: "e14",
|
|
250
|
-
cell_id:
|
|
254
|
+
cell_id: C3,
|
|
251
255
|
code_fingerprint: C3_FINGERPRINT,
|
|
252
256
|
});
|
|
253
257
|
const state = inputs({
|
|
254
258
|
cells: [c3, k7f2],
|
|
255
259
|
executions: [execution(e14, [variable("x", "e14")]), execution(e13)],
|
|
256
260
|
});
|
|
257
|
-
expect(freshnessOf(state)(
|
|
261
|
+
expect(freshnessOf(state)(FIXTURE_CELL)).toEqual({
|
|
258
262
|
sourceChanged: false,
|
|
259
263
|
inputsChanged: true,
|
|
260
264
|
});
|
|
@@ -263,7 +267,7 @@ describe("cellFreshness", () => {
|
|
|
263
267
|
it("is outdated as replaced while the binding cell runs again and the name is unbound", () => {
|
|
264
268
|
const queued = record({
|
|
265
269
|
id: "e14",
|
|
266
|
-
cell_id:
|
|
270
|
+
cell_id: C3,
|
|
267
271
|
code_fingerprint: C3_FINGERPRINT,
|
|
268
272
|
state: { status: "queued" },
|
|
269
273
|
});
|
|
@@ -273,12 +277,12 @@ describe("cellFreshness", () => {
|
|
|
273
277
|
results: [e12, e13],
|
|
274
278
|
});
|
|
275
279
|
const freshness = freshnessOf(state);
|
|
276
|
-
expect(freshness(
|
|
280
|
+
expect(freshness(FIXTURE_CELL)).toEqual({
|
|
277
281
|
sourceChanged: false,
|
|
278
282
|
inputsChanged: true,
|
|
279
283
|
});
|
|
280
284
|
// The retained result for c3 still compares by its own fingerprint.
|
|
281
|
-
expect(freshness(
|
|
285
|
+
expect(freshness(C3)).toEqual({
|
|
282
286
|
sourceChanged: false,
|
|
283
287
|
inputsChanged: false,
|
|
284
288
|
});
|
|
@@ -287,7 +291,7 @@ describe("cellFreshness", () => {
|
|
|
287
291
|
it("is outdated as replaced once a name it read as unbound is bound", () => {
|
|
288
292
|
const reader = record({
|
|
289
293
|
id: "e20",
|
|
290
|
-
cell_id:
|
|
294
|
+
cell_id: FIXTURE_CELL,
|
|
291
295
|
code_fingerprint: K7F2_FINGERPRINT,
|
|
292
296
|
state: completed({ y: null }),
|
|
293
297
|
});
|
|
@@ -295,7 +299,7 @@ describe("cellFreshness", () => {
|
|
|
295
299
|
cells: [c3, k7f2],
|
|
296
300
|
executions: [execution(reader)],
|
|
297
301
|
});
|
|
298
|
-
expect(freshnessOf(unbound)(
|
|
302
|
+
expect(freshnessOf(unbound)(FIXTURE_CELL)).toEqual({
|
|
299
303
|
sourceChanged: false,
|
|
300
304
|
inputsChanged: false,
|
|
301
305
|
});
|
|
@@ -304,7 +308,7 @@ describe("cellFreshness", () => {
|
|
|
304
308
|
cells: [c3, k7f2],
|
|
305
309
|
executions: [execution(e12, [variable("y", "e12")]), execution(reader)],
|
|
306
310
|
});
|
|
307
|
-
expect(freshnessOf(bound)(
|
|
311
|
+
expect(freshnessOf(bound)(FIXTURE_CELL)).toEqual({
|
|
308
312
|
sourceChanged: false,
|
|
309
313
|
inputsChanged: true,
|
|
310
314
|
});
|
|
@@ -313,7 +317,7 @@ describe("cellFreshness", () => {
|
|
|
313
317
|
it("reports both facts when the source and a value it read changed", () => {
|
|
314
318
|
const reader = record({
|
|
315
319
|
id: "e21",
|
|
316
|
-
cell_id:
|
|
320
|
+
cell_id: FIXTURE_CELL,
|
|
317
321
|
code_fingerprint: "stale",
|
|
318
322
|
state: completed({
|
|
319
323
|
x: { execution_id: "e12", update: 0 },
|
|
@@ -327,7 +331,7 @@ describe("cellFreshness", () => {
|
|
|
327
331
|
execution(reader),
|
|
328
332
|
],
|
|
329
333
|
});
|
|
330
|
-
expect(freshnessOf(state)(
|
|
334
|
+
expect(freshnessOf(state)(FIXTURE_CELL)).toEqual({
|
|
331
335
|
sourceChanged: true,
|
|
332
336
|
inputsChanged: true,
|
|
333
337
|
});
|
|
@@ -336,7 +340,7 @@ describe("cellFreshness", () => {
|
|
|
336
340
|
it("compares a skipped execution by the dependencies it would have read", () => {
|
|
337
341
|
const skipped = record({
|
|
338
342
|
id: "e22",
|
|
339
|
-
cell_id:
|
|
343
|
+
cell_id: FIXTURE_CELL,
|
|
340
344
|
code_fingerprint: K7F2_FINGERPRINT,
|
|
341
345
|
state: completed(
|
|
342
346
|
{ x: { execution_id: "e12", update: 0 } },
|
|
@@ -355,7 +359,7 @@ describe("cellFreshness", () => {
|
|
|
355
359
|
execution(skipped),
|
|
356
360
|
],
|
|
357
361
|
});
|
|
358
|
-
expect(freshnessOf(state)(
|
|
362
|
+
expect(freshnessOf(state)(FIXTURE_CELL)).toEqual({
|
|
359
363
|
sourceChanged: false,
|
|
360
364
|
inputsChanged: true,
|
|
361
365
|
});
|
|
@@ -367,7 +371,7 @@ describe("cellFreshness", () => {
|
|
|
367
371
|
executions: [execution(e12, [variable("x", "e12")]), execution(e13)],
|
|
368
372
|
results: [e12, e13],
|
|
369
373
|
});
|
|
370
|
-
expect(freshnessOf(state)(
|
|
374
|
+
expect(freshnessOf(state)(C3)).toEqual({
|
|
371
375
|
sourceChanged: true,
|
|
372
376
|
inputsChanged: false,
|
|
373
377
|
});
|
|
@@ -378,7 +382,7 @@ describe("cellFreshness", () => {
|
|
|
378
382
|
(status) => {
|
|
379
383
|
const reader = record({
|
|
380
384
|
id: "reader-r2",
|
|
381
|
-
cell_id:
|
|
385
|
+
cell_id: FIXTURE_CELL,
|
|
382
386
|
runtime_id: "r2",
|
|
383
387
|
code_fingerprint: K7F2_FINGERPRINT,
|
|
384
388
|
state: {
|
|
@@ -389,7 +393,7 @@ describe("cellFreshness", () => {
|
|
|
389
393
|
});
|
|
390
394
|
const binder = record({
|
|
391
395
|
id: "binder-r3",
|
|
392
|
-
cell_id:
|
|
396
|
+
cell_id: C3,
|
|
393
397
|
runtime_id: "r3",
|
|
394
398
|
code_fingerprint: C3_FINGERPRINT,
|
|
395
399
|
state:
|
|
@@ -410,7 +414,7 @@ describe("cellFreshness", () => {
|
|
|
410
414
|
results: [e12, reader],
|
|
411
415
|
});
|
|
412
416
|
|
|
413
|
-
expect(freshnessOf(state)(
|
|
417
|
+
expect(freshnessOf(state)(FIXTURE_CELL)).toEqual({
|
|
414
418
|
sourceChanged: false,
|
|
415
419
|
inputsChanged: true,
|
|
416
420
|
});
|
|
@@ -420,7 +424,7 @@ describe("cellFreshness", () => {
|
|
|
420
424
|
it("treats a name bound only by an earlier runtime as unbound", () => {
|
|
421
425
|
const reader = record({
|
|
422
426
|
id: "e20",
|
|
423
|
-
cell_id:
|
|
427
|
+
cell_id: FIXTURE_CELL,
|
|
424
428
|
runtime_id: "r2",
|
|
425
429
|
code_fingerprint: K7F2_FINGERPRINT,
|
|
426
430
|
state: completed({ x: null }),
|
|
@@ -429,14 +433,14 @@ describe("cellFreshness", () => {
|
|
|
429
433
|
cells: [c3, k7f2],
|
|
430
434
|
executions: [execution(e12, [variable("x", "e12")]), execution(reader)],
|
|
431
435
|
});
|
|
432
|
-
expect(freshnessOf(retained)(
|
|
436
|
+
expect(freshnessOf(retained)(FIXTURE_CELL)).toEqual({
|
|
433
437
|
sourceChanged: false,
|
|
434
438
|
inputsChanged: false,
|
|
435
439
|
});
|
|
436
440
|
|
|
437
441
|
const rebound = record({
|
|
438
442
|
id: "e14",
|
|
439
|
-
cell_id:
|
|
443
|
+
cell_id: C3,
|
|
440
444
|
runtime_id: "r2",
|
|
441
445
|
code_fingerprint: C3_FINGERPRINT,
|
|
442
446
|
});
|
|
@@ -447,7 +451,7 @@ describe("cellFreshness", () => {
|
|
|
447
451
|
execution(reader),
|
|
448
452
|
],
|
|
449
453
|
});
|
|
450
|
-
expect(freshnessOf(bound)(
|
|
454
|
+
expect(freshnessOf(bound)(FIXTURE_CELL)).toEqual({
|
|
451
455
|
sourceChanged: false,
|
|
452
456
|
inputsChanged: true,
|
|
453
457
|
});
|
|
@@ -458,7 +462,7 @@ describe("cellFreshness", () => {
|
|
|
458
462
|
(status) => {
|
|
459
463
|
const pending = record({
|
|
460
464
|
id: "e14",
|
|
461
|
-
cell_id:
|
|
465
|
+
cell_id: C3,
|
|
462
466
|
code_fingerprint: "ffff000011112222",
|
|
463
467
|
state: status === "running" ? { status, started_at: T0 } : { status },
|
|
464
468
|
});
|
|
@@ -468,7 +472,7 @@ describe("cellFreshness", () => {
|
|
|
468
472
|
results: [e12],
|
|
469
473
|
});
|
|
470
474
|
|
|
471
|
-
expect(freshnessOf(state)(
|
|
475
|
+
expect(freshnessOf(state)(C3)).toEqual({
|
|
472
476
|
sourceChanged: true,
|
|
473
477
|
inputsChanged: false,
|
|
474
478
|
});
|
|
@@ -479,7 +483,7 @@ describe("cellFreshness", () => {
|
|
|
479
483
|
const edited = cell("c3", "ffff000011112222");
|
|
480
484
|
const running = record({
|
|
481
485
|
id: "e14",
|
|
482
|
-
cell_id:
|
|
486
|
+
cell_id: C3,
|
|
483
487
|
code_fingerprint: "ffff000011112222",
|
|
484
488
|
state: { status: "running", started_at: T0 },
|
|
485
489
|
});
|
|
@@ -488,7 +492,7 @@ describe("cellFreshness", () => {
|
|
|
488
492
|
executions: [execution(running), execution(e13)],
|
|
489
493
|
results: [e12, e13],
|
|
490
494
|
});
|
|
491
|
-
expect(freshnessOf(covered)(
|
|
495
|
+
expect(freshnessOf(covered)(C3).sourceChanged).toBe(false);
|
|
492
496
|
|
|
493
497
|
const stale = inputs({
|
|
494
498
|
cells: [edited, k7f2],
|
|
@@ -498,6 +502,6 @@ describe("cellFreshness", () => {
|
|
|
498
502
|
],
|
|
499
503
|
results: [e12, e13],
|
|
500
504
|
});
|
|
501
|
-
expect(freshnessOf(stale)(
|
|
505
|
+
expect(freshnessOf(stale)(C3).sourceChanged).toBe(true);
|
|
502
506
|
});
|
|
503
507
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
2
|
|
|
3
|
+
import { runId } from "@/__tests__/branded";
|
|
3
4
|
import type { ProblemOf } from "@marimo-team/client";
|
|
4
5
|
import type * as Protocol from "@marimo-team/client/protocol";
|
|
5
6
|
import { createStore } from "jotai";
|
|
@@ -23,9 +24,9 @@ function run(
|
|
|
23
24
|
id: string,
|
|
24
25
|
status: Protocol.RunState["status"] = "running",
|
|
25
26
|
runtimeId = "r1",
|
|
26
|
-
): Protocol.
|
|
27
|
+
): Protocol.RunOutput {
|
|
27
28
|
return {
|
|
28
|
-
id,
|
|
29
|
+
id: runId(id),
|
|
29
30
|
notebook_id: "n1",
|
|
30
31
|
runtime_id: runtimeId,
|
|
31
32
|
origin: { kind: "code", code: "pass" },
|
|
@@ -44,7 +45,7 @@ function run(
|
|
|
44
45
|
};
|
|
45
46
|
}
|
|
46
47
|
|
|
47
|
-
function setup(runs: Protocol.
|
|
48
|
+
function setup(runs: Protocol.RunOutput[]) {
|
|
48
49
|
const store = createStore();
|
|
49
50
|
const replica = MockExecutions.seed(store, [], MockExecutions.runtime());
|
|
50
51
|
const interrupt = vi.fn<FakeInterrupt>(async () => ({
|
|
@@ -6,7 +6,7 @@ import type * as Protocol from "@marimo-team/client/protocol";
|
|
|
6
6
|
import { createStore } from "jotai";
|
|
7
7
|
import { describe, expect, it, onTestFinished, vi } from "vitest";
|
|
8
8
|
import { MockExecutions } from "@/__mocks__/executions";
|
|
9
|
-
import { cellId } from "@/__tests__/branded";
|
|
9
|
+
import { cellId, runId } from "@/__tests__/branded";
|
|
10
10
|
import { createNotebookReplica } from "@/core/notebook/replica";
|
|
11
11
|
import {
|
|
12
12
|
fakeBackend,
|
|
@@ -116,8 +116,8 @@ describe("output lifetime", () => {
|
|
|
116
116
|
const { store, snapshot, message, reconnect } = await setup();
|
|
117
117
|
const result = MockExecutions.shown(C1, text("A"));
|
|
118
118
|
snapshot(result);
|
|
119
|
-
const run: Protocol.
|
|
120
|
-
id: "missed",
|
|
119
|
+
const run: Protocol.RunOutput = {
|
|
120
|
+
id: runId("missed"),
|
|
121
121
|
notebook_id: "n1",
|
|
122
122
|
runtime_id: "r1",
|
|
123
123
|
origin: { kind: "cells", cell_ids: [C1] },
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import type * as Protocol from "@marimo-team/client/protocol";
|
|
4
4
|
import { describe, expect, it } from "vitest";
|
|
5
5
|
import { type ExecutionEntries, MockExecutions } from "@/__mocks__/executions";
|
|
6
|
-
import { cellId } from "@/__tests__/branded";
|
|
6
|
+
import { cellId, runId } from "@/__tests__/branded";
|
|
7
7
|
import { cell } from "@/core/notebook/document/__tests__/fixtures";
|
|
8
8
|
import {
|
|
9
9
|
type CellOutputInputs,
|
|
@@ -19,7 +19,9 @@ const HTML: Protocol.Media = { mimetype: "text/html", data: "<b>1</b>" };
|
|
|
19
19
|
/** After every time the execution mocks use. */
|
|
20
20
|
const LATER = "2026-10-01T09:30:00Z";
|
|
21
21
|
|
|
22
|
-
function hostError(
|
|
22
|
+
function hostError(
|
|
23
|
+
overrides: Partial<Protocol.ErrorOutput>,
|
|
24
|
+
): Protocol.ErrorOutput {
|
|
23
25
|
return {
|
|
24
26
|
kind: "exception",
|
|
25
27
|
message: "boom",
|
|
@@ -319,7 +321,7 @@ describe("scratchOutputView", () => {
|
|
|
319
321
|
expect(
|
|
320
322
|
scratchOutputView({
|
|
321
323
|
...executions,
|
|
322
|
-
scratchFailure: { ...failure, runId: "run-2" },
|
|
324
|
+
scratchFailure: { ...failure, runId: runId("run-2") },
|
|
323
325
|
})?.data,
|
|
324
326
|
).toEqual([
|
|
325
327
|
{ type: "unknown", msg: "Kernel channel closed", error_type: null },
|
|
@@ -4,7 +4,7 @@ import type * as Protocol from "@marimo-team/client/protocol";
|
|
|
4
4
|
import { atom } from "jotai";
|
|
5
5
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
6
6
|
import { MockExecutions } from "@/__mocks__/executions";
|
|
7
|
-
import { cellId } from "@/__tests__/branded";
|
|
7
|
+
import { cellId, runId } from "@/__tests__/branded";
|
|
8
8
|
import type { DocumentModel, EditableDocument } from "@/core/notebook/document";
|
|
9
9
|
import {
|
|
10
10
|
cell,
|
|
@@ -34,12 +34,12 @@ vi.mock("@/components/ui/use-toast", () => ({
|
|
|
34
34
|
const C1 = cellId("c1");
|
|
35
35
|
const C2 = cellId("c2");
|
|
36
36
|
|
|
37
|
-
function accepted(cells:
|
|
37
|
+
function accepted(cells: string[]): Protocol.RunOutput {
|
|
38
38
|
return {
|
|
39
|
-
id: "run-1",
|
|
39
|
+
id: runId("run-1"),
|
|
40
40
|
notebook_id: "n1",
|
|
41
41
|
runtime_id: "r1",
|
|
42
|
-
origin: { kind: "cells", cell_ids: cells },
|
|
42
|
+
origin: { kind: "cells", cell_ids: cells.map(cellId) },
|
|
43
43
|
created_at: "2026-10-01T09:20:00Z",
|
|
44
44
|
state: { status: "queued" },
|
|
45
45
|
};
|