/* Copyright 2026 Marimo. All rights reserved. */ import { ChevronDownIcon, ExternalLinkIcon, InfoIcon, PowerOffIcon, ZapIcon, ZapOffIcon, } from "lucide-react"; import type React from "react"; import { DisableIfOverridden } from "@/components/app-config/is-overridden"; import { DropdownMenu, DropdownMenuContent, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { ExternalLink } from "@/components/ui/links"; import { Switch } from "@/components/ui/switch"; import { Tooltip, TooltipProvider } from "@/components/ui/tooltip"; import { useResolvedMarimoConfig } from "@/core/config/config"; import { useRequestClient } from "@/core/network/requests"; import { isWasm } from "@/core/wasm/utils"; import { cn } from "@/utils/cn"; import { FooterItem } from "../footer-item"; interface RuntimeSettingsProps { className?: string; } export const RuntimeSettings: React.FC = ({ className, }) => { const { saveUserConfig } = useRequestClient(); const [config, setUserConfig] = useResolvedMarimoConfig(); const handleStartupToggle = async (checked: boolean) => { // Send only the changed portion to avoid overwriting other config values await saveUserConfig({ config: { runtime: { auto_instantiate: checked } }, }).then(() => { // Update local state with merged config setUserConfig((prev) => ({ ...prev, runtime: { ...prev.runtime, auto_instantiate: checked }, })); }); }; const handleCellChangeToggle = async (checked: boolean) => { const onCellChange = checked ? "autorun" : "lazy"; // Send only the changed portion to avoid overwriting other config values await saveUserConfig({ config: { runtime: { on_cell_change: onCellChange } }, }).then(() => { // Update local state with merged config setUserConfig((prev) => ({ ...prev, runtime: { ...prev.runtime, on_cell_change: onCellChange }, })); }); }; const handleModuleReloadChange = async ( option: "off" | "lazy" | "autorun", ) => { // Send only the changed portion to avoid overwriting other config values await saveUserConfig({ config: { runtime: { auto_reload: option } }, }).then(() => { // Update local state with merged config setUserConfig((prev) => ({ ...prev, runtime: { ...prev.runtime, auto_reload: option }, })); }); }; // Check if all reactivity is disabled const allReactivityDisabled = !config.runtime.auto_instantiate && config.runtime.on_cell_change === "lazy" && (isWasm() || config.runtime.auto_reload !== "autorun"); return (
{allReactivityDisabled ? ( ) : ( )}
Runtime reactivity Docs
{/* On startup toggle */}
{config.runtime.auto_instantiate ? ( ) : ( )}
On startup Whether to automatically run the notebook on startup
} >
{config.runtime.auto_instantiate ? "autorun" : "lazy"}
{/* On cell change toggle */}
{config.runtime.on_cell_change === "autorun" ? ( ) : ( )}
On cell change Whether to automatically run dependent cells after running a cell
} >
{config.runtime.on_cell_change}
{!isWasm() && ( <> {/* On module change dropdown */}
{config.runtime.auto_reload === "off" && ( )} {config.runtime.auto_reload === "lazy" && ( )} {config.runtime.auto_reload === "autorun" && ( )}
On module change Whether to run affected cells, mark them as stale, or do nothing when an external module is updated
} >
{config.runtime.auto_reload}
{["off", "lazy", "autorun"].map((option) => ( ))}
)}
); };