@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
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
|
|
3
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
4
|
+
import { registerIframeResizer } from "../iframe-resizer";
|
|
5
|
+
|
|
6
|
+
const observe = vi.fn();
|
|
7
|
+
let notifyResize: () => void = vi.fn();
|
|
8
|
+
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
delete window.__resizeIframe;
|
|
11
|
+
document.body.replaceChildren();
|
|
12
|
+
vi.stubGlobal(
|
|
13
|
+
"ResizeObserver",
|
|
14
|
+
class {
|
|
15
|
+
public constructor(callback: () => void) {
|
|
16
|
+
notifyResize = callback;
|
|
17
|
+
}
|
|
18
|
+
public observe = observe;
|
|
19
|
+
},
|
|
20
|
+
);
|
|
21
|
+
registerIframeResizer();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
afterEach(() => {
|
|
25
|
+
delete window.__resizeIframe;
|
|
26
|
+
vi.unstubAllGlobals();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
function createIframe() {
|
|
30
|
+
const iframe = document.createElement("iframe");
|
|
31
|
+
document.body.append(iframe);
|
|
32
|
+
const element = iframe.contentDocument!.documentElement;
|
|
33
|
+
Object.defineProperties(element, {
|
|
34
|
+
scrollHeight: { configurable: true, value: 600 },
|
|
35
|
+
clientHeight: { configurable: true, value: 150 },
|
|
36
|
+
scrollWidth: { configurable: true, value: 300 },
|
|
37
|
+
clientWidth: { configurable: true, value: 300 },
|
|
38
|
+
});
|
|
39
|
+
return { iframe, element };
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
describe("islands iframe resizing", () => {
|
|
43
|
+
it("resizes overflowing content and observes subsequent height changes", () => {
|
|
44
|
+
const { iframe, element } = createIframe();
|
|
45
|
+
|
|
46
|
+
window.__resizeIframe!(iframe);
|
|
47
|
+
|
|
48
|
+
expect(iframe.style.height).toBe("600px");
|
|
49
|
+
expect(observe).toHaveBeenCalledExactlyOnceWith(
|
|
50
|
+
iframe.contentDocument!.body,
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
Object.defineProperty(element, "scrollHeight", { value: 900 });
|
|
54
|
+
notifyResize();
|
|
55
|
+
expect(iframe.style.height).toBe("900px");
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it("allows space for a horizontal scrollbar", () => {
|
|
59
|
+
const { iframe, element } = createIframe();
|
|
60
|
+
Object.defineProperty(element, "scrollWidth", { value: 500 });
|
|
61
|
+
|
|
62
|
+
window.__resizeIframe!(iframe);
|
|
63
|
+
|
|
64
|
+
expect(iframe.style.height).toBe("620px");
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it("preserves the height when there is no vertical overflow", () => {
|
|
68
|
+
const { iframe, element } = createIframe();
|
|
69
|
+
Object.defineProperty(element, "scrollHeight", { value: 150 });
|
|
70
|
+
iframe.style.height = "150px";
|
|
71
|
+
|
|
72
|
+
window.__resizeIframe!(iframe);
|
|
73
|
+
|
|
74
|
+
expect(iframe.style.height).toBe("150px");
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it("ignores an iframe whose content window is not ready", () => {
|
|
78
|
+
const iframe = document.createElement("iframe");
|
|
79
|
+
|
|
80
|
+
expect(() => window.__resizeIframe!(iframe)).not.toThrow();
|
|
81
|
+
expect(observe).not.toHaveBeenCalled();
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it("keeps the same handler across repeated registration", () => {
|
|
85
|
+
const handler = window.__resizeIframe;
|
|
86
|
+
|
|
87
|
+
registerIframeResizer();
|
|
88
|
+
|
|
89
|
+
expect(window.__resizeIframe).toBe(handler);
|
|
90
|
+
});
|
|
91
|
+
});
|
|
@@ -38,6 +38,7 @@ async function importMain(): Promise<typeof MainModule> {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
beforeEach(() => {
|
|
41
|
+
delete window.__resizeIframe;
|
|
41
42
|
document.body.replaceChildren();
|
|
42
43
|
mockInitializeApps.mockClear();
|
|
43
44
|
mockStopSession.mockClear();
|
|
@@ -47,6 +48,22 @@ beforeEach(() => {
|
|
|
47
48
|
});
|
|
48
49
|
|
|
49
50
|
describe("islands public API surface", () => {
|
|
51
|
+
it("registers the iframe load handler even without interactive islands", async () => {
|
|
52
|
+
await importMain();
|
|
53
|
+
|
|
54
|
+
expect(window.__resizeIframe).toBeTypeOf("function");
|
|
55
|
+
expect(mockInitializeIslands).not.toHaveBeenCalled();
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it("preserves a host-provided iframe load handler", async () => {
|
|
59
|
+
const hostResizeIframe = vi.fn();
|
|
60
|
+
window.__resizeIframe = hostResizeIframe;
|
|
61
|
+
|
|
62
|
+
await importMain();
|
|
63
|
+
|
|
64
|
+
expect(window.__resizeIframe).toBe(hostResizeIframe);
|
|
65
|
+
});
|
|
66
|
+
|
|
50
67
|
it("exposes a stable set of exports and signatures", async () => {
|
|
51
68
|
const mod = await importMain();
|
|
52
69
|
const surface = Object.fromEntries(
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
vi,
|
|
13
13
|
} from "vitest";
|
|
14
14
|
import { cellId } from "@/__tests__/branded";
|
|
15
|
+
import { MockExecutions } from "@/__mocks__/executions";
|
|
15
16
|
import { MockNotebook } from "@/__mocks__/notebook";
|
|
16
17
|
import { MockRequestClient } from "@/__mocks__/requests";
|
|
17
18
|
import { notebookAtom } from "@/core/cells/cells";
|
|
@@ -249,21 +250,18 @@ function setNotebook(id: string, output?: string): void {
|
|
|
249
250
|
const runtimeCellId = cellId(id);
|
|
250
251
|
store.set(
|
|
251
252
|
notebookAtom,
|
|
252
|
-
MockNotebook.notebookState({
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
}
|
|
265
|
-
: undefined,
|
|
266
|
-
}),
|
|
253
|
+
MockNotebook.notebookState({ cellData: { [runtimeCellId]: {} } }),
|
|
254
|
+
);
|
|
255
|
+
MockExecutions.seed(
|
|
256
|
+
store,
|
|
257
|
+
output === undefined
|
|
258
|
+
? []
|
|
259
|
+
: [
|
|
260
|
+
MockExecutions.shown(runtimeCellId, {
|
|
261
|
+
mimetype: "text/html",
|
|
262
|
+
data: `<div>${output}</div>`,
|
|
263
|
+
}),
|
|
264
|
+
],
|
|
267
265
|
);
|
|
268
266
|
}
|
|
269
267
|
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
2
|
|
|
3
3
|
import { useAtomValue } from "jotai";
|
|
4
|
-
import { selectAtom } from "jotai/utils";
|
|
5
4
|
import { Loader2Icon } from "lucide-react";
|
|
6
|
-
import React, {
|
|
7
|
-
type PropsWithChildren,
|
|
8
|
-
useCallback,
|
|
9
|
-
useEffect,
|
|
10
|
-
useRef,
|
|
11
|
-
} from "react";
|
|
5
|
+
import React, { type PropsWithChildren, useEffect, useRef } from "react";
|
|
12
6
|
import { OutputRenderer } from "@/components/editor/Output";
|
|
13
|
-
import { type NotebookState, notebookAtom } from "@/core/cells/cells";
|
|
14
7
|
import type { CellId } from "@/core/cells/ids";
|
|
15
8
|
import { isOutputEmpty } from "@/core/cells/outputs";
|
|
16
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
type CellRunStatus,
|
|
11
|
+
useCellExecution,
|
|
12
|
+
useCellHasResult,
|
|
13
|
+
useCellOutput,
|
|
14
|
+
} from "@/core/executions";
|
|
17
15
|
import { ISLAND_TAG_NAMES } from "../constants";
|
|
18
16
|
import { islandsHydratedAtom } from "../state";
|
|
19
17
|
import { IslandControls } from "./IslandControls";
|
|
@@ -60,11 +58,8 @@ export const MarimoOutputWrapper: React.FC<MarimoOutputWrapperProps> = ({
|
|
|
60
58
|
}) => {
|
|
61
59
|
const controlsVisible = useIslandControls(alwaysShowRun);
|
|
62
60
|
const wrapperRef = useRef<HTMLDivElement>(null);
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
[cellId],
|
|
66
|
-
);
|
|
67
|
-
const runtime = useAtomValue(selectAtom(notebookAtom, selector));
|
|
61
|
+
const output = useCellOutput(cellId);
|
|
62
|
+
const hasResult = useCellHasResult(cellId);
|
|
68
63
|
const isHydrated = useAtomValue(islandsHydratedAtom);
|
|
69
64
|
|
|
70
65
|
// Sync cell status to the host <marimo-island> element as a data attribute
|
|
@@ -72,9 +67,9 @@ export const MarimoOutputWrapper: React.FC<MarimoOutputWrapperProps> = ({
|
|
|
72
67
|
const { status } = useCellExecution(cellId);
|
|
73
68
|
useSyncStatusToIsland(wrapperRef, status);
|
|
74
69
|
|
|
75
|
-
//
|
|
76
|
-
//
|
|
77
|
-
if (!isHydrated || !
|
|
70
|
+
// Show the static content until the cell has run here. Keep it mounted
|
|
71
|
+
// while the initial run is pending.
|
|
72
|
+
if (!isHydrated || (output === null && !hasResult)) {
|
|
78
73
|
return (
|
|
79
74
|
<div ref={wrapperRef} className="relative min-h-6 empty:hidden">
|
|
80
75
|
{children}
|
|
@@ -82,14 +77,14 @@ export const MarimoOutputWrapper: React.FC<MarimoOutputWrapperProps> = ({
|
|
|
82
77
|
);
|
|
83
78
|
}
|
|
84
79
|
|
|
85
|
-
//
|
|
86
|
-
if (isOutputEmpty(
|
|
80
|
+
// The cell ran and shows nothing, so the static content is out of date.
|
|
81
|
+
if (output === null || isOutputEmpty(output)) {
|
|
87
82
|
return <div ref={wrapperRef} />;
|
|
88
83
|
}
|
|
89
84
|
|
|
90
85
|
return (
|
|
91
86
|
<div ref={wrapperRef} className="relative min-h-6">
|
|
92
|
-
<OutputRenderer message={
|
|
87
|
+
<OutputRenderer message={output} />
|
|
93
88
|
<RunningIndicator status={status} />
|
|
94
89
|
<IslandControls
|
|
95
90
|
cellId={cellId}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
|
|
3
|
+
declare global {
|
|
4
|
+
interface Window {
|
|
5
|
+
__resizeIframe?: (iframe: HTMLIFrameElement) => void;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// Match the inline helper in frontend/index.html, which islands do not load.
|
|
10
|
+
function resizeIframe(iframe: HTMLIFrameElement): void {
|
|
11
|
+
const scrollbarHeight = 20;
|
|
12
|
+
|
|
13
|
+
function setHeight() {
|
|
14
|
+
const element = iframe.contentWindow?.document?.documentElement;
|
|
15
|
+
if (!element || element.scrollHeight === element.clientHeight) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const hasHorizontalScrollbar = element.scrollWidth > element.clientWidth;
|
|
20
|
+
const newHeight =
|
|
21
|
+
element.scrollHeight + (hasHorizontalScrollbar ? scrollbarHeight : 0);
|
|
22
|
+
if (iframe.style.height !== `${newHeight}px`) {
|
|
23
|
+
iframe.style.height = `${newHeight}px`;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
setHeight();
|
|
28
|
+
|
|
29
|
+
const resizeObserver = new ResizeObserver(setHeight);
|
|
30
|
+
const body = iframe.contentWindow?.document?.body;
|
|
31
|
+
if (body) {
|
|
32
|
+
resizeObserver.observe(body);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function registerIframeResizer(): void {
|
|
37
|
+
window.__resizeIframe ??= resizeIframe;
|
|
38
|
+
}
|
package/src/core/islands/main.ts
CHANGED
|
@@ -16,8 +16,11 @@ import { Logger } from "@/utils/Logger";
|
|
|
16
16
|
import { initializeIslands } from "./bootstrap";
|
|
17
17
|
import { getGlobalBridge } from "./bridge";
|
|
18
18
|
import { ISLAND_CSS_CLASSES, ISLAND_TAG_NAMES } from "./constants";
|
|
19
|
+
import { registerIframeResizer } from "./iframe-resizer";
|
|
19
20
|
import { parseMarimoIslandApps } from "./parse";
|
|
20
21
|
|
|
22
|
+
registerIframeResizer();
|
|
23
|
+
|
|
21
24
|
const bridge = getGlobalBridge();
|
|
22
25
|
let bootstrapPromise: Promise<void> | undefined;
|
|
23
26
|
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
2
|
|
|
3
3
|
import { atom } from "jotai";
|
|
4
|
-
import {
|
|
4
|
+
import { cellIdsAtom, hasCellsAtom } from "../cells/cells";
|
|
5
5
|
import { isOutputEmpty } from "../cells/outputs";
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
cellOutputAtom,
|
|
8
|
+
notebookQueuedOrRunningCountAtom,
|
|
9
|
+
} from "../executions";
|
|
7
10
|
import { KnownQueryParams } from "../constants";
|
|
8
11
|
import { showCodeInRunModeAtom } from "../meta/state";
|
|
9
12
|
import { type AppMode, initialModeAtom } from "../mode";
|
|
@@ -80,8 +83,8 @@ function computeRenderPolicy(input: {
|
|
|
80
83
|
* update.
|
|
81
84
|
*/
|
|
82
85
|
const hasCachedOutputsAtom = atom((get) =>
|
|
83
|
-
|
|
84
|
-
(
|
|
86
|
+
get(cellIdsAtom).some(
|
|
87
|
+
(cellId) => !isOutputEmpty(get(cellOutputAtom(cellId))),
|
|
85
88
|
),
|
|
86
89
|
);
|
|
87
90
|
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
|
|
3
|
+
import { afterEach, expect, it, vi } from "vitest";
|
|
4
|
+
import { listProviderModels } from "../ai";
|
|
5
|
+
|
|
6
|
+
vi.mock("@/core/runtime/config", () => ({
|
|
7
|
+
getRuntimeManager: () => ({
|
|
8
|
+
httpURL: new URL("https://notebook.example.com/nested/"),
|
|
9
|
+
headers: () => ({ "Marimo-Session-Id": "session" }),
|
|
10
|
+
}),
|
|
11
|
+
}));
|
|
12
|
+
|
|
13
|
+
afterEach(() => vi.unstubAllGlobals());
|
|
14
|
+
|
|
15
|
+
it.each([
|
|
16
|
+
["gateway", "gateway"],
|
|
17
|
+
["gateway?tenant", "gateway%3Ftenant"],
|
|
18
|
+
["gateway#tenant", "gateway%23tenant"],
|
|
19
|
+
])(
|
|
20
|
+
"encodes %s while preserving runtime URL prefix and session headers",
|
|
21
|
+
async (provider, encodedProvider) => {
|
|
22
|
+
const catalog = { models: [{ id: "model", name: "Model" }] };
|
|
23
|
+
const fetch = vi
|
|
24
|
+
.fn<(request: Request) => Promise<Response>>()
|
|
25
|
+
.mockResolvedValue(Response.json(catalog));
|
|
26
|
+
vi.stubGlobal("fetch", fetch);
|
|
27
|
+
|
|
28
|
+
await expect(listProviderModels(provider)).resolves.toEqual(catalog);
|
|
29
|
+
expect(fetch).toHaveBeenCalledOnce();
|
|
30
|
+
const [request] = fetch.mock.calls[0];
|
|
31
|
+
expect({
|
|
32
|
+
method: request.method,
|
|
33
|
+
url: request.url,
|
|
34
|
+
session: request.headers.get("Marimo-Session-Id"),
|
|
35
|
+
}).toEqual({
|
|
36
|
+
method: "GET",
|
|
37
|
+
url: `https://notebook.example.com/nested/api/ai/models/${encodedProvider}`,
|
|
38
|
+
session: "session",
|
|
39
|
+
});
|
|
40
|
+
},
|
|
41
|
+
);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
|
|
3
|
+
import { getRuntimeManager } from "../runtime/config";
|
|
4
|
+
import { API, createClientWithRuntimeManager } from "./api";
|
|
5
|
+
|
|
6
|
+
export function listProviderModels(provider: string) {
|
|
7
|
+
return createClientWithRuntimeManager(getRuntimeManager())
|
|
8
|
+
.GET("/api/ai/models/{provider_name}", {
|
|
9
|
+
params: { path: { provider_name: encodeURIComponent(provider) } },
|
|
10
|
+
})
|
|
11
|
+
.then(API.handleResponse);
|
|
12
|
+
}
|
|
@@ -188,6 +188,25 @@ describe("NotebookReplica lifetime", () => {
|
|
|
188
188
|
expect(store.get(client.notebookAtom)?.id).toBe("n2");
|
|
189
189
|
});
|
|
190
190
|
|
|
191
|
+
it("preserves output revisions across an unchanged replacement snapshot", async () => {
|
|
192
|
+
const { connect, opened, client, store } = setup();
|
|
193
|
+
connect(lifetime().signal);
|
|
194
|
+
const { receive } = await opened();
|
|
195
|
+
const snapshot = fixtureMessages("notebook-events.sse");
|
|
196
|
+
snapshot.forEach(receive);
|
|
197
|
+
const before = store.get(client.executionsAtom);
|
|
198
|
+
expect(
|
|
199
|
+
[...before.executions.values()].some(
|
|
200
|
+
(execution) => execution.outputVersion > 0,
|
|
201
|
+
),
|
|
202
|
+
).toBe(true);
|
|
203
|
+
|
|
204
|
+
receive({ event: "reset", data: {} });
|
|
205
|
+
snapshot.filter((event) => event.event !== "ready").forEach(receive);
|
|
206
|
+
receive({ event: "ready", id: "98", data: {} });
|
|
207
|
+
expect(store.get(client.executionsAtom)).toEqual(before);
|
|
208
|
+
});
|
|
209
|
+
|
|
191
210
|
it("keeps what is on show when the snapshot replacing it is interrupted", async () => {
|
|
192
211
|
vi.useFakeTimers();
|
|
193
212
|
const { connect, opened, client, store } = setup();
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
import { describe, expect, it } from "vitest";
|
|
4
4
|
import * as Protocol from "@marimo-team/client/protocol";
|
|
5
|
-
import {
|
|
5
|
+
import { executions } from "../resources/executions";
|
|
6
6
|
import { createNotebookReducer } from "@marimo-team/client";
|
|
7
7
|
import { fixtureEvents } from "./fixtures";
|
|
8
8
|
|
|
9
|
-
const reducer = createNotebookReducer({
|
|
9
|
+
const reducer = createNotebookReducer({ executions });
|
|
10
10
|
const snapshot = fixtureEvents("notebook-events.sse");
|
|
11
11
|
const runCells = fixtureEvents("run-cells.sse");
|
|
12
12
|
const time = "2026-10-01T09:30:00Z";
|
|
@@ -18,7 +18,8 @@ function replay(
|
|
|
18
18
|
return events.reduce(reducer.reduce, from);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
const resource = (state: ReturnType<typeof replay>) =>
|
|
21
|
+
const resource = (state: ReturnType<typeof replay>) =>
|
|
22
|
+
state.resources.executions.results;
|
|
22
23
|
|
|
23
24
|
/** Build one event as the stream would deliver it. */
|
|
24
25
|
const event = (message: unknown) => Protocol.Event.parse(message);
|
|
@@ -47,7 +48,7 @@ const restored = {
|
|
|
47
48
|
completed_at: "2026-09-30T09:20:02Z",
|
|
48
49
|
};
|
|
49
50
|
|
|
50
|
-
describe("results
|
|
51
|
+
describe("retained results", () => {
|
|
51
52
|
it("has an entry per document cell, filled by a restored result", () => {
|
|
52
53
|
const ready = snapshot.findIndex((item) => item.event === "ready");
|
|
53
54
|
const opening = resource(replay(snapshot.slice(0, ready + 1)));
|
|
@@ -64,8 +65,8 @@ describe("results resource", () => {
|
|
|
64
65
|
...snapshot.slice(ready),
|
|
65
66
|
]),
|
|
66
67
|
);
|
|
67
|
-
expect(opened.get("c3")?.id).toBe("e-restored");
|
|
68
|
-
expect(opened.get("c3")?.run_id).toBeNull();
|
|
68
|
+
expect(opened.get("c3")?.record.id).toBe("e-restored");
|
|
69
|
+
expect(opened.get("c3")?.record.run_id).toBeNull();
|
|
69
70
|
});
|
|
70
71
|
|
|
71
72
|
it("records a cell's result when its execution completes", () => {
|
|
@@ -75,14 +76,42 @@ describe("results resource", () => {
|
|
|
75
76
|
expect(running.get("k7f2")).toBeNull();
|
|
76
77
|
|
|
77
78
|
const done = resource(replay(runCells, start));
|
|
78
|
-
expect(done.get("c3")?.id).toBe("e12");
|
|
79
|
-
expect(done.get("c3")?.status).toBe("completed");
|
|
80
|
-
expect(done.get("k7f2")?.depends_on).toEqual({
|
|
79
|
+
expect(done.get("c3")?.record.id).toBe("e12");
|
|
80
|
+
expect(done.get("c3")?.record.status).toBe("completed");
|
|
81
|
+
expect(done.get("k7f2")?.record.depends_on).toEqual({
|
|
81
82
|
x: { execution: "e12", update: 0 },
|
|
82
83
|
});
|
|
83
84
|
expect(done.get("c1")).toBeNull();
|
|
84
85
|
});
|
|
85
86
|
|
|
87
|
+
it("keeps a result when the attempt that replaced it was superseded", () => {
|
|
88
|
+
const done = replay(runCells, replay(snapshot));
|
|
89
|
+
const result = resource(done).get("c3")!;
|
|
90
|
+
const superseded = reducer.reduce(
|
|
91
|
+
replay(retire("e12", "e12-x"), done),
|
|
92
|
+
event({
|
|
93
|
+
event: "execution",
|
|
94
|
+
id: "113",
|
|
95
|
+
data: {
|
|
96
|
+
execution: {
|
|
97
|
+
...result.record,
|
|
98
|
+
id: "e14",
|
|
99
|
+
run_id: "run-again",
|
|
100
|
+
started_at: null,
|
|
101
|
+
completed_at: time,
|
|
102
|
+
outcome: {
|
|
103
|
+
kind: "skipped",
|
|
104
|
+
reason: "superseded",
|
|
105
|
+
message: "Replaced by a newer execution",
|
|
106
|
+
related: [],
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
}),
|
|
111
|
+
);
|
|
112
|
+
expect(resource(superseded).get("c3")).toBe(result);
|
|
113
|
+
});
|
|
114
|
+
|
|
86
115
|
it("keeps a result while the host replaces it", () => {
|
|
87
116
|
const done = replay(runCells, replay(snapshot));
|
|
88
117
|
const result = resource(done).get("c3")!;
|
|
@@ -90,7 +119,7 @@ describe("results resource", () => {
|
|
|
90
119
|
expect(resource(retired).get("c3")).toBe(result);
|
|
91
120
|
|
|
92
121
|
const again = {
|
|
93
|
-
...result,
|
|
122
|
+
...result.record,
|
|
94
123
|
id: "e14",
|
|
95
124
|
run_id: "run-again",
|
|
96
125
|
status: "queued",
|
|
@@ -120,14 +149,14 @@ describe("results resource", () => {
|
|
|
120
149
|
},
|
|
121
150
|
}),
|
|
122
151
|
);
|
|
123
|
-
expect(resource(completed).get("c3")?.id).toBe("e14");
|
|
152
|
+
expect(resource(completed).get("c3")?.record.id).toBe("e14");
|
|
124
153
|
});
|
|
125
154
|
|
|
126
155
|
it("replaces a result with an execution interrupted before it started", () => {
|
|
127
156
|
const done = replay(runCells, replay(snapshot));
|
|
128
157
|
const result = resource(done).get("c3")!;
|
|
129
158
|
const interrupted = {
|
|
130
|
-
...result,
|
|
159
|
+
...result.record,
|
|
131
160
|
id: "e14",
|
|
132
161
|
run_id: "run-again",
|
|
133
162
|
status: "completed",
|
|
@@ -158,7 +187,7 @@ describe("results resource", () => {
|
|
|
158
187
|
],
|
|
159
188
|
done,
|
|
160
189
|
);
|
|
161
|
-
expect(resource(cancelled).get("c3")?.outcome).toEqual({
|
|
190
|
+
expect(resource(cancelled).get("c3")?.record.outcome).toEqual({
|
|
162
191
|
kind: "interrupted",
|
|
163
192
|
});
|
|
164
193
|
});
|
|
@@ -170,7 +199,7 @@ describe("results resource", () => {
|
|
|
170
199
|
|
|
171
200
|
const finished = replay(runCells.slice(5), deleted);
|
|
172
201
|
expect(resource(finished).has("c3")).toBe(false);
|
|
173
|
-
expect(resource(finished).get("k7f2")?.id).toBe("e13");
|
|
202
|
+
expect(resource(finished).get("k7f2")?.record.id).toBe("e13");
|
|
174
203
|
});
|
|
175
204
|
|
|
176
205
|
it("ignores cells it has not seen and clears on reset", () => {
|
|
@@ -183,11 +212,11 @@ describe("results resource", () => {
|
|
|
183
212
|
data: { execution: { ...restored, id: "e-zz", cell_id: "zz" } },
|
|
184
213
|
}),
|
|
185
214
|
);
|
|
186
|
-
expect(unknown
|
|
215
|
+
expect(resource(unknown)).toBe(resource(start));
|
|
187
216
|
const reset = reducer.reduce(replay(runCells, start), {
|
|
188
217
|
event: "reset",
|
|
189
218
|
data: {},
|
|
190
219
|
});
|
|
191
|
-
expect(resource(reset)).toBe(
|
|
220
|
+
expect(resource(reset)).toBe(executions.initial.results);
|
|
192
221
|
});
|
|
193
222
|
});
|
|
@@ -24,8 +24,12 @@ import {
|
|
|
24
24
|
} from "./connection";
|
|
25
25
|
import { attachments } from "./resources/attachments";
|
|
26
26
|
import { type Document, document } from "./resources/document";
|
|
27
|
-
import {
|
|
28
|
-
|
|
27
|
+
import {
|
|
28
|
+
type Executions,
|
|
29
|
+
executions,
|
|
30
|
+
resumeResults,
|
|
31
|
+
} from "./resources/executions";
|
|
32
|
+
import type { Results } from "./resources/results";
|
|
29
33
|
import { runtime } from "./resources/runtime";
|
|
30
34
|
|
|
31
35
|
/**
|
|
@@ -162,7 +166,6 @@ export function createNotebookReplica(
|
|
|
162
166
|
attachments,
|
|
163
167
|
runtime,
|
|
164
168
|
executions,
|
|
165
|
-
results,
|
|
166
169
|
});
|
|
167
170
|
type Stream = typeof reducer.initial;
|
|
168
171
|
/**
|
|
@@ -205,7 +208,7 @@ export function createNotebookReplica(
|
|
|
205
208
|
get(presentAtom) ? get(streamAtom).resources.runtime : null,
|
|
206
209
|
);
|
|
207
210
|
const executionsAtom = atom((get) => get(shownAtom).resources.executions);
|
|
208
|
-
const resultsAtom = atom((get) => get(
|
|
211
|
+
const resultsAtom = atom((get) => get(executionsAtom).results);
|
|
209
212
|
const backendAtom = atom<NotebookBackend | null>(null);
|
|
210
213
|
/** The connection this replica follows. Connecting again ends it. */
|
|
211
214
|
let current: { end(): void; reconnect(): Promise<void> } | undefined;
|
|
@@ -218,6 +221,18 @@ export function createNotebookReplica(
|
|
|
218
221
|
return followed;
|
|
219
222
|
}
|
|
220
223
|
if (next.phase !== "snapshot") {
|
|
224
|
+
if (retained !== null && retained.notebook?.id === next.notebook?.id) {
|
|
225
|
+
next = {
|
|
226
|
+
...next,
|
|
227
|
+
resources: {
|
|
228
|
+
...next.resources,
|
|
229
|
+
executions: resumeResults(
|
|
230
|
+
next.resources.executions,
|
|
231
|
+
retained.resources.executions,
|
|
232
|
+
),
|
|
233
|
+
},
|
|
234
|
+
};
|
|
235
|
+
}
|
|
221
236
|
return { stream: next, retained: null };
|
|
222
237
|
}
|
|
223
238
|
return {
|