@marimo-team/islands 0.26.1-dev18 → 0.26.1-dev20
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-BO3Zpp5H.js → ErrorBoundary-Cx-CwafE.js} +1 -1
- package/dist/{chat-ui-b1ERxzeA.js → chat-ui-qZdDDrzU.js} +3 -3
- package/dist/{code-visibility-CMM88JXK.js → code-visibility-CVfXV6fG.js} +2 -2
- package/dist/{common-DPQs9PgT.js → common-BXRJCkJO.js} +3 -3
- package/dist/{data-grid-overlay-editor-ByuVzPXI.js → data-grid-overlay-editor-Mbtx3F9C.js} +1 -1
- package/dist/{error-entries-Bl8fzLQc.js → error-entries-DhI0hGvj.js} +448 -450
- package/dist/{feedback-button-BT4k2_Yi.js → feedback-button-zx4NcNDn.js} +3 -3
- package/dist/{glide-data-editor-xhiVBVLv.js → glide-data-editor-CvezoJKg.js} +3 -3
- package/dist/{globals-Rngj0Xbq.js → globals-CQuPaxzy.js} +1 -1
- package/dist/{html-to-image-D6A1lg0A.js → html-to-image-B803aaWE.js} +1 -1
- package/dist/main.js +3211 -3201
- package/dist/{number-overlay-editor-wXnPSQsq.js → number-overlay-editor-DxM7vsCk.js} +1 -1
- package/dist/{process-output-w5omHedc.js → process-output-CnCLfvnL.js} +2 -2
- package/dist/{reveal-component-f1JkdeUt.js → reveal-component-BefmhjJF.js} +2 -2
- package/package.json +1 -1
- package/src/__mocks__/executions.ts +19 -18
- package/src/__mocks__/notebook.ts +1 -1
- package/src/components/editor/actions/__tests__/name-cell-input.test.tsx +1 -1
- package/src/components/editor/cell/__tests__/useRunCells.test.tsx +3 -3
- package/src/components/editor/chrome/wrapper/__tests__/document-sync-status.test.tsx +5 -2
- 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 +3 -3
- 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 +2 -2
- package/src/core/cells/session.ts +4 -4
- package/src/core/executions/__tests__/atoms.test.ts +5 -2
- package/src/core/executions/__tests__/freshness.test.ts +56 -52
- package/src/core/executions/__tests__/interrupt.test.ts +2 -2
- package/src/core/executions/__tests__/output.test.ts +3 -1
- package/src/core/executions/__tests__/run.test.ts +2 -2
- package/src/core/executions/__tests__/select.test.ts +70 -62
- package/src/core/executions/atoms.ts +1 -1
- 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 +8 -5
- package/src/core/notebook/replica/__tests__/fixtures.ts +6 -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 +1 -1
- package/src/core/transports/static.ts +2 -2
|
@@ -5,6 +5,9 @@ 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";
|
|
9
|
+
|
|
10
|
+
const C3 = cellId("c3");
|
|
8
11
|
|
|
9
12
|
const reducer = createNotebookReducer({ executions });
|
|
10
13
|
const snapshot = fixtureEvents("notebook-events.sse");
|
|
@@ -64,9 +67,9 @@ describe("executions resource", () => {
|
|
|
64
67
|
it("indexes a cell's execution while it is on the stream", () => {
|
|
65
68
|
const start = replay(snapshot);
|
|
66
69
|
const running = resource(replay(runCells.slice(0, 5), start));
|
|
67
|
-
expect(running.latest.get(
|
|
70
|
+
expect(running.latest.get(C3)).toBe("e12");
|
|
68
71
|
expect(running.executions.get("e12")?.record.state.status).toBe("running");
|
|
69
|
-
expect(running.latest.get("k7f2")).toBe("e13");
|
|
72
|
+
expect(running.latest.get(cellId("k7f2"))).toBe("e13");
|
|
70
73
|
expect(running.runs.get("run-cells")?.state.status).toBe("running");
|
|
71
74
|
|
|
72
75
|
const done = replay(runCells, start);
|
|
@@ -85,7 +88,7 @@ describe("executions resource", () => {
|
|
|
85
88
|
|
|
86
89
|
const retired = replay(retire("e12", "e12-x"), done);
|
|
87
90
|
expect(resource(retired).executions.has("e12")).toBe(false);
|
|
88
|
-
expect(resource(retired).latest.has(
|
|
91
|
+
expect(resource(retired).latest.has(C3)).toBe(false);
|
|
89
92
|
const queued = reducer.reduce(
|
|
90
93
|
retired,
|
|
91
94
|
event({
|
|
@@ -104,7 +107,7 @@ describe("executions resource", () => {
|
|
|
104
107
|
},
|
|
105
108
|
}),
|
|
106
109
|
);
|
|
107
|
-
expect(resource(queued).latest.get(
|
|
110
|
+
expect(resource(queued).latest.get(C3)).toBe("e14");
|
|
108
111
|
expect([...resource(queued).executions.keys()]).toEqual([
|
|
109
112
|
"e7",
|
|
110
113
|
"e13",
|
|
@@ -149,7 +152,7 @@ describe("executions resource", () => {
|
|
|
149
152
|
const e12 = resource(cleared).executions.get("e12")!;
|
|
150
153
|
expect(ids(e12)).toEqual([]);
|
|
151
154
|
expect(e12.variables.size).toBe(0);
|
|
152
|
-
expect(resource(cleared).latest.get(
|
|
155
|
+
expect(resource(cleared).latest.get(C3)).toBe("e12");
|
|
153
156
|
});
|
|
154
157
|
|
|
155
158
|
it("orders items by seq, replaces them by id, and drops orphans", () => {
|
|
@@ -96,8 +96,12 @@ export function fixtureMessages(name: string) {
|
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
/** Read the protocol's portable examples as decoded protocol events. */
|
|
99
|
-
export function fixtureEvents(
|
|
99
|
+
export function fixtureEvents(
|
|
100
|
+
name: string,
|
|
101
|
+
): Protocol.NotebookStreamEventOutput[] {
|
|
100
102
|
return fixtureMessages(name).map(({ id, ...message }) =>
|
|
101
|
-
Protocol.NotebookStreamEvent.parse(
|
|
103
|
+
Protocol.NotebookStreamEvent.parse(
|
|
104
|
+
id === undefined ? message : { ...message, id },
|
|
105
|
+
),
|
|
102
106
|
);
|
|
103
107
|
}
|
|
@@ -5,6 +5,10 @@ import * as Protocol from "@marimo-team/client/protocol";
|
|
|
5
5
|
import { executions } from "../resources/executions";
|
|
6
6
|
import { createNotebookReducer } from "@marimo-team/client";
|
|
7
7
|
import { fixtureEvents } from "./fixtures";
|
|
8
|
+
import { cellId } from "@/__tests__/branded";
|
|
9
|
+
|
|
10
|
+
const C3 = cellId("c3");
|
|
11
|
+
const FIXTURE_CELL = cellId("k7f2");
|
|
8
12
|
|
|
9
13
|
const reducer = createNotebookReducer({ executions });
|
|
10
14
|
const snapshot = fixtureEvents("notebook-events.sse");
|
|
@@ -67,28 +71,28 @@ describe("retained results", () => {
|
|
|
67
71
|
...snapshot.slice(ready),
|
|
68
72
|
]),
|
|
69
73
|
);
|
|
70
|
-
expect(opened.get(
|
|
71
|
-
expect(opened.get(
|
|
74
|
+
expect(opened.get(C3)?.record.id).toBe("e-restored");
|
|
75
|
+
expect(opened.get(C3)?.record.run_id).toBeNull();
|
|
72
76
|
});
|
|
73
77
|
|
|
74
78
|
it("records a cell's result when its execution completes", () => {
|
|
75
79
|
const start = replay(snapshot);
|
|
76
80
|
const running = resource(replay(runCells.slice(0, 5), start));
|
|
77
|
-
expect(running.get(
|
|
78
|
-
expect(running.get(
|
|
81
|
+
expect(running.get(C3)).toBeNull();
|
|
82
|
+
expect(running.get(FIXTURE_CELL)).toBeNull();
|
|
79
83
|
|
|
80
84
|
const done = resource(replay(runCells, start));
|
|
81
|
-
expect(done.get(
|
|
82
|
-
expect(done.get(
|
|
83
|
-
expect(done.get(
|
|
85
|
+
expect(done.get(C3)?.record.id).toBe("e12");
|
|
86
|
+
expect(done.get(C3)?.record.state.status).toBe("completed");
|
|
87
|
+
expect(done.get(FIXTURE_CELL)?.record.state).toHaveProperty("depends_on", {
|
|
84
88
|
x: { execution_id: "e12", update: 0 },
|
|
85
89
|
});
|
|
86
|
-
expect(done.get("c1")).toBeNull();
|
|
90
|
+
expect(done.get(cellId("c1"))).toBeNull();
|
|
87
91
|
});
|
|
88
92
|
|
|
89
93
|
it("keeps a result when the attempt that replaced it was superseded", () => {
|
|
90
94
|
const done = replay(runCells, replay(snapshot));
|
|
91
|
-
const result = resource(done).get(
|
|
95
|
+
const result = resource(done).get(C3)!;
|
|
92
96
|
const superseded = reducer.reduce(
|
|
93
97
|
replay(retire("e12", "e12-x"), done),
|
|
94
98
|
event({
|
|
@@ -115,14 +119,14 @@ describe("retained results", () => {
|
|
|
115
119
|
},
|
|
116
120
|
}),
|
|
117
121
|
);
|
|
118
|
-
expect(resource(superseded).get(
|
|
122
|
+
expect(resource(superseded).get(C3)).toBe(result);
|
|
119
123
|
});
|
|
120
124
|
|
|
121
125
|
it("keeps a result while the host replaces it", () => {
|
|
122
126
|
const done = replay(runCells, replay(snapshot));
|
|
123
|
-
const result = resource(done).get(
|
|
127
|
+
const result = resource(done).get(C3)!;
|
|
124
128
|
const retired = replay(retire("e12", "e12-x"), done);
|
|
125
|
-
expect(resource(retired).get(
|
|
129
|
+
expect(resource(retired).get(C3)).toBe(result);
|
|
126
130
|
|
|
127
131
|
const again = {
|
|
128
132
|
...result.record,
|
|
@@ -134,7 +138,7 @@ describe("retained results", () => {
|
|
|
134
138
|
retired,
|
|
135
139
|
event({ event: "execution", id: "113", data: { execution: again } }),
|
|
136
140
|
);
|
|
137
|
-
expect(resource(queued).get(
|
|
141
|
+
expect(resource(queued).get(C3)).toBe(result);
|
|
138
142
|
|
|
139
143
|
const completed = reducer.reduce(
|
|
140
144
|
queued,
|
|
@@ -155,12 +159,12 @@ describe("retained results", () => {
|
|
|
155
159
|
},
|
|
156
160
|
}),
|
|
157
161
|
);
|
|
158
|
-
expect(resource(completed).get(
|
|
162
|
+
expect(resource(completed).get(C3)?.record.id).toBe("e14");
|
|
159
163
|
});
|
|
160
164
|
|
|
161
165
|
it("replaces a result with an execution interrupted before it started", () => {
|
|
162
166
|
const done = replay(runCells, replay(snapshot));
|
|
163
|
-
const result = resource(done).get(
|
|
167
|
+
const result = resource(done).get(C3)!;
|
|
164
168
|
const interrupted = {
|
|
165
169
|
...result.record,
|
|
166
170
|
id: "e14",
|
|
@@ -194,7 +198,7 @@ describe("retained results", () => {
|
|
|
194
198
|
],
|
|
195
199
|
done,
|
|
196
200
|
);
|
|
197
|
-
expect(resource(cancelled).get(
|
|
201
|
+
expect(resource(cancelled).get(C3)?.record.state).toHaveProperty(
|
|
198
202
|
"outcome",
|
|
199
203
|
{
|
|
200
204
|
kind: "cancelled",
|
|
@@ -205,11 +209,11 @@ describe("retained results", () => {
|
|
|
205
209
|
it("drops a cell deleted while its execution runs", () => {
|
|
206
210
|
const start = replay(runCells.slice(0, 5), replay(snapshot));
|
|
207
211
|
const deleted = reducer.reduce(start, removed("cell", "c3", "105"));
|
|
208
|
-
expect(resource(deleted).has(
|
|
212
|
+
expect(resource(deleted).has(C3)).toBe(false);
|
|
209
213
|
|
|
210
214
|
const finished = replay(runCells.slice(5), deleted);
|
|
211
|
-
expect(resource(finished).has(
|
|
212
|
-
expect(resource(finished).get(
|
|
215
|
+
expect(resource(finished).has(C3)).toBe(false);
|
|
216
|
+
expect(resource(finished).get(FIXTURE_CELL)?.record.id).toBe("e13");
|
|
213
217
|
});
|
|
214
218
|
|
|
215
219
|
it("ignores cells it has not seen and clears on reset", () => {
|
|
@@ -7,14 +7,14 @@ import type * as Protocol from "@marimo-team/client/protocol";
|
|
|
7
7
|
/** What an execution shows in place of a cell's output. */
|
|
8
8
|
export type Shown =
|
|
9
9
|
| { readonly kind: "output"; readonly media: Protocol.Media | null }
|
|
10
|
-
| Exclude<Protocol.
|
|
10
|
+
| Exclude<Protocol.ExecutionOutcomeOutput, { kind: "succeeded" }>;
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* How an execution ended when it did not succeed, else its output. Null
|
|
14
14
|
* until a queued or running execution sets its output.
|
|
15
15
|
*/
|
|
16
16
|
export function shown(result: {
|
|
17
|
-
readonly record: Protocol.
|
|
17
|
+
readonly record: Protocol.ExecutionOutput;
|
|
18
18
|
readonly output: Protocol.Output | null;
|
|
19
19
|
}): Shown | null {
|
|
20
20
|
const { state } = result.record;
|
|
@@ -10,9 +10,9 @@ import {
|
|
|
10
10
|
StreamStopped,
|
|
11
11
|
} from "@marimo-team/client";
|
|
12
12
|
import type {
|
|
13
|
-
Analysis,
|
|
13
|
+
AnalysisOutput as Analysis,
|
|
14
14
|
Attachment,
|
|
15
|
-
|
|
15
|
+
ExecutionOutput as HostExecution,
|
|
16
16
|
Output as HostOutput,
|
|
17
17
|
NotebookOutput,
|
|
18
18
|
Runtime,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
2
|
|
|
3
3
|
import type { NotebookResource } from "@marimo-team/client";
|
|
4
|
-
import type { Analysis } from "@marimo-team/client/protocol";
|
|
4
|
+
import type { AnalysisOutput as Analysis } from "@marimo-team/client/protocol";
|
|
5
5
|
|
|
6
6
|
export const analysis: NotebookResource<Analysis | null, "analysis"> = {
|
|
7
7
|
initial: null,
|
|
@@ -10,15 +10,15 @@ import type { NotebookResource } from "@marimo-team/client";
|
|
|
10
10
|
* version. Each cell in its order has a record in `cells`.
|
|
11
11
|
*/
|
|
12
12
|
export interface Document {
|
|
13
|
-
readonly revision: Protocol.
|
|
14
|
-
readonly cells: ReadonlyMap<Protocol.CellId, Protocol.
|
|
13
|
+
readonly revision: Protocol.DocumentOutput;
|
|
14
|
+
readonly cells: ReadonlyMap<Protocol.CellId, Protocol.CellOutput>;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
/** The records of a revision still being received. */
|
|
18
18
|
interface PendingDocument {
|
|
19
19
|
/** Null until the `document` event that closes the group arrives. */
|
|
20
|
-
readonly revision: Protocol.
|
|
21
|
-
readonly cells: ReadonlyMap<Protocol.CellId, Protocol.
|
|
20
|
+
readonly revision: Protocol.DocumentOutput | null;
|
|
21
|
+
readonly cells: ReadonlyMap<Protocol.CellId, Protocol.CellOutput>;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
/**
|
|
@@ -43,8 +43,8 @@ function pendingOf(state: DocumentState): PendingDocument {
|
|
|
43
43
|
|
|
44
44
|
/** Confirm a revision whose records are complete. */
|
|
45
45
|
function publish(
|
|
46
|
-
revision: Protocol.
|
|
47
|
-
cells: ReadonlyMap<Protocol.CellId, Protocol.
|
|
46
|
+
revision: Protocol.DocumentOutput,
|
|
47
|
+
cells: ReadonlyMap<Protocol.CellId, Protocol.CellOutput>,
|
|
48
48
|
): DocumentState {
|
|
49
49
|
const order = new Set(revision.order);
|
|
50
50
|
if (
|
|
@@ -73,11 +73,12 @@ export const document: NotebookResource<DocumentState, "cell" | "document"> = {
|
|
|
73
73
|
},
|
|
74
74
|
"cell.removed": (state, { data }) => {
|
|
75
75
|
const pending = pendingOf(state);
|
|
76
|
-
|
|
76
|
+
const { id } = data;
|
|
77
|
+
if (!pending.cells.has(id)) {
|
|
77
78
|
return state;
|
|
78
79
|
}
|
|
79
80
|
const cells = new Map(pending.cells);
|
|
80
|
-
cells.delete(
|
|
81
|
+
cells.delete(id);
|
|
81
82
|
return { ...state, pending: { ...pending, cells } };
|
|
82
83
|
},
|
|
83
84
|
document: (state, { data }, { phase }) => {
|
|
@@ -36,7 +36,7 @@ export interface Execution extends Result {
|
|
|
36
36
|
* stays for display while a new execution runs.
|
|
37
37
|
*/
|
|
38
38
|
export interface Executions {
|
|
39
|
-
readonly runs: ReadonlyMap<Protocol.RunId, Protocol.
|
|
39
|
+
readonly runs: ReadonlyMap<Protocol.RunId, Protocol.RunOutput>;
|
|
40
40
|
/** Every execution on the stream, scratch included. */
|
|
41
41
|
readonly executions: ReadonlyMap<Protocol.ExecutionId, Execution>;
|
|
42
42
|
/** The execution on the stream for each cell that has one. */
|
|
@@ -56,7 +56,7 @@ export interface RunFailure {
|
|
|
56
56
|
readonly completedAt: string;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
function hostFailure(run: Protocol.
|
|
59
|
+
function hostFailure(run: Protocol.RunOutput): RunFailure | undefined {
|
|
60
60
|
const { state } = run;
|
|
61
61
|
return state.status === "completed" &&
|
|
62
62
|
state.outcome.kind === "failed" &&
|
|
@@ -5,7 +5,7 @@ import { completedAt, shown, startedAt } from "../execution-state";
|
|
|
5
5
|
|
|
6
6
|
/** An execution record and its output, with the local revision of what it shows. */
|
|
7
7
|
export interface Result {
|
|
8
|
-
readonly record: Protocol.
|
|
8
|
+
readonly record: Protocol.ExecutionOutput;
|
|
9
9
|
/** The execution's output item, null until it sets one. */
|
|
10
10
|
readonly output: Protocol.Output | null;
|
|
11
11
|
/** Unchanged by lifecycle-only events. */
|
|
@@ -55,7 +55,7 @@ export function retainScratchResult(
|
|
|
55
55
|
if (record.cell_id !== null || shown(result) === null) {
|
|
56
56
|
return previous;
|
|
57
57
|
}
|
|
58
|
-
const time = (execution: Protocol.
|
|
58
|
+
const time = (execution: Protocol.ExecutionOutput) =>
|
|
59
59
|
Date.parse(
|
|
60
60
|
completedAt(execution) ?? startedAt(execution) ?? "1970-01-01T00:00:00Z",
|
|
61
61
|
);
|
|
@@ -17,7 +17,7 @@ import { activeNotebookReplicaAtom } from "@/core/session/active-notebook";
|
|
|
17
17
|
import { Deferred } from "@/utils/Deferred";
|
|
18
18
|
import { useNotebookDocumentSave } from "../document";
|
|
19
19
|
|
|
20
|
-
const confirmed: Protocol.
|
|
20
|
+
const confirmed: Protocol.DocumentOutput = {
|
|
21
21
|
notebook_id: "n1",
|
|
22
22
|
order: [],
|
|
23
23
|
app_config: {},
|
|
@@ -17,8 +17,8 @@ import { initialLayoutState, layoutStateAtom } from "../../layout/state";
|
|
|
17
17
|
import { documentVersionAtom, needsSaveAtom, savedLayoutAtom } from "../state";
|
|
18
18
|
|
|
19
19
|
function revision(
|
|
20
|
-
overrides: Partial<Protocol.
|
|
21
|
-
): Protocol.
|
|
20
|
+
overrides: Partial<Protocol.DocumentOutput> = {},
|
|
21
|
+
): Protocol.DocumentOutput {
|
|
22
22
|
return {
|
|
23
23
|
notebook_id: "nb",
|
|
24
24
|
order: [],
|
|
@@ -77,6 +77,8 @@ import { VirtualFileTracker } from "@/core/static/virtual-file-tracker";
|
|
|
77
77
|
import { useNotebookSession } from "../useNotebookSession";
|
|
78
78
|
import { type NotebookTransport, StreamStopped } from "@marimo-team/client";
|
|
79
79
|
|
|
80
|
+
const C1 = cellId("c1");
|
|
81
|
+
|
|
80
82
|
const SESSION_ID = generateSessionId();
|
|
81
83
|
|
|
82
84
|
/** One connection the fake transport opened. */
|
|
@@ -270,8 +272,8 @@ describe("useNotebookSession document model", () => {
|
|
|
270
272
|
fixtureMessages("notebook-events.sse").forEach(connection(fake).receive);
|
|
271
273
|
});
|
|
272
274
|
const model = result.current.documentModel;
|
|
273
|
-
const code = () => store.get(model.documentAtom)?.cells.get(
|
|
274
|
-
act(() => store.set(model.editAtom, (tx) => tx.setCode(
|
|
275
|
+
const code = () => store.get(model.documentAtom)?.cells.get(C1)?.code;
|
|
276
|
+
act(() => store.set(model.editAtom, (tx) => tx.setCode(C1, "local")));
|
|
275
277
|
expect(code()).toBe("local");
|
|
276
278
|
|
|
277
279
|
await act(async () => connection(fake).drop());
|
|
@@ -335,7 +337,9 @@ describe("useNotebookSession document model", () => {
|
|
|
335
337
|
});
|
|
336
338
|
|
|
337
339
|
const model = result.current.documentModel;
|
|
338
|
-
act(() =>
|
|
340
|
+
act(() =>
|
|
341
|
+
store.set(model.editAtom, (tx) => tx.setCode(cellId("c3"), "x = 42")),
|
|
342
|
+
);
|
|
339
343
|
notebook = store.get(notebookAtom);
|
|
340
344
|
expect(notebook.cellData[cellId("c3")].code).toBe("x = 42");
|
|
341
345
|
|
|
@@ -421,7 +425,8 @@ describe("useNotebookSession messages", () => {
|
|
|
421
425
|
expect(blocked()).toEqual(new Set(["b", "c"]));
|
|
422
426
|
|
|
423
427
|
const badge = () =>
|
|
424
|
-
cellExecutionView(store.get(cellExecutionInputsAtom), "b")
|
|
428
|
+
cellExecutionView(store.get(cellExecutionInputsAtom), cellId("b"))
|
|
429
|
+
.shownBlock;
|
|
425
430
|
expect(badge()).toBe("current");
|
|
426
431
|
publish(2);
|
|
427
432
|
expect(blocked().size).toBe(0);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
/** The editor session's replica, following its backend while mounted. */
|
|
4
4
|
|
|
5
|
-
import type { Execution } from "@marimo-team/client/protocol";
|
|
5
|
+
import type { ExecutionOutput as Execution } from "@marimo-team/client/protocol";
|
|
6
6
|
import { consoleObservers } from "../cells/execution-console";
|
|
7
7
|
import { useReducerActions } from "../cells/cells";
|
|
8
8
|
import { useStore } from "jotai";
|
|
@@ -412,7 +412,7 @@ export function useNotebookSession(opts: { sessionId: SessionId }) {
|
|
|
412
412
|
},
|
|
413
413
|
checkHealth: () => runtimeManager.reconcileFromHealth(),
|
|
414
414
|
onExecution: (record) => {
|
|
415
|
-
const cellId =
|
|
415
|
+
const cellId = record.cell_id ?? SCRATCH_CELL_ID;
|
|
416
416
|
const time = completedAt(record) ?? startedAt(record);
|
|
417
417
|
const timestamp =
|
|
418
418
|
time === null ? Date.now() / 1000 : Date.parse(time) / 1000;
|
|
@@ -108,7 +108,7 @@ describe("static notebook backend", () => {
|
|
|
108
108
|
it("delivers embedded results as completed executions after the document", async () => {
|
|
109
109
|
const source = snapshot();
|
|
110
110
|
const cell = source.cells[0];
|
|
111
|
-
const execution: Protocol.
|
|
111
|
+
const execution: Protocol.ExecutionOutput = {
|
|
112
112
|
id: "embedded:result",
|
|
113
113
|
run_id: "embedded:run",
|
|
114
114
|
runtime_id: "embedded",
|
|
@@ -10,14 +10,14 @@ import type { NotebookBackend } from "../notebook/replica";
|
|
|
10
10
|
export interface StaticNotebookSnapshot {
|
|
11
11
|
readonly notebook: Omit<Protocol.Notebook, "operations">;
|
|
12
12
|
readonly document: Protocol.Document;
|
|
13
|
-
readonly cells: readonly Protocol.
|
|
13
|
+
readonly cells: readonly Protocol.CellOutput[];
|
|
14
14
|
/** What the cells last produced, as completed executions and their outputs. */
|
|
15
15
|
readonly results: readonly StaticResult[];
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
/** A completed execution and the output it showed, if it set one. */
|
|
19
19
|
export interface StaticResult {
|
|
20
|
-
readonly execution: Protocol.
|
|
20
|
+
readonly execution: Protocol.ExecutionOutput;
|
|
21
21
|
readonly output: Protocol.Output | null;
|
|
22
22
|
}
|
|
23
23
|
|