@marimo-team/islands 0.25.3-dev388 → 0.25.3-dev394
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-BpCrAeX0.js → ConnectedDataExplorerComponent-1DGGwl88.js} +9 -9
- package/dist/{ErrorBoundary-_mFP3LkM.js → ErrorBoundary-DDIASniH.js} +6 -6
- package/dist/{abnfDiagram-VCTEODGH-ZqNgGZlz.js → abnfDiagram-VCTEODGH-CeQEbVik.js} +2 -2
- package/dist/{any-language-editor-CFbAr7vc.js → any-language-editor-C_s_ZoaK.js} +2 -2
- package/dist/{architectureDiagram-5GKGNRK7-BEUaR96d.js → architectureDiagram-5GKGNRK7-C8xUpTAb.js} +1 -1
- package/dist/{assertNever-5uYEbJc8.js → assertNever-DXGfUmPW.js} +2 -2
- package/dist/assets/__vite-browser-external-C9HF3uHE.js +1 -0
- package/dist/assets/worker-B4Cpvr8b.js +171 -0
- package/dist/{chat-ui-BKSYhGMh.js → chat-ui-B6bY_0LF.js} +774 -774
- package/dist/{check-BbhVyViy.js → check-ywinAQy6.js} +1 -1
- package/dist/{chunk-IMKFNOWR-BdEPmWQI.js → chunk-IMKFNOWR-DY7AWyNi.js} +1 -1
- package/dist/{chunk-SHT3W25Y-IvvXM3xf.js → chunk-SHT3W25Y-D4epY9MY.js} +1 -1
- package/dist/{chunk-SVP7TREG-C_qpJUv1.js → chunk-SVP7TREG-CKsl2Q6r.js} +1 -1
- package/dist/{chunk-TICWLB2K-C4agYVWP.js → chunk-TICWLB2K-CMsD2y0F.js} +1 -1
- package/dist/{classDiagram-ZZMXUADV-CT2iq8uF.js → classDiagram-ZZMXUADV-C4FsLnvt.js} +2 -2
- package/dist/{classDiagram-v2-VYDZK3BY-Coe_dD0r.js → classDiagram-v2-VYDZK3BY-BJRuFZeI.js} +2 -2
- package/dist/{code-visibility-DkMNjdNe.js → code-visibility-CByYqwFv.js} +13 -13
- package/dist/{common-Ces9ooG_.js → common-KkgATX2Y.js} +4918 -4910
- package/dist/{config-DJ8M-gPL.js → config-DOwBtRkI.js} +3 -3
- package/dist/{copy-icon-xWvA8ybp.js → copy-icon-BKcX0ltw.js} +2 -2
- package/dist/{createReducer-fp0gX_9U.js → createReducer-Bjx6kuxh.js} +1 -1
- package/dist/{cynefinDiagram-5FMLGOSQ-D0LKziUu.js → cynefinDiagram-5FMLGOSQ-DyI_lSsn.js} +1 -1
- package/dist/{dagre-GXQ25YYZ-Cmgziaw8.js → dagre-GXQ25YYZ-Buoy6sX-.js} +1 -1
- package/dist/{data-grid-overlay-editor-uNMslVKY.js → data-grid-overlay-editor-BHrTJhN3.js} +1 -1
- package/dist/{diagram-S7CK7UJ4-D-lZsALU.js → diagram-S7CK7UJ4-CbSD1DUy.js} +1 -1
- package/dist/{diagram-UQ7AKVKN-TcbdsFoT.js → diagram-UQ7AKVKN-Dapj2rQm.js} +1 -1
- package/dist/{diagram-VX7I27RA-D5BqZi1q.js → diagram-VX7I27RA-CxA3txtC.js} +1 -1
- package/dist/{diagram-Z3DM3KII-MNc7jqvr.js → diagram-Z3DM3KII-BEZqz916.js} +1 -1
- package/dist/{dialog-Cm0VGdxc.js → dialog-mwa6XN15.js} +2 -2
- package/dist/{dropdown-menu-DfamXjVI.js → dropdown-menu-CmgUseHo.js} +5 -5
- package/dist/duckdb-keywords-CdzX4o33.js +3 -0
- package/dist/{ebnfDiagram-PWID7BFC-Cxt6ywyX.js → ebnfDiagram-PWID7BFC-Dmw-1JV3.js} +2 -2
- package/dist/{erDiagram-RLTQ6QDP-BLF-askI.js → erDiagram-RLTQ6QDP-DZpG4cbm.js} +1 -1
- package/dist/{error-banner-k06CAftu.js → error-banner-CHPLqogX.js} +1 -1
- package/dist/{error-entries-rtPWQkJk.js → error-entries-Bk96zt4w.js} +825 -690
- package/dist/{feedback-button-i960qUnq.js → feedback-button-2FaWjlaR.js} +12 -12
- package/dist/{flowDiagram-HODETNUW-CsLw2mWn.js → flowDiagram-HODETNUW-B02oHnBv.js} +2 -2
- package/dist/{formats-DQ-qq-dU.js → formats-BDqe9cfr.js} +1 -1
- package/dist/{glide-data-editor-_EEhlGzS.js → glide-data-editor-B9Yq6Wg1.js} +11 -11
- package/dist/{glide-utils-CHrghEu-.js → glide-utils-DYKWS2YV.js} +2 -2
- package/dist/{globals-DKkjIolp.js → globals-S4D5AVKN.js} +3 -3
- package/dist/{html-to-image-B5nTOeMI.js → html-to-image-BauFF9F_.js} +4842 -4821
- package/dist/{infoDiagram-27XIBGKW-CdSApBWg.js → infoDiagram-27XIBGKW-BPbQHO9m.js} +1 -1
- package/dist/{ishikawaDiagram-5VMMS53U-BnzQ8SI5.js → ishikawaDiagram-5VMMS53U-DmnKSNi7.js} +1 -1
- package/dist/{kanban-definition-UXKFOSKX-D2llTpeX.js → kanban-definition-UXKFOSKX-u5PZbsBe.js} +1 -1
- package/dist/main.js +6236 -6175
- package/dist/{mermaid-BcNMyKmf.js → mermaid-ffopDjig.js} +34 -34
- package/dist/{mindmap-definition-YA3MSWOX-uoEsfD5R.js → mindmap-definition-YA3MSWOX-CX187lhP.js} +1 -1
- package/dist/{number-overlay-editor-D5U7jbrh.js → number-overlay-editor-l7DB2HCO.js} +1 -1
- package/dist/{pegDiagram-XKGWAZYB-DTWrE0S4.js → pegDiagram-XKGWAZYB-Bj6HGPak.js} +2 -2
- package/dist/{pencil-weySvN0N.js → pencil-CijoRsa3.js} +1 -1
- package/dist/{pieDiagram-E7YTZNPT-COME2oGN.js → pieDiagram-E7YTZNPT-C_wIgDJM.js} +1 -1
- package/dist/{process-output-DNxpsd4n.js → process-output-Deae7dX1.js} +4 -4
- package/dist/{railroadDiagram-O6MQD6OU-CUeFcNTY.js → railroadDiagram-O6MQD6OU-CwoJvnvC.js} +2 -2
- package/dist/{requirementDiagram-BXWQKSXE-BUR4lDZG.js → requirementDiagram-BXWQKSXE-C8JuhLLL.js} +1 -1
- package/dist/{reveal-component-BM9TozVQ.js → reveal-component-VR4UzAUv.js} +37 -37
- package/dist/{select-Ca-POp4c.js → select-DW32QOzC.js} +4 -4
- package/dist/{sequenceDiagram-WJ2MYXX4-CSPmml3q.js → sequenceDiagram-WJ2MYXX4-RbrRdoiV.js} +1 -1
- package/dist/{spec-BgSMwzks.js → spec-Ww0JjShW.js} +4 -4
- package/dist/{stateDiagram-D77RDMKH-BDUC8Pi9.js → stateDiagram-D77RDMKH-DWdIvCnU.js} +2 -2
- package/dist/{stateDiagram-v2-MP3YSRHH-BH-qyk8a.js → stateDiagram-v2-MP3YSRHH-BG0j9crW.js} +2 -2
- package/dist/{static-state-Cqzv5X7B.js → static-state-CnQdTBTW.js} +1 -1
- package/dist/style.css +1 -1
- package/dist/{swimlanes-42K2YHIH-CLE9Kiir.js → swimlanes-42K2YHIH-B6zUw4gq.js} +1 -1
- package/dist/{swimlanesDiagram-VR7AAH4N-Cv8kWAeA.js → swimlanesDiagram-VR7AAH4N-DjVEnsIG.js} +2 -2
- package/dist/{timeline-definition-24CTP7MA-fbRGX21i.js → timeline-definition-24CTP7MA-DSAxwqnC.js} +1 -1
- package/dist/{toast-0xspcdmv.js → toast-Crofa36R.js} +3 -3
- package/dist/{tooltip-BwlFTaNy.js → tooltip-Bg-SDCwa.js} +1 -1
- package/dist/{use-restore-focus-fKgXR0nb.js → use-restore-focus-CE9Sflmg.js} +1298 -1283
- package/dist/{useDateFormatter-B7LvPmsw.js → useDateFormatter-D5fsC9ot.js} +2 -2
- package/dist/{useDeepCompareMemoize-OhBYt-q2.js → useDeepCompareMemoize-Bvrue1iy.js} +1 -1
- package/dist/{useLifecycle-D9xcFAIN.js → useLifecycle-Ctr5lECo.js} +1 -1
- package/dist/{vega-component-Chak9Aon.js → vega-component-DQZhTzVQ.js} +6 -6
- package/dist/{vennDiagram-4TSXK5OY-BzKtg8gL.js → vennDiagram-4TSXK5OY-FAGYRdBj.js} +1 -1
- package/dist/{wardleyDiagram-VM6X3IG4-R0SgDvz1.js → wardleyDiagram-VM6X3IG4-BlB973r1.js} +1 -1
- package/dist/{xychartDiagram-S5SC5T6Z-DRskTHEM.js → xychartDiagram-S5SC5T6Z-CywvmjIK.js} +1 -1
- package/package.json +2 -2
- package/src/__mocks__/executions.ts +48 -8
- package/src/__mocks__/notebook.ts +20 -42
- package/src/components/app-config/__tests__/add-model-discovery.test.tsx +255 -0
- package/src/components/app-config/__tests__/model-discovery.test.tsx +183 -0
- package/src/components/app-config/ai-config.tsx +20 -24
- package/src/components/app-config/model-discovery.tsx +118 -184
- package/src/components/app-config/model-provider-config.ts +25 -0
- package/src/components/editor/Output.tsx +5 -4
- package/src/components/editor/__tests__/data-attributes.test.tsx +1 -6
- package/src/components/editor/__tests__/dynamic-favicon.test.tsx +11 -16
- package/src/components/editor/__tests__/output-persistence.test.tsx +6 -24
- package/src/components/editor/actions/__tests__/useSetOutputsExpanded.test.ts +6 -8
- package/src/components/editor/actions/useSetOutputsExpanded.ts +12 -4
- package/src/components/editor/cell/cell-context-menu.tsx +3 -2
- package/src/components/editor/errors/__tests__/send-error-report-button.test.tsx +89 -72
- package/src/components/editor/notebook-cell.tsx +15 -10
- package/src/components/editor/output/console/process-output.ts +4 -2
- package/src/components/editor/renderers/cells-renderer.tsx +3 -1
- package/src/components/editor/renderers/grid-layout/__tests__/grid-layout.test.tsx +5 -11
- package/src/components/editor/renderers/grid-layout/grid-layout.tsx +9 -8
- package/src/components/editor/renderers/types.ts +2 -2
- package/src/components/editor/renderers/vertical-layout/utils.ts +4 -4
- package/src/components/editor/renderers/vertical-layout/vertical-layout.tsx +5 -8
- package/src/components/scratchpad/scratchpad.tsx +6 -2
- package/src/components/slides/__tests__/cell-output-block.test.tsx +7 -8
- package/src/components/slides/__tests__/minimap-actions.test.tsx +3 -3
- package/src/components/slides/__tests__/slide-cell-view.test.tsx +1 -0
- package/src/components/slides/slide-cell-view.tsx +1 -3
- package/src/components/slides/slide.tsx +3 -3
- package/src/core/ai/context/__tests__/registry.test.ts +7 -11
- package/src/core/ai/context/providers/__tests__/cell-output.test.ts +113 -35
- package/src/core/ai/context/providers/__tests__/error.test.ts +74 -191
- package/src/core/ai/context/providers/cell-output.ts +11 -6
- package/src/core/cells/__tests__/__snapshots__/cells.test.ts.snap +8 -103
- package/src/core/cells/__tests__/cells.test.ts +40 -292
- package/src/core/cells/__tests__/clear-outputs.test.ts +151 -0
- package/src/core/cells/__tests__/harness.ts +14 -12
- package/src/core/cells/__tests__/layout.test.ts +20 -26
- package/src/core/cells/__tests__/notebook-outline.test.ts +49 -43
- package/src/core/cells/__tests__/session.test.ts +26 -146
- package/src/core/cells/actions.ts +49 -9
- package/src/core/cells/cell.ts +0 -13
- package/src/core/cells/cells.ts +53 -62
- package/src/core/cells/focus.ts +6 -1
- package/src/core/cells/layout.ts +2 -3
- package/src/core/cells/outputs.ts +2 -2
- package/src/core/cells/session.ts +3 -38
- package/src/core/cells/types.ts +6 -8
- package/src/core/cells/utils.ts +4 -3
- package/src/core/codemirror/ai/__tests__/resources.test.ts +7 -11
- package/src/core/config/config-schema.ts +15 -0
- package/src/core/errors/__tests__/error-entries.test.ts +52 -18
- package/src/core/errors/error-entries.ts +21 -11
- package/src/core/executions/__tests__/freshness.test.ts +7 -4
- package/src/core/executions/__tests__/hooks.test.tsx +5 -1
- package/src/core/executions/__tests__/interrupt.test.ts +2 -0
- package/src/core/executions/__tests__/output-lifecycle.test.ts +201 -0
- package/src/core/executions/__tests__/output.test.ts +87 -3
- package/src/core/executions/__tests__/select.test.ts +17 -10
- package/src/core/executions/atoms.ts +73 -15
- package/src/core/executions/freshness.ts +1 -1
- package/src/core/executions/hooks.ts +18 -8
- package/src/core/executions/index.ts +6 -0
- package/src/core/executions/output.ts +122 -38
- package/src/core/executions/select.ts +2 -2
- package/src/core/export/__tests__/hooks.test.ts +20 -29
- package/src/core/export/hooks.ts +7 -9
- package/src/core/islands/__tests__/iframe-resizer.test.ts +91 -0
- package/src/core/islands/__tests__/main.test.ts +17 -0
- package/src/core/islands/components/__tests__/web-components.test.tsx +13 -15
- package/src/core/islands/components/output-wrapper.tsx +15 -20
- package/src/core/islands/iframe-resizer.ts +38 -0
- package/src/core/islands/main.ts +3 -0
- package/src/core/lifecycle/render-policy.ts +7 -4
- package/src/core/network/__tests__/ai.test.ts +41 -0
- package/src/core/network/ai.ts +12 -0
- package/src/core/notebook/document/__tests__/codemirror.test.ts +2 -0
- package/src/core/notebook/replica/__tests__/replica.test.ts +19 -0
- package/src/core/notebook/replica/__tests__/results.test.ts +45 -16
- package/src/core/notebook/replica/index.ts +1 -1
- package/src/core/notebook/replica/replica.ts +19 -4
- package/src/core/notebook/replica/resources/executions.ts +100 -9
- package/src/core/notebook/replica/resources/results.ts +46 -31
- package/src/core/transports/__tests__/static.test.ts +5 -3
- package/src/stories/cell.stories.tsx +40 -30
- package/src/stories/layout/vertical/one-column.stories.tsx +15 -7
- package/dist/assets/__vite-browser-external-C5NhJPNJ.js +0 -1
- package/dist/assets/worker-D-n8vtGi.js +0 -171
- package/dist/duckdb-keywords-BGArYVVK.js +0 -3
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
import type * as Protocol from "@marimo-team/client/protocol";
|
|
4
4
|
import type { NotebookResource } from "@marimo-team/client";
|
|
5
|
+
import {
|
|
6
|
+
type Result,
|
|
7
|
+
type Results,
|
|
8
|
+
retainResult,
|
|
9
|
+
retainScratchResult,
|
|
10
|
+
} from "./results";
|
|
5
11
|
|
|
6
12
|
/** A console line, display, or input an execution produced, tagged by kind. */
|
|
7
13
|
export type Item =
|
|
@@ -10,8 +16,7 @@ export type Item =
|
|
|
10
16
|
| (Protocol.Input & { readonly kind: "input" });
|
|
11
17
|
|
|
12
18
|
/** An execution on the stream, with the items and variables it has produced. */
|
|
13
|
-
export interface Execution {
|
|
14
|
-
readonly record: Protocol.Execution;
|
|
19
|
+
export interface Execution extends Result {
|
|
15
20
|
/** Items by id. `itemsInOrder` sorts them by `seq`. */
|
|
16
21
|
readonly items: ReadonlyMap<Protocol.ItemId, Item>;
|
|
17
22
|
/** The variables the execution bound, by item id. */
|
|
@@ -21,9 +26,8 @@ export interface Execution {
|
|
|
21
26
|
/**
|
|
22
27
|
* Runs and executions as the stream reports them.
|
|
23
28
|
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* cell's last completed record for display.
|
|
29
|
+
* Items and variables leave with their execution. Each cell's last result
|
|
30
|
+
* stays for display while a new execution runs.
|
|
27
31
|
*/
|
|
28
32
|
export interface Executions {
|
|
29
33
|
readonly runs: ReadonlyMap<Protocol.RunId, Protocol.Run>;
|
|
@@ -31,9 +35,18 @@ export interface Executions {
|
|
|
31
35
|
readonly executions: ReadonlyMap<Protocol.ExecutionId, Execution>;
|
|
32
36
|
/** The execution on the stream for each cell that has one. */
|
|
33
37
|
readonly latest: ReadonlyMap<Protocol.CellId, Protocol.ExecutionId>;
|
|
38
|
+
readonly results: Results;
|
|
39
|
+
readonly scratch: Result | null;
|
|
34
40
|
}
|
|
35
41
|
|
|
36
|
-
type Kind =
|
|
42
|
+
type Kind =
|
|
43
|
+
| "cell"
|
|
44
|
+
| "run"
|
|
45
|
+
| "execution"
|
|
46
|
+
| "console"
|
|
47
|
+
| "display"
|
|
48
|
+
| "input"
|
|
49
|
+
| "variable";
|
|
37
50
|
|
|
38
51
|
/** An execution's items in the order they were produced. */
|
|
39
52
|
export function itemsInOrder(execution: Pick<Execution, "items">): Item[] {
|
|
@@ -124,9 +137,77 @@ function unbind(state: Executions, itemId: Protocol.ItemId): Executions {
|
|
|
124
137
|
return state;
|
|
125
138
|
}
|
|
126
139
|
|
|
140
|
+
function sameOutcome(a: Protocol.Execution, b: Protocol.Execution): boolean {
|
|
141
|
+
return (
|
|
142
|
+
a.outcome === b.outcome ||
|
|
143
|
+
JSON.stringify(a.outcome) === JSON.stringify(b.outcome)
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** Carry displayed results and their revisions through a replacement snapshot. */
|
|
148
|
+
export function resumeResults(
|
|
149
|
+
next: Executions,
|
|
150
|
+
previous: Executions,
|
|
151
|
+
): Executions {
|
|
152
|
+
const resumed = new Map(next.executions);
|
|
153
|
+
for (const [id, execution] of resumed) {
|
|
154
|
+
const retained =
|
|
155
|
+
execution.record.cell_id === null
|
|
156
|
+
? previous.scratch
|
|
157
|
+
: previous.results.get(execution.record.cell_id);
|
|
158
|
+
const before =
|
|
159
|
+
previous.executions.get(id) ??
|
|
160
|
+
(retained?.record.id === id ? retained : undefined);
|
|
161
|
+
if (before !== undefined) {
|
|
162
|
+
resumed.set(id, {
|
|
163
|
+
...execution,
|
|
164
|
+
outputVersion:
|
|
165
|
+
before.outputVersion +
|
|
166
|
+
(sameOutcome(before.record, execution.record) ? 0 : 1),
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
const results = new Map(next.results);
|
|
171
|
+
for (const [cellId, result] of results) {
|
|
172
|
+
const execution =
|
|
173
|
+
result === null ? undefined : resumed.get(result.record.id);
|
|
174
|
+
results.set(
|
|
175
|
+
cellId,
|
|
176
|
+
execution === undefined
|
|
177
|
+
? (previous.results.get(cellId) ?? null)
|
|
178
|
+
: { record: execution.record, outputVersion: execution.outputVersion },
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
const scratch =
|
|
182
|
+
next.scratch === null ? null : resumed.get(next.scratch.record.id);
|
|
183
|
+
return {
|
|
184
|
+
...next,
|
|
185
|
+
executions: resumed,
|
|
186
|
+
results,
|
|
187
|
+
scratch:
|
|
188
|
+
scratch == null
|
|
189
|
+
? previous.scratch
|
|
190
|
+
: retainScratchResult(previous.scratch, scratch),
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
|
|
127
194
|
export const executions: NotebookResource<Executions, Kind> = {
|
|
128
|
-
initial: {
|
|
195
|
+
initial: {
|
|
196
|
+
runs: new Map(),
|
|
197
|
+
executions: new Map(),
|
|
198
|
+
latest: new Map(),
|
|
199
|
+
results: new Map(),
|
|
200
|
+
scratch: null,
|
|
201
|
+
},
|
|
129
202
|
on: {
|
|
203
|
+
cell: (state, { data }) =>
|
|
204
|
+
state.results.has(data.cell.id)
|
|
205
|
+
? state
|
|
206
|
+
: { ...state, results: new Map(state.results).set(data.cell.id, null) },
|
|
207
|
+
"cell.removed": (state, { data }) => ({
|
|
208
|
+
...state,
|
|
209
|
+
results: without(state.results, data.id),
|
|
210
|
+
}),
|
|
130
211
|
run: (state, { data }) => ({
|
|
131
212
|
...state,
|
|
132
213
|
runs: new Map(state.runs).set(data.run.id, data.run),
|
|
@@ -137,11 +218,21 @@ export const executions: NotebookResource<Executions, Kind> = {
|
|
|
137
218
|
: state,
|
|
138
219
|
execution: (state, { data: { execution: record } }) => {
|
|
139
220
|
const previous = state.executions.get(record.id);
|
|
140
|
-
|
|
221
|
+
const execution: Execution = {
|
|
141
222
|
record,
|
|
223
|
+
outputVersion:
|
|
224
|
+
previous === undefined
|
|
225
|
+
? 0
|
|
226
|
+
: previous.outputVersion +
|
|
227
|
+
(sameOutcome(previous.record, record) ? 0 : 1),
|
|
142
228
|
items: previous?.items ?? new Map(),
|
|
143
229
|
variables: previous?.variables ?? new Map(),
|
|
144
|
-
}
|
|
230
|
+
};
|
|
231
|
+
return {
|
|
232
|
+
...set(state, execution),
|
|
233
|
+
results: retainResult(state.results, execution),
|
|
234
|
+
scratch: retainScratchResult(state.scratch, execution),
|
|
235
|
+
};
|
|
145
236
|
},
|
|
146
237
|
"execution.removed": (state, { data }) => remove(state, data.id),
|
|
147
238
|
console: (state, { data }) =>
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
2
|
|
|
3
3
|
import type * as Protocol from "@marimo-team/client/protocol";
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
/** An execution record paired with the local revision of its outcome. */
|
|
6
|
+
export interface Result {
|
|
7
|
+
readonly record: Protocol.Execution;
|
|
8
|
+
/** Unchanged by lifecycle-only events. */
|
|
9
|
+
readonly outputVersion: number;
|
|
10
|
+
}
|
|
5
11
|
|
|
6
12
|
/**
|
|
7
13
|
* Each document cell's last completed execution record.
|
|
@@ -9,40 +15,49 @@ import type { NotebookResource } from "@marimo-team/client";
|
|
|
9
15
|
* The host removes a cell's previous execution before it publishes the
|
|
10
16
|
* next one. A result stays until a newer execution for the cell completes
|
|
11
17
|
* or the cell leaves the document, so a cell can show its last outcome
|
|
12
|
-
* while it runs again.
|
|
13
|
-
*
|
|
14
|
-
* the execution.
|
|
18
|
+
* while it runs again. The record and its output revision are kept; the
|
|
19
|
+
* items and variables stay with the stream's copy of the execution.
|
|
15
20
|
*
|
|
16
21
|
* A cell has an entry from its `cell` event until its removal, null until
|
|
17
22
|
* it completes once. Cells precede their executions on the stream, so a
|
|
18
23
|
* completion for a cell without an entry belongs to a cell the document
|
|
19
24
|
* no longer has.
|
|
25
|
+
*
|
|
26
|
+
* An execution the host skipped as superseded never ran, and a newer one
|
|
27
|
+
* for the same cell is on its way, so it does not replace the result.
|
|
20
28
|
*/
|
|
21
|
-
export type Results = ReadonlyMap<Protocol.CellId,
|
|
29
|
+
export type Results = ReadonlyMap<Protocol.CellId, Result | null>;
|
|
30
|
+
|
|
31
|
+
export function retainResult(state: Results, result: Result): Results {
|
|
32
|
+
const { record, outputVersion } = result;
|
|
33
|
+
const cellId = record.cell_id;
|
|
34
|
+
if (
|
|
35
|
+
cellId === null ||
|
|
36
|
+
record.status !== "completed" ||
|
|
37
|
+
!state.has(cellId) ||
|
|
38
|
+
(record.outcome?.kind === "skipped" &&
|
|
39
|
+
record.outcome.reason === "superseded")
|
|
40
|
+
) {
|
|
41
|
+
return state;
|
|
42
|
+
}
|
|
43
|
+
return new Map(state).set(cellId, { record, outputVersion });
|
|
44
|
+
}
|
|
22
45
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
!state.has(cellId)
|
|
42
|
-
) {
|
|
43
|
-
return state;
|
|
44
|
-
}
|
|
45
|
-
return new Map(state).set(cellId, execution);
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
};
|
|
46
|
+
/** Keep just the latest scratch display, independently of execution history. */
|
|
47
|
+
export function retainScratchResult(
|
|
48
|
+
previous: Result | null,
|
|
49
|
+
result: Result,
|
|
50
|
+
): Result | null {
|
|
51
|
+
const { record, outputVersion } = result;
|
|
52
|
+
if (record.cell_id !== null || record.outcome === null) {
|
|
53
|
+
return previous;
|
|
54
|
+
}
|
|
55
|
+
const time = (execution: Protocol.Execution) =>
|
|
56
|
+
Date.parse(
|
|
57
|
+
execution.completed_at ?? execution.started_at ?? "1970-01-01T00:00:00Z",
|
|
58
|
+
);
|
|
59
|
+
if (previous !== null && time(previous.record) > time(record)) {
|
|
60
|
+
return previous;
|
|
61
|
+
}
|
|
62
|
+
return { record, outputVersion };
|
|
63
|
+
}
|
|
@@ -6,7 +6,7 @@ import { afterEach, assert, describe, expect, it, vi } from "vitest";
|
|
|
6
6
|
import { MockExecutions } from "@/__mocks__/executions";
|
|
7
7
|
import type { NotebookBackend } from "../../notebook/replica";
|
|
8
8
|
import { document as documentResource } from "../../notebook/replica/resources/document";
|
|
9
|
-
import {
|
|
9
|
+
import { executions } from "../../notebook/replica/resources/executions";
|
|
10
10
|
import {
|
|
11
11
|
createStaticNotebookBackend,
|
|
12
12
|
emptySnapshot,
|
|
@@ -124,7 +124,7 @@ describe("static notebook backend", () => {
|
|
|
124
124
|
);
|
|
125
125
|
const reducer = createNotebookReducer({
|
|
126
126
|
document: documentResource,
|
|
127
|
-
|
|
127
|
+
executions,
|
|
128
128
|
});
|
|
129
129
|
const state = events.reduce(reducer.reduce, reducer.initial);
|
|
130
130
|
expect(events.map((event) => event.event).slice(-3)).toEqual([
|
|
@@ -132,7 +132,9 @@ describe("static notebook backend", () => {
|
|
|
132
132
|
"execution",
|
|
133
133
|
"ready",
|
|
134
134
|
]);
|
|
135
|
-
expect(state.resources.results.get(cell.id)).toEqual(
|
|
135
|
+
expect(state.resources.executions.results.get(cell.id)?.record).toEqual(
|
|
136
|
+
result,
|
|
137
|
+
);
|
|
136
138
|
});
|
|
137
139
|
|
|
138
140
|
it("preserves withheld source and its revision metadata", async () => {
|
|
@@ -12,11 +12,9 @@ import {
|
|
|
12
12
|
withCells,
|
|
13
13
|
} from "@/core/notebook/document/__tests__/fixtures";
|
|
14
14
|
import { type NotebookState, notebookAtom } from "@/core/cells/cells";
|
|
15
|
-
import {
|
|
16
|
-
type CellRuntimeState,
|
|
17
|
-
createCellRuntimeState,
|
|
18
|
-
} from "@/core/cells/types";
|
|
15
|
+
import { createCellRuntimeState } from "@/core/cells/types";
|
|
19
16
|
import { defaultUserConfig } from "@/core/config/config-schema";
|
|
17
|
+
import type { CellOutput } from "@/core/executions";
|
|
20
18
|
import { connectionAtom } from "@/core/network/connection";
|
|
21
19
|
import { requestClientAtom } from "@/core/network/requests";
|
|
22
20
|
import { resolveRequestClient } from "@/core/network/resolve";
|
|
@@ -28,7 +26,7 @@ import { TooltipProvider } from "../components/ui/tooltip";
|
|
|
28
26
|
type Story = StoryObj<typeof Cell>;
|
|
29
27
|
|
|
30
28
|
interface CellOverrides {
|
|
31
|
-
output?:
|
|
29
|
+
output?: CellOutput | null;
|
|
32
30
|
/** How the cell's result is outdated, as the host would report it. */
|
|
33
31
|
freshness?: "edited" | "replaced" | "both";
|
|
34
32
|
config?: CellConfig;
|
|
@@ -37,30 +35,49 @@ interface CellOverrides {
|
|
|
37
35
|
const EMPTY_OVERRIDES: Readonly<CellOverrides> = {};
|
|
38
36
|
|
|
39
37
|
/**
|
|
40
|
-
* Give the replica a completed execution
|
|
41
|
-
* whose input a newer execution replaced, or both.
|
|
38
|
+
* Give the replica a completed execution that showed `output`, and whose
|
|
39
|
+
* source was edited since, whose input a newer execution replaced, or both.
|
|
42
40
|
*/
|
|
43
|
-
function
|
|
41
|
+
function seedResult(
|
|
44
42
|
store: ReturnType<typeof createStore>,
|
|
45
43
|
cid: CellId,
|
|
46
|
-
|
|
44
|
+
output: CellOutput | null,
|
|
45
|
+
freshness: CellOverrides["freshness"],
|
|
47
46
|
) {
|
|
48
47
|
const ran = MockExecutions.completed(cid, {
|
|
49
48
|
code_fingerprint: "ran",
|
|
50
49
|
depends_on:
|
|
51
|
-
freshness ===
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
50
|
+
freshness === undefined || freshness === "edited"
|
|
51
|
+
? {}
|
|
52
|
+
: { x: { execution: "gone", update: 0 } },
|
|
53
|
+
outcome: {
|
|
54
|
+
kind: "value",
|
|
55
|
+
display:
|
|
56
|
+
output === null
|
|
57
|
+
? null
|
|
58
|
+
: {
|
|
59
|
+
mimetype: output.mimetype,
|
|
60
|
+
data:
|
|
61
|
+
typeof output.data === "string"
|
|
62
|
+
? output.data
|
|
63
|
+
: JSON.stringify(output.data),
|
|
64
|
+
},
|
|
61
65
|
},
|
|
62
|
-
|
|
63
|
-
|
|
66
|
+
});
|
|
67
|
+
const document =
|
|
68
|
+
freshness === undefined
|
|
69
|
+
? null
|
|
70
|
+
: withCells(
|
|
71
|
+
documentOf(),
|
|
72
|
+
{
|
|
73
|
+
c1: null,
|
|
74
|
+
c2: null,
|
|
75
|
+
[cid]: cell(cid, "import marimo as mo", {
|
|
76
|
+
code_fingerprint: freshness === "replaced" ? "ran" : "edited",
|
|
77
|
+
}),
|
|
78
|
+
},
|
|
79
|
+
[cid],
|
|
80
|
+
);
|
|
64
81
|
MockExecutions.seed(store, [ran], null, document);
|
|
65
82
|
}
|
|
66
83
|
|
|
@@ -83,12 +100,7 @@ const Cell: React.FC<{
|
|
|
83
100
|
},
|
|
84
101
|
cellIds: [cid],
|
|
85
102
|
cellRuntime: {
|
|
86
|
-
[cid]: createCellRuntimeState(
|
|
87
|
-
output: overrides.output ?? null,
|
|
88
|
-
consoleOutputs: [],
|
|
89
|
-
debuggerActive: false,
|
|
90
|
-
outline: null,
|
|
91
|
-
}),
|
|
103
|
+
[cid]: createCellRuntimeState(),
|
|
92
104
|
},
|
|
93
105
|
cellHandles: {
|
|
94
106
|
[cid]: createRef(),
|
|
@@ -100,9 +112,7 @@ const Cell: React.FC<{
|
|
|
100
112
|
|
|
101
113
|
const store = createStore();
|
|
102
114
|
store.set(notebookAtom, notebook);
|
|
103
|
-
|
|
104
|
-
seedFreshness(store, cid, overrides.freshness);
|
|
105
|
-
}
|
|
115
|
+
seedResult(store, cid, overrides.output ?? null, overrides.freshness);
|
|
106
116
|
store.set(connectionAtom, { state: ConnectionState.OPEN });
|
|
107
117
|
store.set(requestClientAtom, resolveRequestClient());
|
|
108
118
|
return (
|
|
@@ -4,6 +4,7 @@ import type { Meta } from "@storybook/react-vite";
|
|
|
4
4
|
import { createStore, Provider } from "jotai";
|
|
5
5
|
import { createRef } from "react";
|
|
6
6
|
import { mockDocumentModel } from "@/__mocks__/document";
|
|
7
|
+
import { MockExecutions } from "@/__mocks__/executions";
|
|
7
8
|
import { cellId } from "@/__tests__/branded";
|
|
8
9
|
import { type NotebookState, notebookAtom } from "@/core/cells/cells";
|
|
9
10
|
import { createCellRuntimeState } from "@/core/cells/types";
|
|
@@ -19,6 +20,16 @@ import { CellsRenderer } from "../../../components/editor/renderers/cells-render
|
|
|
19
20
|
import { TooltipProvider } from "../../../components/ui/tooltip";
|
|
20
21
|
import type { CellId } from "../../../core/cells/ids";
|
|
21
22
|
|
|
23
|
+
const LONG_REPR =
|
|
24
|
+
"<dlt.Relation(dataset='jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_', destination='<dlt.destinations.duckdb(destination_type='duckdb', credentials='local_jaffle.duckdb')>')>";
|
|
25
|
+
|
|
26
|
+
/** Show the long repr as the cell's result. */
|
|
27
|
+
function seedLongRepr(store: ReturnType<typeof createStore>, cellId: CellId) {
|
|
28
|
+
MockExecutions.seed(store, [
|
|
29
|
+
MockExecutions.shown(cellId, { mimetype: "text/plain", data: LONG_REPR }),
|
|
30
|
+
]);
|
|
31
|
+
}
|
|
32
|
+
|
|
22
33
|
const createLongReprNotebook = (
|
|
23
34
|
cellId: CellId,
|
|
24
35
|
hideCode = false,
|
|
@@ -45,12 +56,6 @@ LongReprA()`,
|
|
|
45
56
|
cellIds: [cellId],
|
|
46
57
|
cellRuntime: {
|
|
47
58
|
[cellId]: createCellRuntimeState({
|
|
48
|
-
output: {
|
|
49
|
-
channel: "output",
|
|
50
|
-
data: "<dlt.Relation(dataset='jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_jaffle_ingest_dataset_', destination='<dlt.destinations.duckdb(destination_type='duckdb', credentials='local_jaffle.duckdb')>')>",
|
|
51
|
-
mimetype: "text/plain",
|
|
52
|
-
timestamp: 1_686_863_710,
|
|
53
|
-
},
|
|
54
59
|
consoleOutputs: [
|
|
55
60
|
{
|
|
56
61
|
channel: "stdout",
|
|
@@ -60,7 +65,6 @@ LongReprA()`,
|
|
|
60
65
|
},
|
|
61
66
|
],
|
|
62
67
|
debuggerActive: false,
|
|
63
|
-
outline: null,
|
|
64
68
|
}),
|
|
65
69
|
},
|
|
66
70
|
cellHandles: {
|
|
@@ -85,6 +89,7 @@ const EditModeCodeShown = () => {
|
|
|
85
89
|
|
|
86
90
|
const store = createStore();
|
|
87
91
|
store.set(notebookAtom, notebook);
|
|
92
|
+
seedLongRepr(store, cid);
|
|
88
93
|
store.set(connectionAtom, { state: ConnectionState.OPEN });
|
|
89
94
|
store.set(requestClientAtom, resolveRequestClient());
|
|
90
95
|
store.set(showCodeInRunModeAtom, true);
|
|
@@ -113,6 +118,7 @@ const EditModeCodeHidden = () => {
|
|
|
113
118
|
|
|
114
119
|
const store = createStore();
|
|
115
120
|
store.set(notebookAtom, notebook);
|
|
121
|
+
seedLongRepr(store, cid);
|
|
116
122
|
store.set(connectionAtom, { state: ConnectionState.OPEN });
|
|
117
123
|
store.set(requestClientAtom, resolveRequestClient());
|
|
118
124
|
store.set(showCodeInRunModeAtom, true);
|
|
@@ -141,6 +147,7 @@ const ReadModeCodeShown = () => {
|
|
|
141
147
|
|
|
142
148
|
const store = createStore();
|
|
143
149
|
store.set(notebookAtom, notebook);
|
|
150
|
+
seedLongRepr(store, cid);
|
|
144
151
|
store.set(connectionAtom, { state: ConnectionState.OPEN });
|
|
145
152
|
store.set(requestClientAtom, resolveRequestClient());
|
|
146
153
|
store.set(showCodeInRunModeAtom, true);
|
|
@@ -160,6 +167,7 @@ const ReadModeCodeHidden = () => {
|
|
|
160
167
|
|
|
161
168
|
const store = createStore();
|
|
162
169
|
store.set(notebookAtom, notebook);
|
|
170
|
+
seedLongRepr(store, cid);
|
|
163
171
|
store.set(connectionAtom, { state: ConnectionState.OPEN });
|
|
164
172
|
store.set(requestClientAtom, resolveRequestClient());
|
|
165
173
|
store.set(showCodeInRunModeAtom, true);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./worker-D-n8vtGi.js";var t=/* @__PURE__ */ e(((e,t)=>{t.exports={}}));export default t();
|