A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
refactor: rename WebSocketState to ConnectionState (#11168)
Rajveer Singh284fb95c8b5e
diff --git a/frontend/src/__tests__/mount.test.ts b/frontend/src/__tests__/mount.test.tsindex 24ed07f91e..ca96b30b47 100644--- a/frontend/src/__tests__/mount.test.ts+++ b/frontend/src/__tests__/mount.test.ts@@ -7,7 +7,7 @@ import { kioskModeAtom } from "@/core/mode";import { connectionAtom } from "@/core/network/connection";import { store } from "@/core/state/jotai";import { isStaticNotebook } from "@/core/static/static-state";-import { WebSocketState } from "@/core/websocket/types";+import { ConnectionState } from "@/core/websocket/types";import { pairPreviewAtom } from "@/core/config/pair";import { PAIR_PREVIEW } from "./fixtures/pair-preview";import { mount, visibleForTesting } from "../mount";@@ -59,7 +59,7 @@ describe("mount", () => {store.set(layoutStateAtom, initialLayoutState());store.set(kioskModeAtom, false);// Reset connection atom to initial state- store.set(connectionAtom, { state: WebSocketState.NOT_STARTED });+ store.set(connectionAtom, { state: ConnectionState.NOT_STARTED });});afterEach(() => {@@ -111,7 +111,7 @@ describe("mount", () => {);const connection = store.get(connectionAtom);- expect(connection.state).toBe(WebSocketState.CONNECTING);+ expect(connection.state).toBe(ConnectionState.CONNECTING);});it("should keep connection as NOT_STARTED when runtimeConfig has lazy=true", () => {@@ -124,7 +124,7 @@ describe("mount", () => {);const connection = store.get(connectionAtom);- expect(connection.state).toBe(WebSocketState.NOT_STARTED);+ expect(connection.state).toBe(ConnectionState.NOT_STARTED);});it("should keep connection as NOT_STARTED when no runtimeConfig is provided", () => {@@ -137,7 +137,7 @@ describe("mount", () => {);const connection = store.get(connectionAtom);- expect(connection.state).toBe(WebSocketState.NOT_STARTED);+ expect(connection.state).toBe(ConnectionState.NOT_STARTED);});it("should keep connection as NOT_STARTED for static notebooks even with lazy=false", () => {@@ -155,7 +155,7 @@ describe("mount", () => {);const connection = store.get(connectionAtom);- expect(connection.state).toBe(WebSocketState.NOT_STARTED);+ expect(connection.state).toBe(ConnectionState.NOT_STARTED);});});diff --git a/frontend/src/components/editor/actions/useRestartKernel.tsx b/frontend/src/components/editor/actions/useRestartKernel.tsxindex 59144d3278..517c2aef94 100644--- a/frontend/src/components/editor/actions/useRestartKernel.tsx+++ b/frontend/src/components/editor/actions/useRestartKernel.tsx@@ -5,7 +5,7 @@ import { useImperativeModal } from "@/components/modal/ImperativeModal";import { AlertDialogDestructiveAction } from "@/components/ui/alert-dialog";import { connectionAtom } from "@/core/network/connection";import { useRequestClient } from "@/core/network/requests";-import { WebSocketState } from "@/core/websocket/types";+import { ConnectionState } from "@/core/websocket/types";import { reloadSafe } from "@/utils/reload-safe";export function useRestartKernel() {@@ -22,7 +22,7 @@ export function useRestartKernel() {confirmAction: (<AlertDialogDestructiveActiononClick={async () => {- setConnection({ state: WebSocketState.CLOSING });+ setConnection({ state: ConnectionState.CLOSING });await sendRestart();reloadSafe();}}diff --git a/frontend/src/components/editor/alerts/__tests__/connection-notice.test.tsx b/frontend/src/components/editor/alerts/__tests__/connection-notice.test.tsxindex 603c6dfc98..216644526b 100644--- a/frontend/src/components/editor/alerts/__tests__/connection-notice.test.tsx+++ b/frontend/src/components/editor/alerts/__tests__/connection-notice.test.tsx@@ -11,7 +11,7 @@ import { AppConfigSchema } from "@/core/config/config-schema";import { kernelStartupErrorAtom } from "@/core/errors/state";import { connectionAtom } from "@/core/network/connection";import { sandboxAtom, sandboxSyncAtom } from "@/core/packages/sandbox-state";-import { WebSocketClosedReason, WebSocketState } from "@/core/websocket/types";+import { WebSocketClosedReason, ConnectionState } from "@/core/websocket/types";import { chromeAtom } from "../../chrome/state";import { runtimeDetailsExpandedAtom } from "../../chrome/panels/runtime-details-state";import { ConnectionNotice } from "../connection-notice";@@ -31,7 +31,7 @@ function mount({filename: "notebook.py",});store.set(connectionAtom, {- state: WebSocketState.CONNECTING,+ state: ConnectionState.CONNECTING,phase: "preparing-environment",});if (existingCells) {@@ -64,13 +64,13 @@ it("shows both stages in an empty notebook, checks them off, then dismisses Readexpect(steps.getByText("Start kernel")).toBeInTheDocument();act(() =>store.set(connectionAtom, {- state: WebSocketState.CONNECTING,+ state: ConnectionState.CONNECTING,phase: "starting-kernel",}),);expect(steps.getByText("Environment prepared")).toBeInTheDocument();expect(steps.getByText("Starting kernel")).toBeInTheDocument();- act(() => store.set(connectionAtom, { state: WebSocketState.OPEN }));+ act(() => store.set(connectionAtom, { state: ConnectionState.OPEN }));expect(screen.getByRole("heading", { name: "Your notebook is ready" }),).toBeInTheDocument();@@ -89,7 +89,7 @@ it("uses the shared kernel stage for an ordinary connection and dismisses it wheconst store = mount();act(() => {store.set(sandboxAtom, null);- store.set(connectionAtom, { state: WebSocketState.CONNECTING });+ store.set(connectionAtom, { state: ConnectionState.CONNECTING });});act(() => vi.advanceTimersByTime(500));const stages = within(@@ -99,20 +99,20 @@ it("uses the shared kernel stage for an ordinary connection and dismisses it whe);expect(stages.getAllByRole("listitem")).toHaveLength(1);expect(stages.getByText("Starting kernel")).toBeVisible();- act(() => store.set(connectionAtom, { state: WebSocketState.OPEN }));+ act(() => store.set(connectionAtom, { state: ConnectionState.OPEN }));expect(screen.queryByRole("region", { name: "Notebook startup" })).toBeNull();});it("shows connection status until a sandbox reports its startup phase", () => {const store = mount();- act(() => store.set(connectionAtom, { state: WebSocketState.CONNECTING }));+ act(() => store.set(connectionAtom, { state: ConnectionState.CONNECTING }));act(() => vi.advanceTimersByTime(500));expect(screen.getByRole("heading", { name: "Connecting…" })).toBeVisible();expect(screen.queryByRole("list")).not.toBeInTheDocument();act(() =>store.set(connectionAtom, {- state: WebSocketState.CLOSED,+ state: ConnectionState.CLOSED,code: WebSocketClosedReason.KERNEL_STARTUP_ERROR,reason: "Kernel startup failed",}),@@ -124,7 +124,7 @@ it("shows connection status until a sandbox reports its startup phase", () => {act(() =>store.set(connectionAtom, {- state: WebSocketState.CONNECTING,+ state: ConnectionState.CONNECTING,phase: "preparing-environment",}),);@@ -158,7 +158,7 @@ it("shows ordinary environment preparation failures in the kernel stage", () =>"Configured Python environment is missing",);store.set(connectionAtom, {- state: WebSocketState.CLOSED,+ state: ConnectionState.CLOSED,phase: "preparing-environment",code: WebSocketClosedReason.KERNEL_STARTUP_ERROR,reason: "Kernel startup failed",@@ -208,7 +208,7 @@ it("opens Packages from the minimal inline status when cells exist", () => {isSidebarOpen: true,selectedPanel: "packages",});- act(() => store.set(connectionAtom, { state: WebSocketState.OPEN }));+ act(() => store.set(connectionAtom, { state: ConnectionState.OPEN }));expect(screen.getByRole("status")).toHaveTextContent(/^Ready$/);});@@ -217,7 +217,7 @@ it("uses an inline notice for an existing ordinary notebook, opens collapsed detconst store = mount({ existingCells: true, onRetry });act(() => {store.set(sandboxAtom, null);- store.set(connectionAtom, { state: WebSocketState.CONNECTING });+ store.set(connectionAtom, { state: ConnectionState.CONNECTING });store.set(runtimeDetailsExpandedAtom, false);});act(() => vi.advanceTimersByTime(500));@@ -232,7 +232,7 @@ it("uses an inline notice for an existing ordinary notebook, opens collapsed detexpect(store.get(runtimeDetailsExpandedAtom)).toBe(true);act(() =>store.set(connectionAtom, {- state: WebSocketState.CLOSED,+ state: ConnectionState.CLOSED,code: WebSocketClosedReason.KERNEL_STARTUP_ERROR,reason: "Kernel startup failed",}),@@ -244,7 +244,7 @@ it("uses an inline notice for an existing ordinary notebook, opens collapsed det).toBeVisible();fireEvent.click(screen.getByRole("button", { name: "Try again" }));expect(onRetry).toHaveBeenCalledOnce();- act(() => store.set(connectionAtom, { state: WebSocketState.OPEN }));+ act(() => store.set(connectionAtom, { state: ConnectionState.OPEN }));expect(screen.queryByRole("region", { name: "Notebook startup" })).toBeNull();expect(statusRow).not.toBeInTheDocument();});@@ -264,7 +264,7 @@ it.each([store.set(sandboxAtom, null);}store.set(connectionAtom, {- state: WebSocketState.CONNECTING,+ state: ConnectionState.CONNECTING,phase: "starting-kernel",});});@@ -276,7 +276,7 @@ it.each([act(() => {store.set(kernelStartupErrorAtom, "Could not import the runtime");store.set(connectionAtom, {- state: WebSocketState.CLOSED,+ state: ConnectionState.CLOSED,phase: "starting-kernel",code: WebSocketClosedReason.KERNEL_STARTUP_ERROR,reason: "Kernel startup failed",@@ -301,7 +301,7 @@ it.each([it("does not flash Ready for a startup that finished before the notice appeared", () => {const store = mount({ existingCells: true });act(() => vi.advanceTimersByTime(200));- act(() => store.set(connectionAtom, { state: WebSocketState.OPEN }));+ act(() => store.set(connectionAtom, { state: ConnectionState.OPEN }));expect(screen.queryByRole("status")).not.toBeInTheDocument();act(() => vi.advanceTimersByTime(2000));expect(screen.queryByRole("status")).not.toBeInTheDocument();@@ -310,11 +310,11 @@ it("does not flash Ready for a startup that finished before the notice appeared"it("replaces Ready with a new attempt and never dismisses a failure", () => {const store = mount();act(() => vi.advanceTimersByTime(500));- act(() => store.set(connectionAtom, { state: WebSocketState.OPEN }));+ act(() => store.set(connectionAtom, { state: ConnectionState.OPEN }));act(() => vi.advanceTimersByTime(1000));act(() =>store.set(connectionAtom, {- state: WebSocketState.CONNECTING,+ state: ConnectionState.CONNECTING,phase: "starting-kernel",}),);@@ -322,7 +322,7 @@ it("replaces Ready with a new attempt and never dismisses a failure", () => {expect(screen.getByText("Starting kernel")).toBeInTheDocument();act(() =>store.set(connectionAtom, {- state: WebSocketState.CLOSED,+ state: ConnectionState.CLOSED,code: WebSocketClosedReason.KERNEL_STARTUP_ERROR,phase: "starting-kernel",reason: "Kernel startup failed",@@ -337,7 +337,7 @@ it("replaces Ready with a new attempt and never dismisses a failure", () => {it("shows a sync as a single operation, without pretending to restart the kernel", () => {const store = mount({ existingCells: true });act(() => {- store.set(connectionAtom, { state: WebSocketState.OPEN });+ store.set(connectionAtom, { state: ConnectionState.OPEN });store.set(sandboxSyncAtom, { kind: "running" });});act(() => vi.advanceTimersByTime(500));@@ -369,7 +369,7 @@ it("restores syncing in the existing status and stays quiet for a completed snap},}));act(() => {- store.set(connectionAtom, { state: WebSocketState.OPEN });+ store.set(connectionAtom, { state: ConnectionState.OPEN });restore({ kind: "succeeded" });});act(() => vi.advanceTimersByTime(2000));diff --git a/frontend/src/components/editor/alerts/connection-notice.tsx b/frontend/src/components/editor/alerts/connection-notice.tsxindex 56f52e6605..bc67a7783c 100644--- a/frontend/src/components/editor/alerts/connection-notice.tsx+++ b/frontend/src/components/editor/alerts/connection-notice.tsx@@ -8,7 +8,7 @@ import type { AppConfig } from "@/core/config/config-schema";import { connectionAtom } from "@/core/network/connection";import { useConnectionNotice } from "@/core/network/useConnectionNotice";import { sandboxAtom } from "@/core/packages/sandbox-state";-import { WebSocketState } from "@/core/websocket/types";+import { ConnectionState } from "@/core/websocket/types";import { useInterval } from "@/hooks/useInterval";import { cn } from "@/utils/cn";import { runtimeDetailsExpandedAtom } from "../chrome/panels/runtime-details-state";@@ -42,7 +42,7 @@ export const ConnectionNotice = ({// Reconnection uses the footer indicator while existing cells stay visible.const reconnecting =- connection.state === WebSocketState.CONNECTING &&+ connection.state === ConnectionState.CONNECTING &&connection.phase === "reconnecting";const openDetails = () => {diff --git a/frontend/src/components/editor/app-container.tsx b/frontend/src/components/editor/app-container.tsxindex 49a5a052bd..d26f0ada67 100644--- a/frontend/src/components/editor/app-container.tsx+++ b/frontend/src/components/editor/app-container.tsx@@ -7,7 +7,7 @@ import { PyodideLoader } from "@/core/wasm/PyodideLoader";import {type ConnectionStatus,WebSocketClosedReason,- WebSocketState,+ ConnectionState,} from "@/core/websocket/types";import { cn } from "@/utils/cn";import { DynamicFavicon } from "./dynamic-favicon";@@ -47,7 +47,7 @@ export const AppContainer: React.FC<PropsWithChildren<Props>> = ({data-connection-state={connectionState}className={cn("mathjax_ignore",- connection.state === WebSocketState.CLOSED &&+ connection.state === ConnectionState.CLOSED &&connection.code !==WebSocketClosedReason.KERNEL_STARTUP_ERROR &&"disconnected",diff --git a/frontend/src/components/editor/boundary/__tests__/ErrorBoundary.test.tsx b/frontend/src/components/editor/boundary/__tests__/ErrorBoundary.test.tsxindex f98025b9d5..b7dd5dbd7d 100644--- a/frontend/src/components/editor/boundary/__tests__/ErrorBoundary.test.tsx+++ b/frontend/src/components/editor/boundary/__tests__/ErrorBoundary.test.tsx@@ -14,7 +14,7 @@ import { requestClientAtom } from "@/core/network/requests";import type { EnvironmentInfo } from "@/core/network/types";import { filenameAtom } from "@/core/saving/file-state";import { store } from "@/core/state/jotai";-import { WebSocketState } from "@/core/websocket/types";+import { ConnectionState } from "@/core/websocket/types";import { ErrorBoundary } from "../ErrorBoundary";vi.mock("@/utils/copy", () => ({@@ -144,7 +144,7 @@ function resetSharedState() {store.set(requestClientAtom, null);store.set(notebookAtom, initialNotebookState());store.set(viewStateAtom, { mode: "edit", cellAnchor: null });- store.set(connectionAtom, { state: WebSocketState.OPEN });+ store.set(connectionAtom, { state: ConnectionState.OPEN });store.set(filenameAtom, "/project/example.py");}diff --git a/frontend/src/components/editor/cell/CreateCellButton.tsx b/frontend/src/components/editor/cell/CreateCellButton.tsxindex 9ae14990f2..a81145eaec 100644--- a/frontend/src/components/editor/cell/CreateCellButton.tsx+++ b/frontend/src/components/editor/cell/CreateCellButton.tsx@@ -17,7 +17,7 @@ import {getConnectionTooltip,isAppInteractionDisabled,} from "@/core/websocket/connection-utils";-import type { WebSocketState } from "@/core/websocket/types";+import type { ConnectionState } from "@/core/websocket/types";import { cn } from "@/utils/cn";import { Tooltip } from "../../ui/tooltip";import { MarkdownIcon, PythonIcon } from "./code/icons";@@ -28,7 +28,7 @@ export const CreateCellButton = ({tooltipContent,oneClickShortcut,}: {- connectionState: WebSocketState;+ connectionState: ConnectionState;tooltipContent: React.ReactNode;onClick: ((opts: { code: string; hideCode?: boolean }) => void) | undefined;oneClickShortcut: "shift" | "mod";diff --git a/frontend/src/components/editor/cell/DeleteButton.tsx b/frontend/src/components/editor/cell/DeleteButton.tsxindex 9944034d41..b6c3412339 100644--- a/frontend/src/components/editor/cell/DeleteButton.tsx+++ b/frontend/src/components/editor/cell/DeleteButton.tsx@@ -6,7 +6,7 @@ import {getConnectionTooltip,isAppInteractionDisabled,} from "@/core/websocket/connection-utils";-import type { WebSocketState } from "@/core/websocket/types";+import type { ConnectionState } from "@/core/websocket/types";import { cn } from "@/utils/cn";import { Events } from "@/utils/events";import { Button } from "../../ui/button";@@ -14,7 +14,7 @@ import { Tooltip } from "../../ui/tooltip";export const DeleteButton = (props: {status: RuntimeState;- connectionState: WebSocketState;+ connectionState: ConnectionState;onClick?: (e: React.MouseEvent<HTMLButtonElement>) => void;}): JSX.Element => {const { status, connectionState, onClick } = props;diff --git a/frontend/src/components/editor/cell/RunButton.tsx b/frontend/src/components/editor/cell/RunButton.tsxindex fc8b56d2d7..04284ac2ca 100644--- a/frontend/src/components/editor/cell/RunButton.tsx+++ b/frontend/src/components/editor/cell/RunButton.tsx@@ -6,7 +6,7 @@ import {getConnectionTooltip,isAppInteractionDisabled,} from "@/core/websocket/connection-utils";-import type { WebSocketState } from "@/core/websocket/types";+import type { ConnectionState } from "@/core/websocket/types";import { renderShortcut } from "../../shortcuts/renderShortcut";import { ToolbarItem } from "./toolbar";@@ -16,7 +16,7 @@ function computeColor({loading,inactive,}: {- connectionState: WebSocketState;+ connectionState: ConnectionState;needsRun: boolean;loading: boolean;inactive: boolean;@@ -37,7 +37,7 @@ export const RunButton = (props: {edited: boolean;status: RuntimeState;needsRun: boolean;- connectionState: WebSocketState;+ connectionState: ConnectionState;config: CellConfig;onClick?: () => void;}): JSX.Element => {diff --git a/frontend/src/components/editor/cell/StopButton.tsx b/frontend/src/components/editor/cell/StopButton.tsxindex 6cb2af8077..2c08164f72 100644--- a/frontend/src/components/editor/cell/StopButton.tsx+++ b/frontend/src/components/editor/cell/StopButton.tsx@@ -4,7 +4,7 @@ import type { JSX } from "react";import { useRequestClient } from "@/core/network/requests";import type { RuntimeState } from "@/core/network/types";import { isAppInteractionDisabled } from "@/core/websocket/connection-utils";-import type { WebSocketState } from "@/core/websocket/types";+import type { ConnectionState } from "@/core/websocket/types";import { Functions } from "@/utils/functions";import { renderShortcut } from "../../shortcuts/renderShortcut";import { ToolbarItem } from "./toolbar";@@ -12,7 +12,7 @@ import { useShouldShowInterrupt } from "./useShouldShowInterrupt";export const StopButton = (props: {status: RuntimeState;- connectionState: WebSocketState;+ connectionState: ConnectionState;}): JSX.Element => {const { connectionState, status } = props;const { sendInterrupt } = useRequestClient();diff --git a/frontend/src/components/editor/chrome/components/__tests__/feedback-button.test.tsx b/frontend/src/components/editor/chrome/components/__tests__/feedback-button.test.tsxindex b5307c2f99..0007b17f1b 100644--- a/frontend/src/components/editor/chrome/components/__tests__/feedback-button.test.tsx+++ b/frontend/src/components/editor/chrome/components/__tests__/feedback-button.test.tsx@@ -14,7 +14,7 @@ import { requestClientAtom } from "@/core/network/requests";import type { EnvironmentInfo } from "@/core/network/types";import { filenameAtom } from "@/core/saving/file-state";import { store } from "@/core/state/jotai";-import { WebSocketState } from "@/core/websocket/types";+import { ConnectionState } from "@/core/websocket/types";import * as copyModule from "@/utils/copy";import { FeedbackModal } from "../feedback-button";@@ -53,7 +53,7 @@ describe("FeedbackModal issue reporting", () => {localStorage.clear();store.set(requestClientAtom, MockRequestClient.create());store.set(viewStateAtom, { mode: "edit", cellAnchor: null });- store.set(connectionAtom, { state: WebSocketState.OPEN });+ store.set(connectionAtom, { state: ConnectionState.OPEN });store.set(filenameAtom, "/project/example.py");});@@ -156,7 +156,7 @@ describe("FeedbackModal issue reporting", () => {});it("disables include code and explains why when disconnected", async () => {- store.set(connectionAtom, { state: WebSocketState.CONNECTING });+ store.set(connectionAtom, { state: ConnectionState.CONNECTING });store.set(requestClientAtom,MockRequestClient.create({@@ -244,7 +244,7 @@ describe("FeedbackModal issue reporting", () => {"marimo:issue-report:include-code",JSON.stringify(true),);- store.set(connectionAtom, { state: WebSocketState.CONNECTING });+ store.set(connectionAtom, { state: ConnectionState.CONNECTING });store.set(requestClientAtom, null);render(<FeedbackModal onClose={vi.fn()} />, { wrapper });diff --git a/frontend/src/components/editor/chrome/components/feedback-button.tsx b/frontend/src/components/editor/chrome/components/feedback-button.tsxindex ba1737a77e..cacd17f5fc 100644--- a/frontend/src/components/editor/chrome/components/feedback-button.tsx+++ b/frontend/src/components/editor/chrome/components/feedback-button.tsx@@ -39,7 +39,7 @@ import { connectionAtom } from "@/core/network/connection";import { requestClientAtom } from "@/core/network/requests";import { filenameAtom } from "@/core/saving/file-state";import { store } from "@/core/state/jotai";-import { WebSocketState } from "@/core/websocket/types";+import { ConnectionState } from "@/core/websocket/types";import { useAsyncData } from "@/hooks/useAsyncData";import { useLocalStorage } from "@/hooks/useLocalStorage";import { cn } from "@/utils/cn";@@ -78,7 +78,7 @@ function getNotebookSourceUnavailableReason(args: {hasRequestClient: boolean;filename: string | null;codeAvailable: boolean;- connectionState: WebSocketState;+ connectionState: ConnectionState;}): string | undefined {if (!args.hasRequestClient) {return "Notebook source is unavailable.";@@ -89,7 +89,7 @@ function getNotebookSourceUnavailableReason(args: {if (!args.codeAvailable) {return "Notebook source is hidden in this view.";}- if (args.connectionState !== WebSocketState.OPEN) {+ if (args.connectionState !== ConnectionState.OPEN) {return "Connect the notebook to include its source.";}return undefined;diff --git a/frontend/src/components/editor/chrome/panels/__tests__/packages-panel.test.tsx b/frontend/src/components/editor/chrome/panels/__tests__/packages-panel.test.tsxindex a5df5684fc..1d7f44a2c7 100644--- a/frontend/src/components/editor/chrome/panels/__tests__/packages-panel.test.tsx+++ b/frontend/src/components/editor/chrome/panels/__tests__/packages-panel.test.tsx@@ -22,7 +22,7 @@ import { withPackageInvalidation } from "@/core/packages/package-data";import { useInstallPackages } from "@/core/packages/useInstallPackage";import { sandboxAtom, sandboxSyncAtom } from "@/core/packages/sandbox-state";import { store } from "@/core/state/jotai";-import { WebSocketState } from "@/core/websocket/types";+import { ConnectionState } from "@/core/websocket/types";import PackagesPanel from "../packages-panel";import { PanelSectionProvider } from "../panel-context";import { RuntimeStatusToggle } from "../runtime-status-toggle";@@ -71,7 +71,7 @@ function renderPanel(? { backend: context.backend, manifest: "", filename: "notebook.py" }: null,);- store.set(connectionAtom, { state: WebSocketState.OPEN });+ store.set(connectionAtom, { state: ConnectionState.OPEN });store.set(sandboxSyncAtom, { kind: "succeeded" });const getPackageList = vi.fn().mockResolvedValue({ packages: [] });const client = MockRequestClient.create({@@ -186,7 +186,7 @@ it("refreshes an open panel when a package is installed elsewhere, after installmanifest: "",filename: "notebook.py",});- store.set(connectionAtom, { state: WebSocketState.OPEN });+ store.set(connectionAtom, { state: ConnectionState.OPEN });store.set(sandboxSyncAtom, { kind: "succeeded" });store.set(requestClientAtom, withPackageInvalidation(client));function InstallElsewhere() {@@ -221,7 +221,7 @@ it("refreshes an open panel when a package is installed elsewhere, after install});it("keeps packages and the install draft visible while blocking mutations during sync", async () => {- store.set(connectionAtom, { state: WebSocketState.OPEN });+ store.set(connectionAtom, { state: ConnectionState.OPEN });renderPanel({ kind: "sandbox", backend: "pixi" }, populatedTree);await screen.findByRole("treeitem", { name: /polars/ });const input = screen.getByPlaceholderText("Add packages to pixi sandbox...");diff --git a/frontend/src/components/editor/chrome/panels/__tests__/runtime-details.test.tsx b/frontend/src/components/editor/chrome/panels/__tests__/runtime-details.test.tsxindex 6cbcb6bbd0..daeb6c5f18 100644--- a/frontend/src/components/editor/chrome/panels/__tests__/runtime-details.test.tsx+++ b/frontend/src/components/editor/chrome/panels/__tests__/runtime-details.test.tsx@@ -11,7 +11,7 @@ import { kernelStartupErrorAtom } from "@/core/errors/state";import { connectionAtom, startupProgressAtom } from "@/core/network/connection";import { requestClientAtom } from "@/core/network/requests";import { sandboxAtom } from "@/core/packages/sandbox-state";-import { WebSocketClosedReason, WebSocketState } from "@/core/websocket/types";+import { WebSocketClosedReason, ConnectionState } from "@/core/websocket/types";import PackagesPanel from "../packages-panel";import { PanelSectionProvider } from "../panel-context";import { RuntimeStatusToggle } from "../runtime-status-toggle";@@ -43,8 +43,8 @@ function mount({store.set(connectionAtom,preparing- ? { state: WebSocketState.CONNECTING, phase: "preparing-environment" }- : { state: WebSocketState.OPEN },+ ? { state: ConnectionState.CONNECTING, phase: "preparing-environment" }+ : { state: ConnectionState.OPEN },);store.set(alertAtom, (state) => ({...state,@@ -287,11 +287,11 @@ it.each([false, true])(log_mode: "replace",});store.set(connectionAtom, {- state: WebSocketState.CONNECTING,+ state: ConnectionState.CONNECTING,phase: "starting-kernel",});});- act(() => store.set(connectionAtom, { state: WebSocketState.OPEN }));+ act(() => store.set(connectionAtom, { state: ConnectionState.OPEN }));await screen.findByText("numpy");expect(toggle).toHaveAttribute("aria-expanded", String(inspecting));if (!inspecting) {@@ -322,7 +322,7 @@ it("opens a startup error even after collapsing preparation and keeps both step});store.set(kernelStartupErrorAtom, "Could not import the runtime");store.set(connectionAtom, {- state: WebSocketState.CLOSED,+ state: ConnectionState.CLOSED,phase: "starting-kernel",code: WebSocketClosedReason.KERNEL_STARTUP_ERROR,reason: "Kernel startup failed",@@ -355,7 +355,7 @@ it.each(["uv", "pixi"] as const)("shows connection status and errors before the %s startup phase arrives",(backend) => {const { store } = mount({ backend, preparing: true });- act(() => store.set(connectionAtom, { state: WebSocketState.CONNECTING }));+ act(() => store.set(connectionAtom, { state: ConnectionState.CONNECTING }));const details = within(screen.getByRole("region", { name: "Sandbox details" }),);@@ -365,7 +365,7 @@ it.each(["uv", "pixi"] as const)(act(() => {store.set(kernelStartupErrorAtom, "Kernel process exited unexpectedly");store.set(connectionAtom, {- state: WebSocketState.CLOSED,+ state: ConnectionState.CLOSED,code: WebSocketClosedReason.KERNEL_STARTUP_ERROR,reason: "Kernel startup failed",});@@ -397,7 +397,7 @@ it("uses the same disclosure for an existing environment and updates it throughexpect(within(details).getAllByRole("listitem")).toHaveLength(1);expect(within(details).queryByRole("button", { name: "Sync" })).toBeNull();- act(() => store.set(connectionAtom, { state: WebSocketState.CONNECTING }));+ act(() => store.set(connectionAtom, { state: ConnectionState.CONNECTING }));expect(toggle).toHaveTextContent(/^Runtime$/);expect(within(toggle).getByRole("status")).toHaveAccessibleName("Connecting…",@@ -407,7 +407,7 @@ it("uses the same disclosure for an existing environment and updates it throughexpect(details).not.toBeVisible();act(() =>store.set(connectionAtom, {- state: WebSocketState.CLOSED,+ state: ConnectionState.CLOSED,code: WebSocketClosedReason.KERNEL_STARTUP_ERROR,reason: "Kernel startup failed",}),@@ -422,7 +422,7 @@ it("uses the same disclosure for an existing environment and updates it through"Runtime details, Kernel failed to start",);- act(() => store.set(connectionAtom, { state: WebSocketState.NOT_STARTED }));+ act(() => store.set(connectionAtom, { state: ConnectionState.NOT_STARTED }));expect(toggle).toHaveTextContent(/^Runtime$/);expect(within(toggle).getByRole("status")).toHaveAccessibleName("Kernel not connected",diff --git a/frontend/src/components/editor/chrome/panels/__tests__/sandbox-recovery.test.tsx b/frontend/src/components/editor/chrome/panels/__tests__/sandbox-recovery.test.tsxindex 5be243a7e3..12135601ba 100644--- a/frontend/src/components/editor/chrome/panels/__tests__/sandbox-recovery.test.tsx+++ b/frontend/src/components/editor/chrome/panels/__tests__/sandbox-recovery.test.tsx@@ -24,7 +24,7 @@ import {} from "@/core/packages/sandbox-state";import { filenameAtom } from "@/core/saving/file-state";import { store } from "@/core/state/jotai";-import { WebSocketClosedReason, WebSocketState } from "@/core/websocket/types";+import { WebSocketClosedReason, ConnectionState } from "@/core/websocket/types";import { chromeAtom } from "../../state";import PackagesPanel from "../packages-panel";import { PanelSectionProvider } from "../panel-context";@@ -52,7 +52,7 @@ vi.mock("@/plugins/impl/code/LazyAnyLanguageCodeMirror", () => ({const manifest ='dependencies = ["numpy==0.0.0"]\n\n[tool.custom]\nlabel = "experiment"\n';const failed = {- state: WebSocketState.CLOSED,+ state: ConnectionState.CLOSED,code: WebSocketClosedReason.KERNEL_STARTUP_ERROR,phase: "preparing-environment",reason: "Kernel startup failed",@@ -117,7 +117,7 @@ it("keeps a whole-manifest repair open through failure and closes only after synconst reconnect = vi.fn(async () => {store.set(kernelStartupErrorAtom, null);store.set(connectionAtom, {- state: WebSocketState.CONNECTING,+ state: ConnectionState.CONNECTING,phase: "preparing-environment",});});@@ -161,7 +161,7 @@ it("keeps a whole-manifest repair open through failure and closes only after syn);fireEvent.click(dialog.getByRole("button", { name: "Sync" }));await waitFor(() => expect(reconnect).toHaveBeenCalledTimes(2));- act(() => store.set(connectionAtom, { state: WebSocketState.OPEN }));+ act(() => store.set(connectionAtom, { state: ConnectionState.OPEN }));await waitFor(() =>expect(screen.queryByRole("dialog")).not.toBeInTheDocument(),);diff --git a/frontend/src/components/editor/chrome/wrapper/footer-items/machine-stats.tsx b/frontend/src/components/editor/chrome/wrapper/footer-items/machine-stats.tsxindex f73dd8e276..8aba5c50ca 100644--- a/frontend/src/components/editor/chrome/wrapper/footer-items/machine-stats.tsx+++ b/frontend/src/components/editor/chrome/wrapper/footer-items/machine-stats.tsx@@ -10,7 +10,7 @@ import { connectionAtom } from "@/core/network/connection";import { useRequestClient } from "@/core/network/requests";import type { UsageResponse } from "@/core/network/types";import { isWasm } from "@/core/wasm/utils";-import { WebSocketState } from "@/core/websocket/types";+import { ConnectionState } from "@/core/websocket/types";import { useAsyncData } from "@/hooks/useAsyncData";import { useInterval } from "@/hooks/useInterval";import { cn } from "@/utils/cn";@@ -29,7 +29,7 @@ export const MachineStats: React.FC = () => {if (isWasm()) {return null;}- if (connection.state !== WebSocketState.OPEN) {+ if (connection.state !== ConnectionState.OPEN) {return null;}return getUsageStats();diff --git a/frontend/src/components/editor/controls/Controls.tsx b/frontend/src/components/editor/controls/Controls.tsxindex fff83e0e43..68ae0f97f5 100644--- a/frontend/src/components/editor/controls/Controls.tsx+++ b/frontend/src/components/editor/controls/Controls.tsx@@ -21,7 +21,7 @@ import {getConnectionTooltip,isAppInteractionDisabled,} from "@/core/websocket/connection-utils";-import { WebSocketState } from "@/core/websocket/types";+import { ConnectionState } from "@/core/websocket/types";import { cn } from "@/utils/cn";import { Functions } from "@/utils/functions";import {@@ -43,7 +43,7 @@ interface ControlsProps {onTogglePresenting: () => void;onInterrupt: () => void;onRun: () => void;- connectionState: WebSocketState;+ connectionState: ConnectionState;running: boolean;appConfig: AppConfig;}@@ -60,7 +60,7 @@ export const Controls = ({const undoLabel = useAtomValue(undoLabelAtom);const needsRun = useAtomValue(needsRunAtom);const { undoDeleteCell } = useCellActions();- const closed = connectionState === WebSocketState.CLOSED;+ const closed = connectionState === ConnectionState.CLOSED;let undoControl: JSX.Element | null = null;if (!closed && undoAvailable) {diff --git a/frontend/src/components/editor/controls/__tests__/notebook-menu-dropdown.test.tsx b/frontend/src/components/editor/controls/__tests__/notebook-menu-dropdown.test.tsxindex 286e072b10..40672be6b9 100644--- a/frontend/src/components/editor/controls/__tests__/notebook-menu-dropdown.test.tsx+++ b/frontend/src/components/editor/controls/__tests__/notebook-menu-dropdown.test.tsx@@ -25,7 +25,7 @@ import { requestClientAtom } from "@/core/network/requests";import { filenameAtom } from "@/core/saving/file-state";import { store } from "@/core/state/jotai";import { isWasm } from "@/core/wasm/utils";-import { WebSocketState } from "@/core/websocket/types";+import { ConnectionState } from "@/core/websocket/types";import {DEFAULT_EXPORT_OPTIONS,exportOptionsAtom,@@ -111,7 +111,7 @@ describe("NotebookMenuDropdown", () => {store.set(requestClientAtom, MockRequestClient.create());store.set(filenameAtom, "/project/notebook.py");store.set(viewStateAtom, { mode: "edit", cellAnchor: null });- store.set(connectionAtom, { state: WebSocketState.OPEN });+ store.set(connectionAtom, { state: ConnectionState.OPEN });store.set(kioskModeAtom, false);store.set(layoutStateAtom, {selectedLayout: "vertical",diff --git a/frontend/src/components/editor/header/__tests__/status.test.tsx b/frontend/src/components/editor/header/__tests__/status.test.tsxindex ad8acd215b..09768c7209 100644--- a/frontend/src/components/editor/header/__tests__/status.test.tsx+++ b/frontend/src/components/editor/header/__tests__/status.test.tsx@@ -10,7 +10,7 @@ import { viewStateAtom } from "@/core/mode";import {type ConnectionStatus,WebSocketClosedReason,- WebSocketState,+ ConnectionState,} from "@/core/websocket/types";import { StatusOverlay } from "../status";@@ -40,7 +40,7 @@ describe("StatusOverlay disconnect indicator", () => {const onReconnect = vi.fn();const { getByTestId } = renderOverlay({- state: WebSocketState.CLOSED,+ state: ConnectionState.CLOSED,code: WebSocketClosedReason.KERNEL_DISCONNECTED,reason: "kernel not found",},@@ -57,7 +57,7 @@ describe("StatusOverlay disconnect indicator", () => {it("renders a disabled button when no onReconnect is provided", () => {const { getByTestId } = renderOverlay({- state: WebSocketState.CLOSED,+ state: ConnectionState.CLOSED,code: WebSocketClosedReason.KERNEL_DISCONNECTED,reason: "kernel not found",});@@ -68,7 +68,7 @@ describe("StatusOverlay disconnect indicator", () => {it("leaves editor startup failures to the inline notice", () => {const { queryByTestId } = renderOverlay({- state: WebSocketState.CLOSED,+ state: ConnectionState.CLOSED,code: WebSocketClosedReason.KERNEL_STARTUP_ERROR,reason: "Failed to start kernel sandbox",});diff --git a/frontend/src/components/editor/header/app-header.tsx b/frontend/src/components/editor/header/app-header.tsxindex 4d34874378..033dc8d574 100644--- a/frontend/src/components/editor/header/app-header.tsx+++ b/frontend/src/components/editor/header/app-header.tsx@@ -1,7 +1,7 @@/* Copyright 2026 Marimo. All rights reserved. */import React, { type PropsWithChildren } from "react";-import { type ConnectionStatus, WebSocketState } from "@/core/websocket/types";+import { type ConnectionStatus, ConnectionState } from "@/core/websocket/types";import { Disconnected } from "../Disconnected";interface Props {@@ -17,7 +17,7 @@ export const AppHeader: React.FC<PropsWithChildren<Props>> = ({return (<div className={className}>{children}- {connection.state === WebSocketState.CLOSED && (+ {connection.state === ConnectionState.CLOSED && (<Disconnected reason={connection.reason} />)}</div>diff --git a/frontend/src/components/editor/header/status.tsx b/frontend/src/components/editor/header/status.tsxindex 1471bd01c2..3a3da00157 100644--- a/frontend/src/components/editor/header/status.tsx+++ b/frontend/src/components/editor/header/status.tsx@@ -10,7 +10,7 @@ import { viewStateAtom } from "@/core/mode";import {type ConnectionStatus,WebSocketClosedReason,- WebSocketState,+ ConnectionState,} from "@/core/websocket/types";import { cn } from "@/utils/cn";@@ -21,10 +21,10 @@ export const StatusOverlay: React.FC<{}> = ({ connection, isRunning, onReconnect }) => {const { mode } = useAtomValue(viewStateAtom);const isClosed =- connection.state === WebSocketState.CLOSED &&+ connection.state === ConnectionState.CLOSED &&(mode === "read" ||connection.code !== WebSocketClosedReason.KERNEL_STARTUP_ERROR);- const isOpen = connection.state === WebSocketState.OPEN;+ const isOpen = connection.state === ConnectionState.OPEN;// Editor startup failures have their own recovery UI.const canReconnect =isClosed && connection.code === WebSocketClosedReason.KERNEL_DISCONNECTED;diff --git a/frontend/src/core/codemirror/readonly/__tests__/extension.test.ts b/frontend/src/core/codemirror/readonly/__tests__/extension.test.tsindex 491b36dc02..8920eb7c54 100644--- a/frontend/src/core/codemirror/readonly/__tests__/extension.test.ts+++ b/frontend/src/core/codemirror/readonly/__tests__/extension.test.ts@@ -4,12 +4,12 @@ import { EditorState } from "@codemirror/state";import { EditorView } from "@codemirror/view";import { createStore } from "jotai";import { describe, expect, it } from "vitest";-import { WebSocketState } from "@/core/websocket/types";+import { ConnectionState } from "@/core/websocket/types";import { connectionAtom } from "../../../network/connection";import { dynamicReadonly, isEditorReadonly } from "../extension";function makeStoreWithConnection(- state: typeof WebSocketState.CONNECTING | typeof WebSocketState.OPEN,+ state: typeof ConnectionState.CONNECTING | typeof ConnectionState.OPEN,) {const store = createStore();store.set(connectionAtom, { state });@@ -18,7 +18,7 @@ function makeStoreWithConnection(describe("dynamicReadonly", () => {it("should be readonly when connection is not OPEN", () => {- const store = makeStoreWithConnection(WebSocketState.CONNECTING);+ const store = makeStoreWithConnection(ConnectionState.CONNECTING);const state = EditorState.create({doc: "test",extensions: [dynamicReadonly(store)],@@ -27,7 +27,7 @@ describe("dynamicReadonly", () => {});it("should be editable when connection is OPEN", async () => {- const store = makeStoreWithConnection(WebSocketState.OPEN);+ const store = makeStoreWithConnection(ConnectionState.OPEN);const state = EditorState.create({doc: "test",extensions: [dynamicReadonly(store)],@@ -37,7 +37,7 @@ describe("dynamicReadonly", () => {});it("should toggle readonly when connection state changes", () => {- const store = makeStoreWithConnection(WebSocketState.CONNECTING);+ const store = makeStoreWithConnection(ConnectionState.CONNECTING);const state = EditorState.create({doc: "test",extensions: [dynamicReadonly(store)],@@ -45,7 +45,7 @@ describe("dynamicReadonly", () => {const view = new EditorView({ state });expect(isEditorReadonly(state)).toBe(true);// Simulate connection opening- store.set(connectionAtom, { state: WebSocketState.OPEN });+ store.set(connectionAtom, { state: ConnectionState.OPEN });// The extension uses a plugin to update the state, so we need to create a view to trigger itview.requestMeasure();// The state should now be editablediff --git a/frontend/src/core/codemirror/readonly/extension.ts b/frontend/src/core/codemirror/readonly/extension.tsindex 73f766df04..ef186e500c 100644--- a/frontend/src/core/codemirror/readonly/extension.ts+++ b/frontend/src/core/codemirror/readonly/extension.ts@@ -7,7 +7,7 @@ import {isAppConnecting,} from "@/core/websocket/connection-utils";import { connectionAtom } from "../../network/connection";-import { WebSocketState } from "../../websocket/types";+import { ConnectionState } from "../../websocket/types";/*** State effect for updating readonly status based on connection@@ -111,7 +111,7 @@ export function dynamicReadonly(store: ReturnType<typeof createStore>) {// Subscribe to connectionAtom and manage listenersconst unsubscribe = store.sub(connectionAtom, () => {const connection = store.get(connectionAtom);- if (connection.state === WebSocketState.CONNECTING) {+ if (connection.state === ConnectionState.CONNECTING) {attachListeners();} else {detachListeners();diff --git a/frontend/src/core/datasets/__tests__/data-source-discovery.test.ts b/frontend/src/core/datasets/__tests__/data-source-discovery.test.tsindex 109074542b..9179da439c 100644--- a/frontend/src/core/datasets/__tests__/data-source-discovery.test.ts+++ b/frontend/src/core/datasets/__tests__/data-source-discovery.test.ts@@ -2,7 +2,7 @@import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";import { connectionAtom } from "@/core/network/connection";import { store } from "@/core/state/jotai";-import { WebSocketState } from "@/core/websocket/types";+import { ConnectionState } from "@/core/websocket/types";import {fetchDataSourceDiscovery,invalidateDataSourceDiscovery,@@ -30,7 +30,7 @@ describe("fetchDataSourceDiscovery", () => {beforeEach(() => {// Discovery waits for the session's websocket connection to be open// before requesting, so it doesn't race a still-connecting session.- store.set(connectionAtom, { state: WebSocketState.OPEN });+ store.set(connectionAtom, { state: ConnectionState.OPEN });});afterEach(() => {diff --git a/frontend/src/core/export/hooks.ts b/frontend/src/core/export/hooks.tsindex 652ea79f1c..3606dddc6b 100644--- a/frontend/src/core/export/hooks.ts+++ b/frontend/src/core/export/hooks.ts@@ -16,7 +16,7 @@ import { connectionAtom } from "../network/connection";import { useRequestClient } from "../network/requests";import type { UpdateCellOutputsRequest } from "../network/types";import { VirtualFileTracker } from "../static/virtual-file-tracker";-import { WebSocketState } from "../websocket/types";+import { ConnectionState } from "../websocket/types";const DELAY = 5000; // 5 seconds;@@ -28,7 +28,7 @@ export function useAutoExport() {const htmlEnabled = appConfig.auto_download.includes("html");const ipynbEnabled = appConfig.auto_download.includes("ipynb");- const isConnected = state === WebSocketState.OPEN;+ const isConnected = state === ConnectionState.OPEN;const markdownDisabled = !markdownEnabled || !isConnected;const htmlDisabled = !htmlEnabled || !isConnected;const ipynbDisabled = !ipynbEnabled || !isConnected;diff --git a/frontend/src/core/network/__tests__/connection.test.ts b/frontend/src/core/network/__tests__/connection.test.tsindex af471d9e14..7d532b9693 100644--- a/frontend/src/core/network/__tests__/connection.test.ts+++ b/frontend/src/core/network/__tests__/connection.test.ts@@ -3,7 +3,7 @@import { afterEach, describe, expect, it } from "vitest";import { initialModeAtom } from "@/core/mode";import { store } from "@/core/state/jotai";-import { WebSocketState } from "../../websocket/types";+import { ConnectionState } from "../../websocket/types";import { connectionAtom, waitForConnectionOpenIfNotebook } from "../connection";const NEVER = Symbol("never");@@ -20,7 +20,7 @@ function settledOrNever(promise: Promise<unknown>) {describe("waitForConnectionOpenIfNotebook", () => {afterEach(() => {- store.set(connectionAtom, { state: WebSocketState.NOT_STARTED });+ store.set(connectionAtom, { state: ConnectionState.NOT_STARTED });store.set(initialModeAtom, undefined);});@@ -39,7 +39,7 @@ describe("waitForConnectionOpenIfNotebook", () => {const promise = waitForConnectionOpenIfNotebook();await expect(settledOrNever(promise)).resolves.toBe(NEVER);- store.set(connectionAtom, { state: WebSocketState.OPEN });+ store.set(connectionAtom, { state: ConnectionState.OPEN });await expect(settledOrNever(promise)).resolves.not.toBe(NEVER);});});diff --git a/frontend/src/core/network/connection-notice.ts b/frontend/src/core/network/connection-notice.tsindex 82ef049ea8..dc96120010 100644--- a/frontend/src/core/network/connection-notice.ts+++ b/frontend/src/core/network/connection-notice.ts@@ -5,7 +5,7 @@ import { sandboxAtom, sandboxSyncAtom } from "@/core/packages/sandbox-state";import {type ConnectionPhase,WebSocketClosedReason,- WebSocketState,+ ConnectionState,} from "@/core/websocket/types";import { connectionAtom } from "./connection";@@ -37,7 +37,7 @@ export const connectionNoticeAtom = atom<ConnectionNotice | null>((get) => {if (sandbox &&(syncing || syncError !== null) &&- connection.state === WebSocketState.OPEN+ connection.state === ConnectionState.OPEN) {return {kind: "sync",@@ -56,7 +56,7 @@ export const connectionNoticeAtom = atom<ConnectionNotice | null>((get) => {error: syncError,};}- if (connection.state === WebSocketState.CONNECTING) {+ if (connection.state === ConnectionState.CONNECTING) {const messages = {"preparing-environment": {title: "Preparing environment…",@@ -88,7 +88,7 @@ export const connectionNoticeAtom = atom<ConnectionNotice | null>((get) => {error: null,};}- if (connection.state === WebSocketState.CLOSED) {+ if (connection.state === ConnectionState.CLOSED) {const startupFailed =connection.code === WebSocketClosedReason.KERNEL_STARTUP_ERROR;const environmentFailed =diff --git a/frontend/src/core/network/connection.ts b/frontend/src/core/network/connection.tsindex 27c8c79e9b..4d0e7e61e7 100644--- a/frontend/src/core/network/connection.ts+++ b/frontend/src/core/network/connection.ts@@ -4,14 +4,14 @@ import { atomWithReducer } from "jotai/utils";import type { NotificationMessageData } from "../kernel/messages";import { isNotebookPage } from "../mode";import { waitFor } from "../state/jotai";-import { type ConnectionStatus, WebSocketState } from "../websocket/types";+import { type ConnectionStatus, ConnectionState } from "../websocket/types";/*** Atom for storing the connection status.* Initialized to NOT_STARTED.*/export const connectionAtom = atom<ConnectionStatus>({- state: WebSocketState.NOT_STARTED,+ state: ConnectionState.NOT_STARTED,});type StartupProgress = NotificationMessageData<"startup-progress">;@@ -33,7 +33,7 @@ export const startupProgressAtom = atomWithReducer<export function waitForConnectionOpen() {return waitFor(connectionAtom, (value) => {- return value.state === WebSocketState.OPEN;+ return value.state === ConnectionState.OPEN;});}@@ -53,28 +53,28 @@ export function waitForConnectionOpenIfNotebook() {export const isConnectingAtom = atom((get) => {const connection = get(connectionAtom);- return connection.state === WebSocketState.CONNECTING;+ return connection.state === ConnectionState.CONNECTING;});export const isConnectedAtom = atom((get) => {const connection = get(connectionAtom);- return connection.state === WebSocketState.OPEN;+ return connection.state === ConnectionState.OPEN;});export const canInteractWithAppAtom = atom((get) => {const connection = get(connectionAtom);return (- connection.state === WebSocketState.OPEN ||- connection.state === WebSocketState.NOT_STARTED+ connection.state === ConnectionState.OPEN ||+ connection.state === ConnectionState.NOT_STARTED);});export const isClosedAtom = atom((get) => {const connection = get(connectionAtom);- return connection.state === WebSocketState.CLOSED;+ return connection.state === ConnectionState.CLOSED;});export const isNotStartedAtom = atom((get) => {const connection = get(connectionAtom);- return connection.state === WebSocketState.NOT_STARTED;+ return connection.state === ConnectionState.NOT_STARTED;});diff --git a/frontend/src/core/network/requests-lazy.ts b/frontend/src/core/network/requests-lazy.tsindex 25ac2c2d64..dbbac0619e 100644--- a/frontend/src/core/network/requests-lazy.ts+++ b/frontend/src/core/network/requests-lazy.ts@@ -7,7 +7,7 @@ import { memoizeLastValue } from "@/utils/once";import { waitForKernelToBeInstantiated } from "../kernel/state";import type { RuntimeManager } from "../runtime/runtime";import { store } from "../state/jotai";-import { WebSocketState } from "../websocket/types";+import { ConnectionState } from "../websocket/types";import { connectionAtom, waitForConnectionOpen } from "./connection";import type { EditRequests, RunRequests } from "./types";@@ -159,7 +159,7 @@ export function createLazyRequests(): AllRequests {// Memoize the init call, just once per runtime managerconst initOnce = memoizeLastValue(async (runtimeManager: RuntimeManager) => {- store.set(connectionAtom, { state: WebSocketState.CONNECTING });+ store.set(connectionAtom, { state: ConnectionState.CONNECTING });await runtimeManager.init();});diff --git a/frontend/src/core/packages/__tests__/useSandboxController.test.tsx b/frontend/src/core/packages/__tests__/useSandboxController.test.tsxindex 4681520f75..9e132b4da8 100644--- a/frontend/src/core/packages/__tests__/useSandboxController.test.tsx+++ b/frontend/src/core/packages/__tests__/useSandboxController.test.tsx@@ -17,7 +17,7 @@ import type {} from "@/core/network/types";import { filenameAtom } from "@/core/saving/file-state";import { store } from "@/core/state/jotai";-import { WebSocketState } from "@/core/websocket/types";+import { ConnectionState } from "@/core/websocket/types";import { HTTPError } from "@/utils/errors";import { packageDataVersionAtom } from "../package-data";import {@@ -52,7 +52,7 @@ beforeEach(() => {store.set(sandboxAtom, null);store.set(sandboxSyncAtom, { kind: "succeeded" });store.set(sandboxActionsAtom, null);- store.set(connectionAtom, { state: WebSocketState.OPEN });+ store.set(connectionAtom, { state: ConnectionState.OPEN });store.set(kernelStartupErrorAtom, null);store.set(filenameAtom, "notebook.py");store.set(packageDataVersionAtom, 0);diff --git a/frontend/src/core/packages/useSandboxController.ts b/frontend/src/core/packages/useSandboxController.tsindex 4195359838..fc39164ae8 100644--- a/frontend/src/core/packages/useSandboxController.ts+++ b/frontend/src/core/packages/useSandboxController.ts@@ -8,7 +8,7 @@ import { useRequestClient } from "@/core/network/requests";import { useFilename } from "@/core/saving/filename";import { waitFor } from "@/core/state/jotai";import { isWasm } from "@/core/wasm/utils";-import { WebSocketState } from "@/core/websocket/types";+import { ConnectionState } from "@/core/websocket/types";import { HTTPError, prettyError } from "@/utils/errors";import { invalidatePackageData } from "./package-data";import {@@ -67,7 +67,7 @@ export function useSandboxController(onReconnect: () => Promise<void>) {if (inFlight.current ||operation.kind === "running" ||- connection.state === WebSocketState.CONNECTING+ connection.state === ConnectionState.CONNECTING) {return false;}@@ -91,10 +91,10 @@ export function useSandboxController(onReconnect: () => Promise<void>) {const status = await waitFor(connectionAtom,(value) =>- value.state === WebSocketState.OPEN ||- value.state === WebSocketState.CLOSED,+ value.state === ConnectionState.OPEN ||+ value.state === ConnectionState.CLOSED,);- if (status.state === WebSocketState.CLOSED) {+ if (status.state === ConnectionState.CLOSED) {setOperation({ kind: "idle" });return false;}@@ -177,7 +177,7 @@ export function useSandboxController(onReconnect: () => Promise<void>) {saving ||loading ||operation.kind === "running" ||- connection.state === WebSocketState.CONNECTING;+ connection.state === ConnectionState.CONNECTING;const diagnostic =error ??(operation.kind === "failed"diff --git a/frontend/src/core/runtime/__tests__/adapter.test.ts b/frontend/src/core/runtime/__tests__/adapter.test.tsindex 0b7b83ea27..78d550e9b7 100644--- a/frontend/src/core/runtime/__tests__/adapter.test.ts+++ b/frontend/src/core/runtime/__tests__/adapter.test.ts@@ -6,7 +6,7 @@ import { islandsInitializedAtom } from "../../islands/state";import { kernelStateAtom } from "../../kernel/state";import { connectionAtom } from "../../network/connection";import { wasmInitStateAtom } from "../../wasm/state";-import { WebSocketState } from "../../websocket/types";+import { ConnectionState } from "../../websocket/types";import {canRunCellsAtom,islandsAdapter,@@ -50,13 +50,13 @@ describe("wasmAdapter", () => {describe("remoteAdapter", () => {it.each([- [{ state: WebSocketState.OPEN }, { kind: "ready" }],+ [{ state: ConnectionState.OPEN }, { kind: "ready" }],[- { state: WebSocketState.CONNECTING },+ { state: ConnectionState.CONNECTING },{ kind: "connecting", progress: { label: "Connecting…" } },],[- { state: WebSocketState.NOT_STARTED },+ { state: ConnectionState.NOT_STARTED },{ kind: "connecting", progress: { label: "Not connected" } },],] as const)("maps %j to %j", (conn, expected) => {@@ -68,7 +68,7 @@ describe("remoteAdapter", () => {it("surfaces the close reason when closed", () => {const store = createStore();store.set(connectionAtom, {- state: WebSocketState.CLOSED,+ state: ConnectionState.CLOSED,code: "KERNEL_DISCONNECTED",reason: "Kernel went away",});@@ -125,7 +125,7 @@ describe("canRunCellsAtom", () => {it("is false on a remote adapter until kernel acks", () => {const store = createStore();// Default adapter in test env is remote.- store.set(connectionAtom, { state: WebSocketState.OPEN });+ store.set(connectionAtom, { state: ConnectionState.OPEN });expect(store.get(canRunCellsAtom)).toBe(false);store.set(kernelStateAtom, { isInstantiated: true, error: null });diff --git a/frontend/src/core/runtime/adapter.ts b/frontend/src/core/runtime/adapter.tsindex 759ed42906..64b86ae64e 100644--- a/frontend/src/core/runtime/adapter.ts+++ b/frontend/src/core/runtime/adapter.ts@@ -8,7 +8,7 @@ import { connectionAtom } from "../network/connection";import { isStaticNotebook } from "../static/static-state";import { wasmInitStateAtom } from "../wasm/state";import { isWasm } from "../wasm/utils";-import { WebSocketState } from "../websocket/types";+import { ConnectionState } from "../websocket/types";export type RuntimeKind = "wasm" | "remote" | "static" | "islands";@@ -76,19 +76,19 @@ export const wasmAdapter: RuntimeAdapter = {const remoteStateAtom = atom<AdapterState>((get) => {const conn = get(connectionAtom);switch (conn.state) {- case WebSocketState.OPEN:+ case ConnectionState.OPEN:return { kind: "ready" };- case WebSocketState.CONNECTING:+ case ConnectionState.CONNECTING:return { kind: "connecting", progress: { label: "Connecting…" } };- case WebSocketState.NOT_STARTED:+ case ConnectionState.NOT_STARTED:return { kind: "connecting", progress: { label: "Not connected" } };- case WebSocketState.CLOSING:- case WebSocketState.CLOSED:+ case ConnectionState.CLOSING:+ case ConnectionState.CLOSED:return {kind: "failed",error: {message:- conn.state === WebSocketState.CLOSED+ conn.state === ConnectionState.CLOSED? conn.reason: "Disconnecting",errorKind: "runtime",diff --git a/frontend/src/core/runtime/config.ts b/frontend/src/core/runtime/config.tsindex e849a5d01d..9e30f0808d 100644--- a/frontend/src/core/runtime/config.ts+++ b/frontend/src/core/runtime/config.ts@@ -5,7 +5,7 @@ import { Logger } from "@/utils/Logger";import { connectionAtom } from "../network/connection";import { store } from "../state/jotai";import { isAppNotStarted } from "../websocket/connection-utils";-import { WebSocketState } from "../websocket/types";+import { ConnectionState } from "../websocket/types";import { RuntimeManager } from "./runtime";import type { RuntimeConfig } from "./types";@@ -36,7 +36,7 @@ export function useConnectToRuntime(): () => Promise<void> {const [connection, setConnection] = useAtom(connectionAtom);return useEvent(async () => {if (isAppNotStarted(connection.state)) {- setConnection({ state: WebSocketState.CONNECTING });+ setConnection({ state: ConnectionState.CONNECTING });await runtimeManager.init();} else {Logger.log("Runtime already started or starting...");diff --git a/frontend/src/core/saving/filename.ts b/frontend/src/core/saving/filename.tsindex 55f592396d..26a773c42a 100644--- a/frontend/src/core/saving/filename.ts+++ b/frontend/src/core/saving/filename.ts@@ -9,7 +9,7 @@ import { getAppConfig } from "../config/config";import { KnownQueryParams } from "../constants";import { connectionAtom } from "../network/connection";import { useRequestClient } from "../network/requests";-import { WebSocketState } from "../websocket/types";+import { ConnectionState } from "../websocket/types";import { filenameAtom } from "./file-state";export function useFilename() {@@ -24,7 +24,7 @@ export function useUpdateFilename() {const handleFilenameChange = useEvent(async (name: string) => {const appConfig = getAppConfig();- if (connection.state !== WebSocketState.OPEN) {+ if (connection.state !== ConnectionState.OPEN) {openAlert("Failed to save notebook: not connected to a kernel.");return null;}diff --git a/frontend/src/core/saving/save-component.tsx b/frontend/src/core/saving/save-component.tsxindex bd16417afd..eb776652d2 100644--- a/frontend/src/core/saving/save-component.tsx+++ b/frontend/src/core/saving/save-component.tsx@@ -31,7 +31,7 @@ import { layoutStateAtom } from "../layout/state";import { kioskModeAtom } from "../mode";import { connectionAtom } from "../network/connection";import { useRequestClient } from "../network/requests";-import { WebSocketState } from "../websocket/types";+import { ConnectionState } from "../websocket/types";import { filenameAtom } from "./file-state";import { useFilename, useUpdateFilename } from "./filename";import { lastSavedNotebookAtom, needsSaveAtom } from "./state";@@ -55,7 +55,7 @@ export function enqueueNotebookSave<T>(save: () => Promise<T>): Promise<T> {export const SaveComponent = ({ kioskMode }: SaveNotebookProps) => {const filename = useFilename();const needsSave = useAtomValue(needsSaveAtom);- const closed = useAtomValue(connectionAtom).state === WebSocketState.CLOSED;+ const closed = useAtomValue(connectionAtom).state === ConnectionState.CLOSED;const { saveOrNameNotebook, saveIfNotebookIsPersistent } = useSaveNotebook();useAutoSaveNotebook({ onSave: saveIfNotebookIsPersistent, kioskMode });@@ -120,7 +120,7 @@ export function useSaveNotebook() {}// Don't save if we are not connected to a kernel- if (connection.state !== WebSocketState.OPEN) {+ if (connection.state !== ConnectionState.OPEN) {openAlert("Failed to save notebook: not connected to a kernel.");return;}@@ -168,7 +168,7 @@ export function useSaveNotebook() {const connection = store.get(connectionAtom);if (isNamedPersistentFile(filename) &&- connection.state === WebSocketState.OPEN+ connection.state === ConnectionState.OPEN) {saveNotebook(filename, userInitiated);}@@ -191,7 +191,7 @@ export function useSaveNotebook() {// Filename does not exist and we are connected to a kernelif (!isNamedPersistentFile(filename) &&- connection.state !== WebSocketState.CLOSED+ connection.state !== ConnectionState.CLOSED) {openModal(<SaveDialog onClose={closeModal} onSave={handleSaveDialog} />);}diff --git a/frontend/src/core/saving/useAutoSave.ts b/frontend/src/core/saving/useAutoSave.tsindex 3589d562fe..4a42752ad2 100644--- a/frontend/src/core/saving/useAutoSave.ts+++ b/frontend/src/core/saving/useAutoSave.ts@@ -2,7 +2,7 @@import { useEffect, useRef } from "react";import type { UserConfig } from "../config/config-schema";import type { CellConfig } from "../network/types";-import { type ConnectionStatus, WebSocketState } from "../websocket/types";+import { type ConnectionStatus, ConnectionState } from "../websocket/types";export function useAutoSave(opts: {codes: string[];@@ -43,7 +43,7 @@ export function useAutoSave(opts: {clearTimeout(autosaveTimeoutId.current);}- if (needsSave && connStatus.state === WebSocketState.OPEN) {+ if (needsSave && connStatus.state === ConnectionState.OPEN) {autosaveTimeoutId.current = setTimeout(onSave, config.autosave_delay);}}diff --git a/frontend/src/core/websocket/__tests__/useMarimoKernelConnection.hook.test.tsx b/frontend/src/core/websocket/__tests__/useMarimoKernelConnection.hook.test.tsxindex d98e8160d5..8a1e7b4021 100644--- a/frontend/src/core/websocket/__tests__/useMarimoKernelConnection.hook.test.tsx+++ b/frontend/src/core/websocket/__tests__/useMarimoKernelConnection.hook.test.tsx@@ -52,7 +52,7 @@ import { useRuntimeManager } from "@/core/runtime/config";import { initialRunCompletedAtom } from "../../kernel/state";import { connectionAtom, startupProgressAtom } from "../../network/connection";import type { SessionId } from "../../kernel/session";-import { WebSocketClosedReason, WebSocketState } from "../types";+import { WebSocketClosedReason, ConnectionState } from "../types";import type { IConnectionTransport } from "../transports/transport";import { useMarimoKernelConnection } from "../useMarimoKernelConnection";import { useConnectionTransport } from "../useWebSocket";@@ -118,7 +118,7 @@ describe("useMarimoKernelConnection.reconnect()", () => {isHealthy = vi.fn<() => Promise<boolean>>().mockResolvedValue(true);store = createStore();store.set(connectionAtom, {- state: WebSocketState.CLOSED,+ state: ConnectionState.CLOSED,code: WebSocketClosedReason.KERNEL_DISCONNECTED,reason: "kernel not found",});@@ -163,7 +163,7 @@ describe("useMarimoKernelConnection.reconnect()", () => {expect(isHealthy).toHaveBeenCalledOnce();expect(transport.reconnect).toHaveBeenCalledOnce();expect(store.get(connectionAtom)).toEqual({- state: WebSocketState.CONNECTING,+ state: ConnectionState.CONNECTING,});});@@ -176,7 +176,7 @@ describe("useMarimoKernelConnection.reconnect()", () => {expect(isHealthy).toHaveBeenCalledOnce();expect(transport.reconnect).not.toHaveBeenCalled();expect(store.get(connectionAtom)).toEqual({- state: WebSocketState.CLOSED,+ state: ConnectionState.CLOSED,code: WebSocketClosedReason.KERNEL_DISCONNECTED,reason: "kernel not found",});@@ -215,7 +215,7 @@ it.each(["kernel-ready", "reconnected"])("waits for %s before marking the session connected",async (op) => {const store = createStore();- store.set(connectionAtom, { state: WebSocketState.CONNECTING });+ store.set(connectionAtom, { state: ConnectionState.CONNECTING });vi.mocked(useConnectionTransport).mockClear();vi.mocked(useConnectionTransport).mockReturnValue(makeTransport(WebSocket.OPEN),@@ -229,7 +229,7 @@ it.each(["kernel-ready", "reconnected"])(await act(async () => {await options.onOpen(new Event("open"));});- expect(store.get(connectionAtom).state).toBe(WebSocketState.CONNECTING);+ expect(store.get(connectionAtom).state).toBe(ConnectionState.CONNECTING);act(() => {options.onMessage(@@ -257,7 +257,7 @@ it.each(["kernel-ready", "reconnected"])(}),);});- expect(store.get(connectionAtom).state).toBe(WebSocketState.OPEN);+ expect(store.get(connectionAtom).state).toBe(ConnectionState.OPEN);},);@@ -267,7 +267,7 @@ describe("connection notice", () => {function renderNotice() {const store = createStore();- store.set(connectionAtom, { state: WebSocketState.CONNECTING });+ store.set(connectionAtom, { state: ConnectionState.CONNECTING });const transport = makeTransport(WebSocket.OPEN);vi.mocked(useConnectionTransport).mockReturnValue(transport);vi.mocked(useRuntimeManager).mockReturnValue(@@ -349,7 +349,7 @@ describe("connection notice", () => {act(() => options.onClose(new CloseEvent("close")));act(() => vi.advanceTimersByTime(500));expect(store.get(connectionAtom)).toEqual({- state: WebSocketState.CONNECTING,+ state: ConnectionState.CONNECTING,phase: "reconnecting",});expect(@@ -392,7 +392,7 @@ describe("connection notice", () => {logs: "Kernel startup output\n",log_mode: "replace",});- expect(store.get(connectionAtom)).toEqual({ state: WebSocketState.OPEN });+ expect(store.get(connectionAtom)).toEqual({ state: ConnectionState.OPEN });expect(store.get(startupProgressAtom)).toEqual({phase: "starting-kernel",logs: "Kernel startup output\n",diff --git a/frontend/src/core/websocket/__tests__/useMarimoKernelConnection.test.ts b/frontend/src/core/websocket/__tests__/useMarimoKernelConnection.test.tsindex 59853689b7..842041d1bb 100644--- a/frontend/src/core/websocket/__tests__/useMarimoKernelConnection.test.ts+++ b/frontend/src/core/websocket/__tests__/useMarimoKernelConnection.test.ts@@ -2,7 +2,7 @@import { afterEach, describe, expect, it, vi } from "vitest";import { Logger } from "@/utils/Logger";-import { WebSocketClosedReason, WebSocketState } from "../types";+import { WebSocketClosedReason, ConnectionState } from "../types";import { classifyCloseEvent } from "../useMarimoKernelConnection";function classify(reason: string | undefined) {@@ -14,7 +14,7 @@ describe("classifyCloseEvent", () => {it("retries on empty/undefined reason", () => {const decision = classify(undefined);expect(decision.kind).toBe("retry");- expect(decision.status).toEqual({ state: WebSocketState.CONNECTING });+ expect(decision.status).toEqual({ state: ConnectionState.CONNECTING });});it("treats unknown reason strings as transient and logs a warning", () => {@@ -44,7 +44,7 @@ describe("classifyCloseEvent", () => {const decision = classify(reason);expect(decision.kind).toBe("terminal");expect(decision.status).toMatchObject({- state: WebSocketState.CLOSED,+ state: ConnectionState.CLOSED,code: WebSocketClosedReason.KERNEL_DISCONNECTED,});expect(decision).toMatchObject({@@ -57,7 +57,7 @@ describe("classifyCloseEvent", () => {const decision = classify("MARIMO_KERNEL_STARTUP_ERROR");expect(decision.kind).toBe("terminal");expect(decision.status).toMatchObject({- state: WebSocketState.CLOSED,+ state: ConnectionState.CLOSED,code: WebSocketClosedReason.KERNEL_STARTUP_ERROR,});expect(decision).toMatchObject({@@ -72,7 +72,7 @@ describe("classifyCloseEvent", () => {const decision = classify("MARIMO_TRANSPORT_EXHAUSTED");expect(decision.kind).toBe("gave-up");expect(decision.status).toEqual({- state: WebSocketState.CLOSED,+ state: ConnectionState.CLOSED,code: WebSocketClosedReason.KERNEL_DISCONNECTED,reason: "kernel not found",});diff --git a/frontend/src/core/websocket/connection-utils.ts b/frontend/src/core/websocket/connection-utils.tsindex 7bf3f00caf..69f8912e9d 100644--- a/frontend/src/core/websocket/connection-utils.ts+++ b/frontend/src/core/websocket/connection-utils.ts@@ -1,66 +1,66 @@/* Copyright 2026 Marimo. All rights reserved. */-import { WebSocketState } from "./types";+import { ConnectionState } from "./types";/*** Check if the app is in a closed/disconnected state*/-export function isAppClosed(state: WebSocketState): boolean {- return state === WebSocketState.CLOSED;+export function isAppClosed(state: ConnectionState): boolean {+ return state === ConnectionState.CLOSED;}/*** Check if the app is in a connecting state*/-export function isAppConnecting(state: WebSocketState): boolean {- return state === WebSocketState.CONNECTING;+export function isAppConnecting(state: ConnectionState): boolean {+ return state === ConnectionState.CONNECTING;}/*** Check if the app is in an open/connected state*/-export function isAppConnected(state: WebSocketState): boolean {- return state === WebSocketState.OPEN;+export function isAppConnected(state: ConnectionState): boolean {+ return state === ConnectionState.OPEN;}/*** Check if the app is in a closing state*/-export function isAppClosing(state: WebSocketState): boolean {- return state === WebSocketState.CLOSING;+export function isAppClosing(state: ConnectionState): boolean {+ return state === ConnectionState.CLOSING;}/*** Check if the app is in a not started state*/-export function isAppNotStarted(state: WebSocketState): boolean {- return state === WebSocketState.NOT_STARTED;+export function isAppNotStarted(state: ConnectionState): boolean {+ return state === ConnectionState.NOT_STARTED;}/*** Check if the app is in a state where user interactions should be disabled*/-export function isAppInteractionDisabled(state: WebSocketState): boolean {+export function isAppInteractionDisabled(state: ConnectionState): boolean {return (- state === WebSocketState.CLOSED ||- state === WebSocketState.CLOSING ||- state === WebSocketState.CONNECTING+ state === ConnectionState.CLOSED ||+ state === ConnectionState.CLOSING ||+ state === ConnectionState.CONNECTING);}/*** Get a human-readable tooltip message for the connection state*/-export function getConnectionTooltip(state: WebSocketState): string {+export function getConnectionTooltip(state: ConnectionState): string {switch (state) {- case WebSocketState.CLOSED:+ case ConnectionState.CLOSED:return "App disconnected";- case WebSocketState.CONNECTING:+ case ConnectionState.CONNECTING:return "Connecting to a runtime ...";- case WebSocketState.CLOSING:+ case ConnectionState.CLOSING:return "App disconnecting...";- case WebSocketState.OPEN:+ case ConnectionState.OPEN:return "";- case WebSocketState.NOT_STARTED:+ case ConnectionState.NOT_STARTED:return "Click to connect to a runtime";default:return "";diff --git a/frontend/src/core/websocket/types.ts b/frontend/src/core/websocket/types.tsindex 09a67d6e90..ec7c6f2903 100644--- a/frontend/src/core/websocket/types.ts+++ b/frontend/src/core/websocket/types.ts@@ -6,8 +6,7 @@ export type ConnectionPhase =| NotificationMessageData<"startup-progress">["phase"]| "reconnecting";-// TODO: rename to ConnectionState-export const WebSocketState = {+export const ConnectionState = {NOT_STARTED: "NOT_STARTED",CONNECTING: "CONNECTING",OPEN: "OPEN",@@ -15,8 +14,8 @@ export const WebSocketState = {CLOSED: "CLOSED",} as const;-export type WebSocketState =- (typeof WebSocketState)[keyof typeof WebSocketState];+export type ConnectionState =+ (typeof ConnectionState)[keyof typeof ConnectionState];export const WebSocketClosedReason = {KERNEL_DISCONNECTED: "KERNEL_DISCONNECTED",@@ -28,7 +27,7 @@ export type WebSocketClosedReason =export type ConnectionStatus =| {- state: typeof WebSocketState.CLOSED;+ state: typeof ConnectionState.CLOSED;code: WebSocketClosedReason;/*** Human-readable reason for closing the connection.@@ -37,12 +36,12 @@ export type ConnectionStatus =phase?: ConnectionPhase;}| {- state: typeof WebSocketState.CONNECTING;+ state: typeof ConnectionState.CONNECTING;phase?: ConnectionPhase;}| {state:- | typeof WebSocketState.OPEN- | typeof WebSocketState.CLOSING- | typeof WebSocketState.NOT_STARTED;+ | typeof ConnectionState.OPEN+ | typeof ConnectionState.CLOSING+ | typeof ConnectionState.NOT_STARTED;};diff --git a/frontend/src/core/websocket/useMarimoKernelConnection.tsx b/frontend/src/core/websocket/useMarimoKernelConnection.tsxindex 67e11422a5..1897378eb4 100644--- a/frontend/src/core/websocket/useMarimoKernelConnection.tsx+++ b/frontend/src/core/websocket/useMarimoKernelConnection.tsx@@ -84,7 +84,7 @@ import { isWasm } from "../wasm/utils";import {type ConnectionStatus,WebSocketClosedReason,- WebSocketState,+ ConnectionState,} from "./types";const SUPPORTS_LAZY_KERNELS = true;@@ -116,7 +116,7 @@ export function classifyCloseEvent(event: { reason?: string }): CloseDecision {return {kind: "gave-up",status: {- state: WebSocketState.CLOSED,+ state: ConnectionState.CLOSED,code: WebSocketClosedReason.KERNEL_DISCONNECTED,reason: "kernel not found",},@@ -128,7 +128,7 @@ export function classifyCloseEvent(event: { reason?: string }): CloseDecision {return {kind: "terminal",status: {- state: WebSocketState.CLOSED,+ state: ConnectionState.CLOSED,code: WebSocketClosedReason.KERNEL_DISCONNECTED,reason: "kernel not found",},@@ -138,7 +138,7 @@ export function classifyCloseEvent(event: { reason?: string }): CloseDecision {return {kind: "terminal",status: {- state: WebSocketState.CLOSED,+ state: ConnectionState.CLOSED,code: WebSocketClosedReason.KERNEL_DISCONNECTED,reason: "not authorized",},@@ -148,7 +148,7 @@ export function classifyCloseEvent(event: { reason?: string }): CloseDecision {return {kind: "terminal",status: {- state: WebSocketState.CLOSED,+ state: ConnectionState.CLOSED,code: WebSocketClosedReason.KERNEL_DISCONNECTED,reason: "kiosk mode is not available for this session",},@@ -158,7 +158,7 @@ export function classifyCloseEvent(event: { reason?: string }): CloseDecision {return {kind: "terminal",status: {- state: WebSocketState.CLOSED,+ state: ConnectionState.CLOSED,code: WebSocketClosedReason.KERNEL_STARTUP_ERROR,reason: "Failed to start kernel sandbox",},@@ -175,7 +175,7 @@ export function classifyCloseEvent(event: { reason?: string }): CloseDecision {return {kind: "retry",- status: { state: WebSocketState.CONNECTING },+ status: { state: ConnectionState.CONNECTING },};}@@ -256,17 +256,17 @@ export function useMarimoKernelConnection(opts: {const { phase } = msg.data;updateStartupProgress(msg.data);setConnection((previous) =>- previous.state === WebSocketState.OPEN ||- (previous.state === WebSocketState.CONNECTING &&+ previous.state === ConnectionState.OPEN ||+ (previous.state === ConnectionState.CONNECTING &&previous.phase === phase)? previous- : { state: WebSocketState.CONNECTING, phase },+ : { state: ConnectionState.CONNECTING, phase },);return;}case "kernel-ready": {setKernelStartupError(null);- setConnection({ state: WebSocketState.OPEN });+ setConnection({ state: ConnectionState.OPEN });setInitialRunCompleted(Boolean(msg.data.resumed || msg.data.auto_instantiated),);@@ -481,7 +481,7 @@ export function useMarimoKernelConnection(opts: {case "reconnected":setKernelStartupError(null);- setConnection({ state: WebSocketState.OPEN });+ setConnection({ state: ConnectionState.OPEN });return;case "focus-cell":@@ -526,12 +526,12 @@ export function useMarimoKernelConnection(opts: {}shouldTryReconnecting.current = true;setKernelStartupError(null);- setConnection({ state: WebSocketState.CONNECTING });+ setConnection({ state: ConnectionState.CONNECTING });const healthy = await runtimeManager.reconcileFromHealth();if (!healthy) {shouldTryReconnecting.current = false;setConnection({- state: WebSocketState.CLOSED,+ state: ConnectionState.CLOSED,code: WebSocketClosedReason.KERNEL_DISCONNECTED,reason: "kernel not found",});@@ -607,17 +607,17 @@ export function useMarimoKernelConnection(opts: {setConnection((previous) => {const status = decision.status;if (- status.state === WebSocketState.CLOSED &&+ status.state === ConnectionState.CLOSED &&status.code === WebSocketClosedReason.KERNEL_STARTUP_ERROR &&- (previous.state === WebSocketState.CONNECTING ||- previous.state === WebSocketState.CLOSED)+ (previous.state === ConnectionState.CONNECTING ||+ previous.state === ConnectionState.CLOSED)) {return { ...status, phase: previous.phase };}if (- status.state === WebSocketState.CONNECTING &&- (previous.state === WebSocketState.OPEN ||- (previous.state === WebSocketState.CONNECTING &&+ status.state === ConnectionState.CONNECTING &&+ (previous.state === ConnectionState.OPEN ||+ (previous.state === ConnectionState.CONNECTING &&previous.phase === "reconnecting"))) {return { ...status, phase: "reconnecting" };@@ -642,7 +642,7 @@ export function useMarimoKernelConnection(opts: {onError: (e) => {Logger.warn("WebSocket error", e);setConnection({- state: WebSocketState.CLOSED,+ state: ConnectionState.CLOSED,code: WebSocketClosedReason.KERNEL_DISCONNECTED,reason: "kernel not found",});diff --git a/frontend/src/mount.tsx b/frontend/src/mount.tsxindex 77dcfd936b..a4bd3bcf59 100644--- a/frontend/src/mount.tsx+++ b/frontend/src/mount.tsx@@ -62,7 +62,7 @@ import {import { maybeRegisterVSCodeBindings } from "./core/vscode/vscode-bindings";import type { FileStore } from "./core/wasm/store";import { notebookFileStore } from "./core/wasm/store";-import { WebSocketState } from "./core/websocket/types";+import { ConnectionState } from "./core/websocket/types";import {handleWidgetMessage,WIDGET_REGISTRY,@@ -359,7 +359,7 @@ function initStore(options: unknown) {});// If the remote runtime is not lazy, start it in CONNECTINGif (!firstRuntimeConfig.lazy && !isStaticNotebook()) {- store.set(connectionAtom, { state: WebSocketState.CONNECTING });+ store.set(connectionAtom, { state: ConnectionState.CONNECTING });}} else {store.set(runtimeConfigAtom, {diff --git a/frontend/src/stories/cell.stories.tsx b/frontend/src/stories/cell.stories.tsxindex ec06fc0dbd..1e85bf8ddf 100644--- a/frontend/src/stories/cell.stories.tsx+++ b/frontend/src/stories/cell.stories.tsx@@ -14,7 +14,7 @@ import { connectionAtom } from "@/core/network/connection";import { requestClientAtom } from "@/core/network/requests";import { resolveRequestClient } from "@/core/network/resolve";import type { CellConfig } from "@/core/network/types";-import { WebSocketState } from "@/core/websocket/types";+import { ConnectionState } from "@/core/websocket/types";import { MultiColumn } from "@/utils/id-tree";import type { Milliseconds, Seconds } from "@/utils/time";import { Cell as EditorCell } from "../components/editor/notebook-cell";@@ -84,7 +84,7 @@ const Cell: React.FC<{const store = createStore();store.set(notebookAtom, notebook);- store.set(connectionAtom, { state: WebSocketState.OPEN });+ store.set(connectionAtom, { state: ConnectionState.OPEN });store.set(requestClientAtom, resolveRequestClient());return (<Provider store={store}>diff --git a/frontend/src/stories/layout/vertical/one-column.stories.tsx b/frontend/src/stories/layout/vertical/one-column.stories.tsxindex 2757bea578..fba331a7ea 100644--- a/frontend/src/stories/layout/vertical/one-column.stories.tsx+++ b/frontend/src/stories/layout/vertical/one-column.stories.tsx@@ -11,7 +11,7 @@ import { showCodeInRunModeAtom } from "@/core/meta/state";import { connectionAtom } from "@/core/network/connection";import { requestClientAtom } from "@/core/network/requests";import { resolveRequestClient } from "@/core/network/resolve";-import { WebSocketState } from "@/core/websocket/types";+import { ConnectionState } from "@/core/websocket/types";import { MultiColumn } from "@/utils/id-tree";import type { Milliseconds, Seconds } from "@/utils/time";import { CellArray } from "../../../components/editor/renderers/cell-array";@@ -105,7 +105,7 @@ const EditModeCodeShown = () => {const store = createStore();store.set(notebookAtom, notebook);- store.set(connectionAtom, { state: WebSocketState.OPEN });+ store.set(connectionAtom, { state: ConnectionState.OPEN });store.set(requestClientAtom, resolveRequestClient());store.set(showCodeInRunModeAtom, true);@@ -130,7 +130,7 @@ const EditModeCodeHidden = () => {const store = createStore();store.set(notebookAtom, notebook);- store.set(connectionAtom, { state: WebSocketState.OPEN });+ store.set(connectionAtom, { state: ConnectionState.OPEN });store.set(requestClientAtom, resolveRequestClient());store.set(showCodeInRunModeAtom, true);@@ -155,7 +155,7 @@ const ReadModeCodeShown = () => {const store = createStore();store.set(notebookAtom, notebook);- store.set(connectionAtom, { state: WebSocketState.OPEN });+ store.set(connectionAtom, { state: ConnectionState.OPEN });store.set(requestClientAtom, resolveRequestClient());store.set(showCodeInRunModeAtom, true);@@ -174,7 +174,7 @@ const ReadModeCodeHidden = () => {const store = createStore();store.set(notebookAtom, notebook);- store.set(connectionAtom, { state: WebSocketState.OPEN });+ store.set(connectionAtom, { state: ConnectionState.OPEN });store.set(requestClientAtom, resolveRequestClient());store.set(showCodeInRunModeAtom, true);diff --git a/frontend/src/stories/runtime-story.tsx b/frontend/src/stories/runtime-story.tsxindex 6e995ac850..1625b52363 100644--- a/frontend/src/stories/runtime-story.tsx+++ b/frontend/src/stories/runtime-story.tsx@@ -30,7 +30,7 @@ import { requestClientAtom } from "@/core/network/requests";import { createStaticRequests } from "@/core/network/requests-static";import { sandboxActionsAtom, sandboxAtom } from "@/core/packages/sandbox-state";import { filenameAtom } from "@/core/saving/file-state";-import { WebSocketClosedReason, WebSocketState } from "@/core/websocket/types";+import { WebSocketClosedReason, ConnectionState } from "@/core/websocket/types";import { HTTPError } from "@/utils/errors";const manifest = `requires-python = ">=3.13"@@ -156,16 +156,16 @@ function LifecycleControls({ backend }: { backend: Props["backend"] }) {store.set(connectionAtom,next === "ready"- ? { state: WebSocketState.OPEN }+ ? { state: ConnectionState.OPEN }: next === "failed"? {- state: WebSocketState.CLOSED,+ state: ConnectionState.CLOSED,code: WebSocketClosedReason.KERNEL_STARTUP_ERROR,phase: "starting-kernel",reason: "Kernel failed to start",}: {- state: WebSocketState.CONNECTING,+ state: ConnectionState.CONNECTING,phase:next === "preparing"? "preparing-environment"@@ -252,7 +252,7 @@ export function RuntimeStory(props: Props) {connectionAtom,props.phase === "preparing" || props.phase === "starting"? {- state: WebSocketState.CONNECTING,+ state: ConnectionState.CONNECTING,phase: props.backend? props.phase === "preparing"? "preparing-environment"@@ -261,12 +261,12 @@ export function RuntimeStory(props: Props) {}: props.phase === "failed"? {- state: WebSocketState.CLOSED,+ state: ConnectionState.CLOSED,code: WebSocketClosedReason.KERNEL_STARTUP_ERROR,reason: "Kernel startup failed",phase: props.backend ? "preparing-environment" : undefined,}- : { state: WebSocketState.OPEN },+ : { state: ConnectionState.OPEN },);state.set(kernelStartupErrorAtom,@@ -411,7 +411,7 @@ export function RuntimeStory(props: Props) {reconnect: false,};}- state.set(connectionAtom, { state: WebSocketState.OPEN });+ state.set(connectionAtom, { state: ConnectionState.OPEN });state.set(kernelStartupErrorAtom, null);return {success: true,@@ -425,7 +425,7 @@ export function RuntimeStory(props: Props) {});const appConfig = AppConfigSchema.parse({ width: "full" });const reconnect = async () => {- store.set(connectionAtom, { state: WebSocketState.OPEN });+ store.set(connectionAtom, { state: ConnectionState.OPEN });};useEffect(() => {if (!props.interactive) {@@ -457,12 +457,12 @@ export function RuntimeStory(props: Props) {log_mode: "replace",});store.set(connectionAtom, {- state: WebSocketState.CONNECTING,+ state: ConnectionState.CONNECTING,phase: "starting-kernel",});}, 3500),setTimeout(- () => store.set(connectionAtom, { state: WebSocketState.OPEN }),+ () => store.set(connectionAtom, { state: ConnectionState.OPEN }),5500,),];