@marimo-team/islands 0.25.3-dev462 → 0.25.3-dev464
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-BnH_3-iX.js → ErrorBoundary-BUp3s8bW.js} +1 -1
- package/dist/assets/__vite-browser-external-DoIBUY2I.js +1 -0
- package/dist/assets/{worker-D70Lo75A.js → worker-DFvnFhLF.js} +2 -2
- package/dist/{chat-ui-Ci-OmyBN.js → chat-ui-DFoH-uxc.js} +3 -3
- package/dist/{code-visibility-9cVyvQDR.js → code-visibility-JyOG3ytM.js} +2 -2
- package/dist/{common-BFNJT3tG.js → common-DsPeHITU.js} +4 -4
- package/dist/{data-grid-overlay-editor-CQpih6Vr.js → data-grid-overlay-editor-D6RpA9b2.js} +1 -1
- package/dist/{error-entries-DMWlemUn.js → error-entries-C9OKfJKe.js} +283 -279
- package/dist/{feedback-button-D_xvjRAC.js → feedback-button-w5jJOd6o.js} +3 -3
- package/dist/{glide-data-editor-ttA3lt4w.js → glide-data-editor-lWcwB0Si.js} +3 -3
- package/dist/{globals-DgHMWwtp.js → globals-BFICoaLo.js} +1 -1
- package/dist/{html-to-image-CDlYnllr.js → html-to-image-BiWLL4Tu.js} +1 -1
- package/dist/main.js +163 -176
- package/dist/{number-overlay-editor-VuSNPGWk.js → number-overlay-editor-BDYmg8YM.js} +1 -1
- package/dist/{process-output-89n_C_pU.js → process-output-ClyiXL-f.js} +2 -2
- package/dist/{reveal-component-D63GuWKz.js → reveal-component-B63xZtLQ.js} +2 -2
- package/package.json +1 -1
- package/src/__mocks__/executions.ts +2 -2
- package/src/__mocks__/notebook.ts +6 -3
- package/src/components/dependency-graph/minimap-content.tsx +1 -1
- package/src/components/editor/notebook-cell.tsx +6 -6
- package/src/components/editor/renderers/vertical-layout/vertical-layout.tsx +2 -2
- package/src/components/slides/slide-cell-view.tsx +2 -2
- package/src/core/ai/context/providers/__tests__/error.test.ts +0 -4
- package/src/core/cells/__tests__/cell.test.ts +8 -8
- package/src/core/cells/__tests__/runs.test.ts +1 -1
- package/src/core/cells/__tests__/session.test.ts +2 -2
- package/src/core/cells/__tests__/utils.test.ts +2 -2
- package/src/core/cells/cell.ts +2 -2
- package/src/core/cells/execution-console.ts +18 -13
- package/src/core/cells/runs.ts +10 -2
- package/src/core/cells/session.ts +1 -1
- package/src/core/cells/utils.ts +2 -2
- package/src/core/executions/__tests__/atoms.test.ts +1 -1
- package/src/core/executions/__tests__/interrupt.test.ts +1 -1
- package/src/core/executions/__tests__/output.test.ts +26 -5
- package/src/core/executions/__tests__/select.test.ts +4 -4
- package/src/core/executions/output.ts +16 -4
- package/src/core/islands/__tests__/bridge.test.ts +8 -1
- package/src/core/islands/bridge.ts +7 -3
- package/src/core/notebook/replica/__tests__/executions.test.ts +65 -10
- package/src/core/notebook/replica/__tests__/replica.test.ts +3 -1
- package/src/core/notebook/replica/__tests__/results.test.ts +2 -2
- package/src/core/notebook/replica/replica.ts +2 -8
- package/src/core/notebook/replica/resources/executions.ts +28 -6
- package/src/core/session/__tests__/backend.test.ts +1 -1
- package/src/core/session/__tests__/useNotebookSession.hook.test.tsx +8 -11
- package/src/core/session/useNotebookSession.tsx +1 -1
- package/src/stories/layout/vertical/one-column.stories.tsx +1 -2
- package/dist/assets/__vite-browser-external-DxDOnHRB.js +0 -1
|
@@ -52,7 +52,7 @@ describe("executions resource", () => {
|
|
|
52
52
|
const done = resource(replay(snapshot));
|
|
53
53
|
expect(done.executions.get("e7")?.record.state.status).toBe("completed");
|
|
54
54
|
expect(done.runs.get("run-scratch")?.state).toMatchObject({
|
|
55
|
-
outcome: "succeeded",
|
|
55
|
+
outcome: { kind: "succeeded" },
|
|
56
56
|
});
|
|
57
57
|
const released = reducer.reduce(
|
|
58
58
|
replay(snapshot),
|
|
@@ -80,7 +80,7 @@ describe("executions resource", () => {
|
|
|
80
80
|
},
|
|
81
81
|
);
|
|
82
82
|
expect(resource(done).runs.get("run-cells")?.state).toMatchObject({
|
|
83
|
-
outcome: "succeeded",
|
|
83
|
+
outcome: { kind: "succeeded" },
|
|
84
84
|
});
|
|
85
85
|
|
|
86
86
|
const retired = replay(retire("e12", "e12-x"), done);
|
|
@@ -118,19 +118,21 @@ describe("executions resource", () => {
|
|
|
118
118
|
id: "o9",
|
|
119
119
|
execution_id: "e12",
|
|
120
120
|
seq: 0,
|
|
121
|
-
|
|
122
|
-
text: "late\n",
|
|
121
|
+
content: { kind: "text", stream: "stdout", text: "late\n" },
|
|
123
122
|
};
|
|
124
123
|
const shown = {
|
|
125
124
|
id: "d1",
|
|
126
125
|
execution_id: "e12",
|
|
127
126
|
seq: 1,
|
|
128
|
-
content: {
|
|
127
|
+
content: {
|
|
128
|
+
kind: "media",
|
|
129
|
+
media: { mimetype: "text/plain", data: "figure" },
|
|
130
|
+
},
|
|
129
131
|
};
|
|
130
132
|
const added = replay(
|
|
131
133
|
[
|
|
132
134
|
event({ event: "console", id: "111", data: { console: late } }),
|
|
133
|
-
event({ event: "
|
|
135
|
+
event({ event: "console", id: "112", data: { console: shown } }),
|
|
134
136
|
],
|
|
135
137
|
done,
|
|
136
138
|
);
|
|
@@ -138,7 +140,7 @@ describe("executions resource", () => {
|
|
|
138
140
|
|
|
139
141
|
const cleared = replay(
|
|
140
142
|
[
|
|
141
|
-
removed("
|
|
143
|
+
removed("console", "d1", "113"),
|
|
142
144
|
removed("console", "o9", "114"),
|
|
143
145
|
removed("variable", "e12-x", "115"),
|
|
144
146
|
],
|
|
@@ -171,7 +173,7 @@ describe("executions resource", () => {
|
|
|
171
173
|
const gone = resource(replay(inputs, start));
|
|
172
174
|
expect(gone.executions.has("e-input")).toBe(false);
|
|
173
175
|
expect(gone.runs.get("run-input")?.state).toMatchObject({
|
|
174
|
-
outcome: "
|
|
176
|
+
outcome: { kind: "cancelled" },
|
|
175
177
|
});
|
|
176
178
|
|
|
177
179
|
const orphan = reducer.reduce(
|
|
@@ -184,8 +186,7 @@ describe("executions resource", () => {
|
|
|
184
186
|
id: "o-orphan",
|
|
185
187
|
execution_id: "nope",
|
|
186
188
|
seq: 0,
|
|
187
|
-
|
|
188
|
-
text: "",
|
|
189
|
+
content: { kind: "text", stream: "stdout", text: "" },
|
|
189
190
|
},
|
|
190
191
|
},
|
|
191
192
|
}),
|
|
@@ -207,4 +208,58 @@ describe("executions resource", () => {
|
|
|
207
208
|
const reset = reducer.reduce(done, { event: "reset", data: {} });
|
|
208
209
|
expect(resource(reset)).toBe(executions.initial);
|
|
209
210
|
});
|
|
211
|
+
|
|
212
|
+
it("remembers why the latest scratch run failed until a newer one arrives", () => {
|
|
213
|
+
const run = (
|
|
214
|
+
id: string,
|
|
215
|
+
origin: Protocol.RunOrigin,
|
|
216
|
+
state: Protocol.RunState,
|
|
217
|
+
cursor: string,
|
|
218
|
+
) =>
|
|
219
|
+
event({
|
|
220
|
+
event: "run",
|
|
221
|
+
id: cursor,
|
|
222
|
+
data: {
|
|
223
|
+
run: { id, notebook_id: "n1", runtime_id: "r1", origin, state },
|
|
224
|
+
time,
|
|
225
|
+
},
|
|
226
|
+
});
|
|
227
|
+
const code: Protocol.RunOrigin = { kind: "code", code: "1" };
|
|
228
|
+
const failed: Protocol.RunState = {
|
|
229
|
+
status: "completed",
|
|
230
|
+
started_at: null,
|
|
231
|
+
completed_at: time,
|
|
232
|
+
outcome: { kind: "failed", message: "Kernel channel closed" },
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
const afterFailure = replay(
|
|
236
|
+
[run("run-9", code, failed, "200")],
|
|
237
|
+
replay(snapshot),
|
|
238
|
+
);
|
|
239
|
+
expect(resource(afterFailure).scratchFailure).toEqual({
|
|
240
|
+
runId: "run-9",
|
|
241
|
+
message: "Kernel channel closed",
|
|
242
|
+
completedAt: time,
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
// Cell runs say nothing about the scratchpad.
|
|
246
|
+
const afterCells = replay(
|
|
247
|
+
[
|
|
248
|
+
run(
|
|
249
|
+
"run-10",
|
|
250
|
+
{ kind: "cells", cell_ids: ["c1"] },
|
|
251
|
+
{ status: "queued" },
|
|
252
|
+
"201",
|
|
253
|
+
),
|
|
254
|
+
],
|
|
255
|
+
afterFailure,
|
|
256
|
+
);
|
|
257
|
+
expect(resource(afterCells).scratchFailure?.runId).toBe("run-9");
|
|
258
|
+
|
|
259
|
+
const afterNext = replay(
|
|
260
|
+
[run("run-11", code, { status: "queued" }, "202")],
|
|
261
|
+
afterCells,
|
|
262
|
+
);
|
|
263
|
+
expect(resource(afterNext).scratchFailure).toBeUndefined();
|
|
264
|
+
});
|
|
210
265
|
});
|
|
@@ -161,7 +161,9 @@ describe("NotebookReplica lifetime", () => {
|
|
|
161
161
|
const events = fixtureEvents("notebook-events.sse");
|
|
162
162
|
events.forEach(receive);
|
|
163
163
|
const previous = store.get(client.executionsAtom).scratchConsole;
|
|
164
|
-
expect(previous?.items.get("o3")).toMatchObject({
|
|
164
|
+
expect(previous?.items.get("o3")).toMatchObject({
|
|
165
|
+
content: { kind: "text", text: "2\n" },
|
|
166
|
+
});
|
|
165
167
|
|
|
166
168
|
receive({ event: "reset", data: {} });
|
|
167
169
|
for (const event of events) {
|
|
@@ -168,7 +168,7 @@ describe("retained results", () => {
|
|
|
168
168
|
status: "completed",
|
|
169
169
|
started_at: null,
|
|
170
170
|
completed_at: time,
|
|
171
|
-
outcome: { kind: "
|
|
171
|
+
outcome: { kind: "cancelled" },
|
|
172
172
|
depends_on: {},
|
|
173
173
|
},
|
|
174
174
|
};
|
|
@@ -196,7 +196,7 @@ describe("retained results", () => {
|
|
|
196
196
|
expect(resource(cancelled).get("c3")?.record.state).toHaveProperty(
|
|
197
197
|
"outcome",
|
|
198
198
|
{
|
|
199
|
-
kind: "
|
|
199
|
+
kind: "cancelled",
|
|
200
200
|
},
|
|
201
201
|
);
|
|
202
202
|
});
|
|
@@ -49,7 +49,6 @@ export const EDITOR_EVENT_TYPES = [
|
|
|
49
49
|
"run",
|
|
50
50
|
"execution",
|
|
51
51
|
"console",
|
|
52
|
-
"display",
|
|
53
52
|
"input",
|
|
54
53
|
"output",
|
|
55
54
|
"variable",
|
|
@@ -412,7 +411,7 @@ export function createNotebookReplica(
|
|
|
412
411
|
}
|
|
413
412
|
if (onItem) {
|
|
414
413
|
for (const item of execution.items.values()) {
|
|
415
|
-
if (item.kind === "
|
|
414
|
+
if (item.kind === "console" && item.content.kind === "media") {
|
|
416
415
|
onItem(execution.record, item, false);
|
|
417
416
|
}
|
|
418
417
|
}
|
|
@@ -454,14 +453,9 @@ export function createNotebookReplica(
|
|
|
454
453
|
return;
|
|
455
454
|
}
|
|
456
455
|
case "console":
|
|
457
|
-
case "display":
|
|
458
456
|
case "input": {
|
|
459
457
|
const item =
|
|
460
|
-
event.event === "console"
|
|
461
|
-
? event.data.console
|
|
462
|
-
: event.event === "display"
|
|
463
|
-
? event.data.display
|
|
464
|
-
: event.data.input;
|
|
458
|
+
event.event === "console" ? event.data.console : event.data.input;
|
|
465
459
|
const execution = executions.get(item.execution_id);
|
|
466
460
|
if (execution && onItem) {
|
|
467
461
|
const received = execution.items.get(item.id);
|
|
@@ -10,10 +10,9 @@ import {
|
|
|
10
10
|
} from "./results";
|
|
11
11
|
import { shown, startedAt } from "../execution-state";
|
|
12
12
|
|
|
13
|
-
/** A console
|
|
13
|
+
/** A console entry or input an execution produced, tagged by kind. */
|
|
14
14
|
type ProducedItem =
|
|
15
15
|
| (Protocol.Console & { readonly kind: "console" })
|
|
16
|
-
| (Protocol.Display & { readonly kind: "display" })
|
|
17
16
|
| (Protocol.Input & { readonly kind: "input" });
|
|
18
17
|
|
|
19
18
|
/** Time the host published the item, when included in a live event. */
|
|
@@ -46,6 +45,28 @@ export interface Executions {
|
|
|
46
45
|
readonly scratch: Result | null;
|
|
47
46
|
/** The latest scratch execution to start, including one that printed nothing. */
|
|
48
47
|
readonly scratchConsole?: Execution;
|
|
48
|
+
/** The latest scratch run, if the host could not finish it and says why. */
|
|
49
|
+
readonly scratchFailure?: RunFailure;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** A run the host could not finish, with its reason. */
|
|
53
|
+
export interface RunFailure {
|
|
54
|
+
readonly runId: Protocol.RunId;
|
|
55
|
+
readonly message: string;
|
|
56
|
+
readonly completedAt: string;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function hostFailure(run: Protocol.Run): RunFailure | undefined {
|
|
60
|
+
const { state } = run;
|
|
61
|
+
return state.status === "completed" &&
|
|
62
|
+
state.outcome.kind === "failed" &&
|
|
63
|
+
state.outcome.message !== null
|
|
64
|
+
? {
|
|
65
|
+
runId: run.id,
|
|
66
|
+
message: state.outcome.message,
|
|
67
|
+
completedAt: state.completed_at,
|
|
68
|
+
}
|
|
69
|
+
: undefined;
|
|
49
70
|
}
|
|
50
71
|
|
|
51
72
|
type Kind =
|
|
@@ -54,7 +75,6 @@ type Kind =
|
|
|
54
75
|
| "execution"
|
|
55
76
|
| "output"
|
|
56
77
|
| "console"
|
|
57
|
-
| "display"
|
|
58
78
|
| "input"
|
|
59
79
|
| "variable";
|
|
60
80
|
|
|
@@ -277,6 +297,11 @@ export const executions: NotebookResource<Executions, Kind> = {
|
|
|
277
297
|
run: (state, { data }) => ({
|
|
278
298
|
...state,
|
|
279
299
|
runs: new Map(state.runs).set(data.run.id, data.run),
|
|
300
|
+
// A newer scratch run replaces what the last one reported.
|
|
301
|
+
scratchFailure:
|
|
302
|
+
data.run.origin.kind === "code"
|
|
303
|
+
? hostFailure(data.run)
|
|
304
|
+
: state.scratchFailure,
|
|
280
305
|
}),
|
|
281
306
|
"run.removed": (state, { data }) =>
|
|
282
307
|
state.runs.has(data.id)
|
|
@@ -315,9 +340,6 @@ export const executions: NotebookResource<Executions, Kind> = {
|
|
|
315
340
|
console: (state, { data }) =>
|
|
316
341
|
attach(state, { ...data.console, kind: "console", time: data.time }),
|
|
317
342
|
"console.removed": (state, { data }) => detach(state, data.id),
|
|
318
|
-
display: (state, { data }) =>
|
|
319
|
-
attach(state, { ...data.display, kind: "display", time: data.time }),
|
|
320
|
-
"display.removed": (state, { data }) => detach(state, data.id),
|
|
321
343
|
input: (state, { data }) =>
|
|
322
344
|
attach(state, { ...data.input, kind: "input", time: data.time }),
|
|
323
345
|
variable: (state, { data }) => bind(state, data.variable),
|
|
@@ -517,8 +517,7 @@ it.each(["", "latest"])(
|
|
|
517
517
|
id: "second-line",
|
|
518
518
|
execution_id: scratch.id,
|
|
519
519
|
seq: 0,
|
|
520
|
-
|
|
521
|
-
text,
|
|
520
|
+
content: { kind: "text", stream: "stdout", text },
|
|
522
521
|
},
|
|
523
522
|
},
|
|
524
523
|
});
|
|
@@ -593,8 +592,7 @@ it("keeps a browser-cleared console hidden when the running execution is replaye
|
|
|
593
592
|
id: "new-line",
|
|
594
593
|
execution_id: "e7",
|
|
595
594
|
seq: 1,
|
|
596
|
-
|
|
597
|
-
text: "after the clear",
|
|
595
|
+
content: { kind: "text", stream: "stdout", text: "after the clear" },
|
|
598
596
|
},
|
|
599
597
|
},
|
|
600
598
|
}),
|
|
@@ -753,8 +751,7 @@ it.each(["live", "replay"])(
|
|
|
753
751
|
id: `line-${seq}`,
|
|
754
752
|
execution_id: execution.id,
|
|
755
753
|
seq,
|
|
756
|
-
|
|
757
|
-
text,
|
|
754
|
+
content: { kind: "text", stream: "stdout", text },
|
|
758
755
|
},
|
|
759
756
|
},
|
|
760
757
|
});
|
|
@@ -815,8 +812,7 @@ it("replays execution, debugger, and callback output independently", async () =>
|
|
|
815
812
|
id: "line",
|
|
816
813
|
execution_id: execution.id,
|
|
817
814
|
seq: 0,
|
|
818
|
-
|
|
819
|
-
text: "before pdb",
|
|
815
|
+
content: { kind: "text", stream: "stdout", text: "before pdb" },
|
|
820
816
|
};
|
|
821
817
|
const input = {
|
|
822
818
|
id: "request",
|
|
@@ -906,7 +902,9 @@ it("replays execution, debugger, and callback output independently", async () =>
|
|
|
906
902
|
act(() =>
|
|
907
903
|
conn.receive({
|
|
908
904
|
event: "console",
|
|
909
|
-
data: {
|
|
905
|
+
data: {
|
|
906
|
+
console: { ...line, content: { ...line.content, text: "replaced" } },
|
|
907
|
+
},
|
|
910
908
|
}),
|
|
911
909
|
);
|
|
912
910
|
expect(runtime().consoleOutputs.map((v) => v.data)).toEqual([
|
|
@@ -948,8 +946,7 @@ it.each([
|
|
|
948
946
|
id: "old-line",
|
|
949
947
|
execution_id: execution.id,
|
|
950
948
|
seq: 0,
|
|
951
|
-
|
|
952
|
-
text: "previous run",
|
|
949
|
+
content: { kind: "text", stream: "stdout", text: "previous run" },
|
|
953
950
|
},
|
|
954
951
|
},
|
|
955
952
|
});
|
|
@@ -443,7 +443,7 @@ export function useNotebookSession(opts: { sessionId: SessionId }) {
|
|
|
443
443
|
time === null ? Date.now() / 1000 : Date.parse(time) / 1000;
|
|
444
444
|
if (
|
|
445
445
|
record.state.status === "completed" &&
|
|
446
|
-
record.state.outcome
|
|
446
|
+
record.state.outcome.kind === "failed"
|
|
447
447
|
) {
|
|
448
448
|
getCellLogsForMessage({
|
|
449
449
|
cell_id: cellId,
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./worker-D70Lo75A.js";var t=/* @__PURE__ */ e(((e,t)=>{t.exports={}}));export default t();
|