@marimo-team/islands 0.26.1-dev7 → 0.26.1-dev70
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-DtwVgVpX.js → ConnectedDataExplorerComponent-yQVBQBUW.js} +16 -16
- package/dist/{ErrorBoundary-Dxaw2lRl.js → ErrorBoundary-RBxrwyro.js} +19 -19
- package/dist/{abnfDiagram-VCTEODGH-BbZOIueZ.js → abnfDiagram-VCTEODGH-Ck_lXwQR.js} +2 -2
- package/dist/{any-language-editor-yG-YmLaK.js → any-language-editor-Cx4idbgX.js} +5 -5
- package/dist/{architectureDiagram-5GKGNRK7-qjLjxapm.js → architectureDiagram-5GKGNRK7-XeVhic7Z.js} +1 -1
- package/dist/{assertNever-DywGMo-S.js → assertNever-473SFxLt.js} +14 -14
- package/dist/{button-qQhINE7z.js → button-Z2R2272J.js} +34 -31
- package/dist/{capabilities-DKqMqBzm.js → capabilities-ba3Dyv8n.js} +1 -1
- package/dist/{chat-ui-D5YPIONI.js → chat-ui-D1mRz9h6.js} +113 -113
- package/dist/{check-jchHMCfs.js → check-DmTIavbZ.js} +1 -1
- package/dist/{chunk-IMKFNOWR-BzDY1_I7.js → chunk-IMKFNOWR-DdQni67K.js} +1 -1
- package/dist/{chunk-SHT3W25Y-DbHsMKdo.js → chunk-SHT3W25Y-BdK-vMct.js} +1 -1
- package/dist/{chunk-SVP7TREG-CtwnwAE6.js → chunk-SVP7TREG-cpFZk4Ca.js} +1 -1
- package/dist/{chunk-TICWLB2K-C5Z5QMbO.js → chunk-TICWLB2K-DDgQFRgT.js} +1 -1
- package/dist/{classDiagram-ZZMXUADV-B8E5Hn78.js → classDiagram-ZZMXUADV-DeojX9X4.js} +2 -2
- package/dist/{classDiagram-v2-VYDZK3BY-DeGsK9bT.js → classDiagram-v2-VYDZK3BY-DPfTAiQ6.js} +2 -2
- package/dist/{code-visibility-BbRR76tW.js → code-visibility-Bj4tN90X.js} +28 -28
- package/dist/{common-ChXjW7mo.js → common-CnnpukFz.js} +5102 -5055
- package/dist/{config-qTaTHnpE.js → config-D-lhQq-h.js} +31 -32
- package/dist/{copy-icon-BI7vZHEW.js → copy-icon-DuxRkh7T.js} +3 -3
- package/dist/{createReducer-DdSLRfBT.js → createReducer-D3pBhIVD.js} +2 -2
- package/dist/{cynefinDiagram-5FMLGOSQ-NDedRwsw.js → cynefinDiagram-5FMLGOSQ-DyY9TvuI.js} +1 -1
- package/dist/{dagre-GXQ25YYZ-De0sSZO7.js → dagre-GXQ25YYZ-BPCOgtKg.js} +1 -1
- package/dist/{data-grid-overlay-editor-DPmANZ7y.js → data-grid-overlay-editor-C7_UKpUZ.js} +1 -1
- package/dist/{diagram-S7CK7UJ4-wBtVl61y.js → diagram-S7CK7UJ4-KaF-C6kd.js} +1 -1
- package/dist/{diagram-UQ7AKVKN-CKWE3c1T.js → diagram-UQ7AKVKN-DkeqoSvK.js} +1 -1
- package/dist/{diagram-VX7I27RA-D2Ac5198.js → diagram-VX7I27RA-DExolTAf.js} +1 -1
- package/dist/{diagram-Z3DM3KII-CYaFOQcI.js → diagram-Z3DM3KII-BioFuBF3.js} +1 -1
- package/dist/{dialog-Ic6dh09m.js → dialog-CvyFEwby.js} +32 -32
- package/dist/{dist-BvZpdAuG.js → dist-6B1_Ttbh.js} +1 -1
- package/dist/{dist-D1D56-GS.js → dist-B28poF32.js} +2 -2
- package/dist/{dist-BozTF_gH.js → dist-BBZ7lnMw.js} +2 -2
- package/dist/{dist-BfrgytDR.js → dist-BD8ZKF5t.js} +3 -3
- package/dist/{dist-DNkrY12t.js → dist-BG-7Qpaj.js} +3 -3
- package/dist/{dist-D92tYjLc.js → dist-BIaGGUbU.js} +13 -11
- package/dist/{dist-BagHbFqG.js → dist-BR5PU2Ph.js} +3 -3
- package/dist/{dist-DpYpG8Yc.js → dist-BidYR5m4.js} +3 -3
- package/dist/{dist-D95Cd4xm.js → dist-BkGYCvFX.js} +3 -3
- package/dist/{dist-DneeBk3K.js → dist-BmEyXT7K.js} +2 -2
- package/dist/{dist-BdUitvVW.js → dist-Bt0Wt6m9.js} +2 -2
- package/dist/{dist-CEomphG1.js → dist-CG2Sl0D4.js} +2 -2
- package/dist/{dist-BMz__bo5.js → dist-CQfpgadU.js} +3 -3
- package/dist/{dist-BreKIQqQ.js → dist-CVOPvfzN.js} +3 -3
- package/dist/{dist-BEcpQbZa.js → dist-Cm0iCeQQ.js} +3 -3
- package/dist/{dist-CDVvitRS.js → dist-Cnc14jEq.js} +2 -2
- package/dist/{dist-ChcBm3jk.js → dist-D3KPC38e.js} +4 -4
- package/dist/{dist-B1qu3Bez.js → dist-D7BXk27E.js} +3 -3
- package/dist/{dist-BsE4gQHj.js → dist-D9Qhvxvg.js} +1 -1
- package/dist/{dist-OmeAz0fR.js → dist-DJKajXDB.js} +3 -3
- package/dist/{dist-ObeTgSmf.js → dist-DYbNRTYG.js} +4 -4
- package/dist/{dist-Cshl6jBw.js → dist-DhtDWnzK.js} +2 -2
- package/dist/{dist-BunZKA_9.js → dist-_x2Jks2R.js} +2 -2
- package/dist/{dist-MggMo7OR.js → dist-m0MWV-aw.js} +1 -1
- package/dist/{dist-TGSwzj8a.js → dist-pPbYNVjd.js} +4 -4
- package/dist/{dropdown-menu-Dhv4fcNl.js → dropdown-menu-BiXHfje7.js} +2568 -2568
- package/dist/{ebnfDiagram-PWID7BFC-Ds7f42dj.js → ebnfDiagram-PWID7BFC-BSb9k1ed.js} +2 -2
- package/dist/{erDiagram-RLTQ6QDP-b58Sz2Mc.js → erDiagram-RLTQ6QDP-PWA30a_r.js} +1 -1
- package/dist/{error-banner-CJVLr5_a.js → error-banner-B9HQMSaH.js} +35 -35
- package/dist/{error-entries-BKlEsuk4.js → error-entries-P6Qpq6wP.js} +1032 -867
- package/dist/{esm-B9n0caHs.js → esm-DY8dGAjJ.js} +23 -23
- package/dist/{esm-Bwp_FHP0.js → esm-Dw2ZydG_.js} +3 -3
- package/dist/{feedback-button-DP7fO1Hw.js → feedback-button-BsihKrjV.js} +123 -123
- package/dist/{flowDiagram-HODETNUW-BH9U7VZK.js → flowDiagram-HODETNUW-BPtD__Zz.js} +2 -2
- package/dist/{formats-BLNFWWhV.js → formats-BF95BoCT.js} +3 -3
- package/dist/{glide-data-editor-CVIrr2k2.js → glide-data-editor-bC_hEUqu.js} +43 -43
- package/dist/{glide-utils-Ze_7l_91.js → glide-utils-iHKKQPJ8.js} +3 -3
- package/dist/{globals-Cd1AqHZZ.js → globals-Db9HvOSQ.js} +3 -3
- package/dist/{html-to-image-CNM0ZSFD.js → html-to-image-DhrFZL7t.js} +24150 -24028
- package/dist/{infoDiagram-27XIBGKW-xbjwrcNi.js → infoDiagram-27XIBGKW-SJuilBEE.js} +1 -1
- package/dist/{ishikawaDiagram-5VMMS53U-DKtukhGS.js → ishikawaDiagram-5VMMS53U-DjzyxMr8.js} +1 -1
- package/dist/{kanban-definition-UXKFOSKX-BEhlkZBb.js → kanban-definition-UXKFOSKX-D2_qopGt.js} +1 -1
- package/dist/{loader-Bin_dutt.js → loader-qPmiRXZd.js} +1 -1
- package/dist/main.js +8860 -8741
- package/dist/{mermaid-D1CZDNoB.js → mermaid-DcowNmCx.js} +35 -35
- package/dist/{mindmap-definition-YA3MSWOX-DQcnJPcV.js → mindmap-definition-YA3MSWOX-pEra10M0.js} +1 -1
- package/dist/{number-overlay-editor-CehVCpEF.js → number-overlay-editor-M1rRkX42.js} +1 -1
- package/dist/{pegDiagram-XKGWAZYB-BFQuPYfI.js → pegDiagram-XKGWAZYB-CHOPKVOf.js} +2 -2
- package/dist/{pencil-DVYzq-iR.js → pencil-FAv6JUvp.js} +1 -1
- package/dist/{pieDiagram-E7YTZNPT-l7aqNrem.js → pieDiagram-E7YTZNPT-yGDhsyEN.js} +1 -1
- package/dist/{process-output-DthYR2Te.js → process-output-CBPqVQBu.js} +4 -4
- package/dist/{railroadDiagram-O6MQD6OU-6R3C1lwQ.js → railroadDiagram-O6MQD6OU-CeKEPdyc.js} +2 -2
- package/dist/{requirementDiagram-BXWQKSXE-DdWYu8fn.js → requirementDiagram-BXWQKSXE-DSAbAzKe.js} +1 -1
- package/dist/{reveal-component-AjFFBCGn.js → reveal-component-9yg2qvxu.js} +1018 -1018
- package/dist/{select-CDUxhHZg.js → select-BszV-bbI.js} +135 -135
- package/dist/{sequenceDiagram-WJ2MYXX4-Dzp0dgRc.js → sequenceDiagram-WJ2MYXX4-DVhWj_9H.js} +1 -1
- package/dist/{spec-ZAt4P01J.js → spec-CRfw-lOm.js} +4 -4
- package/dist/{stateDiagram-D77RDMKH-BGnTUhFJ.js → stateDiagram-D77RDMKH-CDQ2MltG.js} +2 -2
- package/dist/{stateDiagram-v2-MP3YSRHH-DsJbmDf1.js → stateDiagram-v2-MP3YSRHH-BQmvwBaz.js} +2 -2
- package/dist/{static-state-C4bAlKTU.js → static-state-BtDNJuc2.js} +7 -7
- package/dist/style.css +1 -1
- package/dist/{swimlanes-42K2YHIH-Bd4Bzh9r.js → swimlanes-42K2YHIH-DLOUTCEL.js} +1 -1
- package/dist/{swimlanesDiagram-VR7AAH4N-BlY12Jf6.js → swimlanesDiagram-VR7AAH4N-BVKrkNJ6.js} +2 -2
- package/dist/{swiper-component-DTdNB9wg.js → swiper-component-B2O8hF7b.js} +2 -2
- package/dist/{timeline-definition-24CTP7MA-m0LanyCH.js → timeline-definition-24CTP7MA-Cb2JoCSd.js} +1 -1
- package/dist/{toast-U3NpO2x3.js → toast-QsOAIPfq.js} +166 -166
- package/dist/{tooltip-UzJukb3F.js → tooltip-BQZ-Bm6h.js} +65 -65
- package/dist/{use-restore-focus-DaTVz6S6.js → use-restore-focus-DT1TZACX.js} +1885 -1877
- package/dist/{useDateFormatter-LQNtoXyh.js → useDateFormatter-D3gyMY-g.js} +2 -2
- package/dist/{useDeepCompareMemoize-CmNbQ9TT.js → useDeepCompareMemoize-CO6rO5Mq.js} +1 -1
- package/dist/{useIframeCapabilities-HTZiVlGV.js → useIframeCapabilities-_0KX0nu_.js} +1 -1
- package/dist/{useLifecycle-DTMczKkf.js → useLifecycle-C9UTzCY8.js} +2 -2
- package/dist/{vega-component-ZTdbCcwI.js → vega-component-i5lZ23n7.js} +19 -19
- package/dist/{vennDiagram-4TSXK5OY-BJ7vqDmn.js → vennDiagram-4TSXK5OY-Cm3EcCcP.js} +1 -1
- package/dist/{wardleyDiagram-VM6X3IG4-D5kWacsn.js → wardleyDiagram-VM6X3IG4-DjlUs2CC.js} +1 -1
- package/dist/{xychartDiagram-S5SC5T6Z-gr15Ws_z.js → xychartDiagram-S5SC5T6Z-DxNDul9l.js} +1 -1
- package/package.json +3 -3
- package/src/__mocks__/animation-frames.ts +31 -0
- package/src/__mocks__/executions.ts +51 -23
- package/src/__mocks__/intersection-observer.ts +45 -0
- package/src/__mocks__/notebook.ts +1 -1
- package/src/__tests__/branded.ts +4 -0
- package/src/__tests__/notebook-analysis.ts +48 -0
- package/src/__tests__/render-tracker.ts +15 -0
- package/src/__tests__/setup.ts +3 -0
- package/src/components/app-config/__tests__/add-model-discovery.test.tsx +30 -0
- package/src/components/app-config/ai-config.tsx +5 -3
- package/src/components/app-config/user-config-form.tsx +1 -1
- package/src/components/data-table/__tests__/export-actions.test.tsx +79 -0
- package/src/components/data-table/export-actions.tsx +64 -19
- package/src/components/data-table/schemas.ts +1 -0
- package/src/components/databases/engine-variable.tsx +2 -2
- package/src/components/dependency-graph/panels.tsx +2 -2
- package/src/components/editor/__tests__/cell-renders.test.tsx +116 -0
- package/src/components/editor/actions/__tests__/name-cell-input.test.tsx +1 -1
- package/src/components/editor/actions/useCellActionButton.tsx +2 -8
- package/src/components/editor/ai/__tests__/completion-utils.test.ts +28 -61
- package/src/components/editor/cell/CreateCellButton.tsx +69 -40
- package/src/components/editor/cell/__tests__/CreateCellButton.test.tsx +49 -0
- package/src/components/editor/cell/__tests__/cell-context-menu.test.tsx +126 -0
- package/src/components/editor/cell/__tests__/useRunCells.test.tsx +5 -5
- package/src/components/editor/cell/cell-context-menu.tsx +202 -111
- package/src/components/editor/cell/code/__tests__/code-placeholder.test.tsx +40 -0
- package/src/components/editor/cell/code/cell-editor.tsx +49 -108
- package/src/components/editor/cell/code/code-placeholder.css +61 -11
- package/src/components/editor/cell/code/code-placeholder.tsx +52 -27
- package/src/components/editor/cell/collapse.tsx +6 -3
- package/src/components/editor/cell/useSplitCell.tsx +2 -2
- package/src/components/editor/chrome/panels/__tests__/secrets-panel.test.tsx +57 -0
- package/src/components/editor/chrome/panels/secrets-panel.tsx +36 -9
- package/src/components/editor/chrome/panels/secrets-utils.ts +20 -0
- package/src/components/editor/chrome/wrapper/__tests__/document-sync-status.test.tsx +5 -2
- package/src/components/editor/chrome/wrapper/__tests__/pending-ai-cells.test.tsx +6 -10
- package/src/components/editor/errors/auto-fix.tsx +8 -7
- package/src/components/editor/header/status.tsx +5 -2
- package/src/components/editor/navigation/__tests__/navigation.test.ts +3 -16
- package/src/components/editor/navigation/focus-utils.ts +20 -8
- package/src/components/editor/navigation/multi-cell-action-toolbar.tsx +3 -11
- package/src/components/editor/navigation/navigation.ts +2 -2
- package/src/components/editor/notebook-cell.tsx +15 -24
- package/src/components/editor/output/MarimoTracebackOutput.tsx +2 -2
- package/src/components/editor/output/console/ConsoleOutput.tsx +77 -50
- package/src/components/editor/output/console/__tests__/ConsoleOutput.test.tsx +28 -0
- package/src/components/editor/renderers/cells-renderer.tsx +3 -2
- package/src/components/editor/renderers/vertical-layout/__tests__/useFocusFirstEditor.test.ts +6 -9
- package/src/components/editor/renderers/vertical-layout/useFocusFirstEditor.ts +2 -5
- package/src/components/find-replace/find-replace.tsx +3 -7
- package/src/components/icons/__tests__/large-spinner.test.tsx +5 -4
- package/src/components/scratchpad/scratchpad.tsx +2 -2
- package/src/components/tracing/tracing-keyboard.test.tsx +4 -3
- package/src/components/ui/__tests__/button-shortcut.test.tsx +22 -0
- package/src/components/ui/__tests__/fullscreen.test.tsx +83 -1
- package/src/components/ui/button.tsx +5 -1
- package/src/components/ui/fullscreen.tsx +43 -89
- package/src/components/variables/__tests__/variables-table.test.tsx +1 -2
- package/src/core/MarimoApp.tsx +1 -1
- package/src/core/__tests__/MarimoApp.test.tsx +147 -0
- package/src/core/ai/__tests__/staged-cells.test.ts +6 -39
- package/src/core/ai/context/providers/__tests__/error.test.ts +6 -3
- package/src/core/ai/staged-cells.ts +8 -35
- package/src/core/ai/tools/__tests__/edit-notebook-tool.test.ts +15 -13
- package/src/core/ai/tools/edit-notebook-tool.ts +13 -8
- package/src/core/cells/__tests__/actions.test.ts +2 -2
- package/src/core/cells/__tests__/add-missing-import.test.ts +14 -9
- package/src/core/cells/__tests__/arrange.test.ts +1 -1
- package/src/core/cells/__tests__/cell-editor-view.test.ts +44 -0
- package/src/core/cells/__tests__/cells.test.ts +0 -1
- package/src/core/cells/__tests__/focus.test.ts +1 -7
- package/src/core/cells/__tests__/harness.ts +9 -8
- package/src/core/cells/__tests__/layout.test.ts +1 -1
- package/src/core/cells/__tests__/pending-delete-service.test.tsx +121 -11
- package/src/core/cells/__tests__/runs.test.ts +14 -14
- package/src/core/cells/__tests__/utils.test.ts +3 -2
- package/src/core/cells/actions.ts +6 -6
- package/src/core/cells/add-missing-import.ts +2 -3
- package/src/core/cells/cells.ts +40 -27
- package/src/core/cells/document.ts +1 -2
- package/src/core/cells/execution-console.ts +10 -5
- package/src/core/cells/focus.ts +1 -1
- package/src/core/cells/ids.ts +2 -4
- package/src/core/cells/pending-delete-service.ts +97 -85
- package/src/core/cells/runs.ts +7 -5
- package/src/core/cells/scrollCellIntoView.ts +4 -14
- package/src/core/cells/session.ts +8 -5
- package/src/core/cells/utils.ts +0 -13
- package/src/core/codemirror/__tests__/cell-documents.test.ts +79 -0
- package/src/core/codemirror/__tests__/debounced-editor-update.test.ts +72 -0
- package/src/core/codemirror/__tests__/editor-mount-scheduler.test.ts +75 -105
- package/src/core/codemirror/__tests__/format.test.ts +85 -63
- package/src/core/codemirror/__tests__/setup.test.ts +61 -1
- package/src/core/codemirror/__tests__/use-lazy-editor-mount.test.tsx +198 -0
- package/src/core/codemirror/cell-documents.ts +132 -0
- package/src/core/codemirror/cells/debugger-decorations.ts +22 -18
- package/src/core/codemirror/cells/line-timing-decorations.ts +13 -11
- package/src/core/codemirror/cells/traceback-decorations.ts +10 -11
- package/src/core/codemirror/code-lens/__tests__/entities.test.ts +7 -11
- package/src/core/codemirror/code-lens/__tests__/extension.test.ts +38 -12
- package/src/core/codemirror/code-lens/__tests__/perf.test.ts +7 -9
- package/src/core/codemirror/code-lens/extension.ts +21 -13
- package/src/core/codemirror/copilot/__tests__/getCodes.test.ts +9 -14
- package/src/core/codemirror/copilot/getCodes.ts +3 -14
- package/src/core/codemirror/debounced-editor-update.ts +41 -0
- package/src/core/codemirror/editor-mount-scheduler.ts +41 -48
- package/src/core/codemirror/extensions.ts +2 -2
- package/src/core/codemirror/find-replace/__tests__/navigate.test.ts +42 -16
- package/src/core/codemirror/find-replace/__tests__/search-highlight.test.ts +30 -0
- package/src/core/codemirror/find-replace/__tests__/unmounted-cells.test.ts +145 -0
- package/src/core/codemirror/find-replace/navigate.ts +88 -129
- package/src/core/codemirror/find-replace/search-highlight.ts +3 -1
- package/src/core/codemirror/find-replace/state.ts +7 -2
- package/src/core/codemirror/format.ts +25 -31
- package/src/core/codemirror/go-to-definition/__tests__/underline.test.ts +58 -0
- package/src/core/codemirror/go-to-definition/__tests__/utils.test.ts +24 -44
- package/src/core/codemirror/go-to-definition/extension.ts +9 -7
- package/src/core/codemirror/go-to-definition/underline.ts +39 -48
- package/src/core/codemirror/language/__tests__/sql.test.ts +36 -0
- package/src/core/codemirror/language/cell-code.ts +7 -0
- package/src/core/codemirror/language/embedded/__tests__/embedded-python.test.ts +2 -18
- package/src/core/codemirror/language/languages/sql/sql.ts +3 -0
- package/src/core/codemirror/lsp/__tests__/notebook-lsp.test.ts +25 -0
- package/src/core/codemirror/lsp/notebook-lsp.ts +6 -16
- package/src/core/codemirror/placeholder/extensions.ts +26 -24
- package/src/core/codemirror/reactive-references/__tests__/extension.test.ts +54 -0
- package/src/core/codemirror/reactive-references/extension.ts +30 -21
- package/src/core/codemirror/use-lazy-editor-mount.ts +70 -0
- package/src/core/codemirror/utils.ts +2 -6
- package/src/core/datasets/__tests__/data-source.test.ts +15 -17
- package/src/core/datasets/data-source-connections.ts +8 -11
- package/src/core/datasets/state.ts +7 -12
- package/src/core/executions/__tests__/atoms.test.ts +211 -5
- package/src/core/executions/__tests__/freshness.test.ts +65 -56
- package/src/core/executions/__tests__/interrupt.test.ts +5 -3
- package/src/core/executions/__tests__/output-lifecycle.test.ts +95 -7
- package/src/core/executions/__tests__/output.test.ts +5 -3
- package/src/core/executions/__tests__/run.test.ts +4 -4
- package/src/core/executions/__tests__/select.test.ts +108 -69
- package/src/core/executions/atoms.ts +248 -83
- package/src/core/executions/freshness.ts +7 -7
- package/src/core/executions/hooks.ts +15 -59
- package/src/core/executions/index.ts +2 -0
- package/src/core/executions/output.ts +49 -35
- package/src/core/executions/select.ts +90 -37
- package/src/core/export/__tests__/hooks.test.ts +1 -1
- package/src/core/islands/__tests__/bridge.test.ts +1 -1
- package/src/core/islands/bootstrap.ts +7 -7
- package/src/core/islands/bridge.ts +1 -1
- package/src/core/meta/__tests__/code-visibility.test.tsx +3 -2
- package/src/core/notebook/document/__tests__/codemirror.test.ts +8 -6
- package/src/core/notebook/document/__tests__/draft.test.ts +56 -58
- package/src/core/notebook/document/__tests__/fixtures.ts +8 -7
- package/src/core/notebook/document/__tests__/hooks.test.tsx +39 -35
- package/src/core/notebook/document/__tests__/lifecycle-scenarios.test.ts +8 -5
- package/src/core/notebook/document/__tests__/model.test.ts +8 -5
- package/src/core/notebook/document/__tests__/protocol-fixtures.ts +2 -2
- package/src/core/notebook/document/__tests__/recovery-scenarios.test.ts +37 -32
- package/src/core/notebook/document/__tests__/scenarios.test.ts +49 -45
- package/src/core/notebook/document/__tests__/state.test.ts +59 -56
- package/src/core/notebook/document/__tests__/submission.test.ts +15 -12
- package/src/core/notebook/document/__tests__/test-host.ts +3 -2
- package/src/core/notebook/document/__tests__/user.ts +7 -3
- package/src/core/notebook/document/draft.ts +29 -11
- package/src/core/notebook/document/state.ts +7 -6
- package/src/core/notebook/replica/__tests__/document.test.ts +9 -5
- package/src/core/notebook/replica/__tests__/executions.test.ts +90 -25
- package/src/core/notebook/replica/__tests__/fixtures.ts +6 -2
- package/src/core/notebook/replica/__tests__/frame.test.ts +206 -0
- package/src/core/notebook/replica/__tests__/once-per-frame.test.ts +95 -0
- package/src/core/notebook/replica/__tests__/replica.test.ts +53 -9
- package/src/core/notebook/replica/__tests__/results.test.ts +27 -29
- package/src/core/notebook/replica/execution-state.ts +2 -2
- package/src/core/notebook/replica/frame.ts +54 -0
- package/src/core/notebook/replica/index.ts +1 -0
- package/src/core/notebook/replica/once-per-frame.ts +60 -0
- package/src/core/notebook/replica/replica.ts +27 -6
- package/src/core/notebook/replica/resources/analysis.ts +1 -1
- package/src/core/notebook/replica/resources/document.ts +9 -8
- package/src/core/notebook/replica/resources/executions.ts +197 -78
- package/src/core/notebook/replica/resources/results.ts +8 -14
- package/src/core/saving/__tests__/document.test.tsx +1 -1
- package/src/core/saving/__tests__/state.test.ts +2 -2
- package/src/core/session/__tests__/useNotebookReplica.hook.test.tsx +55 -9
- package/src/core/session/__tests__/useNotebookSession.hook.test.tsx +230 -12
- package/src/core/session/active-notebook.ts +4 -1
- package/src/core/session/useNotebookReplica.ts +15 -2
- package/src/core/session/useNotebookSession.tsx +38 -46
- package/src/core/state/__tests__/atom-with-selected-inputs.test.ts +48 -0
- package/src/core/state/__tests__/create-keyed-selector-hook.test.tsx +137 -0
- package/src/core/state/atom-with-selected-inputs.ts +24 -0
- package/src/core/state/create-keyed-atom-hook.ts +18 -0
- package/src/core/state/create-keyed-selector-hook.ts +22 -0
- package/src/core/storage/__tests__/state.test.ts +6 -9
- package/src/core/storage/state.ts +5 -8
- package/src/core/transports/__tests__/static.test.ts +3 -2
- package/src/core/transports/static.ts +2 -2
- package/src/core/variables/state.ts +73 -68
- package/src/core/variables/types.ts +2 -2
- package/src/core/vscode/__tests__/is-in-vscode.test.ts +36 -0
- package/src/core/vscode/is-in-vscode.ts +2 -2
- package/src/core/wasm/__tests__/bridge.test.ts +73 -1
- package/src/core/wasm/bridge.ts +5 -4
- package/src/plugins/impl/TextInputPlugin.tsx +2 -1
- package/src/plugins/impl/__test__/text-labels.test.tsx +46 -1
- package/src/utils/__tests__/lazy.test.tsx +33 -0
- package/src/utils/__tests__/shared-intersection-observer.test.ts +49 -0
- package/src/utils/__tests__/shared-resource.test.ts +107 -0
- package/src/utils/arrays.ts +4 -1
- package/src/utils/lazy.tsx +74 -0
- package/src/utils/shared-intersection-observer.ts +53 -0
- package/src/utils/shared-resource.ts +59 -0
- package/src/core/variables/__tests__/state.test.ts +0 -148
- package/src/utils/lazy.ts +0 -35
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
2
|
|
|
3
3
|
import type * as Protocol from "@marimo-team/client/protocol";
|
|
4
|
-
import type { NotebookResource } from "@marimo-team/client";
|
|
4
|
+
import type { HandlerContext, NotebookResource } from "@marimo-team/client";
|
|
5
5
|
import {
|
|
6
6
|
type Result,
|
|
7
7
|
type Results,
|
|
@@ -18,15 +18,15 @@ type ProducedItem =
|
|
|
18
18
|
/** Time the host published the item, when included in a live event. */
|
|
19
19
|
export type Item = ProducedItem & { readonly time?: string };
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
type ExecutionItem = Protocol.Output | Protocol.Variable | Item;
|
|
22
|
+
|
|
23
|
+
/** An execution on the stream, with the items it has produced. */
|
|
22
24
|
export interface Execution extends Result {
|
|
23
25
|
/** Items by id. `itemsInOrder` sorts them by `seq`. */
|
|
24
26
|
readonly lastSeq?: number;
|
|
25
27
|
/** Fast path for a reader displaying exactly the version before an append. */
|
|
26
28
|
readonly append?: { before: WeakRef<Execution["items"]>; item: Item };
|
|
27
29
|
readonly items: ReadonlyMap<Protocol.ItemId, Item>;
|
|
28
|
-
/** The variables the execution bound, by item id. */
|
|
29
|
-
readonly variables: ReadonlyMap<Protocol.ItemId, Protocol.Variable>;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
/**
|
|
@@ -36,11 +36,21 @@ export interface Execution extends Result {
|
|
|
36
36
|
* stays for display while a new execution runs.
|
|
37
37
|
*/
|
|
38
38
|
export interface Executions {
|
|
39
|
-
readonly runs: ReadonlyMap<Protocol.RunId, Protocol.
|
|
39
|
+
readonly runs: ReadonlyMap<Protocol.RunId, Protocol.RunOutput>;
|
|
40
40
|
/** Every execution on the stream, scratch included. */
|
|
41
41
|
readonly executions: ReadonlyMap<Protocol.ExecutionId, Execution>;
|
|
42
|
-
/** The execution
|
|
42
|
+
/** The unfinished execution for each cell, or its latest completed one. */
|
|
43
43
|
readonly latest: ReadonlyMap<Protocol.CellId, Protocol.ExecutionId>;
|
|
44
|
+
/** Bindings by defining cell and item id, shared across unrelated stream updates. */
|
|
45
|
+
readonly variables: ReadonlyMap<
|
|
46
|
+
Protocol.CellId,
|
|
47
|
+
ReadonlyMap<Protocol.ItemId, Protocol.Variable>
|
|
48
|
+
>;
|
|
49
|
+
/** Items received during snapshot or replay before their owning execution. */
|
|
50
|
+
readonly pendingItems?: ReadonlyMap<
|
|
51
|
+
Protocol.ExecutionId,
|
|
52
|
+
readonly ExecutionItem[]
|
|
53
|
+
>;
|
|
44
54
|
readonly results: Results;
|
|
45
55
|
readonly scratch: Result | null;
|
|
46
56
|
/** The latest scratch execution to start, including one that printed nothing. */
|
|
@@ -56,7 +66,7 @@ export interface RunFailure {
|
|
|
56
66
|
readonly completedAt: string;
|
|
57
67
|
}
|
|
58
68
|
|
|
59
|
-
function hostFailure(run: Protocol.
|
|
69
|
+
function hostFailure(run: Protocol.RunOutput): RunFailure | undefined {
|
|
60
70
|
const { state } = run;
|
|
61
71
|
return state.status === "completed" &&
|
|
62
72
|
state.outcome.kind === "failed" &&
|
|
@@ -115,57 +125,60 @@ function retainScratchConsole(
|
|
|
115
125
|
: current;
|
|
116
126
|
}
|
|
117
127
|
|
|
118
|
-
/** Replace an execution
|
|
128
|
+
/** Replace an execution without changing which execution its cell is running. */
|
|
119
129
|
function set(state: Executions, execution: Execution): Executions {
|
|
120
|
-
const { id
|
|
130
|
+
const { id } = execution.record;
|
|
121
131
|
return {
|
|
122
132
|
...state,
|
|
123
133
|
executions: new Map(state.executions).set(id, execution),
|
|
124
134
|
scratchConsole: retainScratchConsole(state, execution),
|
|
125
|
-
latest:
|
|
126
|
-
cellId === null || state.latest.get(cellId) === id
|
|
127
|
-
? state.latest
|
|
128
|
-
: new Map(state.latest).set(cellId, id),
|
|
129
135
|
};
|
|
130
136
|
}
|
|
131
137
|
|
|
132
138
|
function remove(state: Executions, id: Protocol.ExecutionId): Executions {
|
|
133
139
|
const execution = state.executions.get(id);
|
|
134
140
|
if (execution === undefined) {
|
|
135
|
-
return state
|
|
141
|
+
return state.pendingItems?.has(id)
|
|
142
|
+
? { ...state, pendingItems: without(state.pendingItems, id) }
|
|
143
|
+
: state;
|
|
136
144
|
}
|
|
137
145
|
const cellId = execution.record.cell_id;
|
|
146
|
+
const isLatest = cellId !== null && state.latest.get(cellId) === id;
|
|
147
|
+
const executions = without(state.executions, id);
|
|
148
|
+
let latest = state.latest;
|
|
149
|
+
if (isLatest) {
|
|
150
|
+
const retained = state.results.get(cellId);
|
|
151
|
+
latest =
|
|
152
|
+
retained && executions.has(retained.record.id)
|
|
153
|
+
? new Map(latest).set(cellId, retained.record.id)
|
|
154
|
+
: without(latest, cellId);
|
|
155
|
+
}
|
|
138
156
|
return {
|
|
139
157
|
...state,
|
|
140
|
-
executions
|
|
158
|
+
executions,
|
|
159
|
+
latest,
|
|
160
|
+
variables: isLatest ? without(state.variables, cellId) : state.variables,
|
|
141
161
|
scratchConsole:
|
|
142
162
|
state.scratchConsole?.record.id === id ? undefined : state.scratchConsole,
|
|
143
|
-
latest:
|
|
144
|
-
cellId !== null && state.latest.get(cellId) === id
|
|
145
|
-
? without(state.latest, cellId)
|
|
146
|
-
: state.latest,
|
|
147
163
|
};
|
|
148
164
|
}
|
|
149
165
|
|
|
150
|
-
function
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
166
|
+
function withRows(execution: Execution, entries: readonly Item[]): Execution {
|
|
167
|
+
const items = new Map(execution.items);
|
|
168
|
+
let lastSeq = execution.lastSeq ?? -1;
|
|
169
|
+
let append: Execution["append"];
|
|
170
|
+
for (let item of entries) {
|
|
171
|
+
const original = items.get(item.id);
|
|
172
|
+
if (original) {
|
|
173
|
+
// An input keeps the position and time of its first prompt.
|
|
174
|
+
item = { ...item, time: original.time };
|
|
175
|
+
} else if (entries.length === 1 && item.seq > lastSeq) {
|
|
176
|
+
append = { before: new WeakRef(execution.items), item };
|
|
177
|
+
}
|
|
178
|
+
items.set(item.id, item);
|
|
179
|
+
lastSeq = Math.max(lastSeq, item.seq);
|
|
159
180
|
}
|
|
160
|
-
return
|
|
161
|
-
...execution,
|
|
162
|
-
append:
|
|
163
|
-
!original && item.seq > (execution.lastSeq ?? -1)
|
|
164
|
-
? { before: new WeakRef(execution.items), item }
|
|
165
|
-
: undefined,
|
|
166
|
-
lastSeq: Math.max(execution.lastSeq ?? -1, item.seq),
|
|
167
|
-
items: new Map(execution.items).set(item.id, item),
|
|
168
|
-
});
|
|
181
|
+
return { ...execution, append, lastSeq, items };
|
|
169
182
|
}
|
|
170
183
|
|
|
171
184
|
function detach(state: Executions, itemId: Protocol.ItemId): Executions {
|
|
@@ -178,27 +191,57 @@ function detach(state: Executions, itemId: Protocol.ItemId): Executions {
|
|
|
178
191
|
});
|
|
179
192
|
}
|
|
180
193
|
}
|
|
181
|
-
return state;
|
|
194
|
+
return removePendingItem(state, itemId);
|
|
182
195
|
}
|
|
183
196
|
|
|
184
|
-
function bind(
|
|
185
|
-
|
|
186
|
-
|
|
197
|
+
function bind(
|
|
198
|
+
state: Executions,
|
|
199
|
+
execution: Execution,
|
|
200
|
+
variable: Protocol.Variable,
|
|
201
|
+
): Executions {
|
|
202
|
+
const cellId = execution.record.cell_id;
|
|
203
|
+
if (cellId === null) {
|
|
187
204
|
return state;
|
|
188
205
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
206
|
+
const bindings = new Map(state.variables.get(cellId)).set(
|
|
207
|
+
variable.id,
|
|
208
|
+
variable,
|
|
209
|
+
);
|
|
210
|
+
return {
|
|
211
|
+
...state,
|
|
212
|
+
variables: new Map(state.variables).set(cellId, bindings),
|
|
213
|
+
};
|
|
193
214
|
}
|
|
194
215
|
|
|
195
216
|
function unbind(state: Executions, itemId: Protocol.ItemId): Executions {
|
|
196
|
-
for (const
|
|
197
|
-
if (
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
variables
|
|
201
|
-
}
|
|
217
|
+
for (const [cellId, bindings] of state.variables) {
|
|
218
|
+
if (bindings.has(itemId)) {
|
|
219
|
+
const variables = new Map(state.variables);
|
|
220
|
+
if (bindings.size === 1) {
|
|
221
|
+
variables.delete(cellId);
|
|
222
|
+
} else {
|
|
223
|
+
variables.set(cellId, without(bindings, itemId));
|
|
224
|
+
}
|
|
225
|
+
return { ...state, variables };
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
return removePendingItem(state, itemId);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function removePendingItem(
|
|
232
|
+
state: Executions,
|
|
233
|
+
itemId: Protocol.ItemId,
|
|
234
|
+
): Executions {
|
|
235
|
+
for (const [id, items] of state.pendingItems ?? []) {
|
|
236
|
+
if (items.some((item) => item.id === itemId)) {
|
|
237
|
+
const remaining = items.filter((item) => item.id !== itemId);
|
|
238
|
+
const pendingItems = new Map(state.pendingItems);
|
|
239
|
+
if (remaining.length === 0) {
|
|
240
|
+
pendingItems.delete(id);
|
|
241
|
+
} else {
|
|
242
|
+
pendingItems.set(id, remaining);
|
|
243
|
+
}
|
|
244
|
+
return { ...state, pendingItems };
|
|
202
245
|
}
|
|
203
246
|
}
|
|
204
247
|
return state;
|
|
@@ -220,6 +263,37 @@ function update(state: Executions, execution: Execution): Executions {
|
|
|
220
263
|
};
|
|
221
264
|
}
|
|
222
265
|
|
|
266
|
+
function receiveItem(
|
|
267
|
+
state: Executions,
|
|
268
|
+
item: ExecutionItem,
|
|
269
|
+
phase: HandlerContext["phase"],
|
|
270
|
+
): Executions {
|
|
271
|
+
const id = item.execution_id;
|
|
272
|
+
const execution = state.executions.get(id);
|
|
273
|
+
if (execution === undefined) {
|
|
274
|
+
if (phase === "live") {
|
|
275
|
+
return state;
|
|
276
|
+
}
|
|
277
|
+
const items = state.pendingItems?.get(id) ?? [];
|
|
278
|
+
return {
|
|
279
|
+
...state,
|
|
280
|
+
pendingItems: new Map(state.pendingItems).set(id, [...items, item]),
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
if ("kind" in item) {
|
|
284
|
+
return set(state, withRows(execution, [item]));
|
|
285
|
+
}
|
|
286
|
+
if ("revision" in item) {
|
|
287
|
+
return bind(state, execution, item);
|
|
288
|
+
}
|
|
289
|
+
const next = { ...execution, output: item };
|
|
290
|
+
return update(state, {
|
|
291
|
+
...next,
|
|
292
|
+
outputVersion:
|
|
293
|
+
execution.outputVersion + (sameShown(execution, next) ? 0 : 1),
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
|
|
223
297
|
/** Carry displayed results and their revisions through a replacement snapshot. */
|
|
224
298
|
export function resumeResults(
|
|
225
299
|
next: Executions,
|
|
@@ -282,14 +356,25 @@ export const executions: NotebookResource<Executions, Kind> = {
|
|
|
282
356
|
runs: new Map(),
|
|
283
357
|
executions: new Map(),
|
|
284
358
|
latest: new Map(),
|
|
359
|
+
variables: new Map(),
|
|
285
360
|
results: new Map(),
|
|
286
361
|
scratch: null,
|
|
287
362
|
},
|
|
288
363
|
on: {
|
|
289
|
-
cell: (state, { data }) =>
|
|
290
|
-
state.results.has(
|
|
291
|
-
|
|
292
|
-
|
|
364
|
+
cell: (state, { data: { cell } }, { phase }) => {
|
|
365
|
+
if (state.results.has(cell.id)) {
|
|
366
|
+
return state;
|
|
367
|
+
}
|
|
368
|
+
let results: Results = new Map(state.results).set(cell.id, null);
|
|
369
|
+
if (phase !== "live" && state.latest.has(cell.id)) {
|
|
370
|
+
for (const execution of state.executions.values()) {
|
|
371
|
+
if (execution.record.cell_id === cell.id) {
|
|
372
|
+
results = retainResult(results, execution);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
return { ...state, results };
|
|
377
|
+
},
|
|
293
378
|
"cell.removed": (state, { data }) => ({
|
|
294
379
|
...state,
|
|
295
380
|
results: without(state.results, data.id),
|
|
@@ -307,10 +392,10 @@ export const executions: NotebookResource<Executions, Kind> = {
|
|
|
307
392
|
state.runs.has(data.id)
|
|
308
393
|
? { ...state, runs: without(state.runs, data.id) }
|
|
309
394
|
: state,
|
|
310
|
-
execution: (state, { data: { execution: record } }) => {
|
|
395
|
+
execution: (state, { data: { execution: record } }, { phase }) => {
|
|
311
396
|
const previous = state.executions.get(record.id);
|
|
312
397
|
const next = { record, output: previous?.output ?? null };
|
|
313
|
-
|
|
398
|
+
const execution: Execution = {
|
|
314
399
|
...next,
|
|
315
400
|
outputVersion:
|
|
316
401
|
previous === undefined
|
|
@@ -319,30 +404,64 @@ export const executions: NotebookResource<Executions, Kind> = {
|
|
|
319
404
|
append: previous?.append,
|
|
320
405
|
lastSeq: previous?.lastSeq,
|
|
321
406
|
items: previous?.items ?? new Map(),
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
407
|
+
};
|
|
408
|
+
const items = state.pendingItems?.get(record.id);
|
|
409
|
+
// All buffered console rows and prompts appear in this single update.
|
|
410
|
+
const rows = items?.filter((item) => "kind" in item);
|
|
411
|
+
let updated = update(
|
|
412
|
+
state,
|
|
413
|
+
rows?.length ? withRows(execution, rows) : execution,
|
|
414
|
+
);
|
|
415
|
+
if (items && state.pendingItems) {
|
|
416
|
+
updated = {
|
|
417
|
+
...updated,
|
|
418
|
+
pendingItems: without(state.pendingItems, record.id),
|
|
419
|
+
};
|
|
420
|
+
for (const item of items) {
|
|
421
|
+
if (!("kind" in item)) {
|
|
422
|
+
updated = receiveItem(updated, item, phase);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
330
425
|
}
|
|
331
|
-
const
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
426
|
+
const cellId = record.cell_id;
|
|
427
|
+
if (cellId === null || previous !== undefined) {
|
|
428
|
+
return updated;
|
|
429
|
+
}
|
|
430
|
+
const latest = state.latest.get(cellId);
|
|
431
|
+
// A snapshot can deliver the completed predecessor after its successor.
|
|
432
|
+
if (
|
|
433
|
+
phase === "snapshot" &&
|
|
434
|
+
latest !== undefined &&
|
|
435
|
+
record.state.status === "completed" &&
|
|
436
|
+
state.executions.get(latest)?.record.state.status !== "completed"
|
|
437
|
+
) {
|
|
438
|
+
return updated;
|
|
439
|
+
}
|
|
440
|
+
return {
|
|
441
|
+
...updated,
|
|
442
|
+
latest: new Map(state.latest).set(cellId, record.id),
|
|
443
|
+
};
|
|
337
444
|
},
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
445
|
+
"execution.removed": (state, { data }) => remove(state, data.id),
|
|
446
|
+
output: (state, { data }, { phase }) =>
|
|
447
|
+
receiveItem(state, data.output, phase),
|
|
448
|
+
console: (state, { data }, { phase }) =>
|
|
449
|
+
receiveItem(
|
|
450
|
+
state,
|
|
451
|
+
{ ...data.console, kind: "console", time: data.time },
|
|
452
|
+
phase,
|
|
453
|
+
),
|
|
342
454
|
"console.removed": (state, { data }) => detach(state, data.id),
|
|
343
|
-
input: (state, { data }) =>
|
|
344
|
-
|
|
345
|
-
|
|
455
|
+
input: (state, { data }, { phase }) =>
|
|
456
|
+
receiveItem(
|
|
457
|
+
state,
|
|
458
|
+
{ ...data.input, kind: "input", time: data.time },
|
|
459
|
+
phase,
|
|
460
|
+
),
|
|
461
|
+
variable: (state, { data }, { phase }) =>
|
|
462
|
+
receiveItem(state, data.variable, phase),
|
|
346
463
|
"variable.removed": (state, { data }) => unbind(state, data.id),
|
|
464
|
+
ready: (state) =>
|
|
465
|
+
state.pendingItems ? { ...state, pendingItems: undefined } : state,
|
|
347
466
|
},
|
|
348
467
|
};
|
|
@@ -5,7 +5,7 @@ import { completedAt, shown, startedAt } from "../execution-state";
|
|
|
5
5
|
|
|
6
6
|
/** An execution record and its output, with the local revision of what it shows. */
|
|
7
7
|
export interface Result {
|
|
8
|
-
readonly record: Protocol.
|
|
8
|
+
readonly record: Protocol.ExecutionOutput;
|
|
9
9
|
/** The execution's output item, null until it sets one. */
|
|
10
10
|
readonly output: Protocol.Output | null;
|
|
11
11
|
/** Unchanged by lifecycle-only events. */
|
|
@@ -13,21 +13,15 @@ export interface Result {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
* Each document cell's last completed execution
|
|
16
|
+
* Each document cell's last completed execution that was not superseded.
|
|
17
17
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* while it runs again. The record, its output, and the output revision are
|
|
22
|
-
* kept; the items and variables stay with the stream's copy of the execution.
|
|
18
|
+
* A superseded attempt leaves the previous result visible while its replacement
|
|
19
|
+
* is queued or running. The result holds the record, its output, and the
|
|
20
|
+
* output revision. Other items stay with the stream's copy of the execution.
|
|
23
21
|
*
|
|
24
22
|
* A cell has an entry from its `cell` event until its removal, null until
|
|
25
|
-
* it
|
|
26
|
-
*
|
|
27
|
-
* no longer has.
|
|
28
|
-
*
|
|
29
|
-
* An execution the host skipped as superseded never ran, and a newer one
|
|
30
|
-
* for the same cell is on its way, so it does not replace the result.
|
|
23
|
+
* it has a result. If the cell arrives after its execution during catch-up,
|
|
24
|
+
* the replica fills its entry from the execution it has already received.
|
|
31
25
|
*/
|
|
32
26
|
export type Results = ReadonlyMap<Protocol.CellId, Result | null>;
|
|
33
27
|
|
|
@@ -55,7 +49,7 @@ export function retainScratchResult(
|
|
|
55
49
|
if (record.cell_id !== null || shown(result) === null) {
|
|
56
50
|
return previous;
|
|
57
51
|
}
|
|
58
|
-
const time = (execution: Protocol.
|
|
52
|
+
const time = (execution: Protocol.ExecutionOutput) =>
|
|
59
53
|
Date.parse(
|
|
60
54
|
completedAt(execution) ?? startedAt(execution) ?? "1970-01-01T00:00:00Z",
|
|
61
55
|
);
|
|
@@ -17,7 +17,7 @@ import { activeNotebookReplicaAtom } from "@/core/session/active-notebook";
|
|
|
17
17
|
import { Deferred } from "@/utils/Deferred";
|
|
18
18
|
import { useNotebookDocumentSave } from "../document";
|
|
19
19
|
|
|
20
|
-
const confirmed: Protocol.
|
|
20
|
+
const confirmed: Protocol.DocumentOutput = {
|
|
21
21
|
notebook_id: "n1",
|
|
22
22
|
order: [],
|
|
23
23
|
app_config: {},
|
|
@@ -17,8 +17,8 @@ import { initialLayoutState, layoutStateAtom } from "../../layout/state";
|
|
|
17
17
|
import { documentVersionAtom, needsSaveAtom, savedLayoutAtom } from "../state";
|
|
18
18
|
|
|
19
19
|
function revision(
|
|
20
|
-
overrides: Partial<Protocol.
|
|
21
|
-
): Protocol.
|
|
20
|
+
overrides: Partial<Protocol.DocumentOutput> = {},
|
|
21
|
+
): Protocol.DocumentOutput {
|
|
22
22
|
return {
|
|
23
23
|
notebook_id: "nb",
|
|
24
24
|
order: [],
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { act, renderHook } from "@testing-library/react";
|
|
5
5
|
import { createStore, Provider } from "jotai";
|
|
6
6
|
import type { PropsWithChildren } from "react";
|
|
7
|
-
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
7
|
+
import { beforeEach, describe, expect, it, vi, onTestFinished } from "vitest";
|
|
8
8
|
import type { NotebookTransport } from "@marimo-team/client";
|
|
9
9
|
import type { AttachmentOutput } from "@marimo-team/client/protocol";
|
|
10
10
|
import { ConnectionState } from "../types";
|
|
@@ -14,15 +14,19 @@ import {
|
|
|
14
14
|
fakeBackend,
|
|
15
15
|
fixtureMessages,
|
|
16
16
|
} from "../../notebook/replica/__tests__/fixtures";
|
|
17
|
+
import { mockAnimationFrames } from "@/__mocks__/animation-frames";
|
|
17
18
|
import { useNotebookAttachments } from "@/core/notebook";
|
|
18
|
-
import {
|
|
19
|
+
import {
|
|
20
|
+
activeNotebookReplicaAtom,
|
|
21
|
+
activeNotebookFrameAtom,
|
|
22
|
+
} from "../active-notebook";
|
|
19
23
|
|
|
20
24
|
vi.mock("../backend", () => ({ createEditorBackend: vi.fn() }));
|
|
21
25
|
|
|
22
26
|
/** A host-framed native notification. */
|
|
23
27
|
const notification = {
|
|
24
28
|
event: "marimo",
|
|
25
|
-
data: { marimo: { op: "
|
|
29
|
+
data: { marimo: { op: "reload" } },
|
|
26
30
|
};
|
|
27
31
|
|
|
28
32
|
/** A transport whose connections the test drives. */
|
|
@@ -95,9 +99,12 @@ describe("useNotebookReplica", () => {
|
|
|
95
99
|
await act(async () => Promise.resolve());
|
|
96
100
|
expect(store.get(activeNotebookReplicaAtom)).toBe(result.current);
|
|
97
101
|
const [connection] = fake.opened;
|
|
102
|
+
const receive = (message: unknown) => {
|
|
103
|
+
connection.receive(message);
|
|
104
|
+
};
|
|
98
105
|
act(() => {
|
|
99
106
|
connection.open();
|
|
100
|
-
fixtureMessages("notebook-events.sse").forEach(
|
|
107
|
+
fixtureMessages("notebook-events.sse").forEach(receive);
|
|
101
108
|
});
|
|
102
109
|
expect(attachments.result.current.agents).toEqual([
|
|
103
110
|
{
|
|
@@ -120,7 +127,7 @@ describe("useNotebookReplica", () => {
|
|
|
120
127
|
(attachment) => attachment.kind === "browser",
|
|
121
128
|
)!;
|
|
122
129
|
act(() =>
|
|
123
|
-
|
|
130
|
+
receive({
|
|
124
131
|
event: "attachment",
|
|
125
132
|
data: { attachment: { ...browser, name: "Firefox" } },
|
|
126
133
|
}),
|
|
@@ -129,7 +136,7 @@ describe("useNotebookReplica", () => {
|
|
|
129
136
|
|
|
130
137
|
const renamedAgent = { ...agents[0], name: "Renamed agent" };
|
|
131
138
|
act(() =>
|
|
132
|
-
|
|
139
|
+
receive({
|
|
133
140
|
event: "attachment",
|
|
134
141
|
data: { attachment: renamedAgent },
|
|
135
142
|
}),
|
|
@@ -151,10 +158,12 @@ describe("useNotebookReplica", () => {
|
|
|
151
158
|
await act(async () => Promise.resolve());
|
|
152
159
|
const onNotification = vi.fn();
|
|
153
160
|
rerender({ ...options, onNotification, url: () => "ws://redirected/ws" });
|
|
154
|
-
act(() =>
|
|
161
|
+
act(() => {
|
|
162
|
+
fake.notify();
|
|
163
|
+
});
|
|
155
164
|
expect(options.onNotification).not.toHaveBeenCalled();
|
|
156
165
|
expect(onNotification).toHaveBeenCalledExactlyOnceWith({
|
|
157
|
-
data: { op: "
|
|
166
|
+
data: { op: "reload" },
|
|
158
167
|
});
|
|
159
168
|
const [{ url }] = vi.mocked(createEditorBackend).mock.calls[0];
|
|
160
169
|
expect(url()).toBe("ws://redirected/ws");
|
|
@@ -176,7 +185,9 @@ describe("useNotebookReplica", () => {
|
|
|
176
185
|
expect(store.get(result.current.connectionAtom)).toEqual({
|
|
177
186
|
state: ConnectionState.OPEN,
|
|
178
187
|
});
|
|
179
|
-
act(() =>
|
|
188
|
+
act(() => {
|
|
189
|
+
fake.opened.forEach((attempt) => attempt.receive(notification));
|
|
190
|
+
});
|
|
180
191
|
expect(options.onNotification).toHaveBeenCalledOnce();
|
|
181
192
|
unmount();
|
|
182
193
|
expect(active.signal.aborted).toBe(true);
|
|
@@ -185,3 +196,38 @@ describe("useNotebookReplica", () => {
|
|
|
185
196
|
expect(fake.opened).toHaveLength(attempts);
|
|
186
197
|
});
|
|
187
198
|
});
|
|
199
|
+
|
|
200
|
+
it("publishes views once per frame while delivering notifications immediately", async () => {
|
|
201
|
+
const advanceFrame = mockAnimationFrames();
|
|
202
|
+
const fake = makeTransport();
|
|
203
|
+
vi.mocked(createEditorBackend).mockReturnValue(
|
|
204
|
+
fakeBackend({ transport: fake.transport }),
|
|
205
|
+
);
|
|
206
|
+
const { result, options, store, unmount } = setup();
|
|
207
|
+
onTestFinished(unmount);
|
|
208
|
+
await act(async () => Promise.resolve());
|
|
209
|
+
const [connection] = fake.opened;
|
|
210
|
+
act(() => {
|
|
211
|
+
connection.open();
|
|
212
|
+
fixtureMessages("notebook-events.sse").forEach(connection.receive);
|
|
213
|
+
});
|
|
214
|
+
act(advanceFrame);
|
|
215
|
+
const changed = vi.fn();
|
|
216
|
+
const frame = store.get(activeNotebookFrameAtom)!;
|
|
217
|
+
onTestFinished(store.sub(frame.executionsAtom, changed));
|
|
218
|
+
options.onNotification.mockClear();
|
|
219
|
+
act(() => {
|
|
220
|
+
fixtureMessages("run-cells.sse").forEach(connection.receive);
|
|
221
|
+
connection.receive(notification);
|
|
222
|
+
});
|
|
223
|
+
expect(changed).not.toHaveBeenCalled();
|
|
224
|
+
expect(options.onNotification).toHaveBeenCalledOnce();
|
|
225
|
+
expect(store.get(result.current.executionsAtom)).not.toBe(
|
|
226
|
+
store.get(frame.executionsAtom),
|
|
227
|
+
);
|
|
228
|
+
act(advanceFrame);
|
|
229
|
+
expect(changed).toHaveBeenCalledTimes(1);
|
|
230
|
+
expect(options.onNotification).toHaveBeenCalledExactlyOnceWith({
|
|
231
|
+
data: { op: "reload" },
|
|
232
|
+
});
|
|
233
|
+
});
|