/* Copyright 2026 Marimo. All rights reserved. */ import { useAtomValue } from "jotai"; import { LoadingEllipsis } from "@/components/icons/loading-ellipsis"; import { Spinner } from "@/components/icons/spinner"; import { Button } from "@/components/ui/button"; import { DelayMount } from "@/components/utils/delay-mount"; import { isClosedAtom, isConnectingAtom, isNotStartedAtom, } from "@/core/network/connection"; import { useConnectToRuntime } from "@/core/runtime/config"; import { Banner } from "@/plugins/impl/common/error-banner"; import { Tooltip } from "../../ui/tooltip"; import { FloatingAlert } from "./floating-alert"; const SHORT_DELAY_MS = 1000; // 1 second const LONG_DELAY_MS = 5000; // 5 seconds export const ConnectingAlert: React.FC = () => { const isConnecting = useAtomValue(isConnectingAtom); const isClosed = useAtomValue(isClosedAtom); if (isConnecting) { const subtleNotification = (
); const longNotification = (

Connecting to a marimo runtime ...

); // This waits for 1 second to show the subtle notification, then shows the long notification after 5 seconds. return (
{longNotification}
); } if (isClosed) { return (

Failed to connect.

); } }; export const NotStartedConnectionAlert: React.FC = () => { const isNotStarted = useAtomValue(isNotStartedAtom); const connectToRuntime = useConnectToRuntime(); if (isNotStarted) { return (

Not connected to a runtime.

); } return null; };