@marimo-team/islands 0.25.3-dev460 → 0.25.3-dev462
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-D2YXxE_x.js → ErrorBoundary-BnH_3-iX.js} +1 -1
- package/dist/assets/__vite-browser-external-DxDOnHRB.js +1 -0
- package/dist/assets/{worker-DLJ9P24O.js → worker-D70Lo75A.js} +2 -2
- package/dist/{chat-ui-wWHUzOrx.js → chat-ui-Ci-OmyBN.js} +3 -3
- package/dist/{code-visibility-BPWgfZVa.js → code-visibility-9cVyvQDR.js} +2 -2
- package/dist/{common-_2RH91nQ.js → common-BFNJT3tG.js} +3 -3
- package/dist/{data-grid-overlay-editor-yh1wqygW.js → data-grid-overlay-editor-CQpih6Vr.js} +1 -1
- package/dist/{error-entries-3nytC8-z.js → error-entries-DMWlemUn.js} +471 -447
- package/dist/{feedback-button-Ctc_u2JY.js → feedback-button-D_xvjRAC.js} +3 -3
- package/dist/{glide-data-editor-DJikF-sp.js → glide-data-editor-ttA3lt4w.js} +3 -3
- package/dist/{globals-D8_0qvIC.js → globals-DgHMWwtp.js} +1 -1
- package/dist/{html-to-image-C3Nb90uM.js → html-to-image-CDlYnllr.js} +1 -1
- package/dist/main.js +8527 -8499
- package/dist/{number-overlay-editor-BUXorcPD.js → number-overlay-editor-VuSNPGWk.js} +1 -1
- package/dist/{process-output-BiLaCBoX.js → process-output-89n_C_pU.js} +2 -2
- package/dist/{reveal-component-B54ZJYk8.js → reveal-component-D63GuWKz.js} +2 -2
- package/package.json +1 -1
- package/src/__mocks__/executions.ts +61 -30
- package/src/components/editor/__tests__/output-persistence.test.tsx +1 -1
- package/src/components/editor/errors/__tests__/send-error-report-button.test.tsx +5 -1
- package/src/components/editor/renderers/grid-layout/grid-layout.tsx +1 -1
- package/src/core/cells/__tests__/clear-outputs.test.ts +18 -19
- package/src/core/cells/__tests__/harness.ts +4 -1
- package/src/core/cells/__tests__/layout.test.ts +4 -1
- package/src/core/cells/__tests__/runs.test.ts +2 -2
- package/src/core/cells/__tests__/session.test.ts +52 -45
- package/src/core/cells/__tests__/utils.test.ts +3 -3
- package/src/core/cells/execution-console.ts +7 -2
- package/src/core/cells/runs.ts +1 -1
- package/src/core/cells/session.ts +28 -18
- package/src/core/executions/__tests__/freshness.test.ts +11 -9
- package/src/core/executions/__tests__/hooks.test.tsx +8 -9
- package/src/core/executions/__tests__/output-lifecycle.test.ts +34 -35
- package/src/core/executions/__tests__/output.test.ts +28 -53
- package/src/core/executions/__tests__/select.test.ts +7 -7
- package/src/core/executions/atoms.ts +5 -5
- package/src/core/executions/output.ts +25 -28
- package/src/core/executions/select.ts +3 -11
- package/src/core/export/__tests__/hooks.test.ts +7 -9
- package/src/core/notebook/replica/__tests__/replica.test.ts +3 -3
- package/src/core/notebook/replica/__tests__/results.test.ts +2 -2
- package/src/core/notebook/replica/execution-state.ts +20 -12
- package/src/core/notebook/replica/index.ts +2 -1
- package/src/core/notebook/replica/replica.ts +25 -5
- package/src/core/notebook/replica/resources/executions.ts +41 -17
- package/src/core/notebook/replica/resources/results.ts +11 -9
- package/src/core/session/__tests__/useNotebookSession.hook.test.tsx +5 -9
- package/src/core/static/virtual-file-tracker.ts +5 -8
- package/src/core/transports/__tests__/server.test.ts +1 -1
- package/src/core/transports/__tests__/static.test.ts +17 -10
- package/src/core/transports/static.ts +14 -6
- package/src/stories/cell.stories.tsx +14 -14
- package/src/stories/layout/vertical/one-column.stories.tsx +2 -1
- package/dist/assets/__vite-browser-external-D2z_TiUO.js +0 -1
|
@@ -6,7 +6,10 @@ import type * as Protocol from "@marimo-team/client/protocol";
|
|
|
6
6
|
import type * as api from "@marimo-team/marimo-api";
|
|
7
7
|
import { mergeArray } from "@/utils/edit-distance";
|
|
8
8
|
import { Logger } from "@/utils/Logger";
|
|
9
|
-
import type {
|
|
9
|
+
import type {
|
|
10
|
+
StaticNotebookSnapshot,
|
|
11
|
+
StaticResult,
|
|
12
|
+
} from "../transports/static";
|
|
10
13
|
import { CellId, SETUP_CELL_ID } from "./ids";
|
|
11
14
|
import { DEFAULT_CELL_NAME } from "./names";
|
|
12
15
|
import { type CellRuntimeState, createCellRuntimeState } from "./types";
|
|
@@ -213,9 +216,11 @@ function normalizeTraceback(lines: readonly string[]): string | null {
|
|
|
213
216
|
function resultRecord(
|
|
214
217
|
cell: Protocol.Cell,
|
|
215
218
|
sessionCell: SessionCell | null | undefined,
|
|
216
|
-
):
|
|
219
|
+
): StaticResult | null {
|
|
217
220
|
const primary = primaryOutputOf(sessionCell);
|
|
221
|
+
const id = `${EMBEDDED}:${cell.id}:result`;
|
|
218
222
|
let outcome: Protocol.Outcome;
|
|
223
|
+
let output: Protocol.Output | null = null;
|
|
219
224
|
if (primary === undefined) {
|
|
220
225
|
return null;
|
|
221
226
|
} else if (primary.type === "error") {
|
|
@@ -238,9 +243,11 @@ function resultRecord(
|
|
|
238
243
|
};
|
|
239
244
|
} else if (primary.type === "data") {
|
|
240
245
|
const [mimetype, data] = Object.entries(primary.data)[0] ?? [];
|
|
241
|
-
outcome = {
|
|
242
|
-
|
|
243
|
-
|
|
246
|
+
outcome = { kind: "succeeded" };
|
|
247
|
+
output = {
|
|
248
|
+
id: `${id}:output`,
|
|
249
|
+
execution_id: id,
|
|
250
|
+
media:
|
|
244
251
|
mimetype === undefined
|
|
245
252
|
? null
|
|
246
253
|
: {
|
|
@@ -252,19 +259,22 @@ function resultRecord(
|
|
|
252
259
|
return null;
|
|
253
260
|
}
|
|
254
261
|
return {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
262
|
+
execution: {
|
|
263
|
+
id,
|
|
264
|
+
run_id: `${EMBEDDED}:run`,
|
|
265
|
+
runtime_id: EMBEDDED,
|
|
266
|
+
caused_by: null,
|
|
267
|
+
cell_id: cell.id,
|
|
268
|
+
code_fingerprint: cell.code_fingerprint,
|
|
269
|
+
state: {
|
|
270
|
+
status: "completed",
|
|
271
|
+
started_at: null,
|
|
272
|
+
completed_at: null,
|
|
273
|
+
outcome,
|
|
274
|
+
depends_on: {},
|
|
275
|
+
},
|
|
267
276
|
},
|
|
277
|
+
output,
|
|
268
278
|
};
|
|
269
279
|
}
|
|
270
280
|
|
|
@@ -342,7 +352,7 @@ export function readExport({
|
|
|
342
352
|
}
|
|
343
353
|
|
|
344
354
|
const cells: Protocol.Cell[] = [];
|
|
345
|
-
const results:
|
|
355
|
+
const results: StaticResult[] = [];
|
|
346
356
|
const cellRuntime: Record<CellId, CellRuntimeState> = {};
|
|
347
357
|
for (const cellId of cellIds) {
|
|
348
358
|
const cell = cellRecord(
|
|
@@ -35,12 +35,12 @@ function cell(
|
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
const
|
|
38
|
+
const SUCCEEDED: Protocol.Outcome = { kind: "succeeded" };
|
|
39
39
|
|
|
40
40
|
/** A completed state that read `depends_on`. */
|
|
41
41
|
function completed(
|
|
42
42
|
depends_on: Protocol.ExecutionCompleted["depends_on"] = {},
|
|
43
|
-
outcome: Protocol.Outcome =
|
|
43
|
+
outcome: Protocol.Outcome = SUCCEEDED,
|
|
44
44
|
): Protocol.ExecutionCompleted {
|
|
45
45
|
return {
|
|
46
46
|
status: "completed",
|
|
@@ -88,6 +88,7 @@ function execution(
|
|
|
88
88
|
): Execution {
|
|
89
89
|
return {
|
|
90
90
|
record: rec,
|
|
91
|
+
output: null,
|
|
91
92
|
outputVersion: 0,
|
|
92
93
|
items: new Map(),
|
|
93
94
|
variables: new Map(variables.map((v) => [v.id, v])),
|
|
@@ -120,7 +121,11 @@ function inputs({
|
|
|
120
121
|
);
|
|
121
122
|
for (const result of results) {
|
|
122
123
|
if (result.cell_id !== null) {
|
|
123
|
-
retained.set(result.cell_id, {
|
|
124
|
+
retained.set(result.cell_id, {
|
|
125
|
+
record: result,
|
|
126
|
+
output: null,
|
|
127
|
+
outputVersion: 0,
|
|
128
|
+
});
|
|
124
129
|
}
|
|
125
130
|
}
|
|
126
131
|
return {
|
|
@@ -393,7 +398,7 @@ describe("cellFreshness", () => {
|
|
|
393
398
|
started_at: "2026-10-01T09:22:00Z",
|
|
394
399
|
completed_at: "2026-10-01T09:22:01Z",
|
|
395
400
|
}
|
|
396
|
-
: { status, started_at: "2026-10-01T09:22:00Z"
|
|
401
|
+
: { status, started_at: "2026-10-01T09:22:00Z" },
|
|
397
402
|
});
|
|
398
403
|
const state = inputs({
|
|
399
404
|
cells: [c3, k7f2],
|
|
@@ -454,10 +459,7 @@ describe("cellFreshness", () => {
|
|
|
454
459
|
id: "e14",
|
|
455
460
|
cell_id: "c3",
|
|
456
461
|
code_fingerprint: "ffff000011112222",
|
|
457
|
-
state:
|
|
458
|
-
status === "running"
|
|
459
|
-
? { status, started_at: T0, value: null }
|
|
460
|
-
: { status },
|
|
462
|
+
state: status === "running" ? { status, started_at: T0 } : { status },
|
|
461
463
|
});
|
|
462
464
|
const state = inputs({
|
|
463
465
|
cells: [c3],
|
|
@@ -478,7 +480,7 @@ describe("cellFreshness", () => {
|
|
|
478
480
|
id: "e14",
|
|
479
481
|
cell_id: "c3",
|
|
480
482
|
code_fingerprint: "ffff000011112222",
|
|
481
|
-
state: { status: "running", started_at: T0
|
|
483
|
+
state: { status: "running", started_at: T0 },
|
|
482
484
|
});
|
|
483
485
|
const covered = inputs({
|
|
484
486
|
cells: [edited, k7f2],
|
|
@@ -4,7 +4,7 @@ import { act, renderHook } from "@testing-library/react";
|
|
|
4
4
|
import { createStore, Provider } from "jotai";
|
|
5
5
|
import type { ReactNode } from "react";
|
|
6
6
|
import { describe, expect, it, vi } from "vitest";
|
|
7
|
-
import { MockExecutions } from "@/__mocks__/executions";
|
|
7
|
+
import { type ExecutionEntries, MockExecutions } from "@/__mocks__/executions";
|
|
8
8
|
import { configOverridesAtom } from "@/core/config/config";
|
|
9
9
|
import { cellId } from "@/__tests__/branded";
|
|
10
10
|
import {
|
|
@@ -27,7 +27,7 @@ function ran(id: string) {
|
|
|
27
27
|
return { ...MockExecutions.completed(id), code_fingerprint: `${id}-hash` };
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
function setup(records:
|
|
30
|
+
function setup(records: ExecutionEntries) {
|
|
31
31
|
const store = createStore();
|
|
32
32
|
const document = documentOf();
|
|
33
33
|
const replica = MockExecutions.seed(store, records, null, document);
|
|
@@ -153,13 +153,12 @@ describe("input-change warnings", () => {
|
|
|
153
153
|
});
|
|
154
154
|
|
|
155
155
|
describe("useCellOutput", () => {
|
|
156
|
-
const shown = (id: string) =>
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
data: `${id} value
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
});
|
|
156
|
+
const shown = (id: string) =>
|
|
157
|
+
MockExecutions.shown(
|
|
158
|
+
id,
|
|
159
|
+
{ mimetype: "text/plain", data: `${id} value` },
|
|
160
|
+
{ code_fingerprint: `${id}-hash` },
|
|
161
|
+
);
|
|
163
162
|
|
|
164
163
|
it("reads the result's value and hides it once cleared, until a newer result", () => {
|
|
165
164
|
const { store, replica, wrapper } = setup([shown(C1)]);
|
|
@@ -27,11 +27,13 @@ import {
|
|
|
27
27
|
import { scratchOutputView } from "../output";
|
|
28
28
|
|
|
29
29
|
const C1 = cellId("c1");
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
const text = (data: string): Protocol.DisplayData => ({
|
|
31
|
+
mimetype: "text/plain",
|
|
32
|
+
data,
|
|
33
33
|
});
|
|
34
34
|
|
|
35
|
+
type Record = Protocol.Execution | Protocol.Output;
|
|
36
|
+
|
|
35
37
|
async function setup() {
|
|
36
38
|
interface Attempt {
|
|
37
39
|
message: Parameters<NotebookTransport>[1]["message"];
|
|
@@ -60,15 +62,23 @@ async function setup() {
|
|
|
60
62
|
attempt = await opened.promise;
|
|
61
63
|
};
|
|
62
64
|
let cursor = 100;
|
|
63
|
-
const emit = (
|
|
64
|
-
message(
|
|
65
|
+
const emit = (record: Record) =>
|
|
66
|
+
message(
|
|
67
|
+
"execution_id" in record
|
|
68
|
+
? { event: "output", id: String(++cursor), data: { output: record } }
|
|
69
|
+
: {
|
|
70
|
+
event: "execution",
|
|
71
|
+
id: String(++cursor),
|
|
72
|
+
data: { execution: record },
|
|
73
|
+
},
|
|
74
|
+
);
|
|
65
75
|
const remove = (execution: Protocol.Execution) =>
|
|
66
76
|
message({
|
|
67
77
|
event: "execution.removed",
|
|
68
78
|
id: String(++cursor),
|
|
69
79
|
data: { id: execution.id, time: MockExecutions.T1 },
|
|
70
80
|
});
|
|
71
|
-
const snapshot = (records:
|
|
81
|
+
const snapshot = (records: readonly Record[], notebookId = "n1") => {
|
|
72
82
|
message({ event: "reset", data: {} });
|
|
73
83
|
fixtureMessages("notebook-events.sse")
|
|
74
84
|
.filter(({ event }) => ["notebook", "document", "cell"].includes(event))
|
|
@@ -105,8 +115,8 @@ describe("output lifetime", () => {
|
|
|
105
115
|
vi.useRealTimers();
|
|
106
116
|
});
|
|
107
117
|
const { store, snapshot, message, reconnect } = await setup();
|
|
108
|
-
const result = MockExecutions.
|
|
109
|
-
snapshot(
|
|
118
|
+
const result = MockExecutions.shown(C1, text("A"));
|
|
119
|
+
snapshot(result);
|
|
110
120
|
const run: Protocol.Run = {
|
|
111
121
|
id: "missed",
|
|
112
122
|
notebook_id: "n1",
|
|
@@ -126,7 +136,7 @@ describe("output lifetime", () => {
|
|
|
126
136
|
await reconnect();
|
|
127
137
|
}
|
|
128
138
|
if (recovery !== "replay") {
|
|
129
|
-
snapshot(
|
|
139
|
+
snapshot(result);
|
|
130
140
|
} else {
|
|
131
141
|
message({ event: "ready", id: "120", data: {} });
|
|
132
142
|
}
|
|
@@ -148,19 +158,15 @@ describe("output lifetime", () => {
|
|
|
148
158
|
|
|
149
159
|
it("keeps a changed display visible after its execution retires", async () => {
|
|
150
160
|
const { store, replica, emit, remove, snapshot } = await setup();
|
|
151
|
-
const result = MockExecutions.
|
|
152
|
-
snapshot([result]);
|
|
161
|
+
const [result, output] = MockExecutions.shown(C1, text("A"));
|
|
162
|
+
snapshot([result, output]);
|
|
153
163
|
clearCellOutputs(store, [C1]);
|
|
154
164
|
expect(store.get(cellOutputAtom(C1))).toBeNull();
|
|
155
165
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
emit(shown("B"));
|
|
161
|
-
emit(shown("A"));
|
|
162
|
-
// No reader needs to observe the intermediate display for it to count.
|
|
163
|
-
snapshot([shown("A")]);
|
|
166
|
+
emit(MockExecutions.output(result, text("B")));
|
|
167
|
+
emit(output);
|
|
168
|
+
// No reader needs to observe the intermediate output for it to count.
|
|
169
|
+
snapshot([result, output]);
|
|
164
170
|
remove(result);
|
|
165
171
|
const running = MockExecutions.running(C1);
|
|
166
172
|
emit(running);
|
|
@@ -176,27 +182,24 @@ describe("output lifetime", () => {
|
|
|
176
182
|
const { store, emit, remove, snapshot } = await setup();
|
|
177
183
|
const running = MockExecutions.running(C1);
|
|
178
184
|
snapshot([running]);
|
|
179
|
-
emit(
|
|
185
|
+
emit(MockExecutions.output(running, text("A")));
|
|
180
186
|
clearCellOutputs(store, [C1]);
|
|
181
187
|
expect(store.get(cellOutputAtom(C1))).toBeNull();
|
|
182
188
|
|
|
183
|
-
const completed = {
|
|
184
|
-
...MockExecutions.completed(C1, value("A")),
|
|
185
|
-
id: running.id,
|
|
186
|
-
};
|
|
189
|
+
const completed = { ...MockExecutions.completed(C1), id: running.id };
|
|
187
190
|
emit(completed);
|
|
188
191
|
expect(store.get(cellOutputAtom(C1))).toBeNull();
|
|
189
192
|
remove(completed);
|
|
190
193
|
const next = MockExecutions.running(C1);
|
|
191
194
|
emit(next);
|
|
192
195
|
expect(store.get(cellOutputAtom(C1))).toBeNull();
|
|
193
|
-
emit(
|
|
196
|
+
emit(MockExecutions.output(next, text("A")));
|
|
194
197
|
expect(store.get(cellOutputAtom(C1))?.data).toBe("A");
|
|
195
198
|
});
|
|
196
199
|
it("keeps the scratch display after its execution expires", async () => {
|
|
197
200
|
const { store, replica, emit, remove, snapshot } = await setup();
|
|
198
|
-
const scratch = MockExecutions.
|
|
199
|
-
snapshot([scratch]);
|
|
201
|
+
const [scratch, shown] = MockExecutions.shown(null, text("scratch result"));
|
|
202
|
+
snapshot([scratch, shown]);
|
|
200
203
|
const before = scratchOutputView(store.get(replica.executionsAtom));
|
|
201
204
|
expect(before?.data).toBe("scratch result");
|
|
202
205
|
remove(scratch);
|
|
@@ -213,16 +216,12 @@ describe("output lifetime", () => {
|
|
|
213
216
|
const next = MockExecutions.execution(null, {
|
|
214
217
|
status: "running",
|
|
215
218
|
started_at,
|
|
216
|
-
value: null,
|
|
217
219
|
});
|
|
218
220
|
emit(next);
|
|
219
221
|
expect(scratchOutputView(store.get(replica.executionsAtom))).toEqual(
|
|
220
222
|
before,
|
|
221
223
|
);
|
|
222
|
-
emit(
|
|
223
|
-
...next,
|
|
224
|
-
state: { status: "running", started_at, value: value("next") },
|
|
225
|
-
});
|
|
224
|
+
emit(MockExecutions.output(next, text("next")));
|
|
226
225
|
expect(scratchOutputView(store.get(replica.executionsAtom))?.data).toBe(
|
|
227
226
|
"next",
|
|
228
227
|
);
|
|
@@ -232,7 +231,7 @@ describe("output lifetime", () => {
|
|
|
232
231
|
status: "completed",
|
|
233
232
|
started_at,
|
|
234
233
|
completed_at: "2026-10-01T09:22:01Z",
|
|
235
|
-
outcome:
|
|
234
|
+
outcome: { kind: "succeeded" },
|
|
236
235
|
depends_on: {},
|
|
237
236
|
},
|
|
238
237
|
});
|
|
@@ -246,12 +245,12 @@ describe("output lifetime", () => {
|
|
|
246
245
|
|
|
247
246
|
it("keeps scratch output cleared when an empty execution expires", async () => {
|
|
248
247
|
const { store, replica, emit, remove, snapshot } = await setup();
|
|
249
|
-
snapshot(
|
|
248
|
+
snapshot(MockExecutions.shown(null, text("old")));
|
|
250
249
|
const cleared = MockExecutions.execution(null, {
|
|
251
250
|
status: "completed",
|
|
252
251
|
started_at: MockExecutions.T0,
|
|
253
252
|
completed_at: "2026-10-01T09:22:00Z",
|
|
254
|
-
outcome: { kind: "
|
|
253
|
+
outcome: { kind: "succeeded" },
|
|
255
254
|
depends_on: {},
|
|
256
255
|
});
|
|
257
256
|
emit(cleared);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import type * as Protocol from "@marimo-team/client/protocol";
|
|
4
4
|
import { describe, expect, it } from "vitest";
|
|
5
|
-
import { MockExecutions } from "@/__mocks__/executions";
|
|
5
|
+
import { type ExecutionEntries, MockExecutions } from "@/__mocks__/executions";
|
|
6
6
|
import { cellId } from "@/__tests__/branded";
|
|
7
7
|
import { cell } from "@/core/notebook/document/__tests__/fixtures";
|
|
8
8
|
import {
|
|
@@ -34,7 +34,7 @@ function hostError(overrides: Partial<Protocol.Error>): Protocol.Error {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
function inputs(
|
|
37
|
-
records:
|
|
37
|
+
records: ExecutionEntries,
|
|
38
38
|
cleared: CellOutputInputs["cleared"] = new Map(),
|
|
39
39
|
cells: CellOutputInputs["cells"] = new Map(),
|
|
40
40
|
): CellOutputInputs {
|
|
@@ -43,11 +43,8 @@ function inputs(
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
describe("cellOutputView", () => {
|
|
46
|
-
it("shows a
|
|
47
|
-
const view = cellOutputView(
|
|
48
|
-
inputs([MockExecutions.completed(C1, { kind: "value", display: HTML })]),
|
|
49
|
-
C1,
|
|
50
|
-
);
|
|
46
|
+
it("shows a succeeded execution's output", () => {
|
|
47
|
+
const view = cellOutputView(inputs([MockExecutions.shown(C1, HTML)]), C1);
|
|
51
48
|
expect(view).toMatchObject({
|
|
52
49
|
channel: "output",
|
|
53
50
|
mimetype: "text/html",
|
|
@@ -56,7 +53,7 @@ describe("cellOutputView", () => {
|
|
|
56
53
|
expect(view?.timestamp).toBe(Date.parse(MockExecutions.T1) / 1000);
|
|
57
54
|
});
|
|
58
55
|
|
|
59
|
-
it("shows nothing for
|
|
56
|
+
it("shows nothing for an execution without an output, or a cell without a result", () => {
|
|
60
57
|
const state = inputs([MockExecutions.completed(C1)]);
|
|
61
58
|
expect(cellOutputView(state, C1)).toBeNull();
|
|
62
59
|
expect(cellOutputView(state, C2)).toBeNull();
|
|
@@ -136,32 +133,22 @@ describe("cellOutputView", () => {
|
|
|
136
133
|
});
|
|
137
134
|
|
|
138
135
|
it("prefers the running execution's value so far over the retained result", () => {
|
|
139
|
-
const previous = MockExecutions.
|
|
140
|
-
kind: "value",
|
|
141
|
-
display: HTML,
|
|
142
|
-
});
|
|
136
|
+
const previous = MockExecutions.shown(C1, HTML);
|
|
143
137
|
const running = MockExecutions.running(C1);
|
|
144
138
|
const silent = inputs([previous, running]);
|
|
145
139
|
expect(cellOutputView(silent, C1)?.data).toBe("<b>1</b>");
|
|
146
140
|
|
|
147
|
-
const
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
display: { mimetype: "text/plain", data: "so far" },
|
|
153
|
-
}),
|
|
154
|
-
id: running.id,
|
|
155
|
-
},
|
|
156
|
-
]);
|
|
141
|
+
const soFar = MockExecutions.output(running, {
|
|
142
|
+
mimetype: "text/plain",
|
|
143
|
+
data: "so far",
|
|
144
|
+
});
|
|
145
|
+
const showing = inputs([previous, running, soFar]);
|
|
157
146
|
expect(cellOutputView(showing, C1)?.data).toBe("so far");
|
|
158
147
|
|
|
159
148
|
const clearedWhileRunning = inputs([
|
|
160
149
|
previous,
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
id: running.id,
|
|
164
|
-
},
|
|
150
|
+
running,
|
|
151
|
+
MockExecutions.output(running, null),
|
|
165
152
|
]);
|
|
166
153
|
expect(cellOutputView(clearedWhileRunning, C1)).toBeNull();
|
|
167
154
|
});
|
|
@@ -218,33 +205,22 @@ describe("cellOutputView", () => {
|
|
|
218
205
|
});
|
|
219
206
|
|
|
220
207
|
it("hides a cleared result until a newer one lands", () => {
|
|
221
|
-
const first = MockExecutions.
|
|
222
|
-
|
|
223
|
-
display: HTML,
|
|
224
|
-
});
|
|
225
|
-
const cleared = new Map([[C1, { execution: first.id, version: 0 }]]);
|
|
208
|
+
const first = MockExecutions.shown(C1, HTML);
|
|
209
|
+
const cleared = new Map([[C1, { execution: first[0].id, version: 0 }]]);
|
|
226
210
|
expect(cellOutputView(inputs([first], cleared), C1)).toBeNull();
|
|
227
211
|
|
|
228
|
-
const second = MockExecutions.
|
|
229
|
-
kind: "value",
|
|
230
|
-
display: HTML,
|
|
231
|
-
});
|
|
212
|
+
const second = MockExecutions.shown(C1, HTML);
|
|
232
213
|
expect(cellOutputView(inputs([second], cleared), C1)).not.toBeNull();
|
|
233
214
|
});
|
|
234
215
|
|
|
235
216
|
it("keeps a cleared running display hidden when it completes", () => {
|
|
236
|
-
const running = MockExecutions.running(C1
|
|
237
|
-
|
|
238
|
-
display: HTML,
|
|
239
|
-
});
|
|
217
|
+
const running = MockExecutions.running(C1);
|
|
218
|
+
const output = MockExecutions.output(running, HTML);
|
|
240
219
|
const cleared = new Map([[C1, { execution: running.id, version: 0 }]]);
|
|
241
|
-
expect(cellOutputView(inputs([running], cleared), C1)).toBeNull();
|
|
220
|
+
expect(cellOutputView(inputs([running, output], cleared), C1)).toBeNull();
|
|
242
221
|
|
|
243
|
-
const finished = {
|
|
244
|
-
|
|
245
|
-
id: running.id,
|
|
246
|
-
};
|
|
247
|
-
expect(cellOutputView(inputs([finished], cleared), C1)).toBeNull();
|
|
222
|
+
const finished = { ...MockExecutions.completed(C1), id: running.id };
|
|
223
|
+
expect(cellOutputView(inputs([finished, output], cleared), C1)).toBeNull();
|
|
248
224
|
});
|
|
249
225
|
});
|
|
250
226
|
|
|
@@ -304,14 +280,14 @@ describe("scratchOutputView", () => {
|
|
|
304
280
|
const running = MockExecutions.execution(null, {
|
|
305
281
|
status: "running",
|
|
306
282
|
started_at: MockExecutions.T1,
|
|
307
|
-
value: {
|
|
308
|
-
kind: "value",
|
|
309
|
-
display: { mimetype: "text/plain", data: "so far" },
|
|
310
|
-
},
|
|
311
283
|
});
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
284
|
+
const soFar = MockExecutions.output(running, {
|
|
285
|
+
mimetype: "text/plain",
|
|
286
|
+
data: "so far",
|
|
287
|
+
});
|
|
288
|
+
expect(
|
|
289
|
+
scratchOutputView(inputs([done, running, soFar]).executions)?.data,
|
|
290
|
+
).toBe("so far");
|
|
315
291
|
});
|
|
316
292
|
|
|
317
293
|
it("keeps the previous output until a newer run has one to show", () => {
|
|
@@ -319,7 +295,6 @@ describe("scratchOutputView", () => {
|
|
|
319
295
|
const silent = MockExecutions.execution(null, {
|
|
320
296
|
status: "running",
|
|
321
297
|
started_at: LATER,
|
|
322
|
-
value: null,
|
|
323
298
|
});
|
|
324
299
|
expect(scratchOutputView(inputs([done, silent]).executions)?.data).toBe(
|
|
325
300
|
"<b>1</b>",
|
|
@@ -21,7 +21,6 @@ const QUEUED: Protocol.ExecutionState = { status: "queued" };
|
|
|
21
21
|
const RUNNING: Protocol.ExecutionState = {
|
|
22
22
|
status: "running",
|
|
23
23
|
started_at: T0,
|
|
24
|
-
value: null,
|
|
25
24
|
};
|
|
26
25
|
|
|
27
26
|
function record(
|
|
@@ -37,7 +36,7 @@ function record(
|
|
|
37
36
|
status: "completed",
|
|
38
37
|
started_at: T0,
|
|
39
38
|
completed_at: T1,
|
|
40
|
-
outcome: { kind: "
|
|
39
|
+
outcome: { kind: "succeeded" },
|
|
41
40
|
depends_on: {},
|
|
42
41
|
},
|
|
43
42
|
...overrides,
|
|
@@ -47,6 +46,7 @@ function record(
|
|
|
47
46
|
function execution(overrides: Partial<Protocol.Execution> & { id: string }) {
|
|
48
47
|
return {
|
|
49
48
|
record: record(overrides),
|
|
49
|
+
output: null,
|
|
50
50
|
outputVersion: 0,
|
|
51
51
|
items: new Map(),
|
|
52
52
|
variables: new Map(),
|
|
@@ -143,7 +143,7 @@ describe("cellExecutionView", () => {
|
|
|
143
143
|
executions: [
|
|
144
144
|
execution({
|
|
145
145
|
id: "e1",
|
|
146
|
-
state: { status: "running", started_at: T2
|
|
146
|
+
state: { status: "running", started_at: T2 },
|
|
147
147
|
}),
|
|
148
148
|
],
|
|
149
149
|
results: new Map([["c1", execution({ id: "e0" })]]),
|
|
@@ -200,11 +200,11 @@ describe("cellExecutionView", () => {
|
|
|
200
200
|
}),
|
|
201
201
|
"c1",
|
|
202
202
|
);
|
|
203
|
-
const value = ended({ kind: "
|
|
203
|
+
const value = ended({ kind: "succeeded" });
|
|
204
204
|
expect(value).toEqual({
|
|
205
205
|
status: "idle",
|
|
206
206
|
blocked: false,
|
|
207
|
-
outcome: "
|
|
207
|
+
outcome: "succeeded",
|
|
208
208
|
startedAt: Date.parse(T0),
|
|
209
209
|
duration: 1500,
|
|
210
210
|
live: true,
|
|
@@ -276,7 +276,7 @@ describe("cellExecutionView", () => {
|
|
|
276
276
|
results: new Map([["c1", execution({ id: "e2", run_id: "run-2" })]]),
|
|
277
277
|
});
|
|
278
278
|
expect(cellExecutionView(done, "c1").status).toBe("idle");
|
|
279
|
-
expect(cellExecutionView(done, "c1").outcome).toBe("
|
|
279
|
+
expect(cellExecutionView(done, "c1").outcome).toBe("succeeded");
|
|
280
280
|
expect(cellExecutionView(done, "c2").status).toBe("queued");
|
|
281
281
|
|
|
282
282
|
// The stream let the execution go while its run goes on with other cells.
|
|
@@ -325,7 +325,7 @@ describe("cellExecutionView", () => {
|
|
|
325
325
|
);
|
|
326
326
|
expect(view.status).toBe("idle");
|
|
327
327
|
expect(view.blocked).toBe(true);
|
|
328
|
-
expect(view.outcome).toBe("
|
|
328
|
+
expect(view.outcome).toBe("succeeded");
|
|
329
329
|
});
|
|
330
330
|
});
|
|
331
331
|
|
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
type CellExecutionInputs,
|
|
30
30
|
queuedOrRunningCount,
|
|
31
31
|
} from "./select";
|
|
32
|
-
import {
|
|
32
|
+
import { shown } from "@/core/notebook/replica";
|
|
33
33
|
|
|
34
34
|
type Store = ReturnType<typeof createStore>;
|
|
35
35
|
|
|
@@ -237,11 +237,11 @@ export function clearCellOutputs(
|
|
|
237
237
|
const inputs = store.get(cellOutputInputsAtom);
|
|
238
238
|
const next = new Map(inputs.cleared);
|
|
239
239
|
for (const cellId of cellIds) {
|
|
240
|
-
const
|
|
241
|
-
if (
|
|
240
|
+
const showing = shownExecution(inputs, cellId);
|
|
241
|
+
if (showing != null && shown(showing) !== null) {
|
|
242
242
|
next.set(cellId, {
|
|
243
|
-
execution:
|
|
244
|
-
version:
|
|
243
|
+
execution: showing.record.id,
|
|
244
|
+
version: showing.outputVersion,
|
|
245
245
|
});
|
|
246
246
|
}
|
|
247
247
|
}
|