@marimo-team/islands 0.25.3-dev482 → 0.25.3-dev486
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-LA5OtjAG.js → ConnectedDataExplorerComponent-BV2GFVYn.js} +9 -9
- package/dist/{ErrorBoundary-Tw4GGoit.js → ErrorBoundary-D--EtR81.js} +6 -6
- package/dist/{abnfDiagram-VCTEODGH-CBntFgCZ.js → abnfDiagram-VCTEODGH-1AWrWE-o.js} +2 -2
- package/dist/{any-language-editor-gzDRWdCH.js → any-language-editor-Dqpg95i0.js} +2 -2
- package/dist/{architectureDiagram-5GKGNRK7-Bz6ouXl-.js → architectureDiagram-5GKGNRK7-D0zM5fGn.js} +1 -1
- package/dist/{assertNever-DOTNJ2Y4.js → assertNever-BQEDS5Ew.js} +2 -2
- package/dist/assets/__vite-browser-external-DZv_7F5P.js +1 -0
- package/dist/assets/{worker-DFvnFhLF.js → worker-cHYZNFD4.js} +2 -2
- package/dist/{chat-ui-LeUI9zli.js → chat-ui-Blvl4-Kd.js} +16 -16
- package/dist/{check-CApwK1fD.js → check-BTnCP_6g.js} +1 -1
- package/dist/{chunk-IMKFNOWR-DK_M66Dt.js → chunk-IMKFNOWR-CTe-GyEo.js} +1 -1
- package/dist/{chunk-SHT3W25Y-C7Cg6zGL.js → chunk-SHT3W25Y-mDvz0_Bb.js} +1 -1
- package/dist/{chunk-SVP7TREG-K0lWia53.js → chunk-SVP7TREG-TQe5CTi-.js} +1 -1
- package/dist/{chunk-TICWLB2K-DiKpryGp.js → chunk-TICWLB2K-DueGZcaL.js} +1 -1
- package/dist/{classDiagram-ZZMXUADV-CXX5eaxi.js → classDiagram-ZZMXUADV-C80WtbRl.js} +2 -2
- package/dist/{classDiagram-v2-VYDZK3BY-Bjyy4iKL.js → classDiagram-v2-VYDZK3BY-BGUFGXB1.js} +2 -2
- package/dist/{code-visibility-CWrFAfrs.js → code-visibility-CKSt_AlX.js} +14 -14
- package/dist/{common-DZARFS07.js → common-B0U1M1ok.js} +30 -30
- package/dist/{config-C8TXSDmC.js → config-DbjezUyA.js} +3 -3
- package/dist/{copy-icon-CDvvlY90.js → copy-icon-7bY-OuK1.js} +2 -2
- package/dist/{createReducer-CXqSak4H.js → createReducer-BTiEYD5d.js} +1 -1
- package/dist/{cynefinDiagram-5FMLGOSQ-C-MlCYj4.js → cynefinDiagram-5FMLGOSQ-B1FxtX7q.js} +1 -1
- package/dist/{dagre-GXQ25YYZ-C6e9vEKZ.js → dagre-GXQ25YYZ-DsaxsLKR.js} +1 -1
- package/dist/{data-grid-overlay-editor-C1ZVcFjq.js → data-grid-overlay-editor-B1wgTm3e.js} +1 -1
- package/dist/{diagram-S7CK7UJ4-DgXNq_At.js → diagram-S7CK7UJ4-0_x8Q-Gz.js} +1 -1
- package/dist/{diagram-UQ7AKVKN-BG5NExCt.js → diagram-UQ7AKVKN-nvR7yqd-.js} +1 -1
- package/dist/{diagram-VX7I27RA-Da7VYCfC.js → diagram-VX7I27RA-BnEUU78X.js} +1 -1
- package/dist/{diagram-Z3DM3KII-DHk6GaR5.js → diagram-Z3DM3KII-BHX2x9ql.js} +1 -1
- package/dist/{dialog-rgayPemF.js → dialog-CBKdXrw9.js} +2 -2
- package/dist/{dropdown-menu-B12Nf3Zf.js → dropdown-menu-218IIk7S.js} +5 -5
- package/dist/{ebnfDiagram-PWID7BFC-DdSjinXr.js → ebnfDiagram-PWID7BFC-DYZD7-aw.js} +2 -2
- package/dist/{erDiagram-RLTQ6QDP-BgcwfZct.js → erDiagram-RLTQ6QDP-Bv-0tHzX.js} +1 -1
- package/dist/{error-banner-DXHIN-63.js → error-banner-cub3qDum.js} +1 -1
- package/dist/{error-entries--YT1ZOUW.js → error-entries-MZLN-feW.js} +92 -87
- package/dist/feedback-button-coih3loz.js +370 -0
- package/dist/{flowDiagram-HODETNUW-CVwzkmUF.js → flowDiagram-HODETNUW-BV2Dug--.js} +2 -2
- package/dist/{formats-BWuAsLfw.js → formats-CBWqzCiR.js} +1 -1
- package/dist/{glide-data-editor-BQHo_8OJ.js → glide-data-editor-BGlWbHIN.js} +11 -11
- package/dist/{glide-utils-D1McS0Pn.js → glide-utils-DlglW_uh.js} +2 -2
- package/dist/{globals-DQXC3L6D.js → globals-C08BeEBR.js} +3 -3
- package/dist/{html-to-image-BMt1erSy.js → html-to-image-D6h4lzXj.js} +79 -79
- package/dist/{infoDiagram-27XIBGKW-CHkU2P-8.js → infoDiagram-27XIBGKW-xekhSKlY.js} +1 -1
- package/dist/{ishikawaDiagram-5VMMS53U-B0k5UyY5.js → ishikawaDiagram-5VMMS53U-Coe7mUqv.js} +1 -1
- package/dist/{kanban-definition-UXKFOSKX-DwQvOV0x.js → kanban-definition-UXKFOSKX-Znywqtyi.js} +1 -1
- package/dist/main.js +8725 -8691
- package/dist/{mermaid-Bqy6f_NU.js → mermaid-DRT7MewO.js} +34 -34
- package/dist/{mindmap-definition-YA3MSWOX-CqvvAm8I.js → mindmap-definition-YA3MSWOX-Do_NrRXE.js} +1 -1
- package/dist/{number-overlay-editor-B6VKb3LS.js → number-overlay-editor-J2u2bfxK.js} +1 -1
- package/dist/{pegDiagram-XKGWAZYB-Befnx4Ry.js → pegDiagram-XKGWAZYB-CTuwofVH.js} +2 -2
- package/dist/{pencil-BC7pOv9g.js → pencil-qedVMD6q.js} +1 -1
- package/dist/{pieDiagram-E7YTZNPT-6rYFbF7p.js → pieDiagram-E7YTZNPT-CFHRBvha.js} +1 -1
- package/dist/{process-output-CNBGRz3r.js → process-output-MYh-Vr__.js} +4 -4
- package/dist/{railroadDiagram-O6MQD6OU-SSniwYC8.js → railroadDiagram-O6MQD6OU-BJBqS4A3.js} +2 -2
- package/dist/{requirementDiagram-BXWQKSXE-3L_xNfQr.js → requirementDiagram-BXWQKSXE-CoMoIh3b.js} +1 -1
- package/dist/{reveal-component-BlB1yXJU.js → reveal-component-CZLdWmre.js} +7 -7
- package/dist/{select-PQHWLm64.js → select-BcEi9lad.js} +4 -4
- package/dist/{sequenceDiagram-WJ2MYXX4-DvzIRlWu.js → sequenceDiagram-WJ2MYXX4-Cu7Mpp-z.js} +1 -1
- package/dist/{spec-6shN7lEe.js → spec-AxyC1vc5.js} +4 -4
- package/dist/{stateDiagram-D77RDMKH-VsHup-Ig.js → stateDiagram-D77RDMKH-DX7_Rnib.js} +2 -2
- package/dist/{stateDiagram-v2-MP3YSRHH-BwIIR8nk.js → stateDiagram-v2-MP3YSRHH-oFXVbGoo.js} +2 -2
- package/dist/{static-state-CWXd6dYX.js → static-state-CqzVppxA.js} +1 -1
- package/dist/{swimlanes-42K2YHIH-DhSDCIWI.js → swimlanes-42K2YHIH-CxzCGtVZ.js} +1 -1
- package/dist/{swimlanesDiagram-VR7AAH4N-C2WGVm-W.js → swimlanesDiagram-VR7AAH4N-1a1GRLNf.js} +2 -2
- package/dist/{timeline-definition-24CTP7MA-DhUhNinO.js → timeline-definition-24CTP7MA-Pfn2awsU.js} +1 -1
- package/dist/{toast-BGvv7tKS.js → toast-aYa8V5tR.js} +3 -3
- package/dist/{tooltip-CiJ919pg.js → tooltip-CwQmweEz.js} +1 -1
- package/dist/{use-restore-focus-BLj45Ibw.js → use-restore-focus-DlX1CSiq.js} +6 -1
- package/dist/{useDateFormatter-C659lkax.js → useDateFormatter-BAckjdIS.js} +2 -2
- package/dist/{useDeepCompareMemoize-CDhinwm7.js → useDeepCompareMemoize-C6mte0N8.js} +1 -1
- package/dist/{useLifecycle-mKiMNa4V.js → useLifecycle-XZ5KJAFU.js} +1 -1
- package/dist/{vega-component-CWvQ7wBJ.js → vega-component-_We1FoNw.js} +6 -6
- package/dist/{vennDiagram-4TSXK5OY-exvBF8P5.js → vennDiagram-4TSXK5OY-DrIqDugg.js} +1 -1
- package/dist/{wardleyDiagram-VM6X3IG4-BFhJmnXo.js → wardleyDiagram-VM6X3IG4-DBPVNfc3.js} +1 -1
- package/dist/{xychartDiagram-S5SC5T6Z-D_xAdG6u.js → xychartDiagram-S5SC5T6Z-64Isocef.js} +1 -1
- package/package.json +1 -1
- package/src/__mocks__/executions.ts +2 -0
- package/src/__tests__/CellStatus.test.tsx +3 -3
- package/src/components/dependency-graph/__tests__/elements.test.ts +20 -11
- package/src/components/dependency-graph/dependency-graph-tree.tsx +17 -3
- package/src/components/dependency-graph/elements.ts +12 -25
- package/src/components/editor/cell/CellStatus.tsx +23 -38
- package/src/components/editor/cell/ReusableDefinitionBadge.tsx +62 -0
- package/src/components/editor/notebook-cell.tsx +8 -67
- package/src/components/slides/slide-cell-view.tsx +1 -1
- package/src/core/cells/__tests__/cells.test.ts +0 -3
- package/src/core/cells/actions.ts +0 -1
- package/src/core/cells/cells.ts +0 -12
- package/src/core/cells/execution-console.ts +0 -2
- package/src/core/cells/reusable-definition.ts +25 -0
- package/src/core/cells/types.ts +1 -6
- package/src/core/executions/__tests__/atoms.test.ts +1 -41
- package/src/core/executions/__tests__/output-lifecycle.test.ts +1 -5
- package/src/core/executions/__tests__/select.test.ts +34 -2
- package/src/core/executions/atoms.ts +16 -31
- package/src/core/executions/hooks.ts +2 -3
- package/src/core/executions/index.ts +0 -1
- package/src/core/executions/select.ts +55 -2
- package/src/core/islands/bootstrap.ts +0 -16
- package/src/core/notebook/replica/replica.ts +50 -3
- package/src/core/notebook/replica/resources/analysis.ts +9 -0
- package/src/core/session/__tests__/backend.test.ts +3 -12
- package/src/core/session/__tests__/useNotebookSession.hook.test.tsx +84 -0
- package/src/core/session/active-notebook.ts +6 -0
- package/src/core/session/backend.ts +4 -4
- package/src/core/session/useNotebookSession.tsx +0 -17
- package/src/stories/cell-status.stories.tsx +6 -6
- package/dist/assets/__vite-browser-external-DoIBUY2I.js +0 -1
- package/dist/feedback-button-Cypq285l.js +0 -370
|
@@ -14,7 +14,6 @@ import {
|
|
|
14
14
|
acceptRun,
|
|
15
15
|
cellExecutionInputsAtom,
|
|
16
16
|
notebookQueuedOrRunningCountAtom,
|
|
17
|
-
setCellBlocked,
|
|
18
17
|
requestRun,
|
|
19
18
|
type RunRequest,
|
|
20
19
|
withdrawRequest,
|
|
@@ -111,53 +110,14 @@ describe("requestRun", () => {
|
|
|
111
110
|
expect(store.get(notebookQueuedOrRunningCountAtom)).toBe(0);
|
|
112
111
|
});
|
|
113
112
|
|
|
114
|
-
it("forgets requests
|
|
113
|
+
it("forgets requests when the notebook changes", () => {
|
|
115
114
|
const { store, replica } = shown();
|
|
116
115
|
request(store, [C1]);
|
|
117
|
-
setCellBlocked(store, C2, true);
|
|
118
116
|
|
|
119
117
|
store.set(replica.notebookAtom, MockExecutions.notebook("n2"));
|
|
120
118
|
|
|
121
119
|
expect(requested(store)).toEqual([]);
|
|
122
120
|
expect(statusOf(store)).toBe("idle");
|
|
123
|
-
expect(store.get(cellExecutionInputsAtom).blocked.size).toBe(0);
|
|
124
|
-
});
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
describe("setCellBlocked", () => {
|
|
128
|
-
it("does not show a requested cell as queued once the kernel reports it blocked", () => {
|
|
129
|
-
const { store } = shown();
|
|
130
|
-
request(store, [C1]);
|
|
131
|
-
expect(statusOf(store)).toBe("queued");
|
|
132
|
-
|
|
133
|
-
setCellBlocked(store, C1, true);
|
|
134
|
-
|
|
135
|
-
const view = cellExecutionView(store.get(cellExecutionInputsAtom), C1);
|
|
136
|
-
expect(view.status).toBe("idle");
|
|
137
|
-
expect(view.blocked).toBe(true);
|
|
138
|
-
expect(store.get(notebookQueuedOrRunningCountAtom)).toBe(0);
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
it("forgets requests and blocked cells with the replica they were made for", () => {
|
|
142
|
-
const { store } = shown();
|
|
143
|
-
request(store, [C1]);
|
|
144
|
-
setCellBlocked(store, C1, true);
|
|
145
|
-
|
|
146
|
-
MockExecutions.seed(store, [], null, documentOf());
|
|
147
|
-
|
|
148
|
-
const view = cellExecutionView(store.get(cellExecutionInputsAtom), C1);
|
|
149
|
-
expect(view.status).toBe("idle");
|
|
150
|
-
expect(view.blocked).toBe(false);
|
|
151
|
-
expect(store.get(notebookQueuedOrRunningCountAtom)).toBe(0);
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
it("keeps a request while the cell is merely queued", () => {
|
|
155
|
-
const { store } = shown();
|
|
156
|
-
request(store, [C1]);
|
|
157
|
-
|
|
158
|
-
setCellBlocked(store, C1, false);
|
|
159
|
-
|
|
160
|
-
expect(statusOf(store)).toBe("queued");
|
|
161
121
|
});
|
|
162
122
|
});
|
|
163
123
|
|
|
@@ -20,7 +20,6 @@ import {
|
|
|
20
20
|
cellOutputAtom,
|
|
21
21
|
clearCellOutputs,
|
|
22
22
|
isCurrent,
|
|
23
|
-
setCellBlocked,
|
|
24
23
|
requestRun,
|
|
25
24
|
withdrawRequest,
|
|
26
25
|
} from "../atoms";
|
|
@@ -128,9 +127,7 @@ describe("output lifetime", () => {
|
|
|
128
127
|
const pending = requestRun(store, [C1])!;
|
|
129
128
|
acceptRun(store, pending, run);
|
|
130
129
|
const late = requestRun(store, [C1])!;
|
|
131
|
-
setCellBlocked(store, C1, true);
|
|
132
130
|
clearCellOutputs(store, [C1]);
|
|
133
|
-
expect(store.get(cellExecutionInputsAtom).blocked.has(C1)).toBe(true);
|
|
134
131
|
expect(store.get(cellOutputAtom(C1))).toBeNull();
|
|
135
132
|
|
|
136
133
|
if (recovery !== "in-place reset") {
|
|
@@ -141,9 +138,8 @@ describe("output lifetime", () => {
|
|
|
141
138
|
} else {
|
|
142
139
|
message({ event: "ready", id: "120", data: {} });
|
|
143
140
|
}
|
|
144
|
-
const { requested
|
|
141
|
+
const { requested } = store.get(cellExecutionInputsAtom);
|
|
145
142
|
expect([...requested]).toEqual([]);
|
|
146
|
-
expect([...blocked]).toEqual([]);
|
|
147
143
|
expect(store.get(cellOutputAtom(C1))?.data).toBe("A");
|
|
148
144
|
expect(isCurrent(store, late)).toBe(false);
|
|
149
145
|
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
import type * as Protocol from "@marimo-team/client/protocol";
|
|
4
4
|
import { describe, expect, it } from "vitest";
|
|
5
|
-
import { CONFIG } from "@/core/notebook/document/__tests__/fixtures";
|
|
5
|
+
import { cell, CONFIG } from "@/core/notebook/document/__tests__/fixtures";
|
|
6
6
|
import type { Execution, Executions, Results } from "@/core/notebook/replica";
|
|
7
7
|
import {
|
|
8
8
|
anyRunning,
|
|
9
|
+
blockedDescendants,
|
|
9
10
|
type CellExecutionInputs,
|
|
10
11
|
cellExecutionView,
|
|
11
12
|
onlyScratchRunning,
|
|
@@ -13,6 +14,26 @@ import {
|
|
|
13
14
|
runningCellIds,
|
|
14
15
|
} from "../select";
|
|
15
16
|
|
|
17
|
+
it("counts only distinct disabled ancestors in a cycle", () => {
|
|
18
|
+
const analysis: Protocol.Analysis = {
|
|
19
|
+
notebook_id: "n1",
|
|
20
|
+
document_etag: "v1",
|
|
21
|
+
cells: {
|
|
22
|
+
a: { defs: [], refs: [], parents: ["b"], diagnostics: [] },
|
|
23
|
+
b: { defs: [], refs: [], parents: ["a"], diagnostics: [] },
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
const disabled = (id: string) =>
|
|
27
|
+
cell(id, "", { config: { ...CONFIG, disabled: true } });
|
|
28
|
+
const a = disabled("a");
|
|
29
|
+
expect(blockedDescendants(analysis, [a, cell("b", "")])).toEqual(
|
|
30
|
+
new Set(["b"]),
|
|
31
|
+
);
|
|
32
|
+
expect(blockedDescendants(analysis, [a, disabled("b")])).toEqual(
|
|
33
|
+
new Set(["a", "b"]),
|
|
34
|
+
);
|
|
35
|
+
});
|
|
36
|
+
|
|
16
37
|
const T0 = "2026-10-01T09:20:11Z";
|
|
17
38
|
const T1 = "2026-10-01T09:20:12.500Z";
|
|
18
39
|
const T2 = "2026-10-01T09:20:20Z";
|
|
@@ -116,7 +137,15 @@ function inputs({
|
|
|
116
137
|
{ config: { ...CONFIG, disabled: disabled.includes(id) } },
|
|
117
138
|
]),
|
|
118
139
|
);
|
|
119
|
-
return {
|
|
140
|
+
return {
|
|
141
|
+
executions: stream,
|
|
142
|
+
results,
|
|
143
|
+
cells,
|
|
144
|
+
requested,
|
|
145
|
+
blocked,
|
|
146
|
+
shownBlocked: blocked,
|
|
147
|
+
runtimeId,
|
|
148
|
+
};
|
|
120
149
|
}
|
|
121
150
|
|
|
122
151
|
describe("cellExecutionView", () => {
|
|
@@ -124,6 +153,7 @@ describe("cellExecutionView", () => {
|
|
|
124
153
|
expect(cellExecutionView(inputs({}), "c1")).toEqual({
|
|
125
154
|
status: "idle",
|
|
126
155
|
blocked: false,
|
|
156
|
+
shownBlock: null,
|
|
127
157
|
outcome: null,
|
|
128
158
|
startedAt: null,
|
|
129
159
|
duration: null,
|
|
@@ -153,6 +183,7 @@ describe("cellExecutionView", () => {
|
|
|
153
183
|
expect(cellExecutionView(running, "c1")).toEqual({
|
|
154
184
|
status: "running",
|
|
155
185
|
blocked: false,
|
|
186
|
+
shownBlock: null,
|
|
156
187
|
outcome: null,
|
|
157
188
|
startedAt: Date.parse(T2),
|
|
158
189
|
duration: null,
|
|
@@ -206,6 +237,7 @@ describe("cellExecutionView", () => {
|
|
|
206
237
|
expect(value).toEqual({
|
|
207
238
|
status: "idle",
|
|
208
239
|
blocked: false,
|
|
240
|
+
shownBlock: null,
|
|
209
241
|
outcome: "succeeded",
|
|
210
242
|
startedAt: Date.parse(T0),
|
|
211
243
|
duration: 1500,
|
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
} from "./output";
|
|
27
27
|
import {
|
|
28
28
|
anyRunning,
|
|
29
|
+
blockedDescendants,
|
|
29
30
|
type CellExecutionInputs,
|
|
30
31
|
queuedOrRunningCount,
|
|
31
32
|
} from "./select";
|
|
@@ -82,14 +83,6 @@ export interface RunRequest {
|
|
|
82
83
|
*/
|
|
83
84
|
const requestsAtom = atom<Marks<ReadonlySet<RunRequest>>>(null);
|
|
84
85
|
|
|
85
|
-
/**
|
|
86
|
-
* Cells the kernel reports as blocked by a disabled ancestor. Written only
|
|
87
|
-
* by the editor session.
|
|
88
|
-
*
|
|
89
|
-
* TODO(MO-8463): Derive from the document and the analysis stream.
|
|
90
|
-
*/
|
|
91
|
-
const blockedCellsAtom = atom<Marks<ReadonlySet<Protocol.CellId>>>(null);
|
|
92
|
-
|
|
93
86
|
function sameNotebook(
|
|
94
87
|
marked: ShownNotebook,
|
|
95
88
|
shown: ShownNotebook | null,
|
|
@@ -133,6 +126,19 @@ const requestedCellsAtom = atom((get) => {
|
|
|
133
126
|
: new Set([...requests].flatMap((request) => request.cells));
|
|
134
127
|
});
|
|
135
128
|
|
|
129
|
+
/** Use the disabled flags from the same revision as the dependency graph. */
|
|
130
|
+
const blockedCellsAtom = atom((get) => {
|
|
131
|
+
const replica = get(activeNotebookReplicaAtom);
|
|
132
|
+
const view = replica && get(replica.analysisAtom);
|
|
133
|
+
const shownBlocked = view
|
|
134
|
+
? blockedDescendants(view.analysis, view.document.cells.values())
|
|
135
|
+
: NO_BLOCKED;
|
|
136
|
+
return {
|
|
137
|
+
shownBlocked,
|
|
138
|
+
blocked: view?.freshness === "current" ? shownBlocked : NO_BLOCKED,
|
|
139
|
+
};
|
|
140
|
+
});
|
|
141
|
+
|
|
136
142
|
/** What every cell's view derives from. Pair with `cellExecutionView`. */
|
|
137
143
|
export const cellExecutionInputsAtom = atom((get): CellExecutionInputs => {
|
|
138
144
|
const replica = get(activeNotebookReplicaAtom);
|
|
@@ -142,7 +148,7 @@ export const cellExecutionInputsAtom = atom((get): CellExecutionInputs => {
|
|
|
142
148
|
results: replica === null ? NO_RESULTS : get(replica.resultsAtom),
|
|
143
149
|
cells: document?.cells ?? NO_CELLS,
|
|
144
150
|
requested: get(requestedCellsAtom),
|
|
145
|
-
|
|
151
|
+
...get(blockedCellsAtom),
|
|
146
152
|
runtimeId: replica === null ? null : (get(replica.runtimeAtom)?.id ?? null),
|
|
147
153
|
};
|
|
148
154
|
});
|
|
@@ -335,7 +341,7 @@ export function waitForRuntimeRunning(store: Store): Promise<void> {
|
|
|
335
341
|
* Record that this browser is asking the host to run `cellIds`, so that
|
|
336
342
|
* they read as queued before the host has answered.
|
|
337
343
|
*
|
|
338
|
-
* A disabled cell, or one
|
|
344
|
+
* A disabled cell, or one with a disabled ancestor, may be among them
|
|
339
345
|
* so the kernel can set it aside, but the views do not show it as queued.
|
|
340
346
|
* Returns null while no notebook is shown, since there is nothing to
|
|
341
347
|
* record the request against.
|
|
@@ -391,24 +397,3 @@ export function acceptRun(
|
|
|
391
397
|
}
|
|
392
398
|
check();
|
|
393
399
|
}
|
|
394
|
-
|
|
395
|
-
export function setCellBlocked(
|
|
396
|
-
store: Store,
|
|
397
|
-
cellId: Protocol.CellId,
|
|
398
|
-
blocked: boolean,
|
|
399
|
-
): void {
|
|
400
|
-
const known = store.get(cellExecutionInputsAtom).blocked;
|
|
401
|
-
if (known.has(cellId) === blocked) {
|
|
402
|
-
return;
|
|
403
|
-
}
|
|
404
|
-
const next = new Set(known);
|
|
405
|
-
if (blocked) {
|
|
406
|
-
next.add(cellId);
|
|
407
|
-
} else {
|
|
408
|
-
next.delete(cellId);
|
|
409
|
-
}
|
|
410
|
-
const notebook = store.get(shownNotebookAtom);
|
|
411
|
-
if (notebook !== null) {
|
|
412
|
-
store.set(blockedCellsAtom, { notebook, value: next });
|
|
413
|
-
}
|
|
414
|
-
}
|
|
@@ -23,9 +23,8 @@ import { type CellExecutionView, cellExecutionView } from "./select";
|
|
|
23
23
|
/**
|
|
24
24
|
* A cell's status, timing, and how it last ended.
|
|
25
25
|
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* kernel reports blocked by a disabled ancestor.
|
|
26
|
+
* Host executions describe the run, document analysis identifies blocked
|
|
27
|
+
* cells, and local requests account for runs the host has yet to plan.
|
|
29
28
|
*/
|
|
30
29
|
export function useCellExecution(id: Protocol.CellId): CellExecutionView {
|
|
31
30
|
// One atom per mounted cell, kept for its subscription and compared by
|
|
@@ -17,6 +17,7 @@ export interface CellExecutionView {
|
|
|
17
17
|
readonly status: CellRunStatus;
|
|
18
18
|
/** Whether a cell it depends on is disabled, so it cannot run. */
|
|
19
19
|
readonly blocked: boolean;
|
|
20
|
+
readonly shownBlock: "current" | "stale" | null;
|
|
20
21
|
/** Null until the cell completes once, and while it runs again. */
|
|
21
22
|
readonly outcome: CellOutcome | null;
|
|
22
23
|
/**
|
|
@@ -48,8 +49,9 @@ export interface CellExecutionInputs {
|
|
|
48
49
|
* shown the run.
|
|
49
50
|
*/
|
|
50
51
|
readonly requested: ReadonlySet<Protocol.CellId>;
|
|
51
|
-
/** Cells
|
|
52
|
+
/** Cells with a disabled ancestor in the confirmed document. */
|
|
52
53
|
readonly blocked: ReadonlySet<Protocol.CellId>;
|
|
54
|
+
readonly shownBlocked: ReadonlySet<Protocol.CellId>;
|
|
53
55
|
/** The notebook's runtime, null while it has none or the stream is not ready. */
|
|
54
56
|
readonly runtimeId: Protocol.RuntimeId | null;
|
|
55
57
|
}
|
|
@@ -72,6 +74,51 @@ function latestOf(
|
|
|
72
74
|
: (executions.executions.get(executionId) ?? null);
|
|
73
75
|
}
|
|
74
76
|
|
|
77
|
+
/** Cells with a distinct disabled ancestor in the host's dependency graph. */
|
|
78
|
+
export function blockedDescendants(
|
|
79
|
+
analysis: Protocol.Analysis,
|
|
80
|
+
cells: Iterable<Protocol.Cell>,
|
|
81
|
+
): ReadonlySet<Protocol.CellId> {
|
|
82
|
+
const blocked = new Set<Protocol.CellId>();
|
|
83
|
+
const roots = [...cells].filter((cell) => cell.config.disabled);
|
|
84
|
+
if (roots.length === 0) {
|
|
85
|
+
return blocked;
|
|
86
|
+
}
|
|
87
|
+
const children = new Map<Protocol.CellId, Protocol.CellId[]>();
|
|
88
|
+
for (const id of Object.keys(analysis.cells)) {
|
|
89
|
+
children.set(id, []);
|
|
90
|
+
}
|
|
91
|
+
for (const [id, { parents }] of Object.entries(analysis.cells)) {
|
|
92
|
+
if (parents === undefined) {
|
|
93
|
+
return blocked;
|
|
94
|
+
}
|
|
95
|
+
for (const parent of parents) {
|
|
96
|
+
children.get(parent)?.push(id);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// A second distinct root blocks even the first root in a cycle.
|
|
101
|
+
// Beyond two roots, visiting the same subtree cannot add any blocked cells.
|
|
102
|
+
const visits = new Map<Protocol.CellId, number>();
|
|
103
|
+
for (const root of roots) {
|
|
104
|
+
const reachable = new Set([root.id]);
|
|
105
|
+
for (const id of reachable) {
|
|
106
|
+
if (id !== root.id) {
|
|
107
|
+
blocked.add(id);
|
|
108
|
+
}
|
|
109
|
+
const count = visits.get(id) ?? 0;
|
|
110
|
+
if (count === 2) {
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
visits.set(id, count + 1);
|
|
114
|
+
for (const child of children.get(id) ?? []) {
|
|
115
|
+
reachable.add(child);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return blocked;
|
|
120
|
+
}
|
|
121
|
+
|
|
75
122
|
/**
|
|
76
123
|
* Whether a run can reach `id`, meaning the document has the cell and
|
|
77
124
|
* nothing keeps it from running.
|
|
@@ -137,9 +184,15 @@ export function cellExecutionView(
|
|
|
137
184
|
settled && began !== null && ended !== null
|
|
138
185
|
? Time.parse(ended).since(Time.parse(began))
|
|
139
186
|
: null;
|
|
187
|
+
const blocked = inputs.blocked.has(id);
|
|
140
188
|
return {
|
|
141
189
|
status,
|
|
142
|
-
blocked
|
|
190
|
+
blocked,
|
|
191
|
+
shownBlock: blocked
|
|
192
|
+
? "current"
|
|
193
|
+
: inputs.shownBlocked.has(id)
|
|
194
|
+
? "stale"
|
|
195
|
+
: null,
|
|
143
196
|
outcome: settled && result !== null ? outcomeOf(result) : null,
|
|
144
197
|
live:
|
|
145
198
|
result === null ||
|
|
@@ -26,7 +26,6 @@ import { UI_ELEMENT_REGISTRY } from "../dom/uiregistry";
|
|
|
26
26
|
import { FUNCTIONS_REGISTRY } from "../functions/FunctionRegistry";
|
|
27
27
|
import { createNotebookReplica } from "../notebook/replica";
|
|
28
28
|
import { consoleObservers } from "../cells/execution-console";
|
|
29
|
-
import { setCellBlocked } from "../executions";
|
|
30
29
|
import { handleKernelReady, handleRemoveUIElements } from "../kernel/handlers";
|
|
31
30
|
import type { NotificationMessage } from "../kernel/messages";
|
|
32
31
|
import { queryParamHandlers } from "../kernel/queryParamHandlers";
|
|
@@ -260,21 +259,6 @@ function handleNotification(
|
|
|
260
259
|
inputIds: msg.input_ids,
|
|
261
260
|
});
|
|
262
261
|
return;
|
|
263
|
-
case "cell-op":
|
|
264
|
-
if (msg.status != null) {
|
|
265
|
-
setCellBlocked(
|
|
266
|
-
store,
|
|
267
|
-
msg.cell_id,
|
|
268
|
-
msg.status === "disabled-transitively",
|
|
269
|
-
);
|
|
270
|
-
}
|
|
271
|
-
if (msg.serialization !== undefined) {
|
|
272
|
-
actions.setCellReusability({
|
|
273
|
-
cell_id: msg.cell_id,
|
|
274
|
-
serialization: msg.serialization,
|
|
275
|
-
});
|
|
276
|
-
}
|
|
277
|
-
return;
|
|
278
262
|
case "callback-output":
|
|
279
263
|
VirtualFileTracker.INSTANCE.trackCallbackOutput(msg);
|
|
280
264
|
actions.showCommandOutput(msg);
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
StreamStopped,
|
|
11
11
|
} from "@marimo-team/client";
|
|
12
12
|
import type {
|
|
13
|
+
Analysis,
|
|
13
14
|
Attachment,
|
|
14
15
|
Execution as HostExecution,
|
|
15
16
|
Output as HostOutput,
|
|
@@ -24,6 +25,7 @@ import {
|
|
|
24
25
|
ConnectionState,
|
|
25
26
|
type ConnectionStatus,
|
|
26
27
|
} from "./connection";
|
|
28
|
+
import { analysis } from "./resources/analysis";
|
|
27
29
|
import { attachments } from "./resources/attachments";
|
|
28
30
|
import { type Document, document } from "./resources/document";
|
|
29
31
|
import {
|
|
@@ -52,6 +54,7 @@ export const EDITOR_EVENT_KINDS = [
|
|
|
52
54
|
"input",
|
|
53
55
|
"output",
|
|
54
56
|
"variable",
|
|
57
|
+
"analysis",
|
|
55
58
|
"marimo",
|
|
56
59
|
] as const;
|
|
57
60
|
|
|
@@ -60,6 +63,30 @@ type EditorEvent = NotebookStreamEvent<(typeof EDITOR_EVENT_KINDS)[number]>;
|
|
|
60
63
|
/** A native marimo notification, passed through without interpretation. */
|
|
61
64
|
const MarimoMessage = z.object({ marimo: z.unknown() });
|
|
62
65
|
|
|
66
|
+
interface AnalysisView {
|
|
67
|
+
readonly freshness: "current" | "stale";
|
|
68
|
+
readonly analysis: Analysis;
|
|
69
|
+
readonly document: Document;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function analysisView(
|
|
73
|
+
previous: AnalysisView | null,
|
|
74
|
+
document: Document | null,
|
|
75
|
+
analysis: Analysis | null,
|
|
76
|
+
): AnalysisView | null {
|
|
77
|
+
if (document === null) {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
if (analysis?.document_etag === document.revision.etag) {
|
|
81
|
+
return previous?.analysis === analysis && previous.freshness === "current"
|
|
82
|
+
? previous
|
|
83
|
+
: { freshness: "current", document, analysis };
|
|
84
|
+
}
|
|
85
|
+
return previous?.freshness === "current"
|
|
86
|
+
? { ...previous, freshness: "stale" }
|
|
87
|
+
: previous;
|
|
88
|
+
}
|
|
89
|
+
|
|
63
90
|
/** A notebook as its backend's stream reports it, kept current while connected. */
|
|
64
91
|
export interface NotebookReplica {
|
|
65
92
|
/** Connection status, independent of application session readiness. */
|
|
@@ -77,6 +104,8 @@ export interface NotebookReplica {
|
|
|
77
104
|
* submit against this one.
|
|
78
105
|
*/
|
|
79
106
|
readonly documentAtom: Atom<Document | null>;
|
|
107
|
+
/** Last analysis paired with its document. Only current analysis can gate actions. */
|
|
108
|
+
readonly analysisAtom: Atom<AnalysisView | null>;
|
|
80
109
|
/**
|
|
81
110
|
* The document on show: `documentAtom`, or through a reset, the one it
|
|
82
111
|
* replaced until the snapshot that follows is complete.
|
|
@@ -176,6 +205,7 @@ export function createNotebookReplica(
|
|
|
176
205
|
// One atom holds the whole stream, which resource atoms derive from.
|
|
177
206
|
const reducer = createNotebookReducer({
|
|
178
207
|
document,
|
|
208
|
+
analysis,
|
|
179
209
|
attachments,
|
|
180
210
|
runtime,
|
|
181
211
|
executions,
|
|
@@ -189,9 +219,14 @@ export function createNotebookReplica(
|
|
|
189
219
|
* whose session changed. Showing the new snapshot as it arrives would
|
|
190
220
|
* empty every view for as long as that takes.
|
|
191
221
|
*/
|
|
192
|
-
const followedAtom = atom<{
|
|
222
|
+
const followedAtom = atom<{
|
|
223
|
+
stream: Stream;
|
|
224
|
+
retained: Stream | null;
|
|
225
|
+
analyzed: AnalysisView | null;
|
|
226
|
+
}>({
|
|
193
227
|
stream: reducer.initial,
|
|
194
228
|
retained: null,
|
|
229
|
+
analyzed: null,
|
|
195
230
|
});
|
|
196
231
|
const streamAtom = atom((get) => get(followedAtom).stream);
|
|
197
232
|
const shownAtom = atom((get) => {
|
|
@@ -209,6 +244,7 @@ export function createNotebookReplica(
|
|
|
209
244
|
const documentAtom = atom(
|
|
210
245
|
(get) => get(streamAtom).resources.document.current,
|
|
211
246
|
);
|
|
247
|
+
const analysisAtom = atom((get) => get(followedAtom).analyzed);
|
|
212
248
|
const shownDocumentAtom = atom(
|
|
213
249
|
(get) => get(shownAtom).resources.document.current,
|
|
214
250
|
);
|
|
@@ -247,10 +283,16 @@ export function createNotebookReplica(
|
|
|
247
283
|
},
|
|
248
284
|
};
|
|
249
285
|
}
|
|
250
|
-
|
|
286
|
+
const { analysis, document } = next.resources;
|
|
287
|
+
return {
|
|
288
|
+
stream: next,
|
|
289
|
+
retained: null,
|
|
290
|
+
analyzed: analysisView(followed.analyzed, document.current, analysis),
|
|
291
|
+
};
|
|
251
292
|
}
|
|
252
293
|
return {
|
|
253
294
|
stream: next,
|
|
295
|
+
analyzed: null,
|
|
254
296
|
retained: stream.phase === "snapshot" ? retained : stream,
|
|
255
297
|
};
|
|
256
298
|
});
|
|
@@ -265,7 +307,11 @@ export function createNotebookReplica(
|
|
|
265
307
|
|
|
266
308
|
/** Drop what the stream reported and show `status`. */
|
|
267
309
|
function clear(status: ConnectionStatus) {
|
|
268
|
-
store.set(followedAtom, {
|
|
310
|
+
store.set(followedAtom, {
|
|
311
|
+
stream: reducer.initial,
|
|
312
|
+
retained: null,
|
|
313
|
+
analyzed: null,
|
|
314
|
+
});
|
|
269
315
|
setStatus(status);
|
|
270
316
|
}
|
|
271
317
|
|
|
@@ -274,6 +320,7 @@ export function createNotebookReplica(
|
|
|
274
320
|
generationAtom,
|
|
275
321
|
notebookAtom,
|
|
276
322
|
documentAtom,
|
|
323
|
+
analysisAtom,
|
|
277
324
|
shownDocumentAtom,
|
|
278
325
|
backendAtom,
|
|
279
326
|
attachmentsAtom,
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
|
|
3
|
+
import type { NotebookResource } from "@marimo-team/client";
|
|
4
|
+
import type { Analysis } from "@marimo-team/client/protocol";
|
|
5
|
+
|
|
6
|
+
export const analysis: NotebookResource<Analysis | null, "analysis"> = {
|
|
7
|
+
initial: null,
|
|
8
|
+
on: { analysis: (_state, { data }) => data.analysis },
|
|
9
|
+
};
|
|
@@ -80,20 +80,11 @@ describe("createEditorBackend", () => {
|
|
|
80
80
|
).toBe(true),
|
|
81
81
|
);
|
|
82
82
|
const networkUrl = opened[0] ?? fetch.mock.calls[0]?.[0];
|
|
83
|
-
const
|
|
83
|
+
const params =
|
|
84
84
|
networkUrl === undefined
|
|
85
85
|
? undefined
|
|
86
|
-
: new URL(String(networkUrl)).searchParams
|
|
87
|
-
|
|
88
|
-
"execution",
|
|
89
|
-
"console",
|
|
90
|
-
"output",
|
|
91
|
-
"input",
|
|
92
|
-
"marimo",
|
|
93
|
-
];
|
|
94
|
-
expect(executionKinds.filter((kind) => kinds?.includes(kind))).toEqual(
|
|
95
|
-
expected === "socket" || expected === "fetch" ? executionKinds : [],
|
|
96
|
-
);
|
|
86
|
+
: new URL(String(networkUrl)).searchParams;
|
|
87
|
+
expect(params?.has("kinds")).toBeFalsy();
|
|
97
88
|
events.close();
|
|
98
89
|
});
|
|
99
90
|
|
|
@@ -54,6 +54,12 @@ import { ConnectionNotice } from "@/components/editor/alerts/connection-notice";
|
|
|
54
54
|
import { kernelStartupErrorAtom } from "@/core/errors/state";
|
|
55
55
|
import type { NotificationPayload } from "@/core/kernel/messages";
|
|
56
56
|
import { useRuntimeManager } from "@/core/runtime/config";
|
|
57
|
+
import { cellExecutionInputsAtom, cellExecutionView } from "@/core/executions";
|
|
58
|
+
import {
|
|
59
|
+
cell,
|
|
60
|
+
CONFIG,
|
|
61
|
+
document as documentOf,
|
|
62
|
+
} from "@/core/notebook/document/__tests__/fixtures";
|
|
57
63
|
import { initialRunCompletedAtom } from "../../kernel/state";
|
|
58
64
|
import { connectionAtom, startupProgressAtom } from "../../network/connection";
|
|
59
65
|
import { generateSessionId } from "../../kernel/session";
|
|
@@ -353,6 +359,84 @@ describe("useNotebookSession messages", () => {
|
|
|
353
359
|
act(() => connection(fake).receive(payload));
|
|
354
360
|
}
|
|
355
361
|
|
|
362
|
+
it("keeps the last blocked indicator across edits until the host replaces the graph", () => {
|
|
363
|
+
const revision = documentOf().revision;
|
|
364
|
+
const graph = { a: [], b: ["a"], c: ["b"], d: [] };
|
|
365
|
+
function publish(version: number) {
|
|
366
|
+
const codes = {
|
|
367
|
+
a: "x = 1",
|
|
368
|
+
b: version < 3 ? "y = x" : "y = 0",
|
|
369
|
+
c: "print(y)",
|
|
370
|
+
d: version === 1 ? "0" : "1",
|
|
371
|
+
};
|
|
372
|
+
for (const [id, code] of Object.entries(codes)) {
|
|
373
|
+
const record = cell(id, code, {
|
|
374
|
+
version,
|
|
375
|
+
etag: id + version,
|
|
376
|
+
config: { ...CONFIG, disabled: id === "a" },
|
|
377
|
+
});
|
|
378
|
+
receive({ event: "cell", data: { cell: record } });
|
|
379
|
+
}
|
|
380
|
+
const document = {
|
|
381
|
+
...revision,
|
|
382
|
+
version,
|
|
383
|
+
etag: String(version),
|
|
384
|
+
order: Object.keys(graph),
|
|
385
|
+
};
|
|
386
|
+
receive({ event: "document", data: { document } });
|
|
387
|
+
}
|
|
388
|
+
function analyze(
|
|
389
|
+
version: number,
|
|
390
|
+
parents: Record<string, string[]> | null,
|
|
391
|
+
) {
|
|
392
|
+
const analysis = {
|
|
393
|
+
notebook_id: revision.notebook_id,
|
|
394
|
+
document_etag: String(version),
|
|
395
|
+
cells: Object.fromEntries(
|
|
396
|
+
Object.keys(graph).map((id) => [
|
|
397
|
+
id,
|
|
398
|
+
{
|
|
399
|
+
defs: [],
|
|
400
|
+
refs: [],
|
|
401
|
+
diagnostics: [],
|
|
402
|
+
...(parents && { parents: parents[id] }),
|
|
403
|
+
},
|
|
404
|
+
]),
|
|
405
|
+
),
|
|
406
|
+
};
|
|
407
|
+
receive({ event: "analysis", data: { analysis } });
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
receive({
|
|
411
|
+
event: "notebook",
|
|
412
|
+
data: { notebook: MockExecutions.notebook() },
|
|
413
|
+
});
|
|
414
|
+
publish(1);
|
|
415
|
+
receive({ event: "ready", id: "1", data: {} });
|
|
416
|
+
const blocked = () => store.get(cellExecutionInputsAtom).blocked;
|
|
417
|
+
expect(blocked().size).toBe(0);
|
|
418
|
+
analyze(1, null);
|
|
419
|
+
expect(blocked().size).toBe(0);
|
|
420
|
+
analyze(1, graph);
|
|
421
|
+
expect(blocked()).toEqual(new Set(["b", "c"]));
|
|
422
|
+
|
|
423
|
+
const badge = () =>
|
|
424
|
+
cellExecutionView(store.get(cellExecutionInputsAtom), "b").shownBlock;
|
|
425
|
+
expect(badge()).toBe("current");
|
|
426
|
+
publish(2);
|
|
427
|
+
expect(blocked().size).toBe(0);
|
|
428
|
+
expect(badge()).toBe("stale");
|
|
429
|
+
analyze(2, graph);
|
|
430
|
+
expect(badge()).toBe("current");
|
|
431
|
+
|
|
432
|
+
publish(3);
|
|
433
|
+
analyze(2, graph);
|
|
434
|
+
expect(badge()).toBe("stale");
|
|
435
|
+
analyze(3, { ...graph, b: [] });
|
|
436
|
+
expect(badge()).toBeNull();
|
|
437
|
+
expect(blocked().size).toBe(0);
|
|
438
|
+
});
|
|
439
|
+
|
|
356
440
|
it("records completion of the initial run", () => {
|
|
357
441
|
const notification = {
|
|
358
442
|
op: "completed-run",
|
|
@@ -7,6 +7,12 @@ import type { NotebookReplica } from "../notebook/replica";
|
|
|
7
7
|
/** The replica owned by the mounted notebook session. */
|
|
8
8
|
export const activeNotebookReplicaAtom = atom<NotebookReplica | null>(null);
|
|
9
9
|
|
|
10
|
+
/** The last analysis, kept while the host analyzes a newer revision. */
|
|
11
|
+
export const notebookAnalysisAtom = atom((get) => {
|
|
12
|
+
const replica = get(activeNotebookReplicaAtom);
|
|
13
|
+
return (replica && get(replica.analysisAtom)?.analysis) ?? null;
|
|
14
|
+
});
|
|
15
|
+
|
|
10
16
|
/** The document model owned by the mounted notebook session. */
|
|
11
17
|
export const activeDocumentModelAtom = atom<DocumentModel | null>(null);
|
|
12
18
|
|