@marimo-team/islands 0.26.1-dev20 → 0.26.1-dev25
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/{ConnectedDataExplorerComponent-CR9WyiEc.js → ConnectedDataExplorerComponent-jtTaDisw.js} +16 -16
- package/dist/{ErrorBoundary-Cx-CwafE.js → ErrorBoundary-Bs2ehxEI.js} +6 -6
- package/dist/{abnfDiagram-VCTEODGH-DGAbsdXT.js → abnfDiagram-VCTEODGH-cUj3Gnnh.js} +2 -2
- package/dist/{any-language-editor-DzGF1ll-.js → any-language-editor-BHgkY7jY.js} +2 -2
- package/dist/{architectureDiagram-5GKGNRK7-D4DnIo7R.js → architectureDiagram-5GKGNRK7-CIAZgn9d.js} +1 -1
- package/dist/{assertNever-CqwxSD_2.js → assertNever-BHnIohkX.js} +13 -13
- package/dist/{chat-ui-qZdDDrzU.js → chat-ui-DOvIzlMA.js} +46 -46
- package/dist/{check-D9vf6LYF.js → check-LtjuWmNn.js} +1 -1
- package/dist/{chunk-IMKFNOWR-Bc_i6jWx.js → chunk-IMKFNOWR-CB9N3qYR.js} +1 -1
- package/dist/{chunk-SHT3W25Y-CGML5pnF.js → chunk-SHT3W25Y-D9njV7TI.js} +1 -1
- package/dist/{chunk-SVP7TREG-ZpeFKfFT.js → chunk-SVP7TREG-CUCE0BFm.js} +1 -1
- package/dist/{chunk-TICWLB2K-C6cLmcg8.js → chunk-TICWLB2K-iQB6ttkI.js} +1 -1
- package/dist/{classDiagram-ZZMXUADV--q40NTXr.js → classDiagram-ZZMXUADV-BI1VBNIo.js} +2 -2
- package/dist/{classDiagram-v2-VYDZK3BY-Dt_Pp94L.js → classDiagram-v2-VYDZK3BY-BYL3asWh.js} +2 -2
- package/dist/{code-visibility-CVfXV6fG.js → code-visibility-BnMkbydx.js} +19 -19
- package/dist/{common-BXRJCkJO.js → common-CQur5dRA.js} +156 -156
- package/dist/{config-B8JCQMby.js → config-DL9e-OWE.js} +3 -3
- package/dist/{copy-icon-BLig0ZKb.js → copy-icon-rYV2znAe.js} +2 -2
- package/dist/{createReducer-BIUQ3TbG.js → createReducer-BdiSrxHu.js} +5 -5
- package/dist/{cynefinDiagram-5FMLGOSQ-2FtF_-cc.js → cynefinDiagram-5FMLGOSQ-DpGtYvnZ.js} +1 -1
- package/dist/{dagre-GXQ25YYZ-Cymu2SPS.js → dagre-GXQ25YYZ-B5GDC2kN.js} +1 -1
- package/dist/{data-grid-overlay-editor-Mbtx3F9C.js → data-grid-overlay-editor-BXEY35Xl.js} +1 -1
- package/dist/{diagram-S7CK7UJ4-OwDa8kAa.js → diagram-S7CK7UJ4-B2T25t1t.js} +1 -1
- package/dist/{diagram-UQ7AKVKN-CzRDwZwd.js → diagram-UQ7AKVKN-Dy3B5L_z.js} +1 -1
- package/dist/{diagram-VX7I27RA-XRIcgMDs.js → diagram-VX7I27RA-tOptWvNh.js} +1 -1
- package/dist/{diagram-Z3DM3KII-DdRDYAs6.js → diagram-Z3DM3KII-DsgZAokO.js} +1 -1
- package/dist/{dialog-DGh2HNAO.js → dialog-vs6x3On9.js} +19 -19
- package/dist/{dropdown-menu-ChH3oiqI.js → dropdown-menu-DYN2RV5d.js} +193 -193
- package/dist/{ebnfDiagram-PWID7BFC-CZMNMGNP.js → ebnfDiagram-PWID7BFC-CGWECzS1.js} +2 -2
- package/dist/{erDiagram-RLTQ6QDP-ByxHAN4b.js → erDiagram-RLTQ6QDP-CZLi87y3.js} +1 -1
- package/dist/{error-banner-BvRaQnGH.js → error-banner-D-AC7pQx.js} +70 -70
- package/dist/{error-entries-DhI0hGvj.js → error-entries-CncQR572.js} +443 -436
- package/dist/{feedback-button-zx4NcNDn.js → feedback-button-BAOp7zqu.js} +120 -120
- package/dist/{flowDiagram-HODETNUW-BQpzWx5O.js → flowDiagram-HODETNUW-CS86WYbX.js} +2 -2
- package/dist/{formats-BxP8k8Un.js → formats-BUFLQJXY.js} +1 -1
- package/dist/{glide-data-editor-CvezoJKg.js → glide-data-editor-Ce94qTW7.js} +11 -11
- package/dist/{glide-utils-bKdvDwwo.js → glide-utils-CZ-O-CB_.js} +2 -2
- package/dist/{globals-CQuPaxzy.js → globals-Uqg4j5z5.js} +3 -3
- package/dist/{html-to-image-B803aaWE.js → html-to-image-BU7H-AM1.js} +4323 -4318
- package/dist/{infoDiagram-27XIBGKW-C9EWHkak.js → infoDiagram-27XIBGKW-C9JBFfpC.js} +1 -1
- package/dist/{ishikawaDiagram-5VMMS53U-D67SGFvp.js → ishikawaDiagram-5VMMS53U-Eh3iuw2D.js} +1 -1
- package/dist/{kanban-definition-UXKFOSKX-CTMTiazR.js → kanban-definition-UXKFOSKX-DYtuVwYD.js} +1 -1
- package/dist/main.js +401 -400
- package/dist/{mermaid-DE_tvTGF.js → mermaid--k1o49nH.js} +34 -34
- package/dist/{mindmap-definition-YA3MSWOX-LzNgDy8O.js → mindmap-definition-YA3MSWOX-Dn1Cnqys.js} +1 -1
- package/dist/{number-overlay-editor-DxM7vsCk.js → number-overlay-editor-Br_Vp3Ws.js} +1 -1
- package/dist/{pegDiagram-XKGWAZYB-DFMS6feI.js → pegDiagram-XKGWAZYB-DiY7rITR.js} +2 -2
- package/dist/{pencil-CHkdsX07.js → pencil-AWgwbH4D.js} +1 -1
- package/dist/{pieDiagram-E7YTZNPT-C0MSBop-.js → pieDiagram-E7YTZNPT-BL6InbDs.js} +1 -1
- package/dist/{process-output-CnCLfvnL.js → process-output-xJm8T5-E.js} +4 -4
- package/dist/{railroadDiagram-O6MQD6OU-mbdav2pV.js → railroadDiagram-O6MQD6OU-DterenMu.js} +2 -2
- package/dist/{requirementDiagram-BXWQKSXE-C1HNBBO6.js → requirementDiagram-BXWQKSXE-Vb5_9LHC.js} +1 -1
- package/dist/{reveal-component-BefmhjJF.js → reveal-component-B7TgfbYJ.js} +1008 -1008
- package/dist/{select-CvorIE3l.js → select-CKLRKIzB.js} +298 -298
- package/dist/{sequenceDiagram-WJ2MYXX4-D6gBHifq.js → sequenceDiagram-WJ2MYXX4-BWsq8hMt.js} +1 -1
- package/dist/{spec-ayzaXGVq.js → spec-C4uOz0Em.js} +4 -4
- package/dist/{stateDiagram-D77RDMKH-Bx-fTtRZ.js → stateDiagram-D77RDMKH-nfKKy6aQ.js} +2 -2
- package/dist/{stateDiagram-v2-MP3YSRHH-Cec8T2yO.js → stateDiagram-v2-MP3YSRHH-DMUHA_9A.js} +2 -2
- package/dist/{static-state-CqwW3B_X.js → static-state-DZ1nSa6e.js} +9 -9
- package/dist/{swimlanes-42K2YHIH-C2bAgnov.js → swimlanes-42K2YHIH-N4qHIMoc.js} +1 -1
- package/dist/{swimlanesDiagram-VR7AAH4N-CzeG-Mnb.js → swimlanesDiagram-VR7AAH4N-DQpDDjQb.js} +2 -2
- package/dist/{timeline-definition-24CTP7MA-DTJ0Rx8X.js → timeline-definition-24CTP7MA-Od8dY9F5.js} +1 -1
- package/dist/{toast-6V8Og7d5.js → toast-bhZHUEal.js} +187 -187
- package/dist/{tooltip-D0h-ZJ6j.js → tooltip-DSWC_Td_.js} +40 -40
- package/dist/{use-restore-focus-BFvwj2Hj.js → use-restore-focus-ocw7t85i.js} +1371 -1373
- package/dist/{useDateFormatter-D6o9PsWt.js → useDateFormatter-BiDS8uXQ.js} +2 -2
- package/dist/{useDeepCompareMemoize-D-Pbv7dN.js → useDeepCompareMemoize-BsaXfZ8C.js} +1 -1
- package/dist/{useLifecycle-CE0yGTMF.js → useLifecycle-CCV7yZ-v.js} +1 -1
- package/dist/{vega-component-DTf7GHQe.js → vega-component-DpTyTrz3.js} +6 -6
- package/dist/{vennDiagram-4TSXK5OY-lIM3SAjl.js → vennDiagram-4TSXK5OY-Di3T2YMb.js} +1 -1
- package/dist/{wardleyDiagram-VM6X3IG4-Bw_t7uvA.js → wardleyDiagram-VM6X3IG4-CKOF5DTi.js} +1 -1
- package/dist/{xychartDiagram-S5SC5T6Z-BXwkLYKj.js → xychartDiagram-S5SC5T6Z-GYLPWSeb.js} +1 -1
- package/package.json +1 -1
- package/src/__mocks__/executions.ts +27 -5
- package/src/__tests__/branded.ts +4 -0
- package/src/__tests__/notebook-analysis.ts +48 -0
- package/src/components/editor/ai/__tests__/completion-utils.test.ts +28 -61
- package/src/components/editor/cell/__tests__/useRunCells.test.tsx +2 -2
- package/src/components/editor/navigation/__tests__/navigation.test.ts +0 -4
- package/src/components/tracing/tracing-keyboard.test.tsx +4 -3
- package/src/core/cells/__tests__/add-missing-import.test.ts +14 -9
- package/src/core/cells/__tests__/pending-delete-service.test.tsx +4 -11
- package/src/core/cells/__tests__/runs.test.ts +11 -11
- package/src/core/cells/add-missing-import.ts +2 -3
- package/src/core/cells/runs.ts +6 -4
- package/src/core/cells/session.ts +4 -1
- package/src/core/codemirror/code-lens/__tests__/entities.test.ts +7 -11
- package/src/core/codemirror/code-lens/__tests__/extension.test.ts +8 -13
- package/src/core/codemirror/code-lens/__tests__/perf.test.ts +7 -9
- package/src/core/codemirror/copilot/__tests__/getCodes.test.ts +9 -13
- package/src/core/codemirror/go-to-definition/__tests__/utils.test.ts +16 -35
- package/src/core/codemirror/language/embedded/__tests__/embedded-python.test.ts +2 -18
- package/src/core/codemirror/reactive-references/__tests__/extension.test.ts +8 -14
- package/src/core/datasets/__tests__/data-source.test.ts +15 -17
- package/src/core/datasets/data-source-connections.ts +8 -11
- package/src/core/datasets/state.ts +7 -12
- package/src/core/executions/__tests__/atoms.test.ts +2 -2
- package/src/core/executions/__tests__/freshness.test.ts +10 -5
- package/src/core/executions/__tests__/interrupt.test.ts +3 -1
- package/src/core/executions/__tests__/output-lifecycle.test.ts +3 -3
- package/src/core/executions/__tests__/output.test.ts +2 -2
- package/src/core/executions/__tests__/run.test.ts +2 -2
- package/src/core/executions/__tests__/select.test.ts +10 -10
- package/src/core/executions/atoms.ts +2 -1
- package/src/core/executions/freshness.ts +2 -2
- package/src/core/islands/bootstrap.ts +0 -2
- package/src/core/notebook/replica/__tests__/executions.test.ts +13 -9
- package/src/core/notebook/replica/__tests__/replica.test.ts +7 -2
- package/src/core/notebook/replica/replica.ts +11 -2
- package/src/core/notebook/replica/resources/executions.ts +29 -20
- package/src/core/session/__tests__/useNotebookSession.hook.test.tsx +192 -1
- package/src/core/session/useNotebookSession.tsx +37 -37
- package/src/core/storage/__tests__/state.test.ts +6 -9
- package/src/core/storage/state.ts +5 -8
- package/src/core/transports/__tests__/static.test.ts +2 -1
- package/src/core/variables/state.ts +73 -68
- package/src/core/variables/types.ts +2 -2
- package/src/core/wasm/bridge.ts +5 -4
- package/src/core/variables/__tests__/state.test.ts +0 -148
|
@@ -7,7 +7,6 @@ import type {
|
|
|
7
7
|
NotificationMessageData,
|
|
8
8
|
} from "../kernel/messages";
|
|
9
9
|
import { getRequestClient } from "../network/requests";
|
|
10
|
-
import type { VariableName } from "../variables/types";
|
|
11
10
|
import type { DatasetsState } from "./types";
|
|
12
11
|
|
|
13
12
|
function initialState(): DatasetsState {
|
|
@@ -75,17 +74,13 @@ const {
|
|
|
75
74
|
tables: sortedTables,
|
|
76
75
|
};
|
|
77
76
|
},
|
|
78
|
-
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
return names.has(table.variable_name);
|
|
87
|
-
});
|
|
88
|
-
return { ...state, tables };
|
|
77
|
+
removeDatasetsForVariables: (state, removed: ReadonlySet<string>) => {
|
|
78
|
+
const tables = state.tables.filter(
|
|
79
|
+
(table) =>
|
|
80
|
+
!(table.variable_name && removed.has(table.variable_name)) &&
|
|
81
|
+
!(table.engine && removed.has(table.engine)),
|
|
82
|
+
);
|
|
83
|
+
return tables.length === state.tables.length ? state : { ...state, tables };
|
|
89
84
|
},
|
|
90
85
|
toggleTable: (state, tableName: string) => {
|
|
91
86
|
const expandedTables = new Set(state.expandedTables);
|
|
@@ -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,
|
|
@@ -31,7 +31,7 @@ function run(
|
|
|
31
31
|
id = "run-1",
|
|
32
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 },
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
import type * as Protocol from "@marimo-team/client/protocol";
|
|
4
4
|
import { describe, expect, it } from "vitest";
|
|
5
|
-
import type {
|
|
5
|
+
import type { Executions, Result } from "@/core/notebook/replica";
|
|
6
6
|
import { type CellFreshnessInputs, freshnessOf } from "../freshness";
|
|
7
|
-
import { cellId } from "@/__tests__/branded";
|
|
7
|
+
import { cellId, runId } from "@/__tests__/branded";
|
|
8
8
|
|
|
9
9
|
const C3 = cellId("c3");
|
|
10
10
|
const FIXTURE_CELL = cellId("k7f2");
|
|
@@ -63,7 +63,7 @@ function record(
|
|
|
63
63
|
},
|
|
64
64
|
): Protocol.ExecutionOutput {
|
|
65
65
|
return {
|
|
66
|
-
run_id: "run-1",
|
|
66
|
+
run_id: runId("run-1"),
|
|
67
67
|
runtime_id: "r1",
|
|
68
68
|
caused_by_id: null,
|
|
69
69
|
created_at: null,
|
|
@@ -90,7 +90,7 @@ function variable(
|
|
|
90
90
|
function execution(
|
|
91
91
|
rec: Protocol.ExecutionOutput,
|
|
92
92
|
variables: Protocol.Variable[] = [],
|
|
93
|
-
)
|
|
93
|
+
) {
|
|
94
94
|
return {
|
|
95
95
|
record: rec,
|
|
96
96
|
output: null,
|
|
@@ -106,7 +106,7 @@ function inputs({
|
|
|
106
106
|
results = executions.map((e) => e.record),
|
|
107
107
|
}: {
|
|
108
108
|
cells: Protocol.CellOutput[];
|
|
109
|
-
executions:
|
|
109
|
+
executions: ReturnType<typeof execution>[];
|
|
110
110
|
/** Defaults to the executions on the stream. */
|
|
111
111
|
results?: Protocol.ExecutionOutput[];
|
|
112
112
|
}): CellFreshnessInputs {
|
|
@@ -114,6 +114,11 @@ function inputs({
|
|
|
114
114
|
results: new Map(),
|
|
115
115
|
scratch: null,
|
|
116
116
|
runs: new Map(),
|
|
117
|
+
variables: new Map(
|
|
118
|
+
executions.flatMap((e) =>
|
|
119
|
+
e.record.cell_id === null ? [] : [[e.record.cell_id, e.variables]],
|
|
120
|
+
),
|
|
121
|
+
),
|
|
117
122
|
executions: new Map(executions.map((e) => [e.record.id, e])),
|
|
118
123
|
latest: new Map(
|
|
119
124
|
executions.flatMap((e) =>
|
|
@@ -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";
|
|
@@ -25,7 +26,7 @@ function run(
|
|
|
25
26
|
runtimeId = "r1",
|
|
26
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" },
|
|
@@ -54,6 +55,7 @@ function setup(runs: Protocol.RunOutput[]) {
|
|
|
54
55
|
}));
|
|
55
56
|
store.set(replica.backendAtom, fakeBackend({ interrupt }));
|
|
56
57
|
store.set(replica.executionsAtom, {
|
|
58
|
+
variables: new Map(),
|
|
57
59
|
runs: new Map(runs.map((run) => [run.id, run])),
|
|
58
60
|
executions: new Map(),
|
|
59
61
|
latest: new Map(),
|
|
@@ -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,
|
|
@@ -321,7 +321,7 @@ describe("scratchOutputView", () => {
|
|
|
321
321
|
expect(
|
|
322
322
|
scratchOutputView({
|
|
323
323
|
...executions,
|
|
324
|
-
scratchFailure: { ...failure, runId: "run-2" },
|
|
324
|
+
scratchFailure: { ...failure, runId: runId("run-2") },
|
|
325
325
|
})?.data,
|
|
326
326
|
).toEqual([
|
|
327
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,
|
|
@@ -36,7 +36,7 @@ const C2 = cellId("c2");
|
|
|
36
36
|
|
|
37
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
42
|
origin: { kind: "cells", cell_ids: cells.map(cellId) },
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
queuedOrRunningCount,
|
|
14
14
|
runningCellIds,
|
|
15
15
|
} from "../select";
|
|
16
|
-
import { cellId } from "@/__tests__/branded";
|
|
16
|
+
import { cellId, runId } from "@/__tests__/branded";
|
|
17
17
|
|
|
18
18
|
const C1 = cellId("c1");
|
|
19
19
|
const C2 = cellId("c2");
|
|
@@ -53,7 +53,7 @@ function record(
|
|
|
53
53
|
overrides: Partial<Protocol.ExecutionOutput> & { id: string },
|
|
54
54
|
): Protocol.ExecutionOutput {
|
|
55
55
|
return {
|
|
56
|
-
run_id: "run-1",
|
|
56
|
+
run_id: runId("run-1"),
|
|
57
57
|
runtime_id: "r1",
|
|
58
58
|
caused_by_id: null,
|
|
59
59
|
cell_id: C1,
|
|
@@ -78,7 +78,6 @@ function execution(
|
|
|
78
78
|
output: null,
|
|
79
79
|
outputVersion: 0,
|
|
80
80
|
items: new Map(),
|
|
81
|
-
variables: new Map(),
|
|
82
81
|
};
|
|
83
82
|
}
|
|
84
83
|
|
|
@@ -88,7 +87,7 @@ function run(
|
|
|
88
87
|
id = "run-1",
|
|
89
88
|
): Protocol.RunOutput {
|
|
90
89
|
return {
|
|
91
|
-
id,
|
|
90
|
+
id: runId(id),
|
|
92
91
|
notebook_id: "n1",
|
|
93
92
|
runtime_id: "r1",
|
|
94
93
|
origin: { kind: "cells", cell_ids: cells.map(cellId) },
|
|
@@ -130,6 +129,7 @@ function inputs({
|
|
|
130
129
|
const stream: Executions = {
|
|
131
130
|
scratch: null,
|
|
132
131
|
results,
|
|
132
|
+
variables: new Map(),
|
|
133
133
|
runs: new Map(runs.map((r) => [r.id, r])),
|
|
134
134
|
executions: new Map(executions.map((e) => [e.record.id, e])),
|
|
135
135
|
latest: new Map(
|
|
@@ -303,7 +303,7 @@ describe("cellExecutionView", () => {
|
|
|
303
303
|
executions: [
|
|
304
304
|
execution({
|
|
305
305
|
id: "e2",
|
|
306
|
-
run_id: "run-2",
|
|
306
|
+
run_id: runId("run-2"),
|
|
307
307
|
state: RUNNING,
|
|
308
308
|
}),
|
|
309
309
|
],
|
|
@@ -313,8 +313,8 @@ describe("cellExecutionView", () => {
|
|
|
313
313
|
|
|
314
314
|
const done = inputs({
|
|
315
315
|
runs: [run(["c1", "c2"], "running", "run-2")],
|
|
316
|
-
executions: [execution({ id: "e2", run_id: "run-2" })],
|
|
317
|
-
results: new Map([[C1, execution({ id: "e2", run_id: "run-2" })]]),
|
|
316
|
+
executions: [execution({ id: "e2", run_id: runId("run-2") })],
|
|
317
|
+
results: new Map([[C1, execution({ id: "e2", run_id: runId("run-2") })]]),
|
|
318
318
|
});
|
|
319
319
|
expect(cellExecutionView(done, C1).status).toBe("idle");
|
|
320
320
|
expect(cellExecutionView(done, C1).outcome).toBe("succeeded");
|
|
@@ -323,7 +323,7 @@ describe("cellExecutionView", () => {
|
|
|
323
323
|
// The stream let the execution go while its run goes on with other cells.
|
|
324
324
|
const retained = inputs({
|
|
325
325
|
runs: [run(["c1", "c2"], "running", "run-2")],
|
|
326
|
-
results: new Map([[C1, execution({ id: "e2", run_id: "run-2" })]]),
|
|
326
|
+
results: new Map([[C1, execution({ id: "e2", run_id: runId("run-2") })]]),
|
|
327
327
|
});
|
|
328
328
|
expect(cellExecutionView(retained, C1).status).toBe("idle");
|
|
329
329
|
expect(cellExecutionView(retained, C2).status).toBe("queued");
|
|
@@ -331,8 +331,8 @@ describe("cellExecutionView", () => {
|
|
|
331
331
|
// A later run names the cell again while the earlier one's result stands.
|
|
332
332
|
const again = inputs({
|
|
333
333
|
runs: [run(["c1"], "running", "run-2"), run(["c1"], "queued", "run-3")],
|
|
334
|
-
executions: [execution({ id: "e2", run_id: "run-2" })],
|
|
335
|
-
results: new Map([[C1, execution({ id: "e2", run_id: "run-2" })]]),
|
|
334
|
+
executions: [execution({ id: "e2", run_id: runId("run-2") })],
|
|
335
|
+
results: new Map([[C1, execution({ id: "e2", run_id: runId("run-2") })]]),
|
|
336
336
|
});
|
|
337
337
|
expect(cellExecutionView(again, C1).status).toBe("queued");
|
|
338
338
|
|
|
@@ -35,6 +35,7 @@ import { shown } from "@/core/notebook/replica";
|
|
|
35
35
|
type Store = ReturnType<typeof createStore>;
|
|
36
36
|
|
|
37
37
|
const NO_EXECUTIONS: Executions = {
|
|
38
|
+
variables: new Map(),
|
|
38
39
|
runs: new Map(),
|
|
39
40
|
executions: new Map(),
|
|
40
41
|
latest: new Map(),
|
|
@@ -380,7 +381,7 @@ export function withdrawRequest(store: Store, request: RunRequest): void {
|
|
|
380
381
|
export function acceptRun(
|
|
381
382
|
store: Store,
|
|
382
383
|
request: RunRequest,
|
|
383
|
-
run: Protocol.
|
|
384
|
+
run: Protocol.RunOutput,
|
|
384
385
|
): void {
|
|
385
386
|
const waitingAtom = atom(
|
|
386
387
|
(get) =>
|
|
@@ -53,8 +53,8 @@ function boundVariables(
|
|
|
53
53
|
executions: Executions,
|
|
54
54
|
): ReadonlyMap<string, Protocol.Variable[]> {
|
|
55
55
|
const byName = new Map<string, Protocol.Variable[]>();
|
|
56
|
-
for (const
|
|
57
|
-
for (const variable of
|
|
56
|
+
for (const bindings of executions.variables.values()) {
|
|
57
|
+
for (const variable of bindings.values()) {
|
|
58
58
|
const bound = byName.get(variable.name);
|
|
59
59
|
if (bound === undefined) {
|
|
60
60
|
byName.set(variable.name, [variable]);
|
|
@@ -5,7 +5,7 @@ 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 } from "@/__tests__/branded";
|
|
8
|
+
import { cellId, runId } from "@/__tests__/branded";
|
|
9
9
|
|
|
10
10
|
const C3 = cellId("c3");
|
|
11
11
|
|
|
@@ -49,19 +49,21 @@ describe("executions resource", () => {
|
|
|
49
49
|
expect(itemsInOrder(scratch!).map((item) => item.kind)).toEqual([
|
|
50
50
|
"console",
|
|
51
51
|
]);
|
|
52
|
-
expect(opening.runs.get("run-scratch")?.state.status).toBe(
|
|
52
|
+
expect(opening.runs.get(runId("run-scratch"))?.state.status).toBe(
|
|
53
|
+
"running",
|
|
54
|
+
);
|
|
53
55
|
expect(opening.latest.size).toBe(0);
|
|
54
56
|
|
|
55
57
|
const done = resource(replay(snapshot));
|
|
56
58
|
expect(done.executions.get("e7")?.record.state.status).toBe("completed");
|
|
57
|
-
expect(done.runs.get("run-scratch")?.state).toMatchObject({
|
|
59
|
+
expect(done.runs.get(runId("run-scratch"))?.state).toMatchObject({
|
|
58
60
|
outcome: { kind: "succeeded" },
|
|
59
61
|
});
|
|
60
62
|
const released = reducer.reduce(
|
|
61
63
|
replay(snapshot),
|
|
62
64
|
removed("run", "run-scratch", "98"),
|
|
63
65
|
);
|
|
64
|
-
expect(resource(released).runs.has("run-scratch")).toBe(false);
|
|
66
|
+
expect(resource(released).runs.has(runId("run-scratch"))).toBe(false);
|
|
65
67
|
});
|
|
66
68
|
|
|
67
69
|
it("indexes a cell's execution while it is on the stream", () => {
|
|
@@ -70,19 +72,21 @@ describe("executions resource", () => {
|
|
|
70
72
|
expect(running.latest.get(C3)).toBe("e12");
|
|
71
73
|
expect(running.executions.get("e12")?.record.state.status).toBe("running");
|
|
72
74
|
expect(running.latest.get(cellId("k7f2"))).toBe("e13");
|
|
73
|
-
expect(running.runs.get("run-cells")?.state.status).toBe("running");
|
|
75
|
+
expect(running.runs.get(runId("run-cells"))?.state.status).toBe("running");
|
|
74
76
|
|
|
75
77
|
const done = replay(runCells, start);
|
|
76
78
|
const e12 = resource(done).executions.get("e12");
|
|
77
79
|
expect(e12?.record.state.status).toBe("completed");
|
|
78
|
-
expect(
|
|
80
|
+
expect(
|
|
81
|
+
[...resource(done).variables.get(C3)!.values()].map((v) => v.name),
|
|
82
|
+
).toEqual(["x"]);
|
|
79
83
|
expect(resource(done).executions.get("e13")?.record.state).toHaveProperty(
|
|
80
84
|
"depends_on",
|
|
81
85
|
{
|
|
82
86
|
x: { execution_id: "e12", update: 0 },
|
|
83
87
|
},
|
|
84
88
|
);
|
|
85
|
-
expect(resource(done).runs.get("run-cells")?.state).toMatchObject({
|
|
89
|
+
expect(resource(done).runs.get(runId("run-cells"))?.state).toMatchObject({
|
|
86
90
|
outcome: { kind: "succeeded" },
|
|
87
91
|
});
|
|
88
92
|
|
|
@@ -151,7 +155,7 @@ describe("executions resource", () => {
|
|
|
151
155
|
);
|
|
152
156
|
const e12 = resource(cleared).executions.get("e12")!;
|
|
153
157
|
expect(ids(e12)).toEqual([]);
|
|
154
|
-
expect(
|
|
158
|
+
expect(resource(cleared).variables.has(C3)).toBe(false);
|
|
155
159
|
expect(resource(cleared).latest.get(C3)).toBe("e12");
|
|
156
160
|
});
|
|
157
161
|
|
|
@@ -175,7 +179,7 @@ describe("executions resource", () => {
|
|
|
175
179
|
expect(prompted.latest.size).toBe(0);
|
|
176
180
|
const gone = resource(replay(inputs, start));
|
|
177
181
|
expect(gone.executions.has("e-input")).toBe(false);
|
|
178
|
-
expect(gone.runs.get("run-input")?.state).toMatchObject({
|
|
182
|
+
expect(gone.runs.get(runId("run-input"))?.state).toMatchObject({
|
|
179
183
|
outcome: { kind: "cancelled" },
|
|
180
184
|
});
|
|
181
185
|
|
|
@@ -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(
|
|
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(
|
|
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();
|
|
@@ -287,12 +287,21 @@ export function createNotebookReplica(
|
|
|
287
287
|
return {
|
|
288
288
|
stream: next,
|
|
289
289
|
retained: null,
|
|
290
|
-
analyzed: analysisView(
|
|
290
|
+
analyzed: analysisView(
|
|
291
|
+
retained && retained.notebook?.id !== next.notebook?.id
|
|
292
|
+
? null
|
|
293
|
+
: followed.analyzed,
|
|
294
|
+
document.current,
|
|
295
|
+
analysis,
|
|
296
|
+
),
|
|
291
297
|
};
|
|
292
298
|
}
|
|
293
299
|
return {
|
|
294
300
|
stream: next,
|
|
295
|
-
analyzed:
|
|
301
|
+
analyzed:
|
|
302
|
+
followed.analyzed?.freshness === "current"
|
|
303
|
+
? { ...followed.analyzed, freshness: "stale" }
|
|
304
|
+
: followed.analyzed,
|
|
296
305
|
retained: stream.phase === "snapshot" ? retained : stream,
|
|
297
306
|
};
|
|
298
307
|
});
|
|
@@ -18,15 +18,13 @@ type ProducedItem =
|
|
|
18
18
|
/** Time the host published the item, when included in a live event. */
|
|
19
19
|
export type Item = ProducedItem & { readonly time?: string };
|
|
20
20
|
|
|
21
|
-
/** An execution on the stream, with the items
|
|
21
|
+
/** An execution on the stream, with the items it has produced. */
|
|
22
22
|
export interface Execution extends Result {
|
|
23
23
|
/** Items by id. `itemsInOrder` sorts them by `seq`. */
|
|
24
24
|
readonly lastSeq?: number;
|
|
25
25
|
/** Fast path for a reader displaying exactly the version before an append. */
|
|
26
26
|
readonly append?: { before: WeakRef<Execution["items"]>; item: Item };
|
|
27
27
|
readonly items: ReadonlyMap<Protocol.ItemId, Item>;
|
|
28
|
-
/** The variables the execution bound, by item id. */
|
|
29
|
-
readonly variables: ReadonlyMap<Protocol.ItemId, Protocol.Variable>;
|
|
30
28
|
}
|
|
31
29
|
|
|
32
30
|
/**
|
|
@@ -41,6 +39,11 @@ export interface Executions {
|
|
|
41
39
|
readonly executions: ReadonlyMap<Protocol.ExecutionId, Execution>;
|
|
42
40
|
/** The execution on the stream for each cell that has one. */
|
|
43
41
|
readonly latest: ReadonlyMap<Protocol.CellId, Protocol.ExecutionId>;
|
|
42
|
+
/** Bindings by defining cell and item id, shared across unrelated stream updates. */
|
|
43
|
+
readonly variables: ReadonlyMap<
|
|
44
|
+
Protocol.CellId,
|
|
45
|
+
ReadonlyMap<Protocol.ItemId, Protocol.Variable>
|
|
46
|
+
>;
|
|
44
47
|
readonly results: Results;
|
|
45
48
|
readonly scratch: Result | null;
|
|
46
49
|
/** The latest scratch execution to start, including one that printed nothing. */
|
|
@@ -135,15 +138,14 @@ function remove(state: Executions, id: Protocol.ExecutionId): Executions {
|
|
|
135
138
|
return state;
|
|
136
139
|
}
|
|
137
140
|
const cellId = execution.record.cell_id;
|
|
141
|
+
const isLatest = cellId !== null && state.latest.get(cellId) === id;
|
|
138
142
|
return {
|
|
139
143
|
...state,
|
|
140
144
|
executions: without(state.executions, id),
|
|
145
|
+
variables: isLatest ? without(state.variables, cellId) : state.variables,
|
|
141
146
|
scratchConsole:
|
|
142
147
|
state.scratchConsole?.record.id === id ? undefined : state.scratchConsole,
|
|
143
|
-
latest:
|
|
144
|
-
cellId !== null && state.latest.get(cellId) === id
|
|
145
|
-
? without(state.latest, cellId)
|
|
146
|
-
: state.latest,
|
|
148
|
+
latest: isLatest ? without(state.latest, cellId) : state.latest,
|
|
147
149
|
};
|
|
148
150
|
}
|
|
149
151
|
|
|
@@ -182,23 +184,30 @@ function detach(state: Executions, itemId: Protocol.ItemId): Executions {
|
|
|
182
184
|
}
|
|
183
185
|
|
|
184
186
|
function bind(state: Executions, variable: Protocol.Variable): Executions {
|
|
185
|
-
const
|
|
186
|
-
if (
|
|
187
|
+
const cellId = state.executions.get(variable.execution_id)?.record.cell_id;
|
|
188
|
+
if (cellId == null) {
|
|
187
189
|
return state;
|
|
188
190
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
191
|
+
const bindings = new Map(state.variables.get(cellId)).set(
|
|
192
|
+
variable.id,
|
|
193
|
+
variable,
|
|
194
|
+
);
|
|
195
|
+
return {
|
|
196
|
+
...state,
|
|
197
|
+
variables: new Map(state.variables).set(cellId, bindings),
|
|
198
|
+
};
|
|
193
199
|
}
|
|
194
200
|
|
|
195
201
|
function unbind(state: Executions, itemId: Protocol.ItemId): Executions {
|
|
196
|
-
for (const
|
|
197
|
-
if (
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
variables
|
|
201
|
-
}
|
|
202
|
+
for (const [cellId, bindings] of state.variables) {
|
|
203
|
+
if (bindings.has(itemId)) {
|
|
204
|
+
const variables = new Map(state.variables);
|
|
205
|
+
if (bindings.size === 1) {
|
|
206
|
+
variables.delete(cellId);
|
|
207
|
+
} else {
|
|
208
|
+
variables.set(cellId, without(bindings, itemId));
|
|
209
|
+
}
|
|
210
|
+
return { ...state, variables };
|
|
202
211
|
}
|
|
203
212
|
}
|
|
204
213
|
return state;
|
|
@@ -282,6 +291,7 @@ export const executions: NotebookResource<Executions, Kind> = {
|
|
|
282
291
|
runs: new Map(),
|
|
283
292
|
executions: new Map(),
|
|
284
293
|
latest: new Map(),
|
|
294
|
+
variables: new Map(),
|
|
285
295
|
results: new Map(),
|
|
286
296
|
scratch: null,
|
|
287
297
|
},
|
|
@@ -319,7 +329,6 @@ export const executions: NotebookResource<Executions, Kind> = {
|
|
|
319
329
|
append: previous?.append,
|
|
320
330
|
lastSeq: previous?.lastSeq,
|
|
321
331
|
items: previous?.items ?? new Map(),
|
|
322
|
-
variables: previous?.variables ?? new Map(),
|
|
323
332
|
});
|
|
324
333
|
},
|
|
325
334
|
"execution.removed": (state, { data }) => remove(state, data.id),
|