@marimo-team/islands 0.25.3-dev99 → 0.26.1-dev0
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-Dhf5EGs5.js → ConnectedDataExplorerComponent-DtwVgVpX.js} +190 -214
- package/dist/ErrorBoundary-BAPXZkp8.js +213 -0
- package/dist/{ImageComparisonComponent-uU8FSKZE.js → ImageComparisonComponent-CoiwlCwG.js} +20 -20
- package/dist/{Plot-DdYOe1UK.js → Plot-BHJLG4xm.js} +2474 -3107
- package/dist/_baseSet-Bd5zh2yg.js +327 -0
- package/dist/{abnfDiagram-VCTEODGH-Di400kYu.js → abnfDiagram-VCTEODGH-BbZOIueZ.js} +5 -5
- package/dist/{any-language-editor-k2B8YI3Y.js → any-language-editor-yG-YmLaK.js} +9 -9
- package/dist/{apl-GEW9-ZP1.js → apl-stFrI2NB.js} +1 -1
- package/dist/{arc-7ra3iNdN.js → arc-4W6H62B5.js} +1 -1
- package/dist/architecture-7GRP2DOG-GlkXha5_.js +2 -0
- package/dist/{architectureDiagram-5GKGNRK7-BdTJcsNJ.js → architectureDiagram-5GKGNRK7-qjLjxapm.js} +48 -64
- package/dist/{arrays-R6JsImiT.js → arrays-DoQ-AILx.js} +7 -27
- package/dist/{asciiarmor-BWNxzkG7.js → asciiarmor-DHwFuaIC.js} +1 -1
- package/dist/{asn1-Bcn2QutK.js → asn1-KIH4fwAq.js} +1 -1
- package/dist/assertNever-DywGMo-S.js +507 -0
- package/dist/assets/__vite-browser-external-DZv_7F5P.js +1 -0
- package/dist/assets/worker-cHYZNFD4.js +171 -0
- package/dist/{blockDiagram-I7D4REHJ-Cg25UrxT.js → blockDiagram-I7D4REHJ-BoCyD5KO.js} +28 -39
- package/dist/{brainfuck-BQCYDheZ.js → brainfuck-UPAij4U9.js} +1 -1
- package/dist/{button-BxB3RDjN.js → button-qQhINE7z.js} +63 -63
- package/dist/{c4Diagram-7LVT6UL2-BxFgrnNV.js → c4Diagram-7LVT6UL2-DmcTtm4p.js} +8 -8
- package/dist/{capabilities-BgR0osfN.js → capabilities-DKqMqBzm.js} +2 -2
- package/dist/{channel-CPObtJXj.js → channel-B9eaiezW.js} +1 -1
- package/dist/{chat-ui-BIgPxfPP.js → chat-ui-D5YPIONI.js} +3110 -2917
- package/dist/{check-P35dc2dH.js → check-jchHMCfs.js} +1 -1
- package/dist/{chunk-4HAMMTFA-D4eFPyFh.js → chunk-4HAMMTFA-qKgadZwy.js} +6 -6
- package/dist/{chunk-75Z2AOVW-D7gxIs2Q.js → chunk-75Z2AOVW-76L6My3P.js} +4 -4
- package/dist/{chunk-YOKDWASO-DKplTrBY.js → chunk-7TTQLYRW-DBSfUUe5.js} +6253 -5835
- package/dist/{chunk-DU6HZSFF-BwiyaNpg.js → chunk-DU6HZSFF-4SDIhUTY.js} +14 -22
- package/dist/{chunk-F27PBJKO-ufseIn5y.js → chunk-F27PBJKO-COH2t-FO.js} +3 -3
- package/dist/{chunk-FOHPRMQF-BpYR8RqP.js → chunk-FOHPRMQF-ezmr_yWy.js} +49 -58
- package/dist/{chunk-GMAD6QVW-BhaJx0X3.js → chunk-GMAD6QVW-BJGF8QZL.js} +16 -75
- package/dist/{chunk-GVQU2GXP-Cwbt-lF0.js → chunk-GVQU2GXP-BkolpSXU.js} +3 -3
- package/dist/{chunk-IMKFNOWR-mtD7aJBw.js → chunk-IMKFNOWR-BzDY1_I7.js} +8 -8
- package/dist/{chunk-L3NEJ4N5-n-zgIVSy.js → chunk-L3NEJ4N5-B-BFQp9t.js} +6 -6
- package/dist/{chunk-OSK3NFVY-DXa-Cxbn.js → chunk-OSK3NFVY-BzfZ4VBG.js} +8 -8
- package/dist/{chunk-P2QGCYS3-B_Zd3-X0.js → chunk-P2QGCYS3-DJApLVdt.js} +1 -1
- package/dist/{chunk-POPQ4Y6H-hYOXbYH_.js → chunk-POPQ4Y6H-BFSZel4w.js} +2 -2
- package/dist/{chunk-PWAF6VOD-CQw5qATZ.js → chunk-PWAF6VOD-CRu_RGP2.js} +2 -2
- package/dist/{chunk-SHT3W25Y-DybB1ShH.js → chunk-SHT3W25Y-DbHsMKdo.js} +10 -10
- package/dist/{chunk-SVP7TREG-DNhhdCex.js → chunk-SVP7TREG-CtwnwAE6.js} +3 -3
- package/dist/{chunk-TICWLB2K-NhAQhlDf.js → chunk-TICWLB2K-C5Z5QMbO.js} +10 -10
- package/dist/{chunk-XXDRQBXY-Dnl5VBqG.js → chunk-XXDRQBXY-BM-YIt-_.js} +1 -1
- package/dist/classDiagram-ZZMXUADV-B8E5Hn78.js +30 -0
- package/dist/classDiagram-v2-VYDZK3BY-DeGsK9bT.js +30 -0
- package/dist/{clike-CxK9W55Z.js → clike-xU8sCVU1.js} +2 -6
- package/dist/{clojure-Dzcvwpxk.js → clojure-psoSEo36.js} +1 -1
- package/dist/{cmake-DYr-71zp.js → cmake-DDHBwlE7.js} +1 -1
- package/dist/{cobol-DC3g37Kq.js → cobol-C4qjDcIq.js} +1 -1
- package/dist/code-visibility-Ebrgx-u3.js +130 -0
- package/dist/{coffeescript-C-eFwH5N.js → coffeescript-D6UgrGgo.js} +1 -1
- package/dist/{common-iaqaS3Sy.js → common-Capdc2h_.js} +10975 -10314
- package/dist/{commonlisp-CyaNXrJR.js → commonlisp-B0ChVjnu.js} +1 -1
- package/dist/{compiler-runtime-CldRdSsv.js → compiler-runtime-C5KHtL5D.js} +3 -3
- package/dist/{toDate-DKH0_kMo.js → config-qTaTHnpE.js} +96 -180
- package/dist/{copy-icon-CPoxUG7G.js → copy-icon-BI7vZHEW.js} +46 -41
- package/dist/{cose-bilkent-JH36ORCC-_LyRKVqm.js → cose-bilkent-JH36ORCC-B_Oz4vMP.js} +58 -71
- package/dist/createReducer-DdSLRfBT.js +67 -0
- package/dist/{crystal-ih5ax5tQ.js → crystal-DZsc9Ue0.js} +1 -1
- package/dist/{css-CN_wP7_R.js → css-DkYRnQ9U.js} +1 -1
- package/dist/{cubic-OaEBhQPK.js → cubic-CA80xY_e.js} +6 -7
- package/dist/cynefin-OW5HDTMX-0-HehVvH.js +2 -0
- package/dist/{cynefinDiagram-5FMLGOSQ-CX22wa7c.js → cynefinDiagram-5FMLGOSQ-NDedRwsw.js} +5 -5
- package/dist/{cypher-CqGRcmZo.js → cypher-CpWPqgvy.js} +1 -1
- package/dist/{cytoscape.esm-jJhXJpLB.js → cytoscape.esm-BbeMznK5.js} +411 -512
- package/dist/{d-Cj0sOW2z.js → d-Bx2ggfYO.js} +1 -1
- package/dist/{dagre-BGSfXNEb.js → dagre-CpjuekF1.js} +550 -700
- package/dist/{dagre-GXQ25YYZ-Df6Pp-cl.js → dagre-GXQ25YYZ-De0sSZO7.js} +14 -16
- package/dist/{data-grid-overlay-editor-C_cWoUm0.js → data-grid-overlay-editor-CErEC4xn.js} +8 -8
- package/dist/{data-grid-types-0PJ-9N5n.js → data-grid-types-DIX_pCco.js} +2 -2
- package/dist/{debounce-C3jyATpc.js → debounce-DrhhziJv.js} +2 -2
- package/dist/{diagram-S7CK7UJ4-CctU9kVx.js → diagram-S7CK7UJ4-wBtVl61y.js} +7 -15
- package/dist/{diagram-UQ7AKVKN-FVHjCF9j.js → diagram-UQ7AKVKN-CKWE3c1T.js} +5 -5
- package/dist/{diagram-VSXAHHWV-BJWcVVJY.js → diagram-VSXAHHWV-LXjisZoM.js} +6 -6
- package/dist/{diagram-VX7I27RA-BSDbwFFv.js → diagram-VX7I27RA-D2Ac5198.js} +7 -7
- package/dist/{diagram-Z3DM3KII-BX8kW7Nc.js → diagram-Z3DM3KII-CYaFOQcI.js} +5 -5
- package/dist/{dialog-C1PcpCqX.js → dialog-Ic6dh09m.js} +25 -25
- package/dist/{diff-B_hUkiat.js → diff-DNXaJS8v.js} +1 -1
- package/dist/{dist-Bvs24R_E.js → dist-B1qu3Bez.js} +55 -54
- package/dist/{dist-D-wwqlzJ.js → dist-BEcpQbZa.js} +78 -77
- package/dist/{dist-CrSP_H1M.js → dist-BMz__bo5.js} +317 -317
- package/dist/{dist-Cg7gzw-a.js → dist-BagHbFqG.js} +70 -69
- package/dist/{dist-C8fAKSH1.js → dist-BdUitvVW.js} +65 -64
- package/dist/{dist-BuaRHxOc.js → dist-BfrgytDR.js} +45 -44
- package/dist/{dist-CSJ0MDRw.js → dist-BozTF_gH.js} +56 -55
- package/dist/{dist-DiDibOYr.js → dist-BreKIQqQ.js} +149 -148
- package/dist/{dist-CN8zI-XC.js → dist-BsE4gQHj.js} +555 -555
- package/dist/{dist-F8Ep36rk.js → dist-BunZKA_9.js} +60 -59
- package/dist/dist-BvZpdAuG.js +850 -0
- package/dist/{dist-DUAh96QY.js → dist-CB9MzCXv.js} +1 -1
- package/dist/{dist-BK4Oj99o.js → dist-CDVvitRS.js} +18 -17
- package/dist/{dist-CN_BeG2I.js → dist-CEomphG1.js} +59 -58
- package/dist/{dist-BMQf5zIS.js → dist-ChcBm3jk.js} +166 -165
- package/dist/{dist-Lm-D-Vr6.js → dist-CiSkXlAO.js} +3 -3
- package/dist/{dist-D6d86eNJ.js → dist-Cshl6jBw.js} +46 -45
- package/dist/{dist-DBtSl3sf.js → dist-D1D56-GS.js} +54 -56
- package/dist/{dist-DoE4XJBC.js → dist-D92tYjLc.js} +9845 -10688
- package/dist/{dist-OR1OnN-y.js → dist-D95Cd4xm.js} +53 -52
- package/dist/{dist-BorMD-uX.js → dist-DNkrY12t.js} +94 -93
- package/dist/{dist-BLfKmR-l.js → dist-DneeBk3K.js} +18 -17
- package/dist/{dist-diIx5qJW.js → dist-DpYpG8Yc.js} +37 -36
- package/dist/{dist-CkTTIdBe.js → dist-MggMo7OR.js} +243 -243
- package/dist/{dist-PXYI_yuP.js → dist-ObeTgSmf.js} +27 -26
- package/dist/{dist-CLdpGQVr.js → dist-OmeAz0fR.js} +114 -116
- package/dist/{dist-CSbh1PNP.js → dist-TGSwzj8a.js} +26 -25
- package/dist/dropdown-menu-Dhv4fcNl.js +5982 -0
- package/dist/{dtd-B8FGSWWe.js → dtd-D1YZQCVT.js} +1 -1
- package/dist/duckdb-keywords-CdzX4o33.js +3 -0
- package/dist/{dylan-DbIBYIrw.js → dylan-CxbG-PUm.js} +2 -2
- package/dist/{ebnfDiagram-PWID7BFC-DtapdLet.js → ebnfDiagram-PWID7BFC-Ds7f42dj.js} +5 -5
- package/dist/{ecl-DBmkdWAd.js → ecl-DIXH6vul.js} +1 -1
- package/dist/{eiffel-CcWSDDzK.js → eiffel-D0de-eQr.js} +1 -1
- package/dist/{elm-MC-b8a6C.js → elm-DrQrn4VD.js} +1 -1
- package/dist/{erDiagram-RLTQ6QDP-BAru9jHt.js → erDiagram-RLTQ6QDP-b58Sz2Mc.js} +14 -14
- package/dist/{erlang-AdO1-xtV.js → erlang-2KpKpfC7.js} +1 -1
- package/dist/{error-banner-Sl2FlSJ4.js → error-banner-CJVLr5_a.js} +147 -147
- package/dist/error-entries-BKlEsuk4.js +3255 -0
- package/dist/{esm-D2gTsXEV.js → esm-B9n0caHs.js} +643 -644
- package/dist/{esm-AMFssoNp.js → esm-Bwp_FHP0.js} +331 -331
- package/dist/{esm-G4Fhsgng.js → esm-DQtHTnHn.js} +640 -660
- package/dist/eventmodeling-NTZA5JFV-DoBvB4Lj.js +2 -0
- package/dist/{factor-Ys-13HOP.js → factor-Bwu3ZGOk.js} +1 -1
- package/dist/feedback-button-Bxokl7c-.js +370 -0
- package/dist/flowDiagram-HODETNUW-BH9U7VZK.js +15 -0
- package/dist/{formats-V8ifA0Bk.js → formats-BLNFWWhV.js} +9 -9
- package/dist/{forth-DiMuIXFe.js → forth-DYatDpr6.js} +2 -3
- package/dist/{fortran-hkrF2eM4.js → fortran-n8mcQPkL.js} +1 -1
- package/dist/{ganttDiagram-EL5Y4UJY-Dh_4cBJZ.js → ganttDiagram-EL5Y4UJY-YzTghq1V.js} +17 -17
- package/dist/{gas-DlhqN9k8.js → gas-BUZOHBVw.js} +1 -1
- package/dist/{gherkin-0SlhEZ3t.js → gherkin-CrSjX26K.js} +1 -1
- package/dist/gitGraph-4MIJSDKK-Ch7kj-d2.js +2 -0
- package/dist/{gitGraphDiagram-WWUBYQGX-D5nSIzdE.js → gitGraphDiagram-WWUBYQGX-CK66dT35.js} +4 -4
- package/dist/{glide-data-editor-BtpcH-zL.js → glide-data-editor-DkbmoSoO.js} +6717 -2965
- package/dist/{glide-utils-Bt8_pBa2.js → glide-utils-Cn2_NadX.js} +109 -78
- package/dist/{globals-BJP2vdQ8.js → globals-BZH2TwVV.js} +3 -3
- package/dist/{graphlib-BmY_CCV9.js → graphlib-nlwT3Wvy.js} +177 -220
- package/dist/{groovy-YhcTMyvX.js → groovy-IgGNjeU9.js} +1 -1
- package/dist/hasIn-C20JsQ2m.js +28 -0
- package/dist/{haskell-CodLxrtT.js → haskell-Bs1k3a9s.js} +1 -1
- package/dist/{haxe-CiRWNFkH.js → haxe-CQ8Yb3XF.js} +1 -1
- package/dist/highlighted-body-JLMTFACH-yt0ZZn80.js +42 -0
- package/dist/{error-entries-TAO6kEhF.js → html-to-image-CNM0ZSFD.js} +26321 -26406
- package/dist/{idl-DZgBq75I.js → idl-DjnxoAWx.js} +1 -1
- package/dist/info-A6RAGUB7-DCz_Egh9.js +2 -0
- package/dist/{infoDiagram-27XIBGKW-B1hmUggC.js → infoDiagram-27XIBGKW-xbjwrcNi.js} +4 -4
- package/dist/isArrayLikeObject-B-HXCsex.js +626 -0
- package/dist/isEmpty-CdX7MTE1.js +14 -0
- package/dist/{ishikawaDiagram-5VMMS53U-DUeT3t-d.js → ishikawaDiagram-5VMMS53U-DKtukhGS.js} +5 -7
- package/dist/{javascript-BfNytHiM.js → javascript-BQtCoAFy.js} +2 -2
- package/dist/{journeyDiagram-3NMN7TZE-BaLqn-dZ.js → journeyDiagram-3NMN7TZE-CYXsL3IE.js} +4 -4
- package/dist/{jsx-runtime-3BD1kT0s.js → jsx-runtime-D8btoEHk.js} +2 -2
- package/dist/{julia--tLIAG7q.js → julia-BfgtHJE5.js} +1 -1
- package/dist/{kanban-definition-UXKFOSKX-DEUnNNgc.js → kanban-definition-UXKFOSKX-BEhlkZBb.js} +10 -10
- package/dist/{katex-BIdZGsyO.js → katex-wAapZGrX.js} +793 -724
- package/dist/linear-TJTTbHM9.js +203 -0
- package/dist/{livescript-CVPfYnY_.js → livescript-gIdRPKtg.js} +1 -1
- package/dist/{loader-Bm8cy3e8.js → loader-Bin_dutt.js} +12 -12
- package/dist/lru-0OWJJMrW.js +41 -0
- package/dist/{lua-4Fa-T-qq.js → lua-CxFpWvnv.js} +2 -2
- package/dist/main.js +11758 -9367
- package/dist/{mathematica-CtYAy6GG.js → mathematica-QSveeEoW.js} +1 -1
- package/dist/{mbox-D0w9Ah1C.js → mbox-2JtaCPNT.js} +1 -1
- package/dist/{mermaid-B0fXpsNP.js → mermaid-D1CZDNoB.js} +1195 -1182
- package/dist/mermaid-WFAXDIZX-DHB2z13u.js +1 -0
- package/dist/{mermaid-parser.core-DxuSfYwJ.js → mermaid-parser.core-DtOnl7m4.js} +19 -25
- package/dist/{mhchem-CdWPJK6g.js → mhchem-CX8M7Ktl.js} +1 -1
- package/dist/{micromark-factory-space-DGxAzmw8.js → micromark-factory-space-C5soVmaM.js} +1 -1
- package/dist/{mindmap-definition-YA3MSWOX-CPexlhDQ.js → mindmap-definition-YA3MSWOX-DQcnJPcV.js} +13 -13
- package/dist/{mirc-De9aSAZM.js → mirc-BqD6ade4.js} +1 -1
- package/dist/{mllike-BbugeaY_.js → mllike-CT0hgEOO.js} +1 -1
- package/dist/{modelica-BjJwWw1F.js → modelica-DKKebcvq.js} +1 -1
- package/dist/{mscgen-DwiRH5ma.js → mscgen-BJCCsWjR.js} +1 -1
- package/dist/{mumps--plbDM9o.js → mumps-DVQAXZkU.js} +1 -1
- package/dist/{nginx-C4Df7REc.js → nginx-AP4LH2NN.js} +1 -1
- package/dist/{node-sql-parser-BiZOJ-FS.js → node-sql-parser-C9dndbfr.js} +7184 -7195
- package/dist/{now-jM8-M7IR.js → now-BKZCLE5P.js} +12 -13
- package/dist/{nsis-fiiOqLc3.js → nsis-Cah9xkdT.js} +1 -1
- package/dist/{ntriples-jV77I4k8.js → ntriples-CQoaLOV6.js} +2 -2
- package/dist/{number-overlay-editor-CTy6GMzT.js → number-overlay-editor-CkRxchEC.js} +17 -22
- package/dist/{octave-Cztd01tF.js → octave-CeDj2bTn.js} +1 -1
- package/dist/{once-eG8Vmvjd.js → once-NnpX_HnX.js} +1 -1
- package/dist/{oz-Bl8o3BDl.js → oz-BksQrg3k.js} +1 -1
- package/dist/packet-AYTQ26CC-DEMHgLPq.js +2 -0
- package/dist/{pascal-BO5JqysR.js → pascal-BKL17mpl.js} +1 -1
- package/dist/{pegDiagram-XKGWAZYB-CMpp1OOQ.js → pegDiagram-XKGWAZYB-BFQuPYfI.js} +5 -5
- package/dist/pencil-DVYzq-iR.js +10 -0
- package/dist/{perl-Drlh9s6m.js → perl-CacqJ-Ss.js} +1 -1
- package/dist/pick-DgpAbcwP.js +35 -0
- package/dist/pie-WAS4IAKB-DMjTEeHd.js +2 -0
- package/dist/{pieDiagram-E7YTZNPT-DlMWg5t1.js → pieDiagram-E7YTZNPT-l7aqNrem.js} +7 -7
- package/dist/{pig-BWGR8wZw.js → pig-CXSGZ_K9.js} +1 -1
- package/dist/{powershell-DT99xlz_.js → powershell-DY_yIxBM.js} +3 -6
- package/dist/precisionRound-DMIVQrt2.js +97 -0
- package/dist/{process-output-DD-oSvZk.js → process-output-DthYR2Te.js} +19 -30
- package/dist/{properties-Q-rkxld0.js → properties-Om0IDE07.js} +1 -1
- package/dist/{protobuf-DKyWZbs7.js → protobuf-B8nxxb4Q.js} +1 -1
- package/dist/{pug-42ZJUbEC.js → pug-lkUBPvVS.js} +3 -7
- package/dist/{puppet-B4UozHhh.js → puppet-DMkXsi4d.js} +1 -1
- package/dist/purify.es-DmnrIjg4.js +877 -0
- package/dist/{python-DREjAV__.js → python-JQVycMgr.js} +1 -1
- package/dist/{q-Bi63IpBO.js → q-DqE__nNB.js} +1 -1
- package/dist/{quadrantDiagram-AXDQQJYC-Blrm7V7_.js → quadrantDiagram-AXDQQJYC-nGFBFig7.js} +3 -3
- package/dist/{r-DSwXWKMR.js → r-Cbliap7Q.js} +1 -1
- package/dist/radar-RG4KPBEZ-9PwdCvai.js +2 -0
- package/dist/railroad-74A4TZTK-8N9kF5jl.js +2 -0
- package/dist/railroad-abnf-HS5TGJTU-Sg6YmzlR.js +2 -0
- package/dist/railroad-ebnf-LZEXJU2U-CYwp2Oee.js +2 -0
- package/dist/railroad-peg-WCYAUIDC-BfDkAuQ3.js +2 -0
- package/dist/{railroadDiagram-O6MQD6OU-DBJfseeO.js → railroadDiagram-O6MQD6OU-6R3C1lwQ.js} +5 -5
- package/dist/{react-sHtZdjeP.js → react-Bgs_wQh3.js} +3 -3
- package/dist/{react-dom-DUmH0GXv.js → react-dom-DdqGVp5N.js} +5 -5
- package/dist/{react-vega-C4T9Rb_w.js → react-vega-CGgQEf0O.js} +13800 -17236
- package/dist/{requirementDiagram-BXWQKSXE-BC7V639r.js → requirementDiagram-BXWQKSXE-DdWYu8fn.js} +13 -13
- package/dist/{reveal-component-C7puatnn.js → reveal-component-YJ4y0XIg.js} +1003 -1117
- package/dist/{rolldown-runtime-Cb76FRpK.js → rolldown-runtime-BPCzCO3I.js} +1 -1
- package/dist/{rpm-DPb1DeKM.js → rpm-DmT_LNpE.js} +1 -1
- package/dist/{ruby-U7fZA4DP.js → ruby-BHVZTtLW.js} +1 -1
- package/dist/{sankeyDiagram-P5KCCOFB-ELvOcnZH.js → sankeyDiagram-P5KCCOFB-CrOfyc2n.js} +2 -2
- package/dist/{sas-CLk1JpTn.js → sas-CrG5N1he.js} +1 -1
- package/dist/{scheme-CT-2k2Tl.js → scheme-BHUnz-IB.js} +1 -1
- package/dist/select-CDUxhHZg.js +1198 -0
- package/dist/{sequenceDiagram-WJ2MYXX4-CgesU6F-.js → sequenceDiagram-WJ2MYXX4-Dzp0dgRc.js} +6 -6
- package/dist/{shell-BLO7fcsk.js → shell-C5IBmRU5.js} +1 -1
- package/dist/{sieve-nG3C7WNH.js → sieve-BzCnt_E6.js} +2 -2
- package/dist/{sizeCapture-INFHLROL-Dx5SpkQF.js → sizeCapture-INFHLROL-DBeZ20mI.js} +1 -1
- package/dist/{smalltalk-BROcZybA.js → smalltalk-DQFAQul3.js} +1 -1
- package/dist/{solr-mVltHNc5.js → solr-BiapYPCk.js} +1 -1
- package/dist/{sparql-Cv1Ksr4v.js → sparql-BcUKO1is.js} +1 -1
- package/dist/{spec-CcT0slVc.js → spec-ZAt4P01J.js} +84 -57
- package/dist/{src-CA_m4ONl.js → src-D5uZaZib.js} +8 -14
- package/dist/{stateDiagram-D77RDMKH-lH_BUhs3.js → stateDiagram-D77RDMKH-BGnTUhFJ.js} +18 -18
- package/dist/stateDiagram-v2-MP3YSRHH-DsJbmDf1.js +30 -0
- package/dist/static-state-C4bAlKTU.js +68 -0
- package/dist/{stex-Btf3omL8.js → stex-CQ_aCGTF.js} +1 -1
- package/dist/style.css +1 -1
- package/dist/{stylus-Dt4VvLXL.js → stylus-D4gHF5lg.js} +1 -1
- package/dist/{swift-DHsn_CVI.js → swift-CnvIBnbt.js} +1 -1
- package/dist/{swimlanes-42K2YHIH-Cuf9B9kE.js → swimlanes-42K2YHIH-Bd4Bzh9r.js} +37 -59
- package/dist/swimlanesDiagram-VR7AAH4N-BlY12Jf6.js +30 -0
- package/dist/{swiper-component-DfhRvAFi.js → swiper-component-DTdNB9wg.js} +45 -78
- package/dist/{tcl-CV0OLBOl.js → tcl-DkOjjZYO.js} +1 -1
- package/dist/{textile-D320oKVM.js → textile-DgzBVSEW.js} +1 -1
- package/dist/{tiki-BF2aDPlB.js → tiki-MighF8A_.js} +1 -1
- package/dist/{time-BaMbJs4z.js → time-BlOl70lB.js} +19 -19
- package/dist/{timeline-definition-24CTP7MA-yzzw4TF4.js → timeline-definition-24CTP7MA-m0LanyCH.js} +5 -5
- package/dist/toast-U3NpO2x3.js +491 -0
- package/dist/{toml-CaUN7UHo.js → toml-B0B7UAba.js} +1 -1
- package/dist/{tooltip-CKO1pHJo.js → tooltip-UzJukb3F.js} +336 -312
- package/dist/treeView-Q6P3EWNA-BQywp0E1.js +2 -0
- package/dist/treemap-WGGIJYW6-P2ZJnldw.js +2 -0
- package/dist/{troff-DQUFcClZ.js → troff-B4IRX71y.js} +1 -1
- package/dist/{ttcn-CQL1duJS.js → ttcn-B4tpvdJD.js} +1 -1
- package/dist/{ttcn-cfg-BMmEFJPu.js → ttcn-cfg-pfE-1FV8.js} +1 -1
- package/dist/{turtle-C3esgsRr.js → turtle-Bc97ufp6.js} +1 -1
- package/dist/use-restore-focus-DaTVz6S6.js +7672 -0
- package/dist/{use-vega-container-remeasure-Bz4PZMtt.js → use-vega-container-remeasure-BrUpWQfF.js} +4 -8
- package/dist/{useAsyncData-D0mLJstx.js → useAsyncData-P5-Oovhq.js} +7 -7
- package/dist/{useDateFormatter-c_yJtkAe.js → useDateFormatter-LQNtoXyh.js} +5 -5
- package/dist/useDeepCompareMemoize-CmNbQ9TT.js +53 -0
- package/dist/useEvent-BoN7U38T.js +19 -0
- package/dist/{useIframeCapabilities-BkdeVdXC.js → useIframeCapabilities-HTZiVlGV.js} +2 -2
- package/dist/useLifecycle-DTMczKkf.js +112 -0
- package/dist/{vb-RK1eDXRl.js → vb-C5kpOY_q.js} +1 -1
- package/dist/{vbscript-BCOeM0de.js → vbscript-Ck0hgOg5.js} +1 -1
- package/dist/{vega-component-DgytCKrL.js → vega-component-ZTdbCcwI.js} +221 -227
- package/dist/{vega-embed-container--LYZqguO.js → vega-embed-container-DgpACsCB.js} +7 -7
- package/dist/{vega-loader.browser-B9Pz0EGP.js → vega-loader.browser-Co9gYE8Z.js} +637 -294
- package/dist/{velocity-CZKOFbOI.js → velocity-2Doc6dgJ.js} +1 -1
- package/dist/{vennDiagram-4TSXK5OY-eJOrTqqC.js → vennDiagram-4TSXK5OY-BJ7vqDmn.js} +4 -4
- package/dist/{verilog-DqQTzVn8.js → verilog-CmZmYe4R.js} +2 -2
- package/dist/{vhdl-vQr2bfmi.js → vhdl-esMnUHZm.js} +1 -1
- package/dist/wardley-WFR3VGLG-CIBJ6O2G.js +2 -0
- package/dist/{wardleyDiagram-VM6X3IG4-TILPvee6.js → wardleyDiagram-VM6X3IG4-D5kWacsn.js} +5 -5
- package/dist/{webidl-DzX7N40e.js → webidl-G_RlXG7G.js} +1 -1
- package/dist/{xquery-Cw_Q_hGR.js → xquery-IUQpMoMl.js} +1 -1
- package/dist/{xychartDiagram-S5SC5T6Z-DUPvRwwJ.js → xychartDiagram-S5SC5T6Z-gr15Ws_z.js} +8 -8
- package/dist/{yacas-DiC4jJBE.js → yacas-ObL0t2h9.js} +1 -1
- package/dist/{z80-CUOQDEJO.js → z80-jyuJhy0k.js} +1 -1
- package/package.json +38 -42
- package/src/__mocks__/document.tsx +64 -0
- package/src/__mocks__/executions.ts +301 -0
- package/src/__mocks__/notebook.ts +39 -46
- package/src/__mocks__/partial.ts +26 -0
- package/src/__mocks__/requests.ts +2 -8
- package/src/__tests__/CellStatus.test.tsx +25 -26
- package/src/__tests__/fixtures/pair-config.ts +1 -1
- package/src/__tests__/main.test.tsx +24 -1
- package/src/__tests__/module-entry.test.ts +44 -0
- package/src/__tests__/mount.test.ts +17 -58
- package/src/__tests__/{host-imports.test.ts → replica-imports.test.ts} +11 -11
- package/src/components/ai/__tests__/ai-model-dropdown.test.tsx +63 -0
- package/src/components/ai/__tests__/ai-utils.test.ts +8 -0
- package/src/components/ai/ai-model-dropdown.tsx +11 -6
- 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/__tests__/state.test.tsx +50 -0
- package/src/components/app-config/ai-config.tsx +200 -187
- package/src/components/app-config/app-config-button.tsx +6 -5
- package/src/components/app-config/app-config-form.tsx +5 -9
- package/src/components/app-config/common.tsx +7 -9
- package/src/components/app-config/data-form.tsx +113 -116
- package/src/components/app-config/get-dirty-values.ts +4 -4
- package/src/components/app-config/mcp-config.tsx +30 -53
- package/src/components/app-config/model-discovery.tsx +157 -0
- package/src/components/app-config/model-provider-config.ts +25 -0
- package/src/components/app-config/state.ts +2 -0
- package/src/components/app-config/user-config-form.css +91 -0
- package/src/components/app-config/user-config-form.tsx +278 -350
- package/src/components/chat/__tests__/capabilities-popover.test.tsx +0 -1
- package/src/components/chat/__tests__/chat-display.test.tsx +196 -0
- package/src/components/chat/__tests__/chat-markdown.test.tsx +43 -0
- package/src/components/chat/__tests__/chat-utils.test.ts +141 -1
- package/src/components/chat/__tests__/message-queue.test.tsx +94 -1
- package/src/components/chat/__tests__/notebook-access-selector.test.tsx +64 -0
- package/src/components/chat/__tests__/notebook-context.test.ts +199 -0
- package/src/components/chat/__tests__/pending-chat-prompt.test.tsx +568 -0
- package/src/components/chat/__tests__/turn-timing.test.ts +84 -0
- package/src/components/chat/__tests__/use-assistant-turn.test.ts +95 -0
- package/src/components/chat/__tests__/useFileState.test.tsx +176 -15
- package/src/components/chat/__tests__/user-message.test.tsx +27 -0
- package/src/components/chat/acp/__tests__/agent-panel-initialization.test.tsx +1 -1
- package/src/components/chat/acp/__tests__/agent-panel.test.tsx +22 -17
- package/src/components/chat/acp/__tests__/session-tabs.test.tsx +43 -0
- package/src/components/chat/acp/agent-panel.tsx +6 -3
- package/src/components/chat/acp/blocks.tsx +11 -10
- package/src/components/chat/acp/common.tsx +4 -5
- package/src/components/chat/acp/model-selector.tsx +1 -1
- package/src/components/chat/acp/session-tabs.tsx +8 -3
- package/src/components/chat/agent-activity.tsx +132 -0
- package/src/components/chat/capabilities-popover.tsx +2 -11
- package/src/components/chat/chat-components.tsx +10 -6
- package/src/components/chat/chat-display.tsx +131 -57
- package/src/components/chat/chat-history-popover.tsx +6 -1
- package/src/components/chat/chat-markdown.tsx +15 -0
- package/src/components/chat/chat-panel.tsx +422 -358
- package/src/components/chat/chat-typography.css +108 -0
- package/src/components/chat/chat-utils.ts +168 -61
- package/src/components/chat/notebook-access-selector.stories.tsx +22 -0
- package/src/components/chat/notebook-access-selector.tsx +100 -0
- package/src/components/chat/notebook-context.ts +80 -0
- package/src/components/chat/tool-call/__tests__/tool-labels.test.ts +76 -0
- package/src/components/chat/tool-call/__tests__/tool-step.test.tsx +57 -0
- package/src/components/chat/tool-call/shared.ts +6 -0
- package/src/components/chat/tool-call/tool-call-view.tsx +22 -76
- package/src/components/chat/tool-call/tool-labels.ts +172 -0
- package/src/components/chat/tool-call/tool-result.tsx +1 -1
- package/src/components/chat/tool-call/tool-step.tsx +145 -0
- package/src/components/chat/turn-timing.ts +73 -0
- package/src/components/chat/use-assistant-turn.ts +65 -0
- package/src/components/chat/use-chat-generation.ts +20 -0
- package/src/components/chat/user-message.tsx +154 -0
- package/src/components/data-table/TableBottomBar.tsx +4 -1
- package/src/components/data-table/TableTopBar.tsx +2 -0
- package/src/components/data-table/__tests__/chart-spec-model.test.ts +195 -195
- package/src/components/data-table/__tests__/data-table.test.tsx +1 -0
- package/src/components/data-table/__tests__/keyboard-selection.test.tsx +188 -0
- package/src/components/data-table/__tests__/pagination.test.tsx +28 -1
- package/src/components/data-table/charts/__tests__/altair-generator.test.ts +42 -27
- package/src/components/data-table/charts/__tests__/spec-snapshot.test.ts +20 -20
- package/src/components/data-table/charts/__tests__/spec.test.ts +78 -52
- package/src/components/data-table/charts/chart-spec/altair-generator.ts +2 -6
- package/src/components/data-table/charts/chart-spec/spec.ts +68 -43
- package/src/components/data-table/charts/charts.tsx +5 -5
- package/src/components/data-table/column-formatting/types.ts +1 -2
- package/src/components/data-table/column-summary/chart-spec-model.tsx +23 -16
- package/src/components/data-table/data-table.tsx +10 -0
- package/src/components/data-table/pagination.tsx +44 -33
- package/src/components/data-table/range-focus/atoms.ts +4 -6
- package/src/components/data-table/range-focus/use-cell-range-selection.ts +65 -38
- package/src/components/data-table/range-focus/use-scroll-into-view.ts +21 -2
- package/src/components/data-table/renderers.tsx +16 -7
- package/src/components/data-table/row-viewer-panel/__tests__/row-viewer.test.tsx +24 -1
- package/src/components/data-table/row-viewer-panel/row-viewer.tsx +2 -2
- package/src/components/datasources/__tests__/column-preview.test.tsx +41 -11
- package/src/components/datasources/__tests__/datasources-interactions.test.tsx +334 -0
- package/src/components/datasources/__tests__/table-list.test.tsx +51 -1
- package/src/components/datasources/__tests__/utils.test.ts +117 -7
- package/src/components/datasources/column-preview.tsx +9 -10
- package/src/components/datasources/datasources.tsx +22 -22
- package/src/components/datasources/utils.ts +41 -27
- package/src/components/dependency-graph/__tests__/elements.test.ts +20 -11
- package/src/components/dependency-graph/custom-node.tsx +1 -1
- package/src/components/dependency-graph/dependency-graph-tree.tsx +23 -9
- package/src/components/dependency-graph/elements.ts +34 -44
- package/src/components/dependency-graph/minimap-content.tsx +15 -20
- package/src/components/dependency-graph/panels.tsx +2 -1
- package/src/components/dependency-graph/utils/__tests__/layout.test.ts +18 -11
- package/src/components/editor/Output.tsx +5 -4
- package/src/components/editor/__tests__/Output.test.tsx +50 -32
- package/src/{core/attachments/__tests__/toast.test.tsx → components/editor/__tests__/agent-toast.test.tsx} +1 -1
- package/src/components/editor/__tests__/data-attributes.test.tsx +39 -32
- package/src/components/editor/__tests__/dynamic-favicon.test.tsx +11 -16
- package/src/components/editor/__tests__/output-persistence.test.tsx +33 -32
- package/src/components/editor/__tests__/package-alert.test.tsx +22 -1
- package/src/components/editor/actions/__tests__/name-cell-input.test.tsx +70 -0
- package/src/components/editor/actions/__tests__/pair-with-agent-commands.test.ts +21 -40
- package/src/components/editor/actions/__tests__/pair-with-agent-modal.test.tsx +40 -14
- package/src/components/editor/actions/__tests__/pair-with-agent.test.tsx +6 -24
- package/src/components/editor/actions/__tests__/useCellActionButton.test.tsx +132 -0
- package/src/components/editor/actions/__tests__/useSetOutputsExpanded.test.ts +8 -9
- package/src/components/editor/actions/name-cell-input.tsx +4 -3
- package/src/components/editor/actions/pair-with-agent-commands.ts +10 -7
- package/src/components/editor/actions/pair-with-agent-modal.tsx +15 -18
- package/src/components/editor/actions/pair-with-agent.tsx +16 -39
- package/src/components/editor/actions/useCellActionButton.tsx +47 -35
- package/src/components/editor/actions/useConfigActions.tsx +3 -4
- package/src/components/editor/actions/useNotebookActions.tsx +25 -29
- package/src/components/editor/actions/useRestartKernel.tsx +0 -5
- package/src/components/editor/actions/useSetCodeVisibility.ts +11 -12
- package/src/components/editor/actions/useSetOutputsExpanded.ts +24 -24
- package/src/components/editor/ai/ai-completion-editor.tsx +1 -1
- package/src/components/editor/ai/completion-handlers.tsx +0 -37
- package/src/components/editor/ai/prompt-input.tsx +189 -0
- package/src/components/editor/alerts/__tests__/connection-notice.test.tsx +1 -1
- package/src/components/editor/alerts/connection-notice.tsx +1 -1
- package/src/components/editor/app-container.tsx +1 -1
- package/src/components/editor/boundary/ErrorBoundary.tsx +6 -2
- package/src/components/editor/boundary/__tests__/ErrorBoundary.test.tsx +5 -1
- package/src/components/editor/cell/CellStatus.tsx +47 -57
- package/src/components/editor/cell/CreateCellButton.tsx +7 -11
- package/src/components/editor/cell/DeleteButton.tsx +4 -4
- package/src/components/editor/cell/ReusableDefinitionBadge.tsx +62 -0
- package/src/components/editor/cell/RunButton.tsx +18 -8
- package/src/components/editor/cell/StagedAICell.tsx +52 -137
- package/src/components/editor/cell/StopButton.tsx +7 -7
- package/src/components/editor/cell/__tests__/useRunCells.test.tsx +149 -0
- package/src/components/editor/cell/cell-actions.tsx +12 -1
- package/src/components/editor/cell/cell-context-menu.tsx +24 -4
- package/src/components/editor/cell/code/__tests__/language-toggle.test.tsx +38 -1
- package/src/components/editor/cell/code/cell-editor.tsx +66 -169
- package/src/components/editor/cell/code/language-toggle.tsx +6 -4
- package/src/components/editor/cell/collapse.tsx +16 -6
- package/src/components/editor/cell/useAddCell.ts +4 -8
- package/src/components/editor/cell/useDeleteCell.tsx +10 -36
- package/src/components/editor/cell/useRunCells.ts +70 -59
- package/src/components/editor/cell/useSplitCell.tsx +10 -6
- package/src/components/editor/chrome/components/__tests__/feedback-button.test.tsx +1 -1
- package/src/components/editor/chrome/components/feedback-button.tsx +2 -8
- package/src/components/editor/chrome/panels/__tests__/packages-panel.test.tsx +1 -1
- package/src/components/editor/chrome/panels/__tests__/runtime-details.test.tsx +1 -1
- package/src/components/editor/chrome/panels/__tests__/sandbox-recovery.test.tsx +1 -1
- package/src/components/editor/chrome/panels/dependency-graph-panel.tsx +1 -1
- package/src/components/editor/chrome/panels/logs-panel.tsx +2 -1
- package/src/components/editor/chrome/panels/outline/__tests__/outline-keyboard.test.tsx +84 -0
- package/src/components/editor/chrome/panels/outline/floating-outline.tsx +39 -14
- package/src/components/editor/chrome/panels/outline/useActiveOutline.tsx +3 -2
- package/src/components/editor/chrome/panels/panel-header.tsx +13 -0
- package/src/components/editor/chrome/panels/secrets-panel.tsx +1 -0
- package/src/components/editor/chrome/panels/session-panel.tsx +1 -1
- package/src/components/editor/chrome/panels/snippets-panel.tsx +10 -12
- package/src/components/editor/chrome/panels/variable-panel.tsx +1 -5
- package/src/components/editor/chrome/types.ts +1 -1
- package/src/components/editor/chrome/wrapper/__tests__/attachment-status.test.tsx +8 -10
- package/src/components/editor/chrome/wrapper/__tests__/document-sync-status.test.tsx +97 -0
- package/src/components/editor/chrome/wrapper/__tests__/pending-ai-cells.test.tsx +230 -59
- package/src/components/editor/chrome/wrapper/__tests__/useAskAiAboutCell.test.tsx +58 -0
- package/src/components/editor/chrome/wrapper/app-chrome.tsx +91 -74
- package/src/components/editor/chrome/wrapper/footer-items/attachment-status.tsx +5 -5
- package/src/components/editor/chrome/wrapper/footer-items/backend-status.tsx +3 -17
- package/src/components/editor/chrome/wrapper/footer-items/document-sync-status.tsx +54 -0
- package/src/components/editor/chrome/wrapper/footer-items/lsp-status.tsx +1 -1
- package/src/components/editor/chrome/wrapper/footer-items/machine-stats.tsx +1 -1
- package/src/components/editor/chrome/wrapper/footer.tsx +2 -2
- package/src/components/editor/chrome/wrapper/minimap-state.ts +1 -1
- package/src/components/editor/chrome/wrapper/pending-ai-cells.tsx +143 -82
- package/src/components/editor/chrome/wrapper/pending-ai-changes-badge.tsx +25 -0
- package/src/components/editor/chrome/wrapper/sidebar.tsx +8 -4
- package/src/components/editor/chrome/wrapper/useAskAiAboutCell.ts +36 -0
- package/src/components/editor/columns/__tests__/cell-column.test.tsx +1 -1
- package/src/components/editor/columns/cell-column.tsx +1 -1
- package/src/components/editor/columns/sortable-column.tsx +2 -2
- package/src/components/editor/connections/components.tsx +4 -9
- package/src/components/editor/controls/Controls.tsx +9 -6
- package/src/components/editor/controls/__tests__/keyboard-shortcuts.test.tsx +61 -0
- package/src/components/editor/controls/__tests__/notebook-menu-dropdown.test.tsx +10 -4
- package/src/components/editor/controls/keyboard-shortcuts.tsx +14 -5
- package/src/components/editor/documentation.css +34 -11
- package/src/components/editor/errors/__tests__/send-error-report-button.test.tsx +106 -79
- package/src/components/editor/errors/auto-fix.tsx +4 -8
- package/src/components/editor/errors/send-error-report-button.tsx +3 -6
- package/src/components/editor/file-tree/__tests__/file-explorer-navigation.test.tsx +47 -0
- package/src/components/editor/file-tree/file-explorer.tsx +38 -10
- package/src/components/editor/file-tree/file-name-input.tsx +1 -0
- package/src/components/editor/header/__tests__/filename-form.test.tsx +1 -4
- package/src/components/editor/header/__tests__/status.test.tsx +5 -3
- package/src/components/editor/header/app-header.tsx +1 -1
- package/src/components/editor/header/filename-form.tsx +1 -1
- package/src/components/editor/header/status.tsx +44 -22
- package/src/components/editor/links/__tests__/cell-link.test.tsx +148 -0
- package/src/components/editor/links/cell-link-list.tsx +1 -1
- package/src/components/editor/links/cell-link.tsx +21 -11
- package/src/components/editor/navigation/__tests__/clipboard.test.ts +60 -38
- package/src/components/editor/navigation/__tests__/navigation.test.ts +109 -85
- package/src/components/editor/navigation/__tests__/selection.test.ts +43 -21
- package/src/components/editor/navigation/clipboard.ts +17 -14
- package/src/components/editor/navigation/focus-utils.ts +23 -4
- package/src/components/editor/navigation/multi-cell-action-toolbar.tsx +17 -33
- package/src/components/editor/navigation/navigation.ts +74 -72
- package/src/components/editor/navigation/selection.ts +30 -29
- package/src/components/editor/notebook-cell.tsx +143 -256
- package/src/components/editor/output/MarimoErrorOutput.tsx +41 -4
- package/src/components/editor/output/MarimoTracebackOutput.tsx +17 -15
- package/src/components/editor/output/Outputs.css +8 -0
- package/src/components/editor/output/VideoOutput.tsx +6 -0
- package/src/components/editor/output/__tests__/VideoOutput.test.tsx +131 -0
- package/src/components/editor/output/__tests__/traceback.test.tsx +27 -1
- package/src/components/editor/output/ansi-reduce.ts +126 -49
- package/src/components/editor/output/console/ConsoleOutput.tsx +34 -26
- package/src/components/editor/output/console/__tests__/ConsoleOutput.test.tsx +162 -102
- package/src/components/editor/output/console/process-output.ts +4 -2
- package/src/components/editor/package-alert.tsx +8 -3
- package/src/components/editor/renderers/__tests__/add-cell-buttons.test.tsx +18 -0
- package/src/components/editor/renderers/cell-array.tsx +38 -103
- package/src/components/editor/renderers/cells-renderer.tsx +2 -3
- package/src/components/editor/renderers/grid-layout/__tests__/grid-layout.test.tsx +69 -0
- package/src/components/editor/renderers/grid-layout/grid-layout.tsx +30 -28
- package/src/components/editor/renderers/slides-layout/__tests__/plugin.test.ts +0 -4
- package/src/components/editor/renderers/slides-layout/slides-layout.tsx +1 -1
- package/src/components/editor/renderers/types.ts +2 -2
- package/src/components/editor/renderers/vertical-layout/__tests__/useFocusFirstEditor.test.ts +47 -4
- package/src/components/editor/renderers/vertical-layout/useFocusFirstEditor.ts +9 -1
- package/src/components/editor/renderers/vertical-layout/utils.ts +4 -4
- package/src/components/editor/renderers/vertical-layout/vertical-layout.tsx +20 -46
- package/src/components/editor/stdin-blocking-alert.tsx +19 -16
- package/src/components/icons/__tests__/copy-icon.test.tsx +63 -0
- package/src/components/icons/copy-icon.tsx +9 -2
- package/src/components/markdown/__tests__/markdown-renderer.test.tsx +32 -2
- package/src/components/markdown/markdown-renderer.tsx +43 -28
- package/src/components/mcp/mcp-status-indicator.tsx +18 -14
- package/src/components/pages/edit-page.tsx +18 -17
- package/src/components/scratchpad/scratchpad.test.tsx +89 -0
- package/src/components/scratchpad/scratchpad.tsx +54 -37
- package/src/components/scratchpad/state.ts +7 -0
- package/src/components/slides/__tests__/cell-output-block.test.tsx +8 -9
- package/src/components/slides/__tests__/minimap-actions.test.tsx +25 -32
- package/src/components/slides/__tests__/minimap.test.ts +38 -19
- package/src/components/slides/__tests__/slide-cell-view.test.tsx +3 -2
- package/src/components/slides/__tests__/slide-scroll-hint.test.tsx +37 -0
- package/src/components/slides/minimap.tsx +21 -14
- package/src/components/slides/reveal-component.tsx +68 -34
- package/src/components/slides/reveal-slides.css +5 -4
- package/src/components/slides/slide-cell-view.tsx +36 -41
- package/src/components/slides/slide-scroll-hint.tsx +3 -1
- package/src/components/slides/slide.tsx +4 -5
- package/src/components/sort/SortableCellsProvider.tsx +8 -25
- package/src/components/static-html/__tests__/static-banner.test.tsx +1 -1
- package/src/components/tracing/tracing-keyboard.test.tsx +85 -0
- package/src/components/tracing/tracing-spec.ts +11 -1
- package/src/components/tracing/tracing.tsx +48 -40
- package/src/components/ui/__tests__/draggable-popover.test.tsx +24 -0
- package/src/components/ui/__tests__/fullscreen.test.tsx +99 -2
- package/src/components/ui/__tests__/range-slider.test.tsx +165 -0
- package/src/components/ui/__tests__/select.test.tsx +80 -0
- package/src/components/ui/draggable-popover.tsx +24 -2
- package/src/components/ui/fullscreen.tsx +43 -3
- package/src/components/ui/range-slider.tsx +22 -9
- package/src/components/ui/select.tsx +17 -15
- package/src/components/ui/slider.tsx +6 -2
- package/src/components/ui/toast.tsx +1 -1
- package/src/components/variables/__tests__/variables-table.test.tsx +75 -0
- package/src/components/variables/variables-table.tsx +18 -10
- package/src/core/MarimoApp.tsx +3 -1
- package/src/core/ai/__tests__/attachments.test.ts +153 -0
- package/src/core/ai/__tests__/staged-cells.test.ts +90 -609
- package/src/core/ai/attachments.ts +80 -0
- package/src/core/ai/context/__tests__/registry.test.ts +7 -11
- package/src/core/ai/context/context.ts +2 -0
- package/src/core/ai/context/providers/__tests__/cell-output.test.ts +116 -52
- package/src/core/ai/context/providers/__tests__/cell.test.ts +49 -0
- package/src/core/ai/context/providers/__tests__/error.test.ts +76 -219
- package/src/core/ai/context/providers/cell-output.ts +17 -20
- package/src/core/ai/context/providers/cell.ts +54 -0
- package/src/core/ai/staged-cells.ts +56 -323
- package/src/core/ai/state.ts +3 -0
- package/src/core/ai/tools/__tests__/edit-notebook-tool.test.ts +47 -93
- package/src/core/ai/tools/__tests__/registry.test.ts +17 -0
- package/src/core/ai/tools/base.ts +18 -15
- package/src/core/ai/tools/edit-notebook-tool.ts +86 -80
- package/src/core/ai/tools/registry.ts +13 -10
- package/src/core/ai/tools/sample-tool.ts +6 -7
- package/src/core/cells/__tests__/actions.test.ts +623 -35
- package/src/core/cells/__tests__/add-missing-import.test.ts +7 -8
- package/src/core/cells/__tests__/arrange.test.ts +432 -0
- package/src/core/cells/__tests__/cell.test.ts +56 -308
- package/src/core/cells/__tests__/cells.test.ts +327 -3808
- package/src/core/cells/__tests__/clear-outputs.test.ts +156 -0
- package/src/core/cells/__tests__/collapseConsoleOutputs.test.ts +86 -2
- package/src/core/cells/__tests__/document.test.ts +158 -0
- package/src/core/cells/__tests__/editor.test.ts +57 -0
- package/src/core/cells/__tests__/flush-document.test.ts +42 -0
- package/src/core/cells/__tests__/harness.ts +113 -0
- package/src/core/cells/__tests__/layout.test.ts +186 -0
- package/src/core/cells/__tests__/logs.test.ts +18 -42
- package/src/core/cells/__tests__/notebook-outline.test.ts +72 -57
- package/src/core/cells/__tests__/outputs.test.tsx +71 -53
- package/src/core/cells/__tests__/pending-delete-service.test.tsx +11 -20
- package/src/core/cells/__tests__/runs.test.ts +127 -430
- package/src/core/cells/__tests__/session.test.ts +560 -336
- package/src/core/cells/__tests__/utils.test.ts +166 -338
- package/src/core/cells/actions.ts +738 -6
- package/src/core/cells/add-missing-import.ts +48 -47
- package/src/core/cells/arrange.ts +529 -0
- package/src/core/cells/cell.ts +36 -225
- package/src/core/cells/cells.ts +245 -1549
- package/src/core/cells/collapseConsoleOutputs.tsx +71 -40
- package/src/core/cells/columns.ts +38 -0
- package/src/core/cells/command-console.ts +46 -0
- package/src/core/cells/document.ts +167 -0
- package/src/core/cells/edit.ts +30 -0
- package/src/core/cells/editor.ts +82 -0
- package/src/core/cells/execution-console.ts +236 -0
- package/src/core/cells/focus.ts +20 -14
- package/src/core/cells/layout.ts +228 -0
- package/src/core/cells/logs.ts +10 -2
- package/src/core/cells/outputs.ts +14 -30
- package/src/core/cells/pending-delete-service.ts +6 -8
- package/src/core/cells/reusable-definition.ts +25 -0
- package/src/core/cells/runs.ts +70 -118
- package/src/core/cells/scrollCellIntoView.ts +6 -0
- package/src/core/cells/session.ts +176 -101
- package/src/core/cells/types.ts +32 -64
- package/src/core/cells/useAnswerPrompt.ts +29 -0
- package/src/core/cells/utils.ts +113 -102
- package/src/core/codemirror/__tests__/format.test.ts +4 -36
- package/src/core/codemirror/__tests__/setup.test.ts +66 -33
- package/src/core/codemirror/ai/__tests__/resources.test.ts +113 -0
- package/src/core/codemirror/ai/resources.ts +1 -1
- package/src/core/codemirror/cells/__tests__/debugger-state.test.ts +0 -20
- package/src/core/codemirror/cells/__tests__/extensions.test.ts +2 -6
- package/src/core/codemirror/cells/debugger-state.ts +7 -11
- package/src/core/codemirror/cells/extensions.ts +18 -30
- package/src/core/codemirror/cells/state.ts +2 -6
- package/src/core/codemirror/cm.ts +5 -1
- package/src/core/codemirror/config/types.ts +1 -1
- package/src/core/codemirror/copilot/__tests__/completion-integration.test.ts +4 -0
- package/src/core/codemirror/copilot/__tests__/getCodes.test.ts +13 -12
- package/src/core/codemirror/copilot/extension.ts +0 -26
- package/src/core/codemirror/copilot/getCodes.ts +3 -3
- package/src/core/codemirror/format.ts +6 -23
- package/src/core/codemirror/keymaps/vim.ts +2 -2
- package/src/core/codemirror/language/__tests__/extension.test.ts +9 -7
- package/src/core/codemirror/language/__tests__/markdown.test.ts +7 -7
- package/src/core/codemirror/language/__tests__/sql-literals.test.ts +588 -0
- package/src/core/codemirror/language/__tests__/sql.test.ts +123 -28
- package/src/core/codemirror/language/__tests__/utils.test.ts +194 -19
- package/src/core/codemirror/language/cell-code.ts +114 -0
- package/src/core/codemirror/language/extension.ts +52 -35
- package/src/core/codemirror/language/languages/markdown.ts +8 -6
- package/src/core/codemirror/language/languages/python.ts +16 -10
- package/src/core/codemirror/language/languages/sql/completion-builder.ts +31 -14
- package/src/core/codemirror/language/languages/sql/completion-context.ts +197 -0
- package/src/core/codemirror/language/languages/sql/completion-sources.tsx +109 -0
- package/src/core/codemirror/language/languages/sql/sql.ts +21 -28
- package/src/core/codemirror/language/types.ts +7 -7
- package/src/core/codemirror/language/utils.ts +9 -39
- package/src/core/codemirror/lsp/__tests__/notebook-lsp.test.ts +1 -2
- package/src/core/codemirror/lsp/notebook-lsp.ts +6 -5
- package/src/core/codemirror/lsp/utils.ts +1 -1
- package/src/core/codemirror/misc/__tests__/paste.test.ts +3 -1
- package/src/core/codemirror/misc/paste.ts +1 -1
- package/src/core/codemirror/placeholder/__tests__/extensions.test.ts +75 -0
- package/src/core/codemirror/placeholder/extensions.ts +80 -19
- package/src/core/codemirror/readonly/__tests__/extension.test.ts +1 -1
- package/src/core/codemirror/readonly/extension.ts +2 -2
- package/src/core/codemirror/utils.ts +1 -0
- package/src/core/config/__tests__/app-config.test.ts +64 -0
- package/src/core/config/__tests__/config-schema.test.ts +195 -17
- package/src/core/config/config-schema.ts +138 -20
- package/src/core/config/config.ts +69 -20
- package/src/core/config/feature-flag.tsx +0 -2
- package/src/core/datasets/__tests__/data-source-discovery.test.ts +1 -1
- package/src/core/documentation/doc-lookup.ts +1 -1
- package/src/core/dom/__tests__/outline.test.ts +23 -0
- package/src/core/dom/outline.ts +4 -1
- package/src/core/edit-app.tsx +28 -38
- package/src/core/errors/__tests__/error-entries.test.ts +74 -1
- package/src/core/errors/error-entries.ts +28 -16
- package/src/core/executions/__tests__/atoms.test.ts +218 -0
- package/src/core/executions/__tests__/freshness.test.ts +503 -0
- package/src/core/executions/__tests__/hooks.test.tsx +198 -0
- package/src/core/executions/__tests__/input.test.ts +86 -0
- package/src/core/executions/__tests__/interrupt.test.ts +206 -0
- package/src/core/executions/__tests__/output-lifecycle.test.ts +260 -0
- package/src/core/executions/__tests__/output.test.ts +336 -0
- package/src/core/executions/__tests__/run.test.ts +396 -0
- package/src/core/executions/__tests__/select.test.ts +409 -0
- package/src/core/executions/atoms.ts +399 -0
- package/src/core/executions/freshness.ts +174 -0
- package/src/core/executions/hooks.ts +119 -0
- package/src/core/executions/index.ts +58 -0
- package/src/core/executions/input.ts +56 -0
- package/src/core/executions/interrupt.ts +49 -0
- package/src/core/executions/output.ts +337 -0
- package/src/core/executions/run.ts +107 -0
- package/src/core/executions/select.ts +271 -0
- package/src/core/export/__tests__/hooks.test.ts +18 -34
- package/src/core/export/hooks.ts +8 -10
- package/src/core/export/layout.ts +2 -2
- package/src/core/hotkeys/hotkeys.ts +2 -1
- package/src/core/islands/__tests__/bootstrap.test.ts +69 -17
- package/src/core/islands/__tests__/bridge.test.ts +163 -65
- 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/bootstrap.ts +70 -65
- package/src/core/islands/bridge.ts +156 -54
- package/src/core/islands/components/IslandControls.tsx +15 -7
- package/src/core/islands/components/__tests__/IslandControls.test.tsx +36 -51
- package/src/core/islands/components/__tests__/web-components.test.tsx +76 -15
- package/src/core/islands/components/output-wrapper.tsx +19 -24
- package/src/core/islands/components/web-components.tsx +12 -1
- package/src/core/islands/iframe-resizer.ts +38 -0
- package/src/core/islands/main.ts +3 -0
- package/src/core/islands/stubs/slide-cell-view.tsx +2 -5
- package/src/core/islands/worker/__tests__/controller.test.ts +62 -4
- package/src/core/islands/worker/controller.ts +4 -10
- package/src/core/islands/worker/worker.tsx +84 -52
- package/src/core/kernel/__tests__/handlers.test.ts +7 -159
- package/src/core/kernel/handlers.ts +12 -141
- package/src/core/kernel/messages.ts +0 -1
- package/src/core/kernel/state.ts +0 -15
- package/src/core/lifecycle/render-policy.ts +16 -27
- package/src/core/meta/__tests__/code-visibility.test.tsx +78 -70
- package/src/core/meta/code-visibility.ts +18 -9
- package/src/core/network/__tests__/ai.test.ts +41 -0
- package/src/core/network/__tests__/connection.test.ts +1 -1
- package/src/core/network/__tests__/requests-network.test.ts +0 -16
- package/src/core/network/__tests__/requests-toasting.test.tsx +7 -7
- package/src/core/network/ai.ts +12 -0
- package/src/core/network/connection-notice.ts +1 -1
- package/src/core/network/connection.ts +1 -6
- package/src/core/network/requests-network.ts +10 -64
- package/src/core/network/requests-static.ts +2 -11
- package/src/core/network/requests-toasting.tsx +3 -57
- package/src/core/network/resolve.ts +1 -5
- package/src/core/network/types.ts +7 -22
- package/src/core/notebook/__tests__/operations.test.ts +51 -0
- package/src/core/notebook/attachments.ts +38 -0
- package/src/core/notebook/document/__tests__/codemirror.test.ts +768 -0
- package/src/core/{document → notebook/document}/__tests__/draft.test.ts +71 -31
- package/src/core/{document → notebook/document}/__tests__/fixtures.ts +2 -2
- package/src/core/notebook/document/__tests__/hooks.test.tsx +392 -0
- package/src/core/notebook/document/__tests__/lifecycle-scenarios.test.ts +61 -0
- package/src/core/notebook/document/__tests__/model.test.ts +252 -0
- package/src/core/notebook/document/__tests__/protocol-fixtures.ts +38 -0
- package/src/core/notebook/document/__tests__/recovery-scenarios.test.ts +259 -0
- package/src/core/notebook/document/__tests__/scenario-fixture.ts +44 -0
- package/src/core/notebook/document/__tests__/scenarios.test.ts +279 -0
- package/src/core/{document/__tests__/model.test.ts → notebook/document/__tests__/state.test.ts} +48 -24
- package/src/core/notebook/document/__tests__/submission.test.ts +204 -0
- package/src/core/notebook/document/__tests__/test-host.test.ts +92 -0
- package/src/core/notebook/document/__tests__/test-host.ts +223 -0
- package/src/core/notebook/document/__tests__/test-notebook.ts +162 -0
- package/src/core/notebook/document/__tests__/user.ts +62 -0
- package/src/core/notebook/document/codemirror.ts +216 -0
- package/src/core/{document → notebook/document}/draft.ts +53 -30
- package/src/core/notebook/document/hooks.tsx +123 -0
- package/src/core/notebook/document/index.ts +25 -0
- package/src/core/notebook/document/model.ts +105 -0
- package/src/core/notebook/document/select.ts +41 -0
- package/src/core/{document/model.ts → notebook/document/state.ts} +77 -71
- package/src/core/notebook/document/sync.ts +378 -0
- package/src/core/notebook/index.ts +19 -0
- package/src/core/notebook/operations.ts +30 -0
- package/src/core/notebook/replica/AGENTS.md +11 -0
- package/src/core/{host → notebook/replica}/__tests__/document.test.ts +13 -8
- package/src/core/notebook/replica/__tests__/executions.test.ts +272 -0
- package/src/core/notebook/replica/__tests__/fixtures.ts +103 -0
- package/src/core/{host/__tests__/notebook-client.test.ts → notebook/replica/__tests__/replica.test.ts} +268 -25
- package/src/core/notebook/replica/__tests__/results.test.ts +232 -0
- package/src/core/notebook/replica/__tests__/runtime.test.ts +77 -0
- package/src/core/notebook/replica/backend.ts +21 -0
- package/src/core/{host → notebook/replica}/connection.ts +1 -5
- package/src/core/notebook/replica/execution-state.ts +43 -0
- package/src/core/notebook/replica/index.ts +31 -0
- package/src/core/notebook/replica/replica.ts +569 -0
- package/src/core/notebook/replica/resources/analysis.ts +9 -0
- package/src/core/{host → notebook/replica}/resources/document.ts +1 -1
- package/src/core/notebook/replica/resources/executions.ts +348 -0
- package/src/core/notebook/replica/resources/results.ts +66 -0
- package/src/core/notebook/replica/resources/runtime.ts +14 -0
- package/src/core/packages/__tests__/useSandboxController.test.tsx +1 -1
- package/src/core/packages/useSandboxController.ts +1 -1
- package/src/core/run-app.tsx +49 -52
- package/src/core/runtime/__tests__/adapter.test.ts +4 -4
- package/src/core/runtime/__tests__/createWsUrl.test.ts +5 -17
- package/src/core/runtime/__tests__/runtime.test.ts +68 -141
- package/src/core/runtime/adapter.ts +6 -13
- package/src/core/runtime/config.ts +4 -24
- package/src/core/runtime/runtime.ts +11 -16
- package/src/core/runtime/types.ts +0 -5
- package/src/core/saving/__tests__/document.test.tsx +113 -0
- package/src/core/saving/__tests__/state.test.ts +111 -0
- package/src/core/saving/__tests__/useAutoSave.test.tsx +67 -0
- package/src/core/saving/__tests__/useSaveNotebook.test.tsx +69 -0
- package/src/core/saving/document.ts +33 -0
- package/src/core/saving/filename.ts +1 -1
- package/src/core/saving/save-component.tsx +68 -60
- package/src/core/saving/state.ts +42 -37
- package/src/core/saving/useAutoSave.ts +17 -53
- package/src/core/session/__tests__/backend.test.ts +244 -0
- package/src/core/session/__tests__/useNotebookReplica.hook.test.tsx +187 -0
- package/src/core/session/__tests__/useNotebookSession.hook.test.tsx +1552 -0
- package/src/core/session/active-notebook.ts +35 -0
- package/src/core/session/backend.ts +125 -0
- package/src/core/{websocket → session}/connection-utils.ts +2 -14
- package/src/core/session/embedded.ts +7 -0
- package/src/core/{websocket → session}/types.ts +2 -2
- package/src/core/session/useNotebookReplica.ts +91 -0
- package/src/core/{websocket → session}/useNotebookSession.tsx +178 -106
- package/src/core/static/__tests__/files.test.ts +38 -10
- package/src/core/static/virtual-file-tracker.ts +41 -10
- package/src/core/{websocket → transports}/__tests__/connection-state.test.ts +1 -1
- package/src/core/{websocket/transports/__tests__/notebook.test.ts → transports/__tests__/server.test.ts} +29 -119
- package/src/core/transports/__tests__/static.test.ts +357 -0
- package/src/core/transports/__tests__/wasm.test.ts +166 -0
- package/src/core/{websocket → transports}/connection-state.ts +9 -6
- package/src/core/{websocket/transports/notebook.ts → transports/server.ts} +15 -76
- package/src/core/transports/static.ts +188 -0
- package/src/core/transports/wasm.ts +95 -0
- package/src/core/vscode/__tests__/vscode-bindings.test.ts +125 -0
- package/src/core/vscode/vscode-bindings.ts +14 -2
- package/src/core/wasm/PyodideLoader.tsx +2 -1
- package/src/core/wasm/__tests__/PyodideLoader.test.tsx +100 -0
- package/src/core/wasm/__tests__/bridge.test.ts +346 -64
- package/src/core/wasm/__tests__/worker.test.ts +191 -0
- package/src/core/wasm/bridge.ts +167 -85
- package/src/core/wasm/errors.ts +8 -0
- package/src/core/wasm/rpc.ts +15 -3
- package/src/core/wasm/worker/bootstrap.ts +54 -50
- package/src/core/wasm/worker/save-worker.ts +9 -10
- package/src/core/wasm/worker/types.ts +32 -19
- package/src/core/wasm/worker/worker.ts +126 -72
- package/src/css/app/Cell.css +7 -36
- package/src/css/app/codemirror.css +1 -32
- package/src/css/common.css +1 -1
- package/src/css/globals.css +67 -24
- package/src/css/katex.min.css +1 -1
- package/src/hooks/useDebounce.ts +1 -2
- package/src/hooks/useEventListener.ts +1 -2
- package/src/mount.tsx +22 -19
- package/src/plugins/__tests__/plugin-object-schemas.test.ts +104 -0
- package/src/plugins/core/RenderHTML.tsx +3 -5
- package/src/plugins/core/__test__/PluginSlot.test.tsx +202 -0
- package/src/plugins/core/__test__/RenderHTML-copy.test.tsx +60 -0
- package/src/plugins/core/__test__/registerReactComponent.test.ts +45 -0
- package/src/plugins/core/__test__/sanitize.test.ts +35 -0
- package/src/plugins/core/registerReactComponent.tsx +28 -28
- package/src/plugins/core/sanitize-html.ts +8 -1
- package/src/plugins/impl/DataEditorPlugin.tsx +60 -28
- package/src/plugins/impl/DataTablePlugin.tsx +55 -22
- package/src/plugins/impl/RangeSliderPlugin.tsx +17 -2
- package/src/plugins/impl/SliderPlugin.tsx +35 -3
- package/src/plugins/impl/__test__/slider-labels.test.tsx +30 -0
- package/src/plugins/impl/__tests__/DataEditorPlugin.test.ts +190 -10
- package/src/plugins/impl/__tests__/DataTablePlugin.test.tsx +270 -0
- package/src/plugins/impl/__tests__/RangeSliderPlugin.test.tsx +109 -0
- package/src/plugins/impl/__tests__/SliderPlugin.test.tsx +40 -0
- package/src/plugins/impl/anywidget/__tests__/registry.test.ts +151 -0
- package/src/plugins/impl/anywidget/model.ts +3 -1
- package/src/plugins/impl/anywidget/registry.ts +18 -14
- package/src/plugins/impl/chat/__tests__/chat-prompts.test.tsx +1 -1
- package/src/plugins/impl/chat/chat-ui.tsx +5 -5
- package/src/plugins/impl/common/error-banner.tsx +5 -3
- package/src/plugins/impl/data-editor/__tests__/column-types.test.ts +42 -0
- package/src/plugins/impl/data-editor/__tests__/editor-state.test.ts +52 -1
- package/src/plugins/impl/data-editor/__tests__/glide-data-editor.test.tsx +278 -7
- package/src/plugins/impl/data-editor/__tests__/glide-utils.test.ts +116 -0
- package/src/plugins/impl/data-editor/column-types.ts +55 -0
- package/src/plugins/impl/data-editor/editor-state.ts +18 -2
- package/src/plugins/impl/data-editor/glide-data-editor.tsx +97 -18
- package/src/plugins/impl/data-editor/glide-portal.tsx +5 -3
- package/src/plugins/impl/data-editor/glide-utils.ts +36 -37
- package/src/plugins/impl/data-editor/types.ts +5 -0
- package/src/plugins/impl/data-explorer/components/column-summary.tsx +4 -2
- package/src/plugins/impl/data-explorer/functions/types.ts +1 -5
- package/src/plugins/impl/data-frames/DataFramePlugin.tsx +1 -1
- package/src/plugins/impl/data-frames/__tests__/sidebar.test.tsx +160 -0
- package/src/plugins/impl/data-frames/forms/__tests__/__snapshots__/form.test.tsx.snap +66 -66
- package/src/plugins/impl/data-frames/panel.tsx +44 -16
- package/src/plugins/impl/plotly/PlotlyPlugin.tsx +2 -5
- package/src/plugins/impl/plotly/selection.ts +25 -19
- package/src/plugins/impl/vega/VegaPlugin.tsx +2 -3
- package/src/plugins/layout/AccordionPlugin.tsx +2 -1
- package/src/plugins/layout/DownloadPlugin.tsx +7 -11
- package/src/plugins/layout/LazyPlugin.tsx +7 -4
- package/src/plugins/layout/TexPlugin.tsx +0 -1
- package/src/plugins/layout/__test__/DownloadPlugin.test.tsx +205 -0
- package/src/plugins/layout/__test__/mermaid.test.tsx +256 -0
- package/src/plugins/layout/__tests__/AccordionPlugin.test.tsx +21 -0
- package/src/plugins/layout/__tests__/LazyPlugin.test.tsx +98 -0
- package/src/plugins/layout/mermaid/mermaid.tsx +63 -17
- package/src/stories/cell-status.stories.tsx +29 -24
- package/src/stories/cell.stories.tsx +72 -57
- package/src/stories/data-table.stories.tsx +31 -0
- package/src/stories/editor.stories.tsx +4 -1
- package/src/stories/layout/vertical/one-column.stories.tsx +60 -60
- package/src/stories/runtime-story.tsx +23 -17
- package/src/stories/theme.stories.tsx +4 -2
- package/src/theme/__tests__/islands-theme.test.tsx +276 -0
- package/src/theme/namespace.tsx +4 -3
- package/src/theme/useTheme.ts +71 -41
- package/src/utils/__tests__/{createReducer.test.ts → createReducer.test.tsx} +127 -1
- package/src/utils/__tests__/download.test.tsx +183 -23
- package/src/utils/__tests__/numbers.test.ts +57 -0
- package/src/utils/arrays.ts +1 -2
- package/src/utils/createReducer.ts +115 -79
- package/src/utils/download.ts +67 -6
- package/src/utils/errors.ts +0 -7
- package/src/utils/maps.ts +0 -3
- package/src/utils/numbers.ts +59 -9
- package/src/utils/objects.ts +1 -2
- package/src/utils/python-poet/poet.ts +12 -2
- package/src/utils/time.ts +10 -0
- package/src/utils/tracer.ts +9 -5
- package/dist/ErrorBoundary-D9enmz8P.js +0 -200
- package/dist/_baseMerge-BiGRwuqv.js +0 -165
- package/dist/architecture-7GRP2DOG-BWLylgiA.js +0 -3
- package/dist/assets/__vite-browser-external-35VXYmnw.js +0 -1
- package/dist/assets/worker-Dq8y-WM5.js +0 -114
- package/dist/classDiagram-ZZMXUADV-GTL0l5xS.js +0 -30
- package/dist/classDiagram-v2-VYDZK3BY-BWrM2ruI.js +0 -30
- package/dist/code-visibility-Bvoq03vz.js +0 -138
- package/dist/cynefin-OW5HDTMX-obq-i80l.js +0 -3
- package/dist/dropdown-menu-B_7xD2X4.js +0 -4686
- package/dist/duckdb-keywords-BGArYVVK.js +0 -3
- package/dist/eventmodeling-NTZA5JFV-D7nP7Uyu.js +0 -3
- package/dist/feedback-button-DqvOnyXT.js +0 -379
- package/dist/flowDiagram-HODETNUW-CjaeFeea.js +0 -16
- package/dist/gitGraph-4MIJSDKK-Dy9uQXGh.js +0 -3
- package/dist/hasIn-o2Us0uVx.js +0 -132
- package/dist/highlighted-body-KPVGNVTW-3Ziwfz-V.js +0 -38
- package/dist/html-to-image-CWdayGZU.js +0 -3251
- package/dist/info-A6RAGUB7-DKoayiHY.js +0 -3
- package/dist/isArrayLikeObject-BZl-15ir.js +0 -450
- package/dist/isEmpty-BSZ1LaUo.js +0 -35
- package/dist/isSymbol-kQcfYbNX.js +0 -8
- package/dist/label-BRnUC0NX.js +0 -281
- package/dist/linear-DWERh7eI.js +0 -252
- package/dist/mermaid-HWGCJPDP-Du3-HPQA.js +0 -2
- package/dist/packet-AYTQ26CC-Yw7ajchJ.js +0 -3
- package/dist/pick-CJeoxYOS.js +0 -51
- package/dist/pie-WAS4IAKB-BKdKOAkL.js +0 -3
- package/dist/precisionRound-DhAzeRcm.js +0 -49
- package/dist/purify.es-DMv5zIkJ.js +0 -866
- package/dist/radar-RG4KPBEZ-ScR_D_Ts.js +0 -3
- package/dist/railroad-74A4TZTK-DQvPSdo5.js +0 -3
- package/dist/railroad-abnf-HS5TGJTU-CsJQG2O8.js +0 -3
- package/dist/railroad-ebnf-LZEXJU2U-BgEobkSn.js +0 -3
- package/dist/railroad-peg-WCYAUIDC-DjLAjofI.js +0 -3
- package/dist/select-B0LRDH0g.js +0 -1344
- package/dist/semaphore-89jsoHtS.js +0 -44
- package/dist/stateDiagram-v2-MP3YSRHH-8LL6FrBe.js +0 -30
- package/dist/swimlanesDiagram-VR7AAH4N-BoMMtOPh.js +0 -30
- package/dist/toast-CFWpihJU.js +0 -1830
- package/dist/treeView-Q6P3EWNA-DuRV97YF.js +0 -3
- package/dist/treemap-WGGIJYW6-AsLq-uwC.js +0 -3
- package/dist/use-restore-focus-DBCITLeF.js +0 -6369
- package/dist/useDeepCompareMemoize-BpPWi3G3.js +0 -11
- package/dist/useLifecycle-Dum8WSXq.js +0 -169
- package/dist/useTheme-CfeaVw5D.js +0 -904
- package/dist/wardley-WFR3VGLG-Na-tFhQJ.js +0 -3
- package/src/components/chat/reasoning-accordion.tsx +0 -61
- package/src/components/chat/tool-call/tool-error-card.tsx +0 -81
- package/src/components/chat/tool-call/tool-history-row.tsx +0 -174
- package/src/components/editor/ai/__tests__/staged-cell-submission.test.ts +0 -106
- package/src/components/editor/ai/add-cell-with-ai.tsx +0 -506
- package/src/components/editor/ai/staged-cell-submission.ts +0 -46
- package/src/components/editor/alerts/connecting-alert.tsx +0 -27
- package/src/components/editor/alerts/stdin-blocking-alert.tsx +0 -61
- package/src/components/editor/cell/__tests__/StagedAICell.test.tsx +0 -64
- package/src/components/editor/cell/code/__tests__/rtc-editor-config.test.ts +0 -50
- package/src/components/editor/chrome/wrapper/footer-items/rtc-status.tsx +0 -65
- package/src/components/editor/navigation/__tests__/state.test.ts +0 -81
- package/src/components/editor/navigation/state.ts +0 -65
- package/src/components/icons/loading-ellipsis.tsx +0 -46
- package/src/core/ai/tools/__tests__/run-cells-tool.test.ts +0 -656
- package/src/core/ai/tools/run-cells-tool.ts +0 -303
- package/src/core/attachments/state.ts +0 -18
- package/src/core/cells/__tests__/__snapshots__/cells.test.ts.snap +0 -1325
- package/src/core/cells/__tests__/apply-transaction.test.ts +0 -991
- package/src/core/cells/__tests__/document-changes.test.ts +0 -1140
- package/src/core/cells/__tests__/document-roundtrip.test.ts +0 -392
- package/src/core/cells/document-changes.ts +0 -944
- package/src/core/codemirror/rtc/extension.ts +0 -453
- package/src/core/codemirror/rtc/loro/__tests__/sync.test.ts +0 -52
- package/src/core/codemirror/rtc/loro/awareness.ts +0 -531
- package/src/core/codemirror/rtc/loro/colors.ts +0 -38
- package/src/core/codemirror/rtc/loro/sync.ts +0 -168
- package/src/core/document/__tests__/submission.test.ts +0 -334
- package/src/core/host/AGENTS.md +0 -16
- package/src/core/host/__tests__/fixtures.ts +0 -41
- package/src/core/host/notebook-client.ts +0 -259
- package/src/core/network/__tests__/requests-lazy.test.ts +0 -334
- package/src/core/network/requests-lazy.ts +0 -226
- package/src/core/rtc/state.ts +0 -34
- package/src/core/wasm/worker/message-buffer.ts +0 -33
- package/src/core/websocket/__tests__/useNotebookClient.hook.test.tsx +0 -223
- package/src/core/websocket/__tests__/useNotebookSession.hook.test.tsx +0 -606
- package/src/core/websocket/state.ts +0 -7
- package/src/core/websocket/useNotebookClient.ts +0 -89
- package/src/utils/__tests__/id-tree.test.ts +0 -2145
- package/src/utils/id-tree.tsx +0 -1134
- /package/src/{core/attachments/toast.ts → components/editor/agent-toast.ts} +0 -0
- /package/src/core/{host → notebook/replica}/__tests__/attachments.test.ts +0 -0
- /package/src/core/{host → notebook/replica}/resources/attachments.ts +0 -0
|
@@ -1,46 +1,43 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
2
|
|
|
3
|
+
import { defaultUserConfig } from "@/core/config/config-schema";
|
|
4
|
+
|
|
3
5
|
import { python } from "@codemirror/lang-python";
|
|
4
6
|
import { EditorState } from "@codemirror/state";
|
|
5
7
|
import { EditorView } from "@codemirror/view";
|
|
6
8
|
import { createStore } from "jotai";
|
|
9
|
+
import { createRef } from "react";
|
|
7
10
|
import {
|
|
8
11
|
afterAll,
|
|
9
|
-
afterEach,
|
|
10
12
|
beforeAll,
|
|
13
|
+
afterEach,
|
|
11
14
|
beforeEach,
|
|
12
15
|
describe,
|
|
13
16
|
expect,
|
|
14
17
|
it,
|
|
15
18
|
vi,
|
|
16
19
|
} from "vitest";
|
|
20
|
+
import { MockExecutions } from "@/__mocks__/executions";
|
|
17
21
|
import { MockNotebook } from "@/__mocks__/notebook";
|
|
18
22
|
import { cellId } from "@/__tests__/branded";
|
|
19
23
|
import type { CellHandle } from "@/components/editor/notebook-cell";
|
|
20
|
-
import { CellId, SCRATCH_CELL_ID
|
|
24
|
+
import { CellId, SCRATCH_CELL_ID } from "@/core/cells/ids";
|
|
21
25
|
import { foldAllBulk, unfoldAllBulk } from "@/core/codemirror/editing/commands";
|
|
22
26
|
import { adaptiveLanguageConfiguration } from "@/core/codemirror/language/extension";
|
|
23
27
|
import { OverridingHotkeyProvider } from "@/core/hotkeys/hotkeys";
|
|
24
|
-
import type {
|
|
25
|
-
import {
|
|
26
|
-
type CollapsibleTree,
|
|
27
|
-
MultiColumn,
|
|
28
|
-
type CellColumnId,
|
|
29
|
-
} from "@/utils/id-tree";
|
|
30
|
-
import type { Seconds } from "@/utils/time";
|
|
28
|
+
import type { CellConfig } from "@/core/network/types";
|
|
31
29
|
import {
|
|
32
30
|
exportedForTesting,
|
|
33
|
-
flattenTopLevelNotebookCells,
|
|
34
31
|
type NotebookState,
|
|
35
32
|
notebookAtom,
|
|
33
|
+
renderedNotebookCellsAtom,
|
|
36
34
|
} from "../cells";
|
|
37
|
-
import { exportedForTesting as documentTransactionTestExports } from "../document-changes";
|
|
38
35
|
import {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
36
|
+
type CellData,
|
|
37
|
+
createCell,
|
|
38
|
+
createCellConfig,
|
|
39
|
+
createCellRuntimeState,
|
|
40
|
+
} from "../types";
|
|
44
41
|
|
|
45
42
|
vi.mock("@/core/codemirror/editing/commands", () => ({
|
|
46
43
|
foldAllBulk: vi.fn(),
|
|
@@ -60,9 +57,6 @@ vi.mock("../scrollCellIntoView", async (importOriginal) => {
|
|
|
60
57
|
};
|
|
61
58
|
});
|
|
62
59
|
|
|
63
|
-
const FIRST_COLUMN = 0;
|
|
64
|
-
const SECOND_COLUMN = 1;
|
|
65
|
-
|
|
66
60
|
const { initialNotebookState, reducer, createActions } = exportedForTesting;
|
|
67
61
|
|
|
68
62
|
function formatCells(notebook: NotebookState) {
|
|
@@ -78,14 +72,7 @@ function formatCells(notebook: NotebookState) {
|
|
|
78
72
|
const cells = cellsId.map((cellId) => cellData[cellId]);
|
|
79
73
|
return cells.map((cell) => printCell(cell)).join("\n\n");
|
|
80
74
|
};
|
|
81
|
-
|
|
82
|
-
return `> col ${columnIdx}\n${printCells(column.inOrderIds)}`;
|
|
83
|
-
};
|
|
84
|
-
const columns = cellIds.getColumns();
|
|
85
|
-
if (columns.length > 1) {
|
|
86
|
-
return wrap(columns.map(printColumn).join("\n\n"));
|
|
87
|
-
}
|
|
88
|
-
return wrap(printCells(cellIds.inOrderIds));
|
|
75
|
+
return wrap(printCells(cellIds));
|
|
89
76
|
}
|
|
90
77
|
|
|
91
78
|
function createEditor(content: string) {
|
|
@@ -96,14 +83,14 @@ function createEditor(content: string) {
|
|
|
96
83
|
adaptiveLanguageConfiguration({
|
|
97
84
|
cellId: cellId("cell1"),
|
|
98
85
|
completionConfig: {
|
|
86
|
+
...defaultUserConfig().completion,
|
|
99
87
|
activate_on_typing: true,
|
|
100
88
|
signature_hint_on_typing: false,
|
|
101
89
|
copilot: false,
|
|
102
|
-
codeium_api_key: null,
|
|
103
90
|
},
|
|
104
91
|
hotkeys: new OverridingHotkeyProvider({}),
|
|
105
92
|
placeholderType: "marimo-import",
|
|
106
|
-
lspConfig: {},
|
|
93
|
+
lspConfig: { ...defaultUserConfig().language_servers },
|
|
107
94
|
}),
|
|
108
95
|
],
|
|
109
96
|
});
|
|
@@ -118,11 +105,9 @@ function createEditor(content: string) {
|
|
|
118
105
|
|
|
119
106
|
describe("cell reducer", () => {
|
|
120
107
|
let state: NotebookState;
|
|
121
|
-
let cells: ReturnType<typeof flattenTopLevelNotebookCells>;
|
|
122
108
|
let firstCellId: CellId;
|
|
123
109
|
|
|
124
|
-
const
|
|
125
|
-
state = reducer(state, action);
|
|
110
|
+
const mountEditors = () => {
|
|
126
111
|
for (const [cellIdString, handle] of Object.entries(state.cellHandles)) {
|
|
127
112
|
// @ts-expect-error - Typescript Object.entries doesn't know that keys are CellId
|
|
128
113
|
const cid: CellId = cellIdString;
|
|
@@ -135,8 +120,83 @@ describe("cell reducer", () => {
|
|
|
135
120
|
state.cellHandles[cid] = { current: handle };
|
|
136
121
|
}
|
|
137
122
|
}
|
|
138
|
-
|
|
139
|
-
|
|
123
|
+
};
|
|
124
|
+
const actions = createActions((action) => {
|
|
125
|
+
state = reducer(state, action);
|
|
126
|
+
mountEditors();
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
/** Put a cell into the notebook the way the document would. */
|
|
130
|
+
function seedCell({
|
|
131
|
+
cellId,
|
|
132
|
+
before,
|
|
133
|
+
code = "",
|
|
134
|
+
name,
|
|
135
|
+
config,
|
|
136
|
+
newCellId,
|
|
137
|
+
hideCode,
|
|
138
|
+
autoFocus = true,
|
|
139
|
+
}: {
|
|
140
|
+
cellId: CellId | "__end__";
|
|
141
|
+
before: boolean;
|
|
142
|
+
code?: string;
|
|
143
|
+
name?: string;
|
|
144
|
+
config?: CellConfig;
|
|
145
|
+
newCellId?: CellId;
|
|
146
|
+
hideCode?: boolean;
|
|
147
|
+
autoFocus?: boolean;
|
|
148
|
+
}): CellId {
|
|
149
|
+
const cellIndex =
|
|
150
|
+
cellId === "__end__"
|
|
151
|
+
? state.cellIds.length
|
|
152
|
+
: state.cellIds.indexOf(cellId);
|
|
153
|
+
const id = newCellId ?? CellId.create();
|
|
154
|
+
const cellIds = [...state.cellIds];
|
|
155
|
+
cellIds.splice(before ? cellIndex : cellIndex + 1, 0, id);
|
|
156
|
+
state = {
|
|
157
|
+
...state,
|
|
158
|
+
cellIds,
|
|
159
|
+
cellData: {
|
|
160
|
+
...state.cellData,
|
|
161
|
+
[id]: createCell({
|
|
162
|
+
id,
|
|
163
|
+
code,
|
|
164
|
+
name,
|
|
165
|
+
config: createCellConfig({
|
|
166
|
+
...config,
|
|
167
|
+
...(hideCode != null && { hide_code: hideCode }),
|
|
168
|
+
}),
|
|
169
|
+
}),
|
|
170
|
+
},
|
|
171
|
+
cellRuntime: { ...state.cellRuntime, [id]: createCellRuntimeState() },
|
|
172
|
+
cellHandles: { ...state.cellHandles, [id]: createRef() },
|
|
173
|
+
scrollKey: autoFocus ? id : null,
|
|
174
|
+
};
|
|
175
|
+
mountEditors();
|
|
176
|
+
return id;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/** Edit a cell's code as the document delivers it. */
|
|
180
|
+
function editCode(cellId: CellId, code: string) {
|
|
181
|
+
const cells = state.cellIds.map((id) => {
|
|
182
|
+
const cell = state.cellData[id];
|
|
183
|
+
return {
|
|
184
|
+
id,
|
|
185
|
+
code: id === cellId ? code : cell.code,
|
|
186
|
+
name: cell.name,
|
|
187
|
+
config: {
|
|
188
|
+
column: cell.config.column ?? null,
|
|
189
|
+
disabled: cell.config.disabled ?? false,
|
|
190
|
+
hide_code: cell.config.hide_code ?? false,
|
|
191
|
+
expand_output: cell.config.expand_output ?? false,
|
|
192
|
+
},
|
|
193
|
+
};
|
|
194
|
+
});
|
|
195
|
+
actions.reconcileDocument({
|
|
196
|
+
order: state.cellIds,
|
|
197
|
+
cells: new Map(cells.map((cell) => [cell.id, cell])),
|
|
198
|
+
});
|
|
199
|
+
}
|
|
140
200
|
|
|
141
201
|
let i = 0;
|
|
142
202
|
const originalCreate = CellId.create.bind(CellId);
|
|
@@ -151,3835 +211,294 @@ describe("cell reducer", () => {
|
|
|
151
211
|
i = 0;
|
|
152
212
|
|
|
153
213
|
state = initialNotebookState();
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
firstCellId = state.cellIds.inOrderIds[0];
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
afterEach(() => {
|
|
160
|
-
documentTransactionTestExports.cancelPendingChanges();
|
|
214
|
+
seedCell({ cellId: "__end__", before: false });
|
|
215
|
+
firstCellId = state.cellIds[0];
|
|
161
216
|
});
|
|
162
217
|
|
|
163
218
|
afterAll(() => {
|
|
164
219
|
CellId.create = originalCreate;
|
|
165
220
|
});
|
|
166
221
|
|
|
167
|
-
it("can
|
|
168
|
-
|
|
169
|
-
cellId: firstCellId,
|
|
170
|
-
before: false,
|
|
171
|
-
});
|
|
222
|
+
it("can update a cell", () => {
|
|
223
|
+
editCode(firstCellId, "import numpy as np");
|
|
172
224
|
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
173
225
|
"
|
|
174
|
-
[0] ''
|
|
175
|
-
|
|
176
|
-
[1] ''
|
|
226
|
+
[0] 'import numpy as np'
|
|
177
227
|
"
|
|
178
228
|
`);
|
|
179
229
|
});
|
|
180
230
|
|
|
181
|
-
it("can
|
|
182
|
-
actions.
|
|
183
|
-
|
|
184
|
-
code: "import numpy as np",
|
|
185
|
-
before: false,
|
|
186
|
-
});
|
|
187
|
-
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
188
|
-
"
|
|
189
|
-
[0] ''
|
|
231
|
+
it("can fold and unfold all cells", () => {
|
|
232
|
+
actions.foldAll();
|
|
233
|
+
expect(foldAllBulk).toHaveBeenCalled();
|
|
190
234
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
235
|
+
actions.unfoldAll();
|
|
236
|
+
expect(unfoldAllBulk).toHaveBeenCalled();
|
|
237
|
+
});
|
|
194
238
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
239
|
+
it("can clear logs", () => {
|
|
240
|
+
state.cellLogs = [
|
|
241
|
+
{
|
|
242
|
+
level: "stderr",
|
|
243
|
+
message: "log1",
|
|
244
|
+
timestamp: 0,
|
|
245
|
+
source: { type: "cell", cellId: firstCellId },
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
level: "stderr",
|
|
249
|
+
message: "log1",
|
|
250
|
+
timestamp: 0,
|
|
251
|
+
source: { type: "cell", cellId: firstCellId },
|
|
252
|
+
},
|
|
253
|
+
];
|
|
254
|
+
actions.clearLogs();
|
|
255
|
+
expect(state.cellLogs).toEqual([]);
|
|
199
256
|
});
|
|
200
257
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
});
|
|
206
|
-
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
207
|
-
"
|
|
208
|
-
[1] ''
|
|
258
|
+
describe("releaseCellAtoms", () => {
|
|
259
|
+
it("atom families cache atoms until explicitly removed", () => {
|
|
260
|
+
const { cellDataAtom, cellRuntimeAtom, cellHandleAtom } =
|
|
261
|
+
exportedForTesting;
|
|
209
262
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
263
|
+
seedCell({ cellId: firstCellId, before: false });
|
|
264
|
+
const newCellId = state.cellIds[1];
|
|
265
|
+
|
|
266
|
+
const dataAtom1 = cellDataAtom(newCellId);
|
|
267
|
+
const runtimeAtom1 = cellRuntimeAtom(newCellId);
|
|
268
|
+
const handleAtom1 = cellHandleAtom(newCellId);
|
|
269
|
+
|
|
270
|
+
// accesses return cached atoms (same reference)
|
|
271
|
+
const dataAtom2 = cellDataAtom(newCellId);
|
|
272
|
+
const runtimeAtom2 = cellRuntimeAtom(newCellId);
|
|
273
|
+
const handleAtom2 = cellHandleAtom(newCellId);
|
|
214
274
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
before: false,
|
|
219
|
-
code: "x = 1",
|
|
220
|
-
name: "My Cell",
|
|
221
|
-
config: { hide_code: true, disabled: false },
|
|
275
|
+
expect(dataAtom2).toBe(dataAtom1);
|
|
276
|
+
expect(runtimeAtom2).toBe(runtimeAtom1);
|
|
277
|
+
expect(handleAtom2).toBe(handleAtom1);
|
|
222
278
|
});
|
|
223
|
-
const newCellId = state.cellIds.inOrderIds[1];
|
|
224
|
-
expect(state.cellData[newCellId].name).toBe("My Cell");
|
|
225
|
-
expect(state.cellData[newCellId].config.hide_code).toBe(true);
|
|
226
|
-
expect(state.cellData[newCellId].config.disabled).toBe(false);
|
|
227
279
|
});
|
|
280
|
+
});
|
|
228
281
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
282
|
+
it("keeps layout cells stable when only a notebook log changes", () => {
|
|
283
|
+
const store = createStore();
|
|
284
|
+
const id = cellId("cell1");
|
|
285
|
+
const notebook = MockNotebook.notebookState({ cellData: { [id]: {} } });
|
|
286
|
+
store.set(notebookAtom, notebook);
|
|
287
|
+
const cells = store.get(renderedNotebookCellsAtom);
|
|
288
|
+
expect(cells.map((cell) => cell.id)).toEqual([id]);
|
|
289
|
+
|
|
290
|
+
store.set(notebookAtom, {
|
|
291
|
+
...notebook,
|
|
292
|
+
cellLogs: [
|
|
293
|
+
{
|
|
294
|
+
level: "stderr",
|
|
295
|
+
message: "log",
|
|
296
|
+
timestamp: 0,
|
|
297
|
+
source: { type: "cell", cellId: id },
|
|
298
|
+
},
|
|
299
|
+
],
|
|
300
|
+
});
|
|
301
|
+
expect(store.get(renderedNotebookCellsAtom)).toBe(cells);
|
|
302
|
+
});
|
|
242
303
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
246
|
-
"
|
|
247
|
-
[2] ''
|
|
304
|
+
describe("createTracebackInfoAtom", () => {
|
|
305
|
+
const store = createStore();
|
|
248
306
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
307
|
+
it("returns undefined when cell has no errors", async () => {
|
|
308
|
+
store.set(
|
|
309
|
+
notebookAtom,
|
|
310
|
+
MockNotebook.notebookState({
|
|
311
|
+
cellData: {
|
|
312
|
+
[cellId("cell1")]: {
|
|
313
|
+
id: cellId("cell1"),
|
|
314
|
+
name: "cell1",
|
|
315
|
+
code: "",
|
|
316
|
+
},
|
|
317
|
+
},
|
|
318
|
+
}),
|
|
319
|
+
);
|
|
320
|
+
|
|
321
|
+
const tracebackAtom = exportedForTesting.createTracebackInfoAtom(
|
|
322
|
+
cellId("cell1"),
|
|
323
|
+
);
|
|
324
|
+
const traceback = store.get(tracebackAtom);
|
|
252
325
|
|
|
253
|
-
|
|
254
|
-
expect(state.scrollKey).toBe("2");
|
|
326
|
+
expect(traceback).toBeUndefined();
|
|
255
327
|
});
|
|
256
328
|
|
|
257
|
-
it("
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
cellId
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
329
|
+
it("extracts the line of a syntax error the host reports", () => {
|
|
330
|
+
store.set(
|
|
331
|
+
notebookAtom,
|
|
332
|
+
MockNotebook.notebookState({
|
|
333
|
+
cellData: { [cellId("cell1")]: { code: "x = 1" } },
|
|
334
|
+
}),
|
|
335
|
+
);
|
|
336
|
+
MockExecutions.seed(store, [
|
|
337
|
+
MockExecutions.failed(cellId("cell1"), {
|
|
338
|
+
kind: "invalid-syntax",
|
|
339
|
+
message: "Syntax error",
|
|
340
|
+
range: {
|
|
341
|
+
start: { line: 4, character: 0 },
|
|
342
|
+
end: { line: 4, character: 0 },
|
|
343
|
+
},
|
|
344
|
+
}),
|
|
345
|
+
]);
|
|
272
346
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
[0] ''
|
|
347
|
+
const tracebackAtom = exportedForTesting.createTracebackInfoAtom(
|
|
348
|
+
cellId("cell1"),
|
|
349
|
+
);
|
|
350
|
+
const traceback = store.get(tracebackAtom);
|
|
278
351
|
|
|
279
|
-
|
|
280
|
-
"
|
|
281
|
-
|
|
352
|
+
expect(traceback).toEqual([
|
|
353
|
+
{ kind: "cell", cellId: cellId("cell1"), lineNumber: 5 },
|
|
354
|
+
]);
|
|
282
355
|
});
|
|
283
356
|
|
|
284
|
-
it("
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
[0] ''
|
|
298
|
-
"
|
|
299
|
-
`);
|
|
357
|
+
it("ignores a syntax error without a range", () => {
|
|
358
|
+
store.set(
|
|
359
|
+
notebookAtom,
|
|
360
|
+
MockNotebook.notebookState({
|
|
361
|
+
cellData: { [cellId("cell1")]: { code: "x = 1" } },
|
|
362
|
+
}),
|
|
363
|
+
);
|
|
364
|
+
MockExecutions.seed(store, [
|
|
365
|
+
MockExecutions.failed(cellId("cell1"), {
|
|
366
|
+
kind: "invalid-syntax",
|
|
367
|
+
message: "Syntax error",
|
|
368
|
+
}),
|
|
369
|
+
]);
|
|
300
370
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
"
|
|
305
|
-
[0] ''
|
|
371
|
+
const tracebackAtom = exportedForTesting.createTracebackInfoAtom(
|
|
372
|
+
cellId("cell1"),
|
|
373
|
+
);
|
|
306
374
|
|
|
307
|
-
|
|
308
|
-
"
|
|
309
|
-
`);
|
|
375
|
+
expect(store.get(tracebackAtom)).toBeUndefined();
|
|
310
376
|
});
|
|
311
377
|
|
|
312
|
-
it("
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
378
|
+
it("returns undefined when cell is queued", async () => {
|
|
379
|
+
store.set(
|
|
380
|
+
notebookAtom,
|
|
381
|
+
MockNotebook.notebookState({
|
|
382
|
+
cellData: { [cellId("cell1")]: { code: "x = 1" } },
|
|
383
|
+
}),
|
|
384
|
+
);
|
|
385
|
+
MockExecutions.seed(store, [MockExecutions.queued(cellId("cell1"))]);
|
|
319
386
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
expect(
|
|
326
|
-
|
|
387
|
+
const tracebackAtom = exportedForTesting.createTracebackInfoAtom(
|
|
388
|
+
cellId("cell1"),
|
|
389
|
+
);
|
|
390
|
+
const traceback = store.get(tracebackAtom);
|
|
391
|
+
|
|
392
|
+
expect(traceback).toBeUndefined();
|
|
393
|
+
});
|
|
327
394
|
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
395
|
+
it("returns undefined when cell is running", () => {
|
|
396
|
+
store.set(
|
|
397
|
+
notebookAtom,
|
|
398
|
+
MockNotebook.notebookState({
|
|
399
|
+
cellData: { [cellId("cell1")]: { code: "x = 1" } },
|
|
400
|
+
}),
|
|
401
|
+
);
|
|
402
|
+
MockExecutions.seed(store, [MockExecutions.running(cellId("cell1"))]);
|
|
331
403
|
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
404
|
+
const tracebackAtom = exportedForTesting.createTracebackInfoAtom(
|
|
405
|
+
cellId("cell1"),
|
|
406
|
+
);
|
|
407
|
+
const traceback = store.get(tracebackAtom);
|
|
336
408
|
|
|
337
|
-
|
|
338
|
-
expect(state.cellData[restoredCellId].config.hide_code).toBe(true);
|
|
339
|
-
expect(state.cellData[restoredCellId].config.disabled).toBe(true);
|
|
409
|
+
expect(traceback).toBeUndefined();
|
|
340
410
|
});
|
|
411
|
+
});
|
|
341
412
|
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
413
|
+
describe("kernel-ready", () => {
|
|
414
|
+
const CELL_A = cellId("A");
|
|
415
|
+
const CELL_B = cellId("B");
|
|
416
|
+
|
|
417
|
+
const hydratedState = () =>
|
|
418
|
+
MockNotebook.notebookState({
|
|
419
|
+
cellData: {
|
|
420
|
+
[CELL_A]: { id: CELL_A, code: "1" },
|
|
421
|
+
[CELL_B]: { id: CELL_B, code: "2" },
|
|
422
|
+
},
|
|
423
|
+
cellRuntime: {
|
|
424
|
+
[CELL_B]: {
|
|
425
|
+
embeddedConsole: [
|
|
426
|
+
{
|
|
427
|
+
channel: "stdout",
|
|
428
|
+
mimetype: "text/plain",
|
|
429
|
+
data: "hydrated-B-stdout",
|
|
430
|
+
timestamp: 0,
|
|
431
|
+
},
|
|
432
|
+
],
|
|
433
|
+
},
|
|
434
|
+
},
|
|
347
435
|
});
|
|
348
|
-
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
349
|
-
"
|
|
350
|
-
[0] 'import numpy as np'
|
|
351
|
-
"
|
|
352
|
-
`);
|
|
353
|
-
});
|
|
354
436
|
|
|
355
|
-
it("
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
437
|
+
it("resetCellRuntimes starts every cell's runtime over", () => {
|
|
438
|
+
const next = exportedForTesting.reducer(hydratedState(), {
|
|
439
|
+
type: "resetCellRuntimes",
|
|
440
|
+
payload: undefined,
|
|
359
441
|
});
|
|
360
|
-
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
361
|
-
"
|
|
362
|
-
[0] ''
|
|
363
442
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
`);
|
|
443
|
+
expect(next.cellRuntime[CELL_B].embeddedConsole).toEqual([]);
|
|
444
|
+
});
|
|
367
445
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
446
|
+
it("resetCellRuntimes starts the scratch cell over too", () => {
|
|
447
|
+
const state = MockNotebook.notebookState({
|
|
448
|
+
cellData: { [CELL_A]: { id: CELL_A, code: "1" } },
|
|
449
|
+
cellRuntime: {
|
|
450
|
+
[SCRATCH_CELL_ID]: {
|
|
451
|
+
embeddedConsole: [
|
|
452
|
+
{
|
|
453
|
+
channel: "stdout",
|
|
454
|
+
mimetype: "text/plain",
|
|
455
|
+
data: "scratch",
|
|
456
|
+
timestamp: 0,
|
|
457
|
+
},
|
|
458
|
+
],
|
|
459
|
+
},
|
|
460
|
+
},
|
|
461
|
+
});
|
|
462
|
+
const next = exportedForTesting.reducer(state, {
|
|
463
|
+
type: "resetCellRuntimes",
|
|
464
|
+
payload: undefined,
|
|
372
465
|
});
|
|
373
|
-
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
374
|
-
"
|
|
375
|
-
[1] ''
|
|
376
466
|
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
`);
|
|
467
|
+
expect(next.cellRuntime[SCRATCH_CELL_ID].embeddedConsole).toEqual([]);
|
|
468
|
+
});
|
|
380
469
|
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
470
|
+
describe("resetCellRuntimes in WASM", () => {
|
|
471
|
+
beforeEach(async () => {
|
|
472
|
+
const { isWasm } = await import("@/core/wasm/utils");
|
|
473
|
+
vi.mocked(isWasm).mockReturnValue(true);
|
|
385
474
|
});
|
|
386
|
-
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
387
|
-
"
|
|
388
|
-
[0] ''
|
|
389
|
-
|
|
390
|
-
[1] ''
|
|
391
|
-
"
|
|
392
|
-
`);
|
|
393
475
|
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
> col 0
|
|
399
|
-
[0] ''
|
|
476
|
+
afterEach(async () => {
|
|
477
|
+
const { isWasm } = await import("@/core/wasm/utils");
|
|
478
|
+
vi.mocked(isWasm).mockReturnValue(false);
|
|
479
|
+
});
|
|
400
480
|
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
481
|
+
it("keeps hydrated console output and starts the rest over", () => {
|
|
482
|
+
const next = exportedForTesting.reducer(hydratedState(), {
|
|
483
|
+
type: "resetCellRuntimes",
|
|
484
|
+
payload: undefined,
|
|
485
|
+
});
|
|
405
486
|
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
direction: "right",
|
|
487
|
+
expect(next.cellRuntime[CELL_B].embeddedConsole[0]).toMatchObject({
|
|
488
|
+
data: "hydrated-B-stdout",
|
|
489
|
+
});
|
|
410
490
|
});
|
|
411
|
-
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
412
|
-
"
|
|
413
|
-
> col 0
|
|
414
|
-
|
|
415
491
|
|
|
416
|
-
|
|
417
|
-
|
|
492
|
+
it("starts cells with no prior runtime over", () => {
|
|
493
|
+
const state = MockNotebook.notebookState({
|
|
494
|
+
cellData: { [CELL_A]: { id: CELL_A, code: "1" } },
|
|
495
|
+
});
|
|
496
|
+
const next = exportedForTesting.reducer(state, {
|
|
497
|
+
type: "resetCellRuntimes",
|
|
498
|
+
payload: undefined,
|
|
499
|
+
});
|
|
418
500
|
|
|
419
|
-
[
|
|
420
|
-
"
|
|
421
|
-
`);
|
|
422
|
-
|
|
423
|
-
// Move cell left
|
|
424
|
-
actions.moveCell({
|
|
425
|
-
cellId: firstCellId,
|
|
426
|
-
direction: "left",
|
|
427
|
-
});
|
|
428
|
-
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
429
|
-
"
|
|
430
|
-
> col 0
|
|
431
|
-
[0] ''
|
|
432
|
-
|
|
433
|
-
> col 1
|
|
434
|
-
[1] ''
|
|
435
|
-
"
|
|
436
|
-
`);
|
|
437
|
-
|
|
438
|
-
// Try to move cell left when it's already in leftmost column (should noop)
|
|
439
|
-
actions.moveCell({
|
|
440
|
-
cellId: firstCellId,
|
|
441
|
-
direction: "left",
|
|
442
|
-
});
|
|
443
|
-
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
444
|
-
"
|
|
445
|
-
> col 0
|
|
446
|
-
[0] ''
|
|
447
|
-
|
|
448
|
-
> col 1
|
|
449
|
-
[1] ''
|
|
450
|
-
"
|
|
451
|
-
`);
|
|
452
|
-
|
|
453
|
-
// Try to move cell right when it's already in rightmost column (should noop)
|
|
454
|
-
actions.moveCell({
|
|
455
|
-
cellId: cellId("1"),
|
|
456
|
-
direction: "right",
|
|
457
|
-
});
|
|
458
|
-
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
459
|
-
"
|
|
460
|
-
> col 0
|
|
461
|
-
[0] ''
|
|
462
|
-
|
|
463
|
-
> col 1
|
|
464
|
-
[1] ''
|
|
465
|
-
"
|
|
466
|
-
`);
|
|
467
|
-
});
|
|
468
|
-
|
|
469
|
-
it("can drag and drop a cell", () => {
|
|
470
|
-
actions.createNewCell({
|
|
471
|
-
cellId: firstCellId,
|
|
472
|
-
before: false,
|
|
473
|
-
});
|
|
474
|
-
actions.createNewCell({
|
|
475
|
-
cellId: cellId("1"),
|
|
476
|
-
before: false,
|
|
477
|
-
});
|
|
478
|
-
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
479
|
-
"
|
|
480
|
-
[0] ''
|
|
481
|
-
|
|
482
|
-
[1] ''
|
|
483
|
-
|
|
484
|
-
[2] ''
|
|
485
|
-
"
|
|
486
|
-
`);
|
|
487
|
-
|
|
488
|
-
// drag first cell to the end
|
|
489
|
-
actions.dropCellOverCell({
|
|
490
|
-
cellId: firstCellId,
|
|
491
|
-
overCellId: cellId("2"),
|
|
492
|
-
});
|
|
493
|
-
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
494
|
-
"
|
|
495
|
-
[1] ''
|
|
496
|
-
|
|
497
|
-
[2] ''
|
|
498
|
-
|
|
499
|
-
[0] ''
|
|
500
|
-
"
|
|
501
|
-
`);
|
|
502
|
-
|
|
503
|
-
// drag it back to the middle
|
|
504
|
-
actions.dropCellOverCell({
|
|
505
|
-
cellId: firstCellId,
|
|
506
|
-
overCellId: cellId("2"),
|
|
507
|
-
});
|
|
508
|
-
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
509
|
-
"
|
|
510
|
-
[1] ''
|
|
511
|
-
|
|
512
|
-
[0] ''
|
|
513
|
-
|
|
514
|
-
[2] ''
|
|
515
|
-
"
|
|
516
|
-
`);
|
|
517
|
-
});
|
|
518
|
-
|
|
519
|
-
it("can move a cell to an exact index within a column", () => {
|
|
520
|
-
actions.createNewCell({
|
|
521
|
-
cellId: firstCellId,
|
|
522
|
-
before: false,
|
|
523
|
-
});
|
|
524
|
-
actions.createNewCell({
|
|
525
|
-
cellId: cellId("1"),
|
|
526
|
-
before: false,
|
|
527
|
-
});
|
|
528
|
-
|
|
529
|
-
const columnId = state.cellIds.atOrThrow(0).id;
|
|
530
|
-
actions.moveCellToIndex({
|
|
531
|
-
cellId: firstCellId,
|
|
532
|
-
columnId,
|
|
533
|
-
index: 3,
|
|
534
|
-
});
|
|
535
|
-
|
|
536
|
-
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
537
|
-
"
|
|
538
|
-
[1] ''
|
|
539
|
-
|
|
540
|
-
[2] ''
|
|
541
|
-
|
|
542
|
-
[0] ''
|
|
543
|
-
"
|
|
544
|
-
`);
|
|
545
|
-
});
|
|
546
|
-
|
|
547
|
-
it("can move a cell to an exact index across columns", () => {
|
|
548
|
-
actions.createNewCell({
|
|
549
|
-
cellId: firstCellId,
|
|
550
|
-
before: false,
|
|
551
|
-
});
|
|
552
|
-
actions.createNewCell({
|
|
553
|
-
cellId: cellId("1"),
|
|
554
|
-
before: false,
|
|
555
|
-
});
|
|
556
|
-
actions.addColumnBreakpoint({ cellId: cellId("1") });
|
|
557
|
-
|
|
558
|
-
const secondColumnId = state.cellIds.atOrThrow(1).id;
|
|
559
|
-
actions.moveCellToIndex({
|
|
560
|
-
cellId: firstCellId,
|
|
561
|
-
columnId: secondColumnId,
|
|
562
|
-
index: 1,
|
|
563
|
-
});
|
|
564
|
-
|
|
565
|
-
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
566
|
-
"
|
|
567
|
-
> col 0
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
> col 1
|
|
571
|
-
[1] ''
|
|
572
|
-
|
|
573
|
-
[0] ''
|
|
574
|
-
|
|
575
|
-
[2] ''
|
|
576
|
-
"
|
|
577
|
-
`);
|
|
578
|
-
});
|
|
579
|
-
|
|
580
|
-
it("moveCellToIndex is a no-op when moving to the same position", () => {
|
|
581
|
-
actions.createNewCell({
|
|
582
|
-
cellId: firstCellId,
|
|
583
|
-
before: false,
|
|
584
|
-
});
|
|
585
|
-
actions.createNewCell({
|
|
586
|
-
cellId: cellId("1"),
|
|
587
|
-
before: false,
|
|
588
|
-
});
|
|
589
|
-
|
|
590
|
-
const columnId = state.cellIds.atOrThrow(0).id;
|
|
591
|
-
const before = formatCells(state);
|
|
592
|
-
|
|
593
|
-
actions.moveCellToIndex({
|
|
594
|
-
cellId: firstCellId,
|
|
595
|
-
columnId,
|
|
596
|
-
index: 0,
|
|
597
|
-
});
|
|
598
|
-
|
|
599
|
-
expect(formatCells(state)).toBe(before);
|
|
600
|
-
});
|
|
601
|
-
|
|
602
|
-
it("moveCellToIndex is a no-op for an invalid columnId", () => {
|
|
603
|
-
actions.createNewCell({
|
|
604
|
-
cellId: firstCellId,
|
|
605
|
-
before: false,
|
|
606
|
-
});
|
|
607
|
-
|
|
608
|
-
const before = formatCells(state);
|
|
609
|
-
|
|
610
|
-
actions.moveCellToIndex({
|
|
611
|
-
cellId: firstCellId,
|
|
612
|
-
columnId: "nonexistent-column" as CellColumnId,
|
|
613
|
-
index: 0,
|
|
614
|
-
});
|
|
615
|
-
|
|
616
|
-
expect(formatCells(state)).toBe(before);
|
|
617
|
-
});
|
|
618
|
-
|
|
619
|
-
it("can move multiple cells relative to target", () => {
|
|
620
|
-
actions.createNewCell({
|
|
621
|
-
cellId: firstCellId,
|
|
622
|
-
before: false,
|
|
623
|
-
});
|
|
624
|
-
actions.createNewCell({
|
|
625
|
-
cellId: cellId("1"),
|
|
626
|
-
before: false,
|
|
627
|
-
});
|
|
628
|
-
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
629
|
-
"
|
|
630
|
-
[0] ''
|
|
631
|
-
|
|
632
|
-
[1] ''
|
|
633
|
-
|
|
634
|
-
[2] ''
|
|
635
|
-
"
|
|
636
|
-
`);
|
|
637
|
-
|
|
638
|
-
// Move first two cells after the third
|
|
639
|
-
actions.moveCellsRelativeTo({
|
|
640
|
-
cellIds: [firstCellId, cellId("1")],
|
|
641
|
-
targetCellId: cellId("2"),
|
|
642
|
-
position: "after",
|
|
643
|
-
});
|
|
644
|
-
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
645
|
-
"
|
|
646
|
-
[2] ''
|
|
647
|
-
|
|
648
|
-
[0] ''
|
|
649
|
-
|
|
650
|
-
[1] ''
|
|
651
|
-
"
|
|
652
|
-
`);
|
|
653
|
-
});
|
|
654
|
-
|
|
655
|
-
it("can undo cut-paste (move with previousPlacements)", () => {
|
|
656
|
-
actions.createNewCell({
|
|
657
|
-
cellId: firstCellId,
|
|
658
|
-
before: false,
|
|
659
|
-
});
|
|
660
|
-
actions.createNewCell({
|
|
661
|
-
cellId: cellId("1"),
|
|
662
|
-
before: false,
|
|
663
|
-
});
|
|
664
|
-
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
665
|
-
"
|
|
666
|
-
[0] ''
|
|
667
|
-
|
|
668
|
-
[1] ''
|
|
669
|
-
|
|
670
|
-
[2] ''
|
|
671
|
-
"
|
|
672
|
-
`);
|
|
673
|
-
|
|
674
|
-
const col = state.cellIds.findWithId(firstCellId);
|
|
675
|
-
const previousPlacements = [
|
|
676
|
-
{
|
|
677
|
-
columnId: col.id,
|
|
678
|
-
index: col.indexOfOrThrow(
|
|
679
|
-
firstCellId,
|
|
680
|
-
) as import("@/utils/id-tree").CellIndex,
|
|
681
|
-
},
|
|
682
|
-
{
|
|
683
|
-
columnId: col.id,
|
|
684
|
-
index: col.indexOfOrThrow(
|
|
685
|
-
cellId("1"),
|
|
686
|
-
) as import("@/utils/id-tree").CellIndex,
|
|
687
|
-
},
|
|
688
|
-
];
|
|
689
|
-
|
|
690
|
-
actions.moveCellsRelativeTo({
|
|
691
|
-
cellIds: [firstCellId, cellId("1")],
|
|
692
|
-
targetCellId: cellId("2"),
|
|
693
|
-
position: "after",
|
|
694
|
-
previousPlacements,
|
|
695
|
-
});
|
|
696
|
-
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
697
|
-
"
|
|
698
|
-
[2] ''
|
|
699
|
-
|
|
700
|
-
[0] ''
|
|
701
|
-
|
|
702
|
-
[1] ''
|
|
703
|
-
"
|
|
704
|
-
`);
|
|
705
|
-
|
|
706
|
-
actions.undoDeleteCell();
|
|
707
|
-
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
708
|
-
"
|
|
709
|
-
[0] ''
|
|
710
|
-
|
|
711
|
-
[1] ''
|
|
712
|
-
|
|
713
|
-
[2] ''
|
|
714
|
-
"
|
|
715
|
-
`);
|
|
716
|
-
});
|
|
717
|
-
|
|
718
|
-
it("undo order: cut-paste then delete — first undo restores delete, second undo undoes move", () => {
|
|
719
|
-
actions.createNewCell({
|
|
720
|
-
cellId: firstCellId,
|
|
721
|
-
before: false,
|
|
722
|
-
});
|
|
723
|
-
actions.createNewCell({
|
|
724
|
-
cellId: cellId("1"),
|
|
725
|
-
before: false,
|
|
726
|
-
});
|
|
727
|
-
|
|
728
|
-
const col = state.cellIds.findWithId(firstCellId);
|
|
729
|
-
const previousPlacements = [
|
|
730
|
-
{
|
|
731
|
-
columnId: col.id,
|
|
732
|
-
index: col.indexOfOrThrow(
|
|
733
|
-
firstCellId,
|
|
734
|
-
) as import("@/utils/id-tree").CellIndex,
|
|
735
|
-
},
|
|
736
|
-
{
|
|
737
|
-
columnId: col.id,
|
|
738
|
-
index: col.indexOfOrThrow(
|
|
739
|
-
cellId("1"),
|
|
740
|
-
) as import("@/utils/id-tree").CellIndex,
|
|
741
|
-
},
|
|
742
|
-
];
|
|
743
|
-
|
|
744
|
-
actions.moveCellsRelativeTo({
|
|
745
|
-
cellIds: [firstCellId, cellId("1")],
|
|
746
|
-
targetCellId: cellId("2"),
|
|
747
|
-
position: "after",
|
|
748
|
-
previousPlacements,
|
|
749
|
-
});
|
|
750
|
-
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
751
|
-
"
|
|
752
|
-
[2] ''
|
|
753
|
-
|
|
754
|
-
[0] ''
|
|
755
|
-
|
|
756
|
-
[1] ''
|
|
757
|
-
"
|
|
758
|
-
`);
|
|
759
|
-
|
|
760
|
-
actions.deleteCell({ cellId: cellId("2") });
|
|
761
|
-
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
762
|
-
"
|
|
763
|
-
[0] ''
|
|
764
|
-
|
|
765
|
-
[1] ''
|
|
766
|
-
"
|
|
767
|
-
`);
|
|
768
|
-
|
|
769
|
-
actions.undoDeleteCell();
|
|
770
|
-
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
771
|
-
"
|
|
772
|
-
[3] ''
|
|
773
|
-
|
|
774
|
-
[0] ''
|
|
775
|
-
|
|
776
|
-
[1] ''
|
|
777
|
-
"
|
|
778
|
-
`);
|
|
779
|
-
|
|
780
|
-
actions.undoDeleteCell();
|
|
781
|
-
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
782
|
-
"
|
|
783
|
-
[0] ''
|
|
784
|
-
|
|
785
|
-
[1] ''
|
|
786
|
-
|
|
787
|
-
[3] ''
|
|
788
|
-
"
|
|
789
|
-
`);
|
|
790
|
-
});
|
|
791
|
-
|
|
792
|
-
it("keeps error evidence after an edit and a new queued run", () => {
|
|
793
|
-
const code = "raise ValueError('old failure')";
|
|
794
|
-
const output: OutputMessage = {
|
|
795
|
-
channel: "marimo-error",
|
|
796
|
-
mimetype: "application/vnd.marimo+error",
|
|
797
|
-
data: [
|
|
798
|
-
{
|
|
799
|
-
type: "exception",
|
|
800
|
-
msg: "old failure",
|
|
801
|
-
exception_type: "ValueError",
|
|
802
|
-
raising_cell: null,
|
|
803
|
-
traceback: "<pre>ValueError: old failure</pre>",
|
|
804
|
-
},
|
|
805
|
-
],
|
|
806
|
-
code,
|
|
807
|
-
timestamp: 1,
|
|
808
|
-
};
|
|
809
|
-
actions.handleCellMessage({
|
|
810
|
-
cell_id: firstCellId,
|
|
811
|
-
output,
|
|
812
|
-
console: {
|
|
813
|
-
channel: "stderr",
|
|
814
|
-
mimetype: "application/vnd.marimo+traceback",
|
|
815
|
-
data: "<pre>ValueError: old failure</pre>",
|
|
816
|
-
code,
|
|
817
|
-
timestamp: 1,
|
|
818
|
-
},
|
|
819
|
-
status: "idle",
|
|
820
|
-
stale_inputs: null,
|
|
821
|
-
timestamp: 1,
|
|
822
|
-
});
|
|
823
|
-
actions.updateCellCode({
|
|
824
|
-
cellId: firstCellId,
|
|
825
|
-
code: "print('new code')",
|
|
826
|
-
formattingChange: false,
|
|
827
|
-
});
|
|
828
|
-
actions.prepareForRun({ cellId: firstCellId });
|
|
829
|
-
actions.handleCellMessage({
|
|
830
|
-
cell_id: firstCellId,
|
|
831
|
-
output: null,
|
|
832
|
-
console: null,
|
|
833
|
-
status: "queued",
|
|
834
|
-
stale_inputs: null,
|
|
835
|
-
timestamp: 2,
|
|
836
|
-
});
|
|
837
|
-
const runtime = state.cellRuntime[firstCellId];
|
|
838
|
-
expect(state.cellData[firstCellId].lastCodeRun).toBe("print('new code')");
|
|
839
|
-
expect(runtime.output).toEqual(output);
|
|
840
|
-
expect(runtime.consoleOutputs[0].code).toBe(code);
|
|
841
|
-
expect(runtime.consoleOutputs[0].data).toContain("old failure");
|
|
842
|
-
});
|
|
843
|
-
|
|
844
|
-
it("can run cell and receive cell messages", () => {
|
|
845
|
-
// HAPPY PATH
|
|
846
|
-
/////////////////
|
|
847
|
-
// Initial state
|
|
848
|
-
let cell = cells[0];
|
|
849
|
-
expect(cell.status).toBe("idle");
|
|
850
|
-
expect(cell.lastCodeRun).toBe(null);
|
|
851
|
-
expect(cell.edited).toBe(false);
|
|
852
|
-
expect(cell).toMatchSnapshot("initial state");
|
|
853
|
-
|
|
854
|
-
// Update code
|
|
855
|
-
actions.updateCellCode({
|
|
856
|
-
cellId: firstCellId,
|
|
857
|
-
code: "import marimo as mo",
|
|
858
|
-
formattingChange: false,
|
|
859
|
-
});
|
|
860
|
-
cell = cells[0];
|
|
861
|
-
expect(cell.status).toBe("idle");
|
|
862
|
-
expect(cell.lastCodeRun).toBe(null);
|
|
863
|
-
expect(cell.edited).toBe(true);
|
|
864
|
-
expect(cell).toMatchSnapshot("code edited");
|
|
865
|
-
|
|
866
|
-
// Prepare for run
|
|
867
|
-
actions.prepareForRun({
|
|
868
|
-
cellId: firstCellId,
|
|
869
|
-
});
|
|
870
|
-
cell = cells[0];
|
|
871
|
-
expect(cell.status).toBe("queued");
|
|
872
|
-
expect(cell.lastCodeRun).toBe("import marimo as mo");
|
|
873
|
-
expect(cell.edited).toBe(false);
|
|
874
|
-
expect(cell).toMatchSnapshot("prepared for run");
|
|
875
|
-
|
|
876
|
-
// Receive queued messages
|
|
877
|
-
actions.handleCellMessage({
|
|
878
|
-
cell_id: firstCellId,
|
|
879
|
-
output: undefined,
|
|
880
|
-
console: null,
|
|
881
|
-
status: "queued",
|
|
882
|
-
stale_inputs: null,
|
|
883
|
-
timestamp: new Date(10).getTime() as Seconds,
|
|
884
|
-
});
|
|
885
|
-
cell = cells[0];
|
|
886
|
-
expect(cell.status).toBe("queued");
|
|
887
|
-
expect(cell.lastCodeRun).toBe("import marimo as mo");
|
|
888
|
-
expect(cell.edited).toBe(false);
|
|
889
|
-
expect(cell.runElapsedTimeMs).toBe(null);
|
|
890
|
-
expect(cell.runStartTimestamp).toBe(null);
|
|
891
|
-
expect(cell.lastRunStartTimestamp).toBe(null);
|
|
892
|
-
expect(cell).toMatchSnapshot("queued message received");
|
|
893
|
-
|
|
894
|
-
// Receive running messages
|
|
895
|
-
actions.handleCellMessage({
|
|
896
|
-
cell_id: firstCellId,
|
|
897
|
-
output: undefined,
|
|
898
|
-
console: null,
|
|
899
|
-
status: "running",
|
|
900
|
-
stale_inputs: null,
|
|
901
|
-
timestamp: new Date(20).getTime() as Seconds,
|
|
902
|
-
});
|
|
903
|
-
cell = cells[0];
|
|
904
|
-
expect(cell.status).toBe("running");
|
|
905
|
-
expect(cell.lastCodeRun).toBe("import marimo as mo");
|
|
906
|
-
expect(cell.edited).toBe(false);
|
|
907
|
-
expect(cell.runElapsedTimeMs).toBe(null);
|
|
908
|
-
expect(cell.runStartTimestamp).toBe(20);
|
|
909
|
-
expect(cell.lastRunStartTimestamp).toBe(20);
|
|
910
|
-
expect(cell).toMatchSnapshot("running message received");
|
|
911
|
-
|
|
912
|
-
// Console messages shouldn't transition status
|
|
913
|
-
actions.handleCellMessage({
|
|
914
|
-
cell_id: firstCellId,
|
|
915
|
-
output: undefined,
|
|
916
|
-
console: {
|
|
917
|
-
channel: "stdout",
|
|
918
|
-
mimetype: "text/plain",
|
|
919
|
-
data: "hello!",
|
|
920
|
-
timestamp: 0,
|
|
921
|
-
},
|
|
922
|
-
status: undefined,
|
|
923
|
-
stale_inputs: null,
|
|
924
|
-
timestamp: new Date(22).getTime() as Seconds,
|
|
925
|
-
});
|
|
926
|
-
cell = cells[0];
|
|
927
|
-
expect(cell.status).toBe("running");
|
|
928
|
-
expect(cell.edited).toBe(false);
|
|
929
|
-
expect(cell.runElapsedTimeMs).toBe(null);
|
|
930
|
-
expect(cell.runStartTimestamp).toBe(20);
|
|
931
|
-
expect(cell.lastRunStartTimestamp).toBe(20);
|
|
932
|
-
expect(cell).toMatchSnapshot("console message received");
|
|
933
|
-
|
|
934
|
-
// Receive output messages
|
|
935
|
-
actions.handleCellMessage({
|
|
936
|
-
cell_id: firstCellId,
|
|
937
|
-
output: {
|
|
938
|
-
channel: "output",
|
|
939
|
-
mimetype: "text/plain",
|
|
940
|
-
data: "ok",
|
|
941
|
-
timestamp: 0,
|
|
942
|
-
},
|
|
943
|
-
console: {
|
|
944
|
-
channel: "stdout",
|
|
945
|
-
mimetype: "text/plain",
|
|
946
|
-
data: "hello!",
|
|
947
|
-
timestamp: 0,
|
|
948
|
-
},
|
|
949
|
-
status: "idle",
|
|
950
|
-
stale_inputs: null,
|
|
951
|
-
timestamp: new Date(33).getTime() as Seconds,
|
|
952
|
-
});
|
|
953
|
-
cell = cells[0];
|
|
954
|
-
expect(cell.status).toBe("idle");
|
|
955
|
-
expect(cell.edited).toBe(false);
|
|
956
|
-
expect(cell.runElapsedTimeMs).toBe(13_000);
|
|
957
|
-
expect(cell.runStartTimestamp).toBe(null);
|
|
958
|
-
expect(cell.lastRunStartTimestamp).toBe(20);
|
|
959
|
-
expect(cell).toMatchSnapshot("output received");
|
|
960
|
-
|
|
961
|
-
// EDITING BACK AND FORTH
|
|
962
|
-
/////////////////
|
|
963
|
-
// Update code again
|
|
964
|
-
actions.updateCellCode({
|
|
965
|
-
cellId: firstCellId,
|
|
966
|
-
code: "import marimo as mo\nimport numpy",
|
|
967
|
-
formattingChange: false,
|
|
968
|
-
});
|
|
969
|
-
cell = cells[0];
|
|
970
|
-
expect(cell.status).toBe("idle");
|
|
971
|
-
expect(cell.edited).toBe(true);
|
|
972
|
-
expect(cell).toMatchSnapshot("code edited again");
|
|
973
|
-
|
|
974
|
-
// Update code should be unedited
|
|
975
|
-
actions.updateCellCode({
|
|
976
|
-
cellId: firstCellId,
|
|
977
|
-
code: "import marimo as mo",
|
|
978
|
-
formattingChange: false,
|
|
979
|
-
});
|
|
980
|
-
cell = cells[0];
|
|
981
|
-
expect(cell.edited).toBe(false);
|
|
982
|
-
expect(cell).toMatchSnapshot("code reverted");
|
|
983
|
-
|
|
984
|
-
// Update code should be edited again
|
|
985
|
-
actions.updateCellCode({
|
|
986
|
-
cellId: firstCellId,
|
|
987
|
-
code: "import marimo as mo\nimport numpy",
|
|
988
|
-
formattingChange: false,
|
|
989
|
-
});
|
|
990
|
-
cell = cells[0];
|
|
991
|
-
expect(cell.status).toBe("idle");
|
|
992
|
-
expect(cell.lastCodeRun).toBe("import marimo as mo");
|
|
993
|
-
expect(cell.edited).toBe(true);
|
|
994
|
-
expect(cell).toMatchSnapshot("code changed after revert");
|
|
995
|
-
|
|
996
|
-
// ERROR RESPONSE
|
|
997
|
-
/////////////////
|
|
998
|
-
// Prepare for run
|
|
999
|
-
actions.prepareForRun({
|
|
1000
|
-
cellId: firstCellId,
|
|
1001
|
-
});
|
|
1002
|
-
cell = cells[0];
|
|
1003
|
-
expect(cell.output).not.toBe(null); // keep old output
|
|
1004
|
-
// Queue
|
|
1005
|
-
actions.handleCellMessage({
|
|
1006
|
-
cell_id: firstCellId,
|
|
1007
|
-
output: undefined,
|
|
1008
|
-
console: null,
|
|
1009
|
-
status: "queued",
|
|
1010
|
-
stale_inputs: null,
|
|
1011
|
-
timestamp: new Date(40).getTime() as Seconds,
|
|
1012
|
-
});
|
|
1013
|
-
cell = cells[0];
|
|
1014
|
-
expect(cell.output).not.toBe(null); // keep old output
|
|
1015
|
-
// Running
|
|
1016
|
-
actions.handleCellMessage({
|
|
1017
|
-
cell_id: firstCellId,
|
|
1018
|
-
output: undefined,
|
|
1019
|
-
console: null,
|
|
1020
|
-
status: "running",
|
|
1021
|
-
stale_inputs: null,
|
|
1022
|
-
timestamp: new Date(50).getTime() as Seconds,
|
|
1023
|
-
});
|
|
1024
|
-
cell = cells[0];
|
|
1025
|
-
expect(cell.output).not.toBe(null); // keep old output
|
|
1026
|
-
// Receive error
|
|
1027
|
-
actions.handleCellMessage({
|
|
1028
|
-
cell_id: firstCellId,
|
|
1029
|
-
output: {
|
|
1030
|
-
channel: "marimo-error",
|
|
1031
|
-
mimetype: "application/vnd.marimo+error",
|
|
1032
|
-
data: [
|
|
1033
|
-
{ type: "exception", exception_type: "ValueError", msg: "Oh no!" },
|
|
1034
|
-
],
|
|
1035
|
-
timestamp: 0,
|
|
1036
|
-
},
|
|
1037
|
-
console: null,
|
|
1038
|
-
status: "idle",
|
|
1039
|
-
stale_inputs: null,
|
|
1040
|
-
timestamp: new Date(61).getTime() as Seconds,
|
|
1041
|
-
});
|
|
1042
|
-
cell = cells[0];
|
|
1043
|
-
expect(cell.output).not.toBe(null); // keep old output
|
|
1044
|
-
expect(cell.status).toBe("idle");
|
|
1045
|
-
expect(cell.lastCodeRun).toBe("import marimo as mo\nimport numpy");
|
|
1046
|
-
expect(cell.edited).toBe(false);
|
|
1047
|
-
expect(cell.runElapsedTimeMs).toBe(11_000);
|
|
1048
|
-
expect(cell.runStartTimestamp).toBe(null);
|
|
1049
|
-
expect(cell).toMatchSnapshot("error response received");
|
|
1050
|
-
|
|
1051
|
-
// INTERRUPT RESPONSE
|
|
1052
|
-
/////////////////
|
|
1053
|
-
// Prepare for run
|
|
1054
|
-
actions.prepareForRun({
|
|
1055
|
-
cellId: firstCellId,
|
|
1056
|
-
});
|
|
1057
|
-
cell = cells[0];
|
|
1058
|
-
expect(cell.output).not.toBe(null); // keep old output
|
|
1059
|
-
// Queue
|
|
1060
|
-
actions.handleCellMessage({
|
|
1061
|
-
cell_id: firstCellId,
|
|
1062
|
-
output: undefined,
|
|
1063
|
-
console: null,
|
|
1064
|
-
status: "queued",
|
|
1065
|
-
stale_inputs: null,
|
|
1066
|
-
timestamp: new Date(40).getTime() as Seconds,
|
|
1067
|
-
});
|
|
1068
|
-
cell = cells[0];
|
|
1069
|
-
expect(cell.output).not.toBe(null); // keep old output
|
|
1070
|
-
// Running
|
|
1071
|
-
actions.handleCellMessage({
|
|
1072
|
-
cell_id: firstCellId,
|
|
1073
|
-
output: undefined,
|
|
1074
|
-
console: null,
|
|
1075
|
-
status: "running",
|
|
1076
|
-
stale_inputs: null,
|
|
1077
|
-
timestamp: new Date(50).getTime() as Seconds,
|
|
1078
|
-
});
|
|
1079
|
-
cell = cells[0];
|
|
1080
|
-
expect(cell.output).not.toBe(null); // keep old output
|
|
1081
|
-
// Receive error
|
|
1082
|
-
actions.handleCellMessage({
|
|
1083
|
-
cell_id: firstCellId,
|
|
1084
|
-
output: {
|
|
1085
|
-
channel: "marimo-error",
|
|
1086
|
-
mimetype: "application/vnd.marimo+error",
|
|
1087
|
-
data: [{ type: "interruption" }],
|
|
1088
|
-
timestamp: 0,
|
|
1089
|
-
},
|
|
1090
|
-
console: null,
|
|
1091
|
-
status: "idle",
|
|
1092
|
-
stale_inputs: null,
|
|
1093
|
-
timestamp: new Date(61).getTime() as Seconds,
|
|
1094
|
-
});
|
|
1095
|
-
cell = cells[0];
|
|
1096
|
-
expect(cell.status).toBe("idle");
|
|
1097
|
-
expect(cell.lastCodeRun).toBe(cell.code);
|
|
1098
|
-
expect(cell.edited).toBe(false);
|
|
1099
|
-
expect(cell.runElapsedTimeMs).toBe(11_000);
|
|
1100
|
-
expect(cell.runStartTimestamp).toBe(null);
|
|
1101
|
-
expect(cell).toMatchSnapshot("interruption response received");
|
|
1102
|
-
});
|
|
1103
|
-
|
|
1104
|
-
it("errors reset status to idle", () => {
|
|
1105
|
-
// Initial state
|
|
1106
|
-
let cell = cells[0];
|
|
1107
|
-
expect(cell.status).toBe("idle");
|
|
1108
|
-
expect(cell.lastCodeRun).toBe(null);
|
|
1109
|
-
expect(cell.edited).toBe(false);
|
|
1110
|
-
expect(cell).toMatchSnapshot("initial state");
|
|
1111
|
-
|
|
1112
|
-
// Update code
|
|
1113
|
-
actions.updateCellCode({
|
|
1114
|
-
cellId: firstCellId,
|
|
1115
|
-
code: "import marimo as mo",
|
|
1116
|
-
formattingChange: false,
|
|
1117
|
-
});
|
|
1118
|
-
cell = cells[0];
|
|
1119
|
-
expect(cell.status).toBe("idle");
|
|
1120
|
-
expect(cell.lastCodeRun).toBe(null);
|
|
1121
|
-
expect(cell.edited).toBe(true);
|
|
1122
|
-
expect(cell).toMatchSnapshot("code edited");
|
|
1123
|
-
|
|
1124
|
-
// Prepare for run
|
|
1125
|
-
actions.prepareForRun({
|
|
1126
|
-
cellId: firstCellId,
|
|
1127
|
-
});
|
|
1128
|
-
cell = cells[0];
|
|
1129
|
-
expect(cell.status).toBe("queued");
|
|
1130
|
-
expect(cell.lastCodeRun).toBe("import marimo as mo");
|
|
1131
|
-
expect(cell.edited).toBe(false);
|
|
1132
|
-
expect(cell).toMatchSnapshot("prepared for run");
|
|
1133
|
-
|
|
1134
|
-
// ERROR RESPONSE
|
|
1135
|
-
//
|
|
1136
|
-
// should reset status to idle
|
|
1137
|
-
/////////////////
|
|
1138
|
-
// Prepare for run
|
|
1139
|
-
actions.prepareForRun({
|
|
1140
|
-
cellId: firstCellId,
|
|
1141
|
-
});
|
|
1142
|
-
cell = cells[0];
|
|
1143
|
-
// Receive error
|
|
1144
|
-
actions.handleCellMessage({
|
|
1145
|
-
cell_id: firstCellId,
|
|
1146
|
-
output: {
|
|
1147
|
-
channel: "marimo-error",
|
|
1148
|
-
mimetype: "application/vnd.marimo+error",
|
|
1149
|
-
data: [
|
|
1150
|
-
{ type: "exception", exception_type: "SyntaxError", msg: "Oh no!" },
|
|
1151
|
-
],
|
|
1152
|
-
timestamp: 0,
|
|
1153
|
-
},
|
|
1154
|
-
console: null,
|
|
1155
|
-
stale_inputs: null,
|
|
1156
|
-
timestamp: new Date(61).getTime() as Seconds,
|
|
1157
|
-
});
|
|
1158
|
-
cell = cells[0];
|
|
1159
|
-
expect(cell.status).toBe("idle");
|
|
1160
|
-
expect(cell.lastCodeRun).toBe("import marimo as mo");
|
|
1161
|
-
expect(cell.edited).toBe(false);
|
|
1162
|
-
expect(cell.runElapsedTimeMs).toBe(null);
|
|
1163
|
-
expect(cell.runStartTimestamp).toBe(null);
|
|
1164
|
-
expect(cell).toMatchSnapshot("error response received");
|
|
1165
|
-
});
|
|
1166
|
-
|
|
1167
|
-
it("can run a stale cell", () => {
|
|
1168
|
-
// Update code of first cell
|
|
1169
|
-
actions.updateCellCode({
|
|
1170
|
-
cellId: firstCellId,
|
|
1171
|
-
code: "import marimo as mo",
|
|
1172
|
-
formattingChange: false,
|
|
1173
|
-
});
|
|
1174
|
-
// Add cell
|
|
1175
|
-
actions.createNewCell({
|
|
1176
|
-
cellId: firstCellId,
|
|
1177
|
-
before: false,
|
|
1178
|
-
});
|
|
1179
|
-
const secondCell = cells[1].id;
|
|
1180
|
-
// Update code
|
|
1181
|
-
actions.updateCellCode({
|
|
1182
|
-
code: "mo.slider()",
|
|
1183
|
-
cellId: secondCell,
|
|
1184
|
-
formattingChange: false,
|
|
1185
|
-
});
|
|
1186
|
-
|
|
1187
|
-
// Prepare for run
|
|
1188
|
-
actions.prepareForRun({
|
|
1189
|
-
cellId: secondCell,
|
|
1190
|
-
});
|
|
1191
|
-
|
|
1192
|
-
// Receive queued messages
|
|
1193
|
-
actions.handleCellMessage({
|
|
1194
|
-
cell_id: secondCell,
|
|
1195
|
-
output: undefined,
|
|
1196
|
-
console: null,
|
|
1197
|
-
status: "queued",
|
|
1198
|
-
stale_inputs: null,
|
|
1199
|
-
timestamp: new Date(10).getTime() as Seconds,
|
|
1200
|
-
});
|
|
1201
|
-
let cell = cells[1];
|
|
1202
|
-
expect(cell.status).toBe("queued");
|
|
1203
|
-
expect(cell.lastCodeRun).toBe("mo.slider()");
|
|
1204
|
-
expect(cell.edited).toBe(false);
|
|
1205
|
-
expect(cell.runElapsedTimeMs).toBe(null);
|
|
1206
|
-
expect(cell.runStartTimestamp).toBe(null);
|
|
1207
|
-
expect(cell).toMatchSnapshot("queued message received");
|
|
1208
|
-
|
|
1209
|
-
// Receive stale message
|
|
1210
|
-
actions.handleCellMessage({
|
|
1211
|
-
cell_id: secondCell,
|
|
1212
|
-
output: undefined,
|
|
1213
|
-
console: null,
|
|
1214
|
-
status: undefined,
|
|
1215
|
-
stale_inputs: true,
|
|
1216
|
-
timestamp: new Date(20).getTime() as Seconds,
|
|
1217
|
-
});
|
|
1218
|
-
cell = cells[1];
|
|
1219
|
-
expect(cell.status).toBe("queued");
|
|
1220
|
-
expect(cell.lastCodeRun).toBe("mo.slider()");
|
|
1221
|
-
expect(cell.edited).toBe(false);
|
|
1222
|
-
expect(cell.runElapsedTimeMs).toBe(null);
|
|
1223
|
-
expect(cell.runStartTimestamp).toBe(null);
|
|
1224
|
-
expect(cell).toMatchSnapshot("stale inputs received");
|
|
1225
|
-
});
|
|
1226
|
-
|
|
1227
|
-
it("can format code and update cell", () => {
|
|
1228
|
-
const firstCellId = cells[0].id;
|
|
1229
|
-
actions.updateCellCode({
|
|
1230
|
-
cellId: firstCellId,
|
|
1231
|
-
code: "import marimo as mo",
|
|
1232
|
-
formattingChange: false,
|
|
1233
|
-
});
|
|
1234
|
-
let cell = cells[0];
|
|
1235
|
-
expect(cell.status).toBe("idle");
|
|
1236
|
-
expect(cell.lastCodeRun).toBe(null);
|
|
1237
|
-
expect(cell.edited).toBe(true);
|
|
1238
|
-
|
|
1239
|
-
// Run
|
|
1240
|
-
actions.prepareForRun({
|
|
1241
|
-
cellId: firstCellId,
|
|
1242
|
-
});
|
|
1243
|
-
actions.handleCellMessage({
|
|
1244
|
-
cell_id: firstCellId,
|
|
1245
|
-
output: {
|
|
1246
|
-
channel: "output",
|
|
1247
|
-
mimetype: "text/plain",
|
|
1248
|
-
data: "ok",
|
|
1249
|
-
timestamp: 0,
|
|
1250
|
-
},
|
|
1251
|
-
console: {
|
|
1252
|
-
channel: "stdout",
|
|
1253
|
-
mimetype: "text/plain",
|
|
1254
|
-
data: "hello!",
|
|
1255
|
-
timestamp: 0,
|
|
1256
|
-
},
|
|
1257
|
-
status: "idle",
|
|
1258
|
-
stale_inputs: null,
|
|
1259
|
-
timestamp: new Date(33).getTime() as Seconds,
|
|
1260
|
-
});
|
|
1261
|
-
|
|
1262
|
-
// Check steady state
|
|
1263
|
-
cell = cells[0];
|
|
1264
|
-
expect(cell.status).toBe("idle");
|
|
1265
|
-
expect(cell.edited).toBe(false);
|
|
1266
|
-
expect(cell.lastCodeRun).toBe("import marimo as mo");
|
|
1267
|
-
|
|
1268
|
-
// Format code
|
|
1269
|
-
actions.updateCellCode({
|
|
1270
|
-
cellId: firstCellId,
|
|
1271
|
-
code: "import marimo as mo",
|
|
1272
|
-
formattingChange: true,
|
|
1273
|
-
});
|
|
1274
|
-
cell = cells[0];
|
|
1275
|
-
expect(cell.status).toBe("idle");
|
|
1276
|
-
expect(cell.lastCodeRun).toBe("import marimo as mo");
|
|
1277
|
-
expect(cell.edited).toBe(false);
|
|
1278
|
-
});
|
|
1279
|
-
|
|
1280
|
-
it("can update a cells config", () => {
|
|
1281
|
-
const firstCellId = cells[0].id;
|
|
1282
|
-
let cell = cells[0];
|
|
1283
|
-
// Starts empty
|
|
1284
|
-
expect(cell.config).toEqual({
|
|
1285
|
-
disabled: false,
|
|
1286
|
-
hide_code: false,
|
|
1287
|
-
column: null,
|
|
1288
|
-
expand_output: false,
|
|
1289
|
-
});
|
|
1290
|
-
|
|
1291
|
-
actions.updateCellConfig({
|
|
1292
|
-
cellId: firstCellId,
|
|
1293
|
-
config: { disabled: true },
|
|
1294
|
-
});
|
|
1295
|
-
cell = cells[0];
|
|
1296
|
-
expect(cell.config.disabled).toBe(true);
|
|
1297
|
-
|
|
1298
|
-
// Revert
|
|
1299
|
-
actions.updateCellConfig({
|
|
1300
|
-
cellId: firstCellId,
|
|
1301
|
-
config: { disabled: false },
|
|
1302
|
-
});
|
|
1303
|
-
cell = cells[0];
|
|
1304
|
-
expect(cell.config.disabled).toBe(false);
|
|
1305
|
-
});
|
|
1306
|
-
|
|
1307
|
-
it("can run a stopped cell", () => {
|
|
1308
|
-
// Update code of first cell
|
|
1309
|
-
actions.updateCellCode({
|
|
1310
|
-
cellId: firstCellId,
|
|
1311
|
-
code: "mo.md('This has an ancestor that was stopped')",
|
|
1312
|
-
formattingChange: false,
|
|
1313
|
-
});
|
|
1314
|
-
|
|
1315
|
-
// Prepare for run
|
|
1316
|
-
actions.prepareForRun({
|
|
1317
|
-
cellId: firstCellId,
|
|
1318
|
-
});
|
|
1319
|
-
|
|
1320
|
-
// Receive queued messages
|
|
1321
|
-
actions.handleCellMessage({
|
|
1322
|
-
cell_id: firstCellId,
|
|
1323
|
-
output: undefined,
|
|
1324
|
-
console: null,
|
|
1325
|
-
status: "queued",
|
|
1326
|
-
stale_inputs: null,
|
|
1327
|
-
timestamp: new Date(10).getTime() as Seconds,
|
|
1328
|
-
});
|
|
1329
|
-
let cell = cells[0];
|
|
1330
|
-
expect(cell.status).toBe("queued");
|
|
1331
|
-
expect(cell.lastCodeRun).toBe(
|
|
1332
|
-
"mo.md('This has an ancestor that was stopped')",
|
|
1333
|
-
);
|
|
1334
|
-
expect(cell.edited).toBe(false);
|
|
1335
|
-
expect(cell.runElapsedTimeMs).toBe(null);
|
|
1336
|
-
expect(cell.runStartTimestamp).toBe(null);
|
|
1337
|
-
expect(cell).toMatchSnapshot("queued message received");
|
|
1338
|
-
|
|
1339
|
-
// Receive idle message
|
|
1340
|
-
actions.handleCellMessage({
|
|
1341
|
-
cell_id: firstCellId,
|
|
1342
|
-
output: undefined,
|
|
1343
|
-
console: null,
|
|
1344
|
-
status: "idle",
|
|
1345
|
-
stale_inputs: null,
|
|
1346
|
-
timestamp: new Date(20).getTime() as Seconds,
|
|
1347
|
-
});
|
|
1348
|
-
cell = cells[0];
|
|
1349
|
-
expect(cell).toMatchSnapshot("idle message received");
|
|
1350
|
-
|
|
1351
|
-
// Receive stop output
|
|
1352
|
-
actions.handleCellMessage({
|
|
1353
|
-
cell_id: firstCellId,
|
|
1354
|
-
output: {
|
|
1355
|
-
channel: "marimo-error",
|
|
1356
|
-
mimetype: "application/vnd.marimo+error",
|
|
1357
|
-
data: [
|
|
1358
|
-
{
|
|
1359
|
-
msg: "This cell wasn't run because an ancestor was stopped with `mo.stop`: ",
|
|
1360
|
-
raising_cell: "2",
|
|
1361
|
-
type: "ancestor-stopped",
|
|
1362
|
-
},
|
|
1363
|
-
],
|
|
1364
|
-
timestamp: new Date(20).getTime() as Seconds,
|
|
1365
|
-
},
|
|
1366
|
-
console: null,
|
|
1367
|
-
status: "idle",
|
|
1368
|
-
stale_inputs: null,
|
|
1369
|
-
timestamp: new Date(20).getTime() as Seconds,
|
|
1370
|
-
});
|
|
1371
|
-
cell = cells[0];
|
|
1372
|
-
expect(cell.status).toBe("idle");
|
|
1373
|
-
// oxlint-disable-next-line typescript/no-explicit-any no-unsafe-optional-chaining
|
|
1374
|
-
expect((cell.output?.data as any)[0].msg).toBe(
|
|
1375
|
-
"This cell wasn't run because an ancestor was stopped with `mo.stop`: ",
|
|
1376
|
-
);
|
|
1377
|
-
expect(cell.stopped).toBe(true);
|
|
1378
|
-
expect(cell).toMatchSnapshot("ancestor stopped");
|
|
1379
|
-
|
|
1380
|
-
// Receive queued message
|
|
1381
|
-
actions.handleCellMessage({
|
|
1382
|
-
cell_id: firstCellId,
|
|
1383
|
-
output: undefined,
|
|
1384
|
-
console: null,
|
|
1385
|
-
status: "queued",
|
|
1386
|
-
stale_inputs: null,
|
|
1387
|
-
timestamp: new Date(30).getTime() as Seconds,
|
|
1388
|
-
});
|
|
1389
|
-
cell = cells[0];
|
|
1390
|
-
expect(cell.status).toBe("queued");
|
|
1391
|
-
expect(cell.stopped).toBe(true);
|
|
1392
|
-
expect(cell).toMatchSnapshot("queued after stop");
|
|
1393
|
-
|
|
1394
|
-
// Receive running message
|
|
1395
|
-
actions.handleCellMessage({
|
|
1396
|
-
cell_id: firstCellId,
|
|
1397
|
-
output: undefined,
|
|
1398
|
-
console: null,
|
|
1399
|
-
status: "running",
|
|
1400
|
-
stale_inputs: null,
|
|
1401
|
-
timestamp: new Date(40).getTime() as Seconds,
|
|
1402
|
-
});
|
|
1403
|
-
cell = cells[0];
|
|
1404
|
-
expect(cell.status).toBe("running");
|
|
1405
|
-
expect(cell.stopped).toBe(false);
|
|
1406
|
-
expect(cell.output).toBe(null);
|
|
1407
|
-
expect(cell).toMatchSnapshot("running after stop");
|
|
1408
|
-
});
|
|
1409
|
-
|
|
1410
|
-
it("can initialize stdin", () => {
|
|
1411
|
-
const STDOUT: OutputMessage = {
|
|
1412
|
-
channel: "stdout",
|
|
1413
|
-
mimetype: "text/plain",
|
|
1414
|
-
data: "hello!",
|
|
1415
|
-
timestamp: 1,
|
|
1416
|
-
};
|
|
1417
|
-
const STD_IN_1: OutputMessage = {
|
|
1418
|
-
channel: "stdin",
|
|
1419
|
-
mimetype: "text/plain",
|
|
1420
|
-
data: "what is your name?",
|
|
1421
|
-
timestamp: 2,
|
|
1422
|
-
};
|
|
1423
|
-
const STD_IN_2: OutputMessage = {
|
|
1424
|
-
channel: "stdin",
|
|
1425
|
-
mimetype: "text/plain",
|
|
1426
|
-
data: "how old are you?",
|
|
1427
|
-
timestamp: 3,
|
|
1428
|
-
};
|
|
1429
|
-
|
|
1430
|
-
// Initial state
|
|
1431
|
-
let cell = cells[0];
|
|
1432
|
-
expect(cell.status).toBe("idle");
|
|
1433
|
-
expect(cell.consoleOutputs).toEqual([]);
|
|
1434
|
-
expect(cell).toMatchSnapshot("initial state");
|
|
1435
|
-
|
|
1436
|
-
// Prepare for run
|
|
1437
|
-
actions.prepareForRun({
|
|
1438
|
-
cellId: firstCellId,
|
|
1439
|
-
});
|
|
1440
|
-
cell = cells[0];
|
|
1441
|
-
expect(cell.status).toBe("queued");
|
|
1442
|
-
expect(cell.consoleOutputs).toEqual([]);
|
|
1443
|
-
expect(cell).toMatchSnapshot("prepared for run");
|
|
1444
|
-
|
|
1445
|
-
// Receive queued messages
|
|
1446
|
-
actions.handleCellMessage({
|
|
1447
|
-
cell_id: firstCellId,
|
|
1448
|
-
output: undefined,
|
|
1449
|
-
console: null,
|
|
1450
|
-
status: "queued",
|
|
1451
|
-
stale_inputs: null,
|
|
1452
|
-
timestamp: new Date(10).getTime() as Seconds,
|
|
1453
|
-
});
|
|
1454
|
-
cell = cells[0];
|
|
1455
|
-
expect(cell.status).toBe("queued");
|
|
1456
|
-
expect(cell).toMatchSnapshot("queued message received");
|
|
1457
|
-
|
|
1458
|
-
// Receive running messages
|
|
1459
|
-
actions.handleCellMessage({
|
|
1460
|
-
cell_id: firstCellId,
|
|
1461
|
-
output: undefined,
|
|
1462
|
-
console: null,
|
|
1463
|
-
status: "running",
|
|
1464
|
-
stale_inputs: null,
|
|
1465
|
-
timestamp: new Date(20).getTime() as Seconds,
|
|
1466
|
-
});
|
|
1467
|
-
cell = cells[0];
|
|
1468
|
-
expect(cell.status).toBe("running");
|
|
1469
|
-
expect(cell).toMatchSnapshot("running message received");
|
|
1470
|
-
|
|
1471
|
-
// Add console
|
|
1472
|
-
actions.handleCellMessage({
|
|
1473
|
-
cell_id: firstCellId,
|
|
1474
|
-
output: undefined,
|
|
1475
|
-
console: STDOUT,
|
|
1476
|
-
status: undefined,
|
|
1477
|
-
stale_inputs: null,
|
|
1478
|
-
timestamp: new Date(22).getTime() as Seconds,
|
|
1479
|
-
});
|
|
1480
|
-
cell = cells[0];
|
|
1481
|
-
expect(cell.status).toBe("running");
|
|
1482
|
-
expect(cell).toMatchSnapshot("stdout received");
|
|
1483
|
-
|
|
1484
|
-
cell = cells[0];
|
|
1485
|
-
expect(cell.consoleOutputs[0]).toMatchObject(STDOUT);
|
|
1486
|
-
expect(cell.status).toBe("running");
|
|
1487
|
-
expect(cell).toMatchSnapshot("stdout verified");
|
|
1488
|
-
|
|
1489
|
-
// Ask via stdin
|
|
1490
|
-
actions.handleCellMessage({
|
|
1491
|
-
cell_id: firstCellId,
|
|
1492
|
-
output: undefined,
|
|
1493
|
-
console: STD_IN_1,
|
|
1494
|
-
status: undefined,
|
|
1495
|
-
stale_inputs: null,
|
|
1496
|
-
timestamp: new Date(22).getTime() as Seconds,
|
|
1497
|
-
});
|
|
1498
|
-
cell = cells[0];
|
|
1499
|
-
expect(cell.consoleOutputs[0]).toMatchObject(STDOUT);
|
|
1500
|
-
expect(cell.consoleOutputs[1]).toMatchObject(STD_IN_1);
|
|
1501
|
-
expect(cell.status).toBe("running");
|
|
1502
|
-
expect(cell).toMatchSnapshot("stdin requested");
|
|
1503
|
-
|
|
1504
|
-
// Response to stdin
|
|
1505
|
-
actions.setStdinResponse({
|
|
1506
|
-
response: "Marimo!",
|
|
1507
|
-
cellId: firstCellId,
|
|
1508
|
-
outputIndex: 1,
|
|
1509
|
-
});
|
|
1510
|
-
cell = cells[0];
|
|
1511
|
-
expect(cell.consoleOutputs[1]).toMatchObject({
|
|
1512
|
-
...STD_IN_1,
|
|
1513
|
-
response: "Marimo!",
|
|
1514
|
-
});
|
|
1515
|
-
expect(cell.status).toBe("running");
|
|
1516
|
-
expect(cell).toMatchSnapshot("stdin answered");
|
|
1517
|
-
|
|
1518
|
-
// Ask via stdin, again
|
|
1519
|
-
actions.handleCellMessage({
|
|
1520
|
-
cell_id: firstCellId,
|
|
1521
|
-
output: undefined,
|
|
1522
|
-
console: STD_IN_2,
|
|
1523
|
-
status: undefined,
|
|
1524
|
-
stale_inputs: null,
|
|
1525
|
-
timestamp: new Date(22).getTime() as Seconds,
|
|
1526
|
-
});
|
|
1527
|
-
cell = cells[0];
|
|
1528
|
-
expect(cell.consoleOutputs).toMatchObject([
|
|
1529
|
-
STDOUT,
|
|
1530
|
-
{ ...STD_IN_1, response: "Marimo!" },
|
|
1531
|
-
STD_IN_2,
|
|
1532
|
-
]);
|
|
1533
|
-
expect(cell.status).toBe("running");
|
|
1534
|
-
expect(cell).toMatchSnapshot("second stdin requested");
|
|
1535
|
-
|
|
1536
|
-
// Interrupt, so we respond with ""
|
|
1537
|
-
actions.handleCellMessage({
|
|
1538
|
-
cell_id: firstCellId,
|
|
1539
|
-
output: {
|
|
1540
|
-
channel: "marimo-error",
|
|
1541
|
-
mimetype: "application/vnd.marimo+error",
|
|
1542
|
-
data: [{ type: "interruption" }],
|
|
1543
|
-
timestamp: 0,
|
|
1544
|
-
},
|
|
1545
|
-
console: null,
|
|
1546
|
-
status: "idle",
|
|
1547
|
-
stale_inputs: null,
|
|
1548
|
-
timestamp: new Date(61).getTime() as Seconds,
|
|
1549
|
-
});
|
|
1550
|
-
cell = cells[0];
|
|
1551
|
-
expect(cell.status).toBe("idle");
|
|
1552
|
-
expect(cell.consoleOutputs).toMatchObject([
|
|
1553
|
-
STDOUT,
|
|
1554
|
-
{ ...STD_IN_1, response: "Marimo!" },
|
|
1555
|
-
{ ...STD_IN_2, response: "" },
|
|
1556
|
-
]);
|
|
1557
|
-
});
|
|
1558
|
-
|
|
1559
|
-
it("resolves password prompts without retaining the response", () => {
|
|
1560
|
-
const prompt: OutputMessage = {
|
|
1561
|
-
channel: "stdin",
|
|
1562
|
-
mimetype: "text/password",
|
|
1563
|
-
data: "Password: ",
|
|
1564
|
-
timestamp: 1,
|
|
1565
|
-
};
|
|
1566
|
-
actions.handleCellMessage({
|
|
1567
|
-
cell_id: firstCellId,
|
|
1568
|
-
output: undefined,
|
|
1569
|
-
console: prompt,
|
|
1570
|
-
status: "running",
|
|
1571
|
-
stale_inputs: null,
|
|
1572
|
-
timestamp: 1 as Seconds,
|
|
1573
|
-
});
|
|
1574
|
-
|
|
1575
|
-
const secret = "getpass-regression-secret";
|
|
1576
|
-
actions.setStdinResponse({
|
|
1577
|
-
cellId: firstCellId,
|
|
1578
|
-
outputIndex: 0,
|
|
1579
|
-
response: secret,
|
|
1580
|
-
});
|
|
1581
|
-
|
|
1582
|
-
expect(cells[0].consoleOutputs).toEqual([
|
|
1583
|
-
{ ...prompt, id: 1, response: "" },
|
|
1584
|
-
]);
|
|
1585
|
-
expect(JSON.stringify(cells[0].consoleOutputs)).not.toContain(secret);
|
|
1586
|
-
});
|
|
1587
|
-
|
|
1588
|
-
it("does not crash when setStdinResponse has out-of-bounds outputIndex", () => {
|
|
1589
|
-
const STDOUT: OutputMessage = {
|
|
1590
|
-
channel: "stdout",
|
|
1591
|
-
mimetype: "text/plain",
|
|
1592
|
-
data: "hello!",
|
|
1593
|
-
timestamp: 1,
|
|
1594
|
-
};
|
|
1595
|
-
|
|
1596
|
-
// Set the cell to running with a console output
|
|
1597
|
-
actions.prepareForRun({ cellId: firstCellId });
|
|
1598
|
-
actions.handleCellMessage({
|
|
1599
|
-
cell_id: firstCellId,
|
|
1600
|
-
output: undefined,
|
|
1601
|
-
console: null,
|
|
1602
|
-
status: "running",
|
|
1603
|
-
stale_inputs: null,
|
|
1604
|
-
timestamp: new Date(20).getTime() as Seconds,
|
|
1605
|
-
});
|
|
1606
|
-
actions.handleCellMessage({
|
|
1607
|
-
cell_id: firstCellId,
|
|
1608
|
-
output: undefined,
|
|
1609
|
-
console: STDOUT,
|
|
1610
|
-
status: undefined,
|
|
1611
|
-
stale_inputs: null,
|
|
1612
|
-
timestamp: new Date(22).getTime() as Seconds,
|
|
1613
|
-
});
|
|
1614
|
-
|
|
1615
|
-
// Try to set stdin response with an out-of-bounds index
|
|
1616
|
-
// This should not crash - it should return state unchanged
|
|
1617
|
-
actions.setStdinResponse({
|
|
1618
|
-
response: "test",
|
|
1619
|
-
cellId: firstCellId,
|
|
1620
|
-
outputIndex: 999,
|
|
1621
|
-
});
|
|
1622
|
-
|
|
1623
|
-
// Cell state should be unchanged
|
|
1624
|
-
const cell = cells[0];
|
|
1625
|
-
expect(cell.consoleOutputs).toHaveLength(1);
|
|
1626
|
-
expect(cell.consoleOutputs[0]).toMatchObject(STDOUT);
|
|
1627
|
-
});
|
|
1628
|
-
|
|
1629
|
-
it("can receive console when the cell is idle and will clear when starts again", () => {
|
|
1630
|
-
const OLD_STDOUT: OutputMessage = {
|
|
1631
|
-
channel: "stdout",
|
|
1632
|
-
mimetype: "text/plain",
|
|
1633
|
-
data: "hello!",
|
|
1634
|
-
timestamp: 1,
|
|
1635
|
-
};
|
|
1636
|
-
const STDOUT: OutputMessage = {
|
|
1637
|
-
channel: "stdin",
|
|
1638
|
-
mimetype: "text/plain",
|
|
1639
|
-
data: "hello again!",
|
|
1640
|
-
timestamp: 2,
|
|
1641
|
-
};
|
|
1642
|
-
|
|
1643
|
-
// Initial state
|
|
1644
|
-
let cell = cells[0];
|
|
1645
|
-
expect(cell.status).toBe("idle");
|
|
1646
|
-
expect(cell.consoleOutputs).toEqual([]);
|
|
1647
|
-
expect(cell).toMatchSnapshot("initial state");
|
|
1648
|
-
|
|
1649
|
-
// Add console
|
|
1650
|
-
actions.handleCellMessage({
|
|
1651
|
-
cell_id: firstCellId,
|
|
1652
|
-
output: undefined,
|
|
1653
|
-
console: [OLD_STDOUT],
|
|
1654
|
-
status: undefined,
|
|
1655
|
-
stale_inputs: null,
|
|
1656
|
-
timestamp: new Date(1).getTime() as Seconds,
|
|
1657
|
-
});
|
|
1658
|
-
|
|
1659
|
-
// Prepare for run
|
|
1660
|
-
actions.prepareForRun({
|
|
1661
|
-
cellId: firstCellId,
|
|
1662
|
-
});
|
|
1663
|
-
cell = cells[0];
|
|
1664
|
-
expect(cell.status).toBe("queued");
|
|
1665
|
-
expect(cell.consoleOutputs).toMatchObject([OLD_STDOUT]); // Old stays there until it starts running
|
|
1666
|
-
expect(cell).toMatchSnapshot("prepared for run");
|
|
1667
|
-
|
|
1668
|
-
// Receive queued messages
|
|
1669
|
-
actions.handleCellMessage({
|
|
1670
|
-
cell_id: firstCellId,
|
|
1671
|
-
output: undefined,
|
|
1672
|
-
console: null,
|
|
1673
|
-
status: "queued",
|
|
1674
|
-
stale_inputs: null,
|
|
1675
|
-
timestamp: new Date(10).getTime() as Seconds,
|
|
1676
|
-
});
|
|
1677
|
-
cell = cells[0];
|
|
1678
|
-
expect(cell.status).toBe("queued");
|
|
1679
|
-
expect(cell.consoleOutputs).toMatchObject([OLD_STDOUT]); // Old stays there until it starts running
|
|
1680
|
-
expect(cell).toMatchSnapshot("queued message received");
|
|
1681
|
-
|
|
1682
|
-
// Receive running messages
|
|
1683
|
-
actions.handleCellMessage({
|
|
1684
|
-
cell_id: firstCellId,
|
|
1685
|
-
output: undefined,
|
|
1686
|
-
console: [], // Backend sends an empty array to clearu
|
|
1687
|
-
status: "running",
|
|
1688
|
-
stale_inputs: null,
|
|
1689
|
-
timestamp: new Date(20).getTime() as Seconds,
|
|
1690
|
-
});
|
|
1691
|
-
cell = cells[0];
|
|
1692
|
-
expect(cell.status).toBe("running");
|
|
1693
|
-
expect(cell.consoleOutputs).toMatchObject([]);
|
|
1694
|
-
expect(cell).toMatchSnapshot("console cleared while running");
|
|
1695
|
-
|
|
1696
|
-
// Add console
|
|
1697
|
-
actions.handleCellMessage({
|
|
1698
|
-
cell_id: firstCellId,
|
|
1699
|
-
output: undefined,
|
|
1700
|
-
console: [STDOUT],
|
|
1701
|
-
status: "idle",
|
|
1702
|
-
stale_inputs: null,
|
|
1703
|
-
timestamp: new Date(22).getTime() as Seconds,
|
|
1704
|
-
});
|
|
1705
|
-
cell = cells[0];
|
|
1706
|
-
expect(cell.consoleOutputs).toMatchObject([STDOUT]);
|
|
1707
|
-
expect(cell.status).toBe("idle");
|
|
1708
|
-
expect(cell).toMatchSnapshot("console received while idle");
|
|
1709
|
-
});
|
|
1710
|
-
|
|
1711
|
-
it("can send a cell to the top", () => {
|
|
1712
|
-
actions.createNewCell({ cellId: firstCellId, before: false });
|
|
1713
|
-
actions.createNewCell({ cellId: cellId("1"), before: false });
|
|
1714
|
-
actions.sendToTop({ cellId: cellId("2") });
|
|
1715
|
-
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
1716
|
-
"
|
|
1717
|
-
[2] ''
|
|
1718
|
-
|
|
1719
|
-
[0] ''
|
|
1720
|
-
|
|
1721
|
-
[1] ''
|
|
1722
|
-
"
|
|
1723
|
-
`);
|
|
1724
|
-
});
|
|
1725
|
-
|
|
1726
|
-
it("can send a cell to the bottom", () => {
|
|
1727
|
-
actions.createNewCell({ cellId: firstCellId, before: false });
|
|
1728
|
-
actions.createNewCell({ cellId: cellId("1"), before: false });
|
|
1729
|
-
actions.sendToBottom({ cellId: firstCellId });
|
|
1730
|
-
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
1731
|
-
"
|
|
1732
|
-
[1] ''
|
|
1733
|
-
|
|
1734
|
-
[2] ''
|
|
1735
|
-
|
|
1736
|
-
[0] ''
|
|
1737
|
-
"
|
|
1738
|
-
`);
|
|
1739
|
-
});
|
|
1740
|
-
|
|
1741
|
-
it("can focus cells", () => {
|
|
1742
|
-
actions.createNewCell({ cellId: firstCellId, before: false });
|
|
1743
|
-
actions.createNewCell({ cellId: cellId("1"), before: false });
|
|
1744
|
-
|
|
1745
|
-
actions.focusCell({ cellId: cellId("1"), where: "before" });
|
|
1746
|
-
expect(focusAndScrollCellIntoView).toHaveBeenCalledWith(
|
|
1747
|
-
expect.objectContaining({
|
|
1748
|
-
cellId: cellId("0"),
|
|
1749
|
-
}),
|
|
1750
|
-
);
|
|
1751
|
-
|
|
1752
|
-
actions.focusTopCell();
|
|
1753
|
-
expect(scrollToTop).toHaveBeenCalled();
|
|
1754
|
-
|
|
1755
|
-
actions.focusBottomCell();
|
|
1756
|
-
expect(scrollToBottom).toHaveBeenCalled();
|
|
1757
|
-
});
|
|
1758
|
-
|
|
1759
|
-
it("can update cell name", () => {
|
|
1760
|
-
actions.updateCellName({ cellId: firstCellId, name: "Test Cell" });
|
|
1761
|
-
expect(state.cellData[firstCellId].name).toBe("Test Cell");
|
|
1762
|
-
});
|
|
1763
|
-
|
|
1764
|
-
it("can set cell IDs and codes", () => {
|
|
1765
|
-
const newIds = [cellId("3"), cellId("4"), cellId("5")];
|
|
1766
|
-
const newCodes = ["code1", "code2", "code3"];
|
|
1767
|
-
|
|
1768
|
-
actions.setCellIds({ cellIds: newIds });
|
|
1769
|
-
expect(state.cellIds.atOrThrow(FIRST_COLUMN).topLevelIds).toEqual(newIds);
|
|
1770
|
-
|
|
1771
|
-
// When codeIsStale is false, lastCodeRun should match code
|
|
1772
|
-
actions.setCellCodes({
|
|
1773
|
-
codes: newCodes,
|
|
1774
|
-
ids: newIds,
|
|
1775
|
-
codeIsStale: false,
|
|
1776
|
-
});
|
|
1777
|
-
newIds.forEach((id, index) => {
|
|
1778
|
-
expect(state.cellData[id].code).toBe(newCodes[index]);
|
|
1779
|
-
expect(state.cellData[id].lastCodeRun).toBe(newCodes[index]);
|
|
1780
|
-
expect(state.cellData[id].edited).toBe(false);
|
|
1781
|
-
});
|
|
1782
|
-
|
|
1783
|
-
// When codeIsStale is true, lastCodeRun should not change
|
|
1784
|
-
const staleCodes = ["stale1", "stale2", "stale3"];
|
|
1785
|
-
actions.setCellCodes({
|
|
1786
|
-
codes: staleCodes,
|
|
1787
|
-
ids: newIds,
|
|
1788
|
-
codeIsStale: true,
|
|
1789
|
-
});
|
|
1790
|
-
newIds.forEach((id, index) => {
|
|
1791
|
-
expect(state.cellData[id].code).toBe(staleCodes[index]);
|
|
1792
|
-
expect(state.cellData[id].lastCodeRun).toBe(newCodes[index]);
|
|
1793
|
-
expect(state.cellData[id].edited).toBe(true);
|
|
1794
|
-
});
|
|
1795
|
-
});
|
|
1796
|
-
|
|
1797
|
-
it("can can add a new cell with/without stale code", () => {
|
|
1798
|
-
actions.setCellCodes({
|
|
1799
|
-
codes: ["new code"],
|
|
1800
|
-
ids: [cellId("2")],
|
|
1801
|
-
codeIsStale: false,
|
|
1802
|
-
});
|
|
1803
|
-
|
|
1804
|
-
expect(state.cellData[cellId("2")].code).toBe("new code");
|
|
1805
|
-
expect(state.cellData[cellId("2")].edited).toBe(false);
|
|
1806
|
-
expect(state.cellData[cellId("2")].lastCodeRun).toBe("new code");
|
|
1807
|
-
|
|
1808
|
-
actions.setCellCodes({
|
|
1809
|
-
codes: ["new code 2"],
|
|
1810
|
-
ids: [cellId("9")],
|
|
1811
|
-
codeIsStale: true,
|
|
1812
|
-
});
|
|
1813
|
-
|
|
1814
|
-
expect(state.cellData[cellId("9")].code).toBe("new code 2");
|
|
1815
|
-
expect(state.cellData[cellId("9")].edited).toBe(true);
|
|
1816
|
-
expect(state.cellData[cellId("9")].lastCodeRun).toBe(null);
|
|
1817
|
-
});
|
|
1818
|
-
|
|
1819
|
-
it("can partial update cell codes", () => {
|
|
1820
|
-
actions.createNewCell({ cellId: firstCellId, before: false });
|
|
1821
|
-
actions.createNewCell({ cellId: cellId("1"), before: false });
|
|
1822
|
-
|
|
1823
|
-
expect(state.cellIds.inOrderIds).toEqual([
|
|
1824
|
-
cellId("0"),
|
|
1825
|
-
cellId("1"),
|
|
1826
|
-
cellId("2"),
|
|
1827
|
-
]);
|
|
1828
|
-
expect(state.cellData[cellId("0")].code).toBe("");
|
|
1829
|
-
expect(state.cellData[cellId("1")].code).toBe("");
|
|
1830
|
-
expect(state.cellData[cellId("2")].code).toBe("");
|
|
1831
|
-
|
|
1832
|
-
// Update cell 1
|
|
1833
|
-
actions.setCellCodes({
|
|
1834
|
-
codes: ["new code 2"],
|
|
1835
|
-
ids: [cellId("1")],
|
|
1836
|
-
codeIsStale: false,
|
|
1837
|
-
});
|
|
1838
|
-
|
|
1839
|
-
expect(state.cellIds.inOrderIds).toEqual([
|
|
1840
|
-
cellId("0"),
|
|
1841
|
-
cellId("1"),
|
|
1842
|
-
cellId("2"),
|
|
1843
|
-
]);
|
|
1844
|
-
expect(state.cellData[cellId("0")].code).toBe("");
|
|
1845
|
-
expect(state.cellData[cellId("1")].code).toBe("new code 2");
|
|
1846
|
-
expect(state.cellData[cellId("1")].edited).toBe(false);
|
|
1847
|
-
expect(state.cellData[cellId("2")].code).toBe("");
|
|
1848
|
-
});
|
|
1849
|
-
|
|
1850
|
-
it("can set cell codes with new cell ids, while preserving the old cell data", () => {
|
|
1851
|
-
actions.setCellCodes({
|
|
1852
|
-
codes: ["code1", "code2", "code3"],
|
|
1853
|
-
ids: [cellId("3"), cellId("4"), cellId("5")],
|
|
1854
|
-
codeIsStale: false,
|
|
1855
|
-
});
|
|
1856
|
-
expect(state.cellData[cellId("3")].code).toBe("code1");
|
|
1857
|
-
expect(state.cellData[cellId("4")].code).toBe("code2");
|
|
1858
|
-
expect(state.cellData[cellId("5")].code).toBe("code3");
|
|
1859
|
-
|
|
1860
|
-
// Update with some new cell ids and some old cell ids
|
|
1861
|
-
actions.setCellIds({
|
|
1862
|
-
cellIds: [cellId("1"), cellId("2"), cellId("3"), cellId("4")],
|
|
1863
|
-
});
|
|
1864
|
-
actions.setCellCodes({
|
|
1865
|
-
codes: ["new1", "new2", "code1", "code2"],
|
|
1866
|
-
ids: [cellId("1"), cellId("2"), cellId("3"), cellId("4")],
|
|
1867
|
-
codeIsStale: false,
|
|
1868
|
-
});
|
|
1869
|
-
expect(state.cellData[cellId("1")].code).toBe("new1");
|
|
1870
|
-
expect(state.cellData[cellId("2")].code).toBe("new2");
|
|
1871
|
-
expect(state.cellData[cellId("3")].code).toBe("code1");
|
|
1872
|
-
expect(state.cellData[cellId("4")].code).toBe("code2");
|
|
1873
|
-
expect(state.cellIds.inOrderIds).toEqual([
|
|
1874
|
-
cellId("1"),
|
|
1875
|
-
cellId("2"),
|
|
1876
|
-
cellId("3"),
|
|
1877
|
-
cellId("4"),
|
|
1878
|
-
]);
|
|
1879
|
-
// Cell 5 data is preserved (possibly used for tracing), but it's not in the cellIds
|
|
1880
|
-
expect(state.cellData[cellId("5")]).not.toBeUndefined();
|
|
1881
|
-
});
|
|
1882
|
-
|
|
1883
|
-
it("can set cell codes with names and configs", () => {
|
|
1884
|
-
const newIds = [cellId("3"), cellId("4")];
|
|
1885
|
-
actions.setCellIds({ cellIds: newIds });
|
|
1886
|
-
actions.setCellCodes({
|
|
1887
|
-
codes: ["code1", "code2"],
|
|
1888
|
-
ids: newIds,
|
|
1889
|
-
codeIsStale: false,
|
|
1890
|
-
names: ["setup_cell", "analysis"],
|
|
1891
|
-
configs: [
|
|
1892
|
-
{ hide_code: true, disabled: false, column: null },
|
|
1893
|
-
{ hide_code: false, disabled: true, column: null },
|
|
1894
|
-
],
|
|
1895
|
-
});
|
|
1896
|
-
|
|
1897
|
-
expect(state.cellData[cellId("3")].name).toBe("setup_cell");
|
|
1898
|
-
expect(state.cellData[cellId("3")].config.hide_code).toBe(true);
|
|
1899
|
-
expect(state.cellData[cellId("3")].config.disabled).toBe(false);
|
|
1900
|
-
|
|
1901
|
-
expect(state.cellData[cellId("4")].name).toBe("analysis");
|
|
1902
|
-
expect(state.cellData[cellId("4")].config.hide_code).toBe(false);
|
|
1903
|
-
expect(state.cellData[cellId("4")].config.disabled).toBe(true);
|
|
1904
|
-
});
|
|
1905
|
-
|
|
1906
|
-
it("can set cell codes without names/configs (backward compat)", () => {
|
|
1907
|
-
const newIds = [cellId("3")];
|
|
1908
|
-
actions.setCellIds({ cellIds: newIds });
|
|
1909
|
-
actions.setCellCodes({
|
|
1910
|
-
codes: ["code1"],
|
|
1911
|
-
ids: newIds,
|
|
1912
|
-
codeIsStale: false,
|
|
1913
|
-
});
|
|
1914
|
-
|
|
1915
|
-
// Should use defaults when names/configs not provided
|
|
1916
|
-
expect(state.cellData[cellId("3")].code).toBe("code1");
|
|
1917
|
-
expect(state.cellData[cellId("3")].config.hide_code).toBe(false);
|
|
1918
|
-
expect(state.cellData[cellId("3")].config.disabled).toBe(false);
|
|
1919
|
-
});
|
|
1920
|
-
|
|
1921
|
-
it("can update names and configs on existing cells via setCellCodes", () => {
|
|
1922
|
-
// Set initial state
|
|
1923
|
-
actions.setCellCodes({
|
|
1924
|
-
codes: ["x = 1"],
|
|
1925
|
-
ids: [firstCellId],
|
|
1926
|
-
codeIsStale: false,
|
|
1927
|
-
names: ["old_name"],
|
|
1928
|
-
configs: [{ hide_code: false, disabled: false, column: null }],
|
|
1929
|
-
});
|
|
1930
|
-
expect(state.cellData[firstCellId].name).toBe("old_name");
|
|
1931
|
-
expect(state.cellData[firstCellId].config.hide_code).toBe(false);
|
|
1932
|
-
|
|
1933
|
-
// Update with new name and config (same code)
|
|
1934
|
-
actions.setCellCodes({
|
|
1935
|
-
codes: ["x = 1"],
|
|
1936
|
-
ids: [firstCellId],
|
|
1937
|
-
codeIsStale: true,
|
|
1938
|
-
names: ["new_name"],
|
|
1939
|
-
configs: [{ hide_code: true, disabled: false, column: null }],
|
|
1940
|
-
});
|
|
1941
|
-
expect(state.cellData[firstCellId].name).toBe("new_name");
|
|
1942
|
-
expect(state.cellData[firstCellId].config.hide_code).toBe(true);
|
|
1943
|
-
});
|
|
1944
|
-
|
|
1945
|
-
it("can fold and unfold all cells", () => {
|
|
1946
|
-
actions.foldAll();
|
|
1947
|
-
expect(foldAllBulk).toHaveBeenCalled();
|
|
1948
|
-
|
|
1949
|
-
actions.unfoldAll();
|
|
1950
|
-
expect(unfoldAllBulk).toHaveBeenCalled();
|
|
1951
|
-
});
|
|
1952
|
-
|
|
1953
|
-
it("can clear logs", () => {
|
|
1954
|
-
state.cellLogs = [
|
|
1955
|
-
{
|
|
1956
|
-
level: "stderr",
|
|
1957
|
-
message: "log1",
|
|
1958
|
-
timestamp: 0,
|
|
1959
|
-
source: { type: "cell", cellId: firstCellId },
|
|
1960
|
-
},
|
|
1961
|
-
{
|
|
1962
|
-
level: "stderr",
|
|
1963
|
-
message: "log1",
|
|
1964
|
-
timestamp: 0,
|
|
1965
|
-
source: { type: "cell", cellId: firstCellId },
|
|
1966
|
-
},
|
|
1967
|
-
];
|
|
1968
|
-
actions.clearLogs();
|
|
1969
|
-
expect(state.cellLogs).toEqual([]);
|
|
1970
|
-
});
|
|
1971
|
-
|
|
1972
|
-
it("can collapse and expand cells", () => {
|
|
1973
|
-
actions.createNewCell({ cellId: firstCellId, before: false });
|
|
1974
|
-
actions.createNewCell({
|
|
1975
|
-
cellId: cellId("1"),
|
|
1976
|
-
before: false,
|
|
1977
|
-
code: "# Header",
|
|
1978
|
-
});
|
|
1979
|
-
actions.createNewCell({
|
|
1980
|
-
cellId: cellId("2"),
|
|
1981
|
-
before: false,
|
|
1982
|
-
code: "## Subheader",
|
|
1983
|
-
});
|
|
1984
|
-
|
|
1985
|
-
const id = state.cellIds.atOrThrow(FIRST_COLUMN).atOrThrow(1);
|
|
1986
|
-
state.cellRuntime[id] = {
|
|
1987
|
-
...state.cellRuntime[id],
|
|
1988
|
-
outline: {
|
|
1989
|
-
items: [{ name: "Header", level: 1, by: { id: "header" } }],
|
|
1990
|
-
},
|
|
1991
|
-
};
|
|
1992
|
-
|
|
1993
|
-
actions.collapseCell({ cellId: id });
|
|
1994
|
-
expect(state.cellIds.atOrThrow(FIRST_COLUMN).isCollapsed(id)).toBe(true);
|
|
1995
|
-
|
|
1996
|
-
actions.expandCell({ cellId: id });
|
|
1997
|
-
expect(state.cellIds.atOrThrow(FIRST_COLUMN).isCollapsed(id)).toBe(false);
|
|
1998
|
-
});
|
|
1999
|
-
|
|
2000
|
-
it("can collapse and expand all cells in multiple columns", () => {
|
|
2001
|
-
actions.createNewCell({ cellId: firstCellId, before: false });
|
|
2002
|
-
actions.createNewCell({
|
|
2003
|
-
cellId: cellId("1"),
|
|
2004
|
-
before: false,
|
|
2005
|
-
code: "# First Column Header",
|
|
2006
|
-
});
|
|
2007
|
-
actions.createNewCell({
|
|
2008
|
-
cellId: cellId("2"),
|
|
2009
|
-
before: false,
|
|
2010
|
-
code: "## First Column Subheader",
|
|
2011
|
-
});
|
|
2012
|
-
|
|
2013
|
-
actions.addColumnBreakpoint({ cellId: cellId("2") });
|
|
2014
|
-
|
|
2015
|
-
actions.createNewCell({
|
|
2016
|
-
cellId: cellId("3"),
|
|
2017
|
-
before: false,
|
|
2018
|
-
code: "# Second Column Header",
|
|
2019
|
-
});
|
|
2020
|
-
actions.createNewCell({
|
|
2021
|
-
cellId: cellId("4"),
|
|
2022
|
-
before: false,
|
|
2023
|
-
code: "## Second Column Subheader",
|
|
2024
|
-
});
|
|
2025
|
-
|
|
2026
|
-
const firstColumnHeaderId = state.cellIds
|
|
2027
|
-
.atOrThrow(FIRST_COLUMN)
|
|
2028
|
-
.atOrThrow(1);
|
|
2029
|
-
state.cellRuntime[firstColumnHeaderId] = {
|
|
2030
|
-
...state.cellRuntime[firstColumnHeaderId],
|
|
2031
|
-
outline: {
|
|
2032
|
-
items: [
|
|
2033
|
-
{ name: "First Column Header", level: 1, by: { id: "header" } },
|
|
2034
|
-
],
|
|
2035
|
-
},
|
|
2036
|
-
};
|
|
2037
|
-
|
|
2038
|
-
const secondColumnHeaderId = state.cellIds
|
|
2039
|
-
.atOrThrow(SECOND_COLUMN)
|
|
2040
|
-
.atOrThrow(0);
|
|
2041
|
-
state.cellRuntime[secondColumnHeaderId] = {
|
|
2042
|
-
...state.cellRuntime[secondColumnHeaderId],
|
|
2043
|
-
outline: {
|
|
2044
|
-
items: [
|
|
2045
|
-
{ name: "Second Column Header", level: 1, by: { id: "header" } },
|
|
2046
|
-
],
|
|
2047
|
-
},
|
|
2048
|
-
};
|
|
2049
|
-
|
|
2050
|
-
actions.collapseAllCells();
|
|
2051
|
-
expect(
|
|
2052
|
-
state.cellIds.atOrThrow(FIRST_COLUMN).isCollapsed(firstColumnHeaderId),
|
|
2053
|
-
).toBe(true);
|
|
2054
|
-
expect(
|
|
2055
|
-
state.cellIds.atOrThrow(SECOND_COLUMN).isCollapsed(secondColumnHeaderId),
|
|
2056
|
-
).toBe(true);
|
|
2057
|
-
|
|
2058
|
-
actions.expandAllCells();
|
|
2059
|
-
expect(
|
|
2060
|
-
state.cellIds.atOrThrow(FIRST_COLUMN).isCollapsed(firstColumnHeaderId),
|
|
2061
|
-
).toBe(false);
|
|
2062
|
-
expect(
|
|
2063
|
-
state.cellIds.atOrThrow(SECOND_COLUMN).isCollapsed(secondColumnHeaderId),
|
|
2064
|
-
).toBe(false);
|
|
2065
|
-
});
|
|
2066
|
-
|
|
2067
|
-
it("can collapse and expand nested cells in one call", () => {
|
|
2068
|
-
actions.createNewCell({ cellId: firstCellId, before: false });
|
|
2069
|
-
actions.createNewCell({
|
|
2070
|
-
cellId: cellId("1"),
|
|
2071
|
-
before: false,
|
|
2072
|
-
code: "# Header",
|
|
2073
|
-
});
|
|
2074
|
-
actions.createNewCell({
|
|
2075
|
-
cellId: cellId("2"),
|
|
2076
|
-
before: false,
|
|
2077
|
-
code: "## Subheader",
|
|
2078
|
-
});
|
|
2079
|
-
actions.createNewCell({
|
|
2080
|
-
cellId: cellId("3"),
|
|
2081
|
-
before: false,
|
|
2082
|
-
code: "### Subsubheader",
|
|
2083
|
-
});
|
|
2084
|
-
|
|
2085
|
-
const headerId = state.cellIds.atOrThrow(FIRST_COLUMN).atOrThrow(1);
|
|
2086
|
-
state.cellRuntime[headerId] = {
|
|
2087
|
-
...state.cellRuntime[headerId],
|
|
2088
|
-
outline: {
|
|
2089
|
-
items: [{ name: "Header", level: 1, by: { id: "header" } }],
|
|
2090
|
-
},
|
|
2091
|
-
};
|
|
2092
|
-
|
|
2093
|
-
const subheaderId = state.cellIds.atOrThrow(FIRST_COLUMN).atOrThrow(2);
|
|
2094
|
-
state.cellRuntime[subheaderId] = {
|
|
2095
|
-
...state.cellRuntime[subheaderId],
|
|
2096
|
-
outline: {
|
|
2097
|
-
items: [{ name: "Subheader", level: 2, by: { id: "subheader" } }],
|
|
2098
|
-
},
|
|
2099
|
-
};
|
|
2100
|
-
|
|
2101
|
-
// Check if both the parent and child are collapsed
|
|
2102
|
-
actions.collapseAllCells();
|
|
2103
|
-
expect(state.cellIds.atOrThrow(FIRST_COLUMN).isCollapsed(headerId)).toBe(
|
|
2104
|
-
true,
|
|
2105
|
-
);
|
|
2106
|
-
actions.expandCell({ cellId: headerId });
|
|
2107
|
-
expect(state.cellIds.atOrThrow(FIRST_COLUMN).isCollapsed(subheaderId)).toBe(
|
|
2108
|
-
true,
|
|
2109
|
-
);
|
|
2110
|
-
actions.collapseCell({ cellId: headerId });
|
|
2111
|
-
|
|
2112
|
-
// Check if both the parent and child are expanded
|
|
2113
|
-
actions.expandAllCells();
|
|
2114
|
-
expect(state.cellIds.atOrThrow(FIRST_COLUMN).isCollapsed(headerId)).toBe(
|
|
2115
|
-
false,
|
|
2116
|
-
);
|
|
2117
|
-
expect(state.cellIds.atOrThrow(FIRST_COLUMN).isCollapsed(subheaderId)).toBe(
|
|
2118
|
-
false,
|
|
2119
|
-
);
|
|
2120
|
-
});
|
|
2121
|
-
|
|
2122
|
-
it("can collapse all cells when nested heading ranges end at the same cell", () => {
|
|
2123
|
-
actions.createNewCell({ cellId: firstCellId, before: false });
|
|
2124
|
-
actions.createNewCell({
|
|
2125
|
-
cellId: cellId("1"),
|
|
2126
|
-
before: false,
|
|
2127
|
-
code: "# Header",
|
|
2128
|
-
});
|
|
2129
|
-
actions.createNewCell({
|
|
2130
|
-
cellId: cellId("2"),
|
|
2131
|
-
before: false,
|
|
2132
|
-
code: "## Subheader",
|
|
2133
|
-
});
|
|
2134
|
-
actions.createNewCell({
|
|
2135
|
-
cellId: cellId("3"),
|
|
2136
|
-
before: false,
|
|
2137
|
-
code: "### Subsubheader",
|
|
2138
|
-
});
|
|
2139
|
-
|
|
2140
|
-
const headerId = state.cellIds.atOrThrow(FIRST_COLUMN).atOrThrow(1);
|
|
2141
|
-
state.cellRuntime[headerId] = {
|
|
2142
|
-
...state.cellRuntime[headerId],
|
|
2143
|
-
outline: {
|
|
2144
|
-
items: [{ name: "Header", level: 1, by: { id: "header" } }],
|
|
2145
|
-
},
|
|
2146
|
-
};
|
|
2147
|
-
|
|
2148
|
-
const subheaderId = state.cellIds.atOrThrow(FIRST_COLUMN).atOrThrow(2);
|
|
2149
|
-
state.cellRuntime[subheaderId] = {
|
|
2150
|
-
...state.cellRuntime[subheaderId],
|
|
2151
|
-
outline: {
|
|
2152
|
-
items: [{ name: "Subheader", level: 2, by: { id: "subheader" } }],
|
|
2153
|
-
},
|
|
2154
|
-
};
|
|
2155
|
-
|
|
2156
|
-
const subsubheaderId = state.cellIds.atOrThrow(FIRST_COLUMN).atOrThrow(3);
|
|
2157
|
-
state.cellRuntime[subsubheaderId] = {
|
|
2158
|
-
...state.cellRuntime[subsubheaderId],
|
|
2159
|
-
outline: {
|
|
2160
|
-
items: [{ name: "Subsubheader", level: 3, by: { id: "subsubheader" } }],
|
|
2161
|
-
},
|
|
2162
|
-
};
|
|
2163
|
-
|
|
2164
|
-
// The header, subheader and subsubheader ranges all end at the last
|
|
2165
|
-
// cell. Collapsing all used to throw "Node ... not found in tree" and
|
|
2166
|
-
// leave the whole notebook unchanged.
|
|
2167
|
-
actions.collapseAllCells();
|
|
2168
|
-
expect(state.cellIds.atOrThrow(FIRST_COLUMN).isCollapsed(headerId)).toBe(
|
|
2169
|
-
true,
|
|
2170
|
-
);
|
|
2171
|
-
expect(state.cellIds.atOrThrow(FIRST_COLUMN).topLevelIds).toEqual([
|
|
2172
|
-
firstCellId,
|
|
2173
|
-
headerId,
|
|
2174
|
-
]);
|
|
2175
|
-
|
|
2176
|
-
// Each level is nested under its parent, collapsed
|
|
2177
|
-
actions.expandCell({ cellId: headerId });
|
|
2178
|
-
expect(state.cellIds.atOrThrow(FIRST_COLUMN).isCollapsed(subheaderId)).toBe(
|
|
2179
|
-
true,
|
|
2180
|
-
);
|
|
2181
|
-
actions.expandCell({ cellId: subheaderId });
|
|
2182
|
-
expect(
|
|
2183
|
-
state.cellIds.atOrThrow(FIRST_COLUMN).isCollapsed(subsubheaderId),
|
|
2184
|
-
).toBe(true);
|
|
2185
|
-
});
|
|
2186
|
-
|
|
2187
|
-
it("can collapse all cells when a deep chain is followed by a later section", () => {
|
|
2188
|
-
actions.createNewCell({ cellId: firstCellId, before: false });
|
|
2189
|
-
actions.createNewCell({
|
|
2190
|
-
cellId: cellId("1"),
|
|
2191
|
-
before: false,
|
|
2192
|
-
code: "# Header",
|
|
2193
|
-
});
|
|
2194
|
-
actions.createNewCell({
|
|
2195
|
-
cellId: cellId("2"),
|
|
2196
|
-
before: false,
|
|
2197
|
-
code: "## Section A",
|
|
2198
|
-
});
|
|
2199
|
-
actions.createNewCell({
|
|
2200
|
-
cellId: cellId("3"),
|
|
2201
|
-
before: false,
|
|
2202
|
-
code: "### Sub of A",
|
|
2203
|
-
});
|
|
2204
|
-
actions.createNewCell({
|
|
2205
|
-
cellId: cellId("4"),
|
|
2206
|
-
before: false,
|
|
2207
|
-
code: "## Section B",
|
|
2208
|
-
});
|
|
2209
|
-
|
|
2210
|
-
const headerId = state.cellIds.atOrThrow(FIRST_COLUMN).atOrThrow(1);
|
|
2211
|
-
state.cellRuntime[headerId] = {
|
|
2212
|
-
...state.cellRuntime[headerId],
|
|
2213
|
-
outline: {
|
|
2214
|
-
items: [{ name: "Header", level: 1, by: { id: "header" } }],
|
|
2215
|
-
},
|
|
2216
|
-
};
|
|
2217
|
-
|
|
2218
|
-
const sectionAId = state.cellIds.atOrThrow(FIRST_COLUMN).atOrThrow(2);
|
|
2219
|
-
state.cellRuntime[sectionAId] = {
|
|
2220
|
-
...state.cellRuntime[sectionAId],
|
|
2221
|
-
outline: {
|
|
2222
|
-
items: [{ name: "Section A", level: 2, by: { id: "section-a" } }],
|
|
2223
|
-
},
|
|
2224
|
-
};
|
|
2225
|
-
|
|
2226
|
-
const subsectionId = state.cellIds.atOrThrow(FIRST_COLUMN).atOrThrow(3);
|
|
2227
|
-
state.cellRuntime[subsectionId] = {
|
|
2228
|
-
...state.cellRuntime[subsectionId],
|
|
2229
|
-
outline: {
|
|
2230
|
-
items: [{ name: "Sub of A", level: 3, by: { id: "sub-of-a" } }],
|
|
2231
|
-
},
|
|
2232
|
-
};
|
|
2233
|
-
|
|
2234
|
-
const sectionBId = state.cellIds.atOrThrow(FIRST_COLUMN).atOrThrow(4);
|
|
2235
|
-
state.cellRuntime[sectionBId] = {
|
|
2236
|
-
...state.cellRuntime[sectionBId],
|
|
2237
|
-
outline: {
|
|
2238
|
-
items: [{ name: "Section B", level: 2, by: { id: "section-b" } }],
|
|
2239
|
-
},
|
|
2240
|
-
};
|
|
2241
|
-
|
|
2242
|
-
actions.collapseAllCells();
|
|
2243
|
-
expect(state.cellIds.atOrThrow(FIRST_COLUMN).isCollapsed(headerId)).toBe(
|
|
2244
|
-
true,
|
|
2245
|
-
);
|
|
2246
|
-
expect(state.cellIds.atOrThrow(FIRST_COLUMN).topLevelIds).toEqual([
|
|
2247
|
-
firstCellId,
|
|
2248
|
-
headerId,
|
|
2249
|
-
]);
|
|
2250
|
-
|
|
2251
|
-
// Both sections sit under the header, collapsed, with the subsection
|
|
2252
|
-
// nested under section A
|
|
2253
|
-
actions.expandCell({ cellId: headerId });
|
|
2254
|
-
expect(state.cellIds.atOrThrow(FIRST_COLUMN).isCollapsed(sectionAId)).toBe(
|
|
2255
|
-
true,
|
|
2256
|
-
);
|
|
2257
|
-
expect(state.cellIds.atOrThrow(FIRST_COLUMN).isCollapsed(sectionBId)).toBe(
|
|
2258
|
-
true,
|
|
2259
|
-
);
|
|
2260
|
-
actions.expandCell({ cellId: sectionAId });
|
|
2261
|
-
expect(
|
|
2262
|
-
state.cellIds.atOrThrow(FIRST_COLUMN).isCollapsed(subsectionId),
|
|
2263
|
-
).toBe(true);
|
|
2264
|
-
});
|
|
2265
|
-
|
|
2266
|
-
it("can show hidden cells", () => {
|
|
2267
|
-
actions.createNewCell({ cellId: firstCellId, before: false });
|
|
2268
|
-
actions.createNewCell({ cellId: cellId("1"), before: false });
|
|
2269
|
-
actions.collapseCell({ cellId: firstCellId });
|
|
2270
|
-
|
|
2271
|
-
actions.showCellIfHidden({ cellId: cellId("1") });
|
|
2272
|
-
expect(state.cellIds.atOrThrow(FIRST_COLUMN).isCollapsed(firstCellId)).toBe(
|
|
2273
|
-
false,
|
|
2274
|
-
);
|
|
2275
|
-
});
|
|
2276
|
-
|
|
2277
|
-
it("can split and undo split cells", () => {
|
|
2278
|
-
actions.createNewCell({
|
|
2279
|
-
cellId: firstCellId,
|
|
2280
|
-
before: false,
|
|
2281
|
-
code: "line1\nline2",
|
|
2282
|
-
});
|
|
2283
|
-
const nextCellId = state.cellIds.atOrThrow(FIRST_COLUMN).atOrThrow(1);
|
|
2284
|
-
|
|
2285
|
-
const originalCellCount = state.cellIds.atOrThrow(FIRST_COLUMN).length;
|
|
2286
|
-
// Move cursor to the second line
|
|
2287
|
-
const editor = state.cellHandles[nextCellId].current?.editorView;
|
|
2288
|
-
if (!editor) {
|
|
2289
|
-
throw new Error("Editor not found");
|
|
2290
|
-
}
|
|
2291
|
-
editor.dispatch({ selection: { anchor: 5, head: 5 } });
|
|
2292
|
-
actions.splitCell({ cellId: nextCellId });
|
|
2293
|
-
expect(state.cellIds.atOrThrow(FIRST_COLUMN).length).toBe(
|
|
2294
|
-
originalCellCount + 1,
|
|
2295
|
-
);
|
|
2296
|
-
expect(state.cellData[nextCellId].code).toBe("line1");
|
|
2297
|
-
expect(
|
|
2298
|
-
state.cellData[state.cellIds.atOrThrow(FIRST_COLUMN).atOrThrow(2)].code,
|
|
2299
|
-
).toBe("line2");
|
|
2300
|
-
|
|
2301
|
-
actions.undoSplitCell({ cellId: nextCellId, snapshot: "line1\nline2" });
|
|
2302
|
-
expect(state.cellIds.atOrThrow(FIRST_COLUMN).length).toBe(
|
|
2303
|
-
originalCellCount,
|
|
2304
|
-
);
|
|
2305
|
-
expect(state.cellData[nextCellId].code).toBe("line1\nline2");
|
|
2306
|
-
});
|
|
2307
|
-
|
|
2308
|
-
it("can handle multiple console outputs", () => {
|
|
2309
|
-
const STDOUT1: OutputMessage = {
|
|
2310
|
-
channel: "stdout",
|
|
2311
|
-
mimetype: "text/plain",
|
|
2312
|
-
data: "output1",
|
|
2313
|
-
timestamp: 1,
|
|
2314
|
-
};
|
|
2315
|
-
const STDOUT2: OutputMessage = {
|
|
2316
|
-
channel: "stdout",
|
|
2317
|
-
mimetype: "text/plain",
|
|
2318
|
-
data: "output2",
|
|
2319
|
-
timestamp: 2,
|
|
2320
|
-
};
|
|
2321
|
-
|
|
2322
|
-
actions.handleCellMessage({
|
|
2323
|
-
cell_id: firstCellId,
|
|
2324
|
-
output: undefined,
|
|
2325
|
-
console: [STDOUT1, STDOUT2],
|
|
2326
|
-
status: "running",
|
|
2327
|
-
stale_inputs: null,
|
|
2328
|
-
timestamp: new Date(20).getTime() as Seconds,
|
|
2329
|
-
});
|
|
2330
|
-
|
|
2331
|
-
const cell = cells[0];
|
|
2332
|
-
expect(cell.consoleOutputs).toMatchInlineSnapshot(`
|
|
2333
|
-
[
|
|
2334
|
-
{
|
|
2335
|
-
"channel": "stdout",
|
|
2336
|
-
"data": "output1output2",
|
|
2337
|
-
"mimetype": "text/plain",
|
|
2338
|
-
"timestamp": 1,
|
|
2339
|
-
},
|
|
2340
|
-
]
|
|
2341
|
-
`);
|
|
2342
|
-
});
|
|
2343
|
-
|
|
2344
|
-
it("can add a column breakpoint", () => {
|
|
2345
|
-
actions.createNewCell({ cellId: firstCellId, before: false });
|
|
2346
|
-
actions.createNewCell({ cellId: cellId("1"), before: false });
|
|
2347
|
-
actions.createNewCell({ cellId: cellId("2"), before: false });
|
|
2348
|
-
|
|
2349
|
-
expect(state.cellIds.getColumns().length).toBe(1);
|
|
2350
|
-
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
2351
|
-
"
|
|
2352
|
-
[0] ''
|
|
2353
|
-
|
|
2354
|
-
[1] ''
|
|
2355
|
-
|
|
2356
|
-
[2] ''
|
|
2357
|
-
|
|
2358
|
-
[3] ''
|
|
2359
|
-
"
|
|
2360
|
-
`);
|
|
2361
|
-
|
|
2362
|
-
actions.addColumnBreakpoint({ cellId: cellId("2") });
|
|
2363
|
-
|
|
2364
|
-
expect(state.cellIds.getColumns().length).toBe(2);
|
|
2365
|
-
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
2366
|
-
"
|
|
2367
|
-
> col 0
|
|
2368
|
-
[0] ''
|
|
2369
|
-
|
|
2370
|
-
[1] ''
|
|
2371
|
-
|
|
2372
|
-
> col 1
|
|
2373
|
-
[2] ''
|
|
2374
|
-
|
|
2375
|
-
[3] ''
|
|
2376
|
-
"
|
|
2377
|
-
`);
|
|
2378
|
-
|
|
2379
|
-
// Check that the cells are in the correct columns
|
|
2380
|
-
expect(state.cellIds.getColumns()[0].topLevelIds).toEqual([
|
|
2381
|
-
cellId("0"),
|
|
2382
|
-
cellId("1"),
|
|
2383
|
-
]);
|
|
2384
|
-
expect(state.cellIds.getColumns()[1].topLevelIds).toEqual([
|
|
2385
|
-
cellId("2"),
|
|
2386
|
-
cellId("3"),
|
|
2387
|
-
]);
|
|
2388
|
-
});
|
|
2389
|
-
|
|
2390
|
-
it("cannot add a column breakpoint before the first cell", () => {
|
|
2391
|
-
expect(state.cellIds.getColumns().length).toBe(1);
|
|
2392
|
-
actions.createNewCell({ cellId: firstCellId, before: false });
|
|
2393
|
-
actions.createNewCell({ cellId: cellId("1"), before: false });
|
|
2394
|
-
actions.addColumnBreakpoint({ cellId: firstCellId });
|
|
2395
|
-
expect(state.cellIds.getColumns().length).toBe(1);
|
|
2396
|
-
});
|
|
2397
|
-
|
|
2398
|
-
it("can delete a column", () => {
|
|
2399
|
-
actions.createNewCell({ cellId: firstCellId, before: false });
|
|
2400
|
-
actions.createNewCell({ cellId: cellId("1"), before: false });
|
|
2401
|
-
actions.createNewCell({ cellId: cellId("2"), before: false });
|
|
2402
|
-
actions.addColumnBreakpoint({ cellId: cellId("2") });
|
|
2403
|
-
|
|
2404
|
-
expect(state.cellIds.getColumns().length).toBe(2);
|
|
2405
|
-
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
2406
|
-
"
|
|
2407
|
-
> col 0
|
|
2408
|
-
[0] ''
|
|
2409
|
-
|
|
2410
|
-
[1] ''
|
|
2411
|
-
|
|
2412
|
-
> col 1
|
|
2413
|
-
[2] ''
|
|
2414
|
-
|
|
2415
|
-
[3] ''
|
|
2416
|
-
"
|
|
2417
|
-
`);
|
|
2418
|
-
|
|
2419
|
-
const columnId = state.cellIds.atOrThrow(0).id;
|
|
2420
|
-
actions.deleteColumn({ columnId: columnId });
|
|
2421
|
-
|
|
2422
|
-
expect(state.cellIds.getColumns().length).toBe(1);
|
|
2423
|
-
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
2424
|
-
"
|
|
2425
|
-
[2] ''
|
|
2426
|
-
|
|
2427
|
-
[3] ''
|
|
2428
|
-
|
|
2429
|
-
[0] ''
|
|
2430
|
-
|
|
2431
|
-
[1] ''
|
|
2432
|
-
"
|
|
2433
|
-
`);
|
|
2434
|
-
|
|
2435
|
-
// Check that all cells are now in the remaining column
|
|
2436
|
-
expect(state.cellIds.getColumns()[0].topLevelIds).toEqual([
|
|
2437
|
-
"2",
|
|
2438
|
-
"3",
|
|
2439
|
-
"0",
|
|
2440
|
-
"1",
|
|
2441
|
-
]);
|
|
2442
|
-
});
|
|
2443
|
-
|
|
2444
|
-
it("deleting the last column does nothing", () => {
|
|
2445
|
-
actions.createNewCell({ cellId: firstCellId, before: false });
|
|
2446
|
-
actions.createNewCell({ cellId: cellId("1"), before: false });
|
|
2447
|
-
|
|
2448
|
-
const initialState = { ...state };
|
|
2449
|
-
|
|
2450
|
-
actions.deleteColumn({ columnId: initialState.cellIds.atOrThrow(0).id });
|
|
2451
|
-
|
|
2452
|
-
// State should not change
|
|
2453
|
-
expect(state).toEqual(initialState);
|
|
2454
|
-
});
|
|
2455
|
-
|
|
2456
|
-
it("can drop a cell over another cell", () => {
|
|
2457
|
-
actions.createNewCell({ cellId: firstCellId, before: false });
|
|
2458
|
-
actions.createNewCell({ cellId: cellId("1"), before: false });
|
|
2459
|
-
actions.createNewCell({ cellId: cellId("2"), before: false });
|
|
2460
|
-
|
|
2461
|
-
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
2462
|
-
"
|
|
2463
|
-
[0] ''
|
|
2464
|
-
|
|
2465
|
-
[1] ''
|
|
2466
|
-
|
|
2467
|
-
[2] ''
|
|
2468
|
-
|
|
2469
|
-
[3] ''
|
|
2470
|
-
"
|
|
2471
|
-
`);
|
|
2472
|
-
|
|
2473
|
-
actions.dropCellOverCell({
|
|
2474
|
-
cellId: cellId("0"),
|
|
2475
|
-
overCellId: cellId("3"),
|
|
2476
|
-
});
|
|
2477
|
-
|
|
2478
|
-
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
2479
|
-
"
|
|
2480
|
-
[1] ''
|
|
2481
|
-
|
|
2482
|
-
[2] ''
|
|
2483
|
-
|
|
2484
|
-
[3] ''
|
|
2485
|
-
|
|
2486
|
-
[0] ''
|
|
2487
|
-
"
|
|
2488
|
-
`);
|
|
2489
|
-
});
|
|
2490
|
-
|
|
2491
|
-
it("can drop a cell over a new column", () => {
|
|
2492
|
-
actions.createNewCell({ cellId: firstCellId, before: false });
|
|
2493
|
-
actions.createNewCell({ cellId: cellId("1"), before: false });
|
|
2494
|
-
|
|
2495
|
-
expect(state.cellIds.getColumns().length).toBe(1);
|
|
2496
|
-
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
2497
|
-
"
|
|
2498
|
-
[0] ''
|
|
2499
|
-
|
|
2500
|
-
[1] ''
|
|
2501
|
-
|
|
2502
|
-
[2] ''
|
|
2503
|
-
"
|
|
2504
|
-
`);
|
|
2505
|
-
|
|
2506
|
-
actions.dropOverNewColumn({ cellId: cellId("1") });
|
|
2507
|
-
|
|
2508
|
-
expect(state.cellIds.getColumns().length).toBe(2);
|
|
2509
|
-
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
2510
|
-
"
|
|
2511
|
-
> col 0
|
|
2512
|
-
[0] ''
|
|
2513
|
-
|
|
2514
|
-
[2] ''
|
|
2515
|
-
|
|
2516
|
-
> col 1
|
|
2517
|
-
[1] ''
|
|
2518
|
-
"
|
|
2519
|
-
`);
|
|
2520
|
-
|
|
2521
|
-
// Check that the cells are in the correct columns
|
|
2522
|
-
expect(state.cellIds.getColumns()[0].topLevelIds).toEqual([
|
|
2523
|
-
cellId("0"),
|
|
2524
|
-
cellId("2"),
|
|
2525
|
-
]);
|
|
2526
|
-
expect(state.cellIds.getColumns()[1].topLevelIds).toEqual([cellId("1")]);
|
|
2527
|
-
});
|
|
2528
|
-
|
|
2529
|
-
it("can drop a column over another column", () => {
|
|
2530
|
-
actions.createNewCell({ cellId: firstCellId, before: false });
|
|
2531
|
-
actions.createNewCell({ cellId: cellId("1"), before: false });
|
|
2532
|
-
actions.createNewCell({ cellId: cellId("2"), before: false });
|
|
2533
|
-
actions.addColumnBreakpoint({ cellId: cellId("2") });
|
|
2534
|
-
|
|
2535
|
-
expect(state.cellIds.getColumns().length).toBe(2);
|
|
2536
|
-
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
2537
|
-
"
|
|
2538
|
-
> col 0
|
|
2539
|
-
[0] ''
|
|
2540
|
-
|
|
2541
|
-
[1] ''
|
|
2542
|
-
|
|
2543
|
-
> col 1
|
|
2544
|
-
[2] ''
|
|
2545
|
-
|
|
2546
|
-
[3] ''
|
|
2547
|
-
"
|
|
2548
|
-
`);
|
|
2549
|
-
|
|
2550
|
-
const columnId0 = state.cellIds.atOrThrow(0).id;
|
|
2551
|
-
const columnId1 = state.cellIds.atOrThrow(1).id;
|
|
2552
|
-
expect(columnId0).not.toBe(columnId1);
|
|
2553
|
-
actions.moveColumn({ column: columnId1, overColumn: columnId0 });
|
|
2554
|
-
|
|
2555
|
-
expect(state.cellIds.getColumns().length).toBe(2);
|
|
2556
|
-
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
2557
|
-
"
|
|
2558
|
-
> col 0
|
|
2559
|
-
[2] ''
|
|
2560
|
-
|
|
2561
|
-
[3] ''
|
|
2562
|
-
|
|
2563
|
-
> col 1
|
|
2564
|
-
[0] ''
|
|
2565
|
-
|
|
2566
|
-
[1] ''
|
|
2567
|
-
"
|
|
2568
|
-
`);
|
|
2569
|
-
|
|
2570
|
-
// Check that the columns have swapped positions
|
|
2571
|
-
expect(state.cellIds.getColumns()[0].topLevelIds).toEqual([
|
|
2572
|
-
cellId("2"),
|
|
2573
|
-
cellId("3"),
|
|
2574
|
-
]);
|
|
2575
|
-
expect(state.cellIds.getColumns()[1].topLevelIds).toEqual([
|
|
2576
|
-
cellId("0"),
|
|
2577
|
-
cellId("1"),
|
|
2578
|
-
]);
|
|
2579
|
-
});
|
|
2580
|
-
|
|
2581
|
-
it("can compact columns", () => {
|
|
2582
|
-
// Create initial state with 3 columns, including an empty one
|
|
2583
|
-
actions.createNewCell({ cellId: firstCellId, before: false });
|
|
2584
|
-
actions.createNewCell({ cellId: cellId("1"), before: false });
|
|
2585
|
-
actions.addColumnBreakpoint({ cellId: cellId("1") });
|
|
2586
|
-
actions.addColumnBreakpoint({ cellId: cellId("2") });
|
|
2587
|
-
actions.dropOverNewColumn({ cellId: cellId("2") });
|
|
2588
|
-
|
|
2589
|
-
expect(state.cellIds.getColumns().length).toBe(4);
|
|
2590
|
-
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
2591
|
-
"
|
|
2592
|
-
> col 0
|
|
2593
|
-
[0] ''
|
|
2594
|
-
|
|
2595
|
-
> col 1
|
|
2596
|
-
[1] ''
|
|
2597
|
-
|
|
2598
|
-
> col 2
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
> col 3
|
|
2602
|
-
[2] ''
|
|
2603
|
-
"
|
|
2604
|
-
`);
|
|
2605
|
-
|
|
2606
|
-
// Check initial column structure
|
|
2607
|
-
expect(state.cellIds.getColumns()[0].topLevelIds).toEqual([cellId("0")]);
|
|
2608
|
-
expect(state.cellIds.getColumns()[1].topLevelIds).toEqual([cellId("1")]);
|
|
2609
|
-
expect(state.cellIds.getColumns()[2].topLevelIds).toEqual([]);
|
|
2610
|
-
expect(state.cellIds.getColumns()[3].topLevelIds).toEqual([cellId("2")]);
|
|
2611
|
-
|
|
2612
|
-
// Compact columns
|
|
2613
|
-
actions.compactColumns();
|
|
2614
|
-
|
|
2615
|
-
expect(state.cellIds.getColumns().length).toBe(3);
|
|
2616
|
-
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
2617
|
-
"
|
|
2618
|
-
> col 0
|
|
2619
|
-
[0] ''
|
|
2620
|
-
|
|
2621
|
-
> col 1
|
|
2622
|
-
[1] ''
|
|
2623
|
-
|
|
2624
|
-
> col 2
|
|
2625
|
-
[2] ''
|
|
2626
|
-
"
|
|
2627
|
-
`);
|
|
2628
|
-
|
|
2629
|
-
// Check compacted column structure
|
|
2630
|
-
expect(state.cellIds.getColumns()[0].topLevelIds).toEqual([cellId("0")]);
|
|
2631
|
-
expect(state.cellIds.getColumns()[1].topLevelIds).toEqual([cellId("1")]);
|
|
2632
|
-
expect(state.cellIds.getColumns()[2].topLevelIds).toEqual([cellId("2")]);
|
|
2633
|
-
});
|
|
2634
|
-
|
|
2635
|
-
it("rebuildCellColumns regroups cells by config.column", () => {
|
|
2636
|
-
// Create four cells in a single column.
|
|
2637
|
-
actions.createNewCell({ cellId: firstCellId, before: false });
|
|
2638
|
-
actions.createNewCell({ cellId: cellId("1"), before: false });
|
|
2639
|
-
actions.createNewCell({ cellId: cellId("2"), before: false });
|
|
2640
|
-
expect(state.cellIds.getColumns().length).toBe(1);
|
|
2641
|
-
|
|
2642
|
-
// Explicitly set config.column on each cell. This ONLY updates metadata —
|
|
2643
|
-
// updateCellConfig does not touch the MultiColumn tree.
|
|
2644
|
-
actions.updateCellConfig({
|
|
2645
|
-
cellId: cellId("0"),
|
|
2646
|
-
config: { column: 0 },
|
|
2647
|
-
});
|
|
2648
|
-
actions.updateCellConfig({
|
|
2649
|
-
cellId: cellId("2"),
|
|
2650
|
-
config: { column: 1 },
|
|
2651
|
-
});
|
|
2652
|
-
|
|
2653
|
-
// Tree is still a single column at this point.
|
|
2654
|
-
expect(state.cellIds.getColumns().length).toBe(1);
|
|
2655
|
-
|
|
2656
|
-
// Now rebuild the column tree from metadata.
|
|
2657
|
-
actions.rebuildCellColumns({
|
|
2658
|
-
cellIds: [cellId("0"), cellId("1"), cellId("2"), cellId("3")],
|
|
2659
|
-
});
|
|
2660
|
-
|
|
2661
|
-
expect(state.cellIds.getColumns().length).toBe(2);
|
|
2662
|
-
// Cell 1 inherits from 0 (col 0), cell 3 inherits from 2 (col 1).
|
|
2663
|
-
expect(state.cellIds.getColumns()[0].topLevelIds).toEqual([
|
|
2664
|
-
cellId("0"),
|
|
2665
|
-
cellId("1"),
|
|
2666
|
-
]);
|
|
2667
|
-
expect(state.cellIds.getColumns()[1].topLevelIds).toEqual([
|
|
2668
|
-
cellId("2"),
|
|
2669
|
-
cellId("3"),
|
|
2670
|
-
]);
|
|
2671
|
-
});
|
|
2672
|
-
|
|
2673
|
-
it("rebuildCellColumns with explicit column on every cell", () => {
|
|
2674
|
-
actions.createNewCell({ cellId: firstCellId, before: false });
|
|
2675
|
-
actions.createNewCell({ cellId: cellId("1"), before: false });
|
|
2676
|
-
actions.createNewCell({ cellId: cellId("2"), before: false });
|
|
2677
|
-
|
|
2678
|
-
for (const [id, col] of [
|
|
2679
|
-
["0", 1],
|
|
2680
|
-
["1", 0],
|
|
2681
|
-
["2", 1],
|
|
2682
|
-
["3", 0],
|
|
2683
|
-
] as const) {
|
|
2684
|
-
actions.updateCellConfig({ cellId: cellId(id), config: { column: col } });
|
|
2685
|
-
}
|
|
2686
|
-
|
|
2687
|
-
actions.rebuildCellColumns({
|
|
2688
|
-
cellIds: [cellId("0"), cellId("1"), cellId("2"), cellId("3")],
|
|
2689
|
-
});
|
|
2690
|
-
|
|
2691
|
-
expect(state.cellIds.getColumns().length).toBe(2);
|
|
2692
|
-
expect(state.cellIds.getColumns()[0].topLevelIds).toEqual([
|
|
2693
|
-
cellId("1"),
|
|
2694
|
-
cellId("3"),
|
|
2695
|
-
]);
|
|
2696
|
-
expect(state.cellIds.getColumns()[1].topLevelIds).toEqual([
|
|
2697
|
-
cellId("0"),
|
|
2698
|
-
cellId("2"),
|
|
2699
|
-
]);
|
|
2700
|
-
});
|
|
2701
|
-
|
|
2702
|
-
it("rebuildCellColumns collapses to one column when all cells are col 0", () => {
|
|
2703
|
-
actions.createNewCell({ cellId: firstCellId, before: false });
|
|
2704
|
-
actions.addColumnBreakpoint({ cellId: cellId("1") });
|
|
2705
|
-
expect(state.cellIds.getColumns().length).toBe(2);
|
|
2706
|
-
|
|
2707
|
-
// Wipe column metadata back to 0 for both cells.
|
|
2708
|
-
actions.updateCellConfig({ cellId: cellId("0"), config: { column: 0 } });
|
|
2709
|
-
actions.updateCellConfig({ cellId: cellId("1"), config: { column: 0 } });
|
|
2710
|
-
|
|
2711
|
-
actions.rebuildCellColumns({
|
|
2712
|
-
cellIds: [cellId("0"), cellId("1")],
|
|
2713
|
-
});
|
|
2714
|
-
|
|
2715
|
-
expect(state.cellIds.getColumns().length).toBe(1);
|
|
2716
|
-
expect(state.cellIds.getColumns()[0].topLevelIds).toEqual([
|
|
2717
|
-
cellId("0"),
|
|
2718
|
-
cellId("1"),
|
|
2719
|
-
]);
|
|
2720
|
-
});
|
|
2721
|
-
|
|
2722
|
-
it("rebuildCellColumns follows the provided order, not current tree order", () => {
|
|
2723
|
-
// Start with a single column.
|
|
2724
|
-
actions.createNewCell({ cellId: firstCellId, before: false });
|
|
2725
|
-
actions.createNewCell({ cellId: cellId("1"), before: false });
|
|
2726
|
-
actions.updateCellConfig({ cellId: cellId("0"), config: { column: 0 } });
|
|
2727
|
-
actions.updateCellConfig({ cellId: cellId("2"), config: { column: 1 } });
|
|
2728
|
-
|
|
2729
|
-
// Pass the reversed order. The rebuild should honor it.
|
|
2730
|
-
actions.rebuildCellColumns({
|
|
2731
|
-
cellIds: [cellId("2"), cellId("1"), cellId("0")],
|
|
2732
|
-
});
|
|
2733
|
-
|
|
2734
|
-
// cellIds iteration:
|
|
2735
|
-
// 2 → col=1, pushed to col1, prev=1
|
|
2736
|
-
// 1 → col=null, pushed to col[prev=1] = col1
|
|
2737
|
-
// 0 → col=0, pushed to col0
|
|
2738
|
-
expect(state.cellIds.getColumns()[0].topLevelIds).toEqual([cellId("0")]);
|
|
2739
|
-
expect(state.cellIds.getColumns()[1].topLevelIds).toEqual([
|
|
2740
|
-
cellId("2"),
|
|
2741
|
-
cellId("1"),
|
|
2742
|
-
]);
|
|
2743
|
-
});
|
|
2744
|
-
|
|
2745
|
-
it("can clear output of a single cell", () => {
|
|
2746
|
-
// Set up initial state with output
|
|
2747
|
-
actions.handleCellMessage({
|
|
2748
|
-
cell_id: firstCellId,
|
|
2749
|
-
output: {
|
|
2750
|
-
channel: "output",
|
|
2751
|
-
mimetype: "text/plain",
|
|
2752
|
-
data: "test output",
|
|
2753
|
-
timestamp: 0,
|
|
2754
|
-
},
|
|
2755
|
-
console: {
|
|
2756
|
-
channel: "stdout",
|
|
2757
|
-
mimetype: "text/plain",
|
|
2758
|
-
data: "console output",
|
|
2759
|
-
timestamp: 0,
|
|
2760
|
-
},
|
|
2761
|
-
status: "idle",
|
|
2762
|
-
stale_inputs: null,
|
|
2763
|
-
timestamp: new Date(33).getTime() as Seconds,
|
|
2764
|
-
});
|
|
2765
|
-
|
|
2766
|
-
// Verify initial state has output
|
|
2767
|
-
let cell = cells[0];
|
|
2768
|
-
expect(cell.output).not.toBeNull();
|
|
2769
|
-
expect(cell.consoleOutputs.length).toBe(1);
|
|
2770
|
-
|
|
2771
|
-
// Clear output
|
|
2772
|
-
actions.clearCellOutput({ cellId: firstCellId });
|
|
2773
|
-
|
|
2774
|
-
// Verify output is cleared
|
|
2775
|
-
cell = cells[0];
|
|
2776
|
-
expect(cell.output).toBeNull();
|
|
2777
|
-
expect(cell.consoleOutputs).toEqual([]);
|
|
2778
|
-
});
|
|
2779
|
-
|
|
2780
|
-
it("can clear console output of a single cell", () => {
|
|
2781
|
-
// Set up initial state with output
|
|
2782
|
-
actions.handleCellMessage({
|
|
2783
|
-
cell_id: firstCellId,
|
|
2784
|
-
output: {
|
|
2785
|
-
channel: "output",
|
|
2786
|
-
mimetype: "text/plain",
|
|
2787
|
-
data: "test output",
|
|
2788
|
-
timestamp: 0,
|
|
2789
|
-
},
|
|
2790
|
-
console: {
|
|
2791
|
-
channel: "stdout",
|
|
2792
|
-
mimetype: "text/plain",
|
|
2793
|
-
data: "console output",
|
|
2794
|
-
timestamp: 0,
|
|
2795
|
-
},
|
|
2796
|
-
status: "idle",
|
|
2797
|
-
stale_inputs: null,
|
|
2798
|
-
timestamp: new Date(33).getTime() as Seconds,
|
|
2799
|
-
});
|
|
2800
|
-
|
|
2801
|
-
// Add a stdin console output that should be preserved
|
|
2802
|
-
actions.handleCellMessage({
|
|
2803
|
-
cell_id: firstCellId,
|
|
2804
|
-
console: {
|
|
2805
|
-
channel: "stdin",
|
|
2806
|
-
mimetype: "text/plain",
|
|
2807
|
-
data: "stdin prompt",
|
|
2808
|
-
timestamp: 0,
|
|
2809
|
-
},
|
|
2810
|
-
status: "idle",
|
|
2811
|
-
stale_inputs: null,
|
|
2812
|
-
timestamp: new Date(34).getTime() as Seconds,
|
|
2813
|
-
});
|
|
2814
|
-
|
|
2815
|
-
// Verify initial state has output and console outputs
|
|
2816
|
-
let cell = cells[0];
|
|
2817
|
-
expect(cell.output).not.toBeNull();
|
|
2818
|
-
expect(cell.consoleOutputs.length).toBe(2);
|
|
2819
|
-
|
|
2820
|
-
// Clear console output
|
|
2821
|
-
actions.clearCellConsoleOutput({ cellId: firstCellId });
|
|
2822
|
-
|
|
2823
|
-
// Verify only console output is cleared, but stdin is preserved
|
|
2824
|
-
cell = cells[0];
|
|
2825
|
-
expect(cell.output).not.toBeNull(); // Output should remain
|
|
2826
|
-
expect(cell.consoleOutputs.length).toBe(1);
|
|
2827
|
-
expect(cell.consoleOutputs[0].channel).toBe("stdin");
|
|
2828
|
-
expect(cell.consoleOutputs[0].data).toBe("stdin prompt");
|
|
2829
|
-
});
|
|
2830
|
-
|
|
2831
|
-
it("can clear output of all cells", () => {
|
|
2832
|
-
// Create multiple cells with output
|
|
2833
|
-
actions.createNewCell({ cellId: firstCellId, before: false });
|
|
2834
|
-
const secondCellId = state.cellIds.atOrThrow(FIRST_COLUMN).atOrThrow(1);
|
|
2835
|
-
|
|
2836
|
-
// Add output to both cells
|
|
2837
|
-
const outputMessage = {
|
|
2838
|
-
output: {
|
|
2839
|
-
channel: "output",
|
|
2840
|
-
mimetype: "text/plain",
|
|
2841
|
-
data: "test output",
|
|
2842
|
-
timestamp: 0,
|
|
2843
|
-
},
|
|
2844
|
-
console: {
|
|
2845
|
-
channel: "stdout",
|
|
2846
|
-
mimetype: "text/plain",
|
|
2847
|
-
data: "console output",
|
|
2848
|
-
timestamp: 0,
|
|
2849
|
-
},
|
|
2850
|
-
status: "idle",
|
|
2851
|
-
stale_inputs: null,
|
|
2852
|
-
timestamp: new Date(33).getTime() as Seconds,
|
|
2853
|
-
} as const;
|
|
2854
|
-
|
|
2855
|
-
actions.handleCellMessage({
|
|
2856
|
-
...outputMessage,
|
|
2857
|
-
cell_id: firstCellId,
|
|
2858
|
-
});
|
|
2859
|
-
actions.handleCellMessage({
|
|
2860
|
-
...outputMessage,
|
|
2861
|
-
cell_id: secondCellId,
|
|
2862
|
-
});
|
|
2863
|
-
|
|
2864
|
-
// Verify initial state has output
|
|
2865
|
-
expect(state.cellRuntime[firstCellId].output).not.toBeNull();
|
|
2866
|
-
expect(state.cellRuntime[firstCellId].consoleOutputs.length).toBe(1);
|
|
2867
|
-
expect(state.cellRuntime[secondCellId].output).not.toBeNull();
|
|
2868
|
-
expect(state.cellRuntime[secondCellId].consoleOutputs.length).toBe(1);
|
|
2869
|
-
|
|
2870
|
-
// Clear all outputs
|
|
2871
|
-
actions.clearAllCellOutputs();
|
|
2872
|
-
|
|
2873
|
-
// Verify all outputs are cleared
|
|
2874
|
-
expect(state.cellRuntime[firstCellId].output).toBeNull();
|
|
2875
|
-
expect(state.cellRuntime[firstCellId].consoleOutputs).toEqual([]);
|
|
2876
|
-
expect(state.cellRuntime[secondCellId].output).toBeNull();
|
|
2877
|
-
expect(state.cellRuntime[secondCellId].consoleOutputs).toEqual([]);
|
|
2878
|
-
});
|
|
2879
|
-
|
|
2880
|
-
it("skips creating new cell if code exists and skipIfCodeExists is true", () => {
|
|
2881
|
-
// Add initial cell with code
|
|
2882
|
-
actions.updateCellCode({
|
|
2883
|
-
cellId: firstCellId,
|
|
2884
|
-
code: "import numpy as np",
|
|
2885
|
-
formattingChange: false,
|
|
2886
|
-
});
|
|
2887
|
-
|
|
2888
|
-
// Try to create new cell with same code and skipIfCodeExists
|
|
2889
|
-
actions.createNewCell({
|
|
2890
|
-
cellId: "__end__",
|
|
2891
|
-
code: "import numpy as np",
|
|
2892
|
-
before: false,
|
|
2893
|
-
skipIfCodeExists: true,
|
|
2894
|
-
});
|
|
2895
|
-
|
|
2896
|
-
// Should still only have one cell
|
|
2897
|
-
expect(state.cellIds.inOrderIds.length).toBe(1);
|
|
2898
|
-
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
2899
|
-
"
|
|
2900
|
-
[0] 'import numpy as np'
|
|
2901
|
-
"
|
|
2902
|
-
`);
|
|
2903
|
-
|
|
2904
|
-
// Verify we can still add cell with different code
|
|
2905
|
-
actions.createNewCell({
|
|
2906
|
-
cellId: "__end__",
|
|
2907
|
-
code: "import pandas as pd",
|
|
2908
|
-
before: false,
|
|
2909
|
-
skipIfCodeExists: true,
|
|
2910
|
-
});
|
|
2911
|
-
|
|
2912
|
-
expect(state.cellIds.inOrderIds.length).toBe(2);
|
|
2913
|
-
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
2914
|
-
"
|
|
2915
|
-
[0] 'import numpy as np'
|
|
2916
|
-
|
|
2917
|
-
[1] 'import pandas as pd'
|
|
2918
|
-
"
|
|
2919
|
-
`);
|
|
2920
|
-
});
|
|
2921
|
-
|
|
2922
|
-
it("can create and noop-update a setup cell", () => {
|
|
2923
|
-
// Create the setup cell
|
|
2924
|
-
actions.addSetupCellIfDoesntExist({ code: "# Setup code" });
|
|
2925
|
-
|
|
2926
|
-
// Check that setup cell was created
|
|
2927
|
-
expect(state.cellData[SETUP_CELL_ID].id).toBe(SETUP_CELL_ID);
|
|
2928
|
-
expect(state.cellData[SETUP_CELL_ID].name).toBe("setup");
|
|
2929
|
-
expect(state.cellData[SETUP_CELL_ID].code).toBe("# Setup code");
|
|
2930
|
-
expect(state.cellData[SETUP_CELL_ID].edited).toBe(true);
|
|
2931
|
-
expect(state.cellIds.inOrderIds).toContain(SETUP_CELL_ID);
|
|
2932
|
-
|
|
2933
|
-
// Update the setup cell
|
|
2934
|
-
actions.addSetupCellIfDoesntExist({ code: "# Updated setup code" });
|
|
2935
|
-
|
|
2936
|
-
// Check that the setup cell did not change, since it already exists
|
|
2937
|
-
expect(state.cellData[SETUP_CELL_ID].code).toBe("# Setup code");
|
|
2938
|
-
expect(state.cellData[SETUP_CELL_ID].edited).toBe(true);
|
|
2939
|
-
expect(state.cellIds.inOrderIds).toContain(SETUP_CELL_ID);
|
|
2940
|
-
});
|
|
2941
|
-
|
|
2942
|
-
it("can delete and undelete the setup cell", () => {
|
|
2943
|
-
// Create the setup cell
|
|
2944
|
-
actions.addSetupCellIfDoesntExist({ code: "# Setup code" });
|
|
2945
|
-
|
|
2946
|
-
// Check that setup cell was created
|
|
2947
|
-
expect(state.cellData[SETUP_CELL_ID].id).toBe(SETUP_CELL_ID);
|
|
2948
|
-
expect(state.cellData[SETUP_CELL_ID].name).toBe("setup");
|
|
2949
|
-
expect(state.cellData[SETUP_CELL_ID].code).toBe("# Setup code");
|
|
2950
|
-
expect(state.cellData[SETUP_CELL_ID].edited).toBe(true);
|
|
2951
|
-
expect(state.cellIds.inOrderIds).toContain(SETUP_CELL_ID);
|
|
2952
|
-
|
|
2953
|
-
// Delete the setup cell
|
|
2954
|
-
actions.deleteCell({ cellId: SETUP_CELL_ID });
|
|
2955
|
-
|
|
2956
|
-
// Check that setup cell was deleted
|
|
2957
|
-
expect(state.cellData[SETUP_CELL_ID]).toBeDefined(); // we keep old state
|
|
2958
|
-
expect(state.cellIds.inOrderIds).not.toContain(SETUP_CELL_ID);
|
|
2959
|
-
|
|
2960
|
-
// Undo delete the setup cell
|
|
2961
|
-
actions.undoDeleteCell();
|
|
2962
|
-
|
|
2963
|
-
// Check that setup cell was restored
|
|
2964
|
-
expect(state.cellData[SETUP_CELL_ID].id).toBe(SETUP_CELL_ID);
|
|
2965
|
-
expect(state.cellData[SETUP_CELL_ID].name).toBe("setup");
|
|
2966
|
-
expect(state.cellData[SETUP_CELL_ID].code).toBe("# Setup code");
|
|
2967
|
-
expect(state.cellData[SETUP_CELL_ID].edited).toBe(true);
|
|
2968
|
-
expect(state.cellIds.inOrderIds).toContain(SETUP_CELL_ID);
|
|
2969
|
-
|
|
2970
|
-
// Verify scrollKey is set to the restored setup cell
|
|
2971
|
-
expect(state.scrollKey).toBe(SETUP_CELL_ID);
|
|
2972
|
-
});
|
|
2973
|
-
|
|
2974
|
-
it("can delete and then create a new setup cell", () => {
|
|
2975
|
-
// Create the setup cell
|
|
2976
|
-
actions.addSetupCellIfDoesntExist({ code: "# Setup code" });
|
|
2977
|
-
|
|
2978
|
-
// Delete the setup cell
|
|
2979
|
-
actions.deleteCell({ cellId: SETUP_CELL_ID });
|
|
2980
|
-
|
|
2981
|
-
// Create a new setup cell
|
|
2982
|
-
actions.addSetupCellIfDoesntExist({ code: "# New code" });
|
|
2983
|
-
|
|
2984
|
-
// Check that the new setup cell was created
|
|
2985
|
-
expect(state.cellData[SETUP_CELL_ID].id).toBe(SETUP_CELL_ID);
|
|
2986
|
-
expect(state.cellData[SETUP_CELL_ID].name).toBe("setup");
|
|
2987
|
-
expect(state.cellData[SETUP_CELL_ID].code).toBe("# New code");
|
|
2988
|
-
expect(state.cellData[SETUP_CELL_ID].edited).toBe(true);
|
|
2989
|
-
expect(state.cellIds.inOrderIds).toContain(SETUP_CELL_ID);
|
|
2990
|
-
});
|
|
2991
|
-
|
|
2992
|
-
it("can clear all outputs", () => {
|
|
2993
|
-
// Add a cell and give it output
|
|
2994
|
-
actions.createNewCell({
|
|
2995
|
-
cellId: firstCellId,
|
|
2996
|
-
before: false,
|
|
2997
|
-
});
|
|
2998
|
-
|
|
2999
|
-
const cell1Id = cells[0].id;
|
|
3000
|
-
const cell2Id = cells[1].id;
|
|
3001
|
-
|
|
3002
|
-
// Manually set output for the cells
|
|
3003
|
-
state.cellRuntime[cell1Id].output = {
|
|
3004
|
-
channel: "output",
|
|
3005
|
-
mimetype: "text/plain",
|
|
3006
|
-
data: "output1",
|
|
3007
|
-
timestamp: 0 as Seconds,
|
|
3008
|
-
};
|
|
3009
|
-
state.cellRuntime[cell2Id].output = {
|
|
3010
|
-
channel: "output",
|
|
3011
|
-
mimetype: "text/plain",
|
|
3012
|
-
data: "output2",
|
|
3013
|
-
timestamp: 0 as Seconds,
|
|
3014
|
-
};
|
|
3015
|
-
|
|
3016
|
-
actions.clearAllCellOutputs();
|
|
3017
|
-
|
|
3018
|
-
expect(state.cellRuntime[cell1Id].output).toBeNull();
|
|
3019
|
-
expect(state.cellRuntime[cell2Id].output).toBeNull();
|
|
3020
|
-
});
|
|
3021
|
-
|
|
3022
|
-
describe("moveToNextCell", () => {
|
|
3023
|
-
let cell1Id: CellId;
|
|
3024
|
-
let cell2Id: CellId;
|
|
3025
|
-
let cell3Id: CellId;
|
|
3026
|
-
|
|
3027
|
-
beforeEach(() => {
|
|
3028
|
-
// Create a few cells to work with
|
|
3029
|
-
actions.createNewCell({ cellId: "__end__", before: false });
|
|
3030
|
-
actions.createNewCell({ cellId: "__end__", before: false });
|
|
3031
|
-
|
|
3032
|
-
cell1Id = state.cellIds.inOrderIds[0];
|
|
3033
|
-
cell2Id = state.cellIds.inOrderIds[1];
|
|
3034
|
-
cell3Id = state.cellIds.inOrderIds[2];
|
|
3035
|
-
});
|
|
3036
|
-
|
|
3037
|
-
it("creates new cell when moving after last cell with noCreate=false", () => {
|
|
3038
|
-
const initialCellCount = state.cellIds.inOrderIds.length;
|
|
3039
|
-
|
|
3040
|
-
actions.moveToNextCell({
|
|
3041
|
-
cellId: cell3Id,
|
|
3042
|
-
before: false,
|
|
3043
|
-
noCreate: false,
|
|
3044
|
-
});
|
|
3045
|
-
|
|
3046
|
-
expect(state.cellIds.inOrderIds.length).toBe(initialCellCount + 1);
|
|
3047
|
-
});
|
|
3048
|
-
|
|
3049
|
-
it("creates new cell when moving before first cell with noCreate=false", () => {
|
|
3050
|
-
const initialCellCount = state.cellIds.inOrderIds.length;
|
|
3051
|
-
|
|
3052
|
-
actions.moveToNextCell({
|
|
3053
|
-
cellId: cell1Id,
|
|
3054
|
-
before: true,
|
|
3055
|
-
noCreate: false,
|
|
3056
|
-
});
|
|
3057
|
-
|
|
3058
|
-
expect(state.cellIds.inOrderIds.length).toBe(initialCellCount + 1);
|
|
3059
|
-
});
|
|
3060
|
-
|
|
3061
|
-
it("does not create new cell when moving after last cell with noCreate=true", () => {
|
|
3062
|
-
const initialCellCount = state.cellIds.inOrderIds.length;
|
|
3063
|
-
const initialState = { ...state };
|
|
3064
|
-
|
|
3065
|
-
actions.moveToNextCell({
|
|
3066
|
-
cellId: cell3Id,
|
|
3067
|
-
before: false,
|
|
3068
|
-
noCreate: true,
|
|
3069
|
-
});
|
|
3070
|
-
|
|
3071
|
-
// Should not create a new cell
|
|
3072
|
-
expect(state.cellIds.inOrderIds.length).toBe(initialCellCount);
|
|
3073
|
-
// Should not crash or throw an error
|
|
3074
|
-
expect(state.cellIds.inOrderIds).toEqual(initialState.cellIds.inOrderIds);
|
|
3075
|
-
});
|
|
3076
|
-
|
|
3077
|
-
it("does not create new cell when moving before first cell with noCreate=true", () => {
|
|
3078
|
-
const initialCellCount = state.cellIds.inOrderIds.length;
|
|
3079
|
-
const initialState = { ...state };
|
|
3080
|
-
|
|
3081
|
-
actions.moveToNextCell({ cellId: cell1Id, before: true, noCreate: true });
|
|
3082
|
-
|
|
3083
|
-
// Should not create a new cell
|
|
3084
|
-
expect(state.cellIds.inOrderIds.length).toBe(initialCellCount);
|
|
3085
|
-
// Should not crash or throw an error
|
|
3086
|
-
expect(state.cellIds.inOrderIds).toEqual(initialState.cellIds.inOrderIds);
|
|
3087
|
-
});
|
|
3088
|
-
|
|
3089
|
-
it("focuses next cell when moving within bounds", () => {
|
|
3090
|
-
const focusSpy = vi.mocked(focusAndScrollCellIntoView);
|
|
3091
|
-
focusSpy.mockClear();
|
|
3092
|
-
|
|
3093
|
-
actions.moveToNextCell({
|
|
3094
|
-
cellId: cell1Id,
|
|
3095
|
-
before: false,
|
|
3096
|
-
noCreate: true,
|
|
3097
|
-
});
|
|
3098
|
-
|
|
3099
|
-
expect(focusSpy).toHaveBeenCalledWith({
|
|
3100
|
-
cellId: cell2Id,
|
|
3101
|
-
cell: state.cellHandles[cell2Id],
|
|
3102
|
-
isCodeHidden: false,
|
|
3103
|
-
codeFocus: "top",
|
|
3104
|
-
variableName: undefined,
|
|
3105
|
-
});
|
|
3106
|
-
});
|
|
3107
|
-
|
|
3108
|
-
it("focuses previous cell when moving backward within bounds", () => {
|
|
3109
|
-
const focusSpy = vi.mocked(focusAndScrollCellIntoView);
|
|
3110
|
-
focusSpy.mockClear();
|
|
3111
|
-
|
|
3112
|
-
actions.moveToNextCell({ cellId: cell2Id, before: true, noCreate: true });
|
|
3113
|
-
|
|
3114
|
-
expect(focusSpy).toHaveBeenCalledWith({
|
|
3115
|
-
cellId: cell1Id,
|
|
3116
|
-
cell: state.cellHandles[cell1Id],
|
|
3117
|
-
isCodeHidden: false,
|
|
3118
|
-
codeFocus: "bottom",
|
|
3119
|
-
variableName: undefined,
|
|
3120
|
-
});
|
|
3121
|
-
});
|
|
3122
|
-
|
|
3123
|
-
it("does not move focus from scratch cell", () => {
|
|
3124
|
-
const focusSpy = vi.mocked(focusAndScrollCellIntoView);
|
|
3125
|
-
focusSpy.mockClear();
|
|
3126
|
-
const initialState = { ...state };
|
|
3127
|
-
|
|
3128
|
-
actions.moveToNextCell({
|
|
3129
|
-
cellId: SCRATCH_CELL_ID,
|
|
3130
|
-
before: false,
|
|
3131
|
-
noCreate: false,
|
|
3132
|
-
});
|
|
3133
|
-
|
|
3134
|
-
expect(focusSpy).not.toHaveBeenCalled();
|
|
3135
|
-
expect(state.cellIds.inOrderIds).toEqual(initialState.cellIds.inOrderIds);
|
|
3136
|
-
});
|
|
3137
|
-
});
|
|
3138
|
-
|
|
3139
|
-
describe("untouched cells functionality", () => {
|
|
3140
|
-
it("starts with empty untouchedNewCells set", () => {
|
|
3141
|
-
expect(state.untouchedNewCells).toEqual(new Set());
|
|
3142
|
-
});
|
|
3143
|
-
|
|
3144
|
-
it("can create a new cell with hideCode option", () => {
|
|
3145
|
-
const initialCellCount = state.cellIds.inOrderIds.length;
|
|
3146
|
-
|
|
3147
|
-
actions.createNewCell({
|
|
3148
|
-
cellId: "__end__",
|
|
3149
|
-
before: false,
|
|
3150
|
-
hideCode: true,
|
|
3151
|
-
});
|
|
3152
|
-
|
|
3153
|
-
expect(state.cellIds.inOrderIds.length).toBe(initialCellCount + 1);
|
|
3154
|
-
const newCellId =
|
|
3155
|
-
state.cellIds.inOrderIds[state.cellIds.inOrderIds.length - 1];
|
|
3156
|
-
expect(state.untouchedNewCells.has(newCellId)).toBe(true);
|
|
3157
|
-
});
|
|
3158
|
-
|
|
3159
|
-
it("adds interactively-created hidden cell with boilerplate code to untouchedNewCells", () => {
|
|
3160
|
-
// Markdown cells are created with hideCode and non-empty default code
|
|
3161
|
-
// (e.g. `mo.md(r"""\n""")`). They are user-initiated, so their editor
|
|
3162
|
-
// should be shown until first blur.
|
|
3163
|
-
actions.createNewCell({
|
|
3164
|
-
cellId: "__end__",
|
|
3165
|
-
before: false,
|
|
3166
|
-
code: 'mo.md(r"""\n""")',
|
|
3167
|
-
hideCode: true,
|
|
3168
|
-
autoFocus: true,
|
|
3169
|
-
});
|
|
3170
|
-
|
|
3171
|
-
const newCellId =
|
|
3172
|
-
state.cellIds.inOrderIds[state.cellIds.inOrderIds.length - 1];
|
|
3173
|
-
expect(state.untouchedNewCells.has(newCellId)).toBe(true);
|
|
3174
|
-
});
|
|
3175
|
-
|
|
3176
|
-
it("does not add programmatically-created hidden cell with code to untouchedNewCells", () => {
|
|
3177
|
-
// Cells created by the kernel (e.g. via code_mode) carry code and
|
|
3178
|
-
// autoFocus=false; their hide_code must take effect immediately.
|
|
3179
|
-
actions.createNewCell({
|
|
3180
|
-
cellId: "__end__",
|
|
3181
|
-
before: false,
|
|
3182
|
-
code: "x = 1",
|
|
3183
|
-
hideCode: true,
|
|
3184
|
-
autoFocus: false,
|
|
3185
|
-
});
|
|
3186
|
-
|
|
3187
|
-
const newCellId =
|
|
3188
|
-
state.cellIds.inOrderIds[state.cellIds.inOrderIds.length - 1];
|
|
3189
|
-
expect(state.untouchedNewCells.has(newCellId)).toBe(false);
|
|
3190
|
-
});
|
|
3191
|
-
|
|
3192
|
-
it("does not add cell to untouchedNewCells when hideCode is false", () => {
|
|
3193
|
-
actions.createNewCell({
|
|
3194
|
-
cellId: "__end__",
|
|
3195
|
-
before: false,
|
|
3196
|
-
hideCode: false,
|
|
3197
|
-
});
|
|
3198
|
-
|
|
3199
|
-
const newCellId =
|
|
3200
|
-
state.cellIds.inOrderIds[state.cellIds.inOrderIds.length - 1];
|
|
3201
|
-
expect(state.untouchedNewCells.has(newCellId)).toBe(false);
|
|
3202
|
-
});
|
|
3203
|
-
|
|
3204
|
-
it("does not add cell to untouchedNewCells when hideCode is undefined", () => {
|
|
3205
|
-
actions.createNewCell({
|
|
3206
|
-
cellId: "__end__",
|
|
3207
|
-
before: false,
|
|
3208
|
-
});
|
|
3209
|
-
|
|
3210
|
-
const newCellId =
|
|
3211
|
-
state.cellIds.inOrderIds[state.cellIds.inOrderIds.length - 1];
|
|
3212
|
-
expect(state.untouchedNewCells.has(newCellId)).toBe(false);
|
|
3213
|
-
});
|
|
3214
|
-
|
|
3215
|
-
it("can mark a cell as touched", () => {
|
|
3216
|
-
// Create a cell with hideCode
|
|
3217
|
-
actions.createNewCell({
|
|
3218
|
-
cellId: "__end__",
|
|
3219
|
-
before: false,
|
|
3220
|
-
hideCode: true,
|
|
3221
|
-
});
|
|
3222
|
-
|
|
3223
|
-
const newCellId =
|
|
3224
|
-
state.cellIds.inOrderIds[state.cellIds.inOrderIds.length - 1];
|
|
3225
|
-
expect(state.untouchedNewCells.has(newCellId)).toBe(true);
|
|
3226
|
-
|
|
3227
|
-
// Mark it as touched
|
|
3228
|
-
actions.markTouched({ cellId: newCellId });
|
|
3229
|
-
|
|
3230
|
-
expect(state.untouchedNewCells.has(newCellId)).toBe(false);
|
|
3231
|
-
});
|
|
3232
|
-
|
|
3233
|
-
it("markTouched is idempotent", () => {
|
|
3234
|
-
// Create a cell with hideCode
|
|
3235
|
-
actions.createNewCell({
|
|
3236
|
-
cellId: "__end__",
|
|
3237
|
-
before: false,
|
|
3238
|
-
hideCode: true,
|
|
3239
|
-
});
|
|
3240
|
-
|
|
3241
|
-
const newCellId =
|
|
3242
|
-
state.cellIds.inOrderIds[state.cellIds.inOrderIds.length - 1];
|
|
3243
|
-
expect(state.untouchedNewCells.has(newCellId)).toBe(true);
|
|
3244
|
-
|
|
3245
|
-
// Mark it as touched multiple times
|
|
3246
|
-
actions.markTouched({ cellId: newCellId });
|
|
3247
|
-
actions.markTouched({ cellId: newCellId });
|
|
3248
|
-
actions.markTouched({ cellId: newCellId });
|
|
3249
|
-
|
|
3250
|
-
expect(state.untouchedNewCells.has(newCellId)).toBe(false);
|
|
3251
|
-
});
|
|
3252
|
-
|
|
3253
|
-
it("can mark a non-existent cell as touched without error", () => {
|
|
3254
|
-
const nonExistentCellId = cellId("non-existent");
|
|
3255
|
-
|
|
3256
|
-
expect(() => {
|
|
3257
|
-
actions.markTouched({ cellId: nonExistentCellId });
|
|
3258
|
-
}).not.toThrow();
|
|
3259
|
-
|
|
3260
|
-
expect(state.untouchedNewCells.has(nonExistentCellId)).toBe(false);
|
|
3261
|
-
});
|
|
3262
|
-
|
|
3263
|
-
it("can handle multiple untouched cells", () => {
|
|
3264
|
-
// Create multiple cells with hideCode
|
|
3265
|
-
actions.createNewCell({
|
|
3266
|
-
cellId: "__end__",
|
|
3267
|
-
before: false,
|
|
3268
|
-
hideCode: true,
|
|
3269
|
-
});
|
|
3270
|
-
actions.createNewCell({
|
|
3271
|
-
cellId: "__end__",
|
|
3272
|
-
before: false,
|
|
3273
|
-
hideCode: true,
|
|
3274
|
-
});
|
|
3275
|
-
actions.createNewCell({
|
|
3276
|
-
cellId: "__end__",
|
|
3277
|
-
before: false,
|
|
3278
|
-
hideCode: false,
|
|
3279
|
-
});
|
|
3280
|
-
|
|
3281
|
-
const cellIds = state.cellIds.inOrderIds;
|
|
3282
|
-
const cell1Id = cellIds[cellIds.length - 3];
|
|
3283
|
-
const cell2Id = cellIds[cellIds.length - 2];
|
|
3284
|
-
const cell3Id = cellIds[cellIds.length - 1];
|
|
3285
|
-
|
|
3286
|
-
expect(state.untouchedNewCells.has(cell1Id)).toBe(true);
|
|
3287
|
-
expect(state.untouchedNewCells.has(cell2Id)).toBe(true);
|
|
3288
|
-
expect(state.untouchedNewCells.has(cell3Id)).toBe(false);
|
|
3289
|
-
|
|
3290
|
-
// Mark one as touched
|
|
3291
|
-
actions.markTouched({ cellId: cell1Id });
|
|
3292
|
-
|
|
3293
|
-
expect(state.untouchedNewCells.has(cell1Id)).toBe(false);
|
|
3294
|
-
expect(state.untouchedNewCells.has(cell2Id)).toBe(true);
|
|
3295
|
-
expect(state.untouchedNewCells.has(cell3Id)).toBe(false);
|
|
3296
|
-
});
|
|
3297
|
-
|
|
3298
|
-
it("preserves untouched state when cells are moved", () => {
|
|
3299
|
-
// Create cells with hideCode
|
|
3300
|
-
actions.createNewCell({
|
|
3301
|
-
cellId: "__end__",
|
|
3302
|
-
before: false,
|
|
3303
|
-
hideCode: true,
|
|
3304
|
-
});
|
|
3305
|
-
actions.createNewCell({
|
|
3306
|
-
cellId: "__end__",
|
|
3307
|
-
before: false,
|
|
3308
|
-
hideCode: true,
|
|
3309
|
-
});
|
|
3310
|
-
|
|
3311
|
-
const cellIds = state.cellIds.inOrderIds;
|
|
3312
|
-
const cell1Id = cellIds[cellIds.length - 2];
|
|
3313
|
-
const cell2Id = cellIds[cellIds.length - 1];
|
|
3314
|
-
|
|
3315
|
-
expect(state.untouchedNewCells.has(cell1Id)).toBe(true);
|
|
3316
|
-
expect(state.untouchedNewCells.has(cell2Id)).toBe(true);
|
|
3317
|
-
|
|
3318
|
-
// Move cell1 to the end
|
|
3319
|
-
actions.moveCell({
|
|
3320
|
-
cellId: cell1Id,
|
|
3321
|
-
before: false,
|
|
3322
|
-
});
|
|
3323
|
-
|
|
3324
|
-
// Both cells should still be untouched
|
|
3325
|
-
expect(state.untouchedNewCells.has(cell1Id)).toBe(true);
|
|
3326
|
-
expect(state.untouchedNewCells.has(cell2Id)).toBe(true);
|
|
3327
|
-
});
|
|
3328
|
-
|
|
3329
|
-
it("does not remove untouched state when cell is deleted", () => {
|
|
3330
|
-
// We could implement this, but it doesn't actually affect downstream behavior.
|
|
3331
|
-
// It is easier to leave it, so `undo` works as expected.
|
|
3332
|
-
|
|
3333
|
-
// Create a cell with hideCode
|
|
3334
|
-
actions.createNewCell({
|
|
3335
|
-
cellId: "__end__",
|
|
3336
|
-
before: false,
|
|
3337
|
-
hideCode: true,
|
|
3338
|
-
});
|
|
3339
|
-
|
|
3340
|
-
const newCellId =
|
|
3341
|
-
state.cellIds.inOrderIds[state.cellIds.inOrderIds.length - 1];
|
|
3342
|
-
expect(state.untouchedNewCells.has(newCellId)).toBe(true);
|
|
3343
|
-
|
|
3344
|
-
// Delete the cell
|
|
3345
|
-
actions.deleteCell({ cellId: newCellId });
|
|
3346
|
-
|
|
3347
|
-
// Does not actually remove untouched state
|
|
3348
|
-
expect(state.untouchedNewCells.has(newCellId)).toBe(true);
|
|
3349
|
-
});
|
|
3350
|
-
|
|
3351
|
-
it("restores untouched state when cell deletion is undone", () => {
|
|
3352
|
-
// Create a cell with hideCode
|
|
3353
|
-
actions.createNewCell({
|
|
3354
|
-
cellId: "__end__",
|
|
3355
|
-
before: false,
|
|
3356
|
-
hideCode: true,
|
|
3357
|
-
});
|
|
3358
|
-
|
|
3359
|
-
const newCellId =
|
|
3360
|
-
state.cellIds.inOrderIds[state.cellIds.inOrderIds.length - 1];
|
|
3361
|
-
expect(state.untouchedNewCells.has(newCellId)).toBe(true);
|
|
3362
|
-
|
|
3363
|
-
// Delete the cell
|
|
3364
|
-
actions.deleteCell({ cellId: newCellId });
|
|
3365
|
-
// Still exists in untouchedNewCells
|
|
3366
|
-
expect(state.untouchedNewCells.has(newCellId)).toBe(true);
|
|
3367
|
-
|
|
3368
|
-
// Undo the deletion
|
|
3369
|
-
actions.undoDeleteCell();
|
|
3370
|
-
|
|
3371
|
-
// The cell should be restored but no longer untouched
|
|
3372
|
-
// (this is expected behavior - undoing doesn't restore untouched state)
|
|
3373
|
-
const restoredCellId =
|
|
3374
|
-
state.cellIds.inOrderIds[state.cellIds.inOrderIds.length - 1];
|
|
3375
|
-
expect(state.untouchedNewCells.has(restoredCellId)).toBe(false);
|
|
3376
|
-
});
|
|
3377
|
-
|
|
3378
|
-
it("untouched cell behavior with hide_code config", () => {
|
|
3379
|
-
// Create a cell with hideCode and hide_code config
|
|
3380
|
-
actions.createNewCell({
|
|
3381
|
-
cellId: "__end__",
|
|
3382
|
-
before: false,
|
|
3383
|
-
hideCode: true,
|
|
3384
|
-
});
|
|
3385
|
-
|
|
3386
|
-
const newCellId =
|
|
3387
|
-
state.cellIds.inOrderIds[state.cellIds.inOrderIds.length - 1];
|
|
3388
|
-
|
|
3389
|
-
// Update the cell config to hide code
|
|
3390
|
-
actions.updateCellConfig({
|
|
3391
|
-
cellId: newCellId,
|
|
3392
|
-
config: { hide_code: true },
|
|
3393
|
-
});
|
|
3394
|
-
|
|
3395
|
-
// Cell should be untouched and have hide_code config
|
|
3396
|
-
expect(state.untouchedNewCells.has(newCellId)).toBe(true);
|
|
3397
|
-
expect(state.cellData[newCellId].config.hide_code).toBe(true);
|
|
3398
|
-
|
|
3399
|
-
// Code should not be hidden because cell is untouched
|
|
3400
|
-
expect(exportedForTesting.isCellCodeHidden(state, newCellId)).toBe(false);
|
|
3401
|
-
|
|
3402
|
-
// Mark as touched
|
|
3403
|
-
actions.markTouched({ cellId: newCellId });
|
|
3404
|
-
|
|
3405
|
-
// Now code should be hidden
|
|
3406
|
-
expect(state.untouchedNewCells.has(newCellId)).toBe(false);
|
|
3407
|
-
expect(exportedForTesting.isCellCodeHidden(state, newCellId)).toBe(true);
|
|
3408
|
-
});
|
|
3409
|
-
|
|
3410
|
-
it("can mark an existing cell as untouched", () => {
|
|
3411
|
-
// Create a cell without hideCode (not in untouchedNewCells)
|
|
3412
|
-
actions.createNewCell({
|
|
3413
|
-
cellId: "__end__",
|
|
3414
|
-
before: false,
|
|
3415
|
-
hideCode: false,
|
|
3416
|
-
});
|
|
3417
|
-
|
|
3418
|
-
const newCellId =
|
|
3419
|
-
state.cellIds.inOrderIds[state.cellIds.inOrderIds.length - 1];
|
|
3420
|
-
expect(state.untouchedNewCells.has(newCellId)).toBe(false);
|
|
3421
|
-
|
|
3422
|
-
// Mark it as untouched
|
|
3423
|
-
actions.markUntouched({ cellId: newCellId });
|
|
3424
|
-
|
|
3425
|
-
expect(state.untouchedNewCells.has(newCellId)).toBe(true);
|
|
3426
|
-
});
|
|
3427
|
-
|
|
3428
|
-
it("markUntouched is idempotent", () => {
|
|
3429
|
-
// Create a cell without hideCode
|
|
3430
|
-
actions.createNewCell({
|
|
3431
|
-
cellId: "__end__",
|
|
3432
|
-
before: false,
|
|
3433
|
-
hideCode: false,
|
|
3434
|
-
});
|
|
3435
|
-
|
|
3436
|
-
const newCellId =
|
|
3437
|
-
state.cellIds.inOrderIds[state.cellIds.inOrderIds.length - 1];
|
|
3438
|
-
expect(state.untouchedNewCells.has(newCellId)).toBe(false);
|
|
3439
|
-
|
|
3440
|
-
// Mark as untouched multiple times
|
|
3441
|
-
actions.markUntouched({ cellId: newCellId });
|
|
3442
|
-
actions.markUntouched({ cellId: newCellId });
|
|
3443
|
-
actions.markUntouched({ cellId: newCellId });
|
|
3444
|
-
|
|
3445
|
-
expect(state.untouchedNewCells.has(newCellId)).toBe(true);
|
|
3446
|
-
});
|
|
3447
|
-
|
|
3448
|
-
it("markUntouched does not affect already untouched cells", () => {
|
|
3449
|
-
// Create a cell with hideCode (already in untouchedNewCells)
|
|
3450
|
-
actions.createNewCell({
|
|
3451
|
-
cellId: "__end__",
|
|
3452
|
-
before: false,
|
|
3453
|
-
hideCode: true,
|
|
3454
|
-
});
|
|
3455
|
-
|
|
3456
|
-
const newCellId =
|
|
3457
|
-
state.cellIds.inOrderIds[state.cellIds.inOrderIds.length - 1];
|
|
3458
|
-
expect(state.untouchedNewCells.has(newCellId)).toBe(true);
|
|
3459
|
-
|
|
3460
|
-
// Calling markUntouched should not change anything
|
|
3461
|
-
actions.markUntouched({ cellId: newCellId });
|
|
3462
|
-
|
|
3463
|
-
expect(state.untouchedNewCells.has(newCellId)).toBe(true);
|
|
3464
|
-
});
|
|
3465
|
-
|
|
3466
|
-
it("markTouched and markUntouched can toggle cell state", () => {
|
|
3467
|
-
// Create a cell without hideCode
|
|
3468
|
-
actions.createNewCell({
|
|
3469
|
-
cellId: "__end__",
|
|
3470
|
-
before: false,
|
|
3471
|
-
hideCode: false,
|
|
3472
|
-
});
|
|
3473
|
-
|
|
3474
|
-
const newCellId =
|
|
3475
|
-
state.cellIds.inOrderIds[state.cellIds.inOrderIds.length - 1];
|
|
3476
|
-
|
|
3477
|
-
// Initially not untouched
|
|
3478
|
-
expect(state.untouchedNewCells.has(newCellId)).toBe(false);
|
|
3479
|
-
|
|
3480
|
-
// Mark as untouched
|
|
3481
|
-
actions.markUntouched({ cellId: newCellId });
|
|
3482
|
-
expect(state.untouchedNewCells.has(newCellId)).toBe(true);
|
|
3483
|
-
|
|
3484
|
-
// Mark as touched
|
|
3485
|
-
actions.markTouched({ cellId: newCellId });
|
|
3486
|
-
expect(state.untouchedNewCells.has(newCellId)).toBe(false);
|
|
3487
|
-
|
|
3488
|
-
// Mark as untouched again
|
|
3489
|
-
actions.markUntouched({ cellId: newCellId });
|
|
3490
|
-
expect(state.untouchedNewCells.has(newCellId)).toBe(true);
|
|
3491
|
-
});
|
|
3492
|
-
|
|
3493
|
-
it("markUntouched works for markdown cell conversion scenario", () => {
|
|
3494
|
-
// Simulates converting a Python cell to Markdown
|
|
3495
|
-
// 1. Create a regular cell (no hideCode)
|
|
3496
|
-
actions.createNewCell({
|
|
3497
|
-
cellId: "__end__",
|
|
3498
|
-
before: false,
|
|
3499
|
-
hideCode: false,
|
|
3500
|
-
});
|
|
3501
|
-
|
|
3502
|
-
const cellId =
|
|
3503
|
-
state.cellIds.inOrderIds[state.cellIds.inOrderIds.length - 1];
|
|
3504
|
-
|
|
3505
|
-
// Cell starts without hide_code and not in untouchedNewCells
|
|
3506
|
-
expect(state.cellData[cellId].config.hide_code).toBe(false);
|
|
3507
|
-
expect(state.untouchedNewCells.has(cellId)).toBe(false);
|
|
3508
|
-
expect(exportedForTesting.isCellCodeHidden(state, cellId)).toBe(false);
|
|
3509
|
-
|
|
3510
|
-
// 2. Convert to markdown: set hide_code and mark as untouched
|
|
3511
|
-
actions.updateCellConfig({
|
|
3512
|
-
cellId,
|
|
3513
|
-
config: { hide_code: true },
|
|
3514
|
-
});
|
|
3515
|
-
actions.markUntouched({ cellId });
|
|
3516
|
-
|
|
3517
|
-
// Code should NOT be hidden because cell is untouched (user can edit)
|
|
3518
|
-
expect(state.cellData[cellId].config.hide_code).toBe(true);
|
|
3519
|
-
expect(state.untouchedNewCells.has(cellId)).toBe(true);
|
|
3520
|
-
expect(exportedForTesting.isCellCodeHidden(state, cellId)).toBe(false);
|
|
3521
|
-
|
|
3522
|
-
// 3. User blurs the cell (markTouched)
|
|
3523
|
-
actions.markTouched({ cellId });
|
|
3524
|
-
|
|
3525
|
-
// Now code should be hidden
|
|
3526
|
-
expect(state.untouchedNewCells.has(cellId)).toBe(false);
|
|
3527
|
-
expect(exportedForTesting.isCellCodeHidden(state, cellId)).toBe(true);
|
|
3528
|
-
});
|
|
3529
|
-
});
|
|
3530
|
-
|
|
3531
|
-
describe("releaseCellAtoms", () => {
|
|
3532
|
-
it("atom families cache atoms until explicitly removed", () => {
|
|
3533
|
-
const { cellDataAtom, cellRuntimeAtom, cellHandleAtom } =
|
|
3534
|
-
exportedForTesting;
|
|
3535
|
-
|
|
3536
|
-
actions.createNewCell({ cellId: firstCellId, before: false });
|
|
3537
|
-
const newCellId = state.cellIds.inOrderIds[1];
|
|
3538
|
-
|
|
3539
|
-
const dataAtom1 = cellDataAtom(newCellId);
|
|
3540
|
-
const runtimeAtom1 = cellRuntimeAtom(newCellId);
|
|
3541
|
-
const handleAtom1 = cellHandleAtom(newCellId);
|
|
3542
|
-
|
|
3543
|
-
// accesses return cached atoms (same reference)
|
|
3544
|
-
const dataAtom2 = cellDataAtom(newCellId);
|
|
3545
|
-
const runtimeAtom2 = cellRuntimeAtom(newCellId);
|
|
3546
|
-
const handleAtom2 = cellHandleAtom(newCellId);
|
|
3547
|
-
|
|
3548
|
-
expect(dataAtom2).toBe(dataAtom1);
|
|
3549
|
-
expect(runtimeAtom2).toBe(runtimeAtom1);
|
|
3550
|
-
expect(handleAtom2).toBe(handleAtom1);
|
|
3551
|
-
});
|
|
3552
|
-
|
|
3553
|
-
it("cleans up atom family cache when cells are deleted", () => {
|
|
3554
|
-
const { cellDataAtom, cellRuntimeAtom, cellHandleAtom } =
|
|
3555
|
-
exportedForTesting;
|
|
3556
|
-
|
|
3557
|
-
actions.createNewCell({ cellId: firstCellId, before: false });
|
|
3558
|
-
const newCellId = state.cellIds.inOrderIds[1];
|
|
3559
|
-
|
|
3560
|
-
// Access to create cache entries
|
|
3561
|
-
const dataAtom1 = cellDataAtom(newCellId);
|
|
3562
|
-
const runtimeAtom1 = cellRuntimeAtom(newCellId);
|
|
3563
|
-
const handleAtom1 = cellHandleAtom(newCellId);
|
|
3564
|
-
|
|
3565
|
-
// Triggers purge
|
|
3566
|
-
actions.deleteCell({ cellId: newCellId });
|
|
3567
|
-
|
|
3568
|
-
// Access again (should be new instances after cleanup)
|
|
3569
|
-
const dataAtom2 = cellDataAtom(newCellId);
|
|
3570
|
-
const runtimeAtom2 = cellRuntimeAtom(newCellId);
|
|
3571
|
-
const handleAtom2 = cellHandleAtom(newCellId);
|
|
3572
|
-
|
|
3573
|
-
expect(dataAtom2).not.toBe(dataAtom1);
|
|
3574
|
-
expect(runtimeAtom2).not.toBe(runtimeAtom1);
|
|
3575
|
-
expect(handleAtom2).not.toBe(handleAtom1);
|
|
3576
|
-
});
|
|
3577
|
-
});
|
|
3578
|
-
});
|
|
3579
|
-
|
|
3580
|
-
describe("isCellCodeHidden", () => {
|
|
3581
|
-
const state = initialNotebookState();
|
|
3582
|
-
const firstCellId = state.cellIds.inOrderIds[0];
|
|
3583
|
-
|
|
3584
|
-
it("returns false when hide_code is false and cell is not untouched", () => {
|
|
3585
|
-
const testCellId = cellId("test-cell");
|
|
3586
|
-
const testState: NotebookState = {
|
|
3587
|
-
...state,
|
|
3588
|
-
cellData: {
|
|
3589
|
-
...state.cellData,
|
|
3590
|
-
[testCellId]: {
|
|
3591
|
-
...state.cellData[firstCellId],
|
|
3592
|
-
id: testCellId,
|
|
3593
|
-
config: { hide_code: false, disabled: false, column: null },
|
|
3594
|
-
},
|
|
3595
|
-
},
|
|
3596
|
-
untouchedNewCells: new Set(),
|
|
3597
|
-
};
|
|
3598
|
-
|
|
3599
|
-
expect(exportedForTesting.isCellCodeHidden(testState, testCellId)).toBe(
|
|
3600
|
-
false,
|
|
3601
|
-
);
|
|
3602
|
-
});
|
|
3603
|
-
|
|
3604
|
-
it("returns true when hide_code is true and cell is not untouched", () => {
|
|
3605
|
-
const testCellId = cellId("test-cell");
|
|
3606
|
-
const testState: NotebookState = {
|
|
3607
|
-
...state,
|
|
3608
|
-
cellData: {
|
|
3609
|
-
...state.cellData,
|
|
3610
|
-
[testCellId]: {
|
|
3611
|
-
...state.cellData[firstCellId],
|
|
3612
|
-
id: testCellId,
|
|
3613
|
-
config: { hide_code: true, disabled: false, column: null },
|
|
3614
|
-
},
|
|
3615
|
-
},
|
|
3616
|
-
untouchedNewCells: new Set(),
|
|
3617
|
-
};
|
|
3618
|
-
|
|
3619
|
-
expect(exportedForTesting.isCellCodeHidden(testState, testCellId)).toBe(
|
|
3620
|
-
true,
|
|
3621
|
-
);
|
|
3622
|
-
});
|
|
3623
|
-
|
|
3624
|
-
it("returns false when hide_code is true but cell is untouched", () => {
|
|
3625
|
-
const testCellId = cellId("test-cell");
|
|
3626
|
-
const testState: NotebookState = {
|
|
3627
|
-
...state,
|
|
3628
|
-
cellData: {
|
|
3629
|
-
...state.cellData,
|
|
3630
|
-
[testCellId]: {
|
|
3631
|
-
...state.cellData[firstCellId],
|
|
3632
|
-
id: testCellId,
|
|
3633
|
-
config: { hide_code: true, disabled: false, column: null },
|
|
3634
|
-
},
|
|
3635
|
-
},
|
|
3636
|
-
untouchedNewCells: new Set([testCellId]),
|
|
3637
|
-
};
|
|
3638
|
-
|
|
3639
|
-
expect(exportedForTesting.isCellCodeHidden(testState, testCellId)).toBe(
|
|
3640
|
-
false,
|
|
3641
|
-
);
|
|
3642
|
-
});
|
|
3643
|
-
|
|
3644
|
-
it("returns false when hide_code is false and cell is untouched", () => {
|
|
3645
|
-
const testCellId = cellId("test-cell");
|
|
3646
|
-
const testState: NotebookState = {
|
|
3647
|
-
...state,
|
|
3648
|
-
cellData: {
|
|
3649
|
-
...state.cellData,
|
|
3650
|
-
[testCellId]: {
|
|
3651
|
-
...state.cellData[firstCellId],
|
|
3652
|
-
id: testCellId,
|
|
3653
|
-
config: { hide_code: false, disabled: false, column: null },
|
|
3654
|
-
},
|
|
3655
|
-
},
|
|
3656
|
-
untouchedNewCells: new Set([testCellId]),
|
|
3657
|
-
};
|
|
3658
|
-
|
|
3659
|
-
expect(exportedForTesting.isCellCodeHidden(testState, testCellId)).toBe(
|
|
3660
|
-
false,
|
|
3661
|
-
);
|
|
3662
|
-
});
|
|
3663
|
-
});
|
|
3664
|
-
|
|
3665
|
-
describe("createTracebackInfoAtom", () => {
|
|
3666
|
-
const store = createStore();
|
|
3667
|
-
|
|
3668
|
-
it("returns undefined when cell has no errors", async () => {
|
|
3669
|
-
store.set(
|
|
3670
|
-
notebookAtom,
|
|
3671
|
-
MockNotebook.notebookState({
|
|
3672
|
-
cellData: {
|
|
3673
|
-
[cellId("cell1")]: {
|
|
3674
|
-
id: cellId("cell1"),
|
|
3675
|
-
name: "cell1",
|
|
3676
|
-
code: "",
|
|
3677
|
-
},
|
|
3678
|
-
},
|
|
3679
|
-
}),
|
|
3680
|
-
);
|
|
3681
|
-
|
|
3682
|
-
const tracebackAtom = exportedForTesting.createTracebackInfoAtom(
|
|
3683
|
-
cellId("cell1"),
|
|
3684
|
-
);
|
|
3685
|
-
const traceback = store.get(tracebackAtom);
|
|
3686
|
-
|
|
3687
|
-
expect(traceback).toBeUndefined();
|
|
3688
|
-
});
|
|
3689
|
-
|
|
3690
|
-
it("extracts lineno from syntax errors", async () => {
|
|
3691
|
-
store.set(
|
|
3692
|
-
notebookAtom,
|
|
3693
|
-
MockNotebook.notebookState({
|
|
3694
|
-
cellData: {
|
|
3695
|
-
[cellId("cell1")]: {
|
|
3696
|
-
id: cellId("cell1"),
|
|
3697
|
-
name: "cell1",
|
|
3698
|
-
code: "x = 1",
|
|
3699
|
-
},
|
|
3700
|
-
},
|
|
3701
|
-
cellRuntime: {
|
|
3702
|
-
[cellId("cell1")]: {
|
|
3703
|
-
output: {
|
|
3704
|
-
channel: "marimo-error",
|
|
3705
|
-
data: [{ type: "syntax", msg: "Syntax error", lineno: 5 }],
|
|
3706
|
-
mimetype: "application/vnd.marimo+error",
|
|
3707
|
-
},
|
|
3708
|
-
},
|
|
3709
|
-
},
|
|
3710
|
-
}),
|
|
3711
|
-
);
|
|
3712
|
-
|
|
3713
|
-
const tracebackAtom = exportedForTesting.createTracebackInfoAtom(
|
|
3714
|
-
cellId("cell1"),
|
|
3715
|
-
);
|
|
3716
|
-
const traceback = store.get(tracebackAtom);
|
|
3717
|
-
|
|
3718
|
-
expect(traceback).toBeDefined();
|
|
3719
|
-
expect(traceback).toHaveLength(1);
|
|
3720
|
-
expect(traceback![0]).toEqual({
|
|
3721
|
-
kind: "cell",
|
|
3722
|
-
cellId: cellId("cell1"),
|
|
3723
|
-
lineNumber: 5,
|
|
3724
|
-
});
|
|
3725
|
-
});
|
|
3726
|
-
|
|
3727
|
-
it("handles syntax errors with lineno = 0", async () => {
|
|
3728
|
-
store.set(
|
|
3729
|
-
notebookAtom,
|
|
3730
|
-
MockNotebook.notebookState({
|
|
3731
|
-
cellData: {
|
|
3732
|
-
[cellId("cell1")]: {
|
|
3733
|
-
id: cellId("cell1"),
|
|
3734
|
-
name: "cell1",
|
|
3735
|
-
code: "x = 1",
|
|
3736
|
-
},
|
|
3737
|
-
},
|
|
3738
|
-
cellRuntime: {
|
|
3739
|
-
[cellId("cell1")]: {
|
|
3740
|
-
output: {
|
|
3741
|
-
channel: "marimo-error",
|
|
3742
|
-
data: [{ type: "syntax", msg: "Syntax error", lineno: 0 }],
|
|
3743
|
-
mimetype: "application/vnd.marimo+error",
|
|
3744
|
-
},
|
|
3745
|
-
},
|
|
3746
|
-
},
|
|
3747
|
-
}),
|
|
3748
|
-
);
|
|
3749
|
-
|
|
3750
|
-
const tracebackAtom = exportedForTesting.createTracebackInfoAtom(
|
|
3751
|
-
cellId("cell1"),
|
|
3752
|
-
);
|
|
3753
|
-
const traceback = store.get(tracebackAtom);
|
|
3754
|
-
expect(traceback).toBeDefined();
|
|
3755
|
-
expect(traceback).toHaveLength(1);
|
|
3756
|
-
expect(traceback![0].lineNumber).toBe(0);
|
|
3757
|
-
});
|
|
3758
|
-
|
|
3759
|
-
it("ignores syntax errors with lineno = null", () => {
|
|
3760
|
-
store.set(
|
|
3761
|
-
notebookAtom,
|
|
3762
|
-
MockNotebook.notebookState({
|
|
3763
|
-
cellData: {
|
|
3764
|
-
[cellId("cell1")]: {
|
|
3765
|
-
id: cellId("cell1"),
|
|
3766
|
-
name: "cell1",
|
|
3767
|
-
code: "x = 1",
|
|
3768
|
-
},
|
|
3769
|
-
},
|
|
3770
|
-
cellRuntime: {
|
|
3771
|
-
[cellId("cell1")]: {
|
|
3772
|
-
output: {
|
|
3773
|
-
channel: "marimo-error",
|
|
3774
|
-
data: [{ type: "syntax", msg: "Syntax error", lineno: null }],
|
|
3775
|
-
mimetype: "application/vnd.marimo+error",
|
|
3776
|
-
},
|
|
3777
|
-
},
|
|
3778
|
-
},
|
|
3779
|
-
}),
|
|
3780
|
-
);
|
|
3781
|
-
|
|
3782
|
-
const tracebackAtom = exportedForTesting.createTracebackInfoAtom(
|
|
3783
|
-
cellId("cell1"),
|
|
3784
|
-
);
|
|
3785
|
-
const traceback = store.get(tracebackAtom);
|
|
3786
|
-
|
|
3787
|
-
expect(traceback).toBeUndefined();
|
|
3788
|
-
});
|
|
3789
|
-
|
|
3790
|
-
it("handles multiple syntax errors", () => {
|
|
3791
|
-
store.set(
|
|
3792
|
-
notebookAtom,
|
|
3793
|
-
MockNotebook.notebookState({
|
|
3794
|
-
cellData: {
|
|
3795
|
-
[cellId("cell1")]: {
|
|
3796
|
-
id: cellId("cell1"),
|
|
3797
|
-
name: "cell1",
|
|
3798
|
-
code: "x = 1",
|
|
3799
|
-
},
|
|
3800
|
-
},
|
|
3801
|
-
cellRuntime: {
|
|
3802
|
-
[cellId("cell1")]: {
|
|
3803
|
-
output: {
|
|
3804
|
-
channel: "marimo-error",
|
|
3805
|
-
data: [
|
|
3806
|
-
{ type: "syntax", msg: "Syntax error", lineno: 3 },
|
|
3807
|
-
{ type: "syntax", msg: "Syntax error", lineno: 7 },
|
|
3808
|
-
],
|
|
3809
|
-
mimetype: "application/vnd.marimo+error",
|
|
3810
|
-
},
|
|
3811
|
-
},
|
|
3812
|
-
},
|
|
3813
|
-
}),
|
|
3814
|
-
);
|
|
3815
|
-
|
|
3816
|
-
const tracebackAtom = exportedForTesting.createTracebackInfoAtom(
|
|
3817
|
-
cellId("cell1"),
|
|
3818
|
-
);
|
|
3819
|
-
const traceback = store.get(tracebackAtom);
|
|
3820
|
-
expect(traceback).toBeDefined();
|
|
3821
|
-
expect(traceback).toHaveLength(2);
|
|
3822
|
-
expect(traceback![0].lineNumber).toBe(3);
|
|
3823
|
-
expect(traceback![1].lineNumber).toBe(7);
|
|
3824
|
-
});
|
|
3825
|
-
|
|
3826
|
-
it("returns undefined when cell is queued", async () => {
|
|
3827
|
-
store.set(
|
|
3828
|
-
notebookAtom,
|
|
3829
|
-
MockNotebook.notebookState({
|
|
3830
|
-
cellData: {
|
|
3831
|
-
[cellId("cell1")]: {
|
|
3832
|
-
id: cellId("cell1"),
|
|
3833
|
-
name: "cell1",
|
|
3834
|
-
code: "x = 1",
|
|
3835
|
-
},
|
|
3836
|
-
},
|
|
3837
|
-
cellRuntime: {
|
|
3838
|
-
[cellId("cell1")]: {
|
|
3839
|
-
output: {
|
|
3840
|
-
channel: "marimo-error",
|
|
3841
|
-
data: [{ type: "syntax", msg: "Syntax error", lineno: 1 }],
|
|
3842
|
-
mimetype: "application/vnd.marimo+error",
|
|
3843
|
-
},
|
|
3844
|
-
status: "queued",
|
|
3845
|
-
},
|
|
3846
|
-
},
|
|
3847
|
-
}),
|
|
3848
|
-
);
|
|
3849
|
-
|
|
3850
|
-
const tracebackAtom = exportedForTesting.createTracebackInfoAtom(
|
|
3851
|
-
cellId("cell1"),
|
|
3852
|
-
);
|
|
3853
|
-
const traceback = store.get(tracebackAtom);
|
|
3854
|
-
|
|
3855
|
-
expect(traceback).toBeUndefined();
|
|
3856
|
-
});
|
|
3857
|
-
|
|
3858
|
-
it("returns undefined when cell is running", () => {
|
|
3859
|
-
store.set(
|
|
3860
|
-
notebookAtom,
|
|
3861
|
-
MockNotebook.notebookState({
|
|
3862
|
-
cellData: {
|
|
3863
|
-
[cellId("cell1")]: {
|
|
3864
|
-
id: cellId("cell1"),
|
|
3865
|
-
name: "cell1",
|
|
3866
|
-
code: "x = 1",
|
|
3867
|
-
},
|
|
3868
|
-
},
|
|
3869
|
-
cellRuntime: {
|
|
3870
|
-
[cellId("cell1")]: {
|
|
3871
|
-
output: {
|
|
3872
|
-
channel: "marimo-error",
|
|
3873
|
-
data: [{ type: "syntax", msg: "Syntax error", lineno: 1 }],
|
|
3874
|
-
mimetype: "application/vnd.marimo+error",
|
|
3875
|
-
},
|
|
3876
|
-
status: "running",
|
|
3877
|
-
},
|
|
3878
|
-
},
|
|
3879
|
-
}),
|
|
3880
|
-
);
|
|
3881
|
-
|
|
3882
|
-
const tracebackAtom = exportedForTesting.createTracebackInfoAtom(
|
|
3883
|
-
cellId("cell1"),
|
|
3884
|
-
);
|
|
3885
|
-
const traceback = store.get(tracebackAtom);
|
|
3886
|
-
|
|
3887
|
-
expect(traceback).toBeUndefined();
|
|
3888
|
-
});
|
|
3889
|
-
});
|
|
3890
|
-
|
|
3891
|
-
describe("setCells snapshot preservation", () => {
|
|
3892
|
-
const CELL_A = cellId("A");
|
|
3893
|
-
const CELL_B = cellId("B");
|
|
3894
|
-
const newCells: CellData[] = [
|
|
3895
|
-
{
|
|
3896
|
-
id: CELL_A,
|
|
3897
|
-
name: "a",
|
|
3898
|
-
code: "1",
|
|
3899
|
-
edited: false,
|
|
3900
|
-
lastCodeRun: null,
|
|
3901
|
-
lastExecutionTime: null,
|
|
3902
|
-
config: { hide_code: false, disabled: false, column: null },
|
|
3903
|
-
serializedEditorState: null,
|
|
3904
|
-
},
|
|
3905
|
-
{
|
|
3906
|
-
id: CELL_B,
|
|
3907
|
-
name: "b",
|
|
3908
|
-
code: "2",
|
|
3909
|
-
edited: false,
|
|
3910
|
-
lastCodeRun: null,
|
|
3911
|
-
lastExecutionTime: null,
|
|
3912
|
-
config: { hide_code: false, disabled: false, column: null },
|
|
3913
|
-
serializedEditorState: null,
|
|
3914
|
-
},
|
|
3915
|
-
];
|
|
3916
|
-
|
|
3917
|
-
const hydratedState = () =>
|
|
3918
|
-
MockNotebook.notebookState({
|
|
3919
|
-
cellData: {
|
|
3920
|
-
[CELL_A]: { id: CELL_A, code: "1" },
|
|
3921
|
-
[CELL_B]: { id: CELL_B, code: "2" },
|
|
3922
|
-
},
|
|
3923
|
-
cellRuntime: {
|
|
3924
|
-
[CELL_A]: {
|
|
3925
|
-
output: {
|
|
3926
|
-
channel: "output",
|
|
3927
|
-
mimetype: "text/plain",
|
|
3928
|
-
data: "hydrated-A",
|
|
3929
|
-
timestamp: 0,
|
|
3930
|
-
},
|
|
3931
|
-
},
|
|
3932
|
-
[CELL_B]: {
|
|
3933
|
-
consoleOutputs: [
|
|
3934
|
-
{
|
|
3935
|
-
channel: "stdout",
|
|
3936
|
-
mimetype: "text/plain",
|
|
3937
|
-
data: "hydrated-B-stdout",
|
|
3938
|
-
timestamp: 0,
|
|
3939
|
-
},
|
|
3940
|
-
],
|
|
3941
|
-
},
|
|
3942
|
-
},
|
|
3943
|
-
});
|
|
3944
|
-
|
|
3945
|
-
beforeEach(async () => {
|
|
3946
|
-
const { isWasm } = await import("@/core/wasm/utils");
|
|
3947
|
-
vi.mocked(isWasm).mockReturnValue(true);
|
|
3948
|
-
});
|
|
3949
|
-
|
|
3950
|
-
it("preserves hydrated output in WASM", () => {
|
|
3951
|
-
const next = exportedForTesting.reducer(hydratedState(), {
|
|
3952
|
-
type: "setCells",
|
|
3953
|
-
payload: newCells,
|
|
3954
|
-
});
|
|
3955
|
-
|
|
3956
|
-
expect(next.cellRuntime[CELL_A].output).toMatchObject({
|
|
3957
|
-
data: "hydrated-A",
|
|
3958
|
-
});
|
|
3959
|
-
});
|
|
3960
|
-
|
|
3961
|
-
it("preserves console-only hydration in WASM", () => {
|
|
3962
|
-
const next = exportedForTesting.reducer(hydratedState(), {
|
|
3963
|
-
type: "setCells",
|
|
3964
|
-
payload: newCells,
|
|
3965
|
-
});
|
|
3966
|
-
|
|
3967
|
-
expect(next.cellRuntime[CELL_B].consoleOutputs).toHaveLength(1);
|
|
3968
|
-
expect(next.cellRuntime[CELL_B].consoleOutputs[0]).toMatchObject({
|
|
3969
|
-
data: "hydrated-B-stdout",
|
|
501
|
+
expect(next.cellRuntime[CELL_A].embeddedConsole).toEqual([]);
|
|
3970
502
|
});
|
|
3971
503
|
});
|
|
3972
|
-
|
|
3973
|
-
it("resets cells with no prior runtime even in WASM", () => {
|
|
3974
|
-
const empty = MockNotebook.notebookState({ cellData: {} });
|
|
3975
|
-
const next = exportedForTesting.reducer(empty, {
|
|
3976
|
-
type: "setCells",
|
|
3977
|
-
payload: newCells,
|
|
3978
|
-
});
|
|
3979
|
-
|
|
3980
|
-
expect(next.cellRuntime[CELL_A].output).toBeNull();
|
|
3981
|
-
expect(next.cellRuntime[CELL_A].consoleOutputs).toEqual([]);
|
|
3982
|
-
expect(next.cellRuntime[CELL_B].output).toBeNull();
|
|
3983
|
-
expect(next.cellRuntime[CELL_B].consoleOutputs).toEqual([]);
|
|
3984
|
-
});
|
|
3985
504
|
});
|