@marimo-team/islands 0.25.2-dev99 → 0.25.3-dev10
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-BZmqc_F0.js → ConnectedDataExplorerComponent-CNMliVzw.js} +15 -15
- package/dist/{ErrorBoundary-CXkr_IcB.js → ErrorBoundary-BsqSMK9Y.js} +12 -12
- package/dist/{ImageComparisonComponent-Cpfz30OZ.js → ImageComparisonComponent-uU8FSKZE.js} +3 -3
- package/dist/{Plot-CTyjbQDT.js → Plot-DdYOe1UK.js} +2 -2
- package/dist/{abnfDiagram-VCTEODGH-C_Lmaa2j.js → abnfDiagram-VCTEODGH-D-Ez91gV.js} +3 -3
- package/dist/{any-language-editor-BFzqhOBR.js → any-language-editor-DZ_YTVus.js} +7 -7
- package/dist/{architectureDiagram-5GKGNRK7-BKMataHB.js → architectureDiagram-5GKGNRK7-CTpcNtO8.js} +5 -5
- package/dist/assets/__vite-browser-external-BXYkiFsk.js +1 -0
- package/dist/assets/worker-HPY9fbhz.js +114 -0
- package/dist/{blockDiagram-I7D4REHJ-BeHOjyDk.js → blockDiagram-I7D4REHJ-Cg25UrxT.js} +9 -9
- package/dist/{button-BtsM2UqM.js → button-CvjkwdSk.js} +5 -5
- package/dist/{c4Diagram-7LVT6UL2-Bao10t_O.js → c4Diagram-7LVT6UL2-BxFgrnNV.js} +7 -7
- package/dist/{capabilities-A5jrzjCJ.js → capabilities-CQ5IjhzL.js} +1 -1
- package/dist/{channel-BxCkvUgE.js → channel-CPObtJXj.js} +1 -1
- package/dist/{chat-ui-CwOWzoSO.js → chat-ui-0lKdOoQ3.js} +1588 -1396
- package/dist/{check-CNP79M3A.js → check-EDwSwP89.js} +1 -1
- package/dist/{chunk-4HAMMTFA-CH7Gpamd.js → chunk-4HAMMTFA-D4eFPyFh.js} +5 -5
- package/dist/{chunk-75Z2AOVW-AI7CvgKn.js → chunk-75Z2AOVW-D7gxIs2Q.js} +1 -1
- package/dist/{chunk-DU6HZSFF-BSvuTkX4.js → chunk-DU6HZSFF-BwiyaNpg.js} +1 -1
- package/dist/{chunk-F27PBJKO-CLshwT9T.js → chunk-F27PBJKO-ufseIn5y.js} +1 -1
- package/dist/{chunk-GMAD6QVW-wnHcn-lH.js → chunk-GMAD6QVW-BhaJx0X3.js} +3 -3
- package/dist/{chunk-GVQU2GXP-7O2p8hut.js → chunk-GVQU2GXP-Cwbt-lF0.js} +2 -2
- package/dist/{chunk-IMKFNOWR-Bu0Vh_Yi.js → chunk-IMKFNOWR-DGxi-zeo.js} +5 -5
- package/dist/{chunk-L3NEJ4N5-B9_Alrxb.js → chunk-L3NEJ4N5-n-zgIVSy.js} +5 -5
- package/dist/{chunk-OSK3NFVY-PeQPH2fD.js → chunk-OSK3NFVY-DXa-Cxbn.js} +6 -6
- package/dist/{chunk-P2QGCYS3-D9twiFuU.js → chunk-P2QGCYS3-B_Zd3-X0.js} +1 -1
- package/dist/{chunk-POPQ4Y6H-BUiNs18s.js → chunk-POPQ4Y6H-hYOXbYH_.js} +1 -1
- package/dist/{chunk-PWAF6VOD-D8S9NPCy.js → chunk-PWAF6VOD-CQw5qATZ.js} +1 -1
- package/dist/{chunk-SHT3W25Y-B2dyNZ31.js → chunk-SHT3W25Y-CV9J3rAB.js} +7 -7
- package/dist/{chunk-SVP7TREG-D7UPvB10.js → chunk-SVP7TREG-BL-9Fqgg.js} +2 -2
- package/dist/{chunk-TICWLB2K-BNaGoadd.js → chunk-TICWLB2K-Cu_XMjDM.js} +5 -5
- package/dist/{chunk-YOKDWASO-DrWbKnxA.js → chunk-YOKDWASO-DPZk8vhS.js} +6 -6
- package/dist/classDiagram-ZZMXUADV-BXXV13Hq.js +30 -0
- package/dist/classDiagram-v2-VYDZK3BY-B7FXJ1Cp.js +30 -0
- package/dist/{code-visibility-pPjYsRTH.js → code-visibility-CXQvUXHT.js} +18 -18
- package/dist/{common-CkvBp0B4.js → common-CuD-CAC-.js} +6128 -7136
- package/dist/{compiler-runtime-Cj8ZWiNS.js → compiler-runtime-CldRdSsv.js} +2 -2
- package/dist/{copy-icon-BY7jgcaV.js → copy-icon-Ft7t9bqz.js} +6 -6
- package/dist/{cynefinDiagram-5FMLGOSQ-CCDn4Z9e.js → cynefinDiagram-5FMLGOSQ-CH96rwba.js} +3 -3
- package/dist/{dagre-GXQ25YYZ-BJiUO_SV.js → dagre-GXQ25YYZ-BD3PmpFY.js} +10 -10
- package/dist/{data-grid-overlay-editor-L6ELxFAh.js → data-grid-overlay-editor-DgeyYmC1.js} +7 -7
- package/dist/{data-grid-types-BucVmDDp.js → data-grid-types-BH_r7g7l.js} +1 -1
- package/dist/{diagram-S7CK7UJ4-BZfxFNRR.js → diagram-S7CK7UJ4-BsSJJldB.js} +4 -4
- package/dist/{diagram-UQ7AKVKN-1xcsiIMg.js → diagram-UQ7AKVKN-muQtNZc4.js} +3 -3
- package/dist/{diagram-VSXAHHWV-DPAWJ9Nw.js → diagram-VSXAHHWV-BJWcVVJY.js} +2 -2
- package/dist/{diagram-VX7I27RA-DmRsnHYY.js → diagram-VX7I27RA-CdhuZAqR.js} +5 -5
- package/dist/{diagram-Z3DM3KII--b49ryKx.js → diagram-Z3DM3KII-BD8mXjOj.js} +3 -3
- package/dist/{dialog-CmExhUDI.js → dialog-CEBFZNyc.js} +6 -6
- package/dist/{dist-CcyKTBTF.js → dist-DpBpA_n1.js} +2 -2
- package/dist/{dropdown-menu-Cz4TdOJh.js → dropdown-menu-CP_qCYHC.js} +139 -139
- package/dist/{ebnfDiagram-PWID7BFC-rSwVyh4y.js → ebnfDiagram-PWID7BFC-BIN1sweE.js} +3 -3
- package/dist/{erDiagram-RLTQ6QDP-Bfd3iAoC.js → erDiagram-RLTQ6QDP-Ctp5cfoN.js} +12 -12
- package/dist/{error-banner-D30nA9nE.js → error-banner-D-WCIiMt.js} +16 -11
- package/dist/{cells-DZi0ioak.js → error-entries-DSvFWT_M.js} +6171 -5075
- package/dist/{esm-DAVrGVKP.js → esm-AMFssoNp.js} +4 -4
- package/dist/{feedback-button-D-pV0Qji.js → feedback-button-DZMj9PF3.js} +119 -120
- package/dist/flowDiagram-HODETNUW-3EfLrlFb.js +16 -0
- package/dist/{formats-DhhbdyAH.js → formats-CeOmU1MU.js} +6 -6
- package/dist/{ganttDiagram-EL5Y4UJY-B4m_YsKa.js → ganttDiagram-EL5Y4UJY-BQT16JSc.js} +2 -2
- package/dist/{gitGraphDiagram-WWUBYQGX-QRBbvWXh.js → gitGraphDiagram-WWUBYQGX-D5nSIzdE.js} +2 -2
- package/dist/{glide-data-editor-D6CfYwdr.js → glide-data-editor-g_L8FLAC.js} +60 -60
- package/dist/{glide-utils-BVJ4fkxX.js → glide-utils-DJyqh0EM.js} +4 -4
- package/dist/{globals-BwK9YGrX.js → globals-CYGlmBXb.js} +3 -3
- package/dist/{highlighted-body-KPVGNVTW-Ad3MKZ18.js → highlighted-body-KPVGNVTW-zwjq21tf.js} +4 -4
- package/dist/{html-to-image-Cn1_16-x.js → html-to-image-B8s5SgGm.js} +37 -37
- package/dist/{infoDiagram-27XIBGKW-DVQFYvhg.js → infoDiagram-27XIBGKW-DipQoHxl.js} +2 -2
- package/dist/{ishikawaDiagram-5VMMS53U-viPND-nm.js → ishikawaDiagram-5VMMS53U-DgFMjSGz.js} +3 -3
- package/dist/{journeyDiagram-3NMN7TZE-BeeJdJo3.js → journeyDiagram-3NMN7TZE-BaLqn-dZ.js} +2 -2
- package/dist/{jsx-runtime-DgDPJV9S.js → jsx-runtime-3BD1kT0s.js} +1 -1
- package/dist/{kanban-definition-UXKFOSKX-Dcl_ECO9.js → kanban-definition-UXKFOSKX-w1ACVjgl.js} +9 -9
- package/dist/{katex-BNCmKUol.js → katex-BIdZGsyO.js} +141 -116
- package/dist/{label-DQO1jFjf.js → label-BDKF3Afc.js} +10 -10
- package/dist/{loader-Cm-ATtou.js → loader-BQOfjTIJ.js} +1 -1
- package/dist/main.js +623 -590
- package/dist/{mermaid-BfhcnSj-.js → mermaid-CHo49Yv-.js} +56 -56
- package/dist/mermaid-HWGCJPDP-ByCsZnYF.js +2 -0
- package/dist/{mhchem-BEc7A1or.js → mhchem-CdWPJK6g.js} +1 -1
- package/dist/{mindmap-definition-YA3MSWOX-BdxxhF-5.js → mindmap-definition-YA3MSWOX-CrT0KSfX.js} +11 -11
- package/dist/{number-overlay-editor-tMylyldi.js → number-overlay-editor-9VRv-pdj.js} +5 -5
- package/dist/{pegDiagram-XKGWAZYB-Du5p2s0w.js → pegDiagram-XKGWAZYB-BqvywNJA.js} +3 -3
- package/dist/{pieDiagram-E7YTZNPT-DJg-SOIq.js → pieDiagram-E7YTZNPT-BfxJ_XCc.js} +3 -3
- package/dist/{process-output-CUG57KRp.js → process-output-CKRXyszb.js} +5 -5
- package/dist/{quadrantDiagram-AXDQQJYC-keLfFx9f.js → quadrantDiagram-AXDQQJYC-Ccw0xMjN.js} +1 -1
- package/dist/{railroadDiagram-O6MQD6OU-C0ojm-6_.js → railroadDiagram-O6MQD6OU-8vFLVTPu.js} +3 -3
- package/dist/{react-dom-BUgJ-ab_.js → react-dom-DUmH0GXv.js} +29 -21
- package/dist/{react-ofJbxM4x.js → react-sHtZdjeP.js} +103 -94
- package/dist/{react-vega-ewj7q_U5.js → react-vega-BED0DjiB.js} +3 -3
- package/dist/{requirementDiagram-BXWQKSXE-CNwNBmI3.js → requirementDiagram-BXWQKSXE-a_MxGvxe.js} +11 -11
- package/dist/{reveal-component-LXUMcqWX.js → reveal-component-C87mv9Mn.js} +906 -878
- package/dist/{sankeyDiagram-P5KCCOFB-Bh4EsJox.js → sankeyDiagram-P5KCCOFB-ELvOcnZH.js} +1 -1
- package/dist/{select-Bs-nmvm6.js → select-BButFi-d.js} +11 -11
- package/dist/{sequenceDiagram-WJ2MYXX4-DQaW5qBG.js → sequenceDiagram-WJ2MYXX4-CXFMnxGh.js} +4 -4
- package/dist/{spec-DVsoMvYT.js → spec-BwarBpUJ.js} +4 -4
- package/dist/{stateDiagram-D77RDMKH-BDa515QC.js → stateDiagram-D77RDMKH-DQeA_CwI.js} +13 -13
- package/dist/stateDiagram-v2-MP3YSRHH-BxxQucm1.js +30 -0
- package/dist/style.css +1 -1
- package/dist/{swimlanes-42K2YHIH-M4IdGi8J.js → swimlanes-42K2YHIH-Do6L-cYg.js} +10 -10
- package/dist/swimlanesDiagram-VR7AAH4N-DUzPvSVU.js +30 -0
- package/dist/{swiper-component-CpN-hewZ.js → swiper-component-DKntyn8p.js} +5 -5
- package/dist/{timeline-definition-24CTP7MA-DH-kvakg.js → timeline-definition-24CTP7MA-D3c46WM5.js} +3 -3
- package/dist/{toDate-vEi5kTfY.js → toDate-vIXljnsr.js} +43 -42
- package/dist/{toast-DfEpJedt.js → toast-B9UMEi8u.js} +9 -9
- package/dist/{tooltip-CuNWg2ay.js → tooltip-BO1REbqs.js} +7 -7
- package/dist/{use-restore-focus-kmgwrL8q.js → use-restore-focus-BEM7sFWl.js} +2042 -1827
- package/dist/{use-vega-container-remeasure-4DwJbPWu.js → use-vega-container-remeasure-Bz4PZMtt.js} +2 -2
- package/dist/{useAsyncData-rkAlR_vh.js → useAsyncData-Deh5kszT.js} +3 -3
- package/dist/{useDateFormatter-C-tz65rD.js → useDateFormatter-D8XruNGG.js} +4 -4
- package/dist/{useDeepCompareMemoize-BlHFBj5_.js → useDeepCompareMemoize-DXwzRINI.js} +2 -2
- package/dist/{useIframeCapabilities-C1Bt04Iz.js → useIframeCapabilities-DBETvvPl.js} +2 -2
- package/dist/{useLifecycle-B68iY077.js → useLifecycle-j7D9uD1o.js} +6 -6
- package/dist/{useTheme-BwSgeAFb.js → useTheme-CRnjkku0.js} +7 -7
- package/dist/{vega-component-C-bPttRN.js → vega-component-DTG6zxaY.js} +14 -14
- package/dist/{vega-embed-container-sSR5hAsy.js → vega-embed-container-BNHE18G9.js} +5 -5
- package/dist/{vennDiagram-4TSXK5OY-d5g7XeiI.js → vennDiagram-4TSXK5OY-BSZD8JcZ.js} +3 -3
- package/dist/{wardleyDiagram-VM6X3IG4-BfX3bSzR.js → wardleyDiagram-VM6X3IG4-48cUWkfA.js} +3 -3
- package/dist/{xychartDiagram-S5SC5T6Z-C1QsLZg7.js → xychartDiagram-S5SC5T6Z-CswYgYeu.js} +5 -5
- package/package.json +25 -22
- package/src/__tests__/fixtures/{pair-preview.ts → pair-config.ts} +3 -2
- package/src/__tests__/host-imports.test.ts +100 -0
- package/src/__tests__/mount.test.ts +8 -8
- package/src/components/data-table/__tests__/column_formatting.test.ts +30 -0
- package/src/components/data-table/__tests__/columns.test.tsx +70 -0
- package/src/components/data-table/__tests__/context-menu.test.ts +176 -0
- package/src/components/data-table/__tests__/date-filter-inputs.test.tsx +24 -1
- package/src/components/data-table/__tests__/export-actions.test.tsx +329 -6
- package/src/components/data-table/column-formatting/feature.ts +20 -1
- package/src/components/data-table/columns.tsx +25 -18
- package/src/components/data-table/context-menu.tsx +125 -26
- package/src/components/data-table/date-filter-inputs.tsx +15 -42
- package/src/components/data-table/export-actions.tsx +192 -116
- package/src/components/data-table/schemas.ts +14 -36
- package/src/components/data-table/utils.ts +18 -0
- package/src/components/editor/Output.tsx +9 -2
- package/src/components/editor/actions/__tests__/pair-with-agent-commands.test.ts +80 -252
- package/src/components/editor/actions/__tests__/pair-with-agent-modal.test.tsx +186 -34
- package/src/components/editor/actions/pair-with-agent-commands.ts +42 -51
- package/src/components/editor/actions/pair-with-agent-modal.tsx +96 -36
- package/src/components/editor/chrome/panels/error-panel.tsx +1 -0
- package/src/components/editor/chrome/wrapper/__tests__/attachment-status.test.tsx +372 -0
- package/src/components/editor/chrome/wrapper/footer-item.tsx +32 -24
- package/src/components/editor/chrome/wrapper/footer-items/attachment-status.tsx +237 -0
- package/src/components/editor/chrome/wrapper/footer.tsx +2 -0
- package/src/components/editor/controls/__tests__/notebook-menu-dropdown.test.tsx +4 -3
- package/src/components/editor/errors/__tests__/send-error-report-button.test.tsx +548 -0
- package/src/components/editor/errors/send-error-report-button.tsx +69 -0
- package/src/components/editor/output/MarimoErrorOutput.tsx +21 -5
- package/src/components/editor/output/MarimoTracebackOutput.tsx +35 -20
- package/src/components/editor/output/__tests__/ansi-reduce.test.ts +18 -0
- package/src/components/editor/output/ansi-reduce.ts +6 -0
- package/src/components/editor/output/console/ConsoleOutput.tsx +5 -3
- package/src/components/editor/output/console/__tests__/ConsoleOutput.test.tsx +18 -0
- package/src/components/storage/__tests__/storage-file-viewer.test.tsx +2 -1
- package/src/core/attachments/__tests__/toast.test.tsx +58 -0
- package/src/core/attachments/state.ts +21 -0
- package/src/core/attachments/toast.ts +15 -0
- package/src/core/cells/__tests__/cells.test.ts +52 -0
- package/src/core/cells/__tests__/document-roundtrip.test.ts +16 -0
- package/src/core/cells/__tests__/error-report.test.ts +139 -0
- package/src/core/cells/__tests__/session.test.ts +50 -1
- package/src/core/cells/error-report.ts +63 -0
- package/src/core/cells/session.ts +28 -1
- package/src/core/codemirror/copilot/__tests__/completion-integration.test.ts +447 -0
- package/src/core/codemirror/copilot/__tests__/inline-completion.test.ts +395 -0
- package/src/core/codemirror/copilot/__tests__/language-server.test.ts +511 -2
- package/src/core/codemirror/copilot/__tests__/rpc-cancellation.test.ts +201 -0
- package/src/core/codemirror/copilot/extension.ts +22 -11
- package/src/core/codemirror/copilot/language-server.ts +109 -60
- package/src/core/codemirror/language/__tests__/sql.test.ts +4 -3
- package/src/core/codemirror/language/embedded/__tests__/embedded-python.test.ts +138 -26
- package/src/core/codemirror/language/embedded/embedded-python.ts +47 -13
- package/src/core/codemirror/language/embedded/latex.ts +20 -13
- package/src/core/config/pair.ts +5 -3
- package/src/core/datasets/__tests__/data-source-discovery.test.ts +18 -11
- package/src/core/host/AGENTS.md +6 -0
- package/src/core/host/__tests__/protocol.test.ts +214 -0
- package/src/core/host/protocol.ts +1943 -0
- package/src/core/islands/__tests__/bootstrap.test.ts +26 -0
- package/src/core/islands/bootstrap.ts +1 -0
- package/src/core/islands/bridge.ts +2 -2
- package/src/core/kernel/messages.ts +4 -7
- package/src/core/network/__tests__/api.test.ts +114 -1
- package/src/core/network/api.ts +3 -2
- package/src/core/wasm/bridge.ts +2 -2
- package/src/core/wasm/worker/types.ts +2 -2
- package/src/core/websocket/__tests__/useMarimoKernelConnection.hook.test.tsx +193 -0
- package/src/core/websocket/useMarimoKernelConnection.tsx +9 -0
- package/src/css/katex-css.test.ts +1 -1
- package/src/css/katex.min.css +6 -1
- package/src/hooks/__tests__/useEventListener.test.tsx +45 -1
- package/src/hooks/useEventListener.ts +6 -1
- package/src/mount.tsx +3 -3
- package/src/plugins/impl/NumberPlugin.tsx +20 -3
- package/src/plugins/impl/__tests__/DataTablePlugin.test.tsx +84 -0
- package/src/plugins/impl/__tests__/NumberPlugin.test.tsx +159 -1
- package/src/utils/__tests__/dates.test.ts +116 -0
- package/src/utils/dates.ts +94 -0
- package/dist/assets/__vite-browser-external-BqAtzd2P.js +0 -1
- package/dist/assets/worker-Bf8dt6S-.js +0 -109
- package/dist/classDiagram-ZZMXUADV-Bbo2n384.js +0 -30
- package/dist/classDiagram-v2-VYDZK3BY-xR8cGP0r.js +0 -30
- package/dist/error-entries-BovkFYNy.js +0 -56
- package/dist/flowDiagram-HODETNUW-D7IBKS12.js +0 -16
- package/dist/mermaid-HWGCJPDP-DYCzSILp.js +0 -2
- package/dist/stateDiagram-v2-MP3YSRHH-ChNddepZ.js +0 -30
- package/dist/swimlanesDiagram-VR7AAH4N-FUSwmzEp.js +0 -30
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
import { createStore } from "jotai";
|
|
4
4
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
5
5
|
import { RuntimeState } from "@/core/kernel/RuntimeState";
|
|
6
|
+
import { attachmentsAtom } from "@/core/attachments/state";
|
|
7
|
+
import { Logger } from "@/utils/Logger";
|
|
6
8
|
import { initializeIslands } from "../bootstrap";
|
|
7
9
|
import type { IslandsPyodideBridge } from "../bridge";
|
|
8
10
|
import { islandsHydratedAtom, islandsPendingInitialRunsAtom } from "../state";
|
|
@@ -48,6 +50,30 @@ describe("initializeIslands", () => {
|
|
|
48
50
|
expect(store.get(islandsHydratedAtom)).toBe(false);
|
|
49
51
|
store.set(islandsPendingInitialRunsAtom, new Set([1, 2]));
|
|
50
52
|
|
|
53
|
+
const errors = vi.spyOn(Logger, "error");
|
|
54
|
+
consumeMessage?.({
|
|
55
|
+
sessionGeneration: 1,
|
|
56
|
+
message: JSON.stringify({
|
|
57
|
+
op: "attachments",
|
|
58
|
+
data: {
|
|
59
|
+
op: "attachments",
|
|
60
|
+
attachments: [
|
|
61
|
+
{
|
|
62
|
+
id: "a1",
|
|
63
|
+
kind: "agent",
|
|
64
|
+
name: "Pi",
|
|
65
|
+
since: "2026-10-14T00:00:00Z",
|
|
66
|
+
notebook_id: "nb-test",
|
|
67
|
+
identity: "pi-thread",
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
},
|
|
71
|
+
}) as IslandsKernelMessage["message"],
|
|
72
|
+
});
|
|
73
|
+
expect(errors).not.toHaveBeenCalled();
|
|
74
|
+
expect(store.get(attachmentsAtom)).toEqual([]);
|
|
75
|
+
expect(store.get(islandsPendingInitialRunsAtom)).toEqual(new Set([1, 2]));
|
|
76
|
+
|
|
51
77
|
consumeMessage?.(completedRun(1));
|
|
52
78
|
expect(store.get(islandsHydratedAtom)).toBe(false);
|
|
53
79
|
|
|
@@ -7,7 +7,7 @@ import { throwNotImplemented } from "@/utils/functions";
|
|
|
7
7
|
import { Logger } from "@/utils/Logger";
|
|
8
8
|
import { generateUUID } from "@/utils/uuid";
|
|
9
9
|
import { initialNotebookState, notebookAtom } from "../cells/cells";
|
|
10
|
-
import type {
|
|
10
|
+
import type { ClientCommand } from "../kernel/messages";
|
|
11
11
|
import type { EditRequests, RunRequests } from "../network/types";
|
|
12
12
|
import { store as defaultStore } from "../state/jotai";
|
|
13
13
|
import { getMarimoExportContext } from "../static/export-context";
|
|
@@ -392,7 +392,7 @@ export class IslandsPyodideBridge implements RunRequests, EditRequests {
|
|
|
392
392
|
// The kernel uses msgspec to parse control requests, which requires a 'type'
|
|
393
393
|
// field for discriminated union deserialization.
|
|
394
394
|
private async putControlRequest(
|
|
395
|
-
operation:
|
|
395
|
+
operation: ClientCommand,
|
|
396
396
|
session?: AppSession,
|
|
397
397
|
): Promise<void> {
|
|
398
398
|
session ??= await this.getActiveSession();
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import type { components } from "@marimo-team/marimo-api";
|
|
3
3
|
|
|
4
4
|
export type schemas = components["schemas"];
|
|
5
|
-
export type DataType = schemas["
|
|
5
|
+
export type DataType = schemas["DataType"];
|
|
6
6
|
export const DATA_TYPES = [
|
|
7
7
|
"string",
|
|
8
8
|
"boolean",
|
|
@@ -24,10 +24,7 @@ export type DatabaseSchema = schemas["Schema"];
|
|
|
24
24
|
export type DataSourceConnection = schemas["DataSourceConnection"];
|
|
25
25
|
export type OutputChannel = schemas["CellChannel"];
|
|
26
26
|
export type CellOutput = schemas["CellOutput"];
|
|
27
|
-
export type MarimoError =
|
|
28
|
-
CellOutput["data"],
|
|
29
|
-
{ type: string }[]
|
|
30
|
-
>[number];
|
|
27
|
+
export type MarimoError = schemas["MarimoError"];
|
|
31
28
|
export type OutputMessage = schemas["CellOutput"];
|
|
32
29
|
export type CompletionOption =
|
|
33
30
|
schemas["CompletionResultNotification"]["options"][0];
|
|
@@ -54,8 +51,8 @@ export type Capabilities =
|
|
|
54
51
|
NotificationMessageData<"kernel-ready">["capabilities"];
|
|
55
52
|
export type CacheInfoFetched = NotificationMessageData<"cache-info">;
|
|
56
53
|
|
|
57
|
-
export type NotificationMessage = schemas["
|
|
58
|
-
export type
|
|
54
|
+
export type NotificationMessage = schemas["NotificationMessage"];
|
|
55
|
+
export type ClientCommand = schemas["ClientCommand"];
|
|
59
56
|
|
|
60
57
|
export type NotificationMessageType = NotificationMessage["op"];
|
|
61
58
|
export interface NotificationPayload {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
2
|
|
|
3
|
-
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
3
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
4
4
|
import { HTTPError } from "@/utils/errors";
|
|
5
|
+
import { Logger } from "@/utils/Logger";
|
|
5
6
|
import { API } from "../api";
|
|
6
7
|
|
|
7
8
|
// Mock fetch globally
|
|
@@ -25,6 +26,118 @@ describe("API", () => {
|
|
|
25
26
|
baseUrl = "http://localhost:8000";
|
|
26
27
|
});
|
|
27
28
|
|
|
29
|
+
afterEach(() => {
|
|
30
|
+
vi.restoreAllMocks();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it.each(["before fetch", "during fetch"])(
|
|
34
|
+
"API.post propagates cancellation %s without logging it",
|
|
35
|
+
async (timing) => {
|
|
36
|
+
const log = vi.spyOn(Logger, "error").mockReturnValue(undefined);
|
|
37
|
+
const controller = new AbortController();
|
|
38
|
+
mockFetch.mockImplementation(
|
|
39
|
+
(_url: string, { signal }: RequestInit) =>
|
|
40
|
+
new Promise<Response>((_resolve, reject) => {
|
|
41
|
+
if (signal?.aborted) {
|
|
42
|
+
reject(signal.reason);
|
|
43
|
+
} else {
|
|
44
|
+
signal?.addEventListener("abort", () => reject(signal.reason), {
|
|
45
|
+
once: true,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}),
|
|
49
|
+
);
|
|
50
|
+
if (timing === "before fetch") {
|
|
51
|
+
controller.abort();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const response = API.post("/foo", {}, { signal: controller.signal });
|
|
55
|
+
controller.abort();
|
|
56
|
+
|
|
57
|
+
await expect(response).rejects.toBe(controller.signal.reason);
|
|
58
|
+
expect(mockFetch).toHaveBeenCalledWith(
|
|
59
|
+
"http://localhost:8000/api/foo",
|
|
60
|
+
expect.objectContaining({ signal: controller.signal }),
|
|
61
|
+
);
|
|
62
|
+
expect(log).not.toHaveBeenCalled();
|
|
63
|
+
},
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
it.each(["application/json", "text/plain"])(
|
|
67
|
+
"API.post propagates an abort while reading %s without logging it",
|
|
68
|
+
async (contentType) => {
|
|
69
|
+
const log = vi.spyOn(Logger, "error").mockReturnValue(undefined);
|
|
70
|
+
const error = new DOMException("Body read aborted", "AbortError");
|
|
71
|
+
const readBody = vi.fn().mockRejectedValue(error);
|
|
72
|
+
mockFetch.mockResolvedValue({
|
|
73
|
+
ok: true,
|
|
74
|
+
headers: new Headers({ "Content-Type": contentType }),
|
|
75
|
+
json: readBody,
|
|
76
|
+
text: readBody,
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
await expect(API.post("/foo", {})).rejects.toBe(error);
|
|
80
|
+
expect(readBody).toHaveBeenCalledExactlyOnceWith();
|
|
81
|
+
expect(log).not.toHaveBeenCalled();
|
|
82
|
+
},
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
it.each([new TypeError("Failed to fetch"), null, "Request failed"])(
|
|
86
|
+
"API.post logs and preserves non-abort fetch failures: %s",
|
|
87
|
+
async (error) => {
|
|
88
|
+
const log = vi.spyOn(Logger, "error").mockReturnValue(undefined);
|
|
89
|
+
const controller = new AbortController();
|
|
90
|
+
controller.abort();
|
|
91
|
+
mockFetch.mockRejectedValue(error);
|
|
92
|
+
|
|
93
|
+
await expect(
|
|
94
|
+
API.post("/foo", {}, { signal: controller.signal }),
|
|
95
|
+
).rejects.toBe(error);
|
|
96
|
+
expect(log).toHaveBeenCalledExactlyOnceWith(
|
|
97
|
+
"Error requesting http://localhost:8000/api/foo",
|
|
98
|
+
error,
|
|
99
|
+
);
|
|
100
|
+
},
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
it("API.post logs HTTP failures and preserves their status and body", async () => {
|
|
104
|
+
const log = vi.spyOn(Logger, "error").mockReturnValue(undefined);
|
|
105
|
+
const body = { detail: "Service unavailable" };
|
|
106
|
+
mockFetch.mockResolvedValue(
|
|
107
|
+
new Response(JSON.stringify(body), {
|
|
108
|
+
status: 503,
|
|
109
|
+
statusText: "Service Unavailable",
|
|
110
|
+
headers: { "Content-Type": "application/json" },
|
|
111
|
+
}),
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
await expect(API.post("/foo", {})).rejects.toMatchObject({
|
|
115
|
+
name: "HTTPError",
|
|
116
|
+
status: 503,
|
|
117
|
+
message: "Service Unavailable",
|
|
118
|
+
cause: body,
|
|
119
|
+
});
|
|
120
|
+
expect(log).toHaveBeenCalledExactlyOnceWith(
|
|
121
|
+
"Error requesting http://localhost:8000/api/foo",
|
|
122
|
+
expect.any(HTTPError),
|
|
123
|
+
);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it("API.post logs malformed JSON responses", async () => {
|
|
127
|
+
const log = vi.spyOn(Logger, "error").mockReturnValue(undefined);
|
|
128
|
+
mockFetch.mockResolvedValue(
|
|
129
|
+
new Response("invalid json", {
|
|
130
|
+
headers: { "Content-Type": "application/json" },
|
|
131
|
+
}),
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
await expect(API.post("/foo", {})).rejects.toBeInstanceOf(SyntaxError);
|
|
135
|
+
expect(log).toHaveBeenCalledExactlyOnceWith(
|
|
136
|
+
"Error requesting http://localhost:8000/api/foo",
|
|
137
|
+
expect.any(SyntaxError),
|
|
138
|
+
);
|
|
139
|
+
});
|
|
140
|
+
|
|
28
141
|
it("API.post calls fetch with POST and correct URL", async () => {
|
|
29
142
|
mockFetch.mockResolvedValue({
|
|
30
143
|
ok: true,
|
package/src/core/network/api.ts
CHANGED
|
@@ -101,8 +101,9 @@ export const API = {
|
|
|
101
101
|
return response.text() as unknown as RESP;
|
|
102
102
|
})
|
|
103
103
|
.catch((error) => {
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
if (error?.name !== "AbortError") {
|
|
105
|
+
Logger.error(`Error requesting ${fullUrl}`, error);
|
|
106
|
+
}
|
|
106
107
|
throw error;
|
|
107
108
|
});
|
|
108
109
|
},
|
package/src/core/wasm/bridge.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { reloadSafe } from "@/utils/reload-safe";
|
|
|
11
11
|
import { generateUUID } from "@/utils/uuid";
|
|
12
12
|
import { createModuleWorker } from "@/utils/worker";
|
|
13
13
|
import { notebookIsRunningAtom } from "../cells/cells";
|
|
14
|
-
import type {
|
|
14
|
+
import type { ClientCommand } from "../kernel/messages";
|
|
15
15
|
import { getInitialAppMode } from "../mode";
|
|
16
16
|
import { API } from "../network/api";
|
|
17
17
|
import { withDevAssetUrl } from "../network/export-asset-url";
|
|
@@ -711,7 +711,7 @@ export class PyodideBridge implements RunRequests, EditRequests {
|
|
|
711
711
|
public listStorageEntries = throwNotImplemented;
|
|
712
712
|
public downloadStorage = throwNotImplemented;
|
|
713
713
|
|
|
714
|
-
private async putControlRequest(operation:
|
|
714
|
+
private async putControlRequest(operation: ClientCommand) {
|
|
715
715
|
await this.rpc.proxy.request.bridge({
|
|
716
716
|
functionName: "put_control_request",
|
|
717
717
|
payload: operation,
|
|
@@ -3,7 +3,7 @@ import type { PyodideInterface } from "pyodide";
|
|
|
3
3
|
import type { WasmRuntimeConfig } from "../runtime-config";
|
|
4
4
|
import type { UserConfig } from "@/core/config/config-schema";
|
|
5
5
|
import type {
|
|
6
|
-
|
|
6
|
+
ClientCommand,
|
|
7
7
|
NotificationPayload,
|
|
8
8
|
} from "@/core/kernel/messages";
|
|
9
9
|
import type { JsonString } from "@/utils/json/base64";
|
|
@@ -74,7 +74,7 @@ export interface WasmController {
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
export interface RawBridge {
|
|
77
|
-
put_control_request(operation:
|
|
77
|
+
put_control_request(operation: ClientCommand): Promise<string>;
|
|
78
78
|
put_input(input: string): Promise<string>;
|
|
79
79
|
code_complete(request: CodeCompletionRequest): Promise<string>;
|
|
80
80
|
read_code(): Promise<{ contents: string }>;
|
|
@@ -43,6 +43,11 @@ vi.mock("@/core/runtime/config", async () => {
|
|
|
43
43
|
import { MockNotebook } from "@/__mocks__/notebook";
|
|
44
44
|
import { cellId } from "@/__tests__/branded";
|
|
45
45
|
import { alertAtom, getPackageAlert } from "@/core/alerts/state";
|
|
46
|
+
import {
|
|
47
|
+
type Attachment,
|
|
48
|
+
attachmentsAtom,
|
|
49
|
+
agentAttachmentsAtom,
|
|
50
|
+
} from "@/core/attachments/state";
|
|
46
51
|
import { notebookAtom } from "@/core/cells/cells";
|
|
47
52
|
import { AppConfigSchema } from "@/core/config/config-schema";
|
|
48
53
|
import { ConnectionNotice } from "@/components/editor/alerts/connection-notice";
|
|
@@ -184,6 +189,46 @@ describe("useMarimoKernelConnection.reconnect()", () => {
|
|
|
184
189
|
});
|
|
185
190
|
|
|
186
191
|
describe("useMarimoKernelConnection messages", () => {
|
|
192
|
+
it("replaces attachment snapshots, including the last detach", () => {
|
|
193
|
+
const store = createStore();
|
|
194
|
+
vi.mocked(useConnectionTransport).mockReturnValue(
|
|
195
|
+
makeTransport(WebSocket.OPEN),
|
|
196
|
+
);
|
|
197
|
+
vi.mocked(useRuntimeManager).mockReturnValue(
|
|
198
|
+
makeRuntimeManager() as unknown as ReturnType<typeof useRuntimeManager>,
|
|
199
|
+
);
|
|
200
|
+
renderConnectionHook(store);
|
|
201
|
+
const options = vi.mocked(useConnectionTransport).mock.calls.at(-1)![0];
|
|
202
|
+
const agent: Attachment = {
|
|
203
|
+
id: "a1",
|
|
204
|
+
kind: "agent",
|
|
205
|
+
name: "Pi",
|
|
206
|
+
since: "2026-10-14T00:00:00Z",
|
|
207
|
+
notebook_id: "nb-test",
|
|
208
|
+
identity: "pi-thread",
|
|
209
|
+
};
|
|
210
|
+
const client: Attachment = {
|
|
211
|
+
id: "c1",
|
|
212
|
+
kind: "client",
|
|
213
|
+
name: null,
|
|
214
|
+
since: "2026-10-14T00:00:01Z",
|
|
215
|
+
notebook_id: "nb-test",
|
|
216
|
+
};
|
|
217
|
+
for (const attachments of [[agent, client], [client], []]) {
|
|
218
|
+
act(() =>
|
|
219
|
+
options.onMessage(
|
|
220
|
+
new MessageEvent("message", {
|
|
221
|
+
data: JSON.stringify({
|
|
222
|
+
op: "attachments",
|
|
223
|
+
data: { op: "attachments", attachments },
|
|
224
|
+
}),
|
|
225
|
+
}),
|
|
226
|
+
),
|
|
227
|
+
);
|
|
228
|
+
expect(store.get(attachmentsAtom)).toEqual(attachments);
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
|
|
187
232
|
it("records completion of the initial run", () => {
|
|
188
233
|
const store = createStore();
|
|
189
234
|
vi.mocked(useConnectionTransport).mockClear();
|
|
@@ -211,6 +256,101 @@ describe("useMarimoKernelConnection messages", () => {
|
|
|
211
256
|
});
|
|
212
257
|
});
|
|
213
258
|
|
|
259
|
+
describe("attachment snapshots across browser connections", () => {
|
|
260
|
+
const agent: Attachment = {
|
|
261
|
+
id: "a1",
|
|
262
|
+
kind: "agent",
|
|
263
|
+
name: "Pi",
|
|
264
|
+
since: "2026-10-14T00:00:00Z",
|
|
265
|
+
notebook_id: "nb-test",
|
|
266
|
+
identity: "pi-thread",
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
function connectedSession() {
|
|
270
|
+
const store = createStore();
|
|
271
|
+
store.set(connectionAtom, { state: ConnectionState.OPEN });
|
|
272
|
+
store.set(attachmentsAtom, [agent]);
|
|
273
|
+
const transport = makeTransport(WebSocket.OPEN);
|
|
274
|
+
vi.mocked(useConnectionTransport).mockReturnValue(transport);
|
|
275
|
+
vi.mocked(useRuntimeManager).mockReturnValue(
|
|
276
|
+
makeRuntimeManager() as unknown as ReturnType<typeof useRuntimeManager>,
|
|
277
|
+
);
|
|
278
|
+
renderConnectionHook(store);
|
|
279
|
+
const options = vi.mocked(useConnectionTransport).mock.calls.at(-1)![0];
|
|
280
|
+
const receive = (data: NotificationPayload["data"]) =>
|
|
281
|
+
act(() => {
|
|
282
|
+
options.onMessage(
|
|
283
|
+
new MessageEvent("message", {
|
|
284
|
+
data: JSON.stringify({ op: data.op, data }),
|
|
285
|
+
}),
|
|
286
|
+
);
|
|
287
|
+
});
|
|
288
|
+
return { store, transport, options, receive };
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
it.each([
|
|
292
|
+
"MARIMO_NO_FILE_KEY",
|
|
293
|
+
"MARIMO_NO_SESSION_ID",
|
|
294
|
+
"MARIMO_NO_SESSION",
|
|
295
|
+
"MARIMO_SHUTDOWN",
|
|
296
|
+
"MARIMO_KERNEL_STARTUP_ERROR",
|
|
297
|
+
"MARIMO_UNAUTHORIZED",
|
|
298
|
+
"MARIMO_KIOSK_NOT_ALLOWED",
|
|
299
|
+
"MARIMO_TRANSPORT_EXHAUSTED",
|
|
300
|
+
])("clears cached attachments on %s", (reason) => {
|
|
301
|
+
const { store, transport, options } = connectedSession();
|
|
302
|
+
act(() => options.onClose(new CloseEvent("close", { reason })));
|
|
303
|
+
expect(store.get(attachmentsAtom)).toEqual([]);
|
|
304
|
+
expect(store.get(agentAttachmentsAtom)).toEqual([]);
|
|
305
|
+
expect(store.get(connectionAtom).state).toBe(ConnectionState.CLOSED);
|
|
306
|
+
expect(transport.reconnect).not.toHaveBeenCalled();
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
it("clears the snapshot on transport error", () => {
|
|
310
|
+
const { store, options } = connectedSession();
|
|
311
|
+
act(() => options.onError(new Event("error")));
|
|
312
|
+
expect(store.get(attachmentsAtom)).toEqual([]);
|
|
313
|
+
expect(store.get(agentAttachmentsAtom)).toEqual([]);
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
it("waits for a fresh snapshot after a transient reconnect", async () => {
|
|
317
|
+
const { store, transport, options, receive } = connectedSession();
|
|
318
|
+
act(() => options.onClose(new CloseEvent("close")));
|
|
319
|
+
expect(store.get(attachmentsAtom)).toEqual([]);
|
|
320
|
+
expect(store.get(connectionAtom).state).toBe(ConnectionState.CONNECTING);
|
|
321
|
+
expect(transport.reconnect).toHaveBeenCalledOnce();
|
|
322
|
+
|
|
323
|
+
await act(async () => options.onOpen(new Event("open")));
|
|
324
|
+
receive({ op: "reconnected" });
|
|
325
|
+
expect(store.get(connectionAtom).state).toBe(ConnectionState.OPEN);
|
|
326
|
+
expect(store.get(agentAttachmentsAtom)).toEqual([]);
|
|
327
|
+
|
|
328
|
+
const refreshed = { ...agent, id: "a2", name: "Codex" };
|
|
329
|
+
receive({ op: "attachments", attachments: [refreshed] });
|
|
330
|
+
expect(store.get(agentAttachmentsAtom)).toEqual([refreshed]);
|
|
331
|
+
receive({ op: "attachments", attachments: [] });
|
|
332
|
+
expect(store.get(agentAttachmentsAtom)).toEqual([]);
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
it("keeps a fresh snapshot hidden until the session is ready", async () => {
|
|
336
|
+
const { store, options, receive } = connectedSession();
|
|
337
|
+
act(() => options.onClose(new CloseEvent("close")));
|
|
338
|
+
await act(async () => options.onOpen(new Event("open")));
|
|
339
|
+
receive({ op: "attachments", attachments: [agent] });
|
|
340
|
+
expect(store.get(attachmentsAtom)).toEqual([agent]);
|
|
341
|
+
expect(store.get(agentAttachmentsAtom)).toEqual([]);
|
|
342
|
+
receive({ op: "reconnected" });
|
|
343
|
+
expect(store.get(agentAttachmentsAtom)).toEqual([agent]);
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
it("invalidates an old snapshot when a new transport opens", async () => {
|
|
347
|
+
const { store, options } = connectedSession();
|
|
348
|
+
await act(async () => options.onOpen(new Event("open")));
|
|
349
|
+
expect(store.get(attachmentsAtom)).toEqual([]);
|
|
350
|
+
expect(store.get(agentAttachmentsAtom)).toEqual([]);
|
|
351
|
+
});
|
|
352
|
+
});
|
|
353
|
+
|
|
214
354
|
it.each(["kernel-ready", "reconnected"])(
|
|
215
355
|
"waits for %s before marking the session connected",
|
|
216
356
|
async (op) => {
|
|
@@ -261,6 +401,59 @@ it.each(["kernel-ready", "reconnected"])(
|
|
|
261
401
|
},
|
|
262
402
|
);
|
|
263
403
|
|
|
404
|
+
it.each([true, false])(
|
|
405
|
+
"keeps attachments only when kernel-ready resumes the session: %s",
|
|
406
|
+
(resumed) => {
|
|
407
|
+
const store = createStore();
|
|
408
|
+
const attachments: Attachment[] = [
|
|
409
|
+
{
|
|
410
|
+
id: "a1",
|
|
411
|
+
kind: "agent",
|
|
412
|
+
name: "Pi",
|
|
413
|
+
since: "2026-10-14T00:00:00Z",
|
|
414
|
+
notebook_id: "nb-test",
|
|
415
|
+
identity: "pi-thread",
|
|
416
|
+
},
|
|
417
|
+
];
|
|
418
|
+
store.set(attachmentsAtom, attachments);
|
|
419
|
+
vi.mocked(useConnectionTransport).mockReturnValue(
|
|
420
|
+
makeTransport(WebSocket.OPEN),
|
|
421
|
+
);
|
|
422
|
+
vi.mocked(useRuntimeManager).mockReturnValue(
|
|
423
|
+
makeRuntimeManager() as unknown as ReturnType<typeof useRuntimeManager>,
|
|
424
|
+
);
|
|
425
|
+
renderConnectionHook(store);
|
|
426
|
+
const options = vi.mocked(useConnectionTransport).mock.calls.at(-1)![0];
|
|
427
|
+
act(() =>
|
|
428
|
+
options.onMessage(
|
|
429
|
+
new MessageEvent("message", {
|
|
430
|
+
data: JSON.stringify({
|
|
431
|
+
op: "kernel-ready",
|
|
432
|
+
data: {
|
|
433
|
+
op: "kernel-ready",
|
|
434
|
+
cell_ids: [],
|
|
435
|
+
codes: [],
|
|
436
|
+
names: [],
|
|
437
|
+
configs: [],
|
|
438
|
+
layout: null,
|
|
439
|
+
resumed,
|
|
440
|
+
ui_values: {},
|
|
441
|
+
last_executed_code: {},
|
|
442
|
+
last_execution_time: {},
|
|
443
|
+
app_config: { width: "normal" },
|
|
444
|
+
kiosk: false,
|
|
445
|
+
capabilities: { terminal: false },
|
|
446
|
+
auto_instantiated: true,
|
|
447
|
+
consumer_capabilities: { edit: true, interact: true },
|
|
448
|
+
},
|
|
449
|
+
}),
|
|
450
|
+
}),
|
|
451
|
+
),
|
|
452
|
+
);
|
|
453
|
+
expect(store.get(attachmentsAtom)).toEqual(resumed ? attachments : []);
|
|
454
|
+
},
|
|
455
|
+
);
|
|
456
|
+
|
|
264
457
|
describe("connection notice", () => {
|
|
265
458
|
beforeEach(() => vi.useFakeTimers());
|
|
266
459
|
afterEach(() => vi.useRealTimers());
|
|
@@ -5,6 +5,7 @@ import { useAtom, useAtomValue, useSetAtom } from "jotai";
|
|
|
5
5
|
import { useRef } from "react";
|
|
6
6
|
import { useErrorBoundary } from "react-error-boundary";
|
|
7
7
|
import { toast } from "@/components/ui/use-toast";
|
|
8
|
+
import { attachmentsAtom } from "@/core/attachments/state";
|
|
8
9
|
import { getNotebook, useCellActions } from "@/core/cells/cells";
|
|
9
10
|
import { applyTransactionChanges } from "@/core/cells/document-changes";
|
|
10
11
|
import { AUTOCOMPLETER } from "@/core/codemirror/completion/Autocompleter";
|
|
@@ -236,6 +237,7 @@ export function useMarimoKernelConnection(opts: {
|
|
|
236
237
|
} = useAlertActions();
|
|
237
238
|
const setKioskMode = useSetAtom(kioskModeAtom);
|
|
238
239
|
const setStableSessionId = useSetAtom(stableSessionIdAtom);
|
|
240
|
+
const setAttachments = useSetAtom(attachmentsAtom);
|
|
239
241
|
const setCapabilities = useSetAtom(capabilitiesAtom);
|
|
240
242
|
const runtimeManager = useRuntimeManager();
|
|
241
243
|
const transportType = useAtomValue(connectionTransportTypeAtom);
|
|
@@ -252,6 +254,9 @@ export function useMarimoKernelConnection(opts: {
|
|
|
252
254
|
case "reload":
|
|
253
255
|
reloadSafe();
|
|
254
256
|
return;
|
|
257
|
+
case "attachments":
|
|
258
|
+
setAttachments(msg.data.attachments);
|
|
259
|
+
return;
|
|
255
260
|
case "startup-progress": {
|
|
256
261
|
const { phase } = msg.data;
|
|
257
262
|
updateStartupProgress(msg.data);
|
|
@@ -283,6 +288,7 @@ export function useMarimoKernelConnection(opts: {
|
|
|
283
288
|
existingCells,
|
|
284
289
|
});
|
|
285
290
|
if (!msg.data.resumed) {
|
|
291
|
+
setAttachments([]);
|
|
286
292
|
// A freshly started kernel may expose a different environment
|
|
287
293
|
// (e.g. new env vars); re-run discovery instead of reusing stale
|
|
288
294
|
// suggestions from the previous kernel instance.
|
|
@@ -561,6 +567,7 @@ export function useMarimoKernelConnection(opts: {
|
|
|
561
567
|
*/
|
|
562
568
|
onOpen: async () => {
|
|
563
569
|
updateStartupProgress(null);
|
|
570
|
+
setAttachments([]);
|
|
564
571
|
// If we are open, we can reset our reconnecting flag.
|
|
565
572
|
shouldTryReconnecting.current = true;
|
|
566
573
|
},
|
|
@@ -603,6 +610,7 @@ export function useMarimoKernelConnection(opts: {
|
|
|
603
610
|
*/
|
|
604
611
|
onClose: (e) => {
|
|
605
612
|
Logger.warn("WebSocket closed", e.code, e.reason);
|
|
613
|
+
setAttachments([]);
|
|
606
614
|
const decision = classifyCloseEvent(e);
|
|
607
615
|
setConnection((previous) => {
|
|
608
616
|
const status = decision.status;
|
|
@@ -641,6 +649,7 @@ export function useMarimoKernelConnection(opts: {
|
|
|
641
649
|
*/
|
|
642
650
|
onError: (e) => {
|
|
643
651
|
Logger.warn("WebSocket error", e);
|
|
652
|
+
setAttachments([]);
|
|
644
653
|
setConnection({
|
|
645
654
|
state: ConnectionState.CLOSED,
|
|
646
655
|
code: WebSocketClosedReason.KERNEL_DISCONNECTED,
|
|
@@ -32,7 +32,7 @@ describe("copied KaTeX stylesheet", () => {
|
|
|
32
32
|
if (change === "added") {
|
|
33
33
|
root.append(
|
|
34
34
|
postcss.parse(
|
|
35
|
-
".katex .
|
|
35
|
+
".katex .upstream-drift-probe { display: inline-block; }",
|
|
36
36
|
),
|
|
37
37
|
);
|
|
38
38
|
} else {
|
package/src/css/katex.min.css
CHANGED
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
.katex .katex-version::after {
|
|
38
|
-
content: "0.18.
|
|
38
|
+
content: "0.18.7";
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
.katex .katex-mathml {
|
|
@@ -1131,6 +1131,11 @@
|
|
|
1131
1131
|
padding: 0 0.03889em;
|
|
1132
1132
|
}
|
|
1133
1133
|
|
|
1134
|
+
.katex .reflectbox {
|
|
1135
|
+
display: inline-block;
|
|
1136
|
+
transform: scaleX(-1);
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1134
1139
|
.katex .eqn-num::before {
|
|
1135
1140
|
content: "(" counter(katexEqnNo) ")";
|
|
1136
1141
|
counter-increment: katexEqnNo;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { renderHook } from "@testing-library/react";
|
|
4
4
|
import { useRef } from "react";
|
|
5
|
-
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
5
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
6
6
|
import {
|
|
7
7
|
type HTMLElementNotDerivedFromRef,
|
|
8
8
|
isRefObject,
|
|
@@ -28,6 +28,50 @@ describe("isRefObject", () => {
|
|
|
28
28
|
});
|
|
29
29
|
});
|
|
30
30
|
|
|
31
|
+
describe.each([1, 2])("with %i anchors named current", (count) => {
|
|
32
|
+
let iframe: HTMLIFrameElement;
|
|
33
|
+
let browserWindow: Window;
|
|
34
|
+
|
|
35
|
+
beforeEach(() => {
|
|
36
|
+
// An iframe preserves named properties hidden by Vitest's global window.
|
|
37
|
+
iframe = document.createElement("iframe");
|
|
38
|
+
document.body.append(iframe);
|
|
39
|
+
if (!iframe.contentWindow) {
|
|
40
|
+
throw new Error("Expected an iframe window");
|
|
41
|
+
}
|
|
42
|
+
browserWindow = iframe.contentWindow;
|
|
43
|
+
const anchors = Array.from({ length: count }, () => {
|
|
44
|
+
const anchor = browserWindow.document.createElement("a");
|
|
45
|
+
anchor.id = "current";
|
|
46
|
+
return anchor;
|
|
47
|
+
});
|
|
48
|
+
browserWindow.document.body.append(...anchors);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
afterEach(() => {
|
|
52
|
+
iframe.remove();
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it("does not mistake window for a React ref", () => {
|
|
56
|
+
expect("current" in browserWindow).toBe(true);
|
|
57
|
+
expect(isRefObject(browserWindow)).toBe(false);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it("attaches and removes the listener on window", () => {
|
|
61
|
+
const listener = vi.fn();
|
|
62
|
+
const { unmount } = renderHook(() =>
|
|
63
|
+
useEventListener(browserWindow, "resize", listener),
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
browserWindow.dispatchEvent(new Event("resize"));
|
|
67
|
+
expect(listener).toHaveBeenCalledTimes(1);
|
|
68
|
+
|
|
69
|
+
unmount();
|
|
70
|
+
browserWindow.dispatchEvent(new Event("resize"));
|
|
71
|
+
expect(listener).toHaveBeenCalledTimes(1);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
|
|
31
75
|
describe("useEventListener", () => {
|
|
32
76
|
beforeEach(() => {
|
|
33
77
|
vi.clearAllMocks();
|
|
@@ -13,7 +13,12 @@ export type HTMLElementNotDerivedFromRef<T = HTMLElement> = T & {
|
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
export function isRefObject<T>(target: unknown): target is RefObject<T | null> {
|
|
16
|
-
return
|
|
16
|
+
return (
|
|
17
|
+
target !== null &&
|
|
18
|
+
typeof target === "object" &&
|
|
19
|
+
!("addEventListener" in target) &&
|
|
20
|
+
"current" in target
|
|
21
|
+
);
|
|
17
22
|
}
|
|
18
23
|
|
|
19
24
|
export function useEventListener<K extends keyof DocumentEventMap>(
|