@marimo-team/frontend 0.24.3-dev81 → 0.24.3-dev83
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/assets/{ConnectedDataExplorerComponent-DkTZ7AvX.js → ConnectedDataExplorerComponent-BpquZl-D.js} +1 -1
- package/dist/assets/{ErrorBoundary-DTpbqvzY.js → ErrorBoundary-BQqmHnXk.js} +2 -2
- package/dist/assets/{LazyAnyLanguageCodeMirror-DYsZfkSk.js → LazyAnyLanguageCodeMirror-CvxfNkWH.js} +2 -2
- package/dist/assets/{RunButton-IMtEkRXV.js → RunButton-DNkIh9-L.js} +8 -8
- package/dist/assets/{abnfDiagram-VCTEODGH-pTFf_XLR.js → abnfDiagram-VCTEODGH-CnUMzJx3.js} +1 -1
- package/dist/assets/add-cell-with-ai-BMP2uVIa.js +76 -0
- package/dist/assets/{agent-panel-DxU4qgxk.js → agent-panel-45n6y1yx.js} +5 -5
- package/dist/assets/ai-model-dropdown-DHCy-cih.js +3 -0
- package/dist/assets/{any-language-editor-DBp5CC3w.js → any-language-editor-C4RQC2Cx.js} +1 -1
- package/dist/assets/{app-config-button-BjxXAmKd.js → app-config-button-_8eL7EEp.js} +1 -1
- package/dist/assets/{architectureDiagram-5GKGNRK7-C7t0AR-N.js → architectureDiagram-5GKGNRK7-bfcUxn_j.js} +1 -1
- package/dist/assets/arrow-down-BFFrjzad.js +1 -0
- package/dist/assets/{blockDiagram-I7D4REHJ-DZgXohrV.js → blockDiagram-I7D4REHJ-BpF8yI-R.js} +1 -1
- package/dist/assets/{cache-panel-DDlfv8BP.js → cache-panel-BR4yhYeu.js} +1 -1
- package/dist/assets/cells-BcQ8Tm3j.js +220 -0
- package/dist/assets/{chat-display-CHxh_MGC.js → chat-display-C_qIajXO.js} +1 -1
- package/dist/assets/{chat-panel-Ca6yjxkg.js → chat-panel-DZ_Wgf9u.js} +3 -3
- package/dist/assets/{chat-ui-D5zW1hYM.js → chat-ui-BrP572Cm.js} +1 -1
- package/dist/assets/{chunk-IMKFNOWR-CAmhQu-F.js → chunk-IMKFNOWR-C-rPN2GF.js} +1 -1
- package/dist/assets/{chunk-SHT3W25Y-BqEFXoRq.js → chunk-SHT3W25Y-P5kn0hWZ.js} +1 -1
- package/dist/assets/{chunk-SVP7TREG-Dxu0eRzD.js → chunk-SVP7TREG-BDSmMBZT.js} +1 -1
- package/dist/assets/{chunk-TICWLB2K-gHNMAWa9.js → chunk-TICWLB2K-D3dtJ1vz.js} +1 -1
- package/dist/assets/{classDiagram-ZZMXUADV-DE3i3SzX.js → classDiagram-ZZMXUADV-DHIDyAFc.js} +1 -1
- package/dist/assets/{classDiagram-v2-VYDZK3BY-DE3i3SzX.js → classDiagram-v2-VYDZK3BY-DHIDyAFc.js} +1 -1
- package/dist/assets/{code-visibility-kUtIY_sH.js → code-visibility-DB0T__on.js} +1 -1
- package/dist/assets/{command-palette-BZJRR34P.js → command-palette-DvYu24TH.js} +1 -1
- package/dist/assets/{common-DtiDLSXB.js → common-C53kupuv.js} +1 -1
- package/dist/assets/{components-DScgyZ8j.js → components-BrsyCK82.js} +1 -1
- package/dist/assets/{components-CHh1MGbL.js → components-BuvKvfSS.js} +1 -1
- package/dist/assets/config-CmBpjGXk.js +1 -0
- package/dist/assets/{cynefinDiagram-5FMLGOSQ-C8RK-PLH.js → cynefinDiagram-5FMLGOSQ-CYdbFzEV.js} +1 -1
- package/dist/assets/{dagre-GXQ25YYZ-DZ6JGcBM.js → dagre-GXQ25YYZ-CSEPMX9I.js} +1 -1
- package/dist/assets/dagre-SOh4Qguh.js +1 -0
- package/dist/assets/{data-grid-overlay-editor-BkZfO-uG.js → data-grid-overlay-editor-ierQMJA6.js} +1 -1
- package/dist/assets/dependency-graph-panel-DBaLCinF.js +5 -0
- package/dist/assets/{diagram-S7CK7UJ4-BN77DDKM.js → diagram-S7CK7UJ4-D5YIr9T4.js} +1 -1
- package/dist/assets/{diagram-UQ7AKVKN-BZthP0T4.js → diagram-UQ7AKVKN-uqarxJJM.js} +1 -1
- package/dist/assets/{diagram-VX7I27RA-D3GF3lRq.js → diagram-VX7I27RA-HcvMY8pK.js} +1 -1
- package/dist/assets/{diagram-Z3DM3KII-DnsKITpy.js → diagram-Z3DM3KII-fJYqqcs8.js} +1 -1
- package/dist/assets/{documentation-panel-D8fz9UDV.js → documentation-panel-LhtR1Gdz.js} +1 -1
- package/dist/assets/{ebnfDiagram-PWID7BFC-CHqqdhbQ.js → ebnfDiagram-PWID7BFC-z1dFbGgp.js} +1 -1
- package/dist/assets/edit-page-B28h9Fb6.js +176 -0
- package/dist/assets/{erDiagram-RLTQ6QDP-ChDyfc3w.js → erDiagram-RLTQ6QDP-D0QTGZaN.js} +1 -1
- package/dist/assets/{error-entries-Dy7E9tUS.js → error-entries-C-LFkdXb.js} +1 -1
- package/dist/assets/{error-panel-FYd4Tvsc.js → error-panel-JrTKWez-.js} +1 -1
- package/dist/assets/{feedback-button-Zjt-Mi38.js → feedback-button-CXZUuGO0.js} +2 -2
- package/dist/assets/file-explorer-panel-0uckfsy9.js +1 -0
- package/dist/assets/{file-name-input-DifonhZ7.js → file-name-input-B1oP4qI1.js} +1 -1
- package/dist/assets/{flowDiagram-HODETNUW-CelwDl0Y.js → flowDiagram-HODETNUW-CvnIcAyp.js} +1 -1
- package/dist/assets/{gallery-page-C0T1oyzr.js → gallery-page-Dr6gmPct.js} +1 -1
- package/dist/assets/{glide-data-editor-Dqd-if6R.js → glide-data-editor-BdNlPATo.js} +4 -4
- package/dist/assets/{graphlib-6_f7N0YM.js → graphlib-coUtpRhg.js} +1 -1
- package/dist/assets/has-HvSiby4C.js +1 -0
- package/dist/assets/home-page-DU_vk7YP.js +4 -0
- package/dist/assets/index-C0mx13kv.css +2 -0
- package/dist/assets/index-anJECncb.js +62 -0
- package/dist/assets/{infoDiagram-27XIBGKW-Dh0ztpYZ.js → infoDiagram-27XIBGKW-B-ESiKKL.js} +1 -1
- package/dist/assets/{ishikawaDiagram-5VMMS53U-Yy11Lj-8.js → ishikawaDiagram-5VMMS53U-958453Qs.js} +1 -1
- package/dist/assets/{kanban-definition-UXKFOSKX-_hCm9ITM.js → kanban-definition-UXKFOSKX-Cl3MvgdV.js} +1 -1
- package/dist/assets/{logs-panel-D_Ki0PRi.js → logs-panel-B6dW8QcS.js} +1 -1
- package/dist/assets/{mermaid-DUZOkwYg.js → mermaid-Dk7Zo_kD.js} +4 -4
- package/dist/assets/{mindmap-definition-YA3MSWOX-CqKVab9Z.js → mindmap-definition-YA3MSWOX-ObRzpp8l.js} +1 -1
- package/dist/assets/{number-overlay-editor-BFwgibS5.js → number-overlay-editor-BaA6YHpZ.js} +1 -1
- package/dist/assets/{outline-panel-BVLrHsJa.js → outline-panel-AF6eqkBP.js} +1 -1
- package/dist/assets/packages-panel-DnQBjrbw.js +1 -0
- package/dist/assets/panel-context-BPaQeOuV.js +1 -0
- package/dist/assets/panels-Gl9xHiUG.js +33 -0
- package/dist/assets/{pegDiagram-XKGWAZYB-Cq-QrQFc.js → pegDiagram-XKGWAZYB-Dr1N-uz9.js} +1 -1
- package/dist/assets/{pieDiagram-E7YTZNPT-DXU0ndOt.js → pieDiagram-E7YTZNPT-CuOB3ooB.js} +1 -1
- package/dist/assets/{process-output-B76bPsnA.js → process-output-dY19eMY7.js} +1 -1
- package/dist/assets/{railroadDiagram-O6MQD6OU-CFI_pgSK.js → railroadDiagram-O6MQD6OU-B-2q9lGc.js} +1 -1
- package/dist/assets/{requirementDiagram-BXWQKSXE-DgdygEWz.js → requirementDiagram-BXWQKSXE-DDO3d-q-.js} +1 -1
- package/dist/assets/{reveal-component-BqiZOsW3.js → reveal-component-CVZuomdL.js} +3 -3
- package/dist/assets/run-page-q9RV38Se.js +1 -0
- package/dist/assets/scratchpad-panel-CB7Fy9xQ.js +1 -0
- package/dist/assets/scroll-to-bottom-button-BSCkDXet.js +1 -0
- package/dist/assets/{secrets-panel-CeovmJAu.js → secrets-panel-fyK3DrMo.js} +1 -1
- package/dist/assets/{sequenceDiagram-WJ2MYXX4-Cq7P3SPg.js → sequenceDiagram-WJ2MYXX4-09ej9W_c.js} +1 -1
- package/dist/assets/session-panel-CQR7EQYe.js +1 -0
- package/dist/assets/snippets-panel-C8pCQY6-.js +1 -0
- package/dist/assets/{stateDiagram-D77RDMKH-CO8GuJdh.js → stateDiagram-D77RDMKH-Dwreh_3X.js} +1 -1
- package/dist/assets/{stateDiagram-v2-MP3YSRHH-DA7CflqT.js → stateDiagram-v2-MP3YSRHH-CYctHUHC.js} +1 -1
- package/dist/assets/{swimlanes-42K2YHIH-Bkf4BWja.js → swimlanes-42K2YHIH-CqtUaFZN.js} +1 -1
- package/dist/assets/{swimlanesDiagram-VR7AAH4N-Bf0FHwi-.js → swimlanesDiagram-VR7AAH4N-BTvyGqcs.js} +1 -1
- package/dist/assets/{swiper-component-Dcb47cI1.js → swiper-component-BPjhKuFC.js} +1 -1
- package/dist/assets/{terminal-bvd8BLSi.js → terminal-CWmhjUVd.js} +2 -2
- package/dist/assets/{timeline-definition-24CTP7MA-CWdT681e.js → timeline-definition-24CTP7MA-DESfjZe6.js} +1 -1
- package/dist/assets/tracing-DHQdLJrw.js +1 -0
- package/dist/assets/{tracing-panel-AQUl8b58.js → tracing-panel-DkDpfzxp.js} +2 -2
- package/dist/assets/{useCellActionButton-DIiKKxoN.js → useCellActionButton-JBMxiVrN.js} +1 -1
- package/dist/assets/{vega-component-C5LY21OO.js → vega-component-C3dIfNSQ.js} +1 -1
- package/dist/assets/{vega-embed-container-C6Hr9CZj.js → vega-embed-container-DRnOQFW3.js} +1 -1
- package/dist/assets/{vennDiagram-4TSXK5OY-B3uJF3gV.js → vennDiagram-4TSXK5OY-DVP0MtbH.js} +1 -1
- package/dist/assets/{wardleyDiagram-VM6X3IG4-DGmcLh5J.js → wardleyDiagram-VM6X3IG4-Boyg2AlL.js} +1 -1
- package/dist/assets/{xychartDiagram-S5SC5T6Z-kFxqIAk2.js → xychartDiagram-S5SC5T6Z-6MNoagFi.js} +1 -1
- package/dist/index.html +6 -6
- package/package.json +1 -1
- package/src/components/editor/alerts/__tests__/connection-notice.test.tsx +186 -0
- package/src/components/editor/alerts/__tests__/startup-progress.test.tsx +185 -0
- package/src/components/editor/alerts/connection-notice.tsx +100 -54
- package/src/components/editor/alerts/startup-output.tsx +173 -0
- package/src/components/editor/alerts/startup-progress.tsx +204 -0
- package/src/components/editor/chrome/panels/__tests__/packages-panel.test.tsx +53 -4
- package/src/components/editor/chrome/panels/__tests__/sandbox-details.test.tsx +358 -0
- package/src/components/editor/chrome/panels/__tests__/sandbox-recovery.test.tsx +5 -2
- package/src/components/editor/chrome/panels/packages-panel.tsx +32 -21
- package/src/components/editor/chrome/panels/sandbox-details-state.ts +38 -0
- package/src/components/editor/chrome/panels/sandbox-panel.tsx +188 -131
- package/src/components/editor/chrome/panels/sandbox-toggle.tsx +52 -0
- package/src/components/editor/chrome/wrapper/app-chrome.tsx +7 -0
- package/src/components/editor/package-alert.tsx +112 -66
- package/src/core/alerts/__tests__/environment.test.ts +183 -0
- package/src/core/alerts/__tests__/state.test.tsx +240 -0
- package/src/core/alerts/environment.ts +57 -0
- package/src/core/alerts/state.ts +155 -99
- package/src/core/islands/bootstrap.ts +2 -1
- package/src/core/kernel/messages.ts +2 -2
- package/src/core/network/connection-notice.ts +45 -12
- package/src/core/network/connection.ts +19 -0
- package/src/core/network/useConnectionNotice.ts +53 -0
- package/src/core/packages/__tests__/useSandboxController.test.tsx +86 -5
- package/src/core/packages/sandbox-state.ts +56 -4
- package/src/core/packages/useSandboxController.ts +27 -7
- package/src/core/websocket/__tests__/useMarimoKernelConnection.hook.test.tsx +199 -8
- package/src/core/websocket/types.ts +1 -1
- package/src/core/websocket/useMarimoKernelConnection.tsx +31 -19
- package/src/stories/sandbox.stories.tsx +230 -50
- package/dist/assets/add-cell-with-ai-CSNC0MIy.js +0 -76
- package/dist/assets/ai-model-dropdown-Ct4CTWKe.js +0 -3
- package/dist/assets/cells-C0itXtA7.js +0 -220
- package/dist/assets/config-CBLBAU5c.js +0 -1
- package/dist/assets/dagre-Be6hV3Qt.js +0 -1
- package/dist/assets/dependency-graph-panel-DhGTFsO9.js +0 -5
- package/dist/assets/edit-page-Cw1A5Rhq.js +0 -176
- package/dist/assets/file-explorer-panel-BpklXFSu.js +0 -1
- package/dist/assets/has-D5vyh6J_.js +0 -1
- package/dist/assets/home-page-CN05bwXu.js +0 -4
- package/dist/assets/index-B8OSEJVD.css +0 -2
- package/dist/assets/index-CcaMC2ZX.js +0 -62
- package/dist/assets/packages-panel-cq-qnvM5.js +0 -1
- package/dist/assets/panels-DwxpnIFf.js +0 -33
- package/dist/assets/run-page-DVqnr-8x.js +0 -1
- package/dist/assets/scratchpad-panel-BT2lF-Gs.js +0 -1
- package/dist/assets/scroll-to-bottom-button-D4qWtyN8.js +0 -1
- package/dist/assets/session-panel-CGddxX8c.js +0 -1
- package/dist/assets/snippets-panel-UawnfExC.js +0 -1
- package/dist/assets/tracing-BbV840Cl.js +0 -1
|
@@ -42,6 +42,7 @@ vi.mock("@/core/runtime/config", async () => {
|
|
|
42
42
|
|
|
43
43
|
import { MockNotebook } from "@/__mocks__/notebook";
|
|
44
44
|
import { cellId } from "@/__tests__/branded";
|
|
45
|
+
import { alertAtom, getPackageAlert } from "@/core/alerts/state";
|
|
45
46
|
import { notebookAtom } from "@/core/cells/cells";
|
|
46
47
|
import { AppConfigSchema } from "@/core/config/config-schema";
|
|
47
48
|
import { ConnectionNotice } from "@/components/editor/alerts/connection-notice";
|
|
@@ -49,7 +50,7 @@ import { kernelStartupErrorAtom } from "@/core/errors/state";
|
|
|
49
50
|
import type { NotificationPayload } from "@/core/kernel/messages";
|
|
50
51
|
import { useRuntimeManager } from "@/core/runtime/config";
|
|
51
52
|
import { initialRunCompletedAtom } from "../../kernel/state";
|
|
52
|
-
import { connectionAtom } from "../../network/connection";
|
|
53
|
+
import { connectionAtom, startupProgressAtom } from "../../network/connection";
|
|
53
54
|
import type { SessionId } from "../../kernel/session";
|
|
54
55
|
import { WebSocketClosedReason, WebSocketState } from "../types";
|
|
55
56
|
import type { IConnectionTransport } from "../transports/transport";
|
|
@@ -306,7 +307,12 @@ describe("connection notice", () => {
|
|
|
306
307
|
|
|
307
308
|
it("keeps elapsed time across startup phases and leaves reconnection to the footer once cells are available", () => {
|
|
308
309
|
const { store, options, send } = renderNotice();
|
|
309
|
-
send({
|
|
310
|
+
send({
|
|
311
|
+
op: "startup-progress",
|
|
312
|
+
phase: "preparing-environment",
|
|
313
|
+
logs: "",
|
|
314
|
+
log_mode: "replace",
|
|
315
|
+
});
|
|
310
316
|
expect(
|
|
311
317
|
screen.queryByRole("region", { name: "Notebook startup" }),
|
|
312
318
|
).not.toBeInTheDocument();
|
|
@@ -324,8 +330,13 @@ describe("connection notice", () => {
|
|
|
324
330
|
}),
|
|
325
331
|
),
|
|
326
332
|
);
|
|
327
|
-
send({
|
|
328
|
-
|
|
333
|
+
send({
|
|
334
|
+
op: "startup-progress",
|
|
335
|
+
phase: "starting-kernel",
|
|
336
|
+
logs: "",
|
|
337
|
+
log_mode: "replace",
|
|
338
|
+
});
|
|
339
|
+
expect(screen.getByRole("status")).toHaveTextContent("Starting kernel");
|
|
329
340
|
expect(screen.getByText("Elapsed 35s")).toBeInTheDocument();
|
|
330
341
|
send({ op: "reconnected" });
|
|
331
342
|
expect(
|
|
@@ -342,11 +353,71 @@ describe("connection notice", () => {
|
|
|
342
353
|
).not.toBeInTheDocument();
|
|
343
354
|
});
|
|
344
355
|
|
|
356
|
+
it("restores startup output before appending live chunks and resets it for a new attempt", () => {
|
|
357
|
+
const { store, send } = renderNotice();
|
|
358
|
+
const snapshot = {
|
|
359
|
+
op: "startup-progress",
|
|
360
|
+
phase: "starting-kernel",
|
|
361
|
+
logs: "Downloading runtime\n",
|
|
362
|
+
log_mode: "replace",
|
|
363
|
+
} as const;
|
|
364
|
+
send(snapshot);
|
|
365
|
+
send(snapshot);
|
|
366
|
+
const connection = store.get(connectionAtom);
|
|
367
|
+
send({ ...snapshot, logs: "Loading kernel\n", log_mode: "append" });
|
|
368
|
+
expect(store.get(startupProgressAtom)).toEqual({
|
|
369
|
+
phase: "starting-kernel",
|
|
370
|
+
logs: "Downloading runtime\nLoading kernel\n",
|
|
371
|
+
});
|
|
372
|
+
expect(store.get(connectionAtom)).toBe(connection);
|
|
373
|
+
expect(getPackageAlert(store.get(alertAtom))).toBeNull();
|
|
374
|
+
|
|
375
|
+
send({ ...snapshot, phase: "preparing-environment", logs: "" });
|
|
376
|
+
expect(store.get(startupProgressAtom)).toEqual({
|
|
377
|
+
phase: "preparing-environment",
|
|
378
|
+
logs: "",
|
|
379
|
+
});
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
it("restores completed startup output without putting a connected kernel back into startup", async () => {
|
|
383
|
+
const { store, options, send } = renderNotice();
|
|
384
|
+
send({ op: "reconnected" });
|
|
385
|
+
send({
|
|
386
|
+
op: "startup-progress",
|
|
387
|
+
phase: "starting-kernel",
|
|
388
|
+
logs: "Kernel startup output\n",
|
|
389
|
+
log_mode: "replace",
|
|
390
|
+
});
|
|
391
|
+
expect(store.get(connectionAtom)).toEqual({ state: WebSocketState.OPEN });
|
|
392
|
+
expect(store.get(startupProgressAtom)).toEqual({
|
|
393
|
+
phase: "starting-kernel",
|
|
394
|
+
logs: "Kernel startup output\n",
|
|
395
|
+
});
|
|
396
|
+
act(() => vi.advanceTimersByTime(500));
|
|
397
|
+
expect(
|
|
398
|
+
screen.queryByRole("region", { name: "Notebook startup" }),
|
|
399
|
+
).not.toBeInTheDocument();
|
|
400
|
+
|
|
401
|
+
// A new transport starts from the next session's authoritative snapshot.
|
|
402
|
+
await act(async () => options.onOpen(new Event("open")));
|
|
403
|
+
expect(store.get(startupProgressAtom)).toBeNull();
|
|
404
|
+
});
|
|
405
|
+
|
|
345
406
|
it("does not flash a notice when startup finishes within the delay", () => {
|
|
346
407
|
const { send } = renderNotice();
|
|
347
|
-
send({
|
|
408
|
+
send({
|
|
409
|
+
op: "startup-progress",
|
|
410
|
+
phase: "preparing-environment",
|
|
411
|
+
logs: "",
|
|
412
|
+
log_mode: "replace",
|
|
413
|
+
});
|
|
348
414
|
act(() => vi.advanceTimersByTime(200));
|
|
349
|
-
send({
|
|
415
|
+
send({
|
|
416
|
+
op: "startup-progress",
|
|
417
|
+
phase: "starting-kernel",
|
|
418
|
+
logs: "",
|
|
419
|
+
log_mode: "replace",
|
|
420
|
+
});
|
|
350
421
|
act(() => vi.advanceTimersByTime(200));
|
|
351
422
|
expect(
|
|
352
423
|
screen.queryByRole("region", { name: "Notebook startup" }),
|
|
@@ -365,7 +436,7 @@ describe("connection notice", () => {
|
|
|
365
436
|
"keeps a %s failure available until the user retries",
|
|
366
437
|
async (phase, title) => {
|
|
367
438
|
const { store, transport, options, send } = renderNotice();
|
|
368
|
-
send({ op: "startup-progress", phase });
|
|
439
|
+
send({ op: "startup-progress", phase, logs: "", log_mode: "replace" });
|
|
369
440
|
const error = "A full diagnostic\nwith <stderr> details";
|
|
370
441
|
send({ op: "kernel-startup-error", error });
|
|
371
442
|
transport.readyState = WebSocket.CLOSED;
|
|
@@ -389,7 +460,12 @@ describe("connection notice", () => {
|
|
|
389
460
|
expect(
|
|
390
461
|
screen.queryByRole("button", { name: "Try again" }),
|
|
391
462
|
).not.toBeInTheDocument();
|
|
392
|
-
send({
|
|
463
|
+
send({
|
|
464
|
+
op: "startup-progress",
|
|
465
|
+
phase: "preparing-environment",
|
|
466
|
+
logs: "",
|
|
467
|
+
log_mode: "replace",
|
|
468
|
+
});
|
|
393
469
|
act(() => vi.advanceTimersByTime(500));
|
|
394
470
|
expect(screen.getByRole("status")).toHaveTextContent(
|
|
395
471
|
"Preparing environment",
|
|
@@ -398,3 +474,118 @@ describe("connection notice", () => {
|
|
|
398
474
|
},
|
|
399
475
|
);
|
|
400
476
|
});
|
|
477
|
+
|
|
478
|
+
it("replaces environment state from snapshots, then continues live progress", () => {
|
|
479
|
+
const store = createStore();
|
|
480
|
+
vi.mocked(useConnectionTransport).mockClear();
|
|
481
|
+
vi.mocked(useConnectionTransport).mockReturnValue(
|
|
482
|
+
makeTransport(WebSocket.OPEN),
|
|
483
|
+
);
|
|
484
|
+
vi.mocked(useRuntimeManager).mockReturnValue(
|
|
485
|
+
makeRuntimeManager() as unknown as ReturnType<typeof useRuntimeManager>,
|
|
486
|
+
);
|
|
487
|
+
renderConnectionHook(store);
|
|
488
|
+
const options = vi.mocked(useConnectionTransport).mock.calls.at(-1)?.[0];
|
|
489
|
+
function receive(data: NotificationPayload["data"]) {
|
|
490
|
+
act(() =>
|
|
491
|
+
options?.onMessage(
|
|
492
|
+
new MessageEvent("message", {
|
|
493
|
+
data: JSON.stringify({ op: data.op, data }),
|
|
494
|
+
}),
|
|
495
|
+
),
|
|
496
|
+
);
|
|
497
|
+
}
|
|
498
|
+
receive({
|
|
499
|
+
op: "environment-operation",
|
|
500
|
+
source: "kernel",
|
|
501
|
+
operation_id: "old",
|
|
502
|
+
action: "install",
|
|
503
|
+
status: { kind: "running" },
|
|
504
|
+
packages: { pandas: "running" },
|
|
505
|
+
logs: { pandas: "stale" },
|
|
506
|
+
log_mode: "append",
|
|
507
|
+
});
|
|
508
|
+
const operation = {
|
|
509
|
+
operation_id: "new",
|
|
510
|
+
action: "install",
|
|
511
|
+
source: "kernel",
|
|
512
|
+
status: { kind: "running" },
|
|
513
|
+
packages: { numpy: "running" },
|
|
514
|
+
logs: { numpy: "Downloading\n" },
|
|
515
|
+
} as const;
|
|
516
|
+
const serverOperation = {
|
|
517
|
+
...operation,
|
|
518
|
+
operation_id: "server",
|
|
519
|
+
action: "install",
|
|
520
|
+
source: "server",
|
|
521
|
+
status: { kind: "succeeded" },
|
|
522
|
+
packages: { numpy: "succeeded" },
|
|
523
|
+
logs: { numpy: "Server logs\n" },
|
|
524
|
+
} as const;
|
|
525
|
+
receive({
|
|
526
|
+
op: "environment-state",
|
|
527
|
+
source: "server",
|
|
528
|
+
state: {
|
|
529
|
+
restart_required: false,
|
|
530
|
+
operations: [serverOperation],
|
|
531
|
+
},
|
|
532
|
+
});
|
|
533
|
+
const snapshot = {
|
|
534
|
+
op: "environment-state",
|
|
535
|
+
source: "kernel",
|
|
536
|
+
state: { restart_required: false, operations: [operation] },
|
|
537
|
+
} as const;
|
|
538
|
+
// Receiving a snapshot twice must not duplicate logs.
|
|
539
|
+
receive({
|
|
540
|
+
...snapshot,
|
|
541
|
+
state: { ...snapshot.state, operations: [operation] },
|
|
542
|
+
});
|
|
543
|
+
receive({
|
|
544
|
+
...snapshot,
|
|
545
|
+
state: { ...snapshot.state, operations: [operation] },
|
|
546
|
+
});
|
|
547
|
+
receive({
|
|
548
|
+
op: "environment-operation",
|
|
549
|
+
operation_id: "new",
|
|
550
|
+
action: "install",
|
|
551
|
+
source: "kernel",
|
|
552
|
+
status: { kind: "failed", error: "Network unavailable" },
|
|
553
|
+
packages: { numpy: "running" },
|
|
554
|
+
logs: { numpy: "Failed\n" },
|
|
555
|
+
log_mode: "append",
|
|
556
|
+
});
|
|
557
|
+
expect(getPackageAlert(store.get(alertAtom))).toEqual({
|
|
558
|
+
...operation,
|
|
559
|
+
id: "new",
|
|
560
|
+
kind: "environment",
|
|
561
|
+
restartRequired: false,
|
|
562
|
+
status: { kind: "failed", error: "Network unavailable" },
|
|
563
|
+
logs: { numpy: "Downloading\nFailed\n" },
|
|
564
|
+
});
|
|
565
|
+
receive({
|
|
566
|
+
op: "environment-state",
|
|
567
|
+
source: "kernel",
|
|
568
|
+
state: {
|
|
569
|
+
restart_required: false,
|
|
570
|
+
operations: [],
|
|
571
|
+
},
|
|
572
|
+
});
|
|
573
|
+
// Clearing the active environment must not promote an old server success.
|
|
574
|
+
expect(getPackageAlert(store.get(alertAtom))).toBeNull();
|
|
575
|
+
expect(store.get(alertAtom).environments.server.operations).toEqual([
|
|
576
|
+
serverOperation,
|
|
577
|
+
]);
|
|
578
|
+
receive({
|
|
579
|
+
op: "environment-state",
|
|
580
|
+
source: "server",
|
|
581
|
+
state: {
|
|
582
|
+
restart_required: false,
|
|
583
|
+
operations: [],
|
|
584
|
+
},
|
|
585
|
+
});
|
|
586
|
+
expect(getPackageAlert(store.get(alertAtom))).toBeNull();
|
|
587
|
+
expect(store.get(alertAtom).environments).toEqual({
|
|
588
|
+
kernel: { restart_required: false, operations: [] },
|
|
589
|
+
server: { restart_required: false, operations: [] },
|
|
590
|
+
});
|
|
591
|
+
});
|
|
@@ -64,7 +64,7 @@ import type { SessionId } from "../kernel/session";
|
|
|
64
64
|
import { initialRunCompletedAtom, kernelStateAtom } from "../kernel/state";
|
|
65
65
|
import { type LayoutState, useLayoutActions } from "../layout/state";
|
|
66
66
|
import { kioskModeAtom } from "../mode";
|
|
67
|
-
import { connectionAtom } from "../network/connection";
|
|
67
|
+
import { connectionAtom, startupProgressAtom } from "../network/connection";
|
|
68
68
|
import type { RequestId } from "../network/DeferredRequestRegistry";
|
|
69
69
|
import { useRuntimeManager } from "../runtime/config";
|
|
70
70
|
import { SECRETS_REGISTRY } from "../secrets/request-registry";
|
|
@@ -222,8 +222,14 @@ export function useMarimoKernelConnection(opts: {
|
|
|
222
222
|
useDataSourceActions();
|
|
223
223
|
const { setLayoutData } = useLayoutActions();
|
|
224
224
|
const [connection, setConnection] = useAtom(connectionAtom);
|
|
225
|
+
const updateStartupProgress = useSetAtom(startupProgressAtom);
|
|
225
226
|
const { addBanner } = useBannersActions();
|
|
226
|
-
const {
|
|
227
|
+
const {
|
|
228
|
+
addMissingPackageAlert,
|
|
229
|
+
updateEnvironment,
|
|
230
|
+
setEnvironment,
|
|
231
|
+
addStartupLog,
|
|
232
|
+
} = useAlertActions();
|
|
227
233
|
const setKioskMode = useSetAtom(kioskModeAtom);
|
|
228
234
|
const setCapabilities = useSetAtom(capabilitiesAtom);
|
|
229
235
|
const runtimeManager = useRuntimeManager();
|
|
@@ -241,12 +247,18 @@ export function useMarimoKernelConnection(opts: {
|
|
|
241
247
|
case "reload":
|
|
242
248
|
reloadSafe();
|
|
243
249
|
return;
|
|
244
|
-
case "startup-progress":
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
250
|
+
case "startup-progress": {
|
|
251
|
+
const { phase } = msg.data;
|
|
252
|
+
updateStartupProgress(msg.data);
|
|
253
|
+
setConnection((previous) =>
|
|
254
|
+
previous.state === WebSocketState.OPEN ||
|
|
255
|
+
(previous.state === WebSocketState.CONNECTING &&
|
|
256
|
+
previous.phase === phase)
|
|
257
|
+
? previous
|
|
258
|
+
: { state: WebSocketState.CONNECTING, phase },
|
|
259
|
+
);
|
|
249
260
|
return;
|
|
261
|
+
}
|
|
250
262
|
case "kernel-ready": {
|
|
251
263
|
setKernelStartupError(null);
|
|
252
264
|
setConnection({ state: WebSocketState.OPEN });
|
|
@@ -366,26 +378,25 @@ export function useMarimoKernelConnection(opts: {
|
|
|
366
378
|
addBanner(msg.data);
|
|
367
379
|
return;
|
|
368
380
|
case "missing-package-alert":
|
|
369
|
-
|
|
381
|
+
addMissingPackageAlert({
|
|
370
382
|
...msg.data,
|
|
371
383
|
kind: "missing",
|
|
372
384
|
});
|
|
373
385
|
return;
|
|
374
|
-
case "
|
|
386
|
+
case "environment-operation":
|
|
375
387
|
if (
|
|
376
|
-
msg.data.source
|
|
377
|
-
msg.data.
|
|
378
|
-
msg.data.log_status !== "start" &&
|
|
379
|
-
Object.values(msg.data.packages).some(
|
|
380
|
-
(status) => status === "installed" || status === "restart-required",
|
|
381
|
-
)
|
|
388
|
+
msg.data.source === "kernel" &&
|
|
389
|
+
msg.data.status.kind !== "running"
|
|
382
390
|
) {
|
|
383
391
|
invalidatePackageData();
|
|
384
392
|
}
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
393
|
+
updateEnvironment(msg.data);
|
|
394
|
+
return;
|
|
395
|
+
case "environment-state":
|
|
396
|
+
setEnvironment(msg.data);
|
|
397
|
+
if (msg.data.source === "kernel") {
|
|
398
|
+
invalidatePackageData();
|
|
399
|
+
}
|
|
389
400
|
return;
|
|
390
401
|
case "startup-logs":
|
|
391
402
|
addStartupLog({
|
|
@@ -538,6 +549,7 @@ export function useMarimoKernelConnection(opts: {
|
|
|
538
549
|
* The transport is open; kernel-ready establishes session readiness.
|
|
539
550
|
*/
|
|
540
551
|
onOpen: async () => {
|
|
552
|
+
updateStartupProgress(null);
|
|
541
553
|
// If we are open, we can reset our reconnecting flag.
|
|
542
554
|
shouldTryReconnecting.current = true;
|
|
543
555
|
},
|