@marimo-team/islands 0.25.3-dev446 → 0.25.3-dev453
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-CBvdOZsh.js → ErrorBoundary-CIYMOu2p.js} +1 -1
- package/dist/assets/__vite-browser-external-D2z_TiUO.js +1 -0
- package/dist/assets/{worker-BUqfWMtI.js → worker-DLJ9P24O.js} +2 -2
- package/dist/{chat-ui-9oyUBL6M.js → chat-ui-DEHpKH2l.js} +17 -19
- package/dist/{code-visibility-BVsBD2bm.js → code-visibility-BQE60zOk.js} +7 -7
- package/dist/{common-Cz5kXzjw.js → common-DfUux6zJ.js} +4902 -4893
- package/dist/{data-grid-overlay-editor-B-PHwg_F.js → data-grid-overlay-editor-B9zW4oN1.js} +1 -1
- package/dist/{error-entries-CWdDf7iZ.js → error-entries-BG7ifiDg.js} +1368 -996
- package/dist/{feedback-button-DKfgWMh1.js → feedback-button-BEUh4iQQ.js} +129 -129
- package/dist/{glide-data-editor-BMrcgCud.js → glide-data-editor-CbdIXPTZ.js} +3 -3
- package/dist/{globals-vjja83iL.js → globals-BkxG-Y8L.js} +1 -1
- package/dist/{html-to-image-CexRSGAZ.js → html-to-image-9HLBGrIx.js} +4115 -4103
- package/dist/main.js +6562 -6671
- package/dist/{number-overlay-editor-CQvIdVeX.js → number-overlay-editor-BFzdth50.js} +1 -1
- package/dist/{process-output-hcyVRJCC.js → process-output-B8HPq5iZ.js} +2 -2
- package/dist/{reveal-component-DF7VRfN2.js → reveal-component-DK_-9fAX.js} +166 -167
- package/package.json +1 -1
- package/src/__mocks__/executions.ts +7 -4
- package/src/__mocks__/notebook.ts +20 -4
- package/src/components/editor/cell/DeleteButton.tsx +2 -2
- package/src/components/editor/cell/StopButton.tsx +2 -2
- package/src/components/editor/cell/useRunCells.ts +0 -3
- package/src/components/editor/errors/__tests__/send-error-report-button.test.tsx +1 -1
- package/src/components/editor/notebook-cell.tsx +4 -35
- package/src/components/editor/output/ansi-reduce.ts +124 -61
- package/src/components/editor/output/console/ConsoleOutput.tsx +7 -25
- package/src/components/editor/output/console/__tests__/ConsoleOutput.test.tsx +15 -44
- package/src/components/editor/renderers/cells-renderer.tsx +2 -5
- package/src/components/editor/renderers/grid-layout/__tests__/grid-layout.test.tsx +1 -1
- package/src/components/editor/renderers/vertical-layout/vertical-layout.tsx +3 -6
- package/src/components/editor/stdin-blocking-alert.tsx +14 -18
- package/src/components/scratchpad/scratchpad.test.tsx +1 -1
- package/src/components/scratchpad/scratchpad.tsx +5 -6
- package/src/components/slides/__tests__/cell-output-block.test.tsx +2 -2
- package/src/components/slides/__tests__/slide-cell-view.test.tsx +2 -2
- package/src/components/tracing/tracing-spec.ts +11 -1
- package/src/components/tracing/tracing.tsx +4 -0
- package/src/core/ai/context/providers/__tests__/cell-output.test.ts +10 -20
- package/src/core/ai/context/providers/__tests__/error.test.ts +5 -27
- package/src/core/ai/context/providers/cell-output.ts +4 -12
- package/src/core/cells/__tests__/cell.test.ts +1 -169
- package/src/core/cells/__tests__/cells.test.ts +32 -709
- package/src/core/cells/__tests__/clear-outputs.test.ts +21 -14
- package/src/core/cells/__tests__/collapseConsoleOutputs.test.ts +71 -2
- package/src/core/cells/__tests__/logs.test.ts +18 -29
- package/src/core/cells/__tests__/runs.test.ts +128 -431
- package/src/core/cells/__tests__/session.test.ts +9 -9
- package/src/core/cells/actions.ts +29 -7
- package/src/core/cells/cell.ts +1 -96
- package/src/core/cells/cells.ts +147 -117
- package/src/core/cells/collapseConsoleOutputs.tsx +71 -40
- package/src/core/cells/command-console.ts +46 -0
- package/src/core/cells/execution-console.ts +230 -0
- package/src/core/cells/focus.ts +9 -29
- package/src/core/cells/logs.ts +10 -2
- package/src/core/cells/runs.ts +62 -118
- package/src/core/cells/session.ts +2 -2
- package/src/core/cells/types.ts +30 -23
- package/src/core/cells/useAnswerPrompt.ts +29 -0
- package/src/core/errors/error-entries.ts +3 -4
- package/src/core/executions/__tests__/atoms.test.ts +6 -20
- package/src/core/executions/__tests__/input.test.ts +3 -3
- package/src/core/executions/__tests__/output-lifecycle.test.ts +2 -8
- package/src/core/executions/atoms.ts +2 -21
- package/src/core/executions/index.ts +2 -1
- package/src/core/executions/input.ts +4 -3
- package/src/core/executions/output.ts +3 -3
- package/src/core/islands/__tests__/bridge.test.ts +59 -0
- package/src/core/islands/bootstrap.ts +29 -12
- package/src/core/islands/bridge.ts +67 -13
- package/src/core/kernel/handlers.ts +2 -21
- package/src/core/kernel/messages.ts +0 -1
- package/src/core/network/types.ts +0 -1
- package/src/core/notebook/document/__tests__/codemirror.test.ts +1 -0
- package/src/core/notebook/replica/__tests__/executions.test.ts +1 -0
- package/src/core/notebook/replica/__tests__/replica.test.ts +113 -0
- package/src/core/notebook/replica/replica.ts +106 -12
- package/src/core/notebook/replica/resources/executions.ts +57 -4
- package/src/core/session/__tests__/backend.test.ts +2 -4
- package/src/core/session/__tests__/useNotebookReplica.hook.test.tsx +1 -0
- package/src/core/session/__tests__/useNotebookSession.hook.test.tsx +601 -35
- package/src/core/session/useNotebookReplica.ts +20 -6
- package/src/core/session/useNotebookSession.tsx +63 -33
- package/src/core/static/virtual-file-tracker.ts +26 -8
- package/src/stories/layout/vertical/one-column.stories.tsx +18 -12
- package/dist/assets/__vite-browser-external-CpRgw4M_.js +0 -1
- package/src/components/editor/alerts/stdin-blocking-alert.tsx +0 -68
- package/src/core/cells/__tests__/__snapshots__/cells.test.ts.snap +0 -703
|
@@ -10,14 +10,20 @@ import {
|
|
|
10
10
|
} from "./results";
|
|
11
11
|
|
|
12
12
|
/** A console line, display, or input an execution produced, tagged by kind. */
|
|
13
|
-
|
|
13
|
+
type ProducedItem =
|
|
14
14
|
| (Protocol.Console & { readonly kind: "console" })
|
|
15
15
|
| (Protocol.Display & { readonly kind: "display" })
|
|
16
16
|
| (Protocol.Input & { readonly kind: "input" });
|
|
17
17
|
|
|
18
|
+
/** Time the host published the item, when included in a live event. */
|
|
19
|
+
export type Item = ProducedItem & { readonly time?: string };
|
|
20
|
+
|
|
18
21
|
/** An execution on the stream, with the items and variables it has produced. */
|
|
19
22
|
export interface Execution extends Result {
|
|
20
23
|
/** Items by id. `itemsInOrder` sorts them by `seq`. */
|
|
24
|
+
readonly lastSeq?: number;
|
|
25
|
+
/** Fast path for a reader displaying exactly the version before an append. */
|
|
26
|
+
readonly append?: { before: WeakRef<Execution["items"]>; item: Item };
|
|
21
27
|
readonly items: ReadonlyMap<Protocol.ItemId, Item>;
|
|
22
28
|
/** The variables the execution bound, by item id. */
|
|
23
29
|
readonly variables: ReadonlyMap<Protocol.ItemId, Protocol.Variable>;
|
|
@@ -37,6 +43,8 @@ export interface Executions {
|
|
|
37
43
|
readonly latest: ReadonlyMap<Protocol.CellId, Protocol.ExecutionId>;
|
|
38
44
|
readonly results: Results;
|
|
39
45
|
readonly scratch: Result | null;
|
|
46
|
+
/** The latest scratch execution to start, including one that printed nothing. */
|
|
47
|
+
readonly scratchConsole?: Execution;
|
|
40
48
|
}
|
|
41
49
|
|
|
42
50
|
type Kind =
|
|
@@ -62,12 +70,34 @@ function without<K, V>(map: ReadonlyMap<K, V>, key: K): ReadonlyMap<K, V> {
|
|
|
62
70
|
return next;
|
|
63
71
|
}
|
|
64
72
|
|
|
73
|
+
function retainScratchConsole(
|
|
74
|
+
state: Executions,
|
|
75
|
+
execution: Execution,
|
|
76
|
+
): Execution | undefined {
|
|
77
|
+
const current = state.scratchConsole;
|
|
78
|
+
const { id, cell_id, started_at } = execution.record;
|
|
79
|
+
if (cell_id !== null || started_at === null) {
|
|
80
|
+
return current;
|
|
81
|
+
}
|
|
82
|
+
if (!current || current.record.id === id) {
|
|
83
|
+
return execution;
|
|
84
|
+
}
|
|
85
|
+
// A late write from an older execution cannot select its console again.
|
|
86
|
+
if (state.executions.get(id)?.record.started_at != null) {
|
|
87
|
+
return current;
|
|
88
|
+
}
|
|
89
|
+
return Date.parse(started_at) >= Date.parse(current.record.started_at ?? "")
|
|
90
|
+
? execution
|
|
91
|
+
: current;
|
|
92
|
+
}
|
|
93
|
+
|
|
65
94
|
/** Replace an execution on the stream, indexed under its cell. */
|
|
66
95
|
function set(state: Executions, execution: Execution): Executions {
|
|
67
96
|
const { id, cell_id: cellId } = execution.record;
|
|
68
97
|
return {
|
|
69
98
|
...state,
|
|
70
99
|
executions: new Map(state.executions).set(id, execution),
|
|
100
|
+
scratchConsole: retainScratchConsole(state, execution),
|
|
71
101
|
latest:
|
|
72
102
|
cellId === null || state.latest.get(cellId) === id
|
|
73
103
|
? state.latest
|
|
@@ -84,6 +114,8 @@ function remove(state: Executions, id: Protocol.ExecutionId): Executions {
|
|
|
84
114
|
return {
|
|
85
115
|
...state,
|
|
86
116
|
executions: without(state.executions, id),
|
|
117
|
+
scratchConsole:
|
|
118
|
+
state.scratchConsole?.record.id === id ? undefined : state.scratchConsole,
|
|
87
119
|
latest:
|
|
88
120
|
cellId !== null && state.latest.get(cellId) === id
|
|
89
121
|
? without(state.latest, cellId)
|
|
@@ -96,8 +128,18 @@ function attach(state: Executions, item: Item): Executions {
|
|
|
96
128
|
if (execution === undefined) {
|
|
97
129
|
return state;
|
|
98
130
|
}
|
|
131
|
+
// Updating an input's status keeps the prompt at its original position.
|
|
132
|
+
const original = execution.items.get(item.id);
|
|
133
|
+
if (original) {
|
|
134
|
+
item = { ...item, time: original.time };
|
|
135
|
+
}
|
|
99
136
|
return set(state, {
|
|
100
137
|
...execution,
|
|
138
|
+
append:
|
|
139
|
+
!original && item.seq > (execution.lastSeq ?? -1)
|
|
140
|
+
? { before: new WeakRef(execution.items), item }
|
|
141
|
+
: undefined,
|
|
142
|
+
lastSeq: Math.max(execution.lastSeq ?? -1, item.seq),
|
|
101
143
|
items: new Map(execution.items).set(item.id, item),
|
|
102
144
|
});
|
|
103
145
|
}
|
|
@@ -107,6 +149,7 @@ function detach(state: Executions, itemId: Protocol.ItemId): Executions {
|
|
|
107
149
|
if (execution.items.has(itemId)) {
|
|
108
150
|
return set(state, {
|
|
109
151
|
...execution,
|
|
152
|
+
append: undefined,
|
|
110
153
|
items: without(execution.items, itemId),
|
|
111
154
|
});
|
|
112
155
|
}
|
|
@@ -148,6 +191,7 @@ function sameOutcome(a: Protocol.Execution, b: Protocol.Execution): boolean {
|
|
|
148
191
|
export function resumeResults(
|
|
149
192
|
next: Executions,
|
|
150
193
|
previous: Executions,
|
|
194
|
+
runtimeId: Protocol.RuntimeId | undefined,
|
|
151
195
|
): Executions {
|
|
152
196
|
const resumed = new Map(next.executions);
|
|
153
197
|
for (const [id, execution] of resumed) {
|
|
@@ -184,6 +228,12 @@ export function resumeResults(
|
|
|
184
228
|
...next,
|
|
185
229
|
executions: resumed,
|
|
186
230
|
results,
|
|
231
|
+
scratchConsole:
|
|
232
|
+
next.scratchConsole ??
|
|
233
|
+
(previous.scratchConsole?.record.status === "completed" &&
|
|
234
|
+
previous.scratchConsole.record.runtime_id === runtimeId
|
|
235
|
+
? previous.scratchConsole
|
|
236
|
+
: undefined),
|
|
187
237
|
scratch:
|
|
188
238
|
scratch == null
|
|
189
239
|
? previous.scratch
|
|
@@ -225,6 +275,8 @@ export const executions: NotebookResource<Executions, Kind> = {
|
|
|
225
275
|
? 0
|
|
226
276
|
: previous.outputVersion +
|
|
227
277
|
(sameOutcome(previous.record, record) ? 0 : 1),
|
|
278
|
+
append: previous?.append,
|
|
279
|
+
lastSeq: previous?.lastSeq,
|
|
228
280
|
items: previous?.items ?? new Map(),
|
|
229
281
|
variables: previous?.variables ?? new Map(),
|
|
230
282
|
};
|
|
@@ -236,12 +288,13 @@ export const executions: NotebookResource<Executions, Kind> = {
|
|
|
236
288
|
},
|
|
237
289
|
"execution.removed": (state, { data }) => remove(state, data.id),
|
|
238
290
|
console: (state, { data }) =>
|
|
239
|
-
attach(state, { ...data.console, kind: "console" }),
|
|
291
|
+
attach(state, { ...data.console, kind: "console", time: data.time }),
|
|
240
292
|
"console.removed": (state, { data }) => detach(state, data.id),
|
|
241
293
|
display: (state, { data }) =>
|
|
242
|
-
attach(state, { ...data.display, kind: "display" }),
|
|
294
|
+
attach(state, { ...data.display, kind: "display", time: data.time }),
|
|
243
295
|
"display.removed": (state, { data }) => detach(state, data.id),
|
|
244
|
-
input: (state, { data }) =>
|
|
296
|
+
input: (state, { data }) =>
|
|
297
|
+
attach(state, { ...data.input, kind: "input", time: data.time }),
|
|
245
298
|
variable: (state, { data }) => bind(state, data.variable),
|
|
246
299
|
"variable.removed": (state, { data }) => unbind(state, data.id),
|
|
247
300
|
},
|
|
@@ -47,7 +47,7 @@ function sockets() {
|
|
|
47
47
|
super();
|
|
48
48
|
opened.push(String(url));
|
|
49
49
|
}
|
|
50
|
-
public close()
|
|
50
|
+
public close = vi.fn();
|
|
51
51
|
},
|
|
52
52
|
);
|
|
53
53
|
return opened;
|
|
@@ -92,9 +92,7 @@ describe("createEditorBackend", () => {
|
|
|
92
92
|
"marimo",
|
|
93
93
|
];
|
|
94
94
|
expect(executionKinds.filter((kind) => kinds?.includes(kind))).toEqual(
|
|
95
|
-
expected === "socket" || expected === "fetch"
|
|
96
|
-
? ["execution", "marimo"]
|
|
97
|
-
: [],
|
|
95
|
+
expected === "socket" || expected === "fetch" ? executionKinds : [],
|
|
98
96
|
);
|
|
99
97
|
events.close();
|
|
100
98
|
});
|
|
@@ -57,6 +57,7 @@ function setup(strict = false) {
|
|
|
57
57
|
waitUntilReady: async () => undefined,
|
|
58
58
|
checkHealth: async () => true,
|
|
59
59
|
onNotification: vi.fn(),
|
|
60
|
+
onExecution: vi.fn(),
|
|
60
61
|
};
|
|
61
62
|
const wrapper = ({ children }: PropsWithChildren) => (
|
|
62
63
|
<Provider store={store}>{children}</Provider>
|